/* Closer Than You Think — styles
   Layout: one centered column. Header, prompt, a raised timeline board (two lanes around one groove),
   result card that rises in, then the prototype settings. Depth comes from layered shadows,
   a lit top edge on raised surfaces and a sunken groove for the track. */

:root {
  --bg: #E9EDF4;
  --bg-glow: #F8FAFD;
  --surface: #FFFFFF;
  --surface-2: #F5F7FB;
  --ink: #0F1728;
  --ink-edge: #000510;
  --muted: #586378;
  --line: #D2D8E3;
  --soft: #E4E8F0;
  --groove: #D9DEE8;
  --hl: rgba(255, 255, 255, 0.95);
  --sh1: rgba(15, 23, 40, 0.08);
  --sh2: rgba(15, 23, 40, 0.16);
  --sh3: rgba(15, 23, 40, 0.26);
  --a: #E0521B;
  --a-deep: #A63A0F;
  --a-soft: #FFE5D8;
  --b: #1A7398;
  --b-deep: #0F526E;
  --b-soft: #D8EDF6;
  --good: #23864A;
  --bad: #C23A2B;

  --f-display: "Unbounded", "Arial Black", "Helvetica Neue", sans-serif;
  --f-body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --ease-out: cubic-bezier(0.2, 0.85, 0.25, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #090D14; --bg-glow: #141B29; --surface: #141B28; --surface-2: #1A2232;
    --ink: #EBEFF6; --ink-edge: #8E9AB0; --muted: #97A1B4; --line: #2A3447; --soft: #1D2637; --groove: #0B1019;
    --hl: rgba(255, 255, 255, 0.07); --sh1: rgba(0, 0, 0, 0.35); --sh2: rgba(0, 0, 0, 0.5); --sh3: rgba(0, 0, 0, 0.7);
    --a: #FF7B47; --a-deep: #B8481B; --a-soft: #3A2218; --b: #50B7D9; --b-deep: #24748F; --b-soft: #132F3C;
    --good: #5CC27E; --bad: #F2725F;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #090D14; --bg-glow: #141B29; --surface: #141B28; --surface-2: #1A2232;
  --ink: #EBEFF6; --ink-edge: #8E9AB0; --muted: #97A1B4; --line: #2A3447; --soft: #1D2637; --groove: #0B1019;
  --hl: rgba(255, 255, 255, 0.07); --sh1: rgba(0, 0, 0, 0.35); --sh2: rgba(0, 0, 0, 0.5); --sh3: rgba(0, 0, 0, 0.7);
  --a: #FF7B47; --a-deep: #B8481B; --a-soft: #3A2218; --b: #50B7D9; --b-deep: #24748F; --b-soft: #132F3C;
  --good: #5CC27E; --bad: #F2725F;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1100px 520px at 50% -8%, var(--bg-glow), transparent 72%), var(--bg);
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 22px 44px;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

.app { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.brand h1 { font-family: var(--f-display); font-weight: 700; font-size: 18px; line-height: 1.1; letter-spacing: -0.01em; margin: 0; }
.tag { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; }
.meter { display: flex; align-items: center; gap: 12px; }
.dots { display: flex; gap: 6px; }
.dots span { width: 11px; height: 11px; border-radius: 50%; background: var(--soft); box-shadow: inset 0 1px 2px var(--sh2); }
.dots span.done { background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.55), transparent 50%), var(--ink); box-shadow: 0 2px 4px var(--sh2); }
.dots span.now { background: var(--surface); box-shadow: 0 0 0 2px var(--ink), 0 2px 5px var(--sh2); }
.total { font-family: var(--f-display); font-weight: 700; font-size: 20px; line-height: 1; font-variant-numeric: tabular-nums; }
.total small { font-family: var(--f-body); font-size: 12px; font-weight: 600; color: var(--muted); margin-right: 6px; letter-spacing: 0.02em; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--surface-2)); color: var(--ink);
  display: grid; place-items: center; cursor: pointer;
  box-shadow: inset 0 1px 0 var(--hl), 0 2px 0 var(--line), 0 6px 14px -8px var(--sh3);
  transition: transform 0.12s var(--ease-out), box-shadow 0.12s var(--ease-out);
}
.icon-btn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 var(--hl), 0 0 0 var(--line), 0 3px 8px -6px var(--sh3); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .off-x { display: none; }
.icon-btn[aria-pressed="false"] .waves { display: none; }
.icon-btn[aria-pressed="false"] .off-x { display: inline; }

/* Prompt */
.prompt { display: flex; flex-direction: column; gap: 10px; }
.axis-chip { align-self: flex-start; font-family: var(--f-mono); font-size: 12px; font-weight: 500; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; box-shadow: 0 2px 6px -4px var(--sh3); }
.prompt h2 { font-family: var(--f-display); font-weight: 700; font-size: clamp(21px, 4.8vw, 30px); line-height: 1.14; letter-spacing: -0.015em; margin: 0; text-wrap: balance; }
.prompt p { margin: 0; color: var(--muted); font-size: 15px; max-width: 62ch; }

/* Board */
.board {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line); border-radius: 20px; overflow: hidden;
  box-shadow: inset 0 1px 0 var(--hl), 0 1px 2px var(--sh1), 0 26px 50px -26px var(--sh3);
}
.stage { position: relative; height: 300px; touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair; perspective: 900px; }
.rail { position: absolute; top: 0; bottom: 0; left: 20px; right: 20px; }
.track {
  position: absolute; left: -4px; right: -4px; top: 130px; height: 9px; border-radius: 6px;
  background: var(--groove);
  box-shadow: inset 0 2px 3px var(--sh3), inset 0 -1px 0 var(--hl), 0 1px 0 var(--hl);
}
.tick { position: absolute; top: 121px; width: 1.5px; height: 6px; margin-left: -0.75px; border-radius: 1px; background: var(--muted); }
.tick.minor { opacity: 0.45; height: 4px; top: 123px; }
.tick-l { position: absolute; top: 146px; font: 500 11px/1 var(--f-mono); color: var(--muted); white-space: nowrap; transform: translateX(-50%); font-variant-numeric: tabular-nums; }
.tick-l.start { transform: none; }
.tick-l.end { transform: translateX(-100%); }

.hint {
  position: absolute; left: 0; right: 0; height: 68px; border: 1.5px dashed var(--line); border-radius: 14px;
  background: transparent; color: var(--muted); font: 500 14.5px/1.3 var(--f-body);
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 12px; cursor: pointer; text-align: center;
}
.hint.A { top: 18px; }
.hint.B { top: 214px; }
.hint strong { color: var(--ink); font-weight: 700; }
.hint .sw { width: 12px; height: 12px; border-radius: 4px; box-shadow: 0 2px 4px var(--sh2); }

.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.sw.A { background: var(--a); }
.sw.B { background: var(--b); }

.stem { position: absolute; width: 2px; margin-left: -1px; border-radius: 1px; }
.stem.A { top: 34px; height: 96px; background: linear-gradient(180deg, transparent, var(--a) 30%); }
.stem.B { top: 139px; height: 120px; background: linear-gradient(0deg, transparent, var(--b) 30%); }
.dot { position: absolute; top: 126px; width: 17px; height: 17px; margin-left: -8.5px; border-radius: 50%; border: 2.5px solid var(--surface); box-shadow: 0 3px 7px var(--sh3); z-index: 1; }
.dot.A { background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.6), transparent 48%), var(--a); }
.dot.B { background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.6), transparent 48%), var(--b); }

.card {
  position: absolute; width: min(164px, 42vw); padding: 8px 11px 9px; border-radius: 13px; border: 1.5px solid;
  color: var(--ink); text-align: left; font: inherit; cursor: grab; display: flex; flex-direction: column; gap: 3px;
  touch-action: none; z-index: 2;
  transform: translate3d(0, var(--lift, 0px), 0) rotate(var(--rz, 0deg)) scale(var(--sc, 1));
  transition: transform 0.16s var(--ease-out), box-shadow 0.2s var(--ease-out), opacity 0.3s;
}
.card.A { top: 12px; border-color: var(--a); background: linear-gradient(180deg, var(--surface), var(--a-soft) 70%); box-shadow: inset 0 1px 0 var(--hl), 0 3px 0 var(--a-deep), 0 14px 24px -12px var(--sh3); }
.card.B { bottom: 12px; border-color: var(--b); background: linear-gradient(180deg, var(--surface), var(--b-soft) 70%); box-shadow: inset 0 1px 0 var(--hl), 0 3px 0 var(--b-deep), 0 14px 24px -12px var(--sh3); }
.card.active { --lift: -8px; --sc: 1.045; cursor: grabbing; z-index: 4; }
.card.A.active { box-shadow: inset 0 1px 0 var(--hl), 0 3px 0 var(--a-deep), 0 26px 34px -14px var(--sh3); }
.card.B.active { box-shadow: inset 0 1px 0 var(--hl), 0 3px 0 var(--b-deep), 0 26px 34px -14px var(--sh3); }
.c-name { font-weight: 700; font-size: 13.5px; line-height: 1.22; }
.c-read { font: 600 11.5px/1.2 var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.stage.dragging { cursor: grabbing; }
.hint:focus-visible, .card:focus-visible, .btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

/* Reveal */
.stage.revealed .card { opacity: 0.45; --lift: 0px; --sc: 0.97; box-shadow: none; border-style: dashed; }
.stage.revealed .stem { opacity: 0.3; }
.stage.revealed .dot { opacity: 0.55; box-shadow: none; }
.band { position: absolute; top: 128px; height: 13px; border-radius: 6px; opacity: 0; transition: opacity 0.6s ease; }
.band.A { background: var(--a); }
.band.B { background: var(--b); }
.band.show { opacity: 0.35; }
.tline { position: absolute; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; }
.tline.A { top: 104px; height: 26px; }
.tline.B { top: 139px; height: 26px; }
.tdot {
  position: absolute; top: 124px; width: 21px; height: 21px; margin-left: -10.5px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--hl), transparent 55%), var(--surface);
  border: 4.5px solid var(--ink); z-index: 3; box-shadow: 0 6px 12px -2px var(--sh3);
}
.tlabel {
  position: absolute; display: flex; align-items: center; gap: 6px; white-space: nowrap;
  font: 600 12px/1 var(--f-mono); background: var(--ink); color: var(--surface);
  padding: 6px 9px; border-radius: 8px; z-index: 3;
  box-shadow: 0 2px 0 var(--ink-edge), 0 10px 18px -8px var(--sh3);
}
.tlabel.A { top: 74px; }
.tlabel.B { top: 165px; }
.drop { animation: drop 0.36s var(--ease-back) both; }
.tdot.drop { animation-name: drop-dot; }
@keyframes drop { from { opacity: 0; transform: translateY(-16px) scale(0.85); } to { opacity: 1; transform: none; } }
@keyframes drop-dot { from { opacity: 0; transform: translateY(-26px) scale(0.5); } to { opacity: 1; transform: none; } }

/* Legend under the board */
.legend { display: grid; gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.leg { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 11px 14px; background: var(--surface); }
.leg-tag { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; font: 700 13px/1 var(--f-display); color: #FFFFFF; }
.leg.A .leg-tag { background: var(--a); box-shadow: 0 2px 0 var(--a-deep); }
.leg.B .leg-tag { background: var(--b); box-shadow: 0 2px 0 var(--b-deep); }
.leg-text { min-width: 0; }
.leg-name { font-weight: 700; font-size: 15px; line-height: 1.25; }
.leg-detail { font-size: 13.5px; color: var(--muted); }
.leg-state { font: 500 12px/1 var(--f-mono); color: var(--muted); white-space: nowrap; }
.leg-state.ok { color: var(--good); }

/* Result */
.result {
  display: grid; gap: 14px; background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line); border-radius: 20px; padding: 20px 18px;
  box-shadow: inset 0 1px 0 var(--hl), 0 1px 2px var(--sh1), 0 26px 50px -26px var(--sh3);
  transform-origin: 50% 0;
}
.result.enter { animation: rise 0.55s var(--ease-out) both; }
@keyframes rise { from { opacity: 0; transform: perspective(900px) rotateX(14deg) translateY(18px); } to { opacity: 1; transform: none; } }
.r-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.punch { font-family: var(--f-display); font-weight: 700; font-size: clamp(17px, 3.8vw, 22px); line-height: 1.25; letter-spacing: -0.01em; margin: 0; text-wrap: balance; max-width: 34ch; }
.r-score { font-family: var(--f-display); font-weight: 800; font-size: 46px; line-height: 0.9; font-variant-numeric: tabular-nums; white-space: nowrap; }
.r-score small { font-size: 18px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.r-rows { display: grid; gap: 10px; }
.r-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; }
.r-row .sw { margin-top: 6px; }
.r-main { min-width: 0; }
.r-title { font-weight: 700; font-size: 15px; }
.r-meta { font: 500 12.5px/1.5 var(--f-mono); color: var(--muted); }
.r-pts { font: 600 14px/1.4 var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.r-line { font-size: 14.5px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.r-line .ok { color: var(--good); font-weight: 700; }
.r-line .bad { color: var(--bad); font-weight: 700; }
.r-src { font-size: 12.5px; color: var(--muted); }

/* Buttons */
.actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  font: 700 16px/1 var(--f-body); letter-spacing: 0.01em; padding: 16px 26px; min-height: 52px; border-radius: 14px;
  border: none; background: var(--ink); color: var(--surface); cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 4px 0 var(--ink-edge), 0 14px 22px -12px var(--sh3);
  transition: transform 0.1s var(--ease-out), box-shadow 0.1s var(--ease-out), opacity 0.2s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 1px 0 var(--ink-edge), 0 6px 12px -8px var(--sh3); }
.btn:disabled { opacity: 0.28; cursor: not-allowed; box-shadow: none; }
.btn.ghost { background: linear-gradient(180deg, var(--surface), var(--surface-2)); color: var(--ink); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hl), 0 3px 0 var(--line), 0 10px 18px -12px var(--sh3); }
.btn.ghost:active { box-shadow: inset 0 1px 0 var(--hl), 0 0 0 var(--line); }

/* End screen */
.screen { display: flex; flex-direction: column; gap: 18px; }
.eyebrow { margin: 0; font: 600 11.5px/1 var(--f-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.end-total { font-family: var(--f-display); font-weight: 800; font-size: clamp(64px, 18vw, 108px); line-height: 0.9; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.end-total small { font-size: 0.28em; color: var(--muted); margin-left: 10px; letter-spacing: 0; font-weight: 600; }
.muted { color: var(--muted); margin: 0; font-size: 14.5px; }
.end-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: 0 20px 40px -26px var(--sh3); }
.end-list li { display: grid; grid-template-columns: 2.2em 1fr auto; gap: 10px; align-items: center; padding: 12px 14px; background: var(--surface); font-size: 14.5px; }
.end-list .n { font: 600 12px/1 var(--f-mono); color: var(--muted); }
.end-list .p { font: 600 14px/1 var(--f-mono); font-variant-numeric: tabular-nums; }
.end-list .wrong { color: var(--bad); }
.share { display: grid; gap: 12px; }
.share pre { margin: 0; padding: 14px 16px; border-radius: 14px; background: var(--soft); box-shadow: inset 0 2px 4px var(--sh1); font: 500 15px/1.5 var(--f-mono); white-space: pre-wrap; overflow-x: auto; }

/* Prototype settings */
.proto { border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 8px; font-size: 13px; color: var(--muted); }
.switch { display: flex; gap: 10px; align-items: center; color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--ink); }
.proto p { margin: 0; max-width: 70ch; }

@media (prefers-reduced-motion: no-preference) {
  .hint { animation: float 3.2s ease-in-out infinite alternate; }
  .hint.B { animation-delay: -1.6s; }
  @keyframes float { from { transform: translateY(0); } to { transform: translateY(-4px); } }
}
@media (prefers-reduced-motion: reduce) {
  .card, .band, .btn, .icon-btn { transition: none !important; }
  .drop, .result.enter { animation: none !important; }
}
