/* kelvinbiffi.com arcade. Hand-written, no framework. */

:root {
  --bg: #0b0716;
  --bg2: #130b24;
  --bg3: #1c1233;
  --line: #2e2050;
  --ink: #f1ecff;
  --dim: #a99cc9;
  --mute: #6f6490;
  --y: #ffd23d;
  --p: #ff3d7f;
  --cy: #29d3ff;
  --g: #7cff4f;
  --r: #ff4d4d;
  --pixel: "Press Start 2P", ui-monospace, monospace;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --gut: 16px;
  --max: 1080px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.65 var(--mono);
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(176, 107, 255, .16), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, rgba(255, 61, 127, .08), transparent 60%);
  z-index: -1;
}
a { color: var(--y); text-underline-offset: 3px; }
a:hover { color: #fff; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 3px solid var(--y); outline-offset: 3px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sr-skip { position: absolute; left: -9999px; }
.sr-skip:focus { left: 16px; top: 80px; z-index: 100; background: var(--y); color: #000; padding: 8px 12px; }

/* ---------- HUD ---------- */
.hud {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px var(--gut);
  background: rgba(11, 7, 22, .86);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--line);
}
.hud-logo { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; min-width: 0; }
.hud-mark {
  font: 10px/1 var(--pixel);
  background: var(--y); color: #1a1030;
  padding: 7px 6px 6px;
  box-shadow: 3px 3px 0 var(--p);
}
.hud-name { font: 10px/1.4 var(--pixel); letter-spacing: .5px; white-space: nowrap; }
.hud-right { display: flex; align-items: center; gap: 10px; }
.hud-lang { display: flex; border: 2px solid var(--line); }
.hud-lang a {
  font: 9px/1 var(--pixel); color: var(--dim); text-decoration: none;
  padding: 8px 8px 7px;
}
.hud-lang a[aria-current] { background: var(--line); color: var(--y); }
.hud-btn {
  display: grid; place-items: center;
  width: 36px; height: 34px;
  background: transparent; color: var(--dim);
  border: 2px solid var(--line); cursor: pointer;
}
.hud-btn[aria-pressed="true"] { color: var(--g); border-color: var(--g); }
.hud-btn .snd-on { display: none; }
.hud-btn[aria-pressed="true"] .snd-on { display: block; }
.hud-btn[aria-pressed="true"] .snd-off { display: none; }
.hud-skip {
  font: 9px/1.3 var(--pixel);
  color: #1a1030; background: var(--y);
  padding: 10px 12px 9px;
  text-decoration: none; white-space: nowrap;
  box-shadow: 3px 3px 0 var(--p);
  transition: transform .08s, box-shadow .08s;
}
.hud-skip:hover { color: #1a1030; transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--p); }
.hud-skip:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--p); }
@media (max-width: 640px) {
  .hud-name { display: none; }
  .hud-skip { padding: 9px 9px 8px; font-size: 8px; }
  .hud-right { gap: 6px; }
}

main, .foot { max-width: var(--max); margin: 0 auto; padding: 0 var(--gut); }
section { padding: 72px 0 8px; }
.sec-title {
  font: 16px/1.5 var(--pixel);
  margin: 0 0 12px;
  color: var(--ink);
  text-shadow: 3px 3px 0 var(--p);
}
.sec-title::before { content: "\25B8  "; color: var(--y); text-shadow: none; }
.sec-sub { color: var(--dim); max-width: 68ch; margin: 0 0 24px; }

/* ---------- Attract screen ---------- */
.attract { position: relative; padding: 64px 0 40px; text-align: center; }
.attract-sky { position: absolute; inset: 0 calc(50% - 50vw); z-index: -1; overflow: hidden; }
.attract-sky canvas { width: 100%; height: 100%; display: block; }
.kicker { font: 10px/1.6 var(--pixel); color: var(--g); letter-spacing: 1px; margin: 0 0 22px; }
.title { margin: 0 0 28px; font: 400 clamp(38px, 11vw, 104px)/1.05 var(--pixel); letter-spacing: 2px; }
.title-row { display: block; position: relative; color: var(--y); text-shadow: 4px 4px 0 var(--p), 8px 8px 0 #3b1f6e; }
.title-row + .title-row { color: var(--ink); }
.hero-line { font: 600 clamp(19px, 3.2vw, 26px)/1.45 var(--mono); max-width: 36ch; margin: 0 auto 16px; text-wrap: balance; }
.hero-sub { color: var(--dim); max-width: 62ch; margin: 0 auto 36px; text-wrap: pretty; }
.attract-cta { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.credits { font: 9px/1 var(--pixel); color: var(--mute); margin: 0; }

.btn-start, .btn-ghost {
  display: inline-block;
  font: 12px/1.3 var(--pixel);
  padding: 16px 22px 15px;
  text-decoration: none; cursor: pointer;
  border: 0;
  transition: transform .08s, box-shadow .08s;
}
.btn-start { background: var(--p); color: #fff; box-shadow: 4px 4px 0 #6b1740, inset -3px -3px 0 rgba(0,0,0,.25); }
.btn-start:hover { color: #fff; transform: translate(-1px, -1px); box-shadow: 5px 5px 0 #6b1740, inset -3px -3px 0 rgba(0,0,0,.25); }
.btn-start:active { transform: translate(4px, 4px); box-shadow: 0 0 0 #6b1740; }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.btn-ghost:hover { color: var(--y); box-shadow: inset 0 0 0 2px var(--y); }
#startBtn { animation: pulse 1.1s steps(2, end) infinite; }
@keyframes pulse { 50% { background: #c02a61; } }
.blink { animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

/* ---------- Hall ---------- */
.cabinet-frame {
  position: relative;
  border: 4px solid #000;
  box-shadow: 0 0 0 4px var(--line), 0 0 0 8px #000, 0 30px 80px rgba(176, 107, 255, .25);
  background: #05030b;
  line-height: 0;
}
#arcade {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
  touch-action: manipulation;
}
#arcade:focus-visible { outline: none; }
.cabinet-frame:focus-within { box-shadow: 0 0 0 4px var(--y), 0 0 0 8px #000, 0 30px 80px rgba(255, 210, 61, .2); }
.crt {
  position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,.22) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,.55) 100%);
  mix-blend-mode: multiply;
}
.touch-pad { display: none; }
@media (hover: none) and (pointer: coarse) {
  .touch-pad {
    display: flex; gap: 8px;
    position: absolute; right: 8px; bottom: 8px;
    line-height: 1;
  }
  .touch-pad button {
    width: 44px; height: 44px;
    font: 12px/1 var(--pixel);
    background: rgba(0,0,0,.55); color: var(--ink);
    border: 2px solid rgba(255,255,255,.35);
  }
  .touch-pad [data-act] { background: rgba(255, 61, 127, .75); }
}
.hint { font-size: 13px; color: var(--mute); margin: 14px 0 20px; }

.machine-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.chip {
  display: grid; grid-template-columns: 10px 1fr; column-gap: 10px; align-items: center;
  padding: 10px 12px;
  background: var(--bg2);
  border: 2px solid var(--line);
  color: var(--ink); text-decoration: none;
  transition: border-color .12s, transform .12s;
}
.chip:hover, .chip.is-near { border-color: var(--c); transform: translateY(-2px); color: var(--ink); }
.chip-dot { width: 10px; height: 10px; background: var(--c); box-shadow: 0 0 10px var(--c); grid-row: span 2; }
.chip-name { font: 9px/1.6 var(--pixel); }
.chip-tag { font-size: 12px; color: var(--dim); line-height: 1.4; }

/* ---------- High scores ---------- */
.score-table { list-style: none; padding: 0; margin: 0; border: 2px solid var(--line); background: var(--bg2); }
.score-row {
  display: grid; grid-template-columns: 56px minmax(90px, 140px) 1fr; gap: 14px; align-items: baseline;
  padding: 14px 16px;
  border-bottom: 2px dashed var(--line);
}
.score-row:last-child { border-bottom: 0; }
.rank { font: 10px/1 var(--pixel); color: var(--mute); }
.score-row:nth-child(1) .rank { color: var(--y); }
.score-row:nth-child(2) .rank { color: var(--cy); }
.score-row:nth-child(3) .rank { color: var(--p); }
.score-val { font: 20px/1 var(--pixel); color: var(--g); text-shadow: 0 0 12px rgba(124, 255, 79, .35); }
.score-label { color: var(--dim); }
@media (max-width: 560px) {
  .score-row { grid-template-columns: 44px 1fr; }
  .score-label { grid-column: 2; }
  .score-val { font-size: 16px; }
}

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.stat { background: var(--bg2); border: 2px solid var(--line); padding: 16px; }
.stat-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.stat-name { font: 10px/1.5 var(--pixel); }
.stat-lv { font: 9px/1 var(--pixel); color: var(--y); }
.stat-bar { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; margin-bottom: 12px; }
.stat-bar i { height: 12px; background: var(--bg3); }
.stat-bar i.on { background: var(--g); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.stats.seen .stat-bar i.on { animation: fill .3s steps(2) both; animation-delay: calc(var(--i) * 60ms); }
@keyframes fill { from { background: var(--bg3); } }
.stat-items { margin: 0; font-size: 13px; color: var(--dim); }

/* ---------- Ask ---------- */
.terminal { border: 2px solid var(--g); background: #050a05; box-shadow: 0 0 40px rgba(124, 255, 79, .08); }
.term-bar { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: space-between; padding: 10px 14px; border-bottom: 2px solid #173a17; }
.term-name { font: 10px/1.5 var(--pixel); color: var(--g); }
.term-pipe { font-size: 12px; color: #5d9a55; }
.term-log { padding: 16px 14px 4px; min-height: 120px; max-height: 460px; overflow-y: auto; color: #c9f5c0; font-size: 15px; }
.term-log:empty::before { content: "> READY."; color: #5d9a55; }
.msg { margin: 0 0 18px; }
.msg-q { color: var(--g); margin: 0 0 6px; word-break: break-word; }
.msg-q::before { content: "> "; }
.msg-a { margin: 0 0 8px; color: #e4ffe0; }
.msg.refused .msg-a { color: #ffd0d0; }
.stamp {
  display: inline-block;
  font: 9px/1 var(--pixel);
  color: var(--r); border: 2px solid var(--r);
  padding: 6px 7px 5px; margin: 0 0 8px;
  transform: rotate(-2deg);
}
.srcs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: #5d9a55; margin: 0 0 6px; }
.srcs a { color: var(--y); border: 1px solid #4d4217; padding: 1px 7px; text-decoration: none; }
.srcs a:hover { background: #2a2408; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: #5d9a55; }
.checks .ok::before { content: "\2713 "; color: var(--g); }
.checks .ko { color: #ff8b8b; }
.checks .ko::before { content: "\2717 "; }
.msg-mode { font-size: 12px; color: #8a8a5a; margin: 4px 0 0; }
.dots::after { content: ""; animation: dots 1s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.term-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 14px 12px; }
.q-chip {
  font: 13px/1.3 var(--mono);
  background: transparent; color: #9fd996;
  border: 1px dashed #2f6a2a;
  padding: 5px 9px; cursor: pointer;
}
.q-chip:hover { color: var(--g); border-color: var(--g); }
.term-form { display: flex; align-items: center; gap: 8px; border-top: 2px solid #173a17; padding: 10px 14px; }
.prompt { color: var(--g); font-weight: 600; }
.term-form input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; color: #e4ffe0;
  font: 16px/1.4 var(--mono);
  padding: 6px 0;
}
.term-form input::placeholder { color: #3f6e39; }
.term-form input:focus { outline: none; }
.term-form button {
  font: 10px/1 var(--pixel);
  background: var(--g); color: #06210a; border: 0;
  padding: 11px 12px 10px; cursor: pointer;
}
.term-form button:disabled { opacity: .5; cursor: wait; }
.term-meter {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  padding: 10px 14px; border-top: 2px solid #173a17;
  font-size: 12px; color: #5d9a55;
}
.term-meter strong { color: var(--y); font-weight: 600; }
.meter-coins { display: inline-flex; gap: 3px; }
.meter-coins i { width: 9px; height: 9px; background: var(--y); box-shadow: inset -2px -2px 0 #b8901c; }
.meter-coins i.part { opacity: .4; }

/* ---------- Fame ---------- */
.fame-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.fame-list li { background: var(--bg2); border: 2px solid var(--line); border-left: 6px solid var(--cy); padding: 16px; }
.fame-list strong { display: block; font: 10px/1.6 var(--pixel); color: var(--cy); margin-bottom: 8px; }
.fame-list span { color: var(--dim); font-size: 14px; }

/* ---------- Books as cartridges ---------- */
.cartridges { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.cart {
  position: relative; display: flex; align-items: flex-end;
  height: 150px; padding: 14px;
  background: #2a2a33;
  clip-path: polygon(0 12px, 12px 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
  text-decoration: none; color: #111;
  transition: transform .12s;
}
.cart::before { content: ""; position: absolute; left: 14px; right: 14px; top: 14px; height: 10px; background: repeating-linear-gradient(90deg, #1b1b22 0 6px, transparent 6px 10px); }
.cart-label { display: block; width: 100%; background: var(--c); padding: 12px 10px; font: 600 14px/1.35 var(--mono); box-shadow: inset -3px -3px 0 rgba(0,0,0,.18); }
.cart:hover { transform: translateY(-6px); color: #111; }

/* ---------- Continue ---------- */
.continue { text-align: center; padding-bottom: 56px; }
.cont-title { font: clamp(22px, 5vw, 40px)/1.4 var(--pixel); color: var(--y); text-shadow: 4px 4px 0 var(--p); margin: 0 0 18px; }
.count { color: var(--ink); display: inline-block; min-width: 1.2em; }
.cont-line { color: var(--dim); max-width: 56ch; margin: 0 auto 28px; }
.cont-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 24px; }
.cont-links { display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: center; font-size: 14px; }
.cont-links a { word-break: break-all; }

.foot { border-top: 2px solid var(--line); padding-top: 24px; padding-bottom: 40px; color: var(--mute); font-size: 13px; text-align: center; }
.foot a { color: var(--dim); }

/* ---------- Case dialog ---------- */
.case {
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0; border: 0;
  background: var(--bg2); color: var(--ink);
  box-shadow: 0 0 0 4px var(--c), 0 0 0 8px #000, 0 30px 120px rgba(0,0,0,.8);
}
.case::backdrop { background: rgba(5, 3, 11, .82); backdrop-filter: blur(3px); }
.case[open] { animation: boot .22s steps(4) both; }
@keyframes boot { from { clip-path: inset(50% -40px 50% -40px); } to { clip-path: inset(-40px -40px -40px -40px); } }
.case-inner { padding: 24px; }
.case-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
.case-tag { font-size: 13px; color: var(--dim); margin: 0 0 8px; }
.case-title { font: clamp(18px, 4vw, 26px)/1.3 var(--pixel); color: var(--c); margin: 0 0 10px; overflow-wrap: anywhere; }
.case-badge { display: inline-block; font: 9px/1 var(--pixel); background: var(--c); color: #111; padding: 6px 8px 5px; margin: 0; }
.case-close { font: 26px/1 var(--mono); width: 44px; height: 44px; background: transparent; color: var(--ink); border: 2px solid var(--line); cursor: pointer; flex-shrink: 0; }
.case-close:hover { border-color: var(--c); color: var(--c); }
.case-block { margin: 0 0 18px; }
.case-block h3 { font: 9px/1.6 var(--pixel); color: var(--mute); margin: 0 0 6px; text-transform: uppercase; }
.case-block p { margin: 0; }
.case-block.hl { border-left: 4px solid var(--c); padding: 10px 14px; background: var(--bg3); }
.case-block.hl h3 { color: var(--c); }
.facts { margin: 0; padding: 0; list-style: none; }
.facts li { padding-left: 20px; position: relative; margin-bottom: 4px; color: var(--dim); }
.facts li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 8px; height: 8px; background: var(--c); }
.case-stack { font-size: 13px; color: var(--dim); margin: 0 0 22px; }
.case-stack span { font: 9px/1 var(--pixel); color: var(--mute); margin-right: 6px; }
.case-shot { display: block; width: 100%; image-rendering: pixelated; border: 2px solid #000; margin: 0 0 16px; }
.case-text { margin: 0 0 14px; }
.case-text.dim { color: var(--dim); font-size: 14px; margin-bottom: 22px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

.skip-short { display: none; }
@media (max-width: 640px) {
  .skip-long { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .skip-short { display: inline; }
}

/* ---------- How to play ---------- */
.howto { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; font-size: 13px; color: var(--dim); }
.howto li { display: flex; align-items: center; gap: 5px; }
kbd {
  font: 9px/1 var(--pixel); color: var(--ink);
  background: var(--bg3); border: 2px solid var(--line); border-bottom-width: 4px;
  padding: 5px 6px 3px; min-width: 24px; text-align: center;
}
.howto-goal { color: var(--y); }
.coin-ico { width: 10px; height: 12px; background: var(--y); box-shadow: inset -2px 0 0 #b8901c; display: inline-block; }
.howto-click { color: var(--mute); }
@media (hover: none) and (pointer: coarse) { .howto li:nth-child(-n+3) { display: none; } }

/* ---------- Speech bubble over the hall ---------- */
.bubble {
  position: absolute; z-index: 3;
  top: 8%; left: 50%;
  transform: translateX(-50%);
  width: max-content; max-width: min(340px, 62%);
  background: #fffdf5; color: #1a1030;
  padding: 10px 12px 9px;
  box-shadow: 0 0 0 3px #000, 5px 5px 0 3px rgba(0,0,0,.45);
  line-height: 1.4;
  pointer-events: none;
  animation: pop .16s steps(3) both;
}
.bubble::after {
  content: ""; position: absolute; top: 100%; left: calc(50% + var(--tail, 0%));
  border: 8px solid transparent; border-top-color: #fffdf5;
  transform: translateX(-50%);
  filter: drop-shadow(0 3px 0 #000);
}
.bubble strong { display: block; font: 9px/1.4 var(--pixel); margin-bottom: 4px; text-shadow: 1px 1px 0 #1a1030; }
.bubble span { display: block; font: 500 14px/1.4 var(--mono); }
.bubble em { display: block; font: normal 8px/1 var(--pixel); color: #b0126a; margin-top: 7px; }
@keyframes pop { from { transform: translateX(-50%) scale(.6); opacity: 0; } }
@media (max-width: 640px) { .bubble { max-width: 86%; padding: 8px 10px; } .bubble span { font-size: 12.5px; } }

/* ---------- Achievement toasts ---------- */
.toasts { position: absolute; left: 8px; bottom: 8px; z-index: 4; display: flex; flex-direction: column; gap: 6px; max-width: min(360px, 80%); line-height: 1.4; pointer-events: none; }
.toast {
  pointer-events: auto;
  background: #0b0716; border: 2px solid var(--y); box-shadow: 4px 4px 0 var(--p);
  padding: 8px 10px; font-size: 13px; color: var(--ink);
  animation: slide .25s steps(4) both;
}
.toast b { display: block; font: 8px/1.4 var(--pixel); color: var(--y); margin-bottom: 3px; }
.toast b::before { content: "\2605 "; }
.toast.out { opacity: 0; transition: opacity .5s; }
.toast-cta { display: inline-block; margin-top: 6px; font-weight: 600; word-break: break-all; }
@keyframes slide { from { transform: translateX(-30px); opacity: 0; } }

/* ---------- Case one-liner ---------- */
.case-one { font: 600 18px/1.45 var(--mono); color: var(--ink); margin: 0 0 12px; max-width: 46ch; }
