@font-face { font-family: "Press Start 2P"; src: url("../fonts/PressStart2P.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/JetBrainsMono-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/JetBrainsMono-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

/* Standalone page: keep content clear of phone system bars. */
:root { padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
[hidden] { display: none !important; }

/* Skins. Layout: a cool-grey computer case holds an LCD readout, a recessed PCB screen and a row of keycaps. */
:root {
  --case:#c9ced6; --case-hi:#e7eaef; --case-lo:#a9b0bb; --case-edge:#6c7482;
  --ink:#1d2430; --ink-soft:#485263;
  --pcb:#0a2326; --pcb-tile:#12383c; --pcb-plate:#25525b; --pcb-line:#1a4b4e; --rivet:#8fb6be;
  --trace-off:#3d8189; --live:#ffc43d; --live-core:#fff2c2; --on-live:#1d2430;
  --phosphor:#7dffa4; --screen-off:#091416; --screen-ink:#0b4a25;
  --pc-body:#e7eaef; --pc-edge:#6c7482; --src-box:#1d2430;
  --led-off:#59606b; --led-red:#ff5a43;
  --lcd:#0c1a1f; --lcd-ink:#8fffb0; --hint:#5fe3ff; --shade:#0d1217; --star-off:#2a4651;
  --display:"Press Start 2P", ui-monospace, Menlo, Consolas, monospace;
  --body:"JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-skin="terminal"] {
  --case:#1a1e23; --case-hi:#3a444f; --case-lo:#12151a; --case-edge:#07090c;
  --ink:#dbe5ec; --ink-soft:#8d9eae;
  --pcb:#06120c; --pcb-tile:#0d2216; --pcb-plate:#1b3a29; --pcb-line:#12301f; --rivet:#5f8f73;
  --trace-off:#2e7048; --live:#7dff9a; --live-core:#eaffef; --on-live:#04140a;
  --phosphor:#ffb62e; --screen-off:#0b0f0c; --screen-ink:#4a2c00;
  --pc-body:#8b98a5; --pc-edge:#2c333b; --src-box:#04140a;
  --led-off:#46515c;
  --lcd:#050a07; --lcd-ink:#7dff9a; --shade:#000000; --star-off:#233a2b;
  color-scheme: dark;
}
:root[data-skin="blueprint"] {
  --case:#d9e0ea; --case-hi:#f0f4fa; --case-lo:#b5c1d3; --case-edge:#6a7f9f;
  --ink:#14233c; --ink-soft:#47597a;
  --pcb:#0a2146; --pcb-tile:#103466; --pcb-plate:#1c4a8a; --pcb-line:#1a4684; --rivet:#9dbfee;
  --trace-off:#4b7bbd; --live:#8ff3ff; --live-core:#ffffff; --on-live:#06222a;
  --phosphor:#a5ff82; --screen-off:#071730; --screen-ink:#0e4a12;
  --pc-body:#f0f4fa; --pc-edge:#6a7f9f; --src-box:#06182e;
  --led-off:#5b6a82;
  --lcd:#0a1a33; --lcd-ink:#8ff3ff; --hint:#ffd24d; --shade:#050c1a; --star-off:#27487a;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--case); color: var(--ink);
  font: 15px/1.3 var(--body);
  overscroll-behavior: none; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
}
button { font-family: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

#app {
  height: 100%; max-width: 560px; margin-inline: auto;
  padding-block: 10px; padding-inline: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand {
  margin: 0; font: 400 14px/1 var(--display); letter-spacing: .06em;
  display: flex; align-items: center; gap: 10px; text-shadow: 1px 1px 0 var(--case-hi);
}
.pwr { display: inline-block; width: 11px; height: 11px; background: var(--led-red); border: 2px solid var(--case-edge); }
.pwr.on { background: var(--phosphor); box-shadow: 0 0 8px var(--phosphor); }

.lcd {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  padding: 6px 12px 8px; background: var(--lcd); color: var(--lcd-ink);
  border: 4px solid; border-color: var(--case-edge) var(--case-hi) var(--case-hi) var(--case-edge);
  text-shadow: 0 0 6px color-mix(in srgb, var(--lcd-ink) 45%, transparent);
}
.lcd > div { min-width: 0; }
.lcd .l { display: block; font-size: 10px; letter-spacing: .12em; opacity: .7; }
.lcd .v { display: block; font-size: 22px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }

.status { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 15px; }
.goal { display: flex; align-items: center; gap: 10px; min-width: 0; }
.meter { width: 84px; height: 13px; background: var(--led-off); border: 2px solid var(--ink); flex: none; }
.meter i { display: block; height: 100%; width: 0; background: var(--phosphor); box-shadow: 0 0 8px var(--phosphor); transition: width .15s steps(6); }
.tier { font: 400 10px/1 var(--display); color: var(--ink-soft); letter-spacing: .06em; white-space: nowrap; }

.stage { flex: 1 1 0; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.bezel {
  position: relative; padding: 6px; background: var(--pcb); line-height: 0;
  border: 4px solid; border-color: var(--case-edge) var(--case-hi) var(--case-hi) var(--case-edge);
}
.bezel::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,.10) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 62%, rgba(0,0,0,.32) 100%);
}
.bezel.won { animation: glow 1.1s ease-in-out infinite alternate; }
@keyframes glow {
  from { box-shadow: 0 0 0 0 transparent; }
  to { box-shadow: 0 0 22px 3px color-mix(in srgb, var(--live) 75%, transparent); }
}
canvas { display: block; touch-action: manipulation; }

.tip { margin: 0; text-align: center; font-size: 13px; line-height: 1.3; color: var(--ink-soft); min-height: 2.6em; }
.mouse-only { display: none; }
@media (hover: hover) and (pointer: fine) { .mouse-only { display: inline; } }

.keys { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.key {
  font: 400 9px/1 var(--display); letter-spacing: .02em; color: var(--ink);
  background: var(--case-hi); border: 2px solid var(--case-edge); border-bottom-width: 5px; border-radius: 3px;
  padding: 13px 2px 11px; min-height: 48px; cursor: pointer; text-align: center;
}
.key:active { transform: translateY(3px); border-bottom-width: 2px; padding-bottom: 14px; }
.key:disabled { opacity: .45; cursor: default; }
#btnSnd[aria-pressed="false"] { text-decoration: line-through; color: var(--ink-soft); }
.key.small { padding: 10px 12px 8px; min-height: 0; }
.key.wide { padding-inline: 12px; font-size: 11px; }
.key.primary, .key.skin[aria-pressed="true"] { background: var(--live); color: var(--on-live); }
.key.ghost { background: var(--case); }

.overlay {
  position: fixed; inset: 0; z-index: 5; display: flex; overflow: auto;
  background: color-mix(in srgb, var(--shade) 78%, transparent);
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
}
.panel {
  width: 100%; max-width: 400px; margin: auto; padding: 18px; background: var(--case);
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 8px 0 rgba(0,0,0,.35);
  border: 4px solid; border-color: var(--case-hi) var(--case-edge) var(--case-edge) var(--case-hi);
}
.panel h2 { margin: 0; font: 400 14px/1.5 var(--display); text-align: center; text-wrap: balance; }
.sub { margin: 0; font: 400 10px/1.4 var(--display); letter-spacing: .06em; color: var(--ink-soft); }
.note { margin: 0; font-size: 13px; color: var(--ink-soft); text-align: center; }

.diffs { display: flex; flex-direction: column; gap: 8px; }
.diff {
  display: flex; flex-direction: column; gap: 3px; text-align: left; color: var(--ink);
  background: var(--case-hi); border: 2px solid var(--case-edge); border-bottom-width: 5px; border-radius: 3px;
  padding: 10px 12px 8px; cursor: pointer;
}
.diff:active { transform: translateY(3px); border-bottom-width: 2px; padding-bottom: 11px; }
.diff b { font: 400 12px/1.4 var(--display); }
.diff span { font-size: 14px; }
.diff em { font-style: normal; font-size: 12px; color: var(--ink-soft); }
.diff.cur { background: var(--live); color: var(--on-live); }
.diff.cur em { color: var(--on-live); }

.seed { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.seed input {
  font: inherit; font-size: 20px; letter-spacing: .08em; width: 100%; padding: 6px 10px;
  color: var(--lcd-ink); background: var(--lcd); -webkit-user-select: text; user-select: text;
  border: 3px solid; border-color: var(--case-edge) var(--case-hi) var(--case-hi) var(--case-edge);
}
.seed input::placeholder { color: var(--lcd-ink); opacity: .45; }
.skins { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

.lvlist { display: flex; flex-direction: column; gap: 14px; }
.chap { display: flex; flex-direction: column; gap: 6px; }
.chap h3 { margin: 0; display: flex; justify-content: space-between; gap: 8px; font: 400 10px/1.4 var(--display); letter-spacing: .04em; }
.chap h3 em { font-style: normal; color: var(--ink-soft); }
.lvgrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.lv {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0 5px; color: var(--ink);
  background: var(--case-hi); border: 2px solid var(--case-edge); border-bottom-width: 4px; border-radius: 3px; cursor: pointer;
}
.lv:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; padding-bottom: 7px; }
.lv .n { font-size: 16px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.lv .pips { display: flex; gap: 2px; }
.pip { width: 7px; height: 7px; background: var(--case-lo); }
.pip.on { background: var(--live); outline: 1px solid var(--ink); }
.lv.next { background: var(--live); color: var(--on-live); }
.lv:disabled { cursor: default; color: var(--ink-soft); background: repeating-linear-gradient(135deg, var(--case-lo) 0 4px, var(--case) 4px 8px); }

.stars { display: flex; justify-content: center; gap: 10px; padding: 10px; background: var(--lcd); }
.star { width: 30px; height: 30px; background: var(--star-off); clip-path: polygon(50% 0, 62% 36%, 100% 38%, 70% 60%, 80% 100%, 50% 76%, 20% 100%, 30% 60%, 0 38%, 38% 36%); }
.star.on { background: var(--live); }
.res { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.res div { background: var(--lcd); color: var(--lcd-ink); padding: 6px 8px; }
.res dt { font-size: 10px; letter-spacing: .12em; opacity: .7; }
.res dd { margin: 0; font-size: 20px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; }
.row .key { flex: 1; }

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