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

html {
  scrollbar-gutter: stable;
}

:root {
  --bg: #111;
  --surface: #1e1e1e;
  --surface-alt: #2a2a2a;
  --accent: #e8a020;
  --accent-hover: #f0b840;
  --accent-2: #3ac9b0;
  --accent-2-hover: #4fe0c8;
  --accent-3: #f06292;
  --accent-3-hover: #ff7fa8;
  --text: #e8e8e8;
  --text-muted: #888;
  --error: #e05050;
  --success: #3ac9b0;
  --radius: 8px;
  --radius-lg: 16px;
  --max-width: 800px;
  --shadow-playful: 0 6px 20px rgba(232, 160, 32, 0.18);
  --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.35);
}

/* ── Theme chrome — Football ─────────────────────────────────────────── */
body.theme-football {
  --accent:          #22c55e;
  --accent-hover:    #16a34a;
  --shadow-playful:  0 6px 20px rgba(34, 197, 94, 0.2);
}

/* Chalk-line dividers between selector groups */
body.theme-football .selector-group + .selector-group {
  border-top: 2px dashed rgba(34, 197, 94, 0.22);
  padding-top: 0.9rem;
  margin-top: 0.35rem;
}

/* ── Theme chrome — Games ────────────────────────────────────────────── */
body.theme-games {
  --accent:         #00e5ff;
  --accent-hover:   #40f0ff;
  --shadow-playful: 0 6px 20px rgba(0, 229, 255, 0.2);
}

/* CRT scanline overlay */
body.theme-games::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(0, 0, 0, 0.1) 3px,
    rgba(0, 0, 0, 0.1) 4px
  );
  pointer-events: none;
  z-index: 9000;
}

/* Phosphor-glow on major headings in Games theme */
body.theme-games h1,
body.theme-games h2 {
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.45);
}

/* ── Theme chrome — Film/TV ──────────────────────────────────────────── */
body.theme-film {
  --accent:         #e63946;
  --accent-hover:   #ff5a67;
  --shadow-playful: 0 6px 20px rgba(230, 57, 70, 0.22);
}

/* Film-strip dividers between selector groups */
body.theme-film .selector-group + .selector-group {
  border-top: 2px solid rgba(230, 57, 70, 0.25);
  padding-top: 0.9rem;
  margin-top: 0.35rem;
}

/* Subtle vignette framing in Film theme */
body.theme-film::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.35) 100%);
  pointer-events: none;
  z-index: 9000;
}

/* Warm gold glow on major headings in Film theme */
body.theme-film h1,
body.theme-film h2 {
  text-shadow: 0 0 14px rgba(230, 57, 70, 0.35);
}

body {
  /* Deep-space gradient — barely perceptible as a gradient but gives the
     starfield canvas somewhere nuanced to sit instead of pure #111. */
  background: radial-gradient(ellipse at 50% 0%,
    #0f1025 0%,
    #0a0e1c 40%,
    #050510 100%);
  background-color: var(--bg); /* fallback if radial-gradient unsupported */
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  min-height: 100vh;
  padding: 4.5rem 1rem 2rem;
}

/* ── Starfield canvas — sits behind every UI element ─────────────────── */
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s ease;
  will-change: opacity;
}
/* During an active round the event content should be the clear focus, so
   the starfield dims. Home, setup, results, etc. run at full brightness. */
body.in-round #starfield {
  opacity: 0.35;
}

/* Reduced-motion: starfield twinkle is disabled inside starfield.js
   (stars draw once, no rAF loop). We deliberately leave the game's
   functional animations — wheel spins, reveal flips, confetti — alone
   since they communicate outcomes. */
@media (prefers-reduced-motion: reduce) {
  /* Silence purely decorative overlays that add no information. */
  body.theme-chaos::after { animation: none !important; }
}

.screen {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

#screen-gate,
#screen-start,
#screen-results,
#screen-campaign,
#screen-campaign-wheel {
  max-width: 1100px;
}


#screen-round {
  max-width: 1200px;
}

#screen-matching {
  max-width: 1400px;
}

#screen-sequence {
  max-width: none;
}

#screen-location {
  max-width: 1400px;
}

.hidden {
  display: none !important;
}

/* ── Typography ── */

h1 {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--accent);
}

h2 {
  font-size: 2rem;
  font-weight: 700;
}

/* ── Buttons ── */

.btn {
  padding: 0.65rem 1.6rem;
  border-radius: var(--radius);
  border: 2px solid transparent;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s, transform 0.15s, box-shadow 0.15s;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-playful);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

.btn-primary {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Start screen ── */

.rules {
  color: var(--text-muted);
  text-align: center;
  max-width: 520px;
}

.attribution {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
  text-align: center;
  margin-top: -1rem;
  letter-spacing: 0.3px;
}

.selector-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.selector-label {
  width: 100%;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}

.selector-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  min-height: 1.2em;
  max-width: 500px;
  margin-top: 0.25rem;
}

.difficulty-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.btn-difficulty,
.btn-mode,
.btn-era,
.btn-theme {
  background: var(--surface);
  color: var(--text);
  border-color: #444;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
  white-space: nowrap;
}

.btn-difficulty:hover:not(:disabled):not(.selected),
.btn-mode:hover:not(:disabled):not(.selected),
.btn-era:hover:not(:disabled):not(.selected),
.btn-theme:hover:not(:disabled):not(.selected) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-difficulty.selected,
.btn-mode.selected,
.btn-era.selected,
.btn-theme.selected {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

/* Emoji prefixes for playful mode / difficulty / era buttons */
.btn-mode[data-mode="classic"]::before  { content: "📜"; }
.btn-mode[data-mode="matching"]::before { content: "🧩"; }
.btn-mode[data-mode="sequence"]::before { content: "⏳"; }
.btn-mode[data-mode="location"]::before { content: "🗺️"; }

.btn-difficulty[data-difficulty="easy"]::before   { content: "🟢"; }
.btn-difficulty[data-difficulty="medium"]::before { content: "🟡"; }
.btn-difficulty[data-difficulty="hard"]::before   { content: "🔴"; }

.btn-era[data-era="all"]::before          { content: "🌍"; }
.btn-era[data-era="ancient"]::before      { content: "🏛️"; }
.btn-era[data-era="medieval"]::before     { content: "⚔️"; }
.btn-era[data-era="earlyModern"]::before  { content: "⛵"; }
.btn-era[data-era="modern"]::before {
  content: "";
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.2em;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><rect x='1' y='21' width='25' height='5' rx='2' fill='%23222'/><circle cx='5' cy='24' r='1.6' fill='%23888'/><circle cx='10' cy='24' r='1.6' fill='%23888'/><circle cx='15' cy='24' r='1.6' fill='%23888'/><circle cx='20' cy='24' r='1.6' fill='%23888'/><rect x='2' y='16' width='23' height='6' rx='1' fill='%234a5d23'/><rect x='8' y='10' width='10' height='6' rx='1' fill='%23556b2f'/><rect x='17' y='12' width='13' height='2' fill='%234a5d23'/></svg>") center/contain no-repeat;
}
.btn-era[data-era="contemporary"]::before { content: "🛰️"; }

.btn-theme[data-theme="standard"]::before { content: "📚"; }
.btn-theme[data-theme="football"]::before { content: "⚽"; }
.btn-theme[data-theme="games"]::before    { content: "🎮"; }
.btn-theme[data-theme="film"]::before     { content: "🎬"; }

/* ── High Scores – theme accuracy toggle ── */
.hs-theme-accuracy {
  padding: 0;
}
.hs-expand-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  padding: 0.8rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.hs-expand-btn:hover { color: var(--accent); }
.hs-expand-icon {
  font-size: 0.75rem;
  transition: transform 0.2s;
}
.hs-expand-btn.open .hs-expand-icon {
  transform: rotate(180deg);
}
.hs-expand-content {
  padding-bottom: 0.5rem;
}
.theme-accuracy-group {
  margin-bottom: 1rem;
}
.theme-accuracy-group h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 0.4rem;
  color: var(--text-muted, #888);
}

/* ── Matching screen ── */

.matching-instructions {
  color: var(--text-muted);
  text-align: center;
  font-size: 0.9rem;
}

.events-pool {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 60px;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius);
  border: 2px dashed transparent;
  transition: border-color 0.15s, background 0.15s;
}

.events-pool.drag-over {
  border-color: var(--accent);
  background: rgba(232, 160, 32, 0.05);
}

.events-pool:empty::after {
  content: "All events placed";
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
  text-align: center;
  padding: 0.75rem;
  width: 100%;
}

.event-card-draggable {
  background: var(--surface);
  border: 2px solid #444;
  border-radius: var(--radius);
  padding: 0.7rem 2.25rem 0.7rem 1rem;
  position: relative;
  font-size: 0.95rem;
  line-height: 1.4;
  cursor: grab;
  user-select: none;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s, box-shadow 0.15s;
}

.event-card-draggable:hover:not(.submitted) {
  border-color: var(--accent);
}

.event-card-draggable.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.event-card-draggable.dragging {
  opacity: 0.45;
  cursor: grabbing;
}

.event-card-draggable.submitted {
  cursor: default;
}

.event-card-draggable.correct {
  border-color: #4caf50;
  background: rgba(76, 175, 80, 0.15);
}

.event-card-draggable.incorrect {
  border-color: var(--error);
  background: rgba(224, 80, 80, 0.15);
}

.matching-timeline-wrap {
  width: 100%;
  padding-top: 0.5rem;
  position: relative;
}

.matching-timeline {
  display: flex;
  width: 100%;
  gap: 0.5rem;
  align-items: stretch;
}

.year-slot {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
}

.year-slot-label {
  font-weight: 700;
  color: var(--accent);
  font-size: 1rem;
  text-align: center;
  padding: 0.35rem 0.25rem;
  border-bottom: 2px solid var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.year-slot-drop {
  flex: 1;
  min-height: 140px;
  background: var(--surface);
  border: 2px dashed #444;
  border-radius: var(--radius);
  padding: 0.4rem;
  display: flex;
  align-items: stretch;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}

.year-slot-drop.drag-over {
  border-color: var(--accent);
  background: var(--surface-alt);
}

.year-slot-drop .event-card-draggable {
  width: 100%;
  font-size: 0.78rem;
  line-height: 1.35;
  padding: 0.5rem;
  margin: 0;
}

@media (max-width: 640px) {
  .matching-timeline {
    flex-direction: column;
    gap: 0.75rem;
  }

  .year-slot {
    flex-direction: row;
    align-items: stretch;
    gap: 0.75rem;
  }

  .year-slot-label {
    flex: 0 0 90px;
    border-bottom: none;
    border-right: 2px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .year-slot-drop {
    min-height: 60px;
  }

  .year-slot-drop .event-card-draggable {
    font-size: 0.9rem;
  }
}

/* ── Sequence screen ── */

.sequence-current {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  position: relative;
  border-radius: var(--radius);
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 160, 32, 0.15);
}

.sequence-prompt {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-size: 0.7rem;
  font-weight: 700;
}

.sequence-current-card {
  font-size: 1.15rem;
  font-style: italic;
  text-align: center;
  line-height: 1.5;
  padding: 0.25rem 0;
  max-width: 640px;
}

.sequence-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

.sequence-timeline-wrap {
  width: 100%;
  position: relative;
  padding: 0.5rem 0 0.75rem;
}

.sequence-timeline {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 0.4rem;
  row-gap: 1.2rem;
  padding: 0.5rem 0;
  position: relative;
}

.sequence-gap {
  flex: 1 1 70px;
  min-width: 54px;
  max-width: 110px;
  min-height: 140px;
  background: transparent;
  border: 2px dashed #555;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.6rem;
  font-weight: 700;
  padding: 0.5rem;
  transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.15s;
  z-index: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sequence-gap::before {
  content: '+';
  opacity: 0.7;
}

.sequence-gap:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(232, 160, 32, 0.08);
  transform: translateY(-2px);
}

.sequence-gap:focus-visible {
  outline: none;
  border-color: var(--accent);
  color: var(--accent);
}

.sequence-event {
  flex: 0 0 150px;
  min-height: 140px;
  background: var(--surface);
  border: 2px solid #555;
  border-radius: var(--radius);
  padding: 0.6rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  z-index: 1;
  position: relative;
  text-align: center;
  animation: sequenceAppear 0.35s ease-out;
}

@keyframes sequenceAppear {
  from { transform: scale(0.75); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.sequence-event::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  background: var(--accent);
  border: 2px solid var(--bg);
  border-radius: 50%;
}

.sequence-event.latest {
  border-color: #4caf50;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);
}

.sequence-event.latest::after {
  background: #4caf50;
}

.sequence-event.wrong {
  border-color: var(--error);
  background: rgba(224, 80, 80, 0.12);
}

.sequence-event.wrong::after {
  background: var(--error);
}

.sequence-event-year {
  font-weight: 700;
  color: var(--accent);
  font-size: 1.05rem;
  line-height: 1;
}

.sequence-event.latest .sequence-event-year {
  color: #4caf50;
}

.sequence-event.wrong .sequence-event-year {
  color: var(--error);
}

.sequence-event-desc {
  font-size: 0.72rem;
  line-height: 1.3;
  color: var(--text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  -webkit-box-orient: vertical;
}

@media (max-width: 640px) {
  .sequence-event {
    flex: 0 0 130px;
    min-height: 130px;
  }

  .sequence-gap {
    min-height: 130px;
    flex: 1 1 50px;
    min-width: 44px;
  }

  .sequence-current-card {
    font-size: 1rem;
  }
}

.error-msg {
  color: var(--error);
  font-size: 0.9rem;
  text-align: center;
}

/* ── Round screen header ── */

.round-header {
  width: 100%;
  max-width: 1100px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ── Event card ── */

.event-card {
  width: 100%;
  max-width: 900px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  border-left: 4px solid var(--accent);
  position: relative;
}

/* Hint reveal button + text — used across Classic / Matching / Sequence. */
.event-hint-wrap {
  display: block;
  margin-top: 0.6rem;
  font-size: 0.85rem;
}
.event-hint-wrap--classic,
.event-hint-wrap--sequence {
  margin-top: 0.75rem;
}
.btn-hint {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid #555;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1.4;
}
.btn-hint:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-hint.revealed {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(232, 160, 32, 0.08);
}
.event-hint-text {
  display: block;
  margin-top: 0.45rem;
  padding: 0.5rem 0.75rem;
  background: rgba(232, 160, 32, 0.08);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.9rem;
  font-style: normal;
  line-height: 1.45;
}
.event-hint-wrap--matching {
  margin-top: 0.4rem;
  font-size: 0.75rem;
}
.event-hint-wrap--matching .btn-hint {
  padding: 0.05rem 0.4rem;
  font-size: 0.75rem;
}
.event-hint-wrap--matching .event-hint-text {
  font-size: 0.8rem;
  padding: 0.35rem 0.55rem;
}

/* Classic result explanation — shown when points < 1000. */
.result-explanation {
  margin-top: 0.8rem;
  padding: 0.6rem 0.9rem;
  background: rgba(232, 160, 32, 0.08);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}

.event-card p {
  font-size: 1.2rem;
  font-style: italic;
  line-height: 1.6;
}

/* Shared speaker button (top-right of event cards across all modes). */
.speak-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.15s;
  z-index: 2;
}

.speak-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(232, 160, 32, 0.08);
  transform: scale(1.08);
}

.speak-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  color: var(--accent);
}

.speak-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.speak-btn.speaking {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(232, 160, 32, 0.12);
  animation: speakPulse 1.1s ease-in-out infinite;
}

@keyframes speakPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 160, 32, 0.35); }
  50%      { box-shadow: 0 0 0 6px rgba(232, 160, 32, 0); }
}

/* Smaller variant for matching / sequence cards which have tighter padding. */
.speak-btn.speak-btn-sm {
  width: 1.5rem;
  height: 1.5rem;
  font-size: 0.75rem;
  top: 0.25rem;
  right: 0.25rem;
  border-width: 1px;
}

/* ── Timeline widget ── */

.timeline-widget {
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.year-display {
  text-align: center;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 0.25rem;
}

/* ── Slider + ghost-line wrapper ─────────────────────────────────────── */
.slider-and-ghost {
  position: relative;
}

.ghost-line {
  position: absolute;
  top: 50%;
  width: 3px;
  height: 28px;
  transform: translateY(-50%) translateX(-50%);
  background: var(--accent-2);
  border-radius: 2px;
  box-shadow: 0 0 6px var(--accent-2);
  left: 0%;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  transition: left 0.55s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.12s ease;
}

.ghost-line.sweeping { opacity: 1; }

@keyframes ghostLand {
  0%   { box-shadow: 0 0 6px var(--accent-2); }
  40%  { box-shadow: 0 0 18px 6px var(--accent-2); }
  100% { box-shadow: 0 0 6px var(--accent-2); }
}

.ghost-line.landed {
  animation: ghostLand 0.45s ease-out;
}

input[type="range"] {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: #444;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #111;
  box-shadow: 0 0 0 2px var(--accent);
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #111;
}

input[type="range"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

input[type="range"]:disabled::-webkit-slider-thumb {
  cursor: not-allowed;
}

/* ── Tick marks ── */

.tick-marks {
  position: relative;
  height: 1.4rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.tick-marks span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
  line-height: 1;
}

/* ── Number input row ── */

.number-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.number-input-row label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

input[type="number"] {
  width: 110px;
  background: var(--surface);
  color: var(--text);
  border: 2px solid #444;
  border-radius: var(--radius);
  padding: 0.4rem 0.6rem;
  font-size: 1rem;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
}

input[type="number"]:focus {
  border-color: var(--accent);
}

input[type="number"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Remove spinner arrows */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* ── Result panel ── */

.result-panel {
  width: 100%;
  max-width: 900px;
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-top: 3px solid var(--accent);
}

.result-panel p {
  font-size: 1rem;
}

.points-earned {
  font-size: 1.1rem;
  margin-top: 0.5rem;
}

.result-panel .btn {
  align-self: flex-end;
  margin-top: 0.75rem;
}

/* ── Matching: correct-order reveal ── */
.matching-correct-order {
  width: 100%;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.matching-order-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted, #888);
  margin-bottom: 0.4rem;
}

.matching-order-list {
  list-style: decimal inside;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.matching-order-list li {
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text);
}

.matching-order-list .order-year {
  font-weight: 700;
  color: var(--accent);
}

/* ── Results screen ── */

.final-score {
  font-size: 1.4rem;
  text-align: center;
}

#results-table {
  width: 100%;
  max-width: 1100px;
  border-collapse: collapse;
  font-size: 0.95rem;
}

#results-table th,
#results-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #2e2e2e;
}

#results-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

#results-table td:nth-child(2) {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#results-table tr:last-child td {
  border-bottom: none;
}

/* ── Hamburger menu ── */

.menu-wrapper {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
}

.menu-toggle {
  width: 44px;
  height: 44px;
  background: var(--surface);
  border: 1px solid #3a3a3a;
  border-radius: var(--radius);
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}

.menu-toggle:hover {
  border-color: var(--accent);
}

.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

.menu-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle.open span:nth-child(2) { opacity: 0; }
.menu-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.menu-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid #3a3a3a;
  border-radius: var(--radius);
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.menu-item {
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 0.6rem 0.85rem;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
}

.menu-item .menu-icon {
  display: inline-flex;
  width: 1.25em;
  justify-content: center;
  font-size: 1.05em;
  line-height: 1;
}

.menu-item:hover {
  background: var(--surface-alt);
  color: var(--accent);
}

/* ── High-scores screen ── */

#screen-highscores {
  max-width: 900px;
}

.hs-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.hs-section h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.3px;
}

.hs-note {
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
  margin-top: -0.4rem;
}

.hs-table {
  width: 100%;
  max-width: 640px;
  border-collapse: collapse;
  font-size: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.hs-table th,
.hs-table td {
  padding: 0.75rem 1rem;
  text-align: center;
  border-bottom: 1px solid #2e2e2e;
}

.hs-table thead th {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  background: var(--surface-alt);
}

.hs-table tbody th {
  text-align: left;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
}

.hs-table tbody tr:last-child th,
.hs-table tbody tr:last-child td {
  border-bottom: none;
}

.hs-table td {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
}

.hs-table td.empty {
  color: var(--text-muted);
  font-weight: 400;
}

.era-list {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.era-row {
  display: grid;
  grid-template-columns: 130px 1fr 150px;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border-radius: var(--radius);
}

.era-name {
  font-weight: 600;
  color: var(--text);
}

.era-bar {
  height: 10px;
  background: #333;
  border-radius: 5px;
  overflow: hidden;
}

.era-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 5px;
  transition: width 0.4s ease-out;
}

.era-stat {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.era-stat strong {
  color: var(--accent);
  font-weight: 600;
}

.hs-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: #444;
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--error);
  color: var(--error);
}

.btn-danger {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}

.btn-danger:hover:not(:disabled) {
  background: #f06060;
  border-color: #f06060;
}

/* Quit confirmation modal */
.quit-modal-card {
  max-width: 360px;
  text-align: center;
}

.quit-modal-card h2 {
  margin-bottom: 0.5rem;
}

.quit-modal-body {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* Language selection modal (first-load + menu) */
.language-modal-card {
  max-width: 380px;
  text-align: center;
}

.language-modal-card h2 {
  margin-bottom: 0.25rem;
}

.language-modal-body {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.language-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.btn-language {
  background: var(--surface);
  color: var(--text);
  border: 2px solid #444;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  font-size: 1.05rem;
  padding: 0.75rem 1rem;
}

.btn-language:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-language.selected {
  border-color: var(--accent);
  background: rgba(232, 160, 32, 0.12);
  color: var(--accent);
}

.language-flag {
  font-size: 1.4rem;
  line-height: 1;
}

.language-flag-img {
  width: 20px;
  height: 15px;
  object-fit: cover;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 0.3rem;
}

/* Settings modal */
.settings-modal-card {
  max-width: 420px;
  text-align: left;
}

.settings-modal-card h2 {
  margin-bottom: 1.25rem;
  text-align: center;
}

.settings-section {
  margin-bottom: 1.5rem;
}

.settings-section .selector-label {
  display: block;
  margin-bottom: 0.5rem;
}

.volume-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.volume-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}

.volume-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.volume-pct {
  min-width: 3.2rem;
  text-align: right;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

/* ── Cosmetic Vault ─────────────────────────────────────────────────────── */

.vault-level-bar {
  font-size: 0.88rem;
  color: var(--text-muted, #aaa);
  margin-bottom: 1rem;
}

/* ── Multiplayer ─────────────────────────────────────────────────────────── */

.btn-multiplayer {
  min-width: 8rem;
  padding: 0.55rem 1.4rem;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.btn-multiplayer:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-multiplayer.selected {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}

.multiplayer-share-box {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
  max-width: 540px;
  margin: 0.4rem 0;
}

.multiplayer-share-input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-multiplayer-copy {
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-multiplayer-copy:hover {
  background: var(--accent-hover);
}

.multiplayer-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0.75rem;
  text-align: center;
  max-width: 420px;
}

.multiplayer-lobby {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 480px;
  margin-top: 0.5rem;
  padding: 1rem 1.2rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
}

.vault-level-bar strong { color: var(--accent); }

.vault-grid {
  width: 100%;
  max-width: 680px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.vault-card {
  background: #1a1726;
  border: 1.5px solid #2a2540;
  border-radius: 10px;
  padding: 0.85rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  transition: border-color 0.2s;
}

.vault-card.vault-unlocked {
  border-color: #3a3560;
}

.vault-card.vault-active {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(var(--accent-rgb, 232,160,32), 0.25);
}

.vault-card.vault-locked {
  opacity: 0.55;
}

/* Slider thumb preview (a small swatch) */
.vault-thumb-preview {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #555;
  flex-shrink: 0;
}
.vault-card.vault-active .vault-thumb-preview { border-color: var(--accent); }

/* Default thumb preview color */
.vault-thumb-preview.thumb-default   { background: var(--accent, #E8A020); }
.vault-thumb-preview.thumb-gilded    { background: radial-gradient(circle, #ffe066 30%, #c8900a 100%); border-color: #c8900a; }
.vault-thumb-preview.thumb-sapphire  { background: radial-gradient(circle, #80d8ff 30%, #0070c0 100%); border-color: #0070c0; }
.vault-thumb-preview.thumb-prestige  { background: conic-gradient(#e8a020 0%, #c060e8 40%, #40f0ff 70%, #e8a020 100%); }
.vault-thumb-preview.thumb-easter1984{ background: radial-gradient(circle, #cc2222 30%, #440000 100%); border-color: #cc2222; }
.vault-thumb-preview.thumb-unknown   { background: #222; }

.vault-card-name {
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  color: #e0d8f0;
}

.vault-card-flavor {
  font-size: 0.73rem;
  color: #887aaa;
  text-align: center;
  line-height: 1.3;
}

.vault-card-lock {
  font-size: 0.75rem;
  color: #666;
}

.btn-vault-activate {
  font-size: 0.75rem;
  padding: 0.2rem 0.65rem;
  border-radius: 5px;
  background: var(--accent);
  color: #000;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.btn-vault-activate:disabled {
  background: #3a3560;
  color: #666;
  cursor: default;
}

/* ── Cosmetic slider thumb skins ─────────────────────────────────────────── */

/* Gilded Quill — golden thumb */
body.cosmetic-gilded input[type="range"]::-webkit-slider-thumb {
  background: #FFD700;
  box-shadow: 0 0 8px rgba(255,215,0,0.6), 0 0 2px #c8900a;
  border-color: #c8900a;
}
body.cosmetic-gilded input[type="range"]::-moz-range-thumb {
  background: #FFD700;
  box-shadow: 0 0 8px rgba(255,215,0,0.6);
  border-color: #c8900a;
}

/* Scholar's Sapphire — cyan/blue thumb */
body.cosmetic-sapphire input[type="range"]::-webkit-slider-thumb {
  background: #4FC3F7;
  box-shadow: 0 0 10px rgba(79,195,247,0.7);
  border-color: #0070c0;
}
body.cosmetic-sapphire input[type="range"]::-moz-range-thumb {
  background: #4FC3F7;
  box-shadow: 0 0 10px rgba(79,195,247,0.7);
  border-color: #0070c0;
}

/* Prestige — pulsing rainbow ring */
body.cosmetic-prestige input[type="range"]::-webkit-slider-thumb {
  background: var(--accent);
  box-shadow: 0 0 14px rgba(192,96,232,0.8), 0 0 3px rgba(64,240,255,0.5);
  border-color: #c060e8;
  animation: prestigePulse 1.8s ease-in-out infinite;
}
body.cosmetic-prestige input[type="range"]::-moz-range-thumb {
  background: var(--accent);
  box-shadow: 0 0 14px rgba(192,96,232,0.8);
  border-color: #c060e8;
}

@keyframes prestigePulse {
  0%,100% { box-shadow: 0 0 10px rgba(232,160,32,0.7); }
  33%     { box-shadow: 0 0 14px rgba(192,96,232,0.9); }
  66%     { box-shadow: 0 0 14px rgba(64,240,255,0.8); }
}

/* 1984 Easter Egg — dark crimson thumb, slightly eerie */
body.cosmetic-1984 input[type="range"]::-webkit-slider-thumb {
  background: #cc2222;
  box-shadow: 0 0 10px rgba(180,0,0,0.8);
  border-color: #880000;
}
body.cosmetic-1984 input[type="range"]::-moz-range-thumb {
  background: #cc2222;
  box-shadow: 0 0 10px rgba(180,0,0,0.8);
  border-color: #880000;
}


.best-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.5rem;
  background: rgba(232, 160, 32, 0.15);
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  vertical-align: middle;
}

@media (max-width: 640px) {
  .era-row {
    grid-template-columns: 100px 1fr;
    grid-template-rows: auto auto;
  }
  .era-stat {
    grid-column: 1 / -1;
    text-align: left;
  }
}

/* ── Achievements screen ── */

#screen-achievements {
  max-width: 900px;
}

.achievement-summary {
  color: var(--text-muted);
  font-size: 0.95rem;
  text-align: center;
  letter-spacing: 0.3px;
}

.achievement-summary strong {
  color: var(--accent);
  font-weight: 700;
}

/* ── Historian's Journal ────────────────────────────────────────────────── */

.journal-heading {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
}

.journal-stats-bar {
  font-size: 0.88rem;
  color: var(--text-muted, #aaa);
  margin-bottom: 1rem;
}

.journal-stats-bar strong {
  color: var(--accent);
}

.journal-list {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.journal-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: #1a1726;
  border-left: 3px solid transparent;
}

.journal-entry.journal-correct {
  border-left-color: var(--accent);
}

.journal-entry.journal-redacted {
  border-left-color: #333;
  opacity: 0.7;
}

.journal-year-stamp {
  flex-shrink: 0;
  min-width: 4.5rem;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: 4px;
  padding: 0.15rem 0.35rem;
  letter-spacing: 0.03em;
}

.journal-entry.journal-redacted .journal-year-stamp {
  color: #666;
  border-color: #444;
}

.journal-desc-text {
  font-size: 0.85rem;
  color: #d0cce0;
  line-height: 1.35;
}

.journal-entry.journal-redacted .journal-desc-text {
  background: #2a2535;
  color: transparent;
  border-radius: 3px;
  user-select: none;
  letter-spacing: -0.02em;
}

.journal-empty {
  font-size: 0.95rem;
  color: var(--text-muted, #aaa);
  text-align: center;
  padding: 2rem 0;
}

.achievement-list {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* "Hide unlocked" toggle on the achievements screen. */
.achievement-toggle {
  width: 100%;
  max-width: 760px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0 0.75rem;
  font-size: 0.9rem;
  color: var(--muted, #aaa);
  cursor: pointer;
  user-select: none;
}
.achievement-toggle input[type="checkbox"] {
  accent-color: var(--accent, #E8A020);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Difficulty-tier section header in the achievements list. */
.achievement-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.9rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.85rem;
  border: 1px solid transparent;
}
.achievement-section-header:first-child { margin-top: 0; }

.achievement-section-title { }
.achievement-section-count {
  font-weight: 600;
  opacity: 0.85;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-transform: none;
}

/* Tier-specific tints */
.achievement-section-header.tier-easy {
  background: rgba(80, 170, 90, 0.14);
  border-color: rgba(80, 170, 90, 0.40);
  color: #6cc47a;
}
.achievement-section-header.tier-medium {
  background: rgba(80, 140, 220, 0.14);
  border-color: rgba(80, 140, 220, 0.40);
  color: #85b2ff;
}
.achievement-section-header.tier-hard {
  background: rgba(220, 120, 60, 0.14);
  border-color: rgba(220, 120, 60, 0.40);
  color: #ff9f66;
}
.achievement-section-header.tier-extreme {
  background: linear-gradient(90deg, rgba(200, 60, 160, 0.20), rgba(232, 160, 32, 0.22));
  border-color: rgba(232, 160, 32, 0.55);
  color: #ffc97a;
  text-shadow: 0 0 8px rgba(232, 160, 32, 0.35);
}

.achievement-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 0.9rem;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid #2e2e2e;
  border-radius: var(--radius);
  transition: border-color 0.2s, background 0.2s;
}

.achievement-row.unlocked {
  border-color: rgba(232, 160, 32, 0.55);
  background: linear-gradient(135deg, rgba(232, 160, 32, 0.08), var(--surface) 55%);
}

.achievement-icon {
  width: 36px;
  height: 36px;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, transform 0.2s;
}

.achievement-icon svg {
  width: 100%;
  height: 100%;
}

.achievement-row.unlocked .achievement-icon {
  color: var(--accent);
  filter: drop-shadow(0 0 6px rgba(232, 160, 32, 0.45));
}

.achievement-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.achievement-name {
  font-weight: 700;
  color: var(--text);
  font-size: 1rem;
}

.achievement-row.unlocked .achievement-name {
  color: var(--accent);
}

.achievement-desc {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.achievement-bar {
  margin-top: 0.35rem;
  height: 6px;
  background: #2c2c2c;
  border-radius: 3px;
  overflow: hidden;
}

.achievement-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 3px;
  transition: width 0.5s ease-out;
}

.achievement-row:not(.unlocked) .achievement-fill {
  background: linear-gradient(90deg, #666, #888);
}

.achievement-stat {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.achievement-row.unlocked .achievement-stat {
  color: var(--accent);
  font-weight: 600;
}

@media (max-width: 560px) {
  .achievement-row {
    grid-template-columns: 34px 1fr;
    grid-template-rows: auto auto;
  }
  .achievement-icon { width: 28px; height: 28px; }
  .achievement-stat { grid-column: 1 / -1; text-align: left; }
}


/* ── Joey the Archivist mascot ────────────────────────────────────────── */

.joey-wrap {
  position: fixed;
  bottom: 1.5rem;
  right: 1rem;
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  z-index: 8500;
  pointer-events: none;
  opacity: 1;
}

.joey-wrap.hidden {
  display: none;
}

.joey-speech {
  background: #12101c;
  border: 1.5px solid var(--accent);
  border-radius: 10px 10px 0 10px;
  padding: 0.5rem 0.7rem;
  font-size: 0.82rem;
  color: #e0d8f0;
  max-width: 175px;
  line-height: 1.45;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}

.joey-figure {
  flex-shrink: 0;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.5));
}

@keyframes joeySlideIn {
  from { transform: translateX(100px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

@keyframes joeySlideOut {
  from { transform: translateX(0);     opacity: 1; }
  to   { transform: translateX(100px); opacity: 0; }
}

.joey-wrap.joey-enter {
  animation: joeySlideIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.joey-wrap.joey-exit {
  animation: joeySlideOut 0.35s ease-in forwards;
}

/* ── Share link snackbar ── */

.share-snackbar {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: #1e293b;
  color: #e2e8f0;
  padding: 0.65rem 1.4rem;
  border-radius: 2rem;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 9000;
  box-shadow: 0 4px 18px rgba(0,0,0,.45);
  opacity: 1;
  transition: opacity 0.4s ease, transform 0.3s ease;
  pointer-events: none;
}
.share-snackbar.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(1.5rem);
  pointer-events: none;
}

/* ── Achievement unlock toast ── */

.achievement-toast {
  position: fixed;
  top: 1.25rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 300px;
  max-width: 380px;
  padding: 0.9rem 1.2rem;
  background: linear-gradient(135deg, #2a2a2a 0%, #1c1c1c 100%);
  border: 2px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6), 0 0 0 4px rgba(232, 160, 32, 0.12);
  transform: translateX(calc(100% + 3rem));
  opacity: 0;
  transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2), opacity 0.3s;
  pointer-events: none;
}

.achievement-toast.showing {
  transform: translateX(0);
  opacity: 1;
}

.achievement-toast.hidden {
  display: none;
}

.achievement-toast-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  color: var(--accent);
  filter: drop-shadow(0 0 8px rgba(232, 160, 32, 0.6));
  animation: trophySpin 1.8s ease-in-out infinite;
}

@keyframes trophySpin {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25%      { transform: scale(1.12) rotate(-8deg); }
  75%      { transform: scale(1.12) rotate(8deg); }
}

.achievement-toast-content {
  min-width: 0;
}

.achievement-toast-label {
  color: var(--accent);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
}

.achievement-toast-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 0.15rem;
  line-height: 1.2;
}

.achievement-toast-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  line-height: 1.35;
}

/* ── Location mode ── */

.location-event-card {
  width: 100%;
  max-width: 900px;
}

.location-year-label {
  display: inline-block;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.location-map-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.location-map {
  position: relative;
  width: 100%;
  max-width: 1200px;
  aspect-ratio: 4 / 3;
  background: #0d1520;
  border: 1px solid #333;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: crosshair;
}

.location-map-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.location-map-svg {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.map-ocean {
  fill: #A8D8F0;
}

.map-land {
  fill: #F9F2E4;
  stroke: none;
}

/* Historical basemap polygons are drawn on top of the 10m land fill.
   Give them the same fill colour so they don't change the land appearance;
   inland political borders are supplied separately by .map-border-lines. */
.map-borders .map-border {
  fill: #F9F2E4;
  stroke: none;
}

.map-border-lines .map-border-line {
  fill: none;
  stroke: #888;
  stroke-width: 0.6;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

/* 10m Natural Earth lakes — filled with the ocean colour so they read as water. */
.map-lakes .map-lake {
  fill: #A8D8F0;
  stroke: #7ab8d6;
  stroke-width: 0.3;
  vector-effect: non-scaling-stroke;
}

.map-graticule {
  display: none;
}

.map-rivers .map-river {
  fill: none;
  stroke: #A8D8F0;
  stroke-width: 1.4;
  opacity: 0.9;
  vector-effect: non-scaling-stroke;
}

.map-pin-layer {
  pointer-events: none;
}

.map-pin-shadow {
  fill: rgba(0, 0, 0, 0.5);
}

.map-pin.guess .map-pin-head {
  fill: var(--accent);
  stroke: #fff;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.map-pin.guess .map-pin-stem {
  stroke: var(--accent);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.map-pin.actual .map-pin-head {
  fill: #58d97a;
  stroke: #fff;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.map-pin.actual .map-pin-stem {
  stroke: #58d97a;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.map-connector {
  stroke: rgba(232, 160, 32, 0.55);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
  vector-effect: non-scaling-stroke;
}

.map-zoom-controls {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 10;
}

.map-zoom-btn {
  width: 2rem;
  height: 2rem;
  background: rgba(13, 21, 32, 0.88);
  color: var(--text);
  border: 1px solid #444;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.map-zoom-btn:hover:not(:disabled) {
  background: rgba(30, 40, 55, 0.95);
  border-color: var(--accent);
  color: var(--accent);
}

.map-zoom-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.map-zoom-reset {
  font-size: 0.9rem;
}

/* Sequence life pips — only visible when MP grants >1 life. */
.sequence-lives {
  display: inline-flex;
  gap: 0.2rem;
  align-items: center;
  font-size: 1rem;
}
.sequence-lives .life-pip {
  color: var(--accent-3, #f06292);
  text-shadow: 0 0 6px rgba(240, 98, 146, 0.45);
  transition: color 0.25s, transform 0.25s, text-shadow 0.25s;
}
.sequence-lives .life-pip.spent {
  color: #444;
  text-shadow: none;
  transform: scale(0.85);
}

/* ─────────────────────────────────────────────────────────────────────────
   MULTIPLAYER — Custom Game setup + per-round wheel
   ───────────────────────────────────────────────────────────────────────── */

.mp-setup-wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 0.5rem 0.5rem 4rem;
}
.mp-setup-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.mp-setup-header .mp-setup-title {
  color: var(--accent);
  font-size: 1.4rem;
  margin: 0;
  flex: 1;
}
.btn-mp-info {
  background: transparent;
  border: 1px solid #555;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
}
.btn-mp-info:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Seismic-shift on each chip change */
#screen-mp-setup .mp-shaker { transition: transform 0.05s linear; }
#screen-mp-setup .mp-shaker.seismic { animation: mpSeismic 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes mpSeismic {
  0%, 100% { transform: translate(0, 0); }
  10%      { transform: translate(-3px, 1px); }
  20%      { transform: translate(4px, -2px); }
  30%      { transform: translate(-5px, 2px); }
  40%      { transform: translate(6px, 1px); }
  50%      { transform: translate(-6px, -2px); }
  60%      { transform: translate(5px, 2px); }
  70%      { transform: translate(-3px, -1px); }
  80%      { transform: translate(2px, 2px); }
  90%      { transform: translate(-1px, -1px); }
}

#screen-mp-setup .mp-axis {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
#screen-mp-setup .axis-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
#screen-mp-setup .axis-label {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
#screen-mp-setup .axis-era-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  margin-left: 0.4rem;
}
#screen-mp-setup .axis-combined {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
  min-height: 1.5em;
  letter-spacing: 0.02em;
}
#screen-mp-setup .axis-combined:empty::before {
  content: 'none selected';
  color: var(--text-muted);
  font-weight: 400;
  font-style: italic;
  font-size: 0.9rem;
  letter-spacing: 0;
}

#screen-mp-setup .axis-chips {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}
#screen-mp-setup .chip {
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid #444;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
#screen-mp-setup .chip:hover:not(.selected):not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
#screen-mp-setup .chip.selected {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
  font-weight: 700;
  box-shadow: 0 0 10px rgba(232, 160, 32, 0.45);
}
#screen-mp-setup .chip:disabled { opacity: 0.3; cursor: not-allowed; }

#screen-mp-setup .axis-combined.smashing { animation: mpSmash 0.55s cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes mpSmash {
  0%   { opacity: 0; transform: translateX(-25%) scale(0.7); filter: blur(5px); }
  40%  { opacity: 1; transform: translateX(8%) scale(1.18); filter: blur(0); }
  70%  { transform: translateX(-3%) scale(0.96); }
  100% { transform: translateX(0) scale(1); }
}
#screen-mp-setup .axis-combined .pill {
  display: inline-block;
  background: rgba(232, 160, 32, 0.15);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0.1rem 0.2rem;
  letter-spacing: 0;
  animation: mpPillClack 0.4s ease-out;
}
@keyframes mpPillClack {
  0%   { transform: translateY(-6px) scale(0.6); opacity: 0; }
  60%  { transform: translateY(2px) scale(1.1); opacity: 1; }
  100% { transform: translateY(0) scale(1); }
}

#screen-mp-setup .mp-configs {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  border-left: 3px solid var(--accent-2, #3ac9b0);
}
#screen-mp-setup .mp-configs.empty { opacity: 0.6; }
#screen-mp-setup .config-row {
  display: grid;
  grid-template-columns: 160px 1fr 60px;
  gap: 1rem;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
#screen-mp-setup .config-row:last-child { border-bottom: none; }
#screen-mp-setup .config-row .cfg-label {
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
}
#screen-mp-setup .config-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
#screen-mp-setup .config-row .cfg-value {
  text-align: right;
  font-weight: 800;
  color: var(--accent);
  font-size: 1.05rem;
  min-width: 2.5ch;
}
#screen-mp-setup .config-row .cfg-pips {
  grid-column: 2 / 4;
  display: flex;
  gap: 0.3rem;
  margin-top: 0.25rem;
  justify-content: flex-start;
}
#screen-mp-setup .config-row .cfg-pips .pip {
  width: 14px; height: 14px;
  background: #444;
  border-radius: 50%;
  transition: background 0.2s, transform 0.2s;
}
#screen-mp-setup .config-row .cfg-pips .pip.on {
  background: var(--accent-3, #f06292);
  box-shadow: 0 0 6px rgba(240, 98, 146, 0.7);
  transform: scale(1.1);
}

.mp-action-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}
.btn-mp-start, .btn-mp-share {
  font-size: 1rem;
  padding: 0.7rem 1.3rem;
}
.mp-disclaimer {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── MP WHEEL SCREEN ──────────────────────────────────────────────────── */
.mp-wheel-wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 1rem;
  text-align: center;
}
.mp-wheel-title {
  color: var(--accent);
  font-size: 1.3rem;
  margin-bottom: 1.25rem;
}
.mp-wheel-wrap .wheels-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 700px) {
  .mp-wheel-wrap .wheels-row { grid-template-columns: repeat(2, 1fr); }
}
.mp-wheel-wrap .wheel-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.mp-wheel-wrap .slot-label {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.mp-wheel-wrap .wheel-host {
  position: relative;
  width: 150px;
  height: 150px;
  max-width: 100%;
}
.mp-wheel-wrap .wheel-host.nope { animation: mpWheelNope 0.4s ease-out; }
@keyframes mpWheelNope {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px) rotate(-2deg); }
  50% { transform: translateX(6px) rotate(2deg); }
  75% { transform: translateX(-4px) rotate(-1deg); }
}
.mp-wheel-wrap .wheel-host .wheel-pointer {
  position: absolute;
  top: -6px; left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 14px solid var(--accent);
  z-index: 2;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
}
.mp-wheel-wrap .wheel-host .wheel-dial {
  position: absolute;
  inset: 0;
  transform-box: border-box;
  transform-origin: 50% 50%;
  transition: transform 2.2s cubic-bezier(0.18, 0.72, 0.21, 1.0);
  will-change: transform;
  backface-visibility: hidden;
}
.mp-wheel-wrap .wheel-host svg {
  width: 100%;
  height: 100%;
  display: block;
}
.mp-wheel-wrap .wheel-host svg text {
  font-family: system-ui, sans-serif;
  font-weight: 700;
  font-size: 11px;
  fill: #111;
}
.mp-wheel-wrap .wheel-host.auto-pick {
  width: 0; height: 0; min-height: 0;
}
.mp-wheel-wrap .slot-result {
  min-height: 1.5em;
  font-weight: 700;
  color: var(--accent);
  font-size: 0.95rem;
  text-align: center;
}
.mp-wheel-wrap .slot-result.nope { color: var(--error); font-style: italic; font-weight: 500; }
.mp-wheel-wrap .slot-result.resolved { animation: mpResultPop 0.35s cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes mpResultPop {
  0%   { opacity: 0; transform: scale(0.7); }
  60%  { opacity: 1; transform: scale(1.15); }
  100% { transform: scale(1); }
}
.mp-wheel-wrap .wheel-slot:has(.wheel-host.auto-pick) .slot-result.resolved {
  animation: mpAutoFlash 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
  padding: 0.35rem 0.9rem;
  background: var(--accent);
  color: #111;
  border-radius: 999px;
  display: inline-block;
  font-weight: 800;
  box-shadow: 0 0 12px rgba(232, 160, 32, 0.45);
}
@keyframes mpAutoFlash {
  0%   { transform: scale(0.6); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}
.mp-wheel-wrap .round-final {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: rgba(240, 98, 146, 0.08);
  border-left: 3px solid var(--accent-3, #f06292);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  text-align: left;
}
.mp-wheel-wrap .round-final:empty { display: none; }
.mp-wheel-actions {
  margin-top: 1rem;
}

/* ── MP EXPLANATION MODAL ───────────────────────────────────────────── */
.mp-explain-pop {
  max-width: 520px;
}
.mp-explain-pop h3 {
  color: var(--accent);
  margin-bottom: 0.9rem;
  animation: mpExplainTitleIn 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: 0.1s;
  text-shadow: 0 0 16px rgba(232, 160, 32, 0);
}
.mp-explain-body p {
  margin-bottom: 0.75rem;
  color: var(--text);
  line-height: 1.55;
}
.mp-explain-body p strong {
  color: var(--accent);
}
.mp-explain-body p em {
  color: var(--accent-3, #f06292);
  font-style: normal;
  font-weight: 600;
}
#mp-explain-modal:not(.hidden) .mp-explain-line {
  animation: mpExplainFadeUp 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
#mp-explain-modal:not(.hidden) .mp-explain-line:nth-child(1) { animation-delay: 0.25s; }
#mp-explain-modal:not(.hidden) .mp-explain-line:nth-child(2) { animation-delay: 0.37s; }
#mp-explain-modal:not(.hidden) .mp-explain-line:nth-child(3) { animation-delay: 0.49s; }
#mp-explain-modal:not(.hidden) .mp-explain-line:nth-child(4) { animation-delay: 0.61s; }
#mp-explain-modal:not(.hidden) .mp-explain-line:nth-child(5) { animation-delay: 0.73s; }

#mp-explain-modal:not(.hidden) #btn-mp-explain-close {
  animation: mpExplainFadeUp 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: 0.9s;
}

.mp-explain-caveat {
  padding: 0.6rem 0.8rem;
  background: rgba(232, 160, 32, 0.08);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  margin-top: 0.5rem;
  animation: mpExplainFadeUp 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both,
             mpExplainGlow 2.4s ease-in-out 1.6s infinite;
}

@keyframes mpExplainTitleIn {
  0%   { opacity: 0; transform: translateY(-8px) scale(0.92); text-shadow: 0 0 30px rgba(232, 160, 32, 0.8); }
  60%  { opacity: 1; transform: translateY(0) scale(1.04); }
  100% { opacity: 1; transform: translateY(0) scale(1); text-shadow: 0 0 0 rgba(232, 160, 32, 0); }
}
@keyframes mpExplainFadeUp {
  0%   { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes mpExplainGlow {
  0%, 100% { box-shadow: 0 0 0 rgba(232, 160, 32, 0); }
  50%      { box-shadow: 0 0 18px rgba(232, 160, 32, 0.28); }
}

.location-map-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

.location-attribution {
  color: var(--text-muted);
  font-size: 0.72rem;
  text-align: center;
  margin-top: 0.5rem;
}

.location-attribution a {
  color: var(--text-muted);
  text-decoration: underline;
}

.location-attribution a:hover {
  color: var(--accent);
}

/* ── Responsive ── */

@media (max-width: 520px) {
  h1 {
    font-size: 2.2rem;
  }

  .year-display {
    font-size: 1.9rem;
  }

  .event-card {
    padding: 1.25rem 1.25rem;
  }

  .event-card p {
    font-size: 1.05rem;
  }

  .tick-marks {
    font-size: 0.62rem;
    gap: 0;
  }

  .result-panel {
    padding: 1.25rem 1.25rem;
  }

  #results-table td:nth-child(2) {
    max-width: 120px;
  }

  .number-input-row {
    flex-direction: column;
    align-items: center;
  }
}

/* On very short / cramped viewports, hide the slider timeline so the event
   question stays readable. The numeric year input remains available. */
@media (max-height: 560px), (max-width: 360px) {
  #screen-round .slider-and-ghost,
  #screen-round .tick-marks {
    display: none;
  }
}

/* ─────────────────────────────────────────────────────────────────────────
   Profile system: top-right badge, modal, character grid, level badge
   ───────────────────────────────────────────────────────────────────────── */

.profile-badge-wrapper {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
}

.profile-badge {
  background: var(--surface);
  border: 1px solid #3a3a3a;
  border-radius: var(--radius-lg);
  padding: 0.45rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s;
  min-height: 52px;
}

.profile-badge:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-playful);
}

.profile-badge.empty {
  color: var(--text-muted);
  font-style: italic;
}

.profile-badge-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-alt);
  flex: 0 0 auto;
  transition: opacity 0.4s;
}

.profile-badge-avatar svg {
  display: block;
  width: 100%;
  height: 100%;
}

.profile-badge-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
  max-width: 140px;
}

.profile-badge-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.profile-badge-title {
  font-size: 0.72rem;
  color: var(--accent-3);
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

/* Level badge — circular, conic-gradient progress ring */
.level-badge {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--lvl-pct, 0) * 1%), #333 0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  position: relative;
}

.level-badge::before {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--surface);
}

.level-badge .level-num {
  position: relative;
  z-index: 1;
  color: var(--accent);
  line-height: 1;
}

.level-badge.milestone::after {
  content: '★';
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 0.8rem;
  color: var(--accent-3);
  z-index: 2;
  background: var(--surface);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Modal overlay (shared by profile + milestone) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  background: var(--surface);
  border: 1px solid #3a3a3a;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-card);
  animation: modalPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.modal-close:hover {
  color: var(--accent);
  background: var(--surface-alt);
}

.modal-card h2 {
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

/* Profile modal specifics */
.profile-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.profile-field .selector-label {
  text-align: left;
}

.profile-field input[type="text"] {
  padding: 0.55rem 0.75rem;
  background: var(--surface-alt);
  border: 1px solid #3a3a3a;
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.15s;
}

.profile-field input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.gender-toggle {
  display: flex;
  gap: 0.75rem;
}

.gender-toggle label {
  flex: 1;
  padding: 0.5rem 0.9rem;
  background: var(--surface-alt);
  border: 1px solid #3a3a3a;
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.gender-toggle input[type="radio"] {
  accent-color: var(--accent);
}

.gender-toggle label:has(input:checked) {
  border-color: var(--accent);
  background: rgba(232, 160, 32, 0.12);
  color: var(--accent);
}

/* Character grid */
.character-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}


.character-card {
  background: linear-gradient(140deg, var(--surface-alt), var(--surface));
  border: 2px solid #3a3a3a;
  border-radius: var(--radius);
  padding: 0.5rem 0.35rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  position: relative;
  font-family: inherit;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 0;
}

.character-card:hover:not(.locked) {
  transform: scale(1.06);
  border-color: var(--accent-2);
  box-shadow: 0 4px 14px rgba(58, 201, 176, 0.22);
}

.character-card.selected {
  border-color: var(--accent-2);
  background: linear-gradient(140deg, rgba(58, 201, 176, 0.14), var(--surface));
  color: var(--text);
}

.character-card.locked {
  cursor: not-allowed;
  opacity: 0.55;
  filter: grayscale(0.7);
}

.character-card.locked::after {
  content: '🔒';
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.8rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
}

.character-card-preview {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.character-card-preview svg {
  display: block;
  width: 100%;
  height: 100%;
}

.character-card-label {
  font-size: 0.72rem;
  text-align: center;
  line-height: 1.1;
  word-break: break-word;
  overflow-wrap: anywhere;
  width: 100%;
}

#profile-title-select {
  padding: 0.55rem 0.75rem;
  background: var(--surface-alt);
  border: 1px solid #3a3a3a;
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}

/* Milestone celebration */
.milestone-card {
  text-align: center;
  max-width: 420px;
  border-color: var(--accent-3);
  border-width: 2px;
  background: linear-gradient(160deg, var(--surface) 0%, rgba(240, 98, 146, 0.12) 100%);
}

.milestone-sparkle {
  font-size: 2.4rem;
  animation: sparkle 1.2s ease-in-out infinite alternate;
}

@keyframes sparkle {
  from { transform: scale(1) rotate(-5deg); }
  to   { transform: scale(1.12) rotate(5deg); }
}

.milestone-label {
  font-size: 0.85rem;
  color: var(--accent-3);
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 0.25rem;
}

.milestone-level {
  font-size: 4.5rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
  margin: 0.25rem 0 0.75rem;
  text-shadow: 0 2px 16px rgba(232, 160, 32, 0.4);
}

.milestone-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.milestone-reward {
  font-size: 1rem;
  color: var(--accent-2);
  font-weight: 600;
  margin-bottom: 1.2rem;
}

.milestone-card .btn-primary {
  min-width: 140px;
}

/* Next-up panel (end-of-game summary) */
.next-up-panel {
  background: var(--surface);
  border: 1px solid #3a3a3a;
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-top: 1rem;
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.next-up-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

.next-up-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.next-up-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 600;
}

.next-up-row-head .next-up-count {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.82rem;
}

.next-up-bar {
  height: 6px;
  background: var(--surface-alt);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.next-up-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width 0.35s ease-out;
}

.next-up-row.next-up-achievement .next-up-bar-fill {
  background: linear-gradient(90deg, var(--accent-2), var(--accent-2-hover));
}

.next-up-row.next-up-level .next-up-row-head .next-up-label {
  color: var(--accent);
}

/* Avatar pose crossfade transition on the profile badge */
.profile-badge-avatar.pose-switching svg {
  animation: poseFade 0.4s ease;
}

@keyframes poseFade {
  0%   { opacity: 0.3; transform: scale(0.96); }
  100% { opacity: 1;   transform: scale(1); }
}

/* ── Result-tier cinematic stingers ─────────────────────────────────── */

@keyframes stingerBronze {
  0%   { filter: saturate(0.1) brightness(0.65); }
  25%  { filter: saturate(0.4) brightness(0.8); }
  100% { filter: saturate(1)   brightness(1); }
}
@keyframes stingerSilver {
  0%   { transform: translateY(0); }
  6%   { transform: translateY(-4px); }
  14%  { transform: translateY(4px); }
  22%  { transform: translateY(-2px); }
  30%  { transform: translateY(2px); }
  100% { transform: translateY(0); }
}
@keyframes stingerGold {
  0%   { filter: brightness(1)   saturate(1); }
  12%  { filter: brightness(1.5) saturate(1.5); }
  100% { filter: brightness(1)   saturate(1); }
}
@keyframes stingerPlatinum {
  0%   { filter: brightness(1)   saturate(1); }
  7%   { filter: brightness(2.8) saturate(0); }
  18%  { filter: brightness(1.6) saturate(1.3); }
  100% { filter: brightness(1)   saturate(1); }
}

body.stinger-bronze   { animation: stingerBronze   1.6s ease-out forwards; }
body.stinger-silver   { animation: stingerSilver   0.45s ease-out; }
body.stinger-gold     { animation: stingerGold     1.1s ease-out; }
body.stinger-platinum { animation: stingerPlatinum 1.4s ease-out; }

/* ── Number Tumbler ──────────────────────────────────────────────────── */

@keyframes tumblerPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.tumbler-pop {
  display: inline-block;
  animation: tumblerPop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Intro Cinematic ─────────────────────────────────────────────────── */

#screen-intro {
  background: #06060f;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 100vh;
  overflow: hidden;
  transition: opacity 0.7s ease;
}

#screen-intro.intro-fading {
  opacity: 0;
  pointer-events: none;
}

/* Logo sits in the flex flow above the studio credit */
#intro-logo {
  position: relative;
  width: clamp(64px, 16vmin, 110px);
  height: clamp(64px, 16vmin, 110px);
  opacity: 0;
  z-index: 1;
  pointer-events: none;
  transform: scale(0.7);
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#intro-logo.visible {
  opacity: 1;
  transform: scale(1);
}

/* Triggered by JS once the text content takes over */
#intro-logo.logo-fade-out {
  opacity: 0;
  transition: opacity 1.8s ease;
}

#intro-logo svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 28px rgba(232, 160, 32, 0.65));
}

/* Studio credit — sits below the logo */
#intro-studio-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  position: relative;
  z-index: 1;
}

#intro-mike-joey {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  font-weight: 700;
  color: #e8e8e8;
  letter-spacing: 0.08em;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

#intro-mike-joey.visible {
  opacity: 1;
  transform: translateY(0);
}

#intro-presents {
  font-size: clamp(0.85rem, 2vw, 1.1rem);
  color: #888;
  font-style: italic;
  letter-spacing: 0.12em;
  margin-left: 1.5rem;
  opacity: 0;
  transition: opacity 0.6s ease;
}

#intro-presents.visible {
  opacity: 1;
}

/* Title sits above the logo, on one line regardless of screen width */
#intro-title-wrap {
  font-size: clamp(1.2rem, 5.5vw, 4.5rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #e8a020;
  text-align: center;
  white-space: nowrap;       /* prevents "Events" from dropping to a second line */
  text-shadow: 0 0 40px rgba(232, 160, 32, 0.35);
  position: relative;
  z-index: 1;
}

.intro-letter {
  display: inline-block;
  opacity: 0;
  transform: translateY(14px) scale(0.75);
  transition: opacity 0.13s ease, transform 0.13s ease;
}

.intro-letter.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.intro-space {
  min-width: 0.4em;
}

/* ── Singleplayer setup wrapper ──────────────────────────────────────── */

#singleplayer-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
}

.btn-back-to-gate {
  align-self: flex-start;
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--surface-alt);
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-back-to-gate:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* ── Theme chrome — Chaos ────────────────────────────────────────────── */
body.theme-chaos {
  --accent:         #ff4dff;
  --accent-hover:   #ff80ff;
  --shadow-playful: 0 6px 20px rgba(255, 77, 255, 0.25);
}

body.theme-chaos h1,
body.theme-chaos h2 {
  text-shadow: 0 0 12px rgba(255, 77, 255, 0.45);
}

/* Animated rainbow scanline overlay for Chaos */
body.theme-chaos::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(255, 77, 255, 0.04) 3px,
    rgba(255, 77, 255, 0.04) 4px
  );
  pointer-events: none;
  z-index: 9000;
  animation: chaosScanline 8s linear infinite;
}

@keyframes chaosScanline {
  0%   { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

/* Chaos theme button — slightly bigger / more prominent */
.btn-theme-chaos {
  background: linear-gradient(135deg, #ff4dff, #e8a020, #00e5ff);
  color: #111 !important;
  border-color: transparent !important;
}
.btn-theme-chaos:hover:not(:disabled) {
  filter: brightness(1.15);
  transform: translateY(-2px);
}

/* ── Mode-gate cards (start screen) ─────────────────────────────────── */

.mode-gate-cards {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  max-width: 900px;
}

.mode-gate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 2rem 1.5rem;
  background: var(--surface);
  border: 2px solid var(--surface-alt);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s, background 0.18s;
  min-width: 180px;
  flex: 1 1 180px;
  max-width: 260px;
  text-align: center;
}

.mode-gate-card:hover {
  border-color: var(--accent);
  background: var(--surface-alt);
  transform: translateY(-4px);
  box-shadow: var(--shadow-playful);
}

.mode-gate-icon {
  font-size: 2.8rem;
  line-height: 1;
}

.mode-gate-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}

.mode-gate-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* ── Campaign list screen ────────────────────────────────────────────── */

#screen-campaign {
  max-width: 700px;
}

.campaign-list {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  width: 100%;
}

.campaign-card {
  display: flex;
  align-items: flex-start;
  gap: 1.2rem;
  padding: 1.4rem 1.6rem;
  background: var(--surface);
  border: 2px solid var(--surface-alt);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.18s, transform 0.15s, box-shadow 0.18s;
}

.campaign-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-playful);
}

.campaign-card-icon {
  font-size: 2.4rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.campaign-card-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  text-align: left;
}

.campaign-card-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
}

.campaign-card-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.campaign-card-modes {
  font-size: 0.82rem;
  color: var(--text);
  opacity: 0.6;
  margin-top: 0.2rem;
  font-style: italic;
}

/* ── Campaign wheel screen ───────────────────────────────────────────── */

#screen-campaign-wheel {
  max-width: 500px;
}

.campaign-wheel-step {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.campaign-wheel-container {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

.campaign-wheel-pointer {
  font-size: 2rem;
  color: var(--accent);
  line-height: 1;
  margin-bottom: -6px;
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.campaign-wheel-svg {
  width: clamp(240px, 80vw, 300px);
  height: clamp(240px, 80vw, 300px);
  border-radius: 50%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: block;
}

#campaign-wheel-group {
  transition: transform 4s cubic-bezier(0.08, 0.92, 0.18, 1.0);
  transform-origin: 150px 150px;
  transform: rotate(0deg);
}

.campaign-wheel-result {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  animation: wheelResultPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes wheelResultPop {
  0%   { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}

.joey-campaign-speech {
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 0.8rem 1.2rem;
  font-size: 0.95rem;
  color: var(--text);
  max-width: 380px;
  text-align: center;
  animation: joeyEnter 0.35s ease both;
}

/* ── Campaign continue button ────────────────────────────────────────── */

.btn-campaign-continue {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

.btn-campaign-continue:hover {
  background: var(--accent);
  color: #111;
  transform: translateY(-2px);
}

/* ── Campaign start button (on start screen) ─────────────────────────── */

.btn-campaign-start {
  margin-top: 0.5rem;
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 1.2rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-campaign-start:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* ── Tutorial campaign progress tracker ──────────────────────────────── */

.campaign-tutorial-progress {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  margin: 0.5rem 0 0.25rem;
  font-size: 0.9rem;
}

.camp-prog-item {
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
  font-weight: 600;
  transition: opacity 0.3s;
}

.camp-prog-done {
  opacity: 0.4;
  text-decoration: line-through;
  color: var(--text-muted);
}

.camp-prog-sep {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ── Multiplayer Rooms (Colyseus) ────────────────────────────────────── */

/* Hub: Create / Join cards */
.mp-hub-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}
.mp-hub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.mp-hub-title { margin: 0; }
.mp-hub-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.mp-hub-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.mp-hub-card:hover {
  background: var(--surface-hover, var(--surface));
  border-color: var(--accent, var(--text));
  transform: translateY(-2px);
}
.mp-hub-card-icon { font-size: 2.5rem; line-height: 1; }
.mp-hub-card-title { font-weight: 700; font-size: 1.2rem; margin: 0.35rem 0 0.15rem; }
.mp-hub-card-sub { color: var(--text-muted); font-size: 0.9rem; }
@media (max-width: 540px) {
  .mp-hub-cards { grid-template-columns: 1fr; }
}

/* Join screen: room list */
.mp-join-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
}
.mp-join-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.mp-join-title { margin: 0; }
.mp-join-listbox {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem;
  overflow-x: auto;
}
.mp-join-table, .mp-room-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.mp-join-table th, .mp-room-table th,
.mp-join-table td, .mp-room-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.mp-join-table tbody tr:last-child td,
.mp-room-table tbody tr:last-child td { border-bottom: none; }
.mp-join-table th, .mp-room-table th {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.mp-join-row { transition: background 0.1s; }
.mp-join-row:hover { background: rgba(255,255,255,0.04); }
.mp-join-empty {
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
}

/* Room screen */
.mp-room-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
}
.mp-room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.mp-room-title {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mp-room-phase {
  color: var(--text-muted);
  font-size: 0.95rem;
}
.mp-room-config {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0.5rem 0 1rem;
}
.mp-room-table { margin-bottom: 1rem; }
.mp-row-avatar { width: 52px; }
.mp-row-avatar-svg { display: inline-block; width: 40px; height: 40px; vertical-align: middle; }
.mp-row-avatar-svg svg { width: 40px; height: 40px; display: block; }
.mp-row-avatar-fallback { font-size: 1.75rem; line-height: 1; }
.mp-host-badge { color: #ffc107; margin-left: 0.25rem; }
.mp-row-you { color: var(--accent, #5cf); font-weight: 600; }
.mp-row-disc { color: var(--text-muted); font-style: italic; font-size: 0.85em; }
.mp-row-self td { background: rgba(92, 207, 255, 0.05); }
.mp-row-host td { font-weight: 600; }

.mp-room-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.mp-room-footer .btn { min-width: 140px; }
.mp-room-waiting, .mp-room-host-picking {
  color: var(--text-muted);
  font-style: italic;
  margin: 0.25rem 0;
}

/* Create-room modal + password modal */
.mp-create-pop, .mp-pwd-pop {
  max-width: 420px;
}
.mp-create-row {
  display: block;
  margin: 0.75rem 0;
}
.mp-create-row > span {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.mp-create-row input,
.mp-pwd-pop input[type="password"] {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font: inherit;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  box-sizing: border-box;
}
.mp-create-row input:focus,
.mp-pwd-pop input[type="password"]:focus {
  outline: none;
  border-color: var(--accent, #5cf);
}
.mp-pwd-room-name {
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}
.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* Small screens */
@media (max-width: 540px) {
  .mp-join-table, .mp-room-table { font-size: 0.85rem; }
  .mp-join-table th:nth-child(3), .mp-join-table td:nth-child(3) { display: none; }
  .mp-room-table th:nth-child(3), .mp-room-table td:nth-child(3) { display: none; }
}
