:root {
  /* ── Light · "Clean Modern" ───────────────────────────────────────── */
  color-scheme: light;
  --bg: #f5f6fb;
  --bg-grad: radial-gradient(1100px 520px at 0% -10%, rgba(79, 70, 229, 0.06) 0%, transparent 60%),
             radial-gradient(900px 480px at 110% 0%, rgba(6, 182, 212, 0.05) 0%, transparent 55%),
             #f5f6fb;
  --text: #4b5065;
  --text-strong: #111827;
  --text-muted: #646a80;          /* ≥ 4.5:1 on both #fff and #f5f6fb */
  --surface: #ffffff;
  --surface-hover: #f3f4fa;
  --surface-2: #ffffff;           /* inputs / chips / header buttons */
  /* game-board tokens — kept close to the originals so game play areas
     (2048 board etc.) keep their identity in light mode */
  --board-bg: #bbada0;
  --cell-bg: #cdc1b4;
  /* neutral "secondary" fill — games use it for keys / cells / card backs */
  --btn-bg: #6b7190;
  --btn-bg-hover: #575c78;
  --btn-disabled: #e3e5ee;
  --select-bg: #eef0f7;
  --score-label: #eee4da;
  --overlay-bg: rgba(245, 246, 251, 0.88);
  /* brand accent — profile cosmetics (body.accent-*) override these two */
  --accent: #4f46e5;
  --accent-soft: #6366f1;
  --accent-2: #06b6d4;
  --danger: #f65e3b;
  --border: #e6e8f0;
  --shadow-sm: 0 1px 3px rgba(17, 24, 39, 0.05), 0 1px 2px rgba(17, 24, 39, 0.03);
  --shadow-md: 0 6px 16px rgba(17, 24, 39, 0.07), 0 2px 4px rgba(17, 24, 39, 0.04);
  --shadow-lg: 0 14px 32px rgba(17, 24, 39, 0.10), 0 4px 10px rgba(17, 24, 39, 0.05);
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --card-radius: 20px;
  --thumb-inset: 10px;            /* light cards inset the artwork */
  --thumb-radius: 14px;
}

body.dark,
:where(html.dark) > body {
  /* ── Dark · "Midnight Arcade" ─────────────────────────────────────── */
  color-scheme: dark;
  --bg: #0d0f1e;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, rgba(76, 52, 200, 0.42) 0%, transparent 60%),
             radial-gradient(900px 500px at 110% 10%, rgba(14, 116, 144, 0.35) 0%, transparent 55%),
             #0d0f1e;
  --text: #c9cbe6;
  --text-strong: #f5f6ff;
  --text-muted: #9295bb;
  --surface: #171a31;
  --surface-hover: #1e2240;
  --surface-2: #151833;
  --board-bg: #262a4a;
  --cell-bg: #323862;
  --btn-bg: #3a4070;
  --btn-bg-hover: #474e85;
  --btn-disabled: #262a4a;
  --select-bg: #1e2240;
  --score-label: #c9cbe6;
  --overlay-bg: rgba(13, 15, 30, 0.88);
  --accent: #7c5cff;
  --accent-soft: #a855f7;
  --accent-2: #22d3ee;
  --border: #262a4a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.40), 0 2px 4px rgba(0, 0, 0, 0.30);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.45);
  --radius-lg: 18px;
  --card-radius: 18px;
  --thumb-inset: 0px;             /* dark cards: full-bleed artwork */
  --thumb-radius: 0px;
}

/* Tokens DERIVED from --accent. Declared on body (not :root) so they
   resolve against body's own --accent — that way the profile accent
   cosmetics (body.accent-*) recolour buttons / chips / glows too. */
body {
  --accent-fill: var(--accent);                       /* chips, primary buttons */
  --accent-ink: color-mix(in srgb, var(--accent) 80%, #000);  /* accent-coloured text */
  --accent-tint: color-mix(in srgb, var(--accent) 9%, #fff);  /* tag pill bg */
  --focus-ring: var(--accent);
  --on-accent: #fff;                                  /* text on accent fills */
  --accent-hover: color-mix(in srgb, var(--accent) 82%, #000);
  --card-hover-shadow: 0 14px 30px color-mix(in srgb, var(--accent) 16%, transparent);
}
body.dark,
:where(html.dark) > body {
  /* darkened 12% so white button text clears 4.5:1 on both gradient ends (was 4.35 / 3.96);
     color-mix keeps the profile accent cosmetics working */
  --accent-fill: linear-gradient(90deg, color-mix(in srgb, var(--accent) 88%, #000), color-mix(in srgb, var(--accent-soft) 88%, #000));
  --accent-ink: color-mix(in srgb, var(--accent) 55%, #fff);
  --accent-tint: color-mix(in srgb, var(--accent-2) 13%, transparent);
  --focus-ring: color-mix(in srgb, var(--accent) 60%, #fff);
  --accent-hover: color-mix(in srgb, var(--accent) 85%, #fff);
  --card-hover-shadow: 0 0 0 1px var(--accent), 0 14px 40px color-mix(in srgb, var(--accent) 28%, transparent);
}

* { box-sizing: border-box; }

/* html doesn't inherit body.dark variables — set background explicitly */
html.dark { background: #0d0f1e; color-scheme: dark; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .25s ease, color .25s ease;
}

/* Visible keyboard focus everywhere (mouse clicks don't trigger it). */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

a { color: inherit; text-decoration: none; }

/* ========== Header ========== */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 20px 8px;
  gap: 12px;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text-strong);
  border-radius: var(--radius-sm);
}
.site-brand:hover { opacity: 0.85; }
/* Dark: violet→cyan gradient wordmark (lobby only — game pages show "Back") */
body.dark #lobby-game-count {
  background: linear-gradient(90deg, var(--accent-ink), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.site-game-title {
  flex: 1;
  text-align: center;
  margin: 0 12px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ===== Per-game title themes ===== */
/* Electric neon arcade — Snake / Tetris / Breakout / Pong / Asteroids / Space Invaders / Cubesmash / Stairs / Stick Hero / Tanks / Platformer */
.site-game-title.theme-neon {
  font-family: 'Courier New', 'Consolas', monospace;
  color: #5cf;
  text-shadow: 0 0 8px rgba(80, 210, 255, 0.85), 0 0 18px rgba(0, 140, 220, 0.55);
  letter-spacing: 3px;
  font-weight: 700;
}
/* Retro 8-bit arcade — Pac-Man / Frogger / Flappy / Simon / Whack / Typing / Tower */
.site-game-title.theme-pixel {
  font-family: 'Courier New', monospace;
  color: #ff9933;
  text-shadow: 2px 2px 0 #cc4400, 0 0 8px rgba(255, 153, 51, 0.45);
  letter-spacing: 2px;
  font-weight: 800;
}
/* Vibrant pink arcade — Bubble / Candy / Gems / Fruit / DDR / Slot */
.site-game-title.theme-arcade-pink {
  font-family: 'Trebuchet MS', sans-serif;
  color: #ff66cc;
  text-shadow: 0 0 8px rgba(255, 102, 204, 0.75), 0 2px 0 rgba(140, 40, 120, 0.6);
  letter-spacing: 2px;
  font-weight: 800;
}
/* Elegant serif — 2048 / Threes / Mahjong / Kakuro / Sudoku / Chess / Reversi / Xiangqi / Gomoku / UTTT / Dots & Boxes / Battleship / Connect4 / Puzzle15 */
.site-game-title.theme-elegant {
  font-family: Georgia, 'Times New Roman', 'Noto Serif TC', serif;
  color: #c8a040;
  font-style: italic;
  letter-spacing: 2px;
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
/* Casual warm — Memory / Solitaire / Spider / Fishing / Croc / Blackjack / RPS / Darts / Screw / FloodIt */
.site-game-title.theme-casual {
  font-family: 'Trebuchet MS', 'Comic Sans MS', sans-serif;
  color: #7c5fd6;
  letter-spacing: 1px;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(100, 80, 200, 0.3);
}
/* Bold sans — Wordle / Hangman / Boggle / Wordsearch */
.site-game-title.theme-bold {
  font-family: 'Arial Black', Helvetica, sans-serif;
  color: var(--text-strong);
  letter-spacing: 4px;
  font-weight: 900;
  text-transform: uppercase;
}
/* Minimal mono — Minesweeper / Nonogram / Lights Out */
.site-game-title.theme-minimal {
  font-family: 'Consolas', 'Courier New', monospace;
  color: var(--text-strong);
  letter-spacing: 3px;
  font-weight: 600;
}

.site-version {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0;
  opacity: 0.7;
  align-self: flex-end;
  padding-bottom: 1px;
}

.site-brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  flex-shrink: 0;
}

.site-game-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  align-self: flex-end;
  padding-bottom: 3px;
  margin-left: 2px;
}

.site-brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-fill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: -1px;
  box-shadow: var(--shadow-sm);
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}
.site-brand-icon.is-back {
  background: var(--surface-2);
  background-image: none;
  border: 1px solid var(--border);
  color: var(--text-strong);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}
.site-brand:hover .site-brand-icon.is-back {
  background: var(--surface-hover);
  border-color: var(--accent-soft);
  transform: translateX(-2px);
}

.site-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.site-theme-btn {
  background: var(--surface-2);
  color: var(--text-strong);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 36px;
  padding: 7px 14px;
  /* Consistent minimum width so icon-only buttons (🌙 / 🔊 / 📳 / 📊
     etc.) don't shrink narrower than text buttons like "EN". Wider
     text buttons grow naturally beyond this floor. */
  min-width: 44px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.2;
  transition: background .15s ease, border-color .15s ease;
  box-shadow: var(--shadow-sm);
}
.site-theme-btn:hover { background: var(--surface-hover); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }

/* Audio popover — speaker button + collapsible panel beneath it. The
   panel holds the volume slider + haptics toggle. Hidden by default;
   shown when the speaker button is clicked. */
.site-audio-popover { position: relative; display: inline-flex; }
.site-audio-panel {
  position: absolute;
  top: calc(100% + 6px);
  /* Centre under the speaker button on desktop. */
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  white-space: nowrap;
  /* Hard ceiling so the panel can never exceed the viewport width. */
  max-width: calc(100vw - 16px);
  animation: site-audio-panel-pop 0.16s cubic-bezier(.16,1.3,.4,1);
}
.site-vol-row {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; user-select: none;
}
.site-vol-label {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  min-width: 38px; letter-spacing: .5px;
}
.site-audio-panel[hidden] { display: none; }
@keyframes site-audio-panel-pop {
  from { transform: translate(-50%, -4px) scale(0.96); opacity: 0; }
  to   { transform: translate(-50%, 0)    scale(1);    opacity: 1; }
}

/* On phones the speaker may live inside the collapsible kebab menu —
   anchoring the popover to the button would let the actions panel
   clip it. Detach to viewport-fixed centring instead so the popover
   is ALWAYS fully on screen regardless of the speaker's location. */
@media (max-width: 600px) {
  .site-audio-panel {
    position: fixed;
    top: 64px;             /* just below the site header */
    right: 12px;
    left: auto;
    transform: none;
    /* Avoid clipping; the panel is small (slider + padding ≈ 180 px) */
    max-width: calc(100vw - 24px);
    animation-name: site-audio-panel-pop-mobile;
  }
  .site-volume-slider { width: 160px; }
}
@keyframes site-audio-panel-pop-mobile {
  from { transform: translateY(-6px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

/* Compact horizontal volume slider. */
.site-volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 4px;
  margin: 0;
  background: var(--border);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  vertical-align: middle;
}
.site-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--surface);
}
.site-volume-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 2px solid var(--surface);
}

/* Standalone haptics button — shares .site-theme-btn base styling.
   States:
     default          enabled & active — full opacity, accent border
     .is-off          enabled but user toggled off — dimmed
     .is-unsupported  iOS / browsers without navigator.vibrate — heavy
                      dim + diagonal strike-through hint that this
                      browser can't do haptics regardless of toggle */
.site-haptics-btn { transition: opacity .15s ease, border-color .15s ease; }
.site-haptics-btn.is-off { opacity: 0.42; }
.site-haptics-btn[aria-pressed="true"] { border-color: var(--accent); }
.site-haptics-btn.is-unsupported {
  opacity: 0.45;
  cursor: help;
  position: relative;
}
.site-haptics-btn.is-unsupported::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top right,
    transparent calc(50% - 1px),
    rgba(180, 60, 50, 0.65) calc(50% - 1px),
    rgba(180, 60, 50, 0.65) calc(50% + 1px),
    transparent calc(50% + 1px)
  );
  border-radius: inherit;
  pointer-events: none;
}

/* ========== Lobby ========== */
.lobby {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 20px 60px;
}

.lobby-title-row {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.lobby-title {
  font-size: clamp(40px, 8vmin, 64px);
  font-weight: 800;
  margin: 24px 0 0;
  letter-spacing: -2px;
  color: var(--text-strong);
  flex-shrink: 0;
}
.lobby-sub {
  color: var(--text-muted);
  margin: 0 0 32px;
  font-size: 15px;
  line-height: 1.5;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.game-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  overflow: hidden;
  position: relative;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  animation: card-in .5s ease forwards;
  /* `--card-i` is set by lobby.js per card so every card staggers in,
     not just the first 9. min() caps the cascade so cards beyond #30
     don't take forever to show up. */
  animation-delay: min(calc(var(--card-i, 0) * 40ms), 1200ms);
}
body.dark .game-card { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }
@keyframes card-in {
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes bounce-in {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  80%  { transform: scale(0.92); }
  100% { transform: scale(1); }
}
.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--card-hover-shadow);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.game-card:active { transform: translateY(-1px); }

.game-card-thumb {
  height: 140px;
  margin: var(--thumb-inset) var(--thumb-inset) 0;
  border-radius: var(--thumb-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.game-card-thumb svg { width: 100%; height: 100%; display: block; }

.game-card-body {
  padding: 14px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.game-card-title {
  font-size: 18px;
  font-weight: 800;
  margin: 0;
  color: var(--text-strong);
  letter-spacing: -0.2px;
}
.game-card-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
  /* Compact by default — show 2 lines, expand to full on hover. Keeps
     the lobby scannable when there are 60+ cards. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: -webkit-line-clamp .2s ease;
}
.game-card:hover .game-card-desc,
.game-card:focus-visible .game-card-desc,
.game-card.kb-focus .game-card-desc {
  -webkit-line-clamp: unset;
}
/* Footer row: tag pill (left) + decorative "▶ Play" pill (right).
   margin-top:auto pins it to the bottom so rows line up across cards. */
.game-card-foot {
  order: 3;
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.game-card-tag {
  display: inline-block;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.3;
  background: var(--accent-tint);
  color: var(--accent-ink);
  border: 1px solid transparent;
  border-radius: 999px;
  align-self: center;
  text-transform: uppercase;
}
body.dark .game-card-tag {
  color: var(--accent-2);
  border-color: color-mix(in srgb, var(--accent-2) 35%, transparent);
}
.game-card-play {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--accent-fill);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 25%, transparent);
  transition: transform .15s ease, box-shadow .15s ease;
}
.game-card:hover .game-card-play,
.game-card:focus-visible .game-card-play {
  transform: translateX(2px);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent);
}
.game-card[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.6;
}
.game-card[aria-disabled="true"] .game-card-tag,
.game-card[aria-disabled="true"] .game-card-play {
  background: var(--btn-disabled);
}

/* ========== Common buttons (used in games) ========== */
.btn {
  background: var(--accent);   /* primary = brand accent (cosmetics recolour it) */
  color: var(--on-accent);
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 36px;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  touch-action: manipulation;
  transition: background .15s ease, opacity .15s ease, transform .08s ease;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 22%, transparent), inset 0 1px 0 rgba(255,255,255,0.15);
}
.btn:hover:not(:disabled) { background: var(--accent-hover); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled {
  background: var(--btn-disabled);
  color: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
}
.btn-toggle[aria-pressed="false"] { opacity: 0.5; }

/* ========== Help modal ========== */
.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 28, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  animation: help-fadein .2s ease;
}
.help-overlay[hidden] { display: none; }
@keyframes help-fadein { from { opacity: 0; } to { opacity: 1; } }

.help-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 460px;
  width: 100%;
  max-height: 86vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: help-pop .25s cubic-bezier(.5, -0.1, .3, 1.3);
}
@keyframes help-pop {
  from { transform: translateY(16px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.help-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-strong);
  margin: 0;
  letter-spacing: -0.3px;
}
.help-close {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  line-height: 1;
  transition: background .12s ease, color .12s ease;
}
.help-close:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
}

.help-body {
  padding: 18px 20px 22px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  overflow-y: auto;
}
.help-body h3 {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  margin: 18px 0 8px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.help-body h3:first-child { margin-top: 0; }
.help-body p { margin: 0 0 10px; color: var(--text-strong); }
.help-body ul {
  margin: 0 0 12px;
  padding-left: 20px;
  color: var(--text-strong);
}
.help-body li { margin-bottom: 5px; }
.help-body kbd {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-strong);
  margin: 0 1px;
}
.help-body .swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  margin: 0 4px 0 0;
  vertical-align: -3px;
}

#help-content { display: none; }

/* ========== Game page common layout ==========
   Each game's HTML uses <main class="app">; these rules unify the look.
   Games can still override individual properties in their own style.css. */
.app {
  max-width: 540px;
  margin: 0 auto;
  padding: 8px 16px 40px;
}

.app .header {
  display: flex;
  /* The title now lives only in the site header (.site-game-title); the
     in-app .header is just the score row, right-aligned. */
  justify-content: flex-end;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.app .scores {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.app .score-box {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-strong);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  min-width: 64px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease;
}

.app .score-label {
  font-size: 10px;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
}

.app .score-value {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  margin-top: 2px;
}

.app .toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 18px;
}

.app .select {
  background: var(--select-bg);
  color: var(--text-strong);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 28px 8px 14px;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-strong) 50%),
                    linear-gradient(-45deg, transparent 50%, var(--text-strong) 50%);
  background-position: right 12px top 50%, right 8px top 50%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  transition: background-color .15s ease;
}
.app .select:hover { background-color: var(--surface-hover); }

.app .board-wrapper {
  display: flex;
  justify-content: center;
}

/* ========== Mobile tuning ========== */
/* Mobile actions toggle button — hidden on desktop */
.site-actions-toggle { display: none; }

@media (max-width: 600px) {
  .game-grid { grid-template-columns: 1fr; gap: 14px; }
  .lobby { padding-left: 12px; padding-right: 12px; }
  .lobby-title { margin-top: 12px; }
  .app { padding-left: 10px; padding-right: 10px; }
  .app .score-box { padding: 5px 8px; min-width: 52px; }
  .app .score-value { font-size: 16px; }
  .site-header { padding-left: 12px; padding-right: 12px; }
  .site-game-title { font-size: 1rem; margin: 0 6px; }
  /* Show the ⋯ toggle button on every phone/tablet-portrait viewport.
     Unified at 600 px to match the audio-popover breakpoint above so
     the header collapses and the popover anchors identically. */
  .site-actions-toggle { display: flex; align-items: center; justify-content: center; }

  /* Hide the actions bar from normal flow; show as compact 2-column grid when open */
  .site-header-actions {
    display: none;
    position: fixed;
    top: 52px;
    right: 12px;
    z-index: 1000;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 5px;
  }
  .site-header-actions.open { display: grid; }
  .site-header-actions .site-theme-btn,
  .site-header-actions a.site-theme-btn {
    box-sizing: border-box;
    text-align: center;
    padding: 8px 6px;
    border-radius: var(--radius-sm);
    font-size: 14px;
  }
  /* Audio popover positioning is handled globally in the 600px block
     above (position: fixed, top: 64px, right: 12px) — no further
     overrides needed inside the actions-panel context. */
}

/* ========== Filter bar ========== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.filter-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  min-height: 36px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.2px;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.filter-btn:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.filter-btn.active {
  background: var(--accent-fill);
  color: var(--on-accent);
  border-color: transparent;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 30%, transparent);
}
body.dark .filter-btn.active { box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 55%, transparent); }

/* Mobile filter dropdown (≤480px replaces filter-bar) */
.filter-select {
  display: none;
}
@media (max-width: 480px) {
  .filter-bar { display: none; }
  .filter-select {
    display: block;
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background-color: var(--surface-2);
    color: var(--text-strong);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
  }
}

/* ========== Sort bar ========== */
.sort-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.sort-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-right: 2px;
}

.sort-btn {
  padding: 4px 12px;
  min-height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.sort-btn:hover { background: var(--surface-hover); color: var(--text-strong); }
.sort-btn.active { background: var(--accent-fill); color: var(--on-accent); border-color: transparent; }

/* ========== Card badges (NEW / HOT) ========== */
.card-badge {
  position: absolute;
  top: calc(var(--thumb-inset) + 8px);
  left: calc(var(--thumb-inset) + 8px);
  z-index: 5;
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.6px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.card-badge-new {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
}
.card-badge-hot {
  background: linear-gradient(135deg, #ff6b35, #e74c3c);
  left: auto;
  right: calc(var(--thumb-inset) + 52px);   /* clear of the ☆ button */
}
.card-badge-new + .card-badge-hot { right: calc(var(--thumb-inset) + 52px); left: auto; }
.card-badge-3d {
  background: linear-gradient(135deg, #6c5ce7, #8e44ad);
  /* sits next to / instead of NEW, top-left */
}
.card-badge-new + .card-badge-3d { left: calc(var(--thumb-inset) + 60px); }

/* ========== Difficulty dot (bottom-left of thumb) ========== */
.diff-dot {
  position: absolute;
  bottom: 6px;
  left: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  z-index: 4;
  border: 2px solid rgba(0, 0, 0, 0.35);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.diff-dot[data-d="easy"]   { background: #2ecc71; }
.diff-dot[data-d="medium"] { background: #f1c40f; }
.diff-dot[data-d="hard"]   { background: #e74c3c; }

/* ========== Player progress pills (PB / Daily / 未玩, in card body) ========== */
.card-stats-row {
  order: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
  align-items: center;
}
.stat-pill {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.4px;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  line-height: 1.4;
}
.stat-pill-pb       { background: #fdf1cf; color: #7a5600; }
.stat-pill-daily    { background: #dcf5e6; color: #17683b; }
.stat-pill-unplayed { background: var(--surface-hover); color: var(--text-muted); border: 1px solid var(--border); }
body.dark .stat-pill-pb    { background: rgba(255, 211, 77, 0.14); color: #ffd34d; }
body.dark .stat-pill-daily { background: rgba(110, 219, 150, 0.14); color: #6edb96; }

/* ========== Continue last game (hero) ========== */
.continue-card {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1140px;
  margin: 12px auto 0;
  padding: 14px 18px;
  background: var(--accent-fill);
  color: var(--on-accent);
  border-radius: var(--radius-md);
  text-decoration: none;
  box-shadow: var(--shadow-md);
  transition: transform .15s ease-out, box-shadow .15s ease-out;
}
.continue-card[hidden] { display: none; }
.continue-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.continue-card:active { transform: translateY(0); }
.continue-card-arrow {
  font-size: 22px;
  background: rgba(255,255,255,0.25);
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.continue-card-body { flex: 1; min-width: 0; }
.continue-card-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  opacity: 0.85;
}
.continue-card-title {
  font-size: 22px;
  font-weight: 800;
  margin-top: 2px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.continue-card-meta {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.continue-card-chev {
  font-size: 28px;
  opacity: 0.7;
  flex-shrink: 0;
}
@media (max-width: 480px) {
  .continue-card { margin: 8px 12px 0; padding: 12px 14px; gap: 12px; }
  .continue-card-arrow { width: 38px; height: 38px; font-size: 18px; }
  .continue-card-title { font-size: 18px; }
}

/* ========== Recently played ========== */
.recent-bar {
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 20px 0;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.recent-bar[hidden] { display: none; }
.recent-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}
.recent-row { display: flex; gap: 8px; flex-wrap: wrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 480px) {
  .recent-bar { padding: 6px 12px 0; gap: 8px; }
  .recent-row { flex-wrap: nowrap; padding-bottom: 4px; }
  .recent-row::-webkit-scrollbar { display: none; }
  .recent-chip { font-size: 11px; padding: 4px 10px 4px 5px; gap: 5px; white-space: nowrap; }
  .recent-dot { width: 16px; height: 16px; }
}
.recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px 5px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-strong);
  transition: background .15s, border-color .15s;
  cursor: pointer;
}
.recent-chip:hover { background: var(--surface-hover); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.recent-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ========== Search bar ========== */
.search-bar {
  position: relative;
  flex: 1;
  min-width: 180px;
  max-width: 400px;
  margin: 0 0 4px;
}
.search-bar input {
  width: 100%;
  padding: 11px 40px 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-strong);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.search-bar input::placeholder { color: var(--text-muted); opacity: 1; }
.search-bar input:focus,
.search-bar input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.search-clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
  padding: 8px;
  line-height: 1;
}
.search-clear-btn:hover { color: var(--text-strong); }

/* ========== Keyboard focus ring ========== */
.game-card.kb-focus,
.game-card:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

/* ========== Favorites (star) button ========== */
.fav-btn {
  position: absolute;
  top: calc(var(--thumb-inset) + 6px);
  right: calc(var(--thumb-inset) + 6px);
  background: rgba(10, 12, 28, 0.35);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  border: none;
  border-radius: 999px;
  font-size: 18px;
  cursor: pointer;
  /* Visible at low opacity by default — full on hover / pinned / mobile.
     Previously `opacity:0` meant touch users could never see the
     button (no hover state). */
  opacity: 0.55;
  transition: opacity 0.2s, background 0.2s, transform 0.12s;
  color: #fff;
  line-height: 1;
  padding: 6px;
  min-width: 34px;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6;
}
.game-card:hover .fav-btn,
.fav-btn:focus-visible { opacity: 1; background: rgba(10, 12, 28, 0.55); }
.game-card .fav-btn:active { transform: scale(0.88); }
.game-card.pinned .fav-btn { opacity: 1; color: #ffd84a; background: rgba(10, 12, 28, 0.55); }
@media (pointer: coarse) {
  /* Touch devices have no hover — always show the button at full
     visibility so favoriting is one-tap. */
  .fav-btn { opacity: 1; }
}

/* ========== Daily challenge lobby banner ========== */
.daily-section {
  margin-bottom: 22px;
}
.daily-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.daily-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.daily-row::-webkit-scrollbar { height: 4px; }
.daily-row::-webkit-scrollbar-track { background: transparent; }
.daily-row::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
.daily-mini-card {
  flex-shrink: 0;
  width: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  position: relative;
  display: flex;
  flex-direction: column;
}
.daily-mini-card:hover,
.daily-mini-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--card-hover-shadow);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}
.daily-mini-thumb {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.daily-mini-thumb svg { width: 100%; height: 100%; display: block; }
.daily-mini-name {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 6px 6px;
  text-align: center;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.done-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #27ae60;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  border-radius: 999px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

/* ========== Pause overlay ========== */
.pause-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 28, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 150;
  gap: 10px;
  backdrop-filter: blur(2px);
}
.pause-overlay[hidden] { display: none; }
.pause-overlay-text {
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}
.pause-overlay-hint {
  font-size: 14px;
  color: rgba(255,255,255,0.65);
}
.pause-overlay-hint kbd {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  padding: 2px 7px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

/* ========== Achievement toast ========== */
.achievement-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 999;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 280px;
  opacity: 0;
  transform: translateX(120%);
  transition: opacity .3s ease, transform .3s ease;
  pointer-events: none;
}
.achievement-toast.achievement-toast-show {
  opacity: 1;
  transform: translateX(0);
}
.achievement-toast.achievement-toast-hide {
  opacity: 0;
  transform: translateX(120%);
}
.achievement-toast-icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}
.achievement-toast-body { display: flex; flex-direction: column; gap: 2px; }
.achievement-toast-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--accent-ink);
}
.achievement-toast-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-strong);
}
.achievement-toast-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ========== Reduced motion ========== */
@media (prefers-reduced-motion: reduce) {
  .game-card { transition: none; animation: none; }
  .game-card:hover { transform: none; }
  .achievement-toast, .achievement-toast.achievement-toast-hide { transition: none; }
}

/* ── Pause overlay (shared/pause.js) ───────────────────────────────────── */
.site-pause-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
  animation: site-pause-fade 0.15s ease-out;
}
.site-pause-overlay[hidden] { display: none; }
@keyframes site-pause-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.site-pause-card {
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--border));
  border-radius: var(--radius-lg, 14px);
  padding: 28px 36px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  min-width: 220px;
}
.site-pause-title {
  font-size: 28px; font-weight: 900;
  color: var(--accent-ink);
  letter-spacing: 4px;
  margin-bottom: 6px;
}
.site-pause-sub {
  font-size: 13px; color: var(--text-muted);
  margin-bottom: 18px;
}
.site-pause-btn-resume {
  background: var(--accent-fill); color: var(--on-accent);
  border: none; border-radius: var(--radius-md, 10px);
  padding: 8px 28px; font-size: 15px; font-weight: 700;
  cursor: pointer;
  transition: opacity .15s ease;
}
.site-pause-btn-resume:hover { opacity: 0.88; }
/* Header pause button — inherits .site-theme-btn base; only the icon
   needs a slightly larger glyph + a visible state when paused. */
.site-pause-btn[hidden] { display: none !important; }

/* ──────────────────────────────────────────────────────────────────────────
   Profile / XP system — lobby pill, level-up toast, accent variants
   ────────────────────────────────────────────────────────────────────────── */

/* Accent overrides — set on body when SiteProfile.activeAccent is unlocked.
   Each variant overrides --accent + --accent-soft so the entire UI re-tints. */
body.accent-gold        { --accent: #f5b400; --accent-soft: #ffd34d; }
body.dark.accent-gold   { --accent: #ffcb33; --accent-soft: #ffd966; }
body.accent-neon        { --accent: #00e0ff; --accent-soft: #66f0ff; }
body.dark.accent-neon   { --accent: #00e0ff; --accent-soft: #66f0ff; }
body.accent-magenta     { --accent: #e040b8; --accent-soft: #f471d4; }
body.dark.accent-magenta{ --accent: #ff5fc8; --accent-soft: #ff8cd9; }
/* Bright accents (gold / neon) need dark text on accent fills. */
body.accent-gold, body.accent-neon { --on-accent: #12141f; }
/* Rainbow uses a slow hue rotation so the accent shimmers across the UI. */
body.accent-rainbow     { --accent: #ff4d4d; --accent-soft: #ff8a8a; animation: profile-rainbow 8s linear infinite; }
body.dark.accent-rainbow{ --accent: #ff6666; --accent-soft: #ff9c9c; animation: profile-rainbow 8s linear infinite; }
@keyframes profile-rainbow {
  0%   { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

/* Lobby profile pill — lives in site-header next to the version pill. */
.profile-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 5px;
  background: var(--surface-2);
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--border));
  border-radius: 999px;
  font-size: 12px;
  min-height: 36px;
  line-height: 1;
  color: var(--text-strong);
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease, background .15s ease;
  box-shadow: var(--shadow-sm, 0 2px 4px rgba(0,0,0,0.08));
}
/* On mobile dropdown grid (≤600px), the pill spans both columns so the
   level bar isn't squashed into a 1-col slot wider than other icons. */
@media (max-width: 600px) {
  .site-header-actions .profile-pill {
    grid-column: 1 / -1;
    justify-content: center;
    padding: 6px 14px 6px 6px;
  }
}
.profile-pill:hover { transform: translateY(-1px); box-shadow: var(--shadow-md, 0 4px 8px rgba(0,0,0,0.15)); }
.profile-pill-avatar {
  display: inline-flex;
  width: 22px; height: 22px;
  align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: 50%;
  font-size: 13px;
}
.profile-pill-level { font-weight: 800; }
.profile-pill-bar {
  position: relative;
  width: 56px; height: 6px;
  background: color-mix(in srgb, var(--accent) 15%, rgba(0,0,0,0.08));
  border-radius: 3px;
  overflow: hidden;
}
body.dark .profile-pill-bar { background: rgba(255,255,255,0.18); }
.profile-pill-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--accent-fill);
  border-radius: 3px;
  transition: width .3s ease;
}

/* Level-up toast — own slot so it can stack with achievements without
   collision. Slides in from the right. */
.profile-toast {
  position: fixed;
  bottom: 80px;          /* sits above achievement toast (40px) */
  right: 16px;
  background: var(--accent-fill);
  color: var(--on-accent);
  padding: 12px 18px;
  border-radius: 14px;
  font-weight: 700;
  z-index: 10001;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  opacity: 0;
  transform: translateX(120%);
  transition: opacity .25s ease, transform .25s ease;
  max-width: 320px;
  cursor: pointer;
}
.profile-toast.profile-toast-show { opacity: 1; transform: translateX(0); }
.profile-toast.profile-toast-hide { opacity: 0; transform: translateX(120%); }
.profile-toast-main { font-size: 15px; }
.profile-toast-sub  { font-size: 12px; opacity: .92; margin-top: 4px; font-weight: 500; }

/* Lobby footer: About / Privacy / Contact links */
.site-footer {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 12px;
  padding: 24px 16px 40px; font-size: 13px; color: var(--text-muted);
}
.site-footer a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.site-footer a:hover { color: var(--accent-ink); }
