:root {
  --ink: #141124;
  --ink2: #0e0c1c;
  --panel: #1e1937;
  --panel2: #272148;
  --line: #37305f;
  --text: #ece8f6;
  --dim: #9b94ba;
  --mono: "Cascadia Mono", Consolas, "Courier New", monospace;
  --sans: "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: radial-gradient(1200px 700px at 50% -10%, #221c44 0%, var(--ink) 55%, var(--ink2) 100%);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

#app { height: 100vh; display: flex; flex-direction: column; }

/* ---------- menu ---------- */
#menu { flex: 1; overflow-y: auto; padding: 28px 40px 40px; }
.brand { text-align: center; margin: 6px 0 24px; }
.brand h1 {
  font-family: var(--mono);
  font-size: 34px;
  letter-spacing: 0.45em;
  text-indent: 0.45em;
  font-weight: 700;
}
.brand h1 .ten { color: #ffd76e; }
.brand p { color: var(--dim); margin-top: 6px; font-size: 13px; letter-spacing: 0.12em; }
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  max-width: 1080px;
  margin: 0 auto;
}
.tile {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 14px 12px;
  text-align: left;
  color: var(--text);
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.tile:hover, .tile:focus-visible {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 6px 24px -6px var(--accent-dim), inset 0 0 0 1px var(--accent-dim);
}
.tile canvas { display: block; margin: 2px auto 10px; }
.tile .t-key {
  float: right; font-family: var(--mono); font-size: 11px; color: var(--dim);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px;
}
.tile h2 { font-size: 16px; letter-spacing: 0.04em; }
.tile .t-blurb { color: var(--dim); font-size: 12px; margin-top: 3px; min-height: 28px; }
.tile .t-best { font-family: var(--mono); font-size: 11px; color: var(--accent); margin-top: 7px; }

/* ---------- game chrome ---------- */
#game-screen { flex: 1; display: none; flex-direction: column; min-height: 0; }
#game-header {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 18px; border-bottom: 1px solid var(--line);
  background: rgba(20, 17, 36, 0.7);
}
#btn-menu {
  background: none; border: 1px solid var(--line); color: var(--text);
  border-radius: 7px; padding: 6px 12px; font-size: 13px;
}
#btn-menu:hover { border-color: var(--accent); color: var(--accent); }
#game-title { font-size: 17px; font-weight: 600; letter-spacing: 0.06em; color: var(--accent); }
.hud { font-family: var(--mono); font-size: 14px; color: var(--text); white-space: nowrap; }
.hud b { color: var(--accent); font-weight: 700; }
#game-hint { margin-left: auto; color: var(--dim); font-size: 12px; text-align: right; }
#game-area {
  flex: 1; min-height: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 14px;
}

/* overlays (pause / game over) */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 8, 20, 0.78);
}
.overlay .card {
  background: var(--panel); border: 1px solid var(--accent);
  border-radius: 14px; padding: 28px 44px; text-align: center;
  box-shadow: 0 10px 50px -10px var(--accent-dim);
}
.overlay h3 { font-size: 24px; letter-spacing: 0.1em; color: var(--accent); }
.overlay .ov-score { font-family: var(--mono); font-size: 16px; margin: 12px 0 4px; }
.overlay .ov-best { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.overlay .ov-keys { margin-top: 16px; color: var(--dim); font-size: 13px; }
.overlay .ov-keys kbd, #game-hint kbd, .brand kbd {
  font-family: var(--mono); font-size: 11px; border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; color: var(--text);
}
.overlay .ov-btns { margin-top: 14px; display: flex; gap: 10px; justify-content: center; }
.overlay .ov-btns button {
  border-radius: 8px; padding: 8px 18px; font-size: 14px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
}
.overlay .ov-btns button.primary { border-color: var(--accent); color: var(--accent); }
.overlay .ov-btns button:hover { filter: brightness(1.25); }

/* ---------- shared game widgets ---------- */
canvas.game-canvas { background: var(--ink2); border: 1px solid var(--line); border-radius: 10px; image-rendering: pixelated; }
.side-panel { font-family: var(--mono); font-size: 13px; color: var(--dim); display: flex; flex-direction: column; gap: 12px; margin-left: 18px; }
.side-panel .sp-box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.side-panel .sp-box b { color: var(--text); display: block; font-size: 16px; margin-top: 2px; }

.diff-bar { display: flex; gap: 8px; margin-bottom: 12px; justify-content: center; }
.diff-bar button {
  background: var(--panel); color: var(--dim); border: 1px solid var(--line);
  border-radius: 7px; padding: 5px 13px; font-size: 13px;
}
.diff-bar button.on { color: var(--accent); border-color: var(--accent); }

/* 2048 */
.g2048-wrap { display: flex; flex-direction: column; align-items: center; }
.g2048-board {
  position: relative; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px;
  display: grid; grid-template-columns: repeat(4, 96px); grid-template-rows: repeat(4, 96px); gap: 10px;
}
.g2048-cell { background: var(--ink2); border-radius: 8px; }
.g2048-tile {
  position: absolute; width: 96px; height: 96px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 700; font-size: 34px;
  transition: top 0.1s ease, left 0.1s ease;
}
.g2048-tile.pop { animation: pop 0.14s ease; }
@keyframes pop { from { transform: scale(0.4); } to { transform: scale(1); } }

/* minesweeper */
.mines-grid { display: grid; gap: 2px; background: var(--line); border: 2px solid var(--line); border-radius: 8px; padding: 2px; }
.mines-cell {
  width: 30px; height: 30px; border: none; border-radius: 3px;
  background: var(--panel2); color: var(--text);
  font-family: var(--mono); font-weight: 700; font-size: 15px; line-height: 1;
}
.mines-cell:hover { filter: brightness(1.3); }
.mines-cell.open { background: var(--ink2); cursor: default; }
.mines-cell.open:hover { filter: none; }
.mines-cell.boom { background: #5c1f2b; }

/* memory */
.mem-grid { display: grid; grid-template-columns: repeat(4, 92px); gap: 12px; }
.mem-card { perspective: 600px; width: 92px; height: 92px; background: none; border: none; }
.mem-inner { position: relative; width: 100%; height: 100%; transition: transform 0.3s; transform-style: preserve-3d; }
.mem-card.flip .mem-inner { transform: rotateY(180deg); }
.mem-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 40px;
}
.mem-back { background: linear-gradient(135deg, var(--panel2), var(--panel)); border: 1px solid var(--line); color: var(--accent); font-size: 22px; }
.mem-front { background: var(--ink2); border: 1px solid var(--accent); transform: rotateY(180deg); }
.mem-card.done .mem-front { opacity: 0.45; border-color: var(--line); }

/* simon */
.simon-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.simon-board { display: grid; grid-template-columns: repeat(2, 130px); gap: 14px; }
.simon-pad { width: 130px; height: 130px; border-radius: 16px; border: 2px solid transparent; opacity: 0.45; transition: opacity 0.08s, transform 0.08s; }
.simon-pad.lit { opacity: 1; transform: scale(1.05); box-shadow: 0 0 30px -2px currentColor; }
.simon-pad:active { transform: scale(0.97); }
.simon-msg { font-family: var(--mono); font-size: 15px; color: var(--dim); min-height: 20px; }

/* sudoku */
.sud-wrap { display: flex; gap: 22px; align-items: flex-start; }
.sud-grid { display: grid; grid-template-columns: repeat(9, 50px); background: var(--line); border: 2px solid var(--line); border-radius: 6px; overflow: hidden; }
.sud-cell {
  width: 50px; height: 50px; border: none; background: var(--panel);
  color: var(--text); font-family: var(--mono); font-size: 22px; font-weight: 600;
}
.sud-cell.given { background: var(--panel2); color: var(--dim); cursor: default; }
.sud-cell.sel { background: #3a3370 !important; }
.sud-cell.same { background: #2c2756; }
.sud-cell.bad { color: #ff7b72; }
.sud-cell.bR { box-shadow: inset -2px 0 0 var(--line); }
.sud-cell.bB { box-shadow: inset 0 -2px 0 var(--line); }
.sud-cell.bR.bB { box-shadow: inset -2px 0 0 var(--line), inset 0 -2px 0 var(--line); }
.sud-side { display: flex; flex-direction: column; gap: 10px; width: 190px; }
.sud-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sud-pad button, .sud-side > button {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 10px 0; font-family: var(--mono); font-size: 17px;
}
.sud-pad button:hover, .sud-side > button:hover { border-color: var(--accent); color: var(--accent); }
.sud-msg { font-family: var(--mono); font-size: 13px; color: var(--dim); min-height: 34px; }

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

/* ---------------- v2: platform & juice ---------------- */
#game-area { position: relative; overflow: hidden; }
#fx-canvas { position: absolute; inset: 0; pointer-events: none; z-index: 40; }
#mount-scale { transform-origin: center center; will-change: transform; }
#mount-shake { will-change: transform; }
#mount { display: flex; align-items: center; justify-content: center; }

.fade-in { animation: fadeIn .22s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.tile-enter { animation: tileIn .42s cubic-bezier(.2,.9,.3,1.2) backwards; }
@keyframes tileIn { from { opacity: 0; transform: translateY(18px) scale(.92); } to { opacity: 1; transform: none; } }
.tile { transition: transform .14s ease-out, box-shadow .14s ease-out, border-color .14s; }
.tile:hover, .tile.selected {
  transform: translateY(-3px) scale(1.035);
  border-color: var(--accent);
  box-shadow: 0 6px 22px -6px var(--accent-dim), 0 0 0 1px var(--accent-dim);
  z-index: 2;
}
.tile.selected { outline: none; }

.float-text {
  position: absolute; z-index: 50; pointer-events: none;
  font-weight: 700; font-size: 18px; color: var(--accent, #fff);
  text-shadow: 0 1px 6px rgba(0,0,0,.6);
  transform: translate(-50%, -50%);
  animation: floatUp .85s ease-out forwards;
}
@keyframes floatUp {
  from { opacity: 1; margin-top: 0; }
  to { opacity: 0; margin-top: -46px; }
}

.hud-pop { animation: hudPop .18s ease-out; display: inline-block; }
@keyframes hudPop { 50% { transform: scale(1.18); } }

.card-pop { animation: cardPop .25s cubic-bezier(.2,.9,.3,1.25); }
@keyframes cardPop { from { opacity: 0; transform: scale(.86); } to { opacity: 1; transform: none; } }

.ov-btns.col { flex-direction: column; align-items: stretch; }
.ov-btns.col button { margin: 4px 0; }

.ov-table { margin: 12px 0 4px; min-width: 240px; }
.ov-table-title { font-size: 11px; letter-spacing: 2px; color: var(--dim); margin-bottom: 6px; }
.ov-row { display: flex; justify-content: space-between; gap: 14px; padding: 3px 6px; border-radius: 6px; font-size: 14px; }
.ov-row .nm { flex: 1; text-align: left; letter-spacing: 1px; }
.ov-row.me { background: var(--accent-dim); font-weight: 700; }

.ov-initials { margin: 10px 0 2px; font-size: 13px; color: var(--dim); }
.ov-initials input {
  width: 64px; text-align: center; letter-spacing: 4px; font-weight: 700; font-size: 16px;
  background: #0e0c1c; color: #fff; border: 1px solid var(--accent-dim); border-radius: 8px; padding: 5px;
}

.help-card { max-width: 460px; }
.help-body { text-align: left; font-size: 14px; line-height: 1.65; margin: 10px 0; color: #d8d4ee; }
.help-body kbd { margin: 0 1px; }
.help-body b { color: var(--accent); }

.brand-btns { margin-top: 10px; display: flex; gap: 10px; justify-content: center; }
.brand-btns button, #btn-pause {
  background: #1d1933; color: #cfc9ea; border: 1px solid #322b52; border-radius: 8px;
  padding: 6px 16px; cursor: pointer; font: inherit; font-size: 13px;
}
.brand-btns button:hover, #btn-pause:hover { border-color: var(--accent, #79c0ff); color: #fff; }
#btn-pause { margin-left: auto; padding: 4px 12px; font-weight: 700; letter-spacing: -1px; }
#game-hint { margin-left: 0; }

.menu-panel { position: fixed; inset: 0; z-index: 100; background: rgba(10,8,20,.72); display: flex; align-items: center; justify-content: center; }
.panel-card { min-width: 360px; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 9px 2px; font-size: 14px; }
.set-row label { color: #d8d4ee; }
.set-note { color: var(--dim); font-size: 12px; }
.set-row input[type="range"] { width: 150px; accent-color: var(--accent, #79c0ff); }
.set-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent, #79c0ff); }
.set-row input[type="text"] {
  width: 60px; text-align: center; letter-spacing: 3px; font-weight: 700;
  background: #0e0c1c; color: #fff; border: 1px solid #322b52; border-radius: 8px; padding: 5px;
}

/* generic flash for one-frame white hits (canvas games draw their own; DOM games use this) */
.flash { animation: cellFlash .22s ease-out; }
@keyframes cellFlash { 0% { filter: brightness(2.4); } 100% { filter: none; } }

/* ---------------- 2048 v2 (absolute tiles) ---------------- */
.g2048-board { position: relative; background: #1d1933; border-radius: 12px; padding: 10px; }
.g2048-cellbg { position: absolute; background: #14112480; border-radius: 8px; }
.g2048-tile {
  position: absolute; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-weight: 800; z-index: 2;
  transition: left .12s ease-in-out, top .12s ease-in-out;
  background: #2b2547; color: #fff;
}
.g2048-tile.pop { animation: tilePop .18s cubic-bezier(.2,.9,.3,1.4); }
.g2048-tile.spawn { animation: tileSpawn .18s ease-out .1s backwards; }
@keyframes tilePop { 0% { transform: scale(1); } 55% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes tileSpawn { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------------- memory v2 (3D flips) ---------------- */
.mem-grid { display: grid; gap: 10px; perspective: 900px; }
.mem-card { position: relative; cursor: pointer; transform-style: preserve-3d; transition: transform .25s cubic-bezier(.3,.8,.4,1.1); }
.mem-card.deal { animation: dealIn .4s cubic-bezier(.2,.9,.3,1.2) backwards; }
@keyframes dealIn { from { opacity: 0; transform: translateY(26px) scale(.7); } to { opacity: 1; } }
.mem-card.flipped { transform: rotateY(180deg); }
.mem-face {
  position: absolute; inset: 0; border-radius: 10px; backface-visibility: hidden;
  display: flex; align-items: center; justify-content: center;
}
.mem-back {
  background: linear-gradient(135deg, #2b2547, #1d1933 60%);
  border: 1px solid #3a3260;
  background-size: 200% 200%;
}
.mem-card:hover .mem-back { border-color: var(--accent); }
.mem-front { background: #241f3e; border: 1px solid var(--accent-dim); transform: rotateY(180deg); font-size: 28px; }
.mem-card.matched { pointer-events: none; }
.mem-card.matched .mem-front { animation: matchGlow .6s ease-out; border-color: var(--accent); box-shadow: 0 0 18px -2px var(--accent); }
@keyframes matchGlow { 30% { transform: rotateY(180deg) scale(1.12); } 100% { transform: rotateY(180deg) scale(1); } }

/* ---------------- simon v2 ---------------- */
.simon-pad { transition: transform .08s, filter .08s, box-shadow .12s; }
.simon-pad.lit { filter: brightness(1.9) saturate(1.3); transform: scale(.96); box-shadow: 0 0 26px -2px currentColor; }
.simon-wrap.playback .simon-pad { opacity: .8; cursor: default; }

/* ---------------- mines v2 ---------------- */
.mines-cell { transition: filter .1s; }
.mines-cell.press { filter: brightness(1.5); }
.mines-cell.ripple { animation: cellFlash .3s ease-out; }
.mines-cell.wrongflag { background: #5a1f28 !important; position: relative; }
.mines-cell.boomcell { background: #a83242 !important; }

/* ---------------- sudoku v2 ---------------- */
.sud-cell.peer { background: #221d3d; }
.sud-cell.samedigit { background: #2c2553; }
.sud-cell .notes {
  position: absolute; inset: 1px; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  font-size: 9px; color: #8d86b3; line-height: 1; pointer-events: none;
}
.sud-cell .notes span { display: flex; align-items: center; justify-content: center; }
.sud-cell { position: relative; }
.sud-cell.placed { animation: tilePop .18s ease-out; }
.sud-pad button.done { opacity: .28; }
.sud-pad button .cnt { display: block; font-size: 9px; color: var(--dim); }
.sud-unit-done { animation: unitSweep .5s ease-out; }
@keyframes unitSweep { 30% { background: var(--accent-dim); } }

/* ---------------- blockfall v2 side panel ---------------- */
.bf-slot { background: #1d1933; border-radius: 10px; padding: 8px; margin-bottom: 10px; }
.bf-slot .lbl { font-size: 10px; letter-spacing: 2px; color: var(--dim); margin-bottom: 4px; }
.bf-callout {
  position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%);
  font-size: 26px; font-weight: 900; letter-spacing: 3px; color: var(--accent, #ffa657);
  text-shadow: 0 2px 14px rgba(0,0,0,.7); z-index: 45; pointer-events: none;
  animation: calloutUp .9s ease-out forwards;
}
@keyframes calloutUp { from { opacity: 1; margin-top: 0; } 70% { opacity: 1; } to { opacity: 0; margin-top: -34px; } }

/* difficulty / option pills used by several games */
.pill-bar { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; justify-content: center; }
.pill-bar button {
  background: #1d1933; color: #cfc9ea; border: 1px solid #322b52; border-radius: 999px;
  padding: 4px 14px; cursor: pointer; font: inherit; font-size: 12px;
}
.pill-bar button.on { border-color: var(--accent); color: #fff; background: var(--accent-dim); }

/* ---------------- v3: hero + shelf front-end ---------------- */
#menu { position: relative; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
#menu-bg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#menu-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: clamp(14px, 2vh, 26px) clamp(22px, 3vw, 54px) 0;
  position: relative; z-index: 2;
}
.wordmark {
  font-family: var(--mono);
  font-size: clamp(20px, 2.2vw, 32px);
  letter-spacing: .4em; text-indent: .4em; font-weight: 700;
}
.wordmark .ten { color: var(--menu-accent, #ffd76e); transition: color .4s; }

#hero {
  display: flex; align-items: center; gap: clamp(22px, 3vw, 56px);
  padding: clamp(10px, 2.5vh, 36px) clamp(26px, 5vw, 90px);
  position: relative; z-index: 2;
  min-height: 0;
}
#hero-icon {
  width: clamp(120px, 16vw, 220px); height: clamp(120px, 16vw, 220px);
  background: radial-gradient(circle at 50% 42%, var(--menu-accent-dim, #79c0ff33), transparent 72%);
  border-radius: 28px;
  filter: drop-shadow(0 8px 28px var(--menu-accent-dim, #79c0ff33));
  transition: filter .4s;
}
#hero-text { min-width: 0; }
#hero-name {
  font-size: clamp(34px, 4.6vw, 76px);
  letter-spacing: .04em; line-height: 1.05;
  color: var(--text);
  text-shadow: 0 4px 30px var(--menu-accent-dim, transparent);
}
#hero-blurb { color: var(--dim); font-size: clamp(15px, 1.4vw, 22px); margin-top: 8px; max-width: 56ch; }
#hero-meta { font-family: var(--mono); color: var(--menu-accent, #79c0ff); font-size: clamp(13px, 1.1vw, 17px); margin-top: 12px; transition: color .4s; }
#hero-play {
  margin-top: clamp(12px, 2vh, 22px);
  font-size: clamp(15px, 1.3vw, 20px);
  padding: .6em 1.6em;
  border-radius: 12px;
  border: 1px solid var(--menu-accent, #79c0ff);
  background: var(--menu-accent-dim, #79c0ff22);
  color: var(--text);
  animation: heroPulse 2.2s ease-in-out infinite;
}
#hero-play kbd { margin-left: 8px; }
@keyframes heroPulse { 50% { box-shadow: 0 0 24px -4px var(--menu-accent, #79c0ff); } }

#menu .tiles {
  position: relative; z-index: 2;
  display: block; max-width: none; margin: 0;
  padding: 0 clamp(22px, 3vw, 54px) 10px;
  overflow-y: auto; flex: 1; min-height: 0;
}
.shelf-label {
  font-family: var(--mono); font-size: clamp(11px, .95vw, 14px);
  letter-spacing: .28em; color: var(--dim);
  margin: clamp(10px, 1.6vh, 20px) 4px 8px;
}
.shelf { display: flex; gap: clamp(10px, 1vw, 18px); overflow-x: auto; padding: 6px 4px 14px; scrollbar-width: thin; }
.shelf .tile {
  flex: 0 0 auto;
  width: clamp(118px, 9.5vw, 168px);
  padding: clamp(10px, 1vw, 16px) 8px 10px;
  text-align: center;
  border-radius: 16px;
}
.shelf .tile canvas { width: clamp(58px, 4.8vw, 92px); height: clamp(58px, 4.8vw, 92px); margin: 0 auto 8px; }
.shelf .tile h2 { font-size: clamp(13px, 1.05vw, 17px); }
.shelf .tile .t-best { font-size: clamp(10px, .8vw, 12px); margin-top: 5px; min-height: 1em; }
.shelf .tile.selected {
  transform: translateY(-6px) scale(1.12);
  border-color: var(--accent);
  box-shadow: 0 10px 34px -8px var(--accent-dim), 0 0 0 1px var(--accent-dim);
}
#menu-foot {
  position: relative; z-index: 2;
  text-align: center; color: var(--dim);
  font-size: clamp(11px, .9vw, 14px);
  padding: 8px 0 12px;
  border-top: 1px solid #2a234a66;
}

/* game chrome: scale up + auto-dim */
#game-title { font-size: clamp(16px, 1.4vw, 24px); }
.hud { font-size: clamp(14px, 1.25vw, 21px); }
#game-hint { font-size: clamp(11px, .95vw, 15px); }
#game-header { transition: opacity .5s; }
#game-header.dim { opacity: .14; }

/* letterbox treatment: vignette + accent frame glow around the play area */
#game-area {
  background:
    radial-gradient(120% 120% at 50% 50%, transparent 55%, rgba(5,4,12,.55) 100%);
}
#mount-scale { filter: drop-shadow(0 0 44px var(--accent-dim, transparent)); }

/* full-screen settings/stats */
.menu-panel { backdrop-filter: blur(6px); }
.panel-card {
  min-width: min(680px, 92vw);
  max-height: 84vh; overflow-y: auto;
  padding: clamp(26px, 4vh, 46px) clamp(30px, 4vw, 60px);
}
.panel-card h3 { font-size: clamp(22px, 2.2vw, 34px); margin-bottom: 14px; }
.set-row { font-size: clamp(14px, 1.2vw, 19px); padding: 12px 2px; }
.panel-card .ov-row { font-size: clamp(13px, 1.1vw, 17px); padding: 6px 8px; }

/* ---------------- v4: shell ---------------- */
@font-face {
  font-family: 'PS2P';
  src: url('../fonts-PressStart2P.ttf') format('truetype');
  font-display: swap;
}
:root {
  --ease-out: cubic-bezier(.2, .9, .3, 1);
  --ease-in: cubic-bezier(.6, 0, .8, .4);
  --ease-inout: cubic-bezier(.45, 0, .25, 1);
  --dur-1: 180ms;
  --dur-2: 300ms;
}
/* de-webbing */
* { user-select: none; -webkit-user-select: none; }
input, textarea { user-select: text; -webkit-user-select: text; }
html, body { overscroll-behavior: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2a234a; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
button, .tile { cursor: pointer; }
:focus { outline: none; }
:focus-visible { outline: 1px solid var(--menu-accent, #79c0ff); outline-offset: 2px; }

/* boot + title */
#boot {
  position: fixed; inset: 0; z-index: 60;
  background: #0a0817;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(10px, 2.4vh, 26px);
}
#boot-mark { width: clamp(130px, 18vw, 230px); height: auto; image-rendering: pixelated; }
#boot-word {
  font-family: 'PS2P', var(--mono);
  font-size: clamp(22px, 4vw, 54px);
  letter-spacing: .14em; text-indent: .14em;
  color: var(--text);
}
#boot-word span { color: #ffd76e; }
#boot-press {
  font-family: var(--mono);
  font-size: clamp(13px, 1.4vw, 20px);
  letter-spacing: .35em; text-indent: .35em;
  color: #9b93c4;
  animation: bootBlink 1.15s steps(1) infinite;
  opacity: 0; transition: opacity .4s;
}
#boot.title #boot-press { opacity: 1; }
@keyframes bootBlink { 50% { visibility: hidden; } }
#boot-meta {
  position: absolute; bottom: 16px; left: 0; right: 0;
  text-align: center;
  font-family: var(--mono); font-size: 11px; color: #5b5572;
}
#boot-windowed {
  position: absolute; bottom: 16px; right: 18px;
  font-family: var(--mono); font-size: 11px; color: #5b5572;
  display: none; align-items: center; gap: 6px; cursor: pointer;
}
#boot.title #boot-windowed { display: flex; }
#boot.out { opacity: 0; pointer-events: none; transition: opacity var(--dur-2) var(--ease-in); }

/* screen wipe for menu<->game transitions */
#wipe {
  position: fixed; inset: 0; z-index: 55; pointer-events: none;
  background: linear-gradient(105deg, transparent 0%, var(--menu-accent, #79c0ff) 18%, #0a0817 40%, #0a0817 60%, var(--menu-accent, #79c0ff) 82%, transparent 100%);
  transform: translateX(-130%);
}
#wipe.go { transition: transform 260ms var(--ease-inout); transform: translateX(130%); }
#wipe.hold { transform: translateX(0); transition: transform 130ms var(--ease-in); }

/* selector cursor */
#sel-cursor {
  position: fixed; z-index: 5; pointer-events: none;
  border: 2px solid var(--menu-accent, #79c0ff);
  border-radius: 18px;
  box-shadow: 0 0 22px -4px var(--menu-accent, #79c0ff), inset 0 0 14px -8px var(--menu-accent, #79c0ff);
  transition: border-color .25s;
  opacity: 0;
}
#sel-cursor.on { opacity: 1; }
.shelf .tile.selected { transform: translateY(-4px) scale(1.06); box-shadow: none; border-color: transparent; }

/* legend */
#legend {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: center; gap: 2.2em;
  padding: 7px 0 9px;
  font-family: var(--mono); font-size: clamp(10px, .9vw, 13px);
  color: #8d86b3;
  background: linear-gradient(transparent, rgba(8,6,18,.85) 40%);
  pointer-events: none;
  transition: opacity .5s;
}
#legend kbd { font-size: .95em; }
#legend.dim { opacity: .1; }
#menu-foot { display: none; }
#menu .tiles { padding-bottom: 34px; }

/* electron window chrome (frameless windowed mode only) */
#win-chrome {
  position: fixed; top: 0; left: 0; right: 0; height: 30px; z-index: 70;
  -webkit-app-region: drag;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px 0 12px;
  font-family: 'PS2P', var(--mono); font-size: 9px; letter-spacing: .25em; color: #5b5572;
  background: rgba(10,8,23,.92);
  border-bottom: 1px solid #1d1933;
}
#win-chrome button {
  -webkit-app-region: no-drag;
  width: 34px; height: 24px; border: 0; background: transparent;
  color: #8d86b3; font-size: 12px; border-radius: 6px;
}
#win-chrome button:hover { background: #241e44; color: #e8e4fa; }
#wc-close:hover { background: #7a2733; }
body.has-chrome #app { padding-top: 30px; }

/* boot-time type upgrades */
.wordmark, #hero-name { font-family: 'PS2P', var(--mono); }
#hero-name { font-size: clamp(22px, 3vw, 46px); line-height: 1.25; }
.hud#hud-score, #hud-score { font-family: 'PS2P', var(--mono); font-size: clamp(11px, 1vw, 16px); }
#menu-clock { font-family: var(--mono); font-size: clamp(11px, 1vw, 14px); color: #5b5572; margin-right: 14px; }

/* settings left rail */
.set-card { min-width: min(620px, 92vw); }
.set-cols { display: flex; gap: 18px; align-items: stretch; }
.set-rail { display: flex; flex-direction: column; gap: 6px; min-width: 128px; border-right: 1px solid #221c3f; padding-right: 14px; }
.rail-btn {
  text-align: left; background: transparent; border: 0; color: #8d86b3;
  font-family: var(--mono); font-size: clamp(12px, 1vw, 15px);
  padding: .45em .7em; border-radius: 8px; cursor: pointer;
}
.rail-btn:hover { background: #1b1633; color: #e8e4fa; }
.rail-btn.on { background: #241e44; color: var(--menu-accent, #79c0ff); }
.set-pane { flex: 1; display: flex; flex-direction: column; gap: 2px; min-height: 250px; }
.set-pane .set-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: .42em 0; border-bottom: 1px dashed #1d1933; }
.set-pane .set-row:last-child { border-bottom: 0; }
.set-pane button { font-size: clamp(11px, .95vw, 14px); padding: .3em .9em; }
@media (max-width: 620px) { .set-cols { flex-direction: column; } .set-rail { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid #221c3f; padding: 0 0 10px; } }

/* ---------------- v4.1: shell polish ---------------- */
/* shelves: no visible scrollbar; fade the right edge to signal overflow */
.shelf { scrollbar-width: none; -ms-overflow-style: none; }
.shelf::-webkit-scrollbar { width: 0; height: 0; display: none; }
.shelf-wrap { position: relative; }
.shelf-wrap::after {
  content: ''; position: absolute; top: 0; right: 0; bottom: 14px; width: 46px;
  pointer-events: none; opacity: 0; transition: opacity .25s;
  background: linear-gradient(to right, transparent, var(--ink2, #0e0c1c));
}
.shelf-wrap.more-right::after { opacity: 1; }
.shelf-wrap::before {
  content: ''; position: absolute; top: 0; left: 0; bottom: 14px; width: 46px; z-index: 1;
  pointer-events: none; opacity: 0; transition: opacity .25s;
  background: linear-gradient(to left, transparent, var(--ink2, #0e0c1c));
}
.shelf-wrap.more-left::before { opacity: 1; }

/* the whole menu scroll column: keep scrollable, hide the bar */
#menu .tiles { scrollbar-width: none; -ms-overflow-style: none; }
#menu .tiles::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* hero play: label + key chip, properly spaced */
#hero-play { display: inline-flex; align-items: center; gap: 10px; }
#hero-play .hp-key, #legend kbd, .ov-row kbd {
  font-family: var(--mono); font-size: .82em; line-height: 1;
  padding: 3px 7px; border-radius: 6px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16);
  color: inherit; box-shadow: 0 1px 0 rgba(0,0,0,.3);
}

/* legend: space glyphs from labels, give items breathing room */
#legend span { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }

/* hero icon: give the empty pre-demo slot a subtle framed panel instead of a void */
#hero-icon {
  background: radial-gradient(120% 120% at 50% 35%, rgba(255,255,255,.05), transparent 70%);
  border: 1px solid #1d1933; border-radius: 18px; box-shadow: inset 0 0 40px -20px var(--menu-accent, #79c0ff);
}
