:root {
  --bg: #fbf7f0;
  --surface: #ffffff;
  --surface-2: #f3ede2;
  --ink: #1d2623;
  --muted: #5f6b66;
  --line: #e4dccd;
  --pine: #1f5f45;
  --pine-ink: #ffffff;
  --berry: #b8322a;
  --gold: #d89a12;
  --hit: #2e8b57;
  --partial: #8fbf9f;
  --miss: #c9c2b5;
  --fig-ink: #1d2623;
  --fig-soft: #9aa6a0;
  --fig-ground: #c9bfae;
  --fig-accent: #b8322a;
  --shadow: 0 1px 2px rgba(30, 30, 20, .06), 0 6px 20px rgba(30, 30, 20, .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101615; --surface: #18201e; --surface-2: #212b28; --ink: #ecefe9; --muted: #9eaba5; --line: #2c3833;
    --pine: #3f9b72; --pine-ink: #08110d; --berry: #ef6a5f; --gold: #f1b938; --hit: #4fbf83; --partial: #3e6b52; --miss: #47524d;
    --fig-ink: #ecefe9; --fig-soft: #6f7d77; --fig-ground: #4a5650; --fig-accent: #ef6a5f;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101615; --surface: #18201e; --surface-2: #212b28; --ink: #ecefe9; --muted: #9eaba5; --line: #2c3833;
  --pine: #3f9b72; --pine-ink: #08110d; --berry: #ef6a5f; --gold: #f1b938; --hit: #4fbf83; --partial: #3e6b52; --miss: #47524d;
  --fig-ink: #ecefe9; --fig-soft: #6f7d77; --fig-ground: #4a5650; --fig-accent: #ef6a5f;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--pine); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 4.5vw, 2.3rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.pad { padding: 2rem 1rem; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 1rem; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 16px; max-width: 980px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--ink); font-weight: 750; font-size: 1.1rem; }
.brand svg { width: 26px; height: 26px; color: var(--pine); }
#topnav a { font-weight: 600; text-decoration: none; }
main { max-width: 980px; margin: 0 auto; padding: 0 16px 4rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); }
.card + .card, .section + .section { margin-top: 1rem; }
.section { margin-top: 1.6rem; }
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 1.2rem; align-items: center; }
@media (max-width: 720px) { .hero { grid-template-columns: 1fr; } }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; font-weight: 700; color: var(--berry); margin-bottom: .3rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: .65rem 1rem; border-radius: 999px; font: inherit; font-weight: 650; cursor: pointer; text-decoration: none;
  min-height: 44px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--pine); border-color: var(--pine); color: var(--pine-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.big { font-size: 1.08rem; padding: .85rem 1.4rem; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--berry); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }

.fig { width: 100%; aspect-ratio: 4 / 3; background: var(--surface-2); border-radius: 12px; overflow: hidden; display: grid; place-items: center; }
.fig svg { width: 100%; height: 100%; display: block; }
.fig.placeholder { color: var(--muted); font-size: .9rem; }
.fig.small { aspect-ratio: 4 / 3; max-width: 120px; }

.stars { color: var(--gold); letter-spacing: 1px; font-size: .95rem; }
.stars .off { color: var(--line); }
.pill { display: inline-block; padding: .15rem .6rem; border-radius: 999px; background: var(--surface-2); font-size: .82rem; font-weight: 600; color: var(--muted); }

/* board */
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .88rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.day-row { display: grid; grid-template-columns: 9.5rem 1fr; gap: .8rem; padding: .8rem 0; border-top: 1px solid var(--line); align-items: start; }
.day-row:first-child { border-top: 0; }
@media (max-width: 560px) { .day-row { grid-template-columns: 1fr; gap: .4rem; } }
.day-row .dname { font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .65rem .25rem .3rem; border-radius: 999px; background: var(--surface-2); font-size: .9rem; }
.dot { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .75rem; font-weight: 800; flex: none; }
.dot.exceeded { background: var(--gold); color: #3b2a00; }
.dot.hit { background: var(--hit); color: #fff; }
.dot.partial { background: var(--partial); color: var(--ink); }
.dot.missed { background: transparent; border: 2px dashed var(--miss); }
.dot.pending { background: transparent; border: 2px solid var(--line); }

/* doors */
.doors { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: .5rem; }
.door {
  position: relative; aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; font: inherit; color: var(--ink); cursor: pointer; padding: 4px;
}
.door .n { font-size: 1.25rem; font-weight: 800; }
.door .s { font-size: .68rem; color: var(--muted); text-align: center; line-height: 1.1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.door.locked { background: repeating-linear-gradient(135deg, var(--surface-2) 0 8px, var(--surface) 8px 16px); color: var(--muted); cursor: default; }
.door.today { border: 2px solid var(--berry); }
.door.selected { outline: 3px solid var(--pine); outline-offset: 1px; }
.door .dot { position: absolute; top: 4px; right: 4px; width: 16px; height: 16px; font-size: .6rem; }

/* day panel */
.daypanel { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
@media (max-width: 720px) { .daypanel { grid-template-columns: 1fr; } }
.target { font-size: 2.6rem; font-weight: 800; line-height: 1; color: var(--pine); }
.target small { font-size: 1rem; font-weight: 600; color: var(--muted); }
.sets { display: flex; flex-wrap: wrap; gap: .3rem; margin: .4rem 0; }
.sets span { background: var(--surface-2); border-radius: 8px; padding: .15rem .5rem; font-weight: 700; font-size: .9rem; }
.toggle { display: flex; align-items: center; gap: .55rem; padding: .55rem .7rem; border-radius: 10px; background: var(--surface-2); cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--pine); }
ul.cues { margin: .2rem 0 .8rem; padding-left: 1.2rem; }
.logs { list-style: none; padding: 0; margin: .5rem 0 0; }
.logs li { display: flex; gap: .6rem; align-items: center; justify-content: space-between; padding: .45rem 0; border-top: 1px solid var(--line); font-size: .95rem; }

.banner { background: color-mix(in srgb, var(--gold) 18%, var(--surface)); border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--line)); border-radius: var(--radius); padding: .9rem 1rem; }
.banner code { word-break: break-all; font-size: .85rem; }

/* forms */
label.field { display: block; font-weight: 650; margin-bottom: 1rem; }
label.field > span { display: block; margin-bottom: .35rem; }
input[type="text"], input[type="number"], select {
  width: 100%; font: inherit; padding: .65rem .8rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-height: 44px;
}
.choices { display: flex; flex-wrap: wrap; gap: .4rem; }
.choices button { min-width: 46px; }
.choices button.on { background: var(--pine); color: var(--pine-ink); border-color: var(--pine); }
.hint { font-weight: 400; color: var(--muted); font-size: .88rem; margin-top: .3rem; }
details.settings summary { cursor: pointer; font-weight: 700; }
.err { color: var(--berry); font-weight: 600; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(10, 15, 12, .55); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal[hidden] { display: none; }
.modal .box { background: var(--surface); color: var(--ink); border-radius: 18px; padding: 1.3rem; width: min(460px, 100%); max-height: 92vh; overflow: auto; }
.rating { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .6rem 0 1rem; }
.rating button { flex-direction: column; border-radius: 12px; padding: .7rem .3rem; gap: .1rem; }
.rating button b { font-size: 1.5rem; }
.rating button.on { background: var(--pine); color: var(--pine-ink); border-color: var(--pine); }

/* player */
.player { position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow: auto; }
.player .wrap { max-width: 980px; margin: 0 auto; padding: 12px 16px 2rem; display: grid; grid-template-columns: 1.2fr 1fr; gap: 1.2rem; }
@media (max-width: 760px) { .player .wrap { grid-template-columns: 1fr; } }
.player .now { text-align: center; }
.player .phase { text-transform: uppercase; letter-spacing: .1em; font-weight: 800; font-size: .85rem; }
.player .phase.work { color: var(--berry); }
.player .phase.rest, .player .phase.ready { color: var(--pine); }
.player .say { font-size: clamp(1.5rem, 5vw, 2.3rem); font-weight: 800; line-height: 1.15; margin: .3rem 0 .6rem; }
.ring { position: relative; width: 170px; height: 170px; margin: .4rem auto; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.ring .num small { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-top: -.6rem; }
.controls { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin: .8rem 0; }
.steps { list-style: none; padding: 0; margin: 0; font-size: .95rem; max-height: 60vh; overflow: auto; }
.steps li { padding: .35rem .6rem; border-radius: 8px; display: flex; justify-content: space-between; gap: .5rem; }
.steps li.cur { background: var(--pine); color: var(--pine-ink); font-weight: 700; }
.steps li.past { color: var(--muted); text-decoration: line-through; }
.steps li.rest { color: var(--muted); font-size: .85rem; }
.steps li.cur.rest { color: var(--pine-ink); }
.player .fig { max-width: 420px; margin: 0 auto; }
