:root {
  --bg: #10131a;
  --panel: #1b2130;
  --panel-2: #232b3d;
  --ink: #e7ecf5;
  --muted: #8b95a9;
  --accent: #37d67a;
  --accent-ink: #06210f;
  --danger: #ff5d6c;
  --ring: #2f9e44;
  --ring-mat: #3fa34d;
  --border: #333c52;
  font-synthesis: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

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

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.brand {
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 8px;
}
h1.logo {
  font-size: 30px;
  letter-spacing: 1px;
  text-align: center;
  line-height: 1.15;
}
h1.logo .logo-dot {
  color: var(--accent);
  font-size: 1.5em;
  font-weight: 900;
  display: inline-block;
  vertical-align: -0.08em;
  margin: 0 0.02em;
}
h1.logo .logo-dotword {
  display: inline-block;
  font-size: 0.6em;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--ink);
  transform: rotate(-45deg);
  vertical-align: middle;
  margin: 0 0.08em;
}
h1.logo .logo-dotword .logo-dot {
  font-size: 1.3em;
  vertical-align: -0.12em;
  margin: 0 0.01em;
}

.card {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

input[type="text"] {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  padding: 12px 14px;
  outline: none;
}
input[type="text"]:focus { border-color: var(--accent); }

.code-input {
  text-transform: uppercase;
  letter-spacing: 8px;
  text-align: center;
  font-size: 26px;
}

button {
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 16px;
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
  letter-spacing: 0.5px;
}
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.ghost { background: transparent; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.row { display: flex; gap: 10px; width: 100%; }
.row > * { flex: 1; }
.divider { color: var(--muted); font-size: 12px; letter-spacing: 2px; }
.error { color: var(--danger); font-size: 14px; min-height: 18px; text-align: center; }

/* ---- lobby ---- */
.codebox { text-align: center; }
.codebox .big {
  font-size: 46px;
  letter-spacing: 10px;
  font-weight: 700;
  color: var(--accent);
}
.codebox .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.players { display: flex; gap: 10px; }
.player {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  min-width: 0;
}
.player .slot { font-size: 11px; color: var(--muted); }
.player .pname { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player.ready { border-color: var(--accent); }
.player .status { font-size: 11px; color: var(--muted); margin-top: 3px; }
.player.ready .status { color: var(--accent); }
.player.empty .pname { color: var(--muted); font-weight: 400; }

.cat-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
button.cat {
  flex: 0 0 auto;
  padding: 7px 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}
button.cat.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.game-search { font-size: 15px !important; padding: 10px 12px !important; }

.games-head { display: flex; align-items: center; justify-content: space-between; }
.layout-toggle { display: flex; gap: 4px; }
button.lt {
  width: 30px; height: 30px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; color: var(--muted);
  border-radius: 8px;
}
button.lt svg { width: 17px; height: 17px; }
button.lt.on { color: var(--accent-ink); background: var(--accent); border-color: transparent; }

.games { display: grid; gap: 10px; }
.game {
  position: relative;
  text-align: left;
  color: var(--ink);
  padding: 0;
  overflow: hidden;
  border-color: transparent;
  background: var(--panel-2);
  transition: transform 0.08s;
}
.game:active { transform: scale(0.97); }
.game.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.game .gart {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #242a36; /* overridden inline per game */
}
.game .gart .gicon { display: block; }
.game .grow { min-width: 0; display: flex; flex-direction: column; }
.game .gname { font-size: 14px; font-weight: 700; letter-spacing: 0.2px; }
.game .gblurb { font-size: 11.5px; color: var(--muted); font-weight: 400; line-height: 1.3; }
.game .gtag {
  position: absolute;
  top: 7px; right: 7px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  padding: 2px 7px;
}

/* list = one per row: art chip on the left, text on the right */
.games.list { grid-template-columns: 1fr; }
.games.list .game { display: flex; align-items: stretch; gap: 12px; }
.games.list .game .gart { width: 64px; border-radius: 0; }
.games.list .game .gart .gicon { width: 40px; height: 40px; }
.games.list .game .grow { flex: 1; justify-content: center; gap: 3px; padding: 11px 12px 11px 0; }
.games.list .game .gtag { position: static; align-self: flex-start; margin-top: 4px; }
.games.list .game .grow { position: relative; }

/* grid = two per row: full-bleed art panel + label bar */
.games.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.games.grid .game { display: flex; flex-direction: column; }
.games.grid .game .gart { width: 100%; height: 92px; }
.games.grid .game .gart .gicon { width: 56px; height: 56px; }
.games.grid .game .grow { padding: 8px 10px 10px; gap: 0; }
.games.grid .game .gname { text-align: center; }
.games.grid .game .gblurb { display: none; }

.empty-note { color: var(--muted); font-size: 13px; text-align: center; padding: 10px; grid-column: 1 / -1; }
.hint.centered { color: var(--muted); text-align: center; font-size: 13px; }

/* ---- arcade classics ---- */
.arc-final { text-align: center; }
.arc-note { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }

/* ---- bubble blast ---- */
.bb-wrap { position: absolute; inset: 0; }
.bb-weapons {
  position: absolute;
  left: 8px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 6;
}
.bb-weapon {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  font-size: 11px;
  background: rgba(20, 24, 32, 0.72);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 9px;
}
.bb-weapon .wi { font-size: 14px; }
.bb-weapon .wl { letter-spacing: 1px; }
.bb-weapon .wc {
  min-width: 16px; text-align: center; font-weight: 700;
  background: var(--panel-2); border-radius: 5px; padding: 1px 4px;
}
.bb-weapon.armed { border-color: var(--accent); color: var(--accent); }
.bb-weapon:disabled { opacity: 0.4; }
.bb-fire { bottom: calc(24px + env(safe-area-inset-bottom)); }

/* ---- play-mode segmented control ---- */
.mode-bar {
  display: flex;
  width: 100%;
  gap: 3px;
  padding: 3px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 11px;
}
.mode-opt {
  flex: 1;
  padding: 10px 4px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}
.mode-opt.on { background: var(--accent); color: var(--accent-ink); }
.mode-opt:disabled { opacity: 0.3; cursor: not-allowed; }
.solo-card { text-align: center; }

/* ---- CPU opponent ---- */
.player.bot { border-style: dashed; }
.player.bot .pname { text-transform: capitalize; }
.diff-pills { display: flex; gap: 8px; }
button.diff {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 6px;
  background: var(--panel-2);
  border-radius: 10px;
  line-height: 1.15;
}
button.diff .dn { font-size: 14px; font-weight: 700; }
button.diff .db { font-size: 10px; color: var(--muted); font-weight: 400; }
button.diff.on { background: var(--accent); border-color: transparent; }
button.diff.on .dn, button.diff.on .db { color: var(--accent-ink); }

/* ---- lobby / results: sticky action dock ---- */
#screen-lobby, #screen-results { padding-bottom: 128px; }
.lobby-dock {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px -18px calc(-24px - env(safe-area-inset-bottom));
  padding: 14px 18px calc(16px + env(safe-area-inset-bottom));
  background: var(--bg);
  box-shadow: 0 -18px 22px -4px var(--bg), 0 -1px 0 var(--border);
}
.lobby-dock .row { width: 100%; }

/* ---- QR panel ---- */
.qr-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
}
.qr-panel .qr {
  width: 190px;
  height: 190px;
  background: #fff;
  border-radius: 10px;
  padding: 8px;
}

/* ---- quiet reconnect pill ---- */
.reconnect-pill {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--ink);
  background: rgba(12, 15, 20, 0.9);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  animation: pill-in 0.2s ease;
}
@keyframes pill-in { from { opacity: 0; transform: translate(-50%, -6px); } }

/* ---- splash ---- */
#screen-splash { align-items: center; justify-content: center; gap: 22px; text-align: center; }
.splash-title { font-size: 16px; color: var(--ink); letter-spacing: 1px; }
.splash-spin {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .splash-spin { animation-duration: 2s; } }

/* ---- ad slot ---- */
.adslot {
  width: 100%;
  max-width: 520px;
  min-height: 90px;
  margin: 6px auto 0;
  border: 1px dashed var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
/* never show ads during play */
#screen-play .adslot { display: none !important; }

/* ---- play screen ---- */
#screen-play {
  position: fixed;
  inset: 0;
  max-width: none;
  width: 100%;
  padding: 0;
  gap: 0;
  background: #0c0f14;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  overflow-x: hidden;
}
#game-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.quit-btn {
  position: absolute;
  top: calc(7px + env(safe-area-inset-top));
  left: calc(7px + env(safe-area-inset-left));
  z-index: 50;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  border-radius: 50%;
  background: rgba(12, 15, 20, 0.78);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 9px rgba(0, 0, 0, 0.4);
  touch-action: manipulation;
}
.quit-btn:active { transform: scale(0.9); }
.best-banner {
  position: absolute;
  top: calc(30px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  max-width: 78vw;
  padding: 4px 12px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--ink);
  background: rgba(12, 15, 20, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
/* keep DOM-game headers clear of the quit button */
#screen-play .chess-wrap,
#screen-play .wd-wrap,
#screen-play .shred-wrap,
#screen-play .snl-wrap,
#screen-play .ck-wrap { padding-top: 40px; }

/* ---- boxing: floating joystick + punch ---- */
.stick-base {
  position: absolute;
  width: 108px; height: 108px;
  margin: -54px 0 0 -54px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.16);
  pointer-events: none;
  z-index: 5;
}
.stick-nub {
  position: absolute;
  left: 50%; top: 50%;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  border: 2px solid rgba(255,255,255,0.35);
  transform: translate(-50%, -50%);
}
.punch-btn {
  position: absolute;
  right: 24px;
  bottom: calc(28px + env(safe-area-inset-bottom));
  width: 104px; height: 104px;
  border-radius: 50%;
  background: var(--danger);
  color: #2a0007;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 1px;
  display: flex; align-items: center; justify-content: center;
  user-select: none;
  touch-action: none;
  z-index: 6;
}
.punch-btn.active { filter: brightness(1.35); transform: scale(0.94); }
.wb-power {
  position: absolute;
  right: 16px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  padding: 12px 18px;
  border-radius: 12px;
  background: #4db3ff;
  color: #04121f;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 1px;
  border: none;
  z-index: 6;
  touch-action: manipulation;
}
.wb-power:active { transform: scale(0.94); }
.touch-hint {
  position: absolute;
  left: 50%;
  bottom: calc(40px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  letter-spacing: 1px;
  pointer-events: none;
}
/* the FIRE button stays on every size — it works with a tap or a click, and a
   wide screen might still be a touch device (tablet, big phone in landscape).
   Only the touch-worded control hint drops away where a keyboard is likely. */
@media (min-width: 800px) {
  .touch-hint { display: none; }
}

/* ---- chess ---- */
.chess-wrap {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.chess-status { font-size: 15px; color: var(--muted); min-height: 20px; text-align: center; }
.chess-status.mine { color: var(--accent); font-weight: 700; }
.chess-status .warn { color: var(--danger); }
.chess-board {
  width: min(92vw, 420px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 3px solid #2b2f3a;
  border-radius: 6px;
  overflow: hidden;
  touch-action: manipulation;
}
.chess-board .sq {
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.chess-board .sq.light { background: #e9e2cf; }
.chess-board .sq.dark { background: #7a9b76; }
.chess-board .sq.last::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(255, 231, 92, 0.32);
}
.chess-board .sq.sel::after {
  content: ""; position: absolute; inset: 0;
  box-shadow: inset 0 0 0 3px var(--accent);
}
.chess-board .sq.target::before {
  content: ""; position: absolute;
  width: 30%; height: 30%; border-radius: 50%;
  background: rgba(20,20,20,0.32);
  z-index: 2;
}
.chess-board .sq.target:has(.pc)::before {
  width: 82%; height: 82%; background: transparent;
  box-shadow: inset 0 0 0 4px rgba(20,20,20,0.35);
  border-radius: 50%;
}
.chess-board .pc {
  font-size: clamp(22px, 8vw, 40px);
  line-height: 1;
  z-index: 1;
  user-select: none;
}
.chess-board .pc.white { color: #fff; text-shadow: 0 0 2px #000, 0 1px 2px #000; }
.chess-board .pc.black { color: #16181d; text-shadow: 0 0 2px rgba(255,255,255,0.5); }

/* ---- checkers (shares the chess board grid) ---- */
.ck-board {
  width: min(92vw, 420px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 3px solid #2b2f3a;
  border-radius: 6px;
  overflow: hidden;
  touch-action: manipulation;
}
.ck-board .sq { position: relative; display: flex; align-items: center; justify-content: center; }
.ck-board .sq.light { background: #e9e2cf; }
.ck-board .sq.dark { background: #6b4a34; }
.ck-board .sq.last::after { content: ""; position: absolute; inset: 0; background: rgba(255, 231, 92, 0.28); }
.ck-board .sq.sel::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 3px var(--accent); }
.ck-board .sq.target::before {
  content: ""; position: absolute; width: 34%; height: 34%; border-radius: 50%;
  background: rgba(55, 214, 122, 0.55); z-index: 2;
}
.ck-pc {
  position: relative;
  width: 74%; height: 74%; border-radius: 50%;
  z-index: 1;
  box-shadow: inset 0 -3px 4px rgba(0,0,0,0.35), 0 2px 3px rgba(0,0,0,0.4);
}
.ck-pc.red { background: radial-gradient(circle at 35% 30%, #ff8189, #c9302c); }
.ck-pc.black { background: radial-gradient(circle at 35% 30%, #4a4f5a, #16181d); }
.ck-pc.king::after {
  content: "♛"; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(14px, 4.5vw, 22px); color: #f5c451;
}
.chess-moves {
  width: min(92vw, 420px);
  display: flex; gap: 6px; flex-wrap: nowrap;
  overflow-x: auto;
  font-size: 13px;
  color: var(--muted);
  padding-bottom: 4px;
}
.chess-moves .mv-num { color: #5b6577; }
.chess-moves .mv { color: var(--ink); }
button.small { padding: 8px 14px; font-size: 13px; }

/* ---- word duel ---- */
.wd-wrap {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.wd-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.wd-status { font-size: 14px; color: var(--muted); }
.wd-rival-box { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.wd-rival-label { font-size: 10px; letter-spacing: 1px; color: var(--muted); }
.wd-grid { display: grid; gap: 5px; }
.wd-grid .wd-row { display: grid; grid-template-columns: repeat(var(--cols, 5), 1fr); gap: 5px; }
.wd-grid.me { width: min(84vw, 320px); }
.wd-grid.me .wd-tile {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(18px, 6.5vw, 30px);
  font-weight: 800;
  border: 2px solid var(--border);
  border-radius: 4px;
  color: #fff;
  text-transform: uppercase;
}
.wd-grid.me .wd-tile.typed { border-color: #6b7690; }
.wd-grid.rival { width: 84px; }
.wd-grid.rival .wd-tile {
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--panel-2);
}
.wd-tile.g { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.wd-tile.y { background: #d8a531; border-color: #d8a531; color: #2a1e00; }
.wd-tile.b { background: #3a4152; border-color: #3a4152; }
.wd-grid.rival .wd-tile.g { background: var(--accent); }
.wd-grid.rival .wd-tile.y { background: #d8a531; }
.wd-grid.rival .wd-tile.b { background: #3a4152; }
.wd-msg {
  min-height: 16px; font-size: 13px; color: var(--danger);
  opacity: 0; transition: opacity 0.15s;
}
.wd-msg.show { opacity: 1; }
.wd-msg.good { color: var(--accent); font-weight: 700; }
.wd-kb { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.wd-krow { display: flex; gap: 5px; justify-content: center; }
.wd-key {
  flex: 1 1 0;
  min-width: 0;
  max-width: 40px;
  height: 48px;
  padding: 0;
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--panel-2);
  border-radius: 5px;
}
.wd-key.wide { flex: 1.6 1 0; max-width: 62px; font-size: 11px; }
.wd-key.g { background: var(--accent); color: var(--accent-ink); }
.wd-key.y { background: #d8a531; color: #2a1e00; }
.wd-key.b { background: #2a2f3b; color: #6a7386; }
.wd-answer {
  font-size: 34px; font-weight: 800; letter-spacing: 8px;
  color: var(--accent); text-transform: uppercase;
}

.results-mini { transform: scale(0.9); transform-origin: top center; }
.results-mini .chess-board { width: min(70vw, 300px); }

.results-line { font-size: 26px; text-align: center; font-weight: 800; }
.results-line .win { color: var(--accent); }
.score-big { font-size: 40px; text-align: center; letter-spacing: 4px; }
.hide { display: none !important; }

/* ---- shred ---- */
.shred-wrap {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: stretch;
  min-height: 70vh;
}
.shred-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.shred-head .nm { color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 12px; }
.shred-head b { color: var(--ink); font-size: 16px; }
.shred-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  touch-action: none;
}
.shred-stage.hit { animation: shred-shake .09s linear; }
.shred-stage.broke { animation: shred-broke .5s ease forwards; }
@keyframes shred-shake {
  0%,100% { transform: translate(0,0); }
  25% { transform: translate(-4px, 2px) rotate(-1deg); }
  75% { transform: translate(4px, -2px) rotate(1deg); }
}
@keyframes shred-broke {
  0% { transform: scale(1); opacity: 1; }
  20% { transform: scale(1.08); }
  100% { transform: scale(.6) rotate(8deg); opacity: 0; }
}
.shred-art { width: min(74vw, 300px); position: relative; transition: filter .2s; }
.shred-art svg { width: 100%; height: auto; display: block; }
.shred-art.crackA::after, .shred-art.crackB::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(76deg, transparent 47%, rgba(0,0,0,.55) 48%, transparent 49%),
    linear-gradient(-58deg, transparent 62%, rgba(0,0,0,.4) 63%, transparent 64%);
}
.shred-art.crackB::after {
  background:
    linear-gradient(76deg, transparent 40%, rgba(0,0,0,.6) 41%, transparent 43%),
    linear-gradient(-58deg, transparent 55%, rgba(0,0,0,.5) 56%, transparent 58%),
    linear-gradient(20deg, transparent 68%, rgba(0,0,0,.45) 69%, transparent 71%);
}
.shred-bar {
  display: flex;
  height: 16px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.shred-bar .b { transition: flex-grow .12s linear; min-width: 0; }
.shred-bar .b.you { background: var(--accent); }
.shred-bar .b.rival { background: var(--danger); }
.shred-bar .b.mid { background: transparent; }
.shred-hint {
  text-align: center;
  font-family: var(--font-display, ui-monospace), monospace;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 3px;
  color: var(--muted);
  min-height: 26px;
}
.shred-hint.win { color: var(--accent); }
.shred-hint.lose { color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  .shred-stage.hit, .shred-stage.broke { animation: none; }
  .drop-tile.focusing svg { transition: none; }
}

/* ---- tetris: dedicated d-pad + rotate (no floating joystick) ---- */
.tet-pad {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(10px + env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 6;
  pointer-events: none;
}
.tet-pad > * { pointer-events: auto; }
.tet-dpad {
  display: grid;
  grid-template-columns: repeat(3, 50px);
  grid-template-rows: repeat(2, 50px);
  gap: 6px;
}
.tet-btn {
  padding: 0;
  font-size: 19px;
  line-height: 1;
  border-radius: 10px;
  background: rgba(20, 24, 32, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
}
.tet-btn.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.tb-hard  { grid-column: 2; grid-row: 1; }
.tb-left  { grid-column: 1; grid-row: 2; }
.tb-down  { grid-column: 2; grid-row: 2; }
.tb-right { grid-column: 3; grid-row: 2; }
.tet-rotate {
  width: 82px; height: 82px;
  border-radius: 50%;
  font-size: 30px;
  background: var(--danger);
  color: #2a0007;
  border: none;
  font-weight: 800;
}
.tet-rotate.on { filter: brightness(1.3); transform: scale(0.94); }
@media (min-width: 800px) { .tet-pad { opacity: 0.5; } }

/* ---- worms: bomb-size picker + fire ---- */
.wrm-pad {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 6;
  pointer-events: none;
  opacity: 0.4;
  transition: opacity 0.15s;
}
.wrm-pad.live { opacity: 1; }
.wrm-pad > * { pointer-events: auto; }
.wrm-sizes { display: flex; gap: 6px; }
.wrm-size {
  width: 44px; height: 44px;
  padding: 0;
  font-size: 16px;
  border-radius: 10px;
  background: rgba(20, 24, 32, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--ink);
}
.wrm-size.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.wrm-fire {
  width: 78px; height: 78px;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  background: var(--danger);
  color: #2a0007;
  border: none;
}
.wrm-fire:active { transform: scale(0.94); filter: brightness(1.2); }
@media (min-width: 800px) { .wrm-pad { opacity: 0.6; } .wrm-pad.live { opacity: 1; } }

/* "never expires" — prompt to ping your friend once your move is in */
.wrm-notify {
  position: absolute;
  left: 50%; top: 56px;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: rgba(20, 24, 32, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 8px 8px 8px 14px;
  z-index: 7;
  max-width: calc(100% - 24px);
}
.wrm-notify-text { color: var(--muted); font-size: 12px; white-space: nowrap; }
.wrm-notify-link {
  display: inline-flex; align-items: center; gap: 4px;
  background: #25d366; color: #04220f;
  font-weight: 800; font-size: 12px;
  padding: 7px 12px; border-radius: 8px;
  text-decoration: none; white-space: nowrap;
}
.wrm-notify-x {
  background: transparent; border: none; color: var(--muted);
  font-size: 15px; padding: 2px 6px; line-height: 1;
}

/* ---- snakes & ladders ---- */
.snl-wrap {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.snl-status {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  min-height: 20px;
  text-align: center;
}
.snl-board {
  width: min(92vw, 420px);
  aspect-ratio: 1;
  background: #10141c;
  border-radius: 8px;
  touch-action: manipulation;
}
.snl-roll {
  width: min(70vw, 240px);
  height: 56px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--muted);
}
.snl-roll.live { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.snl-roll:disabled { opacity: 0.55; }

/* ---- solo leaderboard ---- */
.lb-card { gap: 10px; }
.lb-head { display: flex; align-items: center; justify-content: space-between; }
.lb-head label { display: flex; align-items: center; gap: 6px; }
.lb-unit { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

.lb-tabs {
  display: flex; gap: 8px; width: 100%;
  overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: none;
}
.lb-tabs::-webkit-scrollbar { display: none; }
.lb-tab {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 13px;
  font-size: 12px; font-weight: 700;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
}
.lb-tab.on { color: var(--accent); border-color: var(--accent); background: #16261e; }
.lb-tab-ico { font-size: 13px; }
.lb-score { text-align: center; }
.lb-score .n { font-size: 34px; font-weight: 800; letter-spacing: 2px; display: block; }
.lb-score .u { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.lb-post { display: flex; gap: 8px; }
.lb-post input { flex: 1; min-width: 0; }
.lb-post button { flex: 0 0 auto; }
.lb-you { text-align: center; color: var(--accent); font-weight: 700; font-size: 14px; }
.lb-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 264px;
  overflow-y: auto;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 14px;
}
.lb-row:nth-child(odd) { background: var(--panel-2); }
.lb-row.mine { background: var(--accent); color: var(--accent-ink); }
.lb-rank {
  width: 22px;
  flex: 0 0 auto;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.lb-row.mine .lb-rank { color: var(--accent-ink); }
.lb-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.lb-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-detail { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-row.mine .lb-detail { color: rgba(6, 33, 15, 0.7); }
.lb-sc { flex: 0 0 auto; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- menu, settings, feedback, how-to-play (ported from the native client) ---- */
.top-icons {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  display: flex;
  gap: 8px;
  z-index: 20;
}
.menu-btn {
  width: 38px; height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
}
.menu-btn svg { width: 18px; height: 18px; display: block; }
.trophy-btn { font-size: 16px; }
.home-logo { margin-top: 42px; }
.link-back { background: none; border: none; color: var(--muted); font-size: 14px; font-weight: 600; padding: 6px 2px; }

#screen-settings, #screen-home { position: relative; }
.settings-head, .htp-head {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: 520px; margin: 0 auto 6px;
}
.settings-head .brand, .htp-head .brand { margin: 0; }
.settings-head > span, .htp-head > span { width: 52px; }

.settings-card { gap: 4px; }
.settings-sec {
  color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: 1px; margin-bottom: 6px;
}
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.settings-row-text { flex: 1; }
.srl { color: var(--ink); font-size: 15px; font-weight: 600; }
.srs { color: var(--muted); font-size: 12px; margin-top: 2px; }
.settings-divider { height: 1px; background: var(--border); margin: 2px 0; }
.settings-about { color: var(--ink); font-size: 13px; line-height: 1.5; }

.toggle {
  flex: 0 0 auto;
  width: 46px; height: 28px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border);
  position: relative; transition: background 0.15s;
}
.toggle .knob {
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--muted); transition: transform 0.15s, background 0.15s;
}
.toggle.on { background: var(--accent); border-color: var(--accent); }
.toggle.on .knob { transform: translateX(18px); background: var(--accent-ink); }

.row-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: none; border: none; color: var(--ink);
  font-size: 15px; font-weight: 600; padding: 10px 0;
  text-decoration: none;
}
.row-btn .chev { color: var(--muted); font-size: 18px; }

/* mobile-apps "coming soon" block */
.apps-card { gap: 8px; }
.apps-soon {
  display: inline-block;
  align-self: flex-start;
  font-size: 10px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--accent-ink); background: var(--accent);
  border-radius: 999px; padding: 3px 10px; margin-bottom: 4px;
}
.apps-badges { display: flex; gap: 10px; flex-wrap: wrap; opacity: 0.55; filter: grayscale(0.4); }
.apps-badges svg { width: 132px; height: 44px; }

/* feedback modal */
.fb-overlay, .htp-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(4, 6, 10, 0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.htp-overlay { align-items: stretch; background: var(--bg); flex-direction: column; padding: 0; }
.fb-card {
  width: 100%; max-width: 420px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.fb-title { color: var(--ink); font-size: 17px; font-weight: 800; }
.fb-text {
  width: 100%; min-height: 110px; resize: vertical;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; color: var(--ink); font: inherit; font-size: 14px;
}
.fb-err { color: var(--danger); font-size: 12px; }
.fb-done { color: var(--ink); font-size: 14px; line-height: 1.5; }
.fb-actions { display: flex; justify-content: flex-end; gap: 10px; }
.fb-actions button { flex: 0 0 auto; padding: 10px 20px; }

/* how-to-play interstitial */
.htp-head { max-width: 560px; padding: calc(14px + env(safe-area-inset-top)) 16px 8px; margin: 0 auto; }
.htp-body {
  flex: 1; overflow-y: auto; width: 100%; max-width: 560px; margin: 0 auto;
  padding: 8px 20px 20px; display: flex; flex-direction: column; align-items: center;
}
.htp-art {
  width: 92px; height: 92px; border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  margin: 6px 0 12px;
}
.htp-art .gicon { width: 52px; height: 52px; }
.htp-name { color: var(--ink); font-size: 20px; font-weight: 800; margin-bottom: 16px; text-align: center; }
.htp-card { width: 100%; margin-bottom: 12px; }
.htp-sec {
  color: var(--accent); font-size: 11px; font-weight: 800;
  letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px;
}
.htp-p { color: var(--ink); font-size: 14.5px; line-height: 1.5; }
.htp-foot {
  width: 100%; max-width: 560px; margin: 0 auto;
  background: var(--panel); border-top: 1px solid var(--border);
  padding: 12px 18px calc(24px + env(safe-area-inset-bottom));
}
.htp-go { width: 100%; padding: 14px; font-size: 16px; }

.games-group-label {
  color: var(--muted); font-size: 11px; font-weight: 800;
  letter-spacing: 1px; text-transform: uppercase;
  margin: 10px 2px 8px;
}
.games-group-label:first-child { margin-top: 2px; }
