:root {
  --bg: #1a0b2e;
  --bg-glow-1: #4a1e6e;
  --bg-glow-2: #6b1f7a;
  --bg-glow-3: #c2410c;
  --text: #fff9f0;
  --text-soft: #e8d9c0;
  --muted: #b8a89a;

  --panel: rgba(30, 12, 50, 0.85);
  --panel-border: rgba(255, 200, 140, 0.25);

  --gold: #ffd54a;
  --gold-deep: #d4a017;
  --magic: #b266ff;
  --magic-deep: #6b21a8;
  --fire: #ff6b35;
  --fire-deep: #c2410c;
  --ice: #5ec3ff;
  --leaf: #4ade80;
  --hot-pink: #ff4f8b;

  --egg: #fff4d1;
  --egg-shine: #ffe892;
  --danger: #ff3860;
  --shadow-soft: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
  --shadow-strong: 0 20px 60px -10px rgba(0, 0, 0, 0.7);

  --serif: "Georgia", "Iowan Old Style", "Palatino", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

body {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(178, 102, 255, 0.35) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(255, 107, 53, 0.25) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(94, 195, 255, 0.18) 0%, transparent 60%),
    radial-gradient(ellipse at 0% 80%, rgba(255, 79, 139, 0.18) 0%, transparent 55%);
  background-attachment: fixed;
}

/* ===== Screens ===== */

.screen {
  display: none;
  min-height: 100vh;
  padding: 1.5rem 1rem;
}

.screen.active { display: flex; flex-direction: column; align-items: center; }

.screen.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 5, 30, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  justify-content: center;
}

.screen.overlay.active { display: flex; }

.screen-inner {
  max-width: 980px;
  width: 100%;
  text-align: center;
  padding: 2rem 1.2rem;
}

#start-screen .screen-inner { max-width: 980px; }
#pause-screen .screen-inner,
#gameover-screen .screen-inner { max-width: 640px; }

/* ===== Start screen ===== */

.title-name {
  margin: 0 0 0.3rem;
  font-family: var(--serif);
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-style: italic;
  font-weight: 700;
  background: linear-gradient(135deg, #ff6db5 0%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

h1 {
  margin: 0 0 0.5rem;
  font-family: var(--serif);
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--fire) 0%, var(--gold) 40%, var(--magic) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 20px rgba(255, 107, 53, 0.3);
}

h1 .crown {
  display: inline-block;
  font-size: 0.7em;
  color: var(--gold);
  -webkit-text-fill-color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 213, 74, 0.6);
  animation: twinkle 2s ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.15); }
}

.subtitle {
  margin: 0 0 1.5rem;
  font-size: clamp(0.95rem, 2.5vw, 1.15rem);
  color: var(--text-soft);
}

.dragon-preview {
  margin: 0.5rem auto 1.5rem;
  display: flex;
  justify-content: center;
}

#preview-canvas {
  filter: drop-shadow(0 8px 24px rgba(255, 107, 53, 0.4));
}

/* ===== Difficulty picker ===== */

.difficulty-picker {
  margin: 0 0 1.8rem;
}

.picker-label {
  margin: 0 0 1rem;
  font-size: 1rem;
  color: var(--text-soft);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.diff-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.7rem;
  max-width: 760px;
  margin: 0 auto;
}

.diff-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1rem 0.5rem;
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 16px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.diff-btn:hover { transform: translateY(-3px); }

.diff-btn.selected {
  border-color: var(--gold);
  box-shadow: 0 0 24px rgba(255, 213, 74, 0.4), inset 0 0 16px rgba(255, 213, 74, 0.1);
  background: linear-gradient(135deg, rgba(255, 213, 74, 0.15), rgba(178, 102, 255, 0.1));
}

.diff-emoji { font-size: 1.8rem; }

.diff-name {
  font-weight: 700;
  font-size: 1.05rem;
  font-family: var(--serif);
}

.diff-desc {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
}

.diff-btn.selected .diff-desc { color: var(--text-soft); }

/* ===== Buttons ===== */

.big-btn {
  display: inline-block;
  padding: 1rem 2.5rem;
  font-size: 1.2rem;
  font-weight: 700;
  font-family: var(--serif);
  color: white;
  background: linear-gradient(135deg, var(--fire) 0%, var(--hot-pink) 50%, var(--magic) 100%);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 107, 53, 0.4), inset 0 -3px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.15s, box-shadow 0.15s;
  font-family: inherit;
  letter-spacing: 0.02em;
}

.big-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(255, 107, 53, 0.55), inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}

.big-btn:active { transform: translateY(0); }

.text-btn {
  display: block;
  margin: 1rem auto 0;
  padding: 0.6rem 1rem;
  background: transparent;
  border: none;
  color: var(--text-soft);
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.text-btn:hover { color: var(--gold); }

/* ===== How to play ===== */

.how-to-play {
  margin: 2rem auto 0;
  max-width: 460px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 0.8rem 1.2rem;
}

.how-to-play summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  color: var(--gold);
  list-style: none;
  padding: 0.4rem 0;
}

.how-to-play summary::-webkit-details-marker { display: none; }
.how-to-play summary::before { content: "▶ "; font-size: 0.7em; display: inline-block; transition: transform 0.2s; }
.how-to-play[open] summary::before { transform: rotate(90deg); }

.how-to-play ul {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0.3rem;
}

.how-to-play li {
  padding: 0.35rem 0;
  font-size: 0.92rem;
  color: var(--text-soft);
}

.how-to-play strong { color: var(--gold); font-weight: 700; }

/* ===== Game screen ===== */

#game-screen { padding: 0.5rem; }

.hud {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 900px;
  margin: 0 auto 0.6rem;
  padding: 0.6rem 0.8rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  flex-wrap: wrap;
}

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

.hud-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.hud-value {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gold);
}

.hud-btn {
  padding: 0.4rem 0.8rem;
  background: rgba(255, 213, 74, 0.15);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--gold);
  font-size: 1.05rem;
  cursor: pointer;
  font-family: inherit;
}

.hud-btn:first-of-type { margin-left: auto; }

.hud-btn-pause {
  font-weight: 700;
  background: linear-gradient(135deg, rgba(255, 213, 74, 0.3), rgba(255, 107, 53, 0.25));
  border-color: var(--gold);
  font-size: 0.95rem;
}

.hud-btn-pause:hover {
  background: linear-gradient(135deg, rgba(255, 213, 74, 0.5), rgba(255, 107, 53, 0.4));
}

.hud-timer-item .hud-value {
  font-variant-numeric: tabular-nums;
}

.hud-timer-item .hud-value.low {
  color: var(--danger);
  animation: timer-low-pulse 0.8s ease-in-out infinite;
}

@keyframes timer-low-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ===== Lock screen ===== */
#lock-screen .screen-inner {
  max-width: 480px;
}
#lock-screen h2 {
  font-family: var(--serif);
  font-size: clamp(2rem, 6vw, 2.8rem);
  background: linear-gradient(135deg, var(--fire), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0 0 1rem;
}
.lock-msg {
  color: var(--text-soft);
  font-size: 1.05rem;
  line-height: 1.55;
  margin: 0 0 1.4rem;
}
.lock-input-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 0.8rem;
}
#lock-input {
  flex: 1;
  max-width: 220px;
  padding: 0.7rem 1rem;
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}
#lock-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 213, 74, 0.18);
}
.lock-error {
  color: var(--danger);
  font-size: 0.92rem;
  min-height: 1.2em;
  margin: 0.3rem 0;
}
.lock-note {
  color: var(--muted);
  font-size: 0.8rem;
  font-style: italic;
  margin: 1.2rem 0 0;
}

.math-banner {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto 0.5rem;
  padding: 0.8rem 1rem;
  background: linear-gradient(135deg, rgba(70, 50, 110, 0.35), rgba(40, 30, 70, 0.3));
  border: 2px solid var(--panel-border);
  border-radius: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  min-height: 96px;
  justify-content: center;
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s;
}

.math-banner.active {
  background: linear-gradient(135deg, rgba(178, 102, 255, 0.3), rgba(255, 213, 74, 0.25));
  border-color: var(--gold);
  animation: math-pulse 1.5s ease-in-out infinite;
  box-shadow: 0 0 30px rgba(255, 213, 74, 0.3);
}

.math-banner:not(.active) .math-problem {
  color: var(--muted);
  font-size: clamp(1.05rem, 2.5vw, 1.4rem);
  font-style: italic;
  font-weight: 500;
  text-shadow: none;
}

.math-banner:not(.active) .math-label {
  color: var(--muted);
}

.math-banner-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  justify-content: center;
}

.math-timer {
  background: rgba(255, 213, 74, 0.2);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-family: var(--serif);
  font-weight: 700;
  color: var(--gold);
  font-size: 0.9rem;
}

.math-timer.countdown {
  background: rgba(255, 56, 96, 0.2);
  border-color: var(--danger);
  color: var(--danger);
  animation: timer-flash 1s ease-in-out infinite;
}

@keyframes timer-flash {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@keyframes math-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(255, 213, 74, 0.25); }
  50% { box-shadow: 0 0 40px rgba(255, 213, 74, 0.55); }
}

.math-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold);
  font-weight: 700;
}

.math-problem {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  font-weight: 800;
  color: white;
  text-shadow: 0 2px 12px rgba(178, 102, 255, 0.6);
}

.powerup-banner {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.2rem;
  background: linear-gradient(135deg, var(--fire), var(--hot-pink));
  border-radius: 999px;
  color: white;
  font-weight: 700;
  font-size: 1.05rem;
  box-shadow: 0 8px 24px rgba(255, 107, 53, 0.5);
  animation: pu-glow 0.8s ease-in-out infinite;
}

@keyframes pu-glow {
  0%, 100% { box-shadow: 0 8px 24px rgba(255, 107, 53, 0.5); }
  50% { box-shadow: 0 12px 36px rgba(255, 107, 53, 0.85), 0 0 24px rgba(255, 213, 74, 0.6); }
}

.pu-icon { font-size: 1.4rem; }
.pu-timer {
  background: rgba(255, 255, 255, 0.25);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-family: var(--serif);
  min-width: 1.8rem;
  text-align: center;
}

.canvas-wrap {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-strong);
  border: 2px solid var(--panel-border);
}

/* ===== Virtual joystick (visible on touch devices only) ===== */
.joystick {
  position: absolute;
  bottom: 14px;
  left: 14px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(255, 213, 74, 0.18), rgba(178, 102, 255, 0.12));
  border: 2px solid rgba(255, 213, 74, 0.45);
  z-index: 30;
  touch-action: none;
  display: none;
  pointer-events: auto;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}
.joystick::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 1px dashed rgba(255, 244, 209, 0.35);
}
.joystick-stick {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--fire));
  left: 50%;
  top: 50%;
  margin-left: -28px;
  margin-top: -28px;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(255, 107, 53, 0.45), inset 0 -3px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.08s linear;
}

/* Show on touch / coarse-pointer devices */
@media (hover: none) and (pointer: coarse) {
  .joystick { display: block; }
  .controls-hint { display: none; }
}

@media (max-width: 600px) {
  .joystick { width: 110px; height: 110px; }
  .joystick-stick { width: 48px; height: 48px; margin-left: -24px; margin-top: -24px; }
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(178, 102, 255, 0.25) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 70%, rgba(255, 107, 53, 0.2) 0%, transparent 60%),
    linear-gradient(180deg, #1a0830 0%, #2d1654 50%, #4a1e6e 100%);
  touch-action: none;
}

.controls-hint {
  text-align: center;
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.controls-hint kbd {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  font-size: 0.85em;
  color: var(--gold);
  font-family: inherit;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

/* ===== Pause / Game Over ===== */

#pause-screen h2,
#gameover-screen h2 {
  font-family: var(--serif);
  font-size: clamp(2rem, 6vw, 3rem);
  margin: 0 0 1rem;
  background: linear-gradient(135deg, var(--fire), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gameover-msg {
  font-size: 1.1rem;
  color: var(--text-soft);
  margin: 0 0 1.5rem;
}

.final-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  max-width: 460px;
  margin: 0 auto 1.5rem;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 0.7rem 0.3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat.best-stat {
  background: linear-gradient(135deg, rgba(255, 213, 74, 0.2), rgba(255, 107, 53, 0.15));
  border-color: var(--gold);
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.stat-val {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold);
}

.new-best {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 1.5rem;
  background: linear-gradient(135deg, var(--gold), var(--fire));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: bounce 0.6s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.hidden { display: none !important; }

/* ===== Page footer ===== */

.page-footer {
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.dedication {
  font-family: var(--serif);
  font-style: italic;
  color: var(--text-soft);
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
}

.dedication span {
  color: var(--gold);
  font-weight: 600;
  font-style: normal;
}

.disclaimer {
  font-size: 0.75rem;
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.5;
  color: var(--muted);
  opacity: 0.7;
}

/* ===== Level picker (start screen) ===== */

.level-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.7rem;
  max-width: 820px;
  margin: 0 auto;
}

.level-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.9rem 0.6rem 0.7rem;
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 16px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  min-height: 140px;
  overflow: hidden;
}

.level-card:hover:not(.locked) { transform: translateY(-3px); }

.level-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 22px rgba(255, 213, 74, 0.45), inset 0 0 14px rgba(255, 213, 74, 0.1);
  background: linear-gradient(135deg, rgba(255, 213, 74, 0.18), rgba(178, 102, 255, 0.12));
}

.level-card.locked {
  opacity: 0.55;
  cursor: not-allowed;
  background: rgba(20, 10, 36, 0.65);
}

.level-card.locked .level-name,
.level-card.locked .level-desc { filter: grayscale(0.5); }

.level-emoji { font-size: 2rem; line-height: 1; }

.level-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1rem;
  color: var(--gold);
}

.level-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.3;
  max-width: 100%;
}

.level-status {
  font-size: 0.7rem;
  color: var(--leaf);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.level-lock {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  margin-top: 0.15rem;
}

.level-unlock-banner {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.35), rgba(255, 213, 74, 0.3));
  border: 2px solid var(--leaf);
  border-radius: 14px;
  padding: 0.7rem 1rem;
  color: var(--text);
  margin: 0 auto 1rem;
  max-width: 460px;
  font-size: 0.95rem;
  animation: unlock-pop 0.5s ease-out;
  box-shadow: 0 0 28px rgba(74, 222, 128, 0.45);
}

.level-unlock-banner strong { color: var(--leaf); }

@keyframes unlock-pop {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); }
}

/* ===== Player picker (start screen) ===== */

.picker-section { margin: 0 0 1.4rem; }

.player-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.6rem;
  max-width: 560px;
  margin: 0 auto;
}

.player-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.5rem 0.4rem 0.6rem;
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 14px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  min-height: 130px;
}

.player-card:hover { transform: translateY(-3px); }

.player-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(255, 213, 74, 0.5), inset 0 0 12px rgba(255, 213, 74, 0.12);
  background: linear-gradient(135deg, rgba(255, 213, 74, 0.18), rgba(178, 102, 255, 0.12));
}

.player-img-wrap {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

.player-card img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  display: block;
}

.player-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--gold);
}

.player-tribe {
  font-size: 0.7rem;
  color: var(--muted);
}

/* ===== Leaderboard ===== */

.leaderboard-card {
  margin: 1.6rem auto 0;
  max-width: 520px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 1rem 1.2rem 1.2rem;
  text-align: left;
}

.leaderboard-card.go-leaderboard {
  margin: 0 auto 1.4rem;
}

.lb-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 0 0.6rem;
}

.leaderboard-card h3 {
  margin: 0 0 0.4rem;
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--gold);
}

.lb-clear {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0.2rem 0.4rem;
  font-family: inherit;
}

.lb-clear:hover { color: var(--danger); }

.lb-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: lb;
}

.lb-row {
  display: grid;
  grid-template-columns: 32px 1fr auto 70px;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.4rem;
  border-bottom: 1px dashed rgba(255, 200, 140, 0.12);
  font-size: 0.92rem;
}

.lb-row:last-child { border-bottom: none; }

.lb-row.lb-highlight {
  background: linear-gradient(90deg, rgba(255, 213, 74, 0.18), rgba(178, 102, 255, 0.12));
  border-radius: 8px;
  border-bottom-color: transparent;
}

.lb-rank {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--gold);
  text-align: center;
}

.lb-name {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--gold);
}

.lb-meta {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
}

.lb-empty {
  color: var(--muted);
  font-style: italic;
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}

/* ===== Name entry row ===== */

.lb-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0 0 1rem;
}

.lb-name-row label {
  color: var(--text-soft);
  font-size: 0.95rem;
}

#lb-name-input {
  padding: 0.5rem 0.8rem;
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  width: 160px;
}

#lb-name-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 213, 74, 0.18);
}

.small-btn {
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, var(--fire), var(--hot-pink));
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.small-btn:hover {
  transform: translateY(-2px);
}

/* ===== Responsive ===== */

@media (max-width: 640px) {
  .diff-buttons { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; max-width: 420px; }
  .diff-btn { padding: 0.7rem 0.3rem; }
  .diff-name { font-size: 0.95rem; }
  .diff-desc { font-size: 0.7rem; }
  .hud { gap: 0.3rem; padding: 0.5rem; }
  .hud-value { font-size: 1.15rem; }
  .final-stats { grid-template-columns: repeat(3, 1fr); }
  .player-picker { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
  .player-card { min-height: 110px; padding: 0.4rem 0.3rem 0.5rem; }
  .player-card img { width: 56px; height: 56px; }
  .player-name { font-size: 0.75rem; }
  .player-tribe { font-size: 0.62rem; }
  .lb-row { grid-template-columns: 28px 1fr auto 56px; font-size: 0.85rem; gap: 0.4rem; }
}

@media (min-width: 900px) {
  h1 { font-size: clamp(2.6rem, 5.5vw, 4rem); }
  .title-name { font-size: clamp(1.6rem, 3.5vw, 2.3rem); }
  .subtitle { font-size: 1.2rem; }
  .picker-label { font-size: 1.15rem; }
  .big-btn { font-size: 1.3rem; padding: 1.1rem 3rem; }
  .player-picker { grid-template-columns: repeat(8, 1fr); max-width: 800px; }
}
