/* The shared chrome (top bar, buttons, dialogs, stats grid, week strip, toast) is in
   hub/game.css, linked before this file. This sets the tokens it uses, the base shapes the game
   chooses for itself, and the drawings. */
:root {
  color-scheme: light dark;
  --bg: #eef3f6;
  --bg-2: #e0e9ef;
  --panel: rgba(255, 255, 255, 0.8);
  --panel-solid: #ffffff;
  --ink: #16232d;
  --muted: #566572;
  --line: rgba(22, 35, 45, 0.14);
  --accent: #2f6f8f; /* white button text on it is 5.6:1 */
  --accent-deep: #22566f;
  --accent-ink: #ffffff;
  --good: #2b9a60;
  --bad: #d23f3f;
  --shadow: rgba(20, 50, 80, 0.16);
  --gold: #e0a019;
  --gold-dim: rgba(22, 35, 45, 0.15);
  --floor: #d6e6f0; /* the top view's squares */
  --bare: rgba(22, 35, 45, 0.05);
  --goal: rgba(22, 35, 45, 0.38);
  --cube: #7fb2cc;
  --cube-t: #cfe6f2;
  --cube-l: #8fc0d8;
  --cube-r: #5d97b4;
  --cube-edge: #1d4a60;
  --display: Fredoka, 'Arial Rounded MT Bold', system-ui, sans-serif;
  --text: Nunito, system-ui, -apple-system, 'Segoe UI', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121820;
    --bg-2: #18212b;
    --panel: rgba(32, 44, 56, 0.75);
    --panel-solid: #1c2733;
    --ink: #e6eef4;
    --muted: #a3b2bf;
    --line: rgba(230, 238, 244, 0.13);
    --accent: #6fb3d6;
    --accent-deep: #4f97bd;
    --accent-ink: #0b1d29;
    --good: #5bd394;
    --bad: #ff7a72;
    --shadow: rgba(0, 0, 0, 0.45);
    --gold: #f6c945;
    --gold-dim: rgba(230, 238, 244, 0.17);
    --floor: #2f5a74;
    --bare: rgba(230, 238, 244, 0.07);
    --goal: rgba(230, 238, 244, 0.42);
    --cube: #4f8fb0;
    --cube-t: #8cc2de;
    --cube-l: #5a9cbe;
    --cube-r: #3b7393;
    --cube-edge: #0d2433;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font: 600 16px/1.4 var(--text);
  -webkit-font-smoothing: antialiased;
  background: linear-gradient(180deg, var(--bg), var(--bg-2)) fixed;
}
button { -webkit-tap-highlight-color: transparent; }

.app {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------------------------------------------------------------- header */
.logo { margin: 0; font: 700 2.1rem/1 var(--display); color: var(--accent-deep); }
@media (prefers-color-scheme: dark) { .logo { color: var(--accent); } }
.day { margin: 4px 0 0; font-size: 0.78rem; color: var(--muted); }

/* ---------------------------------------------------------------- tasks */
.play { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.taskbar { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.tasks { display: flex; gap: 6px; }
.task {
  padding: 7px 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font: 700 0.92rem/1 var(--text);
  cursor: pointer;
}
.task.on { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.task.solved:not(.on) { color: var(--good); border-color: var(--good); }
.task.short:not(.on) { color: var(--muted); border-style: dashed; }
.clock { margin: 0; font: 600 1.15rem/1 var(--display); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- the drawings */
/* --c is a grid square; the front and side views give each cube half of that the other way, so
   they line up with the grid's columns and rows and still fit beside it on a phone. */
.stage { position: relative; width: 100%; }
.desk {
  --c: min(56px, calc((min(100vw, 520px) - 54px) / (var(--n) + var(--h) * 0.5)));
  --u: calc(var(--c) * 0.5);
  display: grid;
  grid-template-columns: calc(var(--n) * var(--c)) calc(var(--h) * var(--u));
  gap: 6px 10px;
  justify-content: center;
  align-items: end;
}
.cap { margin: 0 0 4px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.cap span { letter-spacing: 0; text-transform: none; font-weight: 600; }
.front-wrap .cap { margin: 4px 0 0; }
.grid {
  display: grid;
  grid-template-columns: repeat(var(--n), var(--c));
  grid-auto-rows: var(--c);
  border: 2px solid var(--ink);
  border-radius: 8px;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  outline: none;
  cursor: pointer;
}
.grid:focus-visible { box-shadow: 0 0 0 3px var(--accent); }
.cell {
  display: grid;
  place-items: center;
  border: 0.5px solid var(--line);
  background: var(--panel-solid);
  font: 700 calc(var(--c) * 0.46) / 1 var(--display);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.cell.plan { background: var(--floor); }
.cell.bare { background: repeating-linear-gradient(135deg, var(--bare) 0 4px, transparent 4px 8px), var(--panel-solid); }
.cell.h1 { background: color-mix(in srgb, var(--cube) 35%, var(--panel-solid)); }
.cell.h2 { background: color-mix(in srgb, var(--cube) 55%, var(--panel-solid)); }
.cell.h3 { background: color-mix(in srgb, var(--cube) 75%, var(--panel-solid)); }
.cell.h4 { background: var(--cube); }
.cell.h5 { background: color-mix(in srgb, var(--cube) 80%, var(--ink)); color: var(--panel-solid); }
.cell.wrong { box-shadow: inset 0 0 0 3px var(--bad); }
.grid:focus-visible .cell.cur { outline: 3px dashed var(--accent); outline-offset: -6px; }

.view { display: block; overflow: visible; }
#front { width: calc(var(--n) * var(--c)); height: calc(var(--h) * var(--u)); }
#side { width: calc(var(--h) * var(--u)); height: calc(var(--n) * var(--c)); }
.side-wrap .view, .front-wrap .view { border: 2px solid var(--line); border-radius: 6px; box-sizing: content-box; }
.side-wrap .view { border-left-color: var(--ink); }
.front-wrap .view { border-bottom-color: var(--ink); }
.sq { vector-effect: non-scaling-stroke; stroke-width: 1.5; }
.sq.goal { fill: none; stroke: var(--goal); stroke-dasharray: 3 2; }
.sq.fill { fill: var(--cube); stroke: var(--cube-edge); }
.sq.ok { fill: var(--good); stroke: var(--cube-edge); opacity: 0.85; }
.sq.over { fill: var(--bad); stroke: var(--bad); }
.off { fill: none; stroke: var(--bad); stroke-width: 2; vector-effect: non-scaling-stroke; }
.iso-wrap { align-self: start; justify-self: center; padding-top: 4px; }
.iso { display: block; width: calc(var(--h) * var(--u)); height: calc(var(--h) * var(--u)); }
.iso polygon { stroke: var(--cube-edge); stroke-width: 0.03; stroke-linejoin: round; }
.iso .ground { fill: var(--floor); stroke: var(--line); }
.iso .cube-t { fill: var(--cube-t); }
.iso .cube-l { fill: var(--cube-l); }
.iso .cube-r { fill: var(--cube-r); }
.desk.won .grid { animation: won 0.6s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes won { 40% { transform: scale(1.04); } }
.reduce-motion .desk.won .grid { animation: none; }
@media (prefers-reduced-motion: reduce) { .desk.won .grid { animation: none; } }

.status { margin: 0; min-height: 2.8em; max-width: 440px; text-align: center; color: var(--muted); font-size: 0.92rem; }
.controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* the curtain over unstarted or paused drawings */
.stage.veiled .desk { filter: blur(10px) saturate(0.6); opacity: 0.55; pointer-events: none; }
.curtain {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(88%, 330px);
  padding: 20px 20px 22px;
  border-radius: 22px;
  text-align: center;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px var(--shadow);
  animation: rise 0.4s cubic-bezier(0.2, 1.4, 0.4, 1);
  z-index: 5;
}
.curtain[hidden] { display: none; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, calc(-50% + 16px)) scale(0.96); } }
.reduce-motion .curtain { animation: none; }
@media (prefers-reduced-motion: reduce) { .curtain { animation: none; } }
.cu-kicker { margin: 0; font-size: 0.74rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-deep); }
@media (prefers-color-scheme: dark) { .cu-kicker { color: var(--accent); } }
.cu-title { margin: 4px 0 6px; font: 700 1.9rem/1.05 var(--display); }
.cu-line { margin: 0 0 16px; color: var(--muted); line-height: 1.4; font-size: 0.95rem; }
.curtain .btn { min-width: 150px; }

/* ---------------------------------------------------------------- buttons */
.btn.wide { margin-top: 16px; }

/* ---------------------------------------------------------------- dialogs and results */
.rules { margin: 0 0 12px; padding-left: 20px; }
.rules li { margin: 0 0 6px; }
.kicker { color: var(--muted); }
.res-line { margin: 0 0 12px; font-size: 1rem; color: var(--muted); }
.res-hero { display: flex; align-items: baseline; gap: 14px; margin: -2px 0 6px; }
.res-time { font-weight: 800; font-size: 2.6rem; line-height: 1; font-variant-numeric: tabular-nums; }
.res-stars { display: flex; gap: 2px; font-size: 1.6rem; }
.res-stars span { color: var(--gold-dim); }
.res-stars span.on { color: var(--gold); }
.section-h { margin: 18px 0 10px; font-size: 0.74rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.wd.today i { outline: 2px dashed var(--accent); outline-offset: -2px; }
.wd.won i { background: var(--good); color: #fff; font-size: 0.62rem; }

.toast { z-index: 10; }

@media (max-width: 380px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
