/*
 * Spell to Fly — Game Stylesheet
 * Aesthetic: Pan American Airways 1950s–70s jet age
 * Home: aged travel-paper with Pan Am blue; Game: deep navy cabin
 * Fonts: Playfair Display (display) + Josefin Sans (UI) + Courier Prime (mono)
 */

@import url("https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700;900&family=Josefin+Sans:wght@300;400;600;700&family=Courier+Prime:wght@400;700&display=swap");

/* ============================================================
   CUSTOM PROPERTIES
   ============================================================ */

:root {
  /* ── Backgrounds — aged travel document paper ── */
  --bg:              #EEE8D4;
  --bg-raised:       #E4DAC0;
  --bg-card:         #F5F0E4;
  --bg-card-hover:   #EBE4D0;
  --bg-overlay:      rgba(238, 232, 212, 0.96);

  /* ── Text — deep navy printing ink ── */
  --text-primary:    #0C1830;
  --text-secondary:  #1E3A6A;
  --text-muted:      #4A6890;
  --text-accent:     #0060A9;

  /* ── Accents ── */
  --accent-gold:     #C5A028;   /* brass / medal gold */
  --accent-gold-dim: #D4B848;
  --accent-blue:     #0060A9;   /* Pan Am blue — primary interactive */
  --accent-blue-dim: #4090CC;
  --accent-green:    #1A7040;
  --accent-red:      #B83020;

  /* ── Borders — blue-ink tint ── */
  --border:          rgba(0, 60, 130, 0.12);
  --border-mid:      rgba(0, 60, 130, 0.24);
  --border-bright:   rgba(0, 60, 130, 0.52);

  /* ── Shadows — cool navy ── */
  --shadow-sm:  0 1px 4px  rgba(10, 30, 70, 0.12);
  --shadow-md:  0 4px 16px rgba(10, 30, 70, 0.14);
  --shadow-lg:  0 12px 40px rgba(10, 30, 70, 0.18);
  --shadow-xl:  0 24px 64px rgba(10, 30, 70, 0.24);

  --radius-sm:  3px;
  --radius-md:  7px;
  --radius-lg:  13px;
  --radius-xl:  22px;

  /* ── Typography ── */
  --font-display: "Playfair Display", Georgia, serif;
  --font-ui:      "Josefin Sans", "Trebuchet MS", sans-serif;
  --font-mono:    "Courier Prime", "Courier New", monospace;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-mid:  280ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   RESET & BASE
   ============================================================ */

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: var(--font-ui);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input {
  font-family: var(--font-ui);
}

.hidden {
  display: none !important;
}

/* ============================================================
   SCREEN TRANSITIONS
   ============================================================ */

#screen-home, #screen-game {
  position: fixed;
  inset: 0;
  transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.screen-exit {
  opacity: 0;
  transform: translateY(-12px);
  pointer-events: none;
}

.screen-enter {
  animation: screenEnter 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes screenEnter {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   HOME SCREEN
   ============================================================ */

#screen-home {
  overflow-y: auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 24px 48px;
}

/* Aviation-chart dot grid — like Pan Am route maps and graph paper */
.home-bg-grid {
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(0, 80, 160, 0.18) 1.5px, transparent 1.5px);
  background-size: 24px 24px;
  pointer-events: none;
  z-index: 0;
}

/* Ambient glow */
.home-bg-glow {
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 700px;
  background: radial-gradient(ellipse at center, rgba(0, 96, 169, 0.14) 0%, rgba(0, 60, 130, 0.05) 45%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Header / Logo */
.home-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 52px 0 40px;
}

.logo-mark {
  color: var(--accent-blue);
  flex-shrink: 0;
  animation: logoFloat 4s ease-in-out infinite;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%       { transform: translateY(-4px) rotate(1deg); }
}

.logo-text h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: 0.12em;
  color: var(--text-primary);
  line-height: 1;
}

.logo-sep {
  color: var(--accent-gold);
  margin: 0 2px;
}

.logo-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Main content */
.home-main {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 860px;
  display: flex;
  flex-direction: column;
  gap: 48px;
}

/* Section headings */
.section-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.30em;
  text-transform: uppercase;
  color: var(--accent-blue);
  margin-bottom: 20px;
  white-space: nowrap;
}

.section-heading::before,
.section-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-mid);
}

/* Player section */
.player-section {
  padding: 28px 32px;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.70);
}

.field-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.player-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.player-input-row.hidden {
  display: none;
}

.player-password-group {
  flex: 1;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-password-group .player-input {
  flex: none;
  width: 100%;
}

.player-password-group .player-input.hidden {
  display: none;
}

.player-input {
  flex: 1;
  min-width: 100px;
  height: 46px;
  padding: 0 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font-display);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.player-input::placeholder {
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 13px;
}

.player-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(0, 96, 169, 0.14);
}

.player-input.input--error {
  border-color: var(--accent-red);
  animation: inputShake 0.3s ease;
}

@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-6px); }
  75%       { transform: translateX(6px); }
}

/* Primary button — Pan Am blue */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 24px;
  background: linear-gradient(180deg, #0078CC 0%, #004F99 100%);
  color: #F0F8FF;
  border: 1px solid rgba(0, 80, 160, 0.40);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-primary:hover {
  background: linear-gradient(180deg, #0088E0 0%, #0060B0 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 96, 169, 0.40);
}

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

.btn-primary:disabled,
.btn-primary.btn--loading {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-icon {
  flex-shrink: 0;
}

.player-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  min-height: 20px;
}

/* Player status */
.player-status {
  font-size: 12px;
  color: var(--accent-green);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--transition-mid), transform var(--transition-mid);
}

.player-status.status--visible {
  opacity: 1;
  transform: translateY(0);
}

.btn-auth-toggle {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-left: auto;
  transition: color var(--transition-fast);
}

.btn-auth-toggle:hover {
  color: var(--accent-blue);
}

/* Region cards */
.regions-section {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.regions-section.section--reveal {
  opacity: 1;
  transform: translateY(0);
}

.region-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

@media (max-width: 700px) {
  .region-cards { grid-template-columns: repeat(2, 1fr); }
}

.region-card {
  position: relative;
  padding: 24px 20px 22px;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  text-align: left;
  overflow: hidden;
  transition:
    border-color var(--transition-mid),
    transform var(--transition-mid),
    box-shadow var(--transition-mid),
    background var(--transition-mid);
  cursor: pointer;
}

.region-card-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at 50% 0%,
    hsla(var(--glow), 70%, 55%, 0.08) 0%,
    transparent 70%
  );
  opacity: 0;
  transition: opacity var(--transition-mid);
  pointer-events: none;
}

.region-card-border {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  transition: border-color var(--transition-mid);
  pointer-events: none;
}

.region-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-bright);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.region-card:hover .region-card-glow {
  opacity: 1;
}

.region-card.card--selected {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 1px var(--accent-blue), var(--shadow-md);
}

.region-card.card--dimmed {
  opacity: 0.4;
  pointer-events: none;
}

.region-card-content {
  position: relative;
  z-index: 1;
}

.region-icon {
  display: block;
  color: var(--text-muted);
  margin-bottom: 14px;
  transition: color var(--transition-mid);
}

.region-card:hover .region-icon {
  color: var(--text-secondary);
}

.region-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.region-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Leaderboard */
.leaderboard-section + .leaderboard-section {
  margin-top: 24px;
}

.leaderboard-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.leaderboard-table thead tr {
  border-bottom: 1px solid var(--border-mid);
}

.leaderboard-table th {
  padding: 12px 16px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
}

.lb-rank { width: 36px; text-align: center; }
.lb-score, .lb-moves, .lb-flights { text-align: right; }

.lb-medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.lb-medal--gold   { background: #FFD700; color: #3a2800; box-shadow: 0 1px 6px rgba(255,215,0,0.45); }
.lb-medal--silver { background: #9BA4B0; color: #fff;    box-shadow: 0 1px 4px rgba(155,164,176,0.4); }
.lb-medal--bronze { background: #B87333; color: #fff;    box-shadow: 0 1px 4px rgba(184,115,51,0.4); }

.lb-row {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
}

.lb-row:last-child { border-bottom: none; }
.lb-row:nth-child(even) { background: rgba(0, 60, 130, 0.03); }
.lb-row:hover { background: rgba(0, 60, 130, 0.06); }

.lb-row--first td {
  color: var(--accent-blue);
}

.lb-row--first .lb-rank {
  font-size: 16px;
}

.lb-row--active {
  background: rgba(0, 96, 169, 0.07) !important;
  border-bottom: 1px solid rgba(0, 96, 169, 0.20);
}

.lb-row--active td {
  color: var(--text-primary);
}

.btn-resume {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  background: rgba(74, 143, 232, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(74, 143, 232, 0.35);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.btn-resume:hover {
  background: rgba(74, 143, 232, 0.28);
  border-color: rgba(74, 143, 232, 0.6);
}

.leaderboard-table td {
  padding: 11px 16px;
}

.lb-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px !important;
  font-style: italic;
}

.lb-loading {
  text-align: center;
  padding: 24px;
}

.lb-loading-dots {
  display: inline-flex;
  gap: 6px;
}

.lb-loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: dotPulse 1.2s ease-in-out infinite;
}

.lb-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.lb-loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40%            { opacity: 1;   transform: scale(1); }
}

/* ============================================================
   GAME SCREEN
   ============================================================ */

#screen-game {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.game-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(74, 143, 232, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(212, 168, 75, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* Game nav */
.game-nav {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 16px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--border-bright);
  background: rgba(255,255,255,0.04);
}

.game-nav-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

.nav-region-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-primary);
}

.game-stats {
  display: flex;
  gap: 8px;
}

.stat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
  padding: 4px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  transition: transform var(--transition-fast);
}

.stat-chip.stat-bump {
  animation: statBump 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

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

.stat-chip.bonus-flash {
  animation: bonusFlash 0.8s ease;
}

@keyframes bonusFlash {
  0%, 100% { background: var(--bg-card); border-color: var(--border-mid); }
  50%       { background: rgba(212, 168, 75, 0.15); border-color: var(--accent-gold); }
}

.stat-label {
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1;
  margin-bottom: 2px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

/* Game body */
.game-body {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
  z-index: 1;
}

/* Ticket panel */
.ticket-panel {
  width: 200px;
  flex-shrink: 0;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  border-right: 1px solid var(--border);
  background: var(--bg-raised);
  overflow-y: auto;
}

/* ── Hover flag display ── */
.panel-flag-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 64px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.panel-flag-img {
  width: 100%;
  max-width: 120px;
  height: auto;
  border-radius: 3px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transition: opacity 0.2s;
}

.panel-flag-img.hidden { display: none; }

.panel-flag-hint {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.05em;
}

/* ── Unlock log ── */
.unlock-log {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.unlock-log-heading {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.unlock-log-entries {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-entry {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 6px;
  row-gap: 1px;
  padding: 4px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  animation: logAppear 0.25s ease;
}

@keyframes logAppear {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.log-flag {
  grid-row: 1 / 3;
  width: 22px;
  height: auto;
  align-self: center;
  border-radius: 2px;
}

.log-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-meta {
  display: flex;
  gap: 5px;
  align-items: center;
}

.log-points {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-gold);
}

.log-points--zero { color: var(--text-muted); }

.log-move {
  font-size: 10px;
  color: var(--text-muted);
}

.ticket {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
}

.ticket-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px 8px;
  background: rgba(212, 168, 75, 0.07);
  border-bottom: 1px dashed var(--border-mid);
}

.ticket-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--accent-gold);
}

.ticket-status {
  font-size: 7px;
  letter-spacing: 0.15em;
  color: var(--accent-green);
  background: rgba(74, 173, 122, 0.12);
  padding: 2px 6px;
  border-radius: 3px;
}

.ticket-route {
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ticket-city {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.city-label {
  font-size: 8px;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.city-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.ticket-arrow {
  display: flex;
  justify-content: center;
  color: var(--accent-gold-dim);
}

.ticket-footer {
  padding: 8px 12px 10px;
  border-top: 1px dashed var(--border);
}

.ticket-hint {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
  font-style: italic;
}

/* Perforations (decorative) */
.ticket-perforations {
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 8px;
  background:
    radial-gradient(circle at 0 0, var(--bg-card) 6px, transparent 6px),
    radial-gradient(circle at 8px 0, transparent 6px, var(--bg-raised) 6px);
  background-size: 16px 8px;
  background-repeat: repeat-x;
  opacity: 0.4;
}

/* Map container */
.map-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

#map-container {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.map-svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Map country hover */
.country--locked:hover {
  filter: brightness(1.3);
}

.country--selected {
  stroke: var(--accent-gold) !important;
  stroke-width: 1.5 !important;
}

/* Map legend */
.map-legend {
  display: flex;
  gap: 16px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-raised);
  flex-shrink: 0;
}

.legend-item {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding-left: 14px;
  position: relative;
}

.legend-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.legend-fog::before     { background: #141620; border: 1px solid #1c2030; }
.legend-locked::before  { background: #2d3350; border: 1px solid #3d4570; }
.legend-unlocked::before { background: #2a5a4a; border: 1px solid #3a8a6a; }
.legend-lockedout::before { background: #4a1a1a; border: 1px solid #6b2828; }

/* Leaflet overrides */
.leaflet-container {
  background: #BCC8D4; /* cool blue-grey ocean — vintage aviation chart feel */
  font-family: var(--font-mono);
}

.leaflet-tile-pane {
  filter: brightness(0.88) saturate(0.78) hue-rotate(-8deg);
}

.leaflet-control-zoom {
  border: 1px solid var(--border-mid) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-md) !important;
}

.leaflet-control-zoom a {
  background: var(--bg-card) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border) !important;
  font-family: var(--font-mono) !important;
  line-height: 26px !important;
  width: 26px !important;
  height: 26px !important;
}

.leaflet-control-zoom a:hover {
  background: var(--bg-card-hover) !important;
  color: var(--text-primary) !important;
}

/* Country name labels — appear when a country is unlocked */
.country-map-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  pointer-events: none;
  color: rgba(240, 245, 255, 0.85);
  font-family: var(--font-mono);
  font-size: calc(var(--map-zoom, 4) * 2px);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7), 0 0 6px rgba(0,0,0,0.5);
  white-space: nowrap;
}
.country-map-label::before { display: none !important; }

/* City name labels on the map */
.city-map-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  color: var(--text-accent);
  font-family: var(--font-mono);
  font-size: calc(var(--map-zoom, 4) * 2.5px);
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
  white-space: nowrap;
  pointer-events: none;
}

.city-map-label::before { display: none !important; }

/* Points hover tooltip */
.points-tooltip {
  background: rgba(0, 20, 60, 0.90) !important;
  border: 1px solid rgba(0, 96, 169, 0.55) !important;
  border-radius: 4px !important;
  color: #7AACDC !important;
  font-family: "Courier Prime", monospace !important;
  font-size: 0.72rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.05em !important;
  padding: 2px 6px !important;
  white-space: nowrap !important;
  box-shadow: 0 0 6px rgba(0, 96, 169, 0.30) !important;
  pointer-events: none !important;
}
.points-tooltip::before { display: none !important; }

/* Country hover brightness */
.leaflet-interactive:hover {
  filter: brightness(1.25);
}

/* Pulsing orange city marker (current city + destination) */
.city-pulse-marker {
  position: relative;
  width: 24px;
  height: 24px;
}

.city-pulse-marker .pulse-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  background: #2090D8;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(32, 144, 216, 0.85);
  z-index: 2;
}

.city-pulse-marker .pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  border: 2px solid #2090D8;
  border-radius: 50%;
  animation: cityPulseRing 1.8s ease-out infinite;
}

@keyframes cityPulseRing {
  0%   { transform: translate(-50%, -50%) scale(1);   opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(3.2); opacity: 0; }
}

/* Destination city marker — larger, double-ring, punches through fog */
.city-dest-marker {
  position: relative;
  width: 44px;
  height: 44px;
}

.city-dest-marker .dest-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: #F0A820;
  border-radius: 50%;
  box-shadow: 0 0 8px 3px rgba(240,168,32,0.75), 0 0 18px 6px rgba(240,168,32,0.35);
  z-index: 2;
}

.city-dest-marker .dest-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  border: 2px solid #F0A820;
  border-radius: 50%;
  animation: destPulseRing 2.4s ease-out infinite;
}

.city-dest-marker .dest-ring--2 {
  animation-delay: 1.2s;
}

@keyframes destPulseRing {
  0%   { transform: translate(-50%, -50%) scale(1);   opacity: 0.85; }
  100% { transform: translate(-50%, -50%) scale(4.5); opacity: 0; }
}

/* Destination label — stands out from dark fog */
.city-map-label--dest {
  color: #F0A820 !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  text-shadow: 0 0 8px rgba(0,0,0,0.9), 0 1px 4px #000, 0 0 16px rgba(240,168,32,0.4) !important;
  letter-spacing: 0.05em;
}

/* ============================================================
   SPELLING PANEL
   ============================================================ */

.spelling-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-card);
  border-top: 1px solid var(--border-mid);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 0 0 24px;
  transform: translateY(100%);
  transition: transform var(--transition-slow) cubic-bezier(0.22, 1, 0.36, 1);
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: 0 -20px 60px rgba(10, 25, 60, 0.70);
}

.spelling-panel.panel--open {
  transform: translateY(0);
}

.spelling-panel-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 24px;
}

.spelling-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.spelling-content {
  flex: 1;
  min-width: 0;
}

.spelling-close {
  position: absolute;
  top: 14px;
  right: 20px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-muted);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.spelling-close:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.06);
}

.spelling-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 0 16px;
}

.spelling-type-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: rgba(0, 96, 169, 0.10);
  color: var(--accent-blue);
  border: 1px solid rgba(0, 96, 169, 0.24);
}

.spelling-type-badge--country {
  background: rgba(197, 160, 40, 0.12);
  color: #8A6C10;
  border-color: rgba(197, 160, 40, 0.28);
}

.spelling-type-badge--city {
  background: rgba(0, 96, 169, 0.10);
  color: var(--accent-blue);
  border-color: rgba(0, 96, 169, 0.24);
}

.spelling-points {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-gold);
  letter-spacing: 0.04em;
  transition: color var(--transition-fast);
}

.spelling-points--zero {
  color: var(--text-muted);
}

.spelling-attempt {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-left: auto;
}

.spelling-media {
  flex-shrink: 0;
  width: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 4px;
}

.spelling-media:empty { display: none; }

.spelling-media img {
  width: 240px;
  max-height: 220px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
  object-fit: cover;
}

.spelling-instruction {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* Letter blanks */
.spelling-blanks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 22px;
  transition: filter var(--transition-fast);
}

.spelling-blanks.blanks--correct {
  filter: drop-shadow(0 0 8px rgba(0, 96, 169, 0.55));
}

.spelling-blanks.blanks--wrong {
  animation: blankShake 0.3s ease;
  filter: drop-shadow(0 0 8px rgba(192, 74, 74, 0.5));
}

@keyframes blankShake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-5px); }
  75%       { transform: translateX(5px); }
}

.blank-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 46px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-bottom: 2px solid var(--text-muted);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.blank-letter.blank-revealed {
  border-bottom-color: var(--accent-blue);
  color: var(--accent-blue);
}

.blank-letter.blank-just-revealed {
  animation: blankReveal 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes blankReveal {
  0%   { transform: scale(0.7) rotateX(90deg); opacity: 0.3; }
  100% { transform: scale(1)   rotateX(0deg);  opacity: 1; }
}

.blank-space {
  display: inline-block;
  width: 16px;
  height: 46px;
}

/* Wrong letters display */
.spelling-wrong {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
  margin-bottom: 16px;
}

.wrong-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(192, 74, 74, 0.12);
  border: 1px solid rgba(192, 74, 74, 0.3);
  border-radius: var(--radius-sm);
  color: var(--accent-red);
  font-size: 13px;
  font-weight: 700;
  text-decoration: line-through;
  animation: wrongAppear 0.25s ease;
}

@keyframes wrongAppear {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* Keyboard */
.spelling-keyboard {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 16px;
}

.key-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    transform var(--transition-fast),
    color var(--transition-fast);
}

.key-btn:not([disabled]):hover {
  background: var(--bg-card-hover);
  border-color: var(--border-bright);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

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

.key-btn.key-wrong {
  background: rgba(192, 74, 74, 0.18);
  border-color: rgba(192, 74, 74, 0.5);
  color: rgba(192, 74, 74, 0.7);
  text-decoration: line-through;
  cursor: not-allowed;
}

.key-btn.key-correct {
  background: rgba(0, 96, 169, 0.12);
  border-color: rgba(0, 96, 169, 0.32);
  color: var(--accent-blue);
}

.key-btn.key-pending {
  opacity: 0.5;
  pointer-events: none;
}

/* Spelling actions */
.spelling-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-hear {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.btn-hear:hover {
  color: var(--accent-blue);
  border-color: rgba(0, 96, 169, 0.40);
  background: rgba(0, 96, 169, 0.07);
}

.wrong-count-display {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

.wrong-count-display.danger {
  color: var(--accent-red);
  animation: dangerPulse 0.8s ease infinite;
}

@keyframes dangerPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  padding: 10px 20px;
  background: #001E5A;
  border: 1px solid rgba(0, 96, 169, 0.45);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: #C8E4FC;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-mid), transform var(--transition-mid);
  white-space: nowrap;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(10, 25, 60, 0.6);
}

.toast.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast--success {
  background: #0A3A20;
  border-color: rgba(40, 150, 80, 0.50);
  color: #6ADCA8;
}

.toast--error {
  background: #3A0808;
  border-color: rgba(180, 48, 32, 0.50);
  color: #E07070;
}

.toast--info {
  background: #001E5A;
  border-color: rgba(0, 96, 169, 0.45);
  color: #7AACDC;
}

/* ============================================================
   GAME COMPLETE OVERLAY
   ============================================================ */

.game-complete-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 15, 45, 0.88);
  backdrop-filter: blur(12px);
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.game-complete-overlay.overlay--visible {
  opacity: 1;
}

.game-complete-card {
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-xl);
  padding: 48px 56px;
  text-align: center;
  box-shadow: var(--shadow-xl);
  animation: cardRise 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes cardRise {
  from { transform: translateY(24px) scale(0.95); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

.complete-icon {
  margin-bottom: 24px;
  animation: iconSpin 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes iconSpin {
  from { transform: rotate(-15deg) scale(0.7); opacity: 0; }
  to   { transform: rotate(0deg)   scale(1);   opacity: 1; }
}

.complete-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 900;
  color: var(--text-primary);
  margin-bottom: 28px;
  letter-spacing: 0.02em;
}

.complete-stats {
  display: flex;
  gap: 32px;
  justify-content: center;
  margin-bottom: 36px;
}

.complete-stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.complete-stat-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.complete-stat-value {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 900;
  color: var(--accent-gold);
  line-height: 1;
}

.btn-play-again {
  font-size: 13px;
  padding: 0 28px;
  height: 48px;
}

/* ============================================================
   GAME SCREEN — PAN AM CABIN DARK OVERRIDES
   Home uses aged travel paper; game frames the map in deep Pan Am
   navy — like the interior of a 707 or 747 Clipper cabin.
   ============================================================ */

#screen-game {
  background: #001040;
}

.game-nav {
  background: #001D5A;
  border-bottom-color: rgba(0, 96, 169, 0.35);
}

#screen-game .btn-ghost {
  color: #6AAAD4;
  border-color: rgba(0, 96, 169, 0.32);
}

#screen-game .btn-ghost:hover {
  color: #C0DDF4;
  border-color: rgba(0, 96, 169, 0.60);
  background: rgba(0, 80, 160, 0.12);
}

.nav-region-name {
  color: #C8E4FC;
}

#screen-game .stat-chip {
  background: #002D72;
  border-color: rgba(0, 96, 169, 0.28);
}

#screen-game .stat-label {
  color: rgba(100, 160, 220, 0.65);
}

#screen-game .stat-value {
  color: #C8E4FC;
}

.ticket-panel {
  background: #001D5A;
  border-right-color: rgba(0, 80, 160, 0.22);
}

.ticket {
  background: #002D72;
  border-color: rgba(0, 96, 169, 0.30);
}

.ticket-header {
  background: #0060A9;
  border-bottom: 1px dashed rgba(0, 120, 200, 0.50);
}

.ticket-label {
  color: #E8F4FF;
  letter-spacing: 0.22em;
}

.ticket-status {
  color: #7ADCA8;
  background: rgba(40, 130, 80, 0.22);
}

.city-label,
.ticket-hint {
  color: rgba(100, 160, 220, 0.65);
}

.city-name {
  color: #C8E4FC;
}

.ticket-arrow {
  color: rgba(0, 100, 170, 0.55);
}

.ticket-footer {
  border-top-color: rgba(0, 80, 160, 0.25);
}

.ticket-perforations {
  background:
    radial-gradient(circle at 0 0, #002D72 6px, transparent 6px),
    radial-gradient(circle at 8px 0, transparent 6px, #001D5A 6px);
  background-size: 16px 8px;
  background-repeat: repeat-x;
}

.panel-flag-display {
  border-top-color: rgba(0, 80, 160, 0.18);
}

.panel-flag-hint {
  color: rgba(100, 160, 220, 0.55);
}

.unlock-log {
  border-top-color: rgba(0, 80, 160, 0.18);
}

.unlock-log-heading {
  color: rgba(100, 160, 220, 0.50);
}

.log-entry {
  background: #002D72;
  border-color: rgba(0, 96, 169, 0.22);
}

.log-name {
  color: #C0DCF4;
}

.log-points {
  color: #6AAAD4;
}

.log-move {
  color: rgba(100, 160, 220, 0.55);
}

.map-legend {
  background: #001D5A;
  border-top-color: rgba(0, 80, 160, 0.20);
}

.legend-item {
  color: rgba(100, 160, 220, 0.65);
}

.legend-fog::before      { background: #001040; border: 1px solid #002060; }
.legend-locked::before   { background: #001D5A; border: 1px solid #003090; }
.legend-unlocked::before { background: #1A5A8A; border: 1px solid #2A7AAA; }

.leaflet-control-zoom {
  border-color: rgba(0, 96, 169, 0.35) !important;
}

.leaflet-control-zoom a {
  background: #002D72 !important;
  color: #6AAAD4 !important;
  border-color: rgba(0, 96, 169, 0.28) !important;
}

.leaflet-control-zoom a:hover {
  background: #0060A9 !important;
  color: #E8F4FF !important;
}

/* ============================================================
   SCROLLBAR STYLING
   ============================================================ */

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-mid);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-bright);
}

/* ============================================================
   FOCUS STYLES
   ============================================================ */

:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

button:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================================
   UTILITY
   ============================================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
