/* CHESS REFLEX ARCADE — 90s Memphis / "Saved by the Bell" energy.
   Hard offset shadows, chunky outlines, neon pastels, bold display type. */

:root {
  --bg: #221a3d;
  --bg2: #2c2150;
  --ink: #140f29;
  --pink: #ff5ca2;
  --teal: #2ad6c6;
  --yellow: #ffd23f;
  --purple: #9b6bff;
  --coral: #ff7a59;
  --cream: #fdeccb;
  --white: #ffffff;
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 4px 4px 0 var(--ink);
  --disp: "Bungee", system-ui, sans-serif;
  --ui: "Rubik", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin: 0; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  font-family: var(--ui);
  color: var(--white);
  background:
    radial-gradient(circle at 15% 12%, rgba(155,107,255,.35), transparent 40%),
    radial-gradient(circle at 85% 88%, rgba(42,214,198,.30), transparent 40%),
    var(--bg);
  overflow: hidden;
  user-select: none;
}
body::after { /* subtle CRT scanlines */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 999; opacity: .06;
  background: repeating-linear-gradient(0deg, #000 0 1px, transparent 1px 3px);
}

/* ---------- Drifting chess-piece backdrop ---------- */
.bg-pieces { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bgp {
  position: absolute; opacity: .16; line-height: 1; user-select: none;
  text-shadow: 0 0 16px currentColor, 0 0 4px currentColor;
  animation: bgFloat var(--dur, 11s) ease-in-out var(--delay, 0s) infinite;
  will-change: transform;
}
@keyframes bgFloat {
  0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1); }
  50% { transform: translate(var(--dx, 0), var(--dy, 0)) rotate(var(--rot, 20deg)) scale(1.14); }
}

/* ---------- Screens ---------- */
#app { position: relative; z-index: 1; height: 100%; }
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  padding: 26px 20px calc(26px + env(safe-area-inset-bottom)); gap: 18px;
  max-width: 520px; margin: 0 auto; overflow-y: auto;
  animation: pop .25s cubic-bezier(.2,.8,.3,1.2);
}
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }

/* ---------- Logo / menu ---------- */
.logo { text-align: center; line-height: .92; margin-top: 5vh; }
.logo span { display: block; font-family: var(--disp); }
.logo-1 { font-size: clamp(40px, 13vw, 64px); color: var(--yellow); text-shadow: 4px 4px 0 var(--ink); transform: rotate(-3deg); }
.logo-2 { font-size: clamp(40px, 13vw, 64px); color: var(--teal); text-shadow: 4px 4px 0 var(--ink); transform: rotate(2deg); }
.logo-3 { font-size: clamp(22px, 7.5vw, 38px); color: var(--pink); text-shadow: 3px 3px 0 var(--ink); transform: rotate(-1deg); letter-spacing: 4px; }
.tagline { font-weight: 700; color: var(--cream); text-align: center; font-size: 1rem; }

.menu-btns { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 320px; margin-top: 10px; }
.menu-foot { margin-top: auto; display: flex; gap: 12px; }

.big-btn {
  font-family: var(--disp); font-size: 1.15rem; color: var(--ink); cursor: pointer;
  border: 4px solid var(--ink); border-radius: 16px; padding: 16px 22px; box-shadow: var(--shadow);
  transition: transform .06s, box-shadow .06s; letter-spacing: 1px;
}
.big-btn:active { transform: translate(4px, 4px); box-shadow: 2px 2px 0 var(--ink); }
.big-btn.pink { background: var(--pink); } .big-btn.teal { background: var(--teal); }
.big-btn.yellow { background: var(--yellow); } .big-btn.purple { background: var(--purple); color: var(--white); }

.chip {
  font-family: var(--ui); font-weight: 900; font-size: .8rem; color: var(--ink); background: var(--cream);
  border: 3px solid var(--ink); border-radius: 999px; padding: 8px 14px; cursor: pointer; box-shadow: var(--shadow-sm);
}
.chip:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }

.back-btn, .quit-btn {
  align-self: flex-start; font-family: var(--disp); font-size: .85rem; background: var(--yellow); color: var(--ink);
  border: 3px solid var(--ink); border-radius: 12px; padding: 8px 14px; cursor: pointer; box-shadow: var(--shadow-sm);
}
.quit-btn { align-self: center; margin-top: 6px; background: var(--coral); }
.back-btn:active, .quit-btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }

.screen-title { font-family: var(--disp); text-align: center; font-size: clamp(22px,7vw,34px); line-height: 1; color: var(--white); }
.screen-title b { color: var(--teal); }

/* ---------- Game grid ---------- */
.game-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; }
.game-card {
  border: 4px solid var(--ink); border-radius: 18px; padding: 16px 12px; cursor: pointer; text-align: center;
  box-shadow: var(--shadow); transition: transform .06s, box-shadow .06s; color: var(--ink); position: relative; overflow: hidden;
}
.game-card:active { transform: translate(4px,4px); box-shadow: 2px 2px 0 var(--ink); }
.game-card .gc-emoji { font-size: 2.2rem; }
.game-card .gc-title { font-family: var(--disp); font-size: .95rem; margin-top: 6px; line-height: 1; }
.game-card .gc-blurb { font-weight: 700; font-size: .72rem; margin-top: 6px; opacity: .85; }
.game-card.soon { opacity: .85; cursor: not-allowed; }
.game-card.soon::after { content: "SOON"; position: absolute; top: 8px; right: -28px; background: var(--ink); color: var(--yellow);
  font-family: var(--disp); font-size: .6rem; padding: 3px 30px; transform: rotate(38deg); }

/* ---------- Game intro / how-to ---------- */
.how-card {
  width: 100%; max-width: 380px; background: var(--bg2); border: 4px solid var(--ink);
  border-radius: 18px; padding: 16px 18px; box-shadow: var(--shadow);
}
.how-lore { font-weight: 900; font-size: .62rem; letter-spacing: 2px; color: var(--teal); text-transform: uppercase; margin-bottom: 8px; }
.how-goal { font-family: var(--disp); font-size: 1.05rem; color: var(--yellow); line-height: 1.1; margin-bottom: 14px; }
.how-steps { display: flex; flex-direction: column; gap: 10px; }
.how-step { display: flex; align-items: center; gap: 12px; }
.hs-ic { font-size: 1.3rem; width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto;
  background: var(--bg); border: 3px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow-sm); }
.hs-t { font-weight: 800; font-size: .85rem; color: var(--cream); line-height: 1.25; }
.start-one .tc-name { text-align: center; font-size: 1.4rem; }

/* ---------- Bar label + danger + callout ---------- */
.bar-row { display: flex; align-items: center; gap: 10px; width: 100%; }
.bar-label { font-family: var(--disp); font-size: .62rem; color: var(--cream); letter-spacing: 1px; min-width: 56px; }
.bar-row .timebar { flex: 1; }
.aboard.bio.board-danger { animation: boardDanger .5s ease-in-out infinite; }
@keyframes boardDanger { 50% { box-shadow: var(--shadow), 0 0 0 4px var(--coral), 0 0 24px var(--coral); } }

.callout {
  position: absolute; top: 38%; left: 50%; transform: translate(-50%,-50%); z-index: 20; pointer-events: none;
  font-family: var(--disp); font-size: clamp(20px, 6.5vw, 34px); text-align: center; line-height: 1;
  color: var(--white); text-shadow: 3px 3px 0 var(--ink); max-width: 90%;
}
.callout.good { color: var(--yellow); } .callout.bad { color: var(--coral); }
.callout.show { animation: calloutPop 1.05s ease-out; }
@keyframes calloutPop { 0% { transform: translate(-50%,-50%) scale(.5); opacity: 0; } 18% { transform: translate(-50%,-50%) scale(1.15); opacity: 1; } 80% { opacity: 1; } 100% { transform: translate(-50%,-90%) scale(1); opacity: 0; } }

/* ---------- Tier picker ---------- */
.tier-grid { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 360px; }
.tier-card {
  border: 4px solid var(--ink); border-radius: 16px; padding: 16px 18px; cursor: pointer; text-align: left;
  background: var(--cream); color: var(--ink); box-shadow: var(--shadow); transition: transform .06s, box-shadow .06s;
}
.tier-card:active { transform: translate(4px,4px); box-shadow: 2px 2px 0 var(--ink); }
.tier-card .tc-name { font-family: var(--disp); font-size: 1.2rem; }
.tier-card .tc-desc { font-weight: 700; font-size: .82rem; margin-top: 3px; opacity: .8; }

/* coordinate labels (Recruit tier) */
.lbl { position: absolute; font-family: var(--disp); font-size: .5rem; color: var(--ink); opacity: .55; }
.lbl-f { bottom: 1px; right: 3px; } .lbl-r { top: 1px; left: 3px; }

/* Bio-Evolution targets + stage colors */
.aboard.bio .asq.lite { background: var(--bio-lite, var(--cream)); }
.aboard.bio .asq.dark { background: var(--bio-dark, var(--teal)); transition: background .3s; }
.aboard.bio .asq.lite { transition: background .3s; }
.bio-target {
  position: absolute; inset: 8%; background-size: contain; background-repeat: no-repeat; background-position: center;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.4));
  transform: scale(0); transition: transform .12s cubic-bezier(.2,.9,.3,1.4); pointer-events: none;
}
.bio-target.in { transform: scale(1); }
/* INFECTED targets: a sickly green biohazard glow + pulsing halo (not a colour). */
.bio-target.target { filter: drop-shadow(0 0 5px #46f085) drop-shadow(0 0 12px #1e9e4f) drop-shadow(0 2px 2px rgba(0,0,0,.4)); }
.bio-target.target::before {
  content: ""; position: absolute; inset: -16%; border-radius: 50%; z-index: -1;
  background: radial-gradient(circle, rgba(54,224,122,.62), rgba(54,224,122,0) 68%);
  animation: infectPulse 1.05s ease-in-out infinite;
}
@keyframes infectPulse { 0%,100% { transform: scale(1); opacity: .7; } 50% { transform: scale(1.25); opacity: .95; } }
.bio-target.decoy { opacity: .9; }
.aboard.bio.evolve { animation: evolveFlash .4s; }
@keyframes evolveFlash { 0% { filter: brightness(2.2) saturate(1.6); transform: scale(1.04); } }

.confetti { position: absolute; width: 9px; height: 9px; border-radius: 2px; pointer-events: none; z-index: 6;
  transform: translate(-50%,-50%); animation: conf .72s ease-out forwards; }
@keyframes conf { to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(240deg); opacity: 0; } }

.asq { position: relative; }

/* ---------- HUD / game ---------- */
.game { justify-content: flex-start; }
.hud { display: flex; align-items: center; justify-content: space-between; width: 100%; font-weight: 900; font-size: .72rem; text-align: center; }
.hud b { font-family: var(--disp); font-size: 1.3rem; color: var(--yellow); }
.hud-combo b { color: var(--pink); }
.hud-prompt {
  font-family: var(--disp); font-size: clamp(30px, 11vw, 52px); color: var(--white);
  background: var(--purple); border: 4px solid var(--ink); border-radius: 14px; padding: 4px 18px; box-shadow: var(--shadow-sm);
  min-width: 110px; transform: rotate(-2deg);
}
.timebar { width: 100%; height: 16px; background: var(--bg2); border: 3px solid var(--ink); border-radius: 999px; overflow: hidden; box-shadow: var(--shadow-sm); }
.timebar > i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--teal), var(--yellow)); transition: width .1s linear; }
.timebar.danger { animation: dangerPulse .5s ease-in-out infinite; }
.timebar.danger > i { background: var(--coral); }
@keyframes dangerPulse { 50% { box-shadow: 4px 4px 0 var(--ink), 0 0 14px var(--coral); } }

.screen.game { max-width: 560px; padding-left: 10px; padding-right: 10px; }
.stage { width: 100%; max-width: min(94vw, 500px); aspect-ratio: 1; margin: 6px auto 0; position: relative; }
.aboard {
  position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8,1fr); grid-template-rows: repeat(8,1fr);
  border: 5px solid var(--ink); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow);
}
.asq { display: flex; align-items: center; justify-content: center; cursor: pointer; transition: filter .05s; }
.asq.lite { background: var(--cream); }
.asq.dark { background: var(--teal); }
.asq:active { filter: brightness(.9); }
.asq.flash-good { animation: flashGood .35s; }
.asq.flash-bad { animation: flashBad .35s; }
@keyframes flashGood { 0% { background: var(--yellow); } }
@keyframes flashBad { 0%,100%{} 25%{ background: var(--coral);} 75%{ background: var(--coral);} }

.pop { position: absolute; z-index: 5; font-family: var(--disp); font-size: 1.4rem; pointer-events: none;
  transform: translate(-50%,-50%); animation: popUp .6s ease-out forwards; text-shadow: 2px 2px 0 var(--ink); }
.pop.good { color: var(--yellow); } .pop.bad { color: var(--coral); }
@keyframes popUp { to { transform: translate(-50%,-130%) scale(1.3); opacity: 0; } }
.shake { animation: shake .3s; }
@keyframes shake { 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }

/* ---------- Result ---------- */
.result { justify-content: center; }
.result-title { font-family: var(--disp); font-size: clamp(34px,11vw,56px); color: var(--yellow); text-shadow: 4px 4px 0 var(--ink); transform: rotate(-3deg); }
.result-card { background: var(--bg2); border: 4px solid var(--ink); border-radius: 20px; padding: 22px; width: 100%; max-width: 340px; box-shadow: var(--shadow); text-align: center; }
.big-score { font-family: var(--disp); font-size: clamp(46px,16vw,76px); color: var(--teal); line-height: 1; }
.result-stats { display: flex; justify-content: space-around; margin-top: 14px; font-weight: 900; font-size: .8rem; color: var(--cream); }
.result-stats b { display: block; font-family: var(--disp); font-size: 1.3rem; color: var(--white); }
.hiscore-banner { margin-top: 16px; font-family: var(--disp); color: var(--yellow); font-size: 1rem; }
.hiscore-banner .hs-text { display: block; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.initials { margin-top: 10px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.initials input { font-family: var(--disp); font-size: 1.2rem; width: min(86vw, 300px); text-align: center; text-transform: uppercase;
  background: var(--white); color: var(--ink); border: 4px solid var(--ink); border-radius: 12px; letter-spacing: 2px; padding: 8px; }
.post-btn { font-family: var(--disp); font-size: .85rem; padding: 10px 16px; cursor: pointer;
  background: var(--teal); color: var(--ink); border: 4px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow-sm); }
.post-btn:disabled { opacity: .6; cursor: default; }
.post-status { font-family: var(--body); font-weight: 700; font-size: .8rem; color: var(--cream); min-height: 1.1em; animation: none; }
.post-status.ok { color: var(--teal); }
.post-status.err { color: var(--pink); }
.board-badge { font-family: var(--body); font-size: .6rem; font-weight: 900; padding: 2px 7px; border-radius: 999px; vertical-align: middle; }
.board-badge.global { background: var(--teal); color: var(--ink); }
.board-badge.local { background: var(--bg1); color: var(--cream); border: 2px solid rgba(255,255,255,.25); }
.score-row .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.result-btns { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; justify-content: center; }
.result-btns .big-btn { font-size: .9rem; padding: 13px 16px; }

/* ---------- Scores ---------- */
.score-board { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.score-group { background: var(--bg2); border: 4px solid var(--ink); border-radius: 16px; padding: 14px; box-shadow: var(--shadow-sm); }
.score-group h3 { font-family: var(--disp); color: var(--teal); font-size: .95rem; margin-bottom: 8px; }
.score-row { display: flex; justify-content: space-between; padding: 6px 4px; font-weight: 900; border-bottom: 2px dashed rgba(255,255,255,.12); }
.score-row .rank { color: var(--yellow); width: 28px; }
.score-row .who { color: var(--pink); font-family: var(--disp); flex: 1; }
.score-row .pts { font-family: var(--disp); color: var(--white); }
.score-empty { color: var(--cream); font-weight: 700; opacity: .7; text-align: center; padding: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); z-index: 1000;
  background: var(--ink); color: var(--yellow); font-weight: 900; font-size: .9rem;
  border: 3px solid var(--yellow); border-radius: 999px; padding: 12px 20px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
