/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:            #f0ede6;
  --surface:       #ffffff;
  --surface-2:     #e8e4dc;
  --surface-3:     #d9d4c9;
  --border:        rgba(0,0,0,0.09);
  --border-strong: rgba(0,0,0,0.18);
  --text-primary:  #1c1a17;
  --text-secondary:#5c5848;
  --text-tertiary: #9a9180;
  --accent:        #185FA5;
  --accent-light:  #e8f1fb;
  --green:         #1a9068;
  --green-light:   #e4f5ef;
  --danger:        #b83228;
  --mono-bg:       #1c1a17;
  --mono-fg:       #d4f5a0;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg:     0 12px 32px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.08);
  --r-sm:          8px;
  --r-md:          14px;
  --r-lg:          20px;
  --r-xl:          28px;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  color: var(--text-primary);
  background: var(--bg);
}

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

/* ─── Screen system ─────────────────────────────────────────── */
.screen { display: none; flex-direction: column; min-height: 100dvh; }
.screen.active { display: flex; }

/* ─── Topo background (handoff screen only) ─────────────────── */
.topo-lines {
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cellipse cx='200' cy='200' rx='180' ry='120' fill='none' stroke='rgba(24,95,165,0.07)' stroke-width='1.5'/%3E%3Cellipse cx='200' cy='200' rx='140' ry='90' fill='none' stroke='rgba(24,95,165,0.06)' stroke-width='1.5'/%3E%3Cellipse cx='200' cy='200' rx='100' ry='65' fill='none' stroke='rgba(24,95,165,0.05)' stroke-width='1'/%3E%3Cellipse cx='200' cy='200' rx='60' ry='40' fill='none' stroke='rgba(24,95,165,0.04)' stroke-width='1'/%3E%3C/svg%3E");
  background-size: 400px 400px; background-repeat: repeat; pointer-events: none;
}

/* ─── Setup Screen ──────────────────────────────────────────── */
.setup-bg { position: fixed; inset: 0; z-index: 0; background: #f0ede6; }
/* SVG illustration at 50% opacity sits above the flat colour */
.setup-bg::before {
  content: '';
  position: absolute; inset: 0;
  background-image: url('coordguessr_background.svg');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  opacity: 0.6;
  pointer-events: none;
}
/* Hide topo pattern on setup — SVG background takes over */
.setup-bg .topo-lines { display: none; }

.setup-content {
  position: relative; z-index: 1;
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: 20px 16px 48px;
  display: flex; flex-direction: column;
}

.setup-header { text-align: center; padding: 8px 0 20px; }

.logo-mark {
  width: 44px; height: 44px; margin: 0 auto 12px; color: var(--accent);
}

.setup-header h1 {
  font-size: 1.9rem; font-weight: 700; letter-spacing: -0.03em;
}

.tagline { margin-top: 4px; color: var(--text-secondary); font-size: 0.88rem; font-weight: 700; }

.game-desc {
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.55;
  max-width: 340px;
  margin-left: auto; margin-right: auto;
}

.setup-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 22px 18px;
  display: flex; flex-direction: column; gap: 14px;
}

.setup-section { display: flex; flex-direction: column; gap: 10px; }

.section-label {
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-tertiary);
}


/* ─── Players list ──────────────────────────────────────────── */
.players-list { display: flex; flex-direction: column; gap: 0; }

.player-container { display: flex; flex-direction: column; }

.player-row {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 0;
}

.emoji-btn {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--surface-2);
  font-size: 1.1rem; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.emoji-btn-num {
  font-size: 0.82rem; font-weight: 700;
  font-family: 'DM Mono', monospace; color: var(--text-secondary);
}
.emoji-btn:hover, .emoji-btn.open {
  border-color: var(--accent); background: var(--accent-light);
}

.player-row input {
  flex: 1; min-width: 0;
  padding: 8px 11px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--surface-2);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem; color: var(--text-primary);
  outline: none; transition: border-color 0.15s;
}
.player-row input:focus {
  border-color: var(--accent); background: var(--surface);
}
.player-row input::placeholder { color: var(--text-tertiary); }

.remove-player-btn {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 50%; border: none;
  background: var(--surface-2); color: var(--text-tertiary);
  cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.remove-player-btn:hover { background: #fde8e6; color: var(--danger); }

/* Emoji picker grid */
.emoji-picker {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 8px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-md);
  margin: 4px 0 6px 41px; /* align with input */
  box-shadow: var(--shadow-md);
}
.emoji-picker.hidden { display: none; }

.emoji-opt {
  width: 34px; height: 34px;
  border: none; border-radius: var(--r-sm);
  background: transparent;
  font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.emoji-opt:hover { background: var(--surface-2); }
.emoji-opt.selected { background: var(--accent-light); outline: 2px solid var(--accent); }

/* ─── Segmented controls ────────────────────────────────────── */
.seg-control {
  display: flex; background: var(--surface-2);
  border-radius: var(--r-sm); padding: 3px; gap: 2px;
}
.scroll-seg { overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
.scroll-seg::-webkit-scrollbar { display: none; }

.seg-btn {
  flex: 1; min-width: 44px; padding: 7px 10px;
  border: none; border-radius: calc(var(--r-sm) - 2px);
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.86rem; font-weight: 500; color: var(--text-secondary);
  cursor: pointer; white-space: nowrap;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.seg-btn.active {
  background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-sm);
}
.seg-sm .seg-btn { font-size: 0.82rem; padding: 6px 10px; }

/* ─── Region layout (side-by-side) ──────────────────────────── */
.region-layout {
  display: flex;
  gap: 12px;
  align-items: stretch;
}
.region-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

/* ─── Region row ─────────────────────────────────────────────── */
.region-row {
  display: flex; flex-wrap: wrap;
  gap: 6px; padding: 0;
}

.region-btn {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 7px 14px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem; font-weight: 500; color: var(--text-secondary);
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.region-btn:hover, .region-btn.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent); font-weight: 600;
}

/* ─── Region preview map ────────────────────────────────────── */
.region-preview-map {
  width: 150px;
  flex-shrink: 0;
  min-height: 100px;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1.5px solid var(--border-strong);
  background: #c9d9e8;
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn-primary {
  padding: 13px 24px; border-radius: var(--r-md); border: none;
  background: var(--accent); color: #fff;
  font-family: 'DM Sans', sans-serif; font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.38; cursor: not-allowed; transform: none; }
.btn-full { width: 100%; }
.btn-wide { min-width: 180px; }

.btn-ghost {
  background: none; border: none; color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif; font-size: 0.86rem; font-weight: 500;
  cursor: pointer; padding: 6px 10px; border-radius: var(--r-sm);
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text-primary); }
.btn-sm { font-size: 0.78rem; }
.btn-center { display: block; margin: 0 auto; }

/* ─── Stats row (setup screen — three live pills) ───────────── */
.stats-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.74rem;
  color: var(--text-tertiary);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.stat-pill-val {
  font-family: 'DM Mono', monospace;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-primary);
}

.stat-pill-label { color: var(--text-tertiary); }

.stat-pill-icon { font-size: 0.68rem; line-height: 1; }

/* Pulsing green dot for the "now" pill */
.stat-live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  animation: live-dot-pulse 2s ease-in-out infinite;
}

@keyframes live-dot-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ─── Leaderboard Browser ───────────────────────────────────── */
#screen-leaderboards { background: var(--bg); }

.inner {
  width: 100%; max-width: 600px; margin: 0 auto; padding: 0 16px 48px;
}

.screen-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 0 20px;
}
.screen-topbar h2 { font-size: 1.1rem; font-weight: 600; }

.back-btn {
  background: none; border: none; color: var(--accent);
  font-family: 'DM Sans', sans-serif; font-size: 0.9rem; font-weight: 500;
  cursor: pointer; padding: 6px 0;
  -webkit-tap-highlight-color: transparent;
}

.lb-filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }

.lb-table {
  background: var(--surface); border-radius: var(--r-lg);
  border: 1px solid var(--border); overflow: hidden; box-shadow: var(--shadow-sm);
}

.lb-row {
  display: grid; grid-template-columns: 36px 1fr 80px 56px;
  align-items: center; padding: 12px 16px;
  border-bottom: 1px solid var(--border); gap: 8px;
}
.lb-row:last-child { border-bottom: none; }
.lb-row.lb-header {
  background: var(--surface-2);
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-tertiary);
}
.lb-rank { font-family: 'DM Mono', monospace; font-size: 0.85rem; color: var(--text-tertiary); }
.lb-rank.gold   { color: #c9922a; }
.lb-rank.silver { color: #7a8fa0; }
.lb-rank.bronze { color: #9a6040; }
.lb-name { font-weight: 500; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-family: 'DM Mono', monospace; font-size: 0.88rem; text-align: right; font-weight: 500; }
.lb-rounds { font-family: 'DM Mono', monospace; font-size: 0.78rem; color: var(--text-tertiary); text-align: right; }
.lb-empty { padding: 40px 20px; text-align: center; color: var(--text-tertiary); font-size: 0.9rem; }

/* ─── Handoff Screen ────────────────────────────────────────── */
.handoff-bg { position: fixed; inset: 0; z-index: 0; background: #f0ede6; }
.handoff-bg::before {
  content: '';
  position: absolute; inset: 0;
  background-image: url('coordguessr_background.svg');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  opacity: 0.6;
  pointer-events: none;
}

.handoff-content {
  position: relative; z-index: 1; flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}

.handoff-card {
  background: var(--surface); border-radius: var(--r-xl);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  padding: 32px 28px 38px;
  text-align: center; width: 100%; max-width: 380px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}

.menu-link {
  align-self: flex-start; background: none; border: none;
  color: var(--text-tertiary);
  font-family: 'DM Sans', sans-serif; font-size: 0.82rem; font-weight: 500;
  cursor: pointer; padding: 0; margin-bottom: 4px;
  transition: color 0.15s; -webkit-tap-highlight-color: transparent;
}
.menu-link:hover { color: var(--accent); }

.handoff-label {
  font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-tertiary);
}

.handoff-card h2 {
  font-size: 2rem; font-weight: 700; color: var(--text-primary);
  letter-spacing: -0.02em; margin: 4px 0 2px;
}

.handoff-meta { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 8px; }

.coord-preview {
  background: var(--surface-2); border-radius: var(--r-sm);
  padding: 10px 18px; margin: 4px 0 10px; width: 100%;
}
.coord-lock { font-size: 0.85rem; color: var(--text-tertiary); }

/* ─── Game Screen ───────────────────────────────────────────── */
#screen-game { background: #1a1a1a; position: relative; }

.game-topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--mono-bg); flex-shrink: 0;
  min-height: 52px;
}
.menu-icon-btn {
  background: none; border: none; color: rgba(255,255,255,0.4);
  font-size: 1rem; cursor: pointer; padding: 4px 6px; border-radius: 6px;
  flex-shrink: 0; transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.menu-icon-btn:hover { color: rgba(255,255,255,0.8); }

.topbar-spacer { width: 32px; flex-shrink: 0; }

.game-meta-center {
  display: flex; align-items: center; gap: 8px;
  flex: 1; justify-content: center; flex-wrap: nowrap;
}

.player-pill {
  background: var(--accent); color: #fff;
  border-radius: 100px; padding: 4px 14px;
  font-size: 1rem; font-weight: 600; white-space: nowrap; flex-shrink: 0;
}

.round-badge {
  font-family: 'DM Mono', monospace; font-size: 0.9rem;
  color: rgba(255,255,255,0.45); white-space: nowrap; flex-shrink: 0;
}

.timer-group { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.timer-wrap {
  width: 64px; height: 7px;
  background: rgba(255,255,255,0.15); border-radius: 4px; overflow: hidden;
}
.timer-bar {
  height: 100%; width: 100%; background: var(--mono-fg);
  border-radius: 4px; transition: width 1s linear, background 0.3s;
}
.timer-bar.warning { background: var(--danger); }

.timer-num {
  font-family: 'DM Mono', monospace; font-size: 1rem; font-weight: 500;
  color: rgba(255,255,255,0.7); min-width: 34px; text-align: left;
}
.timer-num.warning { color: var(--danger); }

/* Floating coordinate box — sits below topbar, above map */
.coord-float {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  padding-top: 8px;
  pointer-events: none;
  white-space: nowrap;
}
.coord-box {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--mono-bg);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--r-md); padding: 9px 22px;
  box-shadow: 0 3px 16px rgba(0,0,0,0.35);
}
.coord-val {
  font-family: 'DM Mono', 'Fira Mono', monospace;
  font-size: 1.1rem; font-weight: 500; color: var(--mono-fg); letter-spacing: 0.02em;
}
.coord-sep { color: rgba(255,255,255,0.3); font-family: 'DM Mono', monospace; font-size: 1.1rem; }

/* Map panels */
.map-panel { flex: 1; min-height: 0; }
.map-reveal { flex: 0 0 240px; min-height: 240px; max-height: 300px; }

.game-bottombar {
  display: flex; align-items: center;
  gap: 12px; padding: 10px 14px; background: var(--mono-bg); flex-shrink: 0;
}
.hint-text {
  flex: 1; text-align: center;
  font-size: 0.9rem; color: rgba(255,255,255,0.5);
  font-family: 'DM Mono', monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ─── Round Done Overlay ─────────────────────────────────────── */
.round-done-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 800;
}
.round-done-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 32px 40px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  box-shadow: var(--shadow-lg);
  min-width: 220px;
}
.round-done-icon {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--green-light); color: var(--green);
  font-size: 1.6rem;
  display: flex; align-items: center; justify-content: center;
}
.round-done-round { font-size: 0.9rem; color: var(--text-secondary); }

/* ─── Review Screen ──────────────────────────────────────────── */
#screen-review { background: var(--bg); }

.review-round {
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.review-round-header {
  padding: 10px 14px;
  background: var(--surface-2);
  display: flex; flex-direction: column; gap: 3px;
  border-bottom: 1px solid var(--border);
}
.review-round-header-top {
  display: flex; align-items: baseline; gap: 8px;
}
.review-round-num {
  font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-tertiary);
  flex-shrink: 0;
}
.review-location-name {
  font-size: 0.8rem; color: var(--text-secondary);
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.review-round-coords {
  font-family: 'DM Mono', monospace;
  font-size: 0.82rem; color: var(--text-tertiary); letter-spacing: 0.01em;
}
.review-map-el { height: 200px; width: 100%; }
.review-player-rows {
  display: flex; flex-direction: column;
  border-top: 1px solid var(--border);
}

.dot-anim { font-size: 0.88rem; color: var(--text-tertiary); font-style: italic; }
.dot-anim::after {
  content: ''; animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots {
  0%  { content: ''; } 25% { content: '.'; }
  50% { content: '..'; } 75% { content: '...'; }
}

/* Per-player result rows */
.reveal-player-results {
  display: flex; flex-direction: column; gap: 0;
  border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--border);
}

.rpr-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.rpr-row:last-child { border-bottom: none; }
.rpr-row:nth-child(even) { background: var(--surface-2); }

.rpr-badge {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.82rem; font-weight: 700;
  font-family: 'DM Sans', sans-serif; flex-shrink: 0;
  overflow: hidden; /* so emoji doesn't overflow */
}
.rpr-badge.emoji-badge {
  font-size: 1rem; background: var(--surface-2) !important;
  border-color: var(--border-strong); color: transparent;
}

.rpr-name {
  font-weight: 600; font-size: 0.88rem; flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.rpr-stats { display: flex; gap: 12px; flex-shrink: 0; }

.rpr-stat { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.rpr-stat-label {
  font-size: 0.58rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-tertiary);
}
.rpr-stat-val {
  font-family: 'DM Mono', monospace; font-size: 0.82rem; font-weight: 500; color: var(--text-primary);
}
.rpr-stat-val.accent { color: var(--accent); font-weight: 600; }

/* ─── Final Scores ──────────────────────────────────────────── */
#screen-final { background: transparent; }

.final-bg { position: fixed; inset: 0; z-index: 0; background: #f0ede6; }
.final-bg::before {
  content: '';
  position: absolute; inset: 0;
  background-image: url('coordguessr_background.svg');
  background-size: cover; background-position: center center;
  background-repeat: no-repeat; opacity: 0.6; pointer-events: none;
}
.final-content {
  position: relative; z-index: 1;
  flex: 1;
  display: flex; flex-direction: column; justify-content: center;
  padding: 24px 16px 48px;   /* 16px side gutters like the rest of the game */
}
.final-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 22px 18px;
  margin-bottom: 20px;
  overflow: hidden;
  max-width: 480px;
  width: 100%;
  margin-left: auto; margin-right: auto;
}

/* True-centre the h2 regardless of back-button width */
.final-card .screen-topbar { position: relative; }
.final-card .screen-topbar h2 {
  position: absolute; left: 50%; transform: translateX(-50%);
  white-space: nowrap;
}

.final-header { text-align: center; padding: 8px 0 16px; }
.trophy { font-size: 2.8rem; margin-bottom: 10px; filter: drop-shadow(0 4px 12px rgba(0,0,0,0.12)); }
.final-header h2 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.03em; }
.final-meta { margin-top: 5px; font-size: 0.84rem; color: var(--text-secondary); }

.final-scores {
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-top: 4px;
}

.final-row {
  display: grid; grid-template-columns: 44px 1fr auto;
  align-items: center; gap: 10px; padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}
.final-row:last-child { border-bottom: none; }
.final-row.winner { background: var(--green-light); }

.final-rank { font-family: 'DM Mono', monospace; font-size: 1.1rem; font-weight: 700; text-align: center; }
.final-rank.gold   { color: #c9922a; }
.final-rank.silver { color: #7a8fa0; }
.final-rank.bronze { color: #9a6040; }
.final-rank.other  { font-size: 0.9rem; color: var(--text-tertiary); }

.final-name { font-weight: 600; font-size: 0.98rem; }
.final-score {
  font-family: 'DM Mono', monospace; font-size: 0.98rem; font-weight: 500;
  color: var(--text-secondary); text-align: right;
}
.final-row.winner .final-score { color: var(--green); font-weight: 600; }

/* ─── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 28px 28px 24px;
  width: 100%; max-width: 320px;
  display: flex; flex-direction: column; gap: 10px;
  animation: modal-in 0.18s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.modal-title {
  font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em;
}
.modal-body { font-size: 0.88rem; color: var(--text-secondary); }
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px;
}
.modal-actions .btn-ghost { color: var(--text-secondary); }

/* Danger / success button variants (used in quit modal) */
.btn-danger {
  padding: 13px 24px; border-radius: var(--r-md); border: none;
  background: var(--danger); color: #fff;
  font-family: 'DM Sans', sans-serif; font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.btn-danger:hover { opacity: 0.9; }
.btn-danger:active { transform: scale(0.98); }

.btn-success {
  padding: 13px 24px; border-radius: var(--r-md); border: none;
  background: var(--green); color: #fff;
  font-family: 'DM Sans', sans-serif; font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.btn-success:hover { opacity: 0.9; }
.btn-success:active { transform: scale(0.98); }

.credits-card { text-align: center; gap: 8px; }
.modal-label {
  font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-tertiary);
}
.modal-name {
  font-size: 1rem; font-weight: 600; color: var(--text-primary);
}
.modal-link {
  font-size: 0.82rem; color: var(--accent); text-decoration: none; font-weight: 500;
}
.modal-link:hover { text-decoration: underline; }
/* Leaderboard rank badge shown on final screen */
.final-lb-tag {
  display: inline-block;
  font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--accent-light); color: var(--accent);
  border-radius: 5px; padding: 2px 7px;
  margin-left: 8px; vertical-align: middle;
}

.modal-url-icon {
  display: inline-flex; align-items: center;
  margin-left: 7px; color: var(--accent);
  vertical-align: middle; text-decoration: none;
  opacity: 0.75; transition: opacity 0.15s;
}
.modal-url-icon:hover { opacity: 1; }

.credits-divider {
  height: 1px; background: var(--border); margin: 6px 0;
}
/* Attribution block — both rows left-edge-aligned, block centered in modal */
.credits-attr {
  display: inline-flex; flex-direction: column; gap: 5px;
  align-self: center;
}
.credits-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.78rem; color: var(--text-tertiary); font-weight: 500;
}
/* keep old selector for any legacy references */
.credits-claude {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 0.78rem; color: var(--text-tertiary); font-weight: 500;
}

.credits-btn-link {
  background: none; border: none;
  color: var(--text-tertiary); font-size: 0.78rem;
  font-family: 'DM Sans', sans-serif; font-weight: 400;
  cursor: pointer; padding: 12px 0 4px;
  display: block; margin: 0 auto;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.credits-btn-link:hover { color: var(--text-secondary); }

/* ─── Utilities ─────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Leaflet overrides ─────────────────────────────────────── */
.leaflet-container { font-family: 'DM Sans', sans-serif; background: #c9d9e8; }
.leaflet-control-zoom a { color: var(--text-primary) !important; background: var(--surface) !important; }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 380px) {
  .setup-card { padding: 18px 14px; }
  .coord-val { font-size: 0.95rem; }
  .rpr-stats { gap: 8px; }
}

#screen-game { min-height: 100dvh; }
#game-map { flex: 1; min-height: 200px; }

/* ══════════════════════════════════════════════════════════════
   LOGO — Split Targets animation
══════════════════════════════════════════════════════════════ */
.logo-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 12px;
}
/* SVG element */
.lv1-svg { display: block; max-width: 100%; overflow: visible; }

/* Crosshairs — hidden initially; positioned by Web Animations API */
.lg-t1 { opacity: 0; }
.lg-t2 { opacity: 0; }
/* Text — slides in via CSS animation */
.lg-c  { opacity: 0; transform: translateX(-72px); }
.lg-rd { opacity: 0; transform: translateX(72px); }
.lg-gs { opacity: 0; transform: translateY(22px); }

.lv1-play .lg-c  { animation: lv1-slide-in .42s cubic-bezier(.22,1,.36,1) 1.15s both; }
.lv1-play .lg-rd { animation: lv1-slide-in .42s cubic-bezier(.22,1,.36,1) 1.15s both; }
.lv1-play .lg-gs { animation: lv1-gs-in   .48s cubic-bezier(.22,1,.36,1) 1.52s both; }
.lv1-play .lv1-pulse { animation: lv1-pulse 2.2s ease-in-out 2.1s infinite; }

@keyframes lv1-slide-in { to { opacity:1; transform: translateX(0); } }
@keyframes lv1-gs-in    { to { opacity:1; transform: translateY(0); } }
@keyframes lv1-pulse {
  0%,100% { filter: drop-shadow(0 0 0px rgba(24,95,165,0)); }
  50%     { filter: drop-shadow(0 0 12px rgba(24,95,165,.3)); }
}


/* ─── Desktop layout (≥ 720px) ──────────────────────────────── */
@media (min-width: 720px) {

  /* Setup — wider content, 2-column card */
  .setup-content { max-width: 820px; padding: 40px 32px 64px; }
  .setup-header { padding: 32px 0 28px; }

  .setup-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 36px;
    row-gap: 14px;
    padding: 28px 32px 28px;
  }
  /* Players section spans both columns */
  .setup-card > .setup-section:first-child { grid-column: 1 / -1; }
  /* Region section spans both columns */
  .setup-card > .region-section { grid-column: 1 / -1; }
  /* Start button, leaderboard link and stats row span both columns */
  .setup-card > .btn-primary,
  .setup-card > .btn-ghost,
  .setup-card > .stats-row { grid-column: 1 / -1; }

  /* Region map is wider on desktop */
  .region-preview-map { width: 220px; }

  /* Game topbar — desktop padding */
  .game-topbar { padding: 0 20px; min-height: 56px; }
  .coord-float { top: 56px; }
  .topbar-spacer { display: none; }

  /* Inner containers (leaderboard, review, final) */
  .inner { max-width: 820px; }

  /* Review rounds — 2-column grid */
  #review-rounds-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }
  .review-round { margin-bottom: 0; }

  /* Final card wider */
  .final-card { max-width: 560px; margin-left: auto; margin-right: auto; margin-bottom: 16px; }
}
