:root {
  --bg: #06060d;
  --bg-2: #0c0d18;
  --panel: rgba(20, 22, 38, 0.55);
  --panel-solid: #14162b;
  --panel-2: rgba(28, 31, 50, 0.6);
  --panel-3: rgba(36, 40, 64, 0.65);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-soft: rgba(255, 255, 255, 0.05);
  --text: #eef0ff;
  --muted: #9398bd;
  --muted-2: #5d6184;
  --accent: #00eaff;
  --accent-2: #ff5fae;
  --gold: #ffd166;
  --silver: #d6dceb;
  --bronze: #e3a87d;
  --good: #90ff7a;
  --warn: #ffd166;
  --bad: #ff5b6e;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html, body {
  touch-action: manipulation;
  overscroll-behavior: none;
}
body {
  margin: 0;
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 900px at 18% -10%, rgba(0,234,255,.16), transparent 50%),
    radial-gradient(1000px 800px at 110% 105%, rgba(255,95,174,.14), transparent 55%),
    radial-gradient(900px 700px at 60% 50%, rgba(80,40,180,.08), transparent 60%),
    linear-gradient(180deg, #05060e 0%, #06070f 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
body::before {
  /* faint grain to keep the gradient from looking flat */
  content: "";
  position: fixed; inset: 0;
  background-image:
    radial-gradient(rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 3px 3px;
  pointer-events: none;
  opacity: .35;
  mix-blend-mode: overlay;
  z-index: 0;
}
.app { position: relative; z-index: 1; }

/* ---------- layout ---------- */
.app {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 300px;
  gap: 22px;
  width: 100%;
  max-width: 1320px;
  height: 100dvh;
  margin: 0 auto;
  padding: 24px;
  align-items: stretch;
}
.col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  overflow: hidden;
}
.col.center {
  align-items: center;
  justify-content: center;
}

/* ---------- card chrome (glass) ---------- */
.card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,.05) 0%, rgba(255,255,255,.015) 22%, transparent 60%),
    var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  box-shadow:
    inset 0 1px 0 0 rgba(255,255,255,.07),
    inset 0 0 0 1px rgba(255,255,255,.02),
    0 24px 60px -28px rgba(0,0,0,.7),
    0 4px 14px -10px rgba(0,234,255,.18);
}
.card::after {
  /* subtle top-edge sheen */
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,.06), transparent 25%);
  pointer-events: none;
  mix-blend-mode: overlay;
}
.card h3 {
  margin: 0 0 14px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
}
.card-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-row h3 { margin: 0; }

/* ---------- hold + next ---------- */
.hold-card canvas, .next-card canvas {
  width: 100%;
  height: auto;
  display: block;
}

/* ---------- stats ---------- */
.stats-card { display: flex; flex-direction: column; gap: 14px; }
.stat { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat-label {
  font-size: 10px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-value {
  font: 700 22px/1 "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.stat-value.big { font-size: 34px; color: var(--accent); }
.stat-value.muted { color: var(--muted); font-size: 18px; }
.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}
.new-game-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font: 600 12px/1 inherit;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 11px 0;
  margin-top: 4px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .08s;
}
.new-game-btn:hover { background: var(--panel-2); border-color: var(--accent); color: var(--accent); }
.new-game-btn:active { transform: translateY(1px); }

/* ---------- leaderboard ---------- */
.leaderboard-card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.leaderboard {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.leaderboard::-webkit-scrollbar { width: 4px; }
.leaderboard::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.leaderboard li {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel-2);
  font-size: 13px;
}
.leaderboard li.empty {
  display: block;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 14px 0;
  background: transparent;
}
.leaderboard .rank {
  font: 700 12px/1 "SF Mono", ui-monospace, monospace;
  text-align: center;
  color: var(--muted);
}
.leaderboard .name {
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.leaderboard .score {
  font: 700 12px/1 "SF Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.leaderboard li.top1 {
  background: linear-gradient(90deg, rgba(255,209,102,.15), transparent 60%), var(--panel-2);
  border: 1px solid rgba(255,209,102,.3);
}
.leaderboard li.top1 .rank, .leaderboard li.top1 .score { color: var(--gold); }
.leaderboard li.top2 {
  background: linear-gradient(90deg, rgba(200,210,226,.10), transparent 60%), var(--panel-2);
  border: 1px solid rgba(200,210,226,.18);
}
.leaderboard li.top2 .rank, .leaderboard li.top2 .score { color: var(--silver); }
.leaderboard li.top3 {
  background: linear-gradient(90deg, rgba(211,154,107,.12), transparent 60%), var(--panel-2);
  border: 1px solid rgba(211,154,107,.22);
}
.leaderboard li.top3 .rank, .leaderboard li.top3 .score { color: var(--bronze); }
.leaderboard li.you {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

/* ---------- board (glass frame) ---------- */
.board-frame {
  position: relative;
  padding: 18px;
  border-radius: 24px;
  background:
    radial-gradient(60% 50% at 50% 0%, rgba(0,234,255,.10), transparent),
    linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.01) 30%, transparent 60%),
    var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow:
    inset 0 1px 0 0 rgba(255,255,255,.10),
    inset 0 0 0 1px rgba(255,255,255,.02),
    0 40px 100px -36px rgba(0,234,255,.30),
    0 40px 100px -36px rgba(255,95,174,.22),
    0 24px 80px -30px rgba(0,0,0,.7);
}
.board-frame::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,.08), transparent 22%);
  pointer-events: none;
  mix-blend-mode: overlay;
}
#board {
  display: block;
  background:
    radial-gradient(80% 60% at 50% 20%, rgba(0,234,255,.04), transparent 70%),
    #04050a;
  border-radius: 14px;
  image-rendering: pixelated;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.04),
    inset 0 0 40px rgba(0,234,255,.04),
    inset 0 0 0 100px rgba(0,0,0,0);
  max-height: calc(100dvh - 100px);
  width: auto;
  height: auto;
  position: relative;
  z-index: 1;
  /* hand ALL touch behaviour over to JS — no browser pan / pinch / scroll */
  touch-action: none;
  -webkit-touch-callout: none;
}

/* ---------- overlay (start / pause / game over) ---------- */
.overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background:
    radial-gradient(ellipse at center, rgba(7,7,13,.6), rgba(7,7,13,.92)),
    linear-gradient(180deg, rgba(0,234,255,.05), transparent 40%);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-radius: 24px;
  z-index: 5;
  padding: 14px;
}
.overlay.hidden { display: none; }
.overlay-inner {
  width: min(320px, 100%);
  display: flex; flex-direction: column; gap: 18px;
  text-align: center;
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06121a; font: 800 16px/1 inherit; letter-spacing: .04em;
  box-shadow: 0 12px 30px -10px rgba(0,234,255,.5);
}
.brand h1 {
  margin: 0;
  font: 800 22px/1 inherit;
  letter-spacing: .22em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand h1 span {
  display: block;
  font-size: 11px;
  letter-spacing: .35em;
  color: var(--muted);
  -webkit-text-fill-color: var(--muted);
  margin-top: 6px;
}

.name-field { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.name-field span {
  font-size: 10px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--muted);
}
.name-field input {
  appearance: none;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 10px;
  font: 600 16px/1 inherit; /* must be >=16px or iOS zooms on focus */
  outline: none;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.name-field input::placeholder { color: var(--muted-2); font-weight: 400; }
.name-field input:focus {
  border-color: var(--accent);
  background: var(--panel-3);
  box-shadow: 0 0 0 3px rgba(0,234,255,.16);
}

.start-btn {
  appearance: none; border: 0; cursor: pointer;
  padding: 13px 0;
  border-radius: 11px;
  background: linear-gradient(180deg, var(--accent), #00b4c4);
  color: #001318; font: 800 13px/1 inherit;
  letter-spacing: .18em; text-transform: uppercase;
  box-shadow: 0 10px 30px -8px rgba(0,234,255,.45);
  transition: transform .08s ease, box-shadow .12s;
}
.start-btn:hover { box-shadow: 0 14px 40px -8px rgba(0,234,255,.6); }
.start-btn:active { transform: translateY(1px); }

.overlay-msg { margin: 0; color: var(--muted); font-size: 12px; letter-spacing: .04em; }
.overlay-msg kbd { font-size: 11px; }

.how-to {
  margin-top: 4px;
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
  text-align: left;
}
.how-to summary {
  cursor: pointer;
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  list-style: none;
  text-align: center;
}
.how-to summary::-webkit-details-marker { display: none; }
.how-to summary::after { content: " ▾"; opacity: .6; }
.how-to[open] summary::after { content: " ▴"; }
.legend {
  margin-top: 14px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px;
  color: var(--muted); font-size: 12px;
}
.legend > div { display: flex; align-items: center; gap: 4px; }
.legend span { color: var(--muted); }
kbd {
  display: inline-flex;
  align-items: center;
  font: 600 10px/1 ui-monospace, monospace;
  padding: 4px 6px; border-radius: 5px;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text);
}

/* ---------- toast ---------- */
.toast {
  position: absolute;
  left: 50%; bottom: 28px;
  transform: translate(-50%, 20px);
  background: rgba(10,10,20,.92);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 12px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--text);
  opacity: 0; pointer-events: none;
  transition: transform .25s ease, opacity .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.tetris {
  color: #06121a; background: var(--accent); border-color: transparent;
  box-shadow: 0 10px 36px rgba(0,234,255,.4);
}
.toast.tspin {
  color: #1a0612; background: var(--accent-2); border-color: transparent;
  box-shadow: 0 10px 36px rgba(255,95,174,.4);
}

/* ---------- AI hint switch ---------- */
.switch { position: relative; width: 34px; height: 20px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 999px;
  transition: background .15s, border-color .15s;
}
.switch .track::before {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform .18s ease, background .15s;
}
.switch input:checked + .track {
  background: rgba(0,234,255,.18); border-color: var(--accent);
}
.switch input:checked + .track::before {
  transform: translateX(14px); background: var(--accent);
}
.ai-stats { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.ai-stats div { display: flex; justify-content: space-between; align-items: center; }
.ai-stats b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- music player ---------- */
.player-card { display: flex; flex-direction: column; gap: 12px; }
.mp-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px;
}
.mp-head h3 { margin: 0; }
.mp-source {
  font-size: 10px; color: var(--muted); opacity: .7;
  text-align: right; flex-shrink: 0;
  max-width: 60%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mp-now { min-width: 0; }
.mp-title {
  font: 700 13px/1.2 inherit;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.mp-artist {
  margin-top: 3px;
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mp-progress { display: flex; flex-direction: column; gap: 4px; }
.mp-bar {
  height: 3px; background: var(--bg-2); border-radius: 999px; overflow: hidden;
  cursor: pointer; position: relative;
}
.mp-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .1s linear;
  border-radius: 999px;
}
.mp-time {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}
.mp-controls {
  display: grid; grid-template-columns: 1fr 1.4fr 1fr 1fr;
  gap: 6px;
}
.mp-controls button {
  appearance: none;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 0;
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .08s;
}
.mp-controls button:hover { background: var(--panel-3); border-color: var(--accent); }
.mp-controls button:active { transform: translateY(1px); }
.mp-controls .mp-play {
  background: linear-gradient(180deg, var(--accent), #00b4c4);
  color: #001318; border-color: transparent; font-weight: 800;
}
.mp-controls button.on {
  background: var(--accent-2); color: #1a0612; border-color: transparent; font-weight: 700;
}
.mp-vol { display: flex; align-items: center; gap: 8px; }
.mp-vol .icon { font-size: 13px; color: var(--muted); }
.mp-vol input {
  flex: 1; accent-color: var(--accent);
  height: 2px;
}
.mp-list {
  max-height: 120px; overflow-y: auto;
  padding-top: 6px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
  display: flex; flex-direction: column; gap: 1px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.mp-list::-webkit-scrollbar { width: 4px; }
.mp-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.mp-row {
  display: flex; gap: 8px; align-items: center;
  padding: 4px 8px; border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  transition: background .1s, color .1s;
}
.mp-row:hover { background: var(--panel-2); color: var(--text); }
.mp-row.active { background: rgba(0,234,255,.10); color: var(--accent); font-weight: 600; }
.mp-row-num {
  width: 18px; text-align: right; font-variant-numeric: tabular-nums;
  opacity: .55; font-size: 11px;
}
.mp-row-t { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-status {
  font-size: 10px;
  color: var(--warn);
  min-height: 12px;
  letter-spacing: .04em;
}

/* ---------- mobile / small screens ---------- */
.mobile-controls, .mobile-header, .mobile-drawer { display: none; }

@media (max-width: 940px) {
  body { overflow: hidden; }
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    height: 100dvh;
    padding: max(env(safe-area-inset-top), 6px) 8px 0;
    gap: 6px;
    max-width: 100%;
  }
  .mobile-header { display: grid; }
  .col.center {
    grid-row: 2;
    min-height: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
  }
  .col.left, .col.right { display: none; }

  .mobile-header {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr auto 40px;
    align-items: center;
    gap: 8px;
    padding: 8px 6px 6px;
    grid-row: 1;
  }
  .m-next-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }
  .m-next-wrap span {
    font-size: 9px; letter-spacing: .22em;
    color: var(--muted); text-transform: uppercase;
  }
  .m-next-wrap canvas {
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 6px;
    height: 26px; width: 36px;
    display: block;
  }
  .mobile-header .m-stat {
    display: flex; flex-direction: column;
    align-items: center; gap: 2px;
    min-width: 0;
  }
  .mobile-header .m-stat span {
    font-size: 9px; letter-spacing: .22em;
    color: var(--muted); text-transform: uppercase;
  }
  .mobile-header .m-stat b {
    font: 700 18px/1 "SF Mono", ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
  }
  .mobile-header .m-stat:first-child b { color: var(--accent); font-size: 22px; }
  .m-menu {
    appearance: none;
    width: 40px; height: 40px;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 10px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 4px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .m-menu i {
    display: block;
    width: 18px; height: 2px;
    background: var(--text);
    border-radius: 2px;
  }

  /* drawer */
  .mobile-drawer {
    position: fixed; inset: 0;
    z-index: 50;
    pointer-events: none;
  }
  .mobile-drawer.open { pointer-events: auto; display: block; }
  .m-drawer-scrim {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity .25s;
  }
  .mobile-drawer.open .m-drawer-scrim { opacity: 1; }
  .m-drawer-card {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: min(86vw, 360px);
    background: linear-gradient(180deg, #0c0d18, #07070d);
    border-left: 1px solid var(--border);
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform .28s ease;
    display: flex; flex-direction: column;
    gap: 18px;
  }
  .mobile-drawer.open .m-drawer-card { transform: translateX(0); }
  .m-close {
    appearance: none;
    align-self: flex-end;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.08);
    color: var(--text);
    font-size: 16px; cursor: pointer;
  }
  .m-section h3 {
    margin: 0 0 10px;
    font-size: 10px; letter-spacing: .22em;
    text-transform: uppercase; color: var(--muted);
  }
  .m-drawer-card .leaderboard {
    max-height: none;
  }

  .board-frame {
    padding: 8px;
    border-radius: 14px;
    width: auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #board {
    max-width: 100%;
    max-height: 100%;
    width: auto; height: auto;
  }

  /* ---- mobile controls: swipe is primary, two physical keys as backup ---- */
  .mobile-controls {
    display: grid;
    grid-row: 3;
    grid-template-columns: 1fr 1.4fr;
    gap: 10px;
    padding: 6px 4px calc(10px + env(safe-area-inset-bottom, 0));
    align-items: stretch;
  }
  .dpad { display: none; }
  .action-keys {
    display: contents;
  }
  .key-hold, .key-space { min-height: 56px; }

  .key {
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 48px;
    color: #d9deff;
    background:
      linear-gradient(180deg, #2a2d44 0%, #1a1c2e 55%, #14162a 100%);
    border: 1px solid rgba(255,255,255,.08);
    border-top-color: rgba(255,255,255,.16);
    border-bottom-color: rgba(0,0,0,.55);
    border-radius: 10px;
    font-family: ui-sans-serif, system-ui, -apple-system, "SF Mono", monospace;
    font-weight: 700;
    text-shadow: 0 1px 0 rgba(0,0,0,.55);
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,.10),
      inset 0 -2px 0 rgba(0,0,0,.35),
      0 2px 0 rgba(0,0,0,.5),
      0 5px 10px rgba(0,0,0,.35);
    transition: transform .06s ease, box-shadow .06s ease, background .06s;
  }
  .key span { font-size: 22px; line-height: 1; letter-spacing: .02em; }
  .key em {
    font-style: normal;
    font-size: 9px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: rgba(217,222,255,.45);
    text-shadow: none;
  }
  .key-space span, .key-hold span { font-size: 13px; letter-spacing: .22em; }
  .key:active, .key.pressed {
    transform: translateY(2px);
    background: linear-gradient(180deg, #21243a, #14162a 60%, #0e1023);
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,.05),
      inset 0 -1px 0 rgba(0,0,0,.5),
      0 0 0 rgba(0,0,0,0),
      0 1px 4px rgba(0,0,0,.4);
  }
  /* glowing accent on the SPACE key (it's the money button) */
  .key-space {
    background:
      linear-gradient(180deg, #0ed2e6 0%, #00a2b6 55%, #007988 100%);
    color: #021014;
    text-shadow: 0 1px 0 rgba(255,255,255,.35);
    border-top-color: rgba(255,255,255,.4);
    border-bottom-color: rgba(0,0,0,.5);
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,.25),
      inset 0 -2px 0 rgba(0,0,0,.25),
      0 2px 0 rgba(0,0,0,.45),
      0 6px 18px rgba(0,234,255,.35);
  }
  .key-space em { color: rgba(2,16,20,.55); }
  .key-space:active, .key-space.pressed {
    background: linear-gradient(180deg, #00a2b6, #007988 60%, #005a66);
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,.1),
      inset 0 -1px 0 rgba(0,0,0,.4),
      0 1px 4px rgba(0,234,255,.25);
  }

  /* overlay sized for phone */
  .overlay { border-radius: 14px; padding: 10px; }
  .overlay-inner { width: 100%; max-width: 280px; gap: 14px; }
  .brand h1 { font-size: 20px; }
  .how-to { display: none; }
  .mobile-hint { display: flex; }
}
.mobile-hint {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  padding: 10px 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
  color: var(--muted);
  text-align: left;
}
.hint-row { display: flex; align-items: center; gap: 10px; }
.hint-icon {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  background: rgba(0,234,255,.10);
  color: var(--accent);
  font-size: 14px;
}

/* Landscape phone — board centre, dpad left thumb, action right thumb */
@media (max-width: 940px) and (orientation: landscape) and (max-height: 500px) {
  .app {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: 1fr;
    padding: 6px;
    gap: 8px;
  }
  .col.left { display: none; }
  .col.center { grid-column: 2; grid-row: 1; }
  .mobile-controls {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    grid-column: 1; grid-row: 1;
    width: 38vw;
    max-width: 220px;
    padding: 0;
  }
  .mobile-controls .dpad { aspect-ratio: auto; }
  /* second nav slot would be needed for action keys on right — keep simple for now */
}
