/* ===================================================================
   Brainy Bunch — cartoony mini-game arcade
   =================================================================== */

:root {
  --sky-1: #8ad7ff;
  --sky-2: #c6b8ff;
  --sky-3: #ffd6f0;

  --ink: #2b2150;
  --ink-soft: #6b6298;
  --paper: #fffdf7;
  --paper-2: #fff7e8;

  --p-red:    #ff6b6b;
  --p-orange: #ffa94d;
  --p-yellow: #ffd43b;
  --p-green:  #51cf66;
  --p-teal:   #20c997;
  --p-blue:   #4dabf7;
  --p-indigo: #7c5cff;
  --p-pink:   #f06595;
  --p-purple: #cc5de8;

  --good: #2fbf71;
  --bad: #ff5d6c;

  --shadow: 0 10px 0 rgba(43, 33, 80, 0.12);
  --shadow-soft: 0 14px 30px rgba(43, 33, 80, 0.18);
  --radius: 22px;
  --radius-lg: 30px;

  --font-display: 'Baloo 2', 'Fredoka', system-ui, sans-serif;
  --font-body: 'Fredoka', system-ui, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: linear-gradient(160deg, var(--sky-1) 0%, var(--sky-2) 55%, var(--sky-3) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

#bg-canvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

#fx-canvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 90;
  pointer-events: none;
}

button { font-family: inherit; }

.hidden { display: none !important; }

/* ---------- App shell ---------- */
.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 18px 60px;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 10px 16px 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.logo:active { transform: translateY(3px); box-shadow: 0 6px 0 rgba(43,33,80,.12); }
.logo-mark { font-size: 1.9rem; filter: drop-shadow(0 2px 0 rgba(0,0,0,.12)); }
.logo-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  line-height: .95;
  text-align: left;
  color: var(--ink);
  letter-spacing: .5px;
}

.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hud-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border-radius: 999px;
  padding: 8px 16px;
  box-shadow: var(--shadow);
  font-weight: 700;
}
.chip-icon { font-size: 1.25rem; }
.chip-value { font-family: var(--font-display); font-size: 1.15rem; }

.level-chip { padding-right: 18px; }
.level-badge {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  background: linear-gradient(160deg, var(--p-yellow), var(--p-orange));
  color: #fff;
  border-radius: 50%;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1rem;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.12);
}
.xp-wrap { display: flex; flex-direction: column; gap: 3px; min-width: 120px; }
.xp-bar {
  height: 10px;
  background: #ece6ff;
  border-radius: 999px;
  overflow: hidden;
}
.xp-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--p-indigo), var(--p-pink));
  border-radius: 999px;
  transition: width .5s cubic-bezier(.2,.9,.3,1.2);
}
.xp-text { font-size: .68rem; color: var(--ink-soft); font-weight: 600; }

.icon-btn {
  width: 44px; height: 44px;
  border: none;
  background: var(--paper);
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 5px 0 rgba(43,33,80,.12); }
.icon-btn.muted { opacity: .55; }

/* ---------- Hero ---------- */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #ffffff 0%, var(--paper-2) 100%);
  border-radius: var(--radius-lg);
  padding: 26px 30px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 26px;
  border: 4px solid #fff;
}
.hero-text h1 {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  margin: 0 0 6px;
  color: var(--ink);
}
.hero-text p { margin: 0; color: var(--ink-soft); font-weight: 500; }

.hero-progress { display: flex; align-items: center; gap: 22px; }
.ring {
  --pct: 0;
  width: 96px; height: 96px;
  border-radius: 50%;
  display: grid; place-items: center;
  background:
    radial-gradient(closest-side, #fff 70%, transparent 72% 100%),
    conic-gradient(var(--p-green) calc(var(--pct) * 1%), #e9e4ff 0);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--ink);
  box-shadow: var(--shadow);
}
.hero-stats { display: flex; gap: 16px; }
.hero-stats > div {
  display: flex; flex-direction: column; align-items: center;
  background: #fff; border-radius: 16px; padding: 10px 14px;
  box-shadow: var(--shadow); min-width: 64px;
}
.hero-stats strong { font-family: var(--font-display); font-size: 1.4rem; color: var(--p-indigo); }
.hero-stats span { font-size: .72rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .5px; }

/* ---------- Sections ---------- */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  margin: 8px 4px 14px;
}
.section-head h2 { font-family: var(--font-display); margin: 0; font-size: 1.5rem; }

.filter-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  border: none;
  background: rgba(255,255,255,.6);
  color: var(--ink-soft);
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s ease;
}
.tab:hover { background: #fff; }
.tab.active { background: var(--ink); color: #fff; }

/* ---------- Game grid ---------- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px;
  margin-bottom: 30px;
}

.game-card {
  position: relative;
  border: none;
  text-align: left;
  border-radius: var(--radius);
  padding: 20px 18px 18px;
  cursor: pointer;
  color: #fff;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .15s cubic-bezier(.2,.8,.3,1.4), box-shadow .15s ease;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.game-card::after {
  content: "";
  position: absolute; right: -28px; top: -28px;
  width: 110px; height: 110px;
  background: rgba(255,255,255,.18);
  border-radius: 50%;
}
.game-card:hover { transform: translateY(-6px) rotate(-1deg); box-shadow: 0 18px 0 rgba(43,33,80,.12); }
.game-card:active { transform: translateY(0); }

.gc-emoji { font-size: 2.6rem; filter: drop-shadow(0 3px 0 rgba(0,0,0,.18)); position: relative; z-index: 1; }
.gc-name { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; margin: 8px 0 2px; position: relative; z-index: 1; }
.gc-tag { font-size: .8rem; opacity: .92; font-weight: 500; position: relative; z-index: 1; }
.gc-meta {
  display: flex; align-items: center; gap: 6px;
  margin-top: 10px; position: relative; z-index: 1;
  font-size: .75rem; font-weight: 700;
}
.gc-cat {
  background: rgba(255,255,255,.25);
  padding: 3px 10px; border-radius: 999px;
}
.gc-best { margin-left: auto; background: rgba(0,0,0,.18); padding: 3px 10px; border-radius: 999px; }

.game-card.locked { cursor: not-allowed; filter: grayscale(.55) brightness(.92); }
.lock-overlay {
  position: absolute; inset: 0;
  background: rgba(40,30,70,.55);
  display: grid; place-items: center;
  z-index: 2;
  backdrop-filter: blur(1px);
}
.lock-overlay span { font-family: var(--font-display); font-weight: 700; font-size: .9rem; text-align: center; }
.lock-overlay .lock-icon { font-size: 1.6rem; display: block; }

/* ---------- Badge grid ---------- */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 30px;
}
.badge {
  background: #fff;
  border-radius: 18px;
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform .15s ease;
}
.badge.locked { opacity: .5; filter: grayscale(1); }
.badge.earned { animation: pop .4s ease; }
.badge-icon { font-size: 2rem; }
.badge-name { font-weight: 700; font-size: .85rem; margin-top: 6px; }
.badge-desc { font-size: .68rem; color: var(--ink-soft); margin-top: 2px; }

/* ---------- Play screen ---------- */
.play-top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.back-btn {
  border: none;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  padding: 10px 18px;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(43,33,80,.35);
  transition: transform .1s ease;
}
.back-btn:active { transform: translateY(4px); box-shadow: none; }
.play-title { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 200px; }
.play-emoji { font-size: 2.2rem; }
.play-title h2 { font-family: var(--font-display); margin: 0; font-size: 1.4rem; }
.play-title p { margin: 0; color: var(--ink-soft); font-size: .85rem; }

.play-hud { display: flex; gap: 10px; flex-wrap: wrap; }
.stat-pill {
  background: var(--paper-2);
  border-radius: 14px;
  padding: 8px 14px;
  text-align: center;
  min-width: 70px;
  box-shadow: inset 0 -3px 0 rgba(43,33,80,.06);
}
.stat-pill .sp-label { font-size: .66rem; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-soft); font-weight: 700; }
.stat-pill .sp-value { font-family: var(--font-display); font-size: 1.25rem; font-weight: 800; }
.stat-pill.flash { animation: flashPill .4s ease; }

.stage {
  background: linear-gradient(160deg, #ffffff, var(--paper-2));
  border-radius: var(--radius-lg);
  padding: 24px;
  min-height: 440px;
  box-shadow: var(--shadow-soft);
  border: 4px solid #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.stage.shake { animation: shake .4s ease; }

/* ---------- Generic UI bits used by games ---------- */
.btn {
  border: none;
  border-radius: 16px;
  padding: 12px 22px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform .1s ease, filter .1s ease;
}
.btn:active { transform: translateY(3px); }
.btn-primary {
  background: linear-gradient(160deg, var(--p-indigo), var(--p-purple));
  color: #fff;
  box-shadow: 0 6px 0 #5a3fd1;
}
.btn-primary:active { box-shadow: 0 3px 0 #5a3fd1; }
.btn-ghost {
  background: #efe9ff;
  color: var(--ink);
  box-shadow: 0 6px 0 #d8cffb;
}
.btn-ghost:active { box-shadow: 0 3px 0 #d8cffb; }
.btn-good { background: linear-gradient(160deg, var(--p-green), var(--p-teal)); color:#fff; box-shadow: 0 6px 0 #2faa57; }

.game-msg {
  font-family: var(--font-display);
  font-size: 1.3rem;
  text-align: center;
  color: var(--ink);
}
.game-sub { color: var(--ink-soft); text-align: center; margin-top: 4px; }

.choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; width: 100%; max-width: 460px; }
.choice {
  border: none;
  background: #fff;
  border-radius: 18px;
  padding: 18px;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(43,33,80,.12);
  transition: transform .08s ease;
}
.choice:hover { transform: translateY(-3px); }
.choice:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(43,33,80,.12); }
.choice.correct { background: var(--good); color: #fff; box-shadow: 0 6px 0 #259458; animation: pop .35s ease; }
.choice.wrong { background: var(--bad); color: #fff; box-shadow: 0 6px 0 #cc4654; animation: shake .35s ease; }

.countdown-big {
  font-family: var(--font-display);
  font-size: 6rem;
  font-weight: 800;
  color: var(--p-indigo);
  animation: pop .4s ease;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 36px;
  transform: translate(-50%, 140%);
  background: var(--ink);
  color: #fff;
  padding: 14px 24px;
  border-radius: 999px;
  font-weight: 700;
  z-index: 120;
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
  transition: transform .35s cubic-bezier(.2,.9,.3,1.4);
  max-width: 90vw;
  text-align: center;
}
.toast.show { transform: translate(-50%, 0); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(40,30,70,.5);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  z-index: 110;
  animation: fade .25s ease;
}
.modal {
  background: linear-gradient(160deg, #fff, var(--paper-2));
  border-radius: var(--radius-lg);
  padding: 34px 32px 28px;
  width: min(420px, 90vw);
  text-align: center;
  box-shadow: var(--shadow-soft);
  border: 5px solid #fff;
  animation: popIn .45s cubic-bezier(.2,.9,.3,1.5);
}
.modal-emoji { font-size: 4rem; animation: bounce 1s ease infinite; }
.modal h2 { font-family: var(--font-display); font-size: 2rem; margin: 6px 0 4px; }
.modal p { color: var(--ink-soft); margin: 0 0 16px; font-weight: 500; }
.modal-rewards { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.reward-pill {
  background: #fff; border-radius: 14px; padding: 10px 16px;
  font-weight: 800; font-family: var(--font-display);
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 6px;
}
.reward-pill.coins { color: var(--p-orange); }
.reward-pill.xp { color: var(--p-indigo); }
.modal-actions { display: flex; gap: 12px; justify-content: center; }

/* ---------- Settings ---------- */
.setting-row { display: flex; align-items: center; gap: 12px; margin: 18px 0; }
.setting-row label { font-weight: 700; min-width: 92px; text-align: left; }
.setting-val {
  min-width: 52px; text-align: right;
  font-family: var(--font-display); font-weight: 800; color: var(--p-indigo);
}
input[type="range"].vol {
  flex: 1;
  -webkit-appearance: none; appearance: none;
  height: 12px; border-radius: 999px;
  background: linear-gradient(90deg, var(--p-indigo) 50%, #e9e4ff 50%);
  outline: none; cursor: pointer;
}
input[type="range"].vol::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; border: 4px solid var(--p-indigo);
  box-shadow: 0 3px 0 rgba(43,33,80,.25);
}
input[type="range"].vol::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 4px solid var(--p-indigo);
  box-shadow: 0 3px 0 rgba(43,33,80,.25);
}
.settings-note { font-size: .8rem; color: var(--ink-soft); margin: 10px 0 16px; }

/* ---------- Animations ---------- */
@keyframes pop { 0%{transform:scale(.7)} 60%{transform:scale(1.15)} 100%{transform:scale(1)} }
@keyframes popIn { 0%{transform:scale(.5);opacity:0} 100%{transform:scale(1);opacity:1} }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }
@keyframes fade { from{opacity:0} to{opacity:1} }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-10px)} 40%{transform:translateX(9px)} 60%{transform:translateX(-7px)} 80%{transform:translateX(5px)} }
@keyframes flashPill { 0%{background:var(--p-yellow)} 100%{background:var(--paper-2)} }
@keyframes floatUp { from{transform:translateY(0);opacity:1} to{transform:translateY(-60px);opacity:0} }

.float-pts {
  position: fixed;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.4rem;
  color: var(--p-orange);
  text-shadow: 0 2px 0 #fff;
  pointer-events: none;
  z-index: 95;
  animation: floatUp .9s ease forwards;
}

/* tap ripple */
.fx-ripple {
  position: fixed;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;
  border: 3px solid rgba(124, 92, 255, 0.7);
  border-radius: 50%;
  pointer-events: none;
  z-index: 94;
  animation: rippleOut .6s ease-out forwards;
}
@keyframes rippleOut {
  from { transform: scale(0.3); opacity: .9; }
  to   { transform: scale(7); opacity: 0; }
}

/* full-screen flash */
.fx-flash {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 1;
  transition: opacity .4s ease;
}

/* celebratory glow pulse (added to .stage on win) */
.stage.celebrate { animation: celebrateGlow 1.1s ease; }
@keyframes celebrateGlow {
  0%   { box-shadow: var(--shadow-soft); }
  35%  { box-shadow: 0 0 0 6px rgba(255,212,59,.45), 0 0 60px 10px rgba(124,92,255,.45); }
  100% { box-shadow: var(--shadow-soft); }
}

/* ===================================================================
   New shell components — desktop defaults (mobile-first overrides below)
   =================================================================== */

/* hero is a single collapsible block; on desktop it always shows expanded */
.hero { flex-wrap: wrap; }
.hero-toggle {
  display: flex; align-items: center; gap: 22px;
  flex: 1 1 320px; border: none; background: none; padding: 0;
  text-align: left; color: inherit; font: inherit; cursor: default;
}
.hero-headline { flex: 1; order: 0; }
.hero-headline h1 { font-family: var(--font-display); font-size: clamp(1.7rem, 4vw, 2.6rem); margin: 0 0 6px; color: var(--ink); }
.hero-headline p { margin: 0; color: var(--ink-soft); font-weight: 500; }
.hero-toggle .ring { order: 1; }
.hero-chevron { display: none; }
.hero-body { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }

/* home tabs: on desktop every panel is visible (stacked) */
.tab-panel { display: block; }

/* bottom nav + sheet grabbers: mobile-only, hidden on desktop */
.bottom-nav { display: none; }
.sheet-grabber { display: none; }
.modal-actions-col { flex-direction: column; }
.modal-actions-col .btn { width: 100%; }
.btn-danger { background: #ffe3e6; color: #cc4654; box-shadow: 0 6px 0 #f3b3bb; }
.btn-danger:active { box-shadow: 0 3px 0 #f3b3bb; }

/* ---------- Touch: neutralise sticky :hover on touch devices ---------- */
@media (hover: none) {
  .game-card:hover { transform: none; box-shadow: var(--shadow); }
  .shop-card:hover, .choice:hover, .vial:hover { transform: none; }
  .tab:hover { background: rgba(255,255,255,.6); }
  .simon-pad:not(:disabled):hover { opacity: .5; }
}

/* ===================================================================
   MOBILE (phone-first)  ≤ 720px
   =================================================================== */
@media (max-width: 720px) {
  .app-shell { padding: 0; max-width: none; }
  #main { padding: 0 12px calc(96px + env(safe-area-inset-bottom)); }

  /* ---- compact sticky header ---- */
  .topbar {
    position: sticky; top: 0; z-index: 40;
    margin: 0 0 12px; padding: calc(8px + env(safe-area-inset-top)) 12px 10px;
    gap: 8px; flex-wrap: nowrap;
    background: color-mix(in srgb, var(--paper) 88%, transparent);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-radius: 0 0 22px 22px;
    box-shadow: 0 4px 0 rgba(43,33,80,.06);
  }
  .logo { padding: 0; width: 44px; height: 44px; justify-content: center; border-radius: 16px; }
  .logo-mark { font-size: 1.5rem; }
  .logo-text { display: none; }
  .hud { gap: 8px; flex: 1; flex-wrap: nowrap; }
  .hud-chip { padding: 0 12px; height: 44px; }
  .level-chip { flex: 1; min-width: 0; padding-right: 12px; }
  .xp-wrap { min-width: 0; flex: 1; }
  .xp-text { display: none; }
  .level-badge { width: 30px; height: 30px; font-size: .9rem; }
  .chip-value { font-size: 1.05rem; }
  .topbar-reset { display: none; }   /* Reset lives in Settings on mobile */

  /* ---- home tabs via bottom nav ---- */
  .tab-panel { display: none; }
  #home-screen[data-tab="games"]   #tab-games,
  #home-screen[data-tab="shop"]    #tab-shop,
  #home-screen[data-tab="badges"]  #tab-badges,
  #home-screen[data-tab="leaders"] #tab-leaders { display: block; }

  .bottom-nav {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
    position: fixed; left: 12px; right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 45; padding: 8px;
    background: var(--paper); border-radius: 24px;
    box-shadow: 0 8px 0 rgba(43,33,80,.18);
  }
  .bnav-btn {
    border: none; background: none; cursor: pointer;
    height: 52px; border-radius: 18px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    font-family: var(--font-body); font-weight: 700; font-size: .72rem; color: var(--ink-soft);
  }
  .bnav-ico { font-size: 1.2rem; }
  .bnav-btn.active { background: linear-gradient(160deg, var(--p-indigo), var(--p-pink)); color: #fff; }
  .bnav-btn:active { transform: translateY(2px); }
  body.playing .bottom-nav { display: none; }

  /* ---- collapsible hero ---- */
  .hero {
    flex-direction: column; align-items: stretch; gap: 12px;
    padding: 12px 14px; border-radius: var(--radius); margin-bottom: 14px;
  }
  .hero-toggle { width: 100%; gap: 12px; cursor: pointer; }
  .hero-toggle .ring { order: 0; width: 54px; height: 54px; font-size: .85rem; }
  .hero-headline { order: 1; }
  .hero-headline h1 { font-size: 1.15rem; margin: 0; }
  .hero-headline p { font-size: .8rem; }
  .hero-chevron {
    display: grid; place-items: center; order: 2;
    width: 32px; height: 32px; border-radius: 50%;
    background: #efe9ff; color: var(--p-indigo); font-size: .8rem;
    transition: transform .25s ease; flex: 0 0 auto;
  }
  .hero.expanded .hero-chevron { transform: rotate(180deg); }
  .hero-body { display: none; flex-direction: column; align-items: stretch; gap: 10px; }
  .hero.expanded .hero-body { display: flex; }
  .hero-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .hero-stats > div { min-width: 0; padding: 8px 4px; border-radius: 14px; }
  .hero-stats strong { font-size: 1.2rem; }

  /* ---- section head + filter chips ---- */
  .section-head { margin: 6px 2px 12px; }
  .section-head h2 { font-size: 1.35rem; }
  .filter-tabs {
    flex-wrap: nowrap; overflow-x: auto; gap: 8px;
    margin: 0 -12px; padding: 2px 12px 6px; scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .filter-tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 0 0 auto; height: 44px; display: flex; align-items: center; padding: 0 18px; }

  /* ---- game grid: 2 columns ---- */
  .game-grid { grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
  .game-card { min-height: 132px; padding: 14px 12px 12px; border-radius: 20px; box-shadow: 0 6px 0 rgba(43,33,80,.12); }
  .game-card:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(43,33,80,.12); }
  .gc-emoji { font-size: 2.1rem; }
  .gc-name { font-size: 1rem; }
  .gc-tag { font-size: .72rem; }

  .shop-grid { grid-template-columns: 1fr 1fr; }
  .badge-grid { grid-template-columns: 1fr 1fr; }

  /* ---- play screen: near-full-bleed stage ---- */
  .play-top {
    gap: 10px; padding: 8px 10px; border-radius: 18px; margin-bottom: 10px;
    flex-wrap: nowrap;
  }
  .back-btn {
    width: 44px; height: 44px; flex: 0 0 auto; padding: 0 0 3px;
    border-radius: 50%; font-size: 1.5rem; line-height: 1;
  }
  .play-title { min-width: 0; gap: 8px; }
  .play-emoji { font-size: 1.6rem; }
  .play-title h2 { font-size: 1.05rem; }
  .play-title p { font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .play-hud { width: auto; gap: 6px; flex-wrap: nowrap; }
  .stat-pill { min-width: 52px; padding: 4px 10px; }
  .stat-pill .sp-value { font-size: 1.05rem; }

  .stage {
    margin: 0 -4px; padding: 12px 10px calc(20px + env(safe-area-inset-bottom));
    border-radius: 24px; min-height: 62vh; border-width: 3px;
  }
  .center-col { gap: 14px; }

  /* ---- modals become bottom sheets ---- */
  .modal-backdrop { align-items: flex-end; }
  .modal {
    width: 100%; max-width: none; border-radius: 28px 28px 0 0;
    padding: 12px 20px calc(28px + env(safe-area-inset-bottom));
    border-bottom: none; animation: sheetUp .35s cubic-bezier(.2,.9,.3,1.2);
  }
  .sheet-grabber {
    display: block; width: 44px; height: 5px; border-radius: 999px;
    background: #d8cffb; margin: 0 auto 8px;
  }
  .modal-emoji { font-size: 3.2rem; }
  .modal h2 { font-size: 1.7rem; }
  .modal-actions { flex-direction: column; }
  .modal-actions .btn { width: 100%; padding: 15px 22px; }
  .setting-row { min-height: 44px; }

  /* toast clears the bottom nav */
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ===================================================================
   TABLET  721–1024px
   =================================================================== */
@media (min-width: 721px) and (max-width: 1024px) {
  .app-shell { padding: 16px 20px 40px; }
  .game-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
}

/* ===================================================================
   Game-specific styles
   =================================================================== */
.center-col { display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%; }
.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.shake-x { animation: shake .4s ease; }
.flash { animation: pop .3s ease; }

/* ---- Math / Translate big prompt ---- */
.math-question, .travel-word {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--ink);
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}
.math-question { font-size: clamp(2rem, 7vw, 3rem); padding: 16px 40px; }
.travel-word { font-size: clamp(2rem, 8vw, 3rem); padding: 16px 36px; letter-spacing: 1px; }

/* ---- Color Vials ---- */
.vial-board { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; padding: 10px 0; }
.vial {
  width: 56px; padding: 6px;
  display: flex; flex-direction: column; gap: 4px;
  background: rgba(255,255,255,.55);
  border: 3px solid #fff;
  border-radius: 8px 8px 22px 22px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .14s cubic-bezier(.2,.8,.3,1.4);
}
.vial.sel { transform: translateY(-14px); box-shadow: 0 0 0 4px var(--p-indigo), var(--shadow); }
.vial-seg { height: 38px; border-radius: 5px; background: transparent; transition: background .25s; }
.vial-seg:last-child { border-radius: 5px 5px 16px 16px; }

/* ---- Memory Match ---- */
.mem-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; width: min(360px, 100%); }
.mem-card { width: 100%; aspect-ratio: 1; height: auto; background: transparent; border: none; padding: 0; perspective: 600px; cursor: pointer; }
.mem-inner { position: relative; width: 100%; height: 100%; transition: transform .4s; transform-style: preserve-3d; }
.mem-card.flipped .mem-inner, .mem-card.matched .mem-inner { transform: rotateY(180deg); }
.mem-front, .mem-back {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: 16px; display: grid; place-items: center;
  font-size: clamp(1.7rem, 8vw, 2.2rem); box-shadow: var(--shadow);
}
.mem-front { background: linear-gradient(160deg, #7c5cff, #cc5de8); color: #fff; }
.mem-back { background: #fff; transform: rotateY(180deg); }
.mem-card.matched .mem-back { background: #d3f9d8; box-shadow: 0 0 18px rgba(81,207,102,.6); }

/* ---- Echo Pads (Simon) ---- */
.simon-board { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; width: 300px; max-width: 80vw; }
.simon-pad {
  aspect-ratio: 1; border: none; border-radius: 22px; cursor: pointer;
  opacity: .5; box-shadow: var(--shadow); transition: opacity .1s, transform .1s, box-shadow .1s;
}
.simon-pad:not(:disabled):hover { opacity: .75; }
.simon-pad.lit { opacity: 1; transform: scale(1.05); box-shadow: 0 0 34px rgba(255,255,255,.95), var(--shadow); }

/* ---- Word Scramble ---- */
.scramble-hint {
  font-size: 1.15rem; font-weight: 700; color: var(--ink);
  background: #fff; padding: 12px 18px; border-radius: 14px;
  box-shadow: var(--shadow); text-align: center; max-width: 460px;
}
.scramble-answer { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; min-height: 54px; }
.slot-cell {
  width: 44px; height: 54px; border-radius: 10px;
  border: 3px dashed #cbb9ff; background: #faf7ff;
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; color: var(--ink);
}
.slot-cell.filled { border-style: solid; border-color: var(--p-indigo); background: #fff; cursor: pointer; }
.slot-cell.correct-cell { background: var(--good); color: #fff; border-color: var(--good); }
.scramble-pool { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 440px; }
.letter-tile {
  width: 44px; height: 54px; border: none; border-radius: 10px;
  background: linear-gradient(160deg, #ffd43b, #ffa94d); color: #5a3a10;
  font-family: var(--font-display); font-size: 1.5rem; font-weight: 800;
  cursor: pointer; box-shadow: 0 5px 0 #e69138; transition: transform .1s;
}
.letter-tile:active { transform: translateY(3px); box-shadow: 0 2px 0 #e69138; }
.letter-tile.used { opacity: .25; box-shadow: none; }

/* ---- Number Merge / Slide shared board ---- */
.merge-board, .slide-board {
  display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 1fr;
  gap: 8px; background: #cdbce0; padding: 8px; border-radius: 16px; box-shadow: var(--shadow);
  width: min(320px, 92vw); aspect-ratio: 1;
}
.merge-cell {
  border-radius: 11px; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; background: #e7dcf2;
  font-size: clamp(1.1rem, 5.5vw, 1.6rem);
}
.merge-cell.empty { background: #ddd0ee; }
.pop-tile { animation: pop .18s ease; }

.arrow-pad { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.arrow-pad button {
  width: 54px; height: 46px; border: none; border-radius: 12px;
  background: var(--ink); color: #fff; font-size: 1.05rem; cursor: pointer;
  box-shadow: 0 4px 0 rgba(43,33,80,.4);
}
.arrow-pad button:active { transform: translateY(3px); box-shadow: none; }
.arrow-mid { display: flex; gap: 6px; }

.slide-tile {
  border: none; border-radius: 12px;
  font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; color: #fff;
  cursor: pointer; box-shadow: inset 0 -4px 0 rgba(0,0,0,.18); transition: transform .08s;
}
.slide-tile:active { transform: scale(.95); }
.slide-tile.blank { background: transparent; box-shadow: none; cursor: default; }

/* ---- Whack-a-Mole ---- */
.whack-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.hole {
  position: relative; width: 96px; height: 100px; max-width: 24vw;
  border: none; background: transparent; cursor: pointer; overflow: hidden; padding: 0;
}
.hole .mound {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; height: 44px;
  background: radial-gradient(ellipse at top, #c98a52, #8a5a30);
  border-radius: 50% 50% 30% 30% / 80% 80% 20% 20%;
  box-shadow: inset 0 -6px 0 rgba(0,0,0,.18); z-index: 2;
}
.hole .critter {
  position: absolute; left: 50%; bottom: 18px; transform: translate(-50%, 130%);
  font-size: 2.6rem; transition: transform .13s ease; z-index: 1;
}
.hole.up .critter { transform: translate(-50%, 0); }

/* ---- Lights Out ---- */
.lights-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.light {
  width: 58px; height: 58px; max-width: 15vw; border: none; border-radius: 12px;
  background: #3a3358; cursor: pointer;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.25); transition: all .15s;
}
.light.on { background: radial-gradient(circle at 30% 30%, #fff6b0, #ffd43b);
  box-shadow: 0 0 18px #ffd43b, inset 0 -4px 0 rgba(180,140,0,.3); }

/* ---- Snake ---- */
.snake-canvas { border-radius: 16px; box-shadow: var(--shadow); background: #dff5df; touch-action: none; width: min(374px, 100%); height: auto; }

/* ---- Reaction ---- */
.react-pad {
  width: 100%; max-width: 460px; height: 290px; border: none; border-radius: 24px;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; color: #fff; box-shadow: var(--shadow); transition: background .12s, transform .08s;
}
.react-pad:active { transform: scale(.99); }
.react-big { font-family: var(--font-display); font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 800; }
.react-sub { font-size: 1rem; opacity: .92; }
.react-pad.idle, .react-pad.done, .react-pad.between { background: linear-gradient(160deg, #4dabf7, #7c5cff); }
.react-pad.waiting { background: linear-gradient(160deg, #ff8787, #ff6b6b); }
.react-pad.ready { background: linear-gradient(160deg, #51cf66, #20c997); }
.react-pad.early { background: linear-gradient(160deg, #ffa94d, #ff6b6b); }

/* ---- Pattern Memory ---- */
.pat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pat-cell {
  width: 64px; height: 64px; max-width: 16vw; border: none; border-radius: 14px;
  background: #e3dcf5; cursor: pointer; box-shadow: inset 0 -4px 0 rgba(0,0,0,.1); transition: all .15s;
}
.pat-cell.lit { background: radial-gradient(circle at 30% 30%, #b9a4ff, #7c5cff); box-shadow: 0 0 22px #7c5cff; }
.pat-cell.good { background: radial-gradient(circle at 30% 30%, #8ce99a, #51cf66); box-shadow: 0 0 18px #51cf66; }
.pat-cell.bad { background: radial-gradient(circle at 30% 30%, #ff9a9a, #ff6b6b); box-shadow: 0 0 18px #ff6b6b; }

/* ---- Translate ---- */
.travel-choice { font-size: 1.15rem; }

/* ---- Odd One Out ---- */
.odd-grid { display: grid; gap: 8px; }
.odd-cell {
  font-size: 1.8rem; width: 50px; height: 50px; max-width: 13vw;
  background: #fff; border: none; border-radius: 12px; cursor: pointer;
  box-shadow: 0 4px 0 rgba(43,33,80,.1); transition: transform .08s;
  display: grid; place-items: center;
}
.odd-cell:active { transform: scale(.92); }
.odd-cell.found { background: #d3f9d8; }

/* ---- Number Hunt ---- */
.hunt-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.hunt-cell {
  width: 56px; height: 56px; max-width: 16vw; border: none; border-radius: 12px;
  background: #fff; font-family: var(--font-display); font-size: 1.25rem; font-weight: 800;
  color: var(--ink); cursor: pointer; box-shadow: 0 4px 0 rgba(43,33,80,.12);
}
.hunt-cell:active { transform: translateY(2px); }
.hunt-cell.found { background: var(--p-green); color: #fff; box-shadow: none; }

/* ---- Dot Count ---- */
.dot-box {
  position: relative; width: min(340px, 84vw); height: 210px;
  background: #fff; border-radius: 16px; box-shadow: var(--shadow);
}
.dot { position: absolute; border-radius: 50%; box-shadow: inset 0 -3px 0 rgba(0,0,0,.15); }

/* ---- Color Clash (Stroop) ---- */
.stroop-word {
  font-family: var(--font-display); font-size: clamp(2.4rem, 9vw, 3.4rem); font-weight: 800;
  background: #fff; padding: 18px 48px; border-radius: 20px;
  box-shadow: var(--shadow); letter-spacing: 3px;
}
.stroop-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.stroop-btn { font-size: 1.25rem; min-width: 130px; }

/* ---- Higher or Lower ---- */
.hl-card {
  width: 150px; height: 190px;
  background: linear-gradient(160deg, #fff, #f2ecff);
  border-radius: 20px; border: 4px solid #fff;
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 3.4rem; font-weight: 800; color: var(--ink);
  box-shadow: var(--shadow);
}
.hl-card.flip { animation: pop .3s ease; }

/* ---- Missing Letter ---- */
.ml-hint { font-size: 3.2rem; filter: drop-shadow(0 3px 0 rgba(0,0,0,.12)); }
.ml-word { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.ml-cell {
  width: 40px; height: 50px; background: #fff; border-radius: 10px;
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; color: var(--ink);
  box-shadow: 0 4px 0 rgba(43,33,80,.1);
}
.ml-cell.gap { background: #fff6d6; border: 3px dashed var(--p-orange); color: var(--p-orange); }

/* ---- Emoji Riddle ---- */
.riddle-emojis {
  font-size: clamp(2.4rem, 9vw, 3.2rem);
  background: #fff; padding: 14px 34px; border-radius: 20px; box-shadow: var(--shadow);
}

/* ---- Number Recall ---- */
.digit-display {
  min-width: 230px; min-height: 66px; text-align: center;
  font-family: var(--font-display); font-size: 2.4rem; font-weight: 800; letter-spacing: 7px;
  background: #fff; padding: 12px 22px; border-radius: 16px; box-shadow: var(--shadow);
  color: var(--ink);
}
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key {
  width: 66px; height: 50px; max-width: 20vw; border: none; border-radius: 12px;
  background: #fff; font-family: var(--font-display); font-size: 1.25rem; font-weight: 800;
  color: var(--ink); cursor: pointer; box-shadow: 0 4px 0 rgba(43,33,80,.12);
}
.key:active { transform: translateY(3px); box-shadow: none; }

/* ---- Maze / Catch canvases ---- */
.maze-canvas, .catch-canvas {
  border-radius: 16px; box-shadow: var(--shadow);
  background: #fff; touch-action: none; width: min(374px, 100%); height: auto;
}

/* ---- Theme Shop ---- */
.shop-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px; margin-bottom: 30px;
}
.shop-card {
  background: #fff; border-radius: 18px; padding: 14px; text-align: center;
  box-shadow: var(--shadow); transition: transform .15s ease;
}
.shop-card:hover { transform: translateY(-3px); }
.shop-card.equipped { outline: 4px solid var(--p-green); }
.swatch {
  height: 46px; border-radius: 12px; margin-bottom: 8px;
  border: 3px solid #fff; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.shop-name { font-weight: 800; font-family: var(--font-display); margin-bottom: 4px; }
.shop-buy { width: 100%; padding: 9px 10px; font-size: .9rem; }
.shop-buy:disabled { opacity: .55; cursor: not-allowed; }

/* ---- Rebirth ---- */
.rebirth-btn {
  margin-top: 12px; border: none; border-radius: 14px; padding: 11px 20px;
  font-family: var(--font-display); font-weight: 800; font-size: .95rem;
  background: linear-gradient(160deg, #cc5de8, #7c5cff); color: #fff;
  cursor: pointer; box-shadow: 0 5px 0 #5a3fd1;
  animation: rebirthGlow 2s ease infinite;
}
.rebirth-btn:active { transform: translateY(4px); box-shadow: none; }
@keyframes rebirthGlow {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(204,93,232,0)); }
  50% { filter: drop-shadow(0 0 12px rgba(204,93,232,.8)); }
}

/* ---- Themes (background skins) ---- */
body[data-theme="ocean"]  { background-image: linear-gradient(160deg, #6ee7ff 0%, #4dabf7 55%, #b3f5e6 100%); }
body[data-theme="sunset"] { background-image: linear-gradient(160deg, #ffd43b 0%, #ff9a6b 55%, #ff6baa 100%); }
body[data-theme="forest"] { background-image: linear-gradient(160deg, #b2f2bb 0%, #69db7c 55%, #e9fac8 100%); }
body[data-theme="candy"]  { background-image: linear-gradient(160deg, #ffc9de 0%, #eebefa 55%, #c5f6fa 100%); }
body[data-theme="space"]  { background-image: linear-gradient(160deg, #4c4a78 0%, #7c5cff 55%, #2b2150 100%); }


/* ===================================================================
   ACCOUNTS, LEADERBOARD & ADS  (added for cloud saving)
   =================================================================== */

/* ---- account button sync state dot ---- */
#account-btn { position: relative; }
#account-btn::after {
  content: ''; position: absolute; right: 5px; bottom: 5px;
  width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid var(--paper); background: transparent; transition: background .2s;
}
#account-btn.sync-saved::after   { background: var(--good); }
#account-btn.sync-offline::after { background: var(--p-orange); }

/* ---- auth gate overlay ---- */
.auth-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: none; place-items: center; padding: 20px;
  background: linear-gradient(160deg, var(--sky-1), var(--sky-2) 55%, var(--sky-3));
  overflow-y: auto;
}
.auth-overlay.show { display: grid; }
.auth-card {
  background: linear-gradient(160deg, #fff, var(--paper-2));
  border-radius: var(--radius-lg);
  border: 5px solid #fff;
  box-shadow: var(--shadow-soft);
  padding: 28px 26px 24px;
  width: min(420px, 94vw);
  text-align: center;
  animation: popIn .45s cubic-bezier(.2,.9,.3,1.5);
}
.auth-logo .logo-mark { font-size: 3rem; }
.auth-title { font-family: var(--font-display); font-size: 1.7rem; margin: 6px 0 4px; }
.auth-sub { color: var(--ink-soft); font-weight: 500; margin: 0 0 18px; font-size: .95rem; }

.auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: #efe9ff; border-radius: 16px; padding: 5px; margin-bottom: 18px;
}
.auth-tab {
  border: none; background: transparent; cursor: pointer;
  padding: 10px; border-radius: 12px;
  font-family: var(--font-display); font-weight: 700; color: var(--ink-soft);
}
.auth-tab.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

.auth-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field > span { font-weight: 700; font-size: .9rem; }
.auth-field > span em { color: var(--ink-soft); font-style: normal; font-weight: 500; }
.auth-field input {
  font-family: var(--font-body); font-size: 1rem;
  padding: 13px 15px; border-radius: 14px;
  border: 2px solid #e7e0ff; background: #fff; color: var(--ink);
  outline: none; transition: border-color .15s;
}
.auth-field input:focus { border-color: var(--p-indigo); }
.auth-hint { color: var(--ink-soft); font-size: .78rem; font-weight: 500; }
.auth-error {
  display: none; background: #ffe3e6; color: #cc4654;
  border-radius: 12px; padding: 10px 14px; font-weight: 600; font-size: .9rem;
}
.auth-error.show { display: block; }
.auth-submit { width: 100%; margin-top: 4px; }

.auth-divider {
  display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: var(--ink-soft);
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 2px; background: #e7e0ff; border-radius: 2px;
}
.auth-guest { width: 100%; }
.auth-guest-note { color: var(--ink-soft); font-size: .78rem; margin: 10px 0 0; font-weight: 500; }

/* ---- account sheet ---- */
.account-modal .modal-actions-col { margin-top: 10px; }

/* ---- leaderboard ---- */
.lb-caption { color: var(--ink-soft); font-weight: 500; margin: 0 0 14px; }
.leaders-list { display: flex; flex-direction: column; gap: 8px; }
.lb-me-box { margin-bottom: 14px; }
.lb-row {
  display: grid; grid-template-columns: 42px 1fr auto auto auto; align-items: center; gap: 10px;
  background: var(--paper); border-radius: 16px; padding: 12px 16px;
  box-shadow: var(--shadow); font-weight: 600;
}
.lb-rank { font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; text-align: center; }
.lb-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-lvl { color: var(--ink-soft); font-size: .85rem; }
.lb-coins { color: var(--p-orange); font-family: var(--font-display); font-weight: 800; white-space: nowrap; }
/* 🌀 rebirth count beside a name — prestige is a flex on this board, not a penalty */
.lb-rebirth { font-size: .8rem; font-weight: 800; color: var(--p-violet, #7c5cff); white-space: nowrap; }
.lb-row.lb-me { outline: 3px solid var(--p-indigo); background: #f3efff; }
.lb-loading { color: var(--ink-soft); font-weight: 600; text-align: center; padding: 30px 10px; }

/* ---- ad slot ---- */
.ad-slot {
  max-width: 970px; margin: 22px auto 0; min-height: 60px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); overflow: hidden;
}
.ad-slot .adsbygoogle { width: 100%; }
body.playing .ad-slot { display: none; }   /* no ads mid-game */

@media (max-width: 720px) {
  .ad-slot { margin: 16px 0 0; }
}

/* ---- share-my-rank button ---- */
.lb-share-btn { width: 100%; margin: 0 0 14px; }

/* ===================================================================
   PAUSE + MINI RECORDS
   =================================================================== */
.pause-btn { flex: 0 0 auto; }

.pause-modal { max-width: min(480px, 92vw); max-height: 88vh; overflow-y: auto; }

.mini-records { margin-top: 22px; text-align: left; }
.mr-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.mr-head h3 { font-family: var(--font-display); margin: 0; font-size: 1.15rem; }
.mr-sub { color: var(--ink-soft); font-weight: 600; font-size: .82rem; }

.mr-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; padding-right: 2px; }
.mr-me-box { margin-bottom: 10px; }
.mr-row {
  display: grid; grid-template-columns: 34px 1fr auto auto; align-items: center; gap: 8px;
  background: var(--paper); border-radius: 12px; padding: 9px 12px;
  box-shadow: var(--shadow); font-weight: 600; font-size: .86rem;
}
.mr-rank { font-family: var(--font-display); font-weight: 800; text-align: center; }
.mr-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mr-stats { color: var(--p-orange); font-weight: 700; font-size: .78rem; white-space: nowrap; }
.mr-row.mr-me { outline: 3px solid var(--p-indigo); background: #f3efff; }
.mr-loading { color: var(--ink-soft); font-weight: 600; text-align: center; padding: 20px 10px; font-size: .88rem; }
.mr-loading small { font-weight: 500; }

@media (max-width: 720px) {
  .pause-btn { width: 40px; height: 40px; font-size: 1.05rem; }
  .mini-records { margin-top: 16px; }
  .mr-list { max-height: 220px; }
}

/* ===================================================================
   REALTIME: notification bell, challenge invites, battles, beats
   =================================================================== */

/* ---- beats chip ---- */
.beats-chip .chip-value { color: #6b6298; }
.beats-chip .chip-icon { filter: grayscale(1) brightness(0.9); }

/* ---- challenge button on leaderboard / mini records rows ---- */
.btn-challenge {
  border: none; background: #efe9ff; color: var(--p-indigo);
  width: 34px; height: 34px; border-radius: 12px; font-size: 1rem;
  cursor: pointer; box-shadow: var(--shadow); transition: transform .12s ease;
  display: grid; place-items: center;
}
.btn-challenge:active { transform: translateY(2px); }
.mr-row .btn-challenge { width: 28px; height: 28px; font-size: .85rem; border-radius: 9px; }

/* ---- notification bell ---- */
.bell-dot {
  position: absolute; top: 7px; right: 7px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--bad); border: 2px solid var(--paper);
}
#bell-btn { position: relative; }
.bell-panel {
  position: fixed; top: 70px; right: 16px; z-index: 130;
  width: min(340px, 92vw); max-height: 60vh; overflow-y: auto;
  background: var(--paper); border-radius: var(--radius);
  box-shadow: var(--shadow-soft); border: 4px solid #fff;
  animation: popIn .25s cubic-bezier(.2,.9,.3,1.5);
}
.bell-head {
  font-family: var(--font-display); font-weight: 800; font-size: 1.05rem;
  padding: 14px 16px 8px;
}
.bell-list { display: flex; flex-direction: column; gap: 2px; padding: 0 8px 10px; }
.bell-item {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 10px 8px; border-radius: 12px; font-weight: 600; font-size: .88rem;
}
.bell-item:hover { background: var(--paper-2); }
.bell-item-time { color: var(--ink-soft); font-size: .72rem; white-space: nowrap; flex: 0 0 auto; }
.bell-empty { color: var(--ink-soft); font-weight: 600; text-align: center; padding: 20px 10px; font-size: .88rem; }

/* ---- challenge invite toast stack ---- */
.challenge-toast-stack {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 140; display: flex; flex-direction: column; gap: 10px;
  width: min(420px, 94vw);
}
.challenge-toast {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(160deg, #fff, var(--paper-2));
  border: 4px solid #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-soft); padding: 12px 14px;
  animation: popIn .3s cubic-bezier(.2,.9,.3,1.5);
}
.ct-icon { font-size: 1.8rem; flex: 0 0 auto; }
.ct-body { flex: 1; min-width: 0; }
.ct-title { font-family: var(--font-display); font-weight: 800; font-size: .95rem; }
.ct-sub { color: var(--ink-soft); font-weight: 600; font-size: .78rem; margin-top: 2px; }
.ct-actions { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.ct-actions .btn { padding: 8px 14px; font-size: .82rem; }

/* ---- battle countdown ---- */
.battle-countdown {
  position: fixed; inset: 0; z-index: 150;
  display: grid; place-items: center;
  background: rgba(40,30,70,.55); backdrop-filter: blur(3px);
  font-family: var(--font-display); font-weight: 800;
  font-size: 8rem; color: #fff;
  text-shadow: 0 10px 0 rgba(0,0,0,.2);
  animation: popIn .2s cubic-bezier(.2,.9,.3,1.5);
}

/* ---- battle status bar (shown while a battle is live) ---- */
.battle-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  background: linear-gradient(90deg, var(--p-indigo), var(--p-purple));
  color: #fff; font-family: var(--font-display); font-weight: 800;
  text-align: center; padding: 10px 16px;
  box-shadow: 0 4px 14px rgba(43,33,80,.25);
}

/* ---- battle result modal extras ---- */
.reward-pill.beats { color: #4a4470; }
.reward-pill.lost { color: var(--bad); }

/* ---- challenge game picker ---- */
.cp-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px; max-height: 320px; overflow-y: auto; margin: 6px 0 4px;
}
.cp-choice {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--paper); border: none; border-radius: 14px;
  padding: 12px 8px; cursor: pointer; font-weight: 700; font-size: .78rem;
  box-shadow: var(--shadow); transition: transform .12s ease;
}
.cp-choice:active { transform: translateY(2px); }
.cp-emoji { font-size: 1.6rem; }

@media (max-width: 720px) {
  .bell-panel { top: 64px; right: 8px; width: calc(100vw - 16px); }
  .battle-countdown { font-size: 5.5rem; }
  .challenge-toast-stack { top: 8px; width: calc(100vw - 16px); }
}

/* ===================================================================
   ADMIN PANEL
   =================================================================== */
.admin-modal { max-width: min(460px, 94vw); max-height: 88vh; overflow-y: auto; text-align: left; }
.admin-modal h2 { text-align: center; }
.admin-note { text-align: center; color: var(--ink-soft); font-weight: 500; font-size: .85rem; margin: 0 0 8px; }
.admin-section { margin: 16px 0; }
.admin-section h3 { font-family: var(--font-display); font-size: 1rem; margin: 0 0 8px; }
.admin-btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-btn-row .btn { padding: 9px 14px; font-size: .85rem; flex: 1 1 auto; min-width: 68px; }
.admin-custom { display: flex; gap: 8px; margin-top: 8px; }
.admin-custom input {
  flex: 1; min-width: 0; font-family: var(--font-body); font-size: .95rem;
  padding: 10px 12px; border-radius: 12px; border: 2px solid #e7e0ff; background: #fff; color: var(--ink); outline: none;
}
.admin-custom input:focus { border-color: var(--p-indigo); }
.admin-maxout { width: 100%; }

/* ===================================================================
   Content sections: the how-to-play guides, the Q&A, the site footer,
   the per-game guide on the play screen, and the cookie consent bar.

   These carry the site's written content — the guides describe all 23
   games and the Q&A answers real questions — so they're styled as
   readable prose rather than game chrome.
   =================================================================== */

/* --- how-to-play guides --- */
.guides-section, .about-section { margin: 34px 0 8px; }
.guides-intro {
  margin: 0 4px 18px;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.65;
  max-width: 70ch;
}
.guides-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}
.guide-card {
  background: rgba(255, 255, 255, .92);
  border: 3px solid #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 16px 18px;
}
.guide-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0 0 2px;
  display: flex; align-items: center; gap: 8px;
}
.guide-emoji { font-size: 1.4rem; }
.guide-meta {
  margin: 0 0 10px;
  font-size: .84rem;
  color: var(--ink-soft);
  font-weight: 600;
}
.guide-cat {
  display: inline-block;
  background: #f0ecff;
  color: var(--p-indigo);
  border-radius: 999px;
  padding: 2px 9px;
  font-weight: 700;
}
.guide-card p {
  margin: 8px 0;
  font-size: .93rem;
  line-height: 1.6;
}
.guide-card strong { font-weight: 700; }

/* --- Q&A --- */
.about-section h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin: 20px 4px 4px;
}
.about-section p {
  margin: 0 4px 12px;
  font-size: .97rem;
  line-height: 1.68;
  max-width: 70ch;
}
.about-section a { color: var(--p-indigo); font-weight: 700; }

/* --- per-game guide on the play screen --- */
.play-guide { margin: 14px auto 0; max-width: 640px; width: 100%; }
.play-guide.hidden { display: none; }
.play-guide-details {
  background: rgba(255, 255, 255, .9);
  border: 3px solid #fff;
  border-radius: 18px;
  padding: 10px 16px;
  box-shadow: var(--shadow-soft);
}
.play-guide-details summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 1rem;
  padding: 4px 0;
}
.play-guide-details p {
  font-size: .92rem;
  line-height: 1.6;
  margin: 8px 0;
}
.play-guide-details .pg-skill { color: var(--ink-soft); }

/* --- site footer --- */
.site-footer {
  margin: 40px auto 0;
  padding: 26px 20px 30px;
  text-align: center;
  color: #3c3466;
  max-width: 900px;
}
.footer-nav {
  display: flex; flex-wrap: wrap; gap: 8px 20px;
  justify-content: center; margin-bottom: 12px;
}
.footer-nav a {
  color: #3c3466; font-weight: 700; font-size: .95rem;
  text-decoration: none;
  border-bottom: 2px solid rgba(60, 52, 102, .3);
}
.footer-nav a:hover { border-bottom-color: #3c3466; }
.footer-note { margin: 6px 0; font-size: .92rem; }
.footer-copy { margin: 4px 0 0; font-size: .84rem; opacity: .75; }
/* The footer belongs to the home screen; hide it while a game is on screen. */
body.playing .site-footer { display: none; }

/* --- cookie consent bar --- */
.consent-banner {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 300;
  background: rgba(255, 255, 255, .97);
  border-top: 3px solid #fff;
  box-shadow: 0 -8px 30px rgba(43, 33, 80, .22);
  padding: 14px 16px;
  transform: translateY(110%);
  transition: transform .35s cubic-bezier(.2, .9, .3, 1.1);
  /* keep clear of the mobile bottom nav */
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
}
.consent-banner.show { transform: translateY(0); }
.consent-inner {
  max-width: 900px; margin: 0 auto;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.consent-text {
  margin: 0; flex: 1 1 320px;
  font-size: .9rem; line-height: 1.55;
  color: var(--ink);
}
.consent-text a { color: var(--p-indigo); font-weight: 700; }
.consent-actions { display: flex; gap: 10px; flex: 0 0 auto; }
.consent-btn {
  font-family: var(--font-display);
  font-size: .95rem; font-weight: 700;
  border-radius: 999px; padding: 10px 20px;
  border: 3px solid #fff; cursor: pointer;
}
.consent-accept {
  background: linear-gradient(160deg, var(--p-indigo), var(--p-violet));
  color: #fff; box-shadow: var(--shadow);
}
.consent-decline { background: #f0ecff; color: var(--ink); }
.consent-btn:active { transform: translateY(2px); }

@media (max-width: 560px) {
  .consent-inner { justify-content: center; text-align: center; }
  .consent-actions { width: 100%; justify-content: center; }
  .guides-grid { grid-template-columns: 1fr; }
}

/* ===================================================================
   Guest sign-up UI.

   Guests previously only got a 2.4-second toast, which was effectively
   invisible — so people played without ever learning that accounts, the
   leaderboard and 1v1 battles existed. Three visible surfaces now:
   this banner, the 👤 account sheet, and the invite dialog below.
   =================================================================== */

/* --- persistent banner on the Games tab --- */
.guest-banner {
  position: relative;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(160deg, #fff, #f4f0ff);
  border: 3px solid #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 16px 44px 16px 18px;
  margin: 4px 4px 18px;
  animation: popIn .4s cubic-bezier(.2, .9, .3, 1.4);
}
.gb-icon { font-size: 2rem; flex: 0 0 auto; }
.gb-text { flex: 1 1 260px; display: flex; flex-direction: column; gap: 2px; }
.gb-text strong {
  font-family: var(--font-display);
  font-size: 1.08rem;
}
.gb-text span { font-size: .93rem; color: var(--ink-soft); line-height: 1.5; }
.gb-actions { display: flex; gap: 10px; flex: 0 0 auto; flex-wrap: wrap; }
.gb-btn { padding: 11px 18px; font-size: .95rem; }
.gb-close {
  position: absolute; top: 8px; right: 10px;
  background: none; border: none; cursor: pointer;
  font-size: 1rem; color: var(--ink-soft);
  line-height: 1; padding: 6px; border-radius: 999px;
}
.gb-close:hover { background: #efeaff; color: var(--ink); }

/* --- the "save your progress?" dialog --- */
.invite-modal { max-width: 460px; }
.invite-modal h2 { margin-bottom: 6px; }
.invite-modal > p {
  color: var(--ink-soft);
  font-size: .96rem;
  line-height: 1.6;
  margin: 0 0 16px;
}

/* what they'd lose, pulled from the live save */
.invite-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; margin: 0 0 16px;
}
.invite-stat {
  background: #f4f0ff;
  border-radius: 14px;
  padding: 10px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.invite-stat strong {
  font-family: var(--font-display);
  font-size: 1.3rem; color: var(--p-indigo);
  line-height: 1;
}
.invite-stat span { font-size: .72rem; color: var(--ink-soft); text-align: center; }

.invite-perks {
  list-style: none; margin: 0 0 18px; padding: 0;
  text-align: left;
}
.invite-perks li {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: .93rem; line-height: 1.5;
  padding: 5px 0;
}
.invite-perks li span { flex: 0 0 auto; font-size: 1.05rem; }

.invite-later { font-size: .92rem; }
.invite-never {
  display: block; margin: 12px auto 0;
  background: none; border: none; cursor: pointer;
  color: var(--ink-soft); font-family: var(--font-body);
  font-size: .84rem; text-decoration: underline;
  padding: 4px 8px;
}
.invite-never:hover { color: var(--ink); }

@media (max-width: 560px) {
  .guest-banner { padding: 15px 40px 15px 16px; }
  .gb-actions { width: 100%; }
  .gb-btn { flex: 1 1 0; }
  .invite-stats { grid-template-columns: repeat(2, 1fr); }
}
