/* ============================================================
   Ultra Games — Stylesheet
   Themes are driven by CSS custom properties on :root.
   Switching theme = setting different values for these vars.
   ============================================================ */

:root {
  /* Theme variables — default = Pirate.
     Panels and accents use the Captain's Bounty dark wood + amber palette,
     but the page background is the original desert-island photo. */
  --bg-gradient: linear-gradient(to bottom, #f4c873, #c47a3a);
  --bg-decoration: url("assets/pirate-bg.png");
  --bg-decoration-size: cover;
  --bg-decoration-repeat: no-repeat;
  --panel-bg: rgba(22, 12, 7, 0.78);
  --panel-bg-2: rgba(33, 17, 8, 0.85);
  --panel-border: #78350f;
  --panel-shadow: rgba(0, 0, 0, 0.45);
  --panel-radius: 24px;
  --text-color: #fef3c7;
  --text-muted: rgba(252, 211, 77, 0.7);
  --accent-color: #fbbf24;
  --accent-color-2: #b45309;
  --button-bg: linear-gradient(180deg, #fcd34d 0%, #b45309 100%);
  --button-bg-hover: linear-gradient(180deg, #f59e0b 0%, #92400e 100%);
  --button-text: #24120a;
  --font-heading: 'Georgia', 'Palatino', 'Playfair Display', serif;
  --font-body: 'Georgia', 'Palatino', serif;
  --tile-rotate-odd: 0deg;
  --tile-rotate-even: 0deg;
}

/* ===== THEME: Space Station ===== */
body.theme-space {
  --bg-gradient: radial-gradient(ellipse at top, #1a1a4e 0%, #0a0a1e 60%, #000000 100%);
  --bg-decoration: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 800'><g fill='white'><circle cx='100' cy='100' r='1.5'/><circle cx='250' cy='200' r='1'/><circle cx='400' cy='80' r='2'/><circle cx='600' cy='150' r='1.5'/><circle cx='800' cy='90' r='1'/><circle cx='950' cy='220' r='2'/><circle cx='1100' cy='100' r='1.5'/><circle cx='150' cy='400' r='1'/><circle cx='300' cy='500' r='1.5'/><circle cx='550' cy='450' r='1'/><circle cx='700' cy='600' r='2'/><circle cx='900' cy='500' r='1'/><circle cx='1050' cy='650' r='1.5'/><circle cx='200' cy='700' r='1'/><circle cx='450' cy='720' r='1.5'/><circle cx='800' cy='750' r='1'/></g><circle cx='900' cy='200' r='60' fill='%23a78bfa' opacity='0.4'/><circle cx='200' cy='600' r='40' fill='%2306b6d4' opacity='0.4'/></svg>");
  --bg-decoration-size: cover;
  --bg-decoration-repeat: no-repeat;
  --panel-bg: rgba(20, 25, 60, 0.85);
  --panel-bg-2: rgba(40, 45, 90, 0.85);
  --panel-border: #06b6d4;
  --panel-shadow: rgba(6, 182, 212, 0.5);
  --panel-radius: 8px;
  --text-color: #e0e7ff;
  --text-muted: #a78bfa;
  --accent-color: #06b6d4;
  --accent-color-2: #a78bfa;
  --button-bg: #06b6d4;
  --button-bg-hover: #0891b2;
  --button-text: #0a0a1e;
  --font-heading: 'Trebuchet MS', 'Helvetica', sans-serif;
  --font-body: 'Trebuchet MS', 'Helvetica', sans-serif;
  --tile-rotate-odd: 0deg;
  --tile-rotate-even: 0deg;
}

/* ===== THEME: Jungle ===== */
body.theme-jungle {
  --bg-gradient: linear-gradient(to bottom, #4a7c3a 0%, #2d5016 60%, #1a3a0a 100%);
  --bg-decoration: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 800'><g><ellipse cx='150' cy='150' rx='100' ry='50' fill='%2316a34a' transform='rotate(-20 150 150)' opacity='0.6'/><ellipse cx='1050' cy='180' rx='110' ry='55' fill='%2315803d' transform='rotate(25 1050 180)' opacity='0.6'/><ellipse cx='200' cy='650' rx='130' ry='60' fill='%2316a34a' transform='rotate(15 200 650)' opacity='0.5'/><ellipse cx='1000' cy='680' rx='120' ry='55' fill='%2315803d' transform='rotate(-15 1000 680)' opacity='0.5'/><ellipse cx='600' cy='100' rx='90' ry='40' fill='%2322c55e' transform='rotate(-10 600 100)' opacity='0.4'/></g><circle cx='600' cy='400' r='40' fill='%23fbbf24' opacity='0.3'/></svg>");
  --bg-decoration-size: cover;
  --bg-decoration-repeat: no-repeat;
  --panel-bg: #d4a574;
  --panel-bg-2: #b8895a;
  --panel-border: #5a3a1a;
  --panel-shadow: rgba(26, 58, 10, 0.6);
  --panel-radius: 14px;
  --text-color: #2d1810;
  --text-muted: #5a3a1a;
  --accent-color: #ea580c;
  --accent-color-2: #fbbf24;
  --button-bg: #ea580c;
  --button-bg-hover: #c2410c;
  --button-text: #fff7ed;
  --font-heading: 'Verdana', 'Geneva', sans-serif;
  --font-body: 'Verdana', 'Geneva', sans-serif;
  --tile-rotate-odd: -0.5deg;
  --tile-rotate-even: 0.5deg;
}

/* ===== Layout / base ===== */

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text-color);
  overflow-x: hidden;
}

#background-layer {
  position: fixed;
  inset: 0;
  background-color: #071923;
  background-image: var(--bg-decoration), var(--bg-gradient);
  background-size: var(--bg-decoration-size, cover), cover;
  background-repeat: var(--bg-decoration-repeat, no-repeat), no-repeat;
  background-position: top left, center;
  z-index: -1;
}

.screen { min-height: 100vh; }
.hidden { display: none !important; }

/* ===== Card panel (dark wood with amber border) ===== */
.scroll-panel {
  background: var(--panel-bg);
  background-image: linear-gradient(135deg, var(--panel-bg) 0%, var(--panel-bg-2) 100%);
  border: 2px solid var(--panel-border);
  border-radius: var(--panel-radius);
  box-shadow:
    0 20px 50px var(--panel-shadow),
    inset 0 1px 0 rgba(252, 211, 77, 0.08);
  padding: 24px;
  position: relative;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ===== Auth screen ===== */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
}

.game-title {
  font-family: var(--font-heading);
  font-size: 2.8rem;
  text-align: center;
  margin: 0;
  color: var(--accent-color);
  text-shadow: 2px 2px 0 var(--accent-color-2);
}

.tagline {
  text-align: center;
  font-style: italic;
  color: var(--text-muted);
  margin: 4px 0 20px;
}

.tab-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--panel-border);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px;
  font-size: 1rem;
  font-family: var(--font-heading);
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}

.tab-btn.active {
  color: var(--accent-color);
  border-bottom-color: var(--accent-color);
  font-weight: bold;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-form input {
  padding: 12px 14px;
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(18, 9, 7, 0.7);
  color: var(--text-color);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--accent-color);
  background: rgba(18, 9, 7, 0.85);
  box-shadow: 0 0 0 3px rgba(252, 211, 77, 0.18);
}

/* ===== Password field with show/hide eye toggle ===== */
.password-field {
  position: relative;
  display: block;
}

.password-field input {
  width: 100%;
  padding-right: 42px;
}

.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.password-toggle:hover {
  color: var(--accent-color);
  background: rgba(0, 0, 0, 0.05);
}

.password-toggle:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 1px;
}

.password-toggle svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* Default: open eye visible, closed eye hidden */
.password-toggle .eye-closed { display: none; }
.password-toggle.revealed .eye-open { display: none; }
.password-toggle.revealed .eye-closed { display: block; }

.primary-btn {
  background: var(--button-bg);
  color: var(--button-text);
  border: 2px solid rgba(252, 211, 77, 0.8);
  padding: 12px 24px;
  font-size: 1.05rem;
  font-family: var(--font-heading);
  font-weight: 900;
  cursor: pointer;
  border-radius: 16px;
  margin-top: 8px;
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
  letter-spacing: 0.5px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  position: relative;
  overflow: hidden;
}

.primary-btn::before {
  content: "";
  position: absolute;
  inset: 0 0 55% 0;
  background: rgba(255, 255, 255, 0.18);
  pointer-events: none;
}

.primary-btn:hover { background: var(--button-bg-hover); transform: translateY(-2px); }
.primary-btn:active { transform: scale(0.98); }
.primary-btn:disabled { filter: grayscale(0.5); opacity: 0.6; cursor: default; transform: none; }

.ghost-btn {
  background: rgba(58, 33, 21, 0.55);
  color: var(--text-color);
  border: 2px solid var(--panel-border);
  padding: 8px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: bold;
  transition: background 0.15s, transform 0.1s;
}

.ghost-btn:hover { background: rgba(120, 53, 15, 0.45); transform: translateY(-1px); }

.error-msg {
  color: #b00020;
  font-size: 0.9rem;
  margin: 4px 0 0;
  min-height: 1.2em;
}

.avatar-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.avatar-option {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.4);
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s;
  overflow: hidden;
  padding: 4px;
}

.avatar-option:hover { background: rgba(255,255,255,0.7); }
.avatar-option.selected {
  border-color: var(--accent-color);
  background: rgba(255,255,255,0.9);
  transform: scale(1.08);
}

/* ===== Avatar images (used everywhere an avatar is rendered) ===== */
.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

/* ===== Top bar (glass dark wood with amber border) ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: rgba(22, 12, 7, 0.78);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  margin: 14px 18px 0;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--accent-color);
}

.brand-icon { font-size: 1.6rem; }

.topnav { display: flex; gap: 8px; }

.nav-btn {
  background: rgba(58, 33, 21, 0.5);
  border: 1.5px solid var(--panel-border);
  color: var(--text-color);
  padding: 8px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: bold;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.nav-btn:hover, .nav-btn.active {
  background: var(--accent-color);
  color: var(--button-text);
  border-color: var(--accent-color);
  transform: translateY(-1px);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(29, 16, 10, 0.8);
  padding: 6px 14px;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
}

.avatar-display {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(252, 211, 77, 0.18);
  border: 2px solid rgba(252, 211, 77, 0.6);
  border-radius: 50%;
  overflow: hidden;
  padding: 2px;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.avatar-display:hover {
  transform: scale(1.05);
  box-shadow: 0 0 0 3px rgba(252, 211, 77, 0.35);
}
.user-name { font-weight: bold; color: var(--text-color); }
.coin-display {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-color);
  font-weight: bold;
  background: rgba(252, 211, 77, 0.12);
  border: 1px solid rgba(252, 211, 77, 0.35);
  padding: 4px 12px;
  border-radius: 12px;
}

/* ===== Main layout ===== */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .main-layout { grid-template-columns: 1fr; }
}

.page-content { min-height: 60vh; }

/* ===== Home: game tiles (pirate scroll feel) ===== */
.page-title {
  font-family: var(--font-heading);
  color: var(--accent-color);
  text-shadow: 2px 2px 0 var(--accent-color-2);
  margin: 0 0 16px;
  font-size: 2rem;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
  padding: 8px;
}

.game-tile {
  background: var(--panel-bg);
  background-image: linear-gradient(135deg, var(--panel-bg) 0%, var(--panel-bg-2) 100%);
  border: 2px solid var(--panel-border);
  border-radius: var(--panel-radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 12px 30px var(--panel-shadow), inset 0 1px 0 rgba(252, 211, 77, 0.08);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  font-family: var(--font-heading);
  color: var(--text-color);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.game-tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px var(--panel-shadow), 0 0 0 2px var(--accent-color), inset 0 1px 0 rgba(252, 211, 77, 0.15);
  border-color: var(--accent-color);
}

.game-tile-icon {
  font-size: 2.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  background: rgba(252, 211, 77, 0.15);
  border: 1px solid rgba(252, 211, 77, 0.35);
  border-radius: 18px;
}

.game-tile-name {
  font-size: 1.35rem;
  font-weight: 900;
  margin: 0 0 6px;
  color: var(--accent-color);
  letter-spacing: 0.3px;
}

.game-tile-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin: 0;
}

/* ===== Leaderboards ===== */
.global-leaderboard h2,
.game-leaderboard h2 {
  font-family: var(--font-heading);
  margin: 0 0 12px;
  color: var(--accent-color);
  font-size: 1.3rem;
  text-align: center;
}

.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.leaderboard-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px dashed var(--panel-border);
}

.leaderboard-list li:last-child { border-bottom: none; }

.leaderboard-list .rank {
  font-weight: bold;
  color: var(--accent-color);
  width: 28px;
}

.leaderboard-list .lb-avatar {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.4);
  border-radius: 50%;
  overflow: hidden;
  padding: 2px;
  flex-shrink: 0;
}
.leaderboard-list .lb-name { flex: 1; font-weight: 500; }
.leaderboard-list .lb-score { font-weight: bold; color: var(--text-muted); }
.leaderboard-list .empty-msg {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 20px;
}
.leaderboard-list .is-me { background: rgba(255,255,255,0.4); border-radius: 6px; }

/* ===== Game page ===== */
.game-page {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
}

@media (max-width: 900px) {
  .game-page { grid-template-columns: 1fr; }
}

.game-stage {
  background: var(--panel-bg);
  background-image: linear-gradient(135deg, var(--panel-bg) 0%, var(--panel-bg-2) 100%);
  border: 3px solid var(--panel-border);
  border-radius: var(--panel-radius);
  padding: 40px;
  text-align: center;
  min-height: 400px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.game-stage h1 {
  font-family: var(--font-heading);
  color: var(--accent-color);
  font-size: 2.4rem;
  margin: 0;
}

.game-stage .placeholder-art { font-size: 6rem; }

.last-result {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin: 8px 0 0;
  min-height: 1.5em;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ===== Shop ===== */
.shop-section {
  margin-bottom: 30px;
}

.shop-section h2 {
  font-family: var(--font-heading);
  color: var(--accent-color);
  border-bottom: 2px solid var(--panel-border);
  padding-bottom: 6px;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.shop-item {
  background: var(--panel-bg);
  background-image: linear-gradient(135deg, var(--panel-bg) 0%, var(--panel-bg-2) 100%);
  border: 2.5px solid var(--panel-border);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.shop-item .preview {
  font-size: 3rem;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.3);
  border-radius: 10px;
  width: 100%;
  overflow: hidden;
  padding: 6px;
}

.shop-item .preview .avatar-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.shop-item .preview.theme-preview {
  font-size: 1rem;
  text-align: center;
  flex-direction: column;
  font-family: var(--font-heading);
  padding: 6px;
  line-height: 1.3;
}

.shop-item-name {
  font-weight: bold;
  font-family: var(--font-heading);
  margin: 0;
}

.shop-price {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-color);
  font-weight: bold;
}

.shop-item .primary-btn { width: 100%; padding: 8px; font-size: 0.9rem; margin-top: 4px; }

.shop-item.is-equipped {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-color-2);
}

.equipped-badge {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--accent-color);
}

/* ===== Profile ===== */
.profile-card {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.profile-avatar-big {
  width: 130px;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.4);
  border-radius: 50%;
  border: 3px solid var(--panel-border);
  overflow: hidden;
  padding: 12px;
  flex-shrink: 0;
}

.profile-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-stats .stat-label { color: var(--text-muted); font-size: 0.9rem; }
.profile-stats .stat-value { font-size: 1.25rem; font-weight: bold; color: var(--accent-color); }

.profile-section h3 {
  font-family: var(--font-heading);
  color: var(--accent-color);
  margin: 24px 0 8px;
}

.owned-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.owned-pill {
  background: rgba(255,255,255,0.4);
  border: 1.5px solid var(--panel-border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.owned-pill-img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  padding: 2px;
}

.empty-state {
  color: var(--text-muted);
  font-style: italic;
  padding: 12px;
}

.muted-help {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-style: italic;
  margin: 10px 2px 0;
}

/* Profile avatar picker — same building block as the registration
   picker, just sized up a bit for the larger profile real estate. */
.profile-avatar-picker {
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 12px;
  max-width: 640px;
}

.profile-avatar-picker .avatar-option {
  background: rgba(252, 211, 77, 0.08);
  border-color: rgba(252, 211, 77, 0.25);
}

.profile-avatar-picker .avatar-option:hover {
  background: rgba(252, 211, 77, 0.2);
  border-color: rgba(252, 211, 77, 0.6);
}

.profile-avatar-picker .avatar-option.selected {
  border-color: var(--accent-color);
  background: rgba(252, 211, 77, 0.25);
  box-shadow: 0 0 0 3px rgba(252, 211, 77, 0.35);
}

/* ===== Name That Book ===== */
.ntb-stage {
  background: var(--panel-bg);
  background-image: linear-gradient(135deg, var(--panel-bg) 0%, var(--panel-bg-2) 100%);
  border: 3px solid var(--panel-border);
  border-radius: var(--panel-radius);
  padding: 24px;
  min-height: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.ntb-header {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-family: var(--font-heading);
  color: var(--text-muted);
  font-size: 1rem;
}

.ntb-running-score {
  color: var(--accent-color);
  font-weight: bold;
}

.ntb-timer-bar {
  width: 100%;
  height: 10px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  overflow: hidden;
}

.ntb-timer-fill {
  height: 100%;
  width: 100%;
  background: var(--accent-color);
  transition: width 0.08s linear;
}

/* Emoji rebus clue — the centrepiece of the question screen */
.ntb-clue-label {
  font-family: var(--font-heading);
  color: var(--text-muted);
  font-size: 1rem;
  margin: 8px 0 0;
}

.ntb-clue-emojis {
  font-size: 4.5rem;
  line-height: 1.15;
  letter-spacing: 8px;
  text-align: center;
  padding: 20px 12px;
  background: rgba(255, 255, 255, 0.35);
  border: 2px dashed var(--panel-border);
  border-radius: 14px;
  min-width: 260px;
  max-width: 100%;
  word-break: keep-all;
  /* Force browser/system emoji rendering so colour emoji show up
     even when the active theme picks a plain serif font */
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
               "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
}

@media (max-width: 540px) {
  .ntb-clue-emojis { font-size: 3.2rem; letter-spacing: 4px; }
}

/* Revealed title + author shown after the player answers */
.ntb-reveal {
  min-height: 1.4em;
  font-style: italic;
  color: var(--text-color);
  margin: 0;
  font-size: 1rem;
  text-align: center;
}

.ntb-result-line {
  min-height: 1.4em;
  font-weight: bold;
  font-family: var(--font-heading);
  margin: 0;
  font-size: 1.05rem;
}

.ntb-result-line.is-correct { color: #15803d; }
.ntb-result-line.is-wrong { color: #b91c1c; }

.ntb-choices {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  width: 100%;
  max-width: 480px;
}

.ntb-choice {
  background: var(--button-bg);
  color: var(--button-text);
  border: none;
  padding: 14px 16px;
  font-size: 1.05rem;
  font-family: var(--font-heading);
  font-weight: bold;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s, box-shadow 0.2s;
  text-align: center;
}

.ntb-choice:hover:not(:disabled) {
  background: var(--button-bg-hover);
  transform: translateY(-1px);
}

.ntb-choice:active { transform: scale(0.98); }
.ntb-choice:disabled { cursor: default; opacity: 0.9; }

.ntb-choice.is-correct {
  background: #15803d !important;
  color: #fff !important;
  box-shadow: 0 0 0 3px #86efac;
}

.ntb-choice.is-wrong {
  background: #b91c1c !important;
  color: #fff !important;
  box-shadow: 0 0 0 3px #fca5a5;
}

.ntb-results { text-align: center; gap: 10px; justify-content: center; }

.ntb-results-title {
  font-family: var(--font-heading);
  color: var(--accent-color);
  font-size: 2rem;
  margin: 0;
}

.ntb-results-score {
  font-family: var(--font-heading);
  font-size: 3.2rem;
  color: var(--accent-color);
  font-weight: bold;
  text-shadow: 2px 2px 0 var(--accent-color-2);
}

.ntb-results-coins {
  color: var(--accent-color);
  font-weight: bold;
  font-size: 1.05rem;
}

.ntb-results-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 12px;
}

/* Anchor reference for the absolute Quit button */
.ntb-stage { position: relative; }

.ntb-quit-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(255, 255, 255, 0.4);
  border: 1.5px solid var(--panel-border);
  color: var(--text-color);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  z-index: 5;
}

.ntb-quit-btn:hover { background: rgba(0, 0, 0, 0.08); }

/* Intro splash — title, blurb, Start button. Sits on the same .ntb-stage
   so it picks up the active theme's parchment styling automatically. */
.ntb-intro {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px 40px;
  gap: 14px;
}

.ntb-intro .ntb-title {
  font-family: var(--font-heading);
  font-size: 2.6rem;
  margin: 0;
  color: var(--accent-color);
  text-shadow: 2px 2px 0 var(--accent-color-2);
}

.ntb-intro .ntb-subtitle {
  font-size: 1.1rem;
  max-width: 560px;
  margin: 8px auto 16px;
  line-height: 1.5;
  color: var(--text-color);
}

.ntb-intro .ntb-subtitle small { opacity: 0.7; font-size: 0.85rem; }

.ntb-intro .ntb-start-btn { font-size: 1.2rem; padding: 14px 32px; }

/* ===== Fullscreen game mode =====
   Hides the topbar and side panels so a custom-rendered game owns
   the viewport. The game's own Quit button is the way out. */
body.fullscreen-game .topbar,
body.fullscreen-game .global-leaderboard,
body.fullscreen-game .game-leaderboard {
  display: none !important;
}

body.fullscreen-game .main-layout {
  grid-template-columns: 1fr;
  padding: 0;
  max-width: none;
  margin: 0;
  gap: 0;
}

body.fullscreen-game .page-content { min-height: 100vh; }

body.fullscreen-game .game-page {
  grid-template-columns: 1fr;
  padding: 0;
  gap: 0;
}

body.fullscreen-game .game-stage-custom { min-height: 100vh; }

body.fullscreen-game .ntb-stage {
  min-height: 100vh;
  border-radius: 0;
  border: none;
  padding: 60px 24px 32px;
  justify-content: center;
}

/* ===== Lava Bounce ===== */
.lb-stage {
  position: relative;
  width: 100%;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #1a0f2e 0%, #0a0612 70%, #1a0a05 100%);
  color: #fef3c7;
  font-family: var(--font-heading);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.lb-quit-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(255, 255, 255, 0.12);
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  color: #fef3c7;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  z-index: 5;
}

.lb-quit-btn:hover { background: rgba(255, 255, 255, 0.22); }
.lb-quit-inline { position: static; align-self: center; }

.lb-intro {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px 40px;
  gap: 12px;
}

.lb-title {
  font-size: 3rem;
  margin: 0;
  color: #fbbf24;
  text-shadow: 3px 3px 0 #7c2d12;
}

.lb-subtitle {
  font-size: 1.15rem;
  max-width: 560px;
  margin: 8px auto 16px;
  line-height: 1.5;
}

.lb-subtitle small { opacity: 0.7; font-size: 0.85rem; }

.lb-start-btn { font-size: 1.2rem; padding: 14px 32px; }

.lb-play {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
}

.lb-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.45);
  border-bottom: 2px solid rgba(255, 255, 255, 0.15);
  color: #fef3c7;
  z-index: 2;
}

.lb-hud-score, .lb-hud-time { font-size: 1.1rem; font-weight: bold; }
.lb-hud-score { color: #fbbf24; }
.lb-hud-time { color: #fca5a5; }
.lb-hud-label {
  font-size: 0.75rem;
  font-weight: normal;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-right: 6px;
}

.lb-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: none;
}

.lb-results {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px 40px;
  gap: 6px;
}

.lb-results-title {
  font-size: 2.4rem;
  margin: 0;
  color: #fbbf24;
  text-shadow: 3px 3px 0 #7c2d12;
}

.lb-results-subtitle { font-size: 1.1rem; opacity: 0.85; margin: 0; }

.lb-results-score {
  font-size: 4rem;
  font-weight: bold;
  color: #fbbf24;
  text-shadow: 3px 3px 0 #7c2d12;
  margin: 12px 0;
}

.lb-results-coins { color: #fbbf24; font-weight: bold; font-size: 1.1rem; }

.lb-results-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 16px;
}

/* ===== Monster Dash =====
   Same fullscreen wrapper pattern as Lava Bounce. The actual game
   is drawn into a <canvas>, so the CSS only needs to handle the
   intro/HUD/results chrome. */
.md-stage {
  position: relative;
  width: 100%;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #1e1b4b 0%, #0c0a1e 70%, #050510 100%);
  color: #fef3c7;
  font-family: var(--font-heading);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.md-quit-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(255, 255, 255, 0.12);
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  color: #fef3c7;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  z-index: 5;
}

.md-quit-btn:hover { background: rgba(255, 255, 255, 0.22); }
.md-quit-inline { position: static; align-self: center; }

.md-intro {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px 40px;
  gap: 12px;
}

.md-title {
  font-size: 3rem;
  margin: 0;
  color: #c4b5fd;
  text-shadow: 3px 3px 0 #4c1d95;
}

.md-subtitle {
  font-size: 1.15rem;
  max-width: 560px;
  margin: 8px auto 16px;
  line-height: 1.5;
}

.md-subtitle small { opacity: 0.7; font-size: 0.85rem; }

.md-start-btn { font-size: 1.2rem; padding: 14px 32px; }

.md-play {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
}

.md-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.5);
  border-bottom: 2px solid rgba(196, 181, 253, 0.2);
  color: #fef3c7;
  z-index: 2;
}

.md-hud-score, .md-hud-dist { font-size: 1.1rem; font-weight: bold; }
.md-hud-score { color: #fbbf24; }
.md-hud-dist { color: #c4b5fd; }
.md-hud-label {
  font-size: 0.75rem;
  font-weight: normal;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-right: 6px;
}

.md-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: none;
}

.md-results {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px 40px;
  gap: 6px;
}

.md-results-title {
  font-size: 2.4rem;
  margin: 0;
  color: #c4b5fd;
  text-shadow: 3px 3px 0 #4c1d95;
}

.md-results-subtitle { font-size: 1.1rem; opacity: 0.85; margin: 0; }

.md-results-score {
  font-size: 4rem;
  font-weight: bold;
  color: #fbbf24;
  text-shadow: 3px 3px 0 #4c1d95;
  margin: 12px 0;
}

.md-results-coins { color: #fbbf24; font-weight: bold; font-size: 1.1rem; }

.md-results-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 16px;
}

/* ===== Name That Book intro splash ===== */
.ntb-intro {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px 40px;
  gap: 14px;
}

.ntb-intro .ntb-title {
  font-family: var(--font-heading);
  font-size: 2.6rem;
  margin: 0;
  color: var(--accent-color);
  text-shadow: 2px 2px 0 var(--accent-color-2);
}

.ntb-intro .ntb-subtitle {
  font-size: 1.1rem;
  max-width: 560px;
  margin: 8px auto 16px;
  line-height: 1.5;
  color: var(--text-color);
}

.ntb-intro .ntb-subtitle small { opacity: 0.7; font-size: 0.85rem; }

.ntb-intro .ntb-start-btn { font-size: 1.2rem; padding: 14px 32px; }

/* ===== Pairs =====
   Casino felt-table look with gold trim, ported from the original
   pairs.html standalone. Sits on its own .pr-stage (fullscreen). */
.pr-stage {
  position: relative;
  width: 100%;
  min-height: 100vh;
  background: radial-gradient(ellipse at center, #1a5f3f 0%, #134a30 45%, #0d3a25 80%, #08291a 100%);
  background-image:
    repeating-linear-gradient(45deg, rgba(0,0,0,0.03) 0 2px, transparent 2px 4px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.015) 0 2px, transparent 2px 4px),
    radial-gradient(ellipse at center, #1a5f3f 0%, #134a30 45%, #0d3a25 80%, #08291a 100%);
  color: #f4ead5;
  font-family: 'Georgia', 'Times New Roman', serif;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pr-quit-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(0, 0, 0, 0.35);
  border: 1.5px solid rgba(212, 175, 55, 0.6);
  color: #f4ead5;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Georgia', serif;
  font-size: 0.9rem;
  z-index: 5;
}

.pr-quit-btn:hover { background: rgba(0, 0, 0, 0.55); }
.pr-quit-inline { position: static; align-self: center; margin-right: auto; }

/* Intro screen */
.pr-intro {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px 40px;
  gap: 12px;
}

.pr-title {
  font-size: 3rem;
  margin: 0;
  color: #d4af37;
  letter-spacing: 4px;
  text-shadow: 0 3px 10px rgba(0,0,0,0.6);
}

.pr-subtitle {
  font-size: 1.15rem;
  max-width: 560px;
  margin: 8px auto 16px;
  line-height: 1.5;
  font-style: italic;
}

.pr-subtitle small { opacity: 0.7; font-size: 0.85rem; font-style: normal; }

.pr-start-btn { font-size: 1.2rem; padding: 14px 32px; }

/* Gameplay layout */
.pr-play {
  display: grid;
  grid-template-rows: auto 1fr;
}

.pr-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 22px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(212, 175, 55, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.pr-hud-item { display: flex; flex-direction: column; align-items: center; min-width: 90px; }

.pr-hud-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #d4af37;
  font-family: 'Helvetica Neue', sans-serif;
  margin-bottom: 4px;
}

.pr-hud-value {
  font-size: 22px;
  font-weight: bold;
  color: #f4ead5;
  font-family: 'Georgia', serif;
}

.pr-hud-value.pr-score { color: #d4af37; }
.pr-hud-value.pr-time.warning { color: #f5b041; }
.pr-hud-value.pr-time.danger { color: #e74c3c; animation: pr-pulse 0.7s infinite alternate; }
@keyframes pr-pulse { from { opacity: 1; } to { opacity: 0.55; } }

/* Card grid */
.pr-grid-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  padding: 20px;
}

.pr-grid {
  display: grid;
  gap: 14px;
  width: 100%;
  justify-content: center;
  perspective: 1200px;
}

.pr-card {
  aspect-ratio: 2 / 3;
  width: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0.2, 0.2, 1), opacity 0.5s ease, scale 0.3s ease;
  cursor: pointer;
  border-radius: 12px;
}

.pr-card:hover:not(.flipped):not(.matched) { transform: translateY(-4px); }
.pr-card.flipped { transform: rotateY(180deg); }
.pr-card.flipped:hover { transform: rotateY(180deg) translateY(-2px); }
.pr-card.matched { opacity: 0; transform: rotateY(180deg) scale(0.7); pointer-events: none; }

.pr-card.mismatch .pr-face { animation: pr-shake 0.4s ease; }
@keyframes pr-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.pr-face {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 6px 14px rgba(0,0,0,0.5),
    inset 0 0 0 1px rgba(255,255,255,0.05);
}

.pr-face-back {
  background: radial-gradient(ellipse at center, #8b1a1a 0%, #5c0f0f 70%, #3a0808 100%);
  border: 3px solid #d4af37;
  overflow: hidden;
}

.pr-face-back::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(212, 175, 55, 0.5);
  border-radius: 8px;
}

.pr-face-back::after {
  content: '?';
  font-family: 'Georgia', serif;
  font-size: clamp(40px, 10vw, 80px);
  font-weight: bold;
  color: #d4af37;
  text-shadow: 0 2px 4px rgba(0,0,0,0.6), 0 0 12px rgba(212, 175, 55, 0.4);
}

.pr-face-front {
  background: linear-gradient(135deg, #faf3e0 0%, #f4ead5 50%, #e8dcc0 100%);
  border: 3px solid #d4af37;
  transform: rotateY(180deg);
  font-size: clamp(36px, 8vw, 64px);
}

.pr-face-front::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(139, 90, 60, 0.3);
  border-radius: 8px;
}

/* Round-complete overlay (sits over the play area) */
.pr-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(8, 30, 20, 0.92);
  backdrop-filter: blur(8px);
  z-index: 10;
  padding: 30px;
  text-align: center;
  animation: pr-fade-in 0.4s ease;
}

@keyframes pr-fade-in {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.pr-screen-title {
  font-size: clamp(36px, 6vw, 56px);
  color: #d4af37;
  margin: 0 0 12px;
  text-shadow: 0 3px 10px rgba(0,0,0,0.6);
  letter-spacing: 2px;
}

.pr-screen-subtitle {
  font-size: clamp(16px, 2.5vw, 22px);
  color: #f4ead5;
  margin-bottom: 30px;
  font-style: italic;
  max-width: 600px;
}

.pr-screen-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 30px;
  flex-wrap: wrap;
  justify-content: center;
}

.pr-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 22px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 10px;
  min-width: 110px;
}

.pr-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #d4af37;
  font-family: 'Helvetica Neue', sans-serif;
}

.pr-stat-value {
  font-size: 28px;
  color: #f4ead5;
  font-weight: bold;
  margin-top: 4px;
}

.pr-screen-btn { font-size: 1.1rem; padding: 14px 32px; }

.pr-confetti {
  position: absolute;
  width: 10px;
  height: 14px;
  top: -20px;
  animation: pr-fall linear forwards;
  pointer-events: none;
  z-index: 11;
}

@keyframes pr-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(700px) rotate(720deg); opacity: 0; }
}

/* Results screen */
.pr-results {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px 40px;
  gap: 6px;
}

.pr-results-title {
  font-size: 2.6rem;
  margin: 0;
  color: #d4af37;
  letter-spacing: 2px;
  text-shadow: 0 3px 10px rgba(0,0,0,0.6);
}

.pr-results-subtitle { font-size: 1.1rem; opacity: 0.85; margin: 0; font-style: italic; }

.pr-results-score {
  font-size: 4rem;
  font-weight: bold;
  color: #d4af37;
  text-shadow: 0 3px 10px rgba(0,0,0,0.6);
  margin: 12px 0;
}

.pr-results-line { margin: 2px 0; opacity: 0.9; }
.pr-results-coins { color: #d4af37; font-weight: bold; font-size: 1.1rem; }

.pr-results-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 16px;
}

/* ===== Music toggle button =====
   Small round button in the user-chip area. Toggles the procedural
   background music. Persists between sessions via localStorage. */
.music-toggle {
  background: rgba(252, 211, 77, 0.15);
  border: 1px solid var(--panel-border);
  color: var(--accent-color);
  width: 36px;
  height: 36px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  flex-shrink: 0;
}

.music-toggle:hover { background: rgba(252, 211, 77, 0.3); transform: translateY(-1px); }
.music-toggle.muted { opacity: 0.55; }
