/* Amelia's Minefield. Style: true-black flat (tasteskill app sheet, seed 1632533958).
   Elevation by lightness alone: ground #000, surface #111, raised #2a2a2a. No borders or shadows on
   anything at rest. One data hue: amber, the AI ghost. Amelia's own marks are white. */
:root {
  --ground: #000000;
  --surface: #111111;
  --raised: #2a2a2a;
  --raised-hi: #353535;
  --rule: #1a1a1a;
  --control: #444444;
  --text: #ffffff;
  --muted: #b4b4b4;
  --faint: #949494;
  --ai: #f2b33d;            /* the one data hue */
  --ai-tint: #2b2414;
  --flag: #e5484d;
  --mine-tint: #2c1a20;
  --safe: #c6f24e;
  --safe-tint: #222a10;
  --radius-card: 20px;
  --radius-cell: 4px;
  --gap: 14px;
  --pad: 22px;
  --control-height: 44px;
  --fs-title: 20px;
  --fs-section: 16px;
  --fs-kpi: 24px;
  --fs-body: 14px;
  --fs-small: 12px;
  --cell: 28px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--ground); color: var(--text); }
body {
  font: 400 var(--fs-body)/20px "Inter", system-ui, sans-serif;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* ---------- top bar ---------- */
.top {
  height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 20px; border-bottom: 1px solid var(--rule);
}
.brand {
  display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; cursor: pointer;
  font-weight: 600; font-size: 15px; color: var(--text);
}
.brand svg { width: 26px; height: 26px; flex: none; }
.player { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.player .who { color: var(--text); font-weight: 500; }
.player button {
  height: 32px; padding: 0 14px; border-radius: 999px; border: 0; background: var(--raised);
  color: var(--text); cursor: pointer; font-size: 13px;
}
.player button:hover { background: var(--raised-hi); }

main { max-width: 1200px; margin: 0 auto; }
.screen { padding: 24px 20px 40px; }
h1 { font-size: var(--fs-title); line-height: 28px; font-weight: 600; margin: 0; }

/* ---------- ladder ---------- */
.ladder-head { display: grid; gap: 6px; margin-bottom: 20px; max-width: 620px; }
.ladder-head p { margin: 0; color: var(--muted); font-size: 15px; line-height: 22px; }
.summary {
  display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface);
  border-radius: var(--radius-card); margin-bottom: 28px; max-width: 620px;
}
.summary div { padding: 16px var(--pad); }
.summary div + div { border-left: 1px solid var(--rule); }
.summary .k { display: block; font-size: var(--fs-small); color: var(--muted); line-height: 16px; }
.summary .v { font-size: var(--fs-kpi); line-height: 32px; font-weight: 600; }
.summary .v small { font-size: 14px; color: var(--faint); font-weight: 400; }
.summary .v.ai { color: var(--ai); }

.climb { list-style: none; margin: 0; padding: 0; max-width: 620px; position: relative; }
.climb .group { color: var(--muted); font-size: 13px; padding: 22px 0 8px 44px; }
.rung { position: relative; }
/* the rail: a 2px line through every rung's mark; filled white up to the highest level cleared */
.rung::before {
  content: ""; position: absolute; left: 15px; top: 0; bottom: 0; width: 2px; background: var(--raised);
}
.rung.done::before { background: var(--text); }
.rung:first-child::before { top: 50%; }
.rung:last-child::before { bottom: 50%; }
.rung button {
  position: relative; width: 100%; min-height: 72px; display: grid;
  grid-template-columns: 32px 1fr auto; align-items: center; gap: 12px;
  background: none; border: 0; padding: 10px 14px 10px 0; text-align: left; cursor: pointer;
  border-radius: 14px;
}
.rung button:hover:not(:disabled) { background: var(--surface); }
.rung button:disabled { cursor: not-allowed; }
.mark {
  width: 32px; height: 32px; border-radius: 999px; display: grid; place-items: center;
  background: var(--ground); position: relative; z-index: 1;
  font-size: 12px; font-weight: 600; color: var(--faint);
  outline: 2px solid var(--raised); outline-offset: -2px;
}
.rung.done .mark { background: var(--text); color: #000; outline: none; }
.rung.beat .mark { background: var(--ai); color: #000; outline: none; }
.rung.next .mark { outline: 2px solid var(--text); outline-offset: -2px; color: var(--text); }
.rung-main { display: grid; gap: 2px; min-width: 0; }
.rung-name { font-size: var(--fs-section); font-weight: 600; line-height: 22px; }
.rung.locked .rung-name { color: var(--faint); font-weight: 500; }
.rung-meta { font-size: 13px; color: var(--muted); line-height: 18px; }
.rung.locked .rung-meta { color: var(--faint); }
.rung-side { display: grid; justify-items: end; gap: 4px; }
.rung-best { font-size: 15px; font-weight: 600; }
.pill { font-size: 12px; line-height: 22px; height: 22px; padding: 0 9px; border-radius: 999px; white-space: nowrap; }
.pill.beat { background: var(--ai-tint); color: var(--ai); }
.pill.clear { background: #222222; color: var(--text); }
.pill.next { background: var(--text); color: #000; }
.ladder-foot { color: var(--faint); font-size: 13px; margin: 24px 0 0 44px; max-width: 576px; }

/* ---------- game ---------- */
.game-head {
  background: var(--surface); border-radius: var(--radius-card); padding: 16px var(--pad);
  display: grid; grid-template-columns: 1fr auto; gap: 14px 24px; align-items: center; margin-bottom: var(--gap);
}
.game-title { display: grid; gap: 2px; }
.game-title .meta { color: var(--muted); font-size: 13px; }
.stats { display: flex; gap: 0; }
.stat { padding: 0 20px; display: grid; gap: 2px; }
.stat + .stat { border-left: 1px solid #222222; }
.stat:last-child { padding-right: 0; }
.stat .k { font-size: var(--fs-small); color: var(--muted); line-height: 16px; }
.stat .v { font-size: var(--fs-kpi); line-height: 30px; font-weight: 600; }
.stat.ai .v { color: var(--ai); }
.race { grid-column: 1 / -1; display: grid; gap: 6px; }
.lane { display: grid; grid-template-columns: 26px 1fr 44px; align-items: center; gap: 10px; font-size: var(--fs-small); color: var(--muted); }
.lane .pct { text-align: right; }
.track { height: 6px; background: var(--raised); border-radius: 999px; overflow: hidden; }
.fill { height: 100%; width: 0; border-radius: 999px; transition: width .2s linear; }
.fill.you { background: var(--text); }
.fill.ai { background: var(--ai); }

.boardwrap {
  overflow: auto; max-width: 100%;
  max-height: calc(100dvh - 290px); min-height: 260px;
  background: var(--surface); border-radius: var(--radius-card);
  overscroll-behavior: contain; touch-action: pan-x pan-y;
}
.board {
  display: grid; width: max-content; margin: 12px; outline: none; gap: 2px;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
/* unopened cells are raised (lighter); opened cells sink to the ground */
.c {
  width: calc(var(--cell) - 2px); height: calc(var(--cell) - 2px);
  display: grid; place-items: center;
  font-weight: 600; font-size: calc(var(--cell) * .56); line-height: 1;
  background: var(--raised); border-radius: var(--radius-cell); cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.c.h:hover { background: var(--raised-hi); }
.c.o { background: var(--ground); cursor: default; }
.c.o.n { cursor: pointer; }
.c.f::after {
  content: ""; width: 62%; height: 62%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M7 3v13M4 16.5h8' stroke='%23fff' stroke-width='1.8' stroke-linecap='round'/%3E%3Cpath d='M8 3l9 3.6L8 10.2z' fill='%23e5484d'/%3E%3C/svg%3E") center / contain no-repeat;
}
.c.m { background: var(--mine-tint); }
.c.m::after { content: ""; width: 36%; height: 36%; border-radius: 999px; background: var(--text); }
.c.boom { background: var(--flag); }
.c.boom::after { background: #000; }
.c.wrong { background: var(--raised); }
.c.wrong::after { content: "\00d7"; color: var(--flag); font-size: calc(var(--cell) * .7); }
.c.start { outline: 1px solid #3d3d3d; outline-offset: -1px; }
.c.proof { background: var(--safe-tint); outline: 2px solid var(--safe); outline-offset: -2px; }
.c.cursor { outline: 2px solid var(--text); outline-offset: -2px; }
.c.ghost { outline: 2px solid var(--ai); outline-offset: -2px; }
.n1 { color: #5aa9ff; } .n2 { color: #4fd17a; } .n3 { color: #ff6464; } .n4 { color: #f08bd6; }
.n5 { color: #e8c547; } .n6 { color: #4dd4cf; } .n7 { color: #ffffff; } .n8 { color: #949494; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--gap); align-items: center; }
.tool {
  height: var(--control-height); min-width: 44px; padding: 0 18px; border-radius: 999px; border: 0;
  background: var(--raised); color: var(--text); cursor: pointer; font-weight: 500;
}
.tool:hover { background: var(--raised-hi); }
.tool:active { transform: scale(.97); }
.tool[aria-pressed="true"] { background: var(--text); color: #000; }
.tool.round { padding: 0; width: 44px; font-size: 18px; }
.controls .spacer { flex: 1; }
.hint { color: var(--faint); font-size: 13px; margin: 12px 0 0; }

/* ---------- dialogs (they float, so they may cast a shadow) ---------- */
.result {
  background: var(--surface); color: var(--text); border: 0; border-radius: var(--radius-card);
  padding: 24px; width: min(420px, calc(100vw - 32px));
  box-shadow: 0 24px 64px rgba(0, 0, 0, .6); /* taste-skill-ignore: dialog floats */
}
.result::backdrop { background: rgba(0, 0, 0, .72); }
.result h2 { margin: 0 0 6px; font-size: var(--fs-title); line-height: 28px; font-weight: 600; }
.result p { margin: 0; color: var(--muted); font-size: 15px; line-height: 22px; }
.resStats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 18px 0 20px; background: #1a1a1a; border-radius: 14px; }
.resStats div { padding: 12px 14px; display: grid; gap: 2px; }
.resStats div + div { border-left: 1px solid var(--surface); }
.resStats .k { font-size: var(--fs-small); color: var(--muted); }
.resStats .v { font-size: 18px; font-weight: 600; line-height: 24px; }
.resStats .v.ai { color: var(--ai); }
.resBtns { display: grid; gap: 8px; }
.resBtns button, #whoForm button {
  height: 44px; border-radius: 999px; border: 0; background: var(--raised); cursor: pointer; font-weight: 500;
}
.resBtns button:hover, #whoForm button:hover { background: var(--raised-hi); }
.resBtns .primary, #whoForm .primary { background: var(--text); color: #000; font-weight: 600; }
.resBtns .primary:hover, #whoForm .primary:hover { background: #e6e6e6; }
#whoForm { display: grid; gap: 10px; margin-top: 16px; }
#whoForm input {
  font: inherit; font-size: 16px; color: var(--text); background: var(--ground); border: 1px solid var(--control);
  border-radius: 999px; padding: 0 18px; height: 44px;
}

@media (prefers-reduced-motion: reduce) { .fill { transition: none; } .tool:active { transform: none; } }

@media (max-width: 640px) {
  .top { padding: 0 16px; }
  .screen { padding: 18px 16px 32px; }
  .game-head { grid-template-columns: 1fr; padding: 14px 16px; }
  .stats { display: grid; grid-template-columns: repeat(3, 1fr); }
  .stat { padding: 0 12px; }
  .stat:first-child { padding-left: 0; }
  .boardwrap { max-height: calc(100dvh - 330px); }
  .summary div { padding: 14px 16px; }
  .hint { display: none; }
  .controls { display: grid; grid-template-columns: 1fr 1fr 44px 44px 44px; }
  .controls .spacer { display: none; }
  .tool { padding: 0 10px; }
  #zoomFit { padding: 0; }
}

/* ---------- up next ---------- */
.upnext { background: var(--surface); border-radius: var(--radius-card); padding: 20px var(--pad) var(--pad); margin-bottom: 28px; max-width: 620px; display: grid; gap: 16px; }
.upnext h2 { margin: 0; font-size: var(--fs-small); line-height: 16px; font-weight: 500; color: var(--muted); }
.next-name { font-size: var(--fs-title); line-height: 26px; font-weight: 600; margin-top: -10px; }
.next-meta { color: var(--muted); font-size: 13px; margin-top: -12px; }
.dense { display: grid; gap: 8px; }
.dense-row { display: grid; grid-template-columns: 112px 1fr 48px; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.dense-row .bar { height: 8px; background: var(--raised); border-radius: 999px; overflow: hidden; }
.dense-row .bar span { display: block; height: 100%; border-radius: 999px; background: var(--faint); }
.dense-row.this { color: var(--text); }
.dense-row.this .bar span { background: var(--text); }
.dense-row .val { text-align: right; }
.next-record { font-size: 13px; color: var(--muted); }
.next-record b { color: var(--text); font-weight: 600; }
.next-record .ai { color: var(--ai); }
.play {
  height: 44px; border: 0; border-radius: 999px; background: var(--text); color: #000;
  font-weight: 600; font-size: 15px; cursor: pointer;
}
.play:hover { background: #e6e6e6; }
.play:active { transform: scale(.98); }
.rung-won { font-size: 12px; color: var(--faint); }

@media (min-width: 1000px) {
  #ladder {
    display: grid; grid-template-columns: minmax(0, 620px) minmax(320px, 1fr); column-gap: 48px;
    grid-template-areas: "head side" "summary side" "list side" "foot side"; align-items: start;
  }
  .ladder-head { grid-area: head; }
  .summary { grid-area: summary; }
  .climb { grid-area: list; }
  .ladder-foot { grid-area: foot; }
  .upnext { grid-area: side; position: sticky; top: 24px; margin: 0; max-width: 440px; }
}
