/* Palette (pallete.png): navy #07004D, blue #2D82B7, mint #42E2B8, cream #F3DFBF, coral #EB8A90.
   Navy is the room, cream is the ink, mint means "go / progress", coral means "attention". */

@font-face {
  font-family: "Fredoka";
  src: url("/fonts/fredoka.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --navy: #07004d;
  --navy-2: #110a63;
  --navy-3: #1b1478;
  --line: #2a2390;
  --blue: #2d82b7;
  --mint: #42e2b8;
  --cream: #f3dfbf;
  --coral: #eb8a90;
  --muted: color-mix(in srgb, var(--cream) 62%, var(--navy));
  --radius: 18px;
  --display: "Fredoka", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, #1a2a8a55, transparent 60%), radial-gradient(900px 500px at -10% 110%, #2d82b733, transparent 60%), var(--navy);
  background-attachment: fixed;
  color: var(--cream);
  font:
    16px / 1.45 system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
.display {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
}

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1.05rem;
  margin-bottom: 8px;
}

[hidden] {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.error {
  color: var(--coral);
  min-height: 1.2em;
  margin: 6px 0 0;
}

/* ---------- buttons & inputs ---------- */

.btn {
  font: 600 1rem var(--display);
  border: 0;
  border-radius: 14px;
  padding: 11px 18px;
  background: var(--navy-3);
  color: var(--cream);
  cursor: pointer;
  transition:
    transform 0.08s,
    filter 0.15s,
    background 0.15s;
  min-height: 44px;
}

.btn:hover {
  filter: brightness(1.12);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn.mint {
  background: var(--mint);
  color: var(--navy);
}

.btn.coral {
  background: var(--coral);
  color: var(--navy);
}

.btn.blue {
  background: var(--blue);
  color: #fff;
}

.btn.ghost {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--line);
}

.btn.danger {
  color: var(--coral);
}

.btn.big {
  font-size: 1.15rem;
  padding: 14px 26px;
}

.btn.small {
  padding: 6px 12px;
  min-height: 34px;
  font-size: 0.9rem;
  border-radius: 11px;
}

input,
select {
  font: inherit;
  color: var(--cream);
  background: var(--navy);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  width: 100%;
  min-height: 44px;
}

input:focus-visible,
select:focus-visible,
.btn:focus-visible,
.tile:focus-visible,
.chip:focus-visible,
.tab:focus-visible {
  outline: 3px solid var(--mint);
  outline-offset: 2px;
}

input[type="checkbox"] {
  width: 22px;
  height: 22px;
  min-height: 0;
  accent-color: var(--mint);
}

input[type="range"] {
  accent-color: var(--mint);
  padding: 0;
  border: 0;
  background: none;
}

input.num {
  width: 96px;
  flex: none;
}

label {
  display: block;
  margin: 12px 0 0;
  font-weight: 600;
}

label > input,
label > select,
label > .row {
  margin-top: 6px;
  font-weight: 400;
}

label.inline {
  display: flex;
  gap: 10px;
  align-items: center;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 12px 0 0;
}

legend {
  font-weight: 600;
  padding: 0;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.row.center {
  justify-content: center;
}

.row.between {
  justify-content: space-between;
  margin-top: 16px;
}

.row.wrap {
  flex-wrap: wrap;
}

.stack > * + * {
  margin-top: 10px;
}

/* ---------- lock ---------- */

.lock {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.lock-card {
  width: min(380px, 100%);
  text-align: center;
}

.lock-card h1 {
  font-size: 2.6rem;
}

.lock-card .sub {
  color: var(--muted);
  margin: 4px 0 24px;
}

.lock-card form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.logo {
  width: 84px;
  height: 84px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: conic-gradient(var(--mint) 0 25%, var(--blue) 0 50%, var(--cream) 0 75%, var(--coral) 0);
  box-shadow: 0 0 40px #42e2b855;
  animation: spin-slow 14s linear infinite;
}

@keyframes spin-slow {
  to {
    transform: rotate(1turn);
  }
}

/* ---------- layout ---------- */

.view {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
}

.card {
  background: color-mix(in srgb, var(--navy-2) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 22px 2px 10px;
}

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--navy) 92%, black);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}

.tab {
  background: none;
  border: 0;
  color: var(--muted);
  font: 600 0.8rem var(--display);
  padding: 8px 0 10px;
  min-height: 56px;
  display: grid;
  justify-items: center;
  gap: 2px;
  cursor: pointer;
}

.tab .ti {
  font-size: 1.25rem;
  line-height: 1;
}

.tab[aria-current="page"] {
  color: var(--mint);
}

/* ---------- score ---------- */

.score-card {
  background: linear-gradient(135deg, #2d82b740, #42e2b822 60%, transparent), var(--navy-2);
}

.score-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.score-num {
  font: 700 3.2rem / 1 var(--display);
  color: var(--cream);
}

.score-num small {
  font-size: 1rem;
  color: var(--muted);
  font-weight: 500;
  margin-left: 4px;
}

.score-meta {
  text-align: right;
  color: var(--muted);
  font-size: 0.92rem;
}

.score-meta b {
  color: var(--cream);
}

.bar {
  position: relative;
  height: 14px;
  border-radius: 99px;
  background: var(--navy);
  margin: 14px 0 6px;
  overflow: hidden;
}

.bar > span {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--blue), var(--mint));
  transition: width 0.6s ease;
}

.bar.won > span {
  background: linear-gradient(90deg, var(--mint), var(--cream), var(--coral));
  box-shadow: 0 0 18px #42e2b8aa;
}

.goal-line {
  font-family: var(--display);
  font-weight: 500;
}

.goal-line.won {
  color: var(--mint);
}

.spark {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 46px;
  margin-top: 12px;
}

.spark > div {
  flex: 1;
  position: relative;
  height: 100%;
}

.spark .s-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: 4px 4px 2px 2px;
  background: var(--blue);
  min-height: 2px;
}

.spark .s-bar.won {
  background: var(--mint);
}

.spark .s-bar.today {
  outline: 2px solid var(--cream);
  outline-offset: 1px;
}

.spark .s-goal {
  position: absolute;
  left: -1px;
  right: -1px;
  height: 2px;
  background: var(--coral);
  opacity: 0.8;
}

/* ---------- running timer ---------- */

.timer-card {
  border-left: 8px solid var(--task, var(--mint));
}

.timer-name {
  font: 600 1.5rem var(--display);
}

.timer-clock {
  font: 700 2.6rem / 1.1 var(--display);
  font-variant-numeric: tabular-nums;
  margin: 4px 0;
}

.checkin-due {
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 10px #eb8a9033;
  }
}

.banner {
  background: color-mix(in srgb, var(--coral) 18%, var(--navy-2));
  border: 1px solid var(--coral);
}

/* ---------- task tiles ---------- */

.pick-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 2px 12px;
}

.spin-btn {
  display: flex;
  gap: 8px;
  align-items: center;
}

.spin-btn .mini-wheel {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: conic-gradient(var(--navy) 0 25%, var(--blue) 0 50%, var(--cream) 0 75%, var(--coral) 0);
}

.spin-btn:hover .mini-wheel {
  animation: spin-slow 1s linear infinite;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.tile {
  position: relative;
  text-align: left;
  background: var(--navy-2);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 12px 12px 10px;
  color: var(--cream);
  cursor: pointer;
  min-height: 92px;
  font: inherit;
  transition:
    transform 0.1s,
    border-color 0.15s;
}

.tile:hover {
  border-color: var(--task);
  transform: translateY(-2px);
}

.tile.on {
  border-color: var(--task);
  background: color-mix(in srgb, var(--task) 16%, var(--navy-2));
}

.tile .t-name {
  font: 600 1.05rem var(--display);
  display: flex;
  gap: 8px;
  align-items: center;
  padding-right: 34px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--task);
  flex: none;
}

.tile .t-sub {
  color: var(--muted);
  font-size: 0.86rem;
  margin-top: 6px;
}

.tile .boost-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
}

.tile .boost-btn.has {
  color: var(--navy);
  background: var(--cream);
  font-weight: 700;
  font-size: 0.78rem;
}

.badge {
  display: inline-block;
  font: 600 0.75rem var(--display);
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--navy-3);
  color: var(--cream);
}

.badge.coral {
  background: var(--coral);
  color: var(--navy);
}

.badge.mint {
  background: var(--mint);
  color: var(--navy);
}

/* ---------- lists ---------- */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}

.list li:last-child {
  border-bottom: 0;
}

.list .grow {
  flex: 1;
  min-width: 0;
}

.list .title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

table.breakdown {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.breakdown th,
.breakdown td {
  padding: 8px 4px;
  text-align: right;
  border-bottom: 1px solid var(--line);
}

.breakdown th:first-child,
.breakdown td:first-child {
  text-align: left;
}

.breakdown th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.85rem;
}

.timeline {
  position: relative;
  height: 28px;
  background: var(--navy);
  border-radius: 8px;
  overflow: hidden;
  margin: 8px 0 4px;
}

.timeline > span {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--task);
  border-radius: 3px;
}

.timeline > span.missed {
  background: repeating-linear-gradient(45deg, var(--task) 0 6px, transparent 6px 10px);
}

.timeline-ticks {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.72rem;
}

.day-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.day-nav h2 {
  text-align: center;
  flex: 1;
}

/* ---------- chips & swatches ---------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  font: 600 0.9rem var(--display);
  border: 2px solid var(--task, var(--line));
  background: color-mix(in srgb, var(--task, var(--navy-3)) 22%, var(--navy-2));
  color: var(--cream);
  border-radius: 99px;
  padding: 6px 12px;
  cursor: pointer;
  min-height: 36px;
}

.chip.off {
  background: transparent;
  border-style: dashed;
  color: var(--muted);
  text-decoration: line-through;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  padding: 0;
}

.swatch[aria-checked="true"] {
  border-color: var(--cream);
  box-shadow: 0 0 0 2px var(--navy);
}

/* ---------- weight check ---------- */

.check {
  margin-top: 12px;
  background: var(--navy);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.92rem;
}

.check:empty {
  display: none;
}

.check .q {
  font-family: var(--display);
  font-weight: 600;
  margin-bottom: 6px;
}

.check ul {
  margin: 0;
  padding-left: 18px;
}

.check li.flag {
  color: var(--coral);
}

.check .warn {
  color: var(--coral);
  margin: 8px 0 0;
}

.check .ok {
  color: var(--mint);
  margin: 8px 0 0;
}

/* ---------- dialogs ---------- */

.dlg {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 0;
  background: var(--navy-2);
  color: var(--cream);
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
}

.dlg::backdrop {
  background: #03002acc;
  backdrop-filter: blur(3px);
}

.dlg-body {
  padding: 18px;
}

.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.x {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1.2rem;
  width: 40px;
  height: 40px;
  cursor: pointer;
  border-radius: 10px;
}

.wheel-wrap {
  position: relative;
  width: min(300px, 100%);
  margin: 10px auto 6px;
  aspect-ratio: 1;
}

#wheel {
  width: 100%;
  height: 100%;
  display: block;
}

.pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 26px solid var(--coral);
  filter: drop-shadow(0 2px 2px #0008);
  z-index: 1;
}

.spin-result {
  text-align: center;
  font: 600 1.4rem var(--display);
  min-height: 1.6em;
  margin: 6px 0 10px;
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 16px 0 8px;
}

/* ---------- toast & confetti ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(76px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--cream);
  color: var(--navy);
  font: 600 0.95rem var(--display);
  padding: 10px 18px;
  border-radius: 99px;
  z-index: 50;
  box-shadow: 0 6px 24px #0007;
  max-width: calc(100vw - 32px);
}

.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 60;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 420px) {
  .score-num {
    font-size: 2.6rem;
  }
  .timer-clock {
    font-size: 2.2rem;
  }
  .tiles {
    grid-template-columns: 1fr 1fr;
  }
}

.spin-cost {
  text-align: center;
  color: var(--coral);
  font-size: 0.9rem;
  min-height: 1.2em;
  margin: -4px 0 10px;
}

/* Quota progress on a tile: a thin bar filled to --p, mint once met. */
.tile .t-quota {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  padding-bottom: 4px;
  background:
    linear-gradient(var(--cream), var(--cream)) left bottom / var(--p) 3px no-repeat,
    linear-gradient(var(--line), var(--line)) left bottom / 100% 3px no-repeat;
}

.tile .t-quota.met {
  color: var(--mint);
  background: linear-gradient(var(--mint), var(--mint)) left bottom / 100% 3px no-repeat;
}

/* Coming up: due today stands out in coral. */
.list li.due-today .due {
  color: var(--coral);
  font-weight: 700;
}

/* Plan dialog */
.plan-sec {
  border-top: 1px solid var(--line);
  padding: 4px 0 12px;
}

.plan-sec:first-child {
  border-top: 0;
}

.plan-h {
  font: 600 1.05rem var(--display);
  margin: 12px 0 8px;
}

.plan-form {
  display: grid;
  gap: 10px;
  margin-top: 8px;
  padding: 12px;
  border-radius: 14px;
  background: var(--navy);
}

.plan-form label {
  margin: 0;
}

.plan-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.plan-pair .num {
  width: 100%;
}

.list li[role="button"] {
  cursor: pointer;
}

.chev {
  color: var(--muted);
  font-size: 1.3rem;
}
