/* ============================================================
   GeoGuessr Clone — UI
   Precise, cartographic, no noise
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
  /* Backgrounds */
  --bg:         #0d1117;
  --bg-subtle:  #161b22;
  --bg-overlay: #1c2128;
  --bg-inset:   #010409;

  /* Borders */
  --border:       #30363d;
  --border-muted: #21262d;

  /* Foregrounds */
  --fg:        #e6edf3;
  --fg-muted:  #8b949e;
  --fg-subtle: #484f58;

  /* Accent — blue */
  --accent:        #2f81f7;
  --accent-subtle: rgba(47,129,247,.12);
  --accent-muted:  rgba(47,129,247,.25);

  /* Semantic */
  --success: #3fb950;
  --warning: #d29922;
  --danger:  #f85149;
  --done:    #a371f7;

  --success-subtle: rgba(63,185,80,.12);
  --danger-subtle:  rgba(248,81,73,.12);
  --warning-subtle: rgba(210,153,34,.12);
  --done-subtle:    rgba(163,113,247,.12);

  /* Teams */
  --team-a: #58a6ff;
  --team-b: #f85149;

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

  /* Radii */
  --r-sm: 4px;
  --r:    6px;
  --r-lg: 8px;

  /* Transitions */
  --t: 120ms ease;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
img, svg { display: block; }

/* ---------- Views ---------- */
.view { display: none; min-height: 100vh; }
.view--active { display: block; }
.view--fullscreen {
  position: fixed; inset: 0; z-index: 100; overflow: hidden;
}
.view--fullscreen.view--active { display: flex; flex-direction: column; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: var(--r);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
  transition: background var(--t), border-color var(--t), color var(--t);
  user-select: none;
}
.btn:active { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn--primary {
  background: var(--accent);
  border-color: rgba(240,246,252,.1);
  color: #fff;
}
.btn--primary:hover:not(:disabled) { background: #388bfd; }

.btn--success {
  background: var(--success);
  border-color: rgba(240,246,252,.1);
  color: #0d1117;
}
.btn--success:hover:not(:disabled) { background: #46c85a; }

.btn--danger {
  background: var(--danger);
  border-color: rgba(240,246,252,.1);
  color: #fff;
}
.btn--danger:hover:not(:disabled) { background: #ff6a63; }

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--fg-muted);
}
.btn--ghost:hover:not(:disabled) {
  background: var(--bg-overlay);
  border-color: var(--border);
  color: var(--fg);
}

.btn--lg  { padding: 10px 20px; font-size: 15px; line-height: 22px; }
.btn--sm  { padding: 3px 12px; font-size: 12px; line-height: 18px; }
.btn--xs  { padding: 2px 8px;  font-size: 11px; line-height: 16px; }
.btn--block { width: 100%; }

/* ---------- Inputs ---------- */
.input {
  display: block;
  width: 100%;
  padding: 5px 12px;
  background: var(--bg-inset);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 14px;
  line-height: 20px;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}
.input::placeholder { color: var(--fg-subtle); }
.input--lg { padding: 7px 14px; font-size: 15px; }
.input--code {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .15em;
  text-align: center;
  text-transform: uppercase;
  width: 148px;
}

.form-hint { font-size: 12px; color: var(--fg-muted); margin-top: 4px; }
.form-hint-inline { font-size: 11px; color: var(--fg-muted); font-weight: 400; }

/* ---------- Toggle ---------- */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle__slider {
  position: absolute; inset: 0; border-radius: 22px;
  background: var(--bg-overlay); border: 1px solid var(--border);
  cursor: pointer; transition: var(--t);
}
.toggle__slider::before {
  content: ''; position: absolute;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--fg-muted); left: 2px; top: 2px;
  transition: transform var(--t), background var(--t);
}
.toggle input:checked + .toggle__slider { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle__slider::before { transform: translateX(18px); background: #fff; }

/* ---------- Toast ---------- */
#toast-container {
  position: fixed; bottom: 16px; right: 16px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999; pointer-events: none;
}
.toast {
  padding: 10px 14px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  font-size: 13px; font-weight: 500;
  background: var(--bg-overlay);
  color: var(--fg);
  max-width: 320px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s, transform .25s;
  pointer-events: none;
}
.toast--visible { opacity: 1; transform: translateY(0); }
.toast--success { background: var(--success-subtle); border-color: var(--success); color: var(--success); }
.toast--error   { background: var(--danger-subtle);  border-color: var(--danger);  color: var(--danger); }
.toast--info    { background: var(--bg-overlay); border-color: var(--border); color: var(--fg); }

.toast--achievement {
  background: var(--done-subtle);
  border-color: var(--done);
  color: var(--fg);
  max-width: 340px;
}
.toast--xp {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--fg);
}
.toast-ach__header {
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--done); margin-bottom: 6px;
}
.toast-ach__body { display: flex; align-items: center; gap: 10px; }
.toast-ach__icon { font-size: 1.6rem; line-height: 1; }
.toast-ach__name { font-weight: 600; font-size: 13px; }
.toast-ach__desc { font-size: 12px; color: var(--fg-muted); margin-top: 2px; }

/* ---------- Spinner ---------- */
.spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Shared states ---------- */
.loading-state, .empty-state, .error-state {
  text-align: center; padding: 40px 20px; color: var(--fg-muted); font-size: 13px;
}
.loading-state .spinner { width: 20px; height: 20px; }
.error-state { color: var(--danger); }


/* ============================================================
   HOME VIEW
   ============================================================ */
.home {
  min-height: 100vh;
  display: flex; flex-direction: column;
  max-width: 1040px; margin: 0 auto; padding: 0 24px 48px;
}

/* Header */
.home__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 0 32px;
  border-bottom: 1px solid var(--border-muted);
  margin-bottom: 28px;
  gap: 16px; flex-wrap: wrap;
}
.home__brand { display: flex; flex-direction: column; gap: 2px; }
.home__logo {
  font-size: 22px; font-weight: 700; letter-spacing: -.02em; color: var(--fg);
}
.home__tagline { color: var(--fg-muted); font-size: 13px; }
.home__nav { display: flex; gap: 6px; flex-wrap: wrap; }

/* Body layout */
.home__body {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  flex: 1;
}
.home__sidebar { display: flex; flex-direction: column; gap: 16px; }
.home__main    { display: flex; flex-direction: column; gap: 16px; }

/* Cards */
.home__card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
}
.home__card-label {
  font-size: 11px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--fg-muted); margin-bottom: 14px;
}

/* Avatar picker */
.avatar-picker {
  display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px;
}
.avatar-btn {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  transition: border-color var(--t), background var(--t);
}
.avatar-btn:hover { background: var(--bg-inset); border-color: var(--fg-subtle); }
.avatar-btn--active { border-color: var(--accent); background: var(--accent-subtle); }

/* Join rows */
.join-row { display: flex; gap: 8px; align-items: center; }
.join-row .input--code { flex: 1; min-width: 0; }

/* Quick play strip */
.home__quickplay {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.quick-action {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: border-color var(--t), background var(--t);
}
.quick-action:hover { border-color: var(--accent); background: var(--accent-subtle); }
.quick-action__icon { font-size: 20px; margin-bottom: 4px; }
.quick-action__text strong { display: block; font-size: 13px; font-weight: 600; color: var(--fg); }
.quick-action__text span   { display: block; font-size: 11px; color: var(--fg-muted); margin-top: 1px; }

/* Create game card + mode grid */
.home__card--create { flex: 1; }
.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mode-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 14px 12px;
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  transition: border-color var(--t), background var(--t);
  text-align: left; position: relative;
}
.mode-card:hover { border-color: var(--accent); background: var(--accent-subtle); }
.mode-card__icon { font-size: 22px; line-height: 1; }
.mode-card__body { flex: 1; min-width: 0; }
.mode-card__name { display: block; font-size: 13px; font-weight: 600; color: var(--fg); margin-bottom: 2px; }
.mode-card__desc { display: block; font-size: 11px; color: var(--fg-muted); line-height: 1.4; }
.mode-card__badge {
  position: absolute; top: 8px; right: 8px;
  font-size: 10px; font-weight: 600;
  background: var(--done-subtle); color: var(--done);
  border: 1px solid var(--done); border-radius: 20px;
  padding: 1px 6px;
}

/* Badge */
.badge--me {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 600;
  padding: 1px 7px; border-radius: 20px;
  background: var(--accent-subtle);
  border: 1px solid var(--accent);
  color: var(--accent);
  vertical-align: middle;
  font-style: normal;
}


/* ============================================================
   LOBBY VIEW
   ============================================================ */
.lobby { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.lobby__header {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.lobby__title {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 600; flex: 1;
}
.lobby__mode-icon { font-size: 18px; }
.lobby__code-badge {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px;
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.lobby__code-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-subtle); }
.lobby__code {
  font-family: var(--mono); font-size: 18px; font-weight: 700;
  letter-spacing: .12em; color: var(--warning);
}

.lobby__body {
  flex: 1;
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  min-height: 0;
  overflow: hidden;
}
.lobby__panel {
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}
.lobby__panel:last-child { border-right: none; border-left: 1px solid var(--border); }
.lobby__panel--settings { border-right: none; padding: 20px 24px; }

.panel__title {
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--fg-muted); margin-bottom: 12px;
}

/* Team tabs */
.team-tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.team-tab {
  flex: 1; padding: 5px 10px;
  border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--bg-overlay); font-size: 12px; font-weight: 600;
  color: var(--fg-muted); cursor: pointer; transition: all var(--t);
}
.team-tab:hover { border-color: var(--fg-subtle); color: var(--fg); }
.team-tab--active.team-tab--a { background: rgba(88,166,255,.12); border-color: var(--team-a); color: var(--team-a); }
.team-tab--active.team-tab--b { background: rgba(248,81,73,.12); border-color: var(--team-b); color: var(--team-b); }

/* Players */
.player-list { display: flex; flex-direction: column; gap: 6px; }
.player-card {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-muted);
  border-radius: var(--r);
  font-size: 13px;
}
.player-card--me { border-color: var(--accent); background: var(--accent-subtle); }
.player-card--disconnected { opacity: .4; }
.player-card__avatar { font-size: 18px; flex-shrink: 0; }
.player-card__name { flex: 1; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-card__dc { font-size: 10px; color: var(--warning); font-weight: 600; }
.player-card__you {
  font-size: 10px; font-weight: 600;
  color: var(--accent); background: var(--accent-subtle);
  border: 1px solid var(--accent); border-radius: 20px;
  padding: 1px 7px; flex-shrink: 0;
}

/* Spectators */
.spectators-section { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-muted); }
.spectator-list { display: flex; flex-direction: column; gap: 4px; }
.spectator-item { font-size: 12px; color: var(--fg-muted); padding: 3px 0; }

/* Skip vote */
.skip-vote { margin-bottom: 12px; padding: 10px 12px; background: var(--warning-subtle); border: 1px solid var(--warning); border-radius: var(--r); }
.skip-vote__label { font-size: 12px; font-weight: 600; color: var(--warning); margin-bottom: 6px; }
.skip-vote__bar { height: 3px; background: var(--border); border-radius: 3px; overflow: hidden; }
.skip-vote__fill { height: 100%; background: var(--warning); border-radius: 3px; transition: width .3s; }

/* Settings */
.settings-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group--inline { flex-direction: row; align-items: center; justify-content: space-between; }
.form-label { font-size: 12px; font-weight: 600; color: var(--fg-muted); }

.settings-readonly { display: flex; flex-direction: column; }
.settings-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--border-muted);
}
.settings-row:last-child { border-bottom: none; }
.settings-row span { color: var(--fg-muted); }
.settings-row strong { color: var(--fg); font-weight: 600; font-family: var(--mono); font-size: 12px; }

.lobby__status {
  margin: 12px 0; padding: 8px 12px;
  background: var(--warning-subtle);
  border: 1px solid var(--warning);
  border-radius: var(--r);
  font-size: 13px; font-weight: 600; color: var(--warning);
  min-height: 0;
  display: none;
}
.lobby__status:not(:empty) { display: block; }
.lobby__waiting { padding: 16px 0; color: var(--fg-muted); font-size: 13px; }

/* Chat */
.lobby__panel--chat { display: flex; flex-direction: column; gap: 0; padding: 0; }
.lobby__panel--chat .panel__title { padding: 16px 16px 0; margin-bottom: 12px; }
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 0 16px 8px;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 0;
}
.chat-msg { display: flex; flex-direction: column; gap: 2px; }
.chat-msg__name { font-size: 11px; color: var(--fg-subtle); }
.chat-msg__text {
  background: var(--bg-overlay);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-sm);
  padding: 5px 9px; font-size: 13px;
  word-break: break-word; max-width: 88%; align-self: flex-start;
}
.chat-msg--me .chat-msg__name { text-align: right; }
.chat-msg--me .chat-msg__text {
  background: var(--accent-subtle);
  border-color: var(--accent-muted);
  align-self: flex-end;
}
.chat-input-row {
  display: flex; gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input-row .input { flex: 1; }


/* ============================================================
   GAME VIEW
   ============================================================ */
.game {
  flex: 1; position: relative;
  background: #000; overflow: hidden;
  display: flex; flex-direction: column;
}

.game__hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,.75) 0%, transparent 100%);
  pointer-events: none;
}
.hud__left, .hud__right { display: flex; flex-direction: column; gap: 4px; }
.hud__right { align-items: flex-end; }
.hud__actions { display: flex; gap: 6px; pointer-events: auto; }
.hud__center { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hud__round {
  font-size: 13px; font-weight: 600;
  background: rgba(0,0,0,.5);
  padding: 3px 10px; border-radius: var(--r-sm);
  border: 1px solid rgba(255,255,255,.1);
}
.hud__mode {
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255,255,255,.5);
}
.hud__skip-btn { pointer-events: auto; opacity: .7; }
.hud__skip-btn:hover { opacity: 1; }
.hud__leave-btn { pointer-events: auto; opacity: .5; }
.hud__leave-btn:hover { opacity: 1; color: var(--danger); border-color: var(--danger); }

.spectator-banner {
  position: absolute; top: 52px; left: 50%; transform: translateX(-50%);
  z-index: 10;
  background: rgba(0,0,0,.65);
  border: 1px solid var(--warning);
  border-radius: var(--r-sm); padding: 3px 12px;
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--warning);
}

/* Timer */
.timer {
  font-family: var(--mono);
  font-size: 2rem; font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
  transition: color var(--t);
}
.timer--warning { color: var(--warning); }
.timer--danger  { color: var(--danger); animation: timerPulse .5s ease-in-out infinite; }
.timer__bar { width: 100px; height: 3px; background: rgba(255,255,255,.15); border-radius: 3px; overflow: hidden; }
.timer__bar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 1s linear; }
@keyframes timerPulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* HUD Players */
.hud__players { display: flex; gap: 5px; pointer-events: auto; }
.hud-player {
  display: flex; align-items: center; gap: 4px;
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--r-sm);
  padding: 3px 8px; font-size: 11px;
  transition: opacity var(--t);
}
.hud-player--me { border-color: var(--accent); background: rgba(47,129,247,.2); }
.hud-player--guessed { opacity: .35; }
.hud-player__avatar { font-size: 13px; }
.hud-player__name { color: rgba(255,255,255,.6); max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-player__score { font-family: var(--mono); font-weight: 600; color: var(--success); font-size: 11px; }

/* Street View */
.streetview { flex: 1; position: relative; background: #111; color-scheme: light; }
.streetview > div:not(.streetview__loading) { width: 100%; height: 100%; }
.streetview__loading {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg); color: var(--fg-muted); gap: 8px; z-index: 5;
}
.streetview__no-key, .streetview__error {
  text-align: center; max-width: 340px; padding: 24px;
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--r-lg); line-height: 1.6; font-size: 13px;
}
.streetview__error-detail { font-size: 11px; color: var(--danger); margin-top: 6px; font-family: var(--mono); }

/* Skip vote HUD */
.skip-vote-hud {
  position: absolute; bottom: 220px; left: 50%; transform: translateX(-50%);
  z-index: 15;
  display: flex; align-items: center; gap: 10px;
  background: rgba(0,0,0,.8);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--r-sm); padding: 6px 12px;
  font-size: 11px; font-weight: 600; min-width: 180px;
}
.skip-vote-hud__bar { flex: 1; height: 3px; background: rgba(255,255,255,.1); border-radius: 3px; overflow: hidden; }
.skip-vote-hud__fill { height: 100%; background: var(--warning); border-radius: 3px; transition: width .3s; }

/* Guess map */
.guess-map-wrap {
  position: absolute; bottom: 16px; right: 16px; z-index: 20;
  width: 280px; height: 190px;
  border-radius: var(--r);
  border: 1px solid rgba(255,255,255,.12);
  overflow: hidden;
  transition: width .25s ease, height .25s ease;
  background: var(--bg);
  box-shadow: 0 4px 24px rgba(0,0,0,.6);
}
.guess-map-wrap--expanded { width: 440px; height: 320px; }
.guess-map { width: 100%; height: calc(100% - 40px); }
.guess-map__footer {
  height: 40px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px;
  background: var(--bg-subtle); border-top: 1px solid var(--border);
}
.guess-map__coords { font-family: var(--mono); font-size: 11px; color: var(--fg-subtle); flex: 1; }
.guess-map__pass { position: absolute; top: 5px; left: 5px; opacity: .55; }
.guess-map__pass:hover { opacity: 1; }

/* Leaflet pins */
.guess-pin { background: none; border: none; }
.guess-pin__inner {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
  box-shadow: 0 1px 6px rgba(0,0,0,.6);
}
.player-pin { background: none; border: none; }
.player-pin__inner {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 10px; color: #fff;
  border: 2px solid rgba(255,255,255,.7);
  box-shadow: 0 1px 6px rgba(0,0,0,.6);
}
.actual-pin { background: none; border: none; }
.actual-pin__inner { font-size: 22px; filter: drop-shadow(0 1px 3px rgba(0,0,0,.5)); }


/* ============================================================
   RESULTS VIEW
   ============================================================ */
.results { display: flex; flex-direction: column; height: 100%; background: var(--bg); }

.results__header {
  padding: 14px 20px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.results__round { font-size: 15px; font-weight: 700; }
.results__location { color: var(--fg-muted); font-size: 13px; flex: 1; }
.results__region { color: var(--fg-subtle); }

.results__body {
  flex: 1; display: grid;
  grid-template-columns: 1fr 200px 300px;
  min-height: 0; overflow: hidden;
}
.results__map { overflow: hidden; }
.results__my-score {
  display: flex; align-items: center; justify-content: center;
  padding: 20px 16px;
  background: var(--bg-subtle);
  border-left: 1px solid var(--border);
}
.results__players {
  padding: 16px;
  background: var(--bg-subtle);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}
.results__players h3 {
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--fg-muted); margin-bottom: 10px;
}

/* Score display */
.score-display { text-align: center; }
.score-display__value {
  font-family: var(--mono);
  font-size: 3rem; font-weight: 700; line-height: 1;
  color: var(--score-colour, var(--success));
  margin-bottom: 4px;
}
.score-display__grade {
  font-size: 12px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--score-colour, var(--success));
  margin-bottom: 8px;
}
.score-display__distance { font-size: 12px; color: var(--fg-muted); }
.score-display__context { font-size: 11px; color: var(--fg-subtle); margin-top: 4px; }

/* Result rows */
.results__player-list { display: flex; flex-direction: column; }
.result-row {
  display: grid;
  grid-template-columns: 20px 22px 1fr 18px auto auto auto;
  align-items: center; gap: 5px;
  padding: 7px 2px; border-bottom: 1px solid var(--border-muted);
  font-size: 12px;
}
.result-row:last-child { border-bottom: none; }
.result-row--me { background: var(--accent-subtle); border-radius: var(--r-sm); padding: 7px 5px; }
.result-row__rank  { font-family: var(--mono); color: var(--fg-subtle); font-size: 11px; font-weight: 600; }
.result-row__avatar { font-size: 14px; }
.result-row__name  { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-row__flag  { font-size: 13px; }
.result-row__distance { color: var(--fg-muted); white-space: nowrap; font-family: var(--mono); font-size: 11px; }
.result-row__score { font-family: var(--mono); font-weight: 700; white-space: nowrap; }
.result-row__total { font-family: var(--mono); color: var(--fg-subtle); font-size: 10px; white-space: nowrap; }

.results__footer {
  padding: 10px 20px;
  background: var(--bg-subtle); border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; gap: 20px;
  flex-shrink: 0;
}
.results__countdown { color: var(--fg-muted); font-size: 12px; font-family: var(--mono); }
.results__eliminated { color: var(--danger); font-size: 12px; font-weight: 600; }


/* ============================================================
   SUMMARY VIEW
   ============================================================ */
.summary { max-width: 680px; margin: 0 auto; padding: 40px 20px 80px; }

.summary__header { text-align: center; margin-bottom: 40px; }
.summary__title { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.summary__subtitle { color: var(--fg-muted); font-size: 13px; margin-top: 4px; }

.summary__winner-banner { margin-bottom: 16px; }
.summary__winner-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-subtle); }
.summary__winner-name { font-size: 22px; font-weight: 700; }

.summary__team-winner {
  display: inline-block; margin-bottom: 16px;
  padding: 12px 24px; border-radius: var(--r);
  font-size: 18px; font-weight: 700; border: 1px solid;
}
.team-winner--a { background: rgba(88,166,255,.1); border-color: var(--team-a); color: var(--team-a); }
.team-winner--b { background: rgba(248,81,73,.1); border-color: var(--team-b); color: var(--team-b); }
.team-scores { display: flex; gap: 20px; justify-content: center; font-size: 13px; margin-top: 6px; color: var(--fg-muted); font-weight: 400; }

/* Podium */
.summary__podium {
  display: flex; align-items: flex-end; justify-content: center;
  gap: 12px; margin-bottom: 32px;
}
.podium-card {
  display: flex; flex-direction: column; align-items: center;
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 12px;
  flex: 1; max-width: 180px;
}
.podium-card--1 { border-color: var(--warning); order: 2; padding-bottom: 24px; }
.podium-card--2 { order: 1; padding-bottom: 12px; }
.podium-card--3 { order: 3; }
.podium-card--me { box-shadow: 0 0 0 2px var(--accent); }
.podium-card__medal  { font-size: 24px; margin-bottom: 8px; }
.podium-card__avatar { font-size: 24px; margin-bottom: 6px; }
.podium-card__name   { font-size: 12px; font-weight: 600; text-align: center; margin-bottom: 4px; }
.podium-card__score  { font-family: var(--mono); font-size: 16px; font-weight: 700; color: var(--warning); }
.podium-card__xp     { font-size: 11px; color: var(--accent); margin-top: 3px; font-family: var(--mono); }

/* Final standings */
.summary__full-scores {
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden; margin-bottom: 20px;
}
.summary__full-scores h3 {
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--fg-muted);
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.summary__score-list { display: flex; flex-direction: column; }
.final-score-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--border-muted);
  font-size: 13px;
}
.final-score-row:last-child { border-bottom: none; }
.final-score-row--me { background: var(--accent-subtle); }
.final-score-row__rank   { width: 32px; text-align: center; font-size: 16px; }
.final-score-row__avatar { font-size: 18px; }
.final-score-row__name   { flex: 1; font-weight: 500; }
.final-score-row__score  { font-family: var(--mono); font-weight: 700; font-size: 14px; }
.final-score-row__xp     { font-family: var(--mono); font-size: 11px; color: var(--accent); }

.summary__my-rank {
  text-align: center; color: var(--fg-muted); font-size: 13px; margin-bottom: 24px;
}
.summary__my-rank strong { color: var(--fg); }
.summary__xp-badge { color: var(--accent); font-family: var(--mono); font-weight: 700; }

.summary__actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.summary__waiting { color: var(--fg-muted); text-align: center; padding: 12px 0; font-size: 13px; }


/* ============================================================
   LEADERBOARD VIEW
   ============================================================ */
.leaderboard-page { max-width: 740px; margin: 0 auto; padding: 32px 20px 80px; }

.leaderboard-page__header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px;
}
.leaderboard-page__title { font-size: 20px; font-weight: 700; }

.leaderboard-page__filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.filter-group { display: flex; gap: 2px; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--r); padding: 2px; }
.filter-btn {
  padding: 4px 12px; border-radius: var(--r-sm); border: none;
  background: transparent; color: var(--fg-muted); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all var(--t);
}
.filter-btn:hover { color: var(--fg); background: var(--bg-overlay); }
.filter-btn--active { background: var(--bg-overlay); color: var(--fg); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }

.lb-loading, .lb-empty, .lb-error {
  text-align: center; padding: 40px; color: var(--fg-muted); font-size: 13px;
}
.lb-error { color: var(--danger); }

.lb-table {
  width: 100%; border-collapse: collapse;
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
}
.lb-table thead th {
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 600; color: var(--fg-muted);
  text-transform: uppercase; letter-spacing: .06em;
  background: var(--bg-overlay); border-bottom: 1px solid var(--border);
}
.lb-table tbody tr { border-bottom: 1px solid var(--border-muted); transition: background var(--t); }
.lb-table tbody tr:last-child { border-bottom: none; }
.lb-table tbody tr:hover { background: var(--bg-overlay); }
.lb-table td { padding: 10px 14px; font-size: 13px; }
.lb-table__row--me { background: var(--accent-subtle) !important; }
.lb-table__rank  { font-size: 16px; width: 48px; }
.lb-table__player { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.lb-table__avatar { font-size: 16px; }
.lb-table__score { font-family: var(--mono); font-weight: 700; color: var(--warning); }

.lb-player-link {
  background: none; border: none; padding: 0; font-family: inherit; font-size: inherit;
  font-weight: 500; color: var(--fg); cursor: pointer;
}
.lb-player-link:hover { color: var(--accent); text-decoration: underline; }


/* ============================================================
   PROFILE VIEW
   ============================================================ */
.profile-page { max-width: 740px; margin: 0 auto; padding: 32px 20px 80px; }
.profile-page__header { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }

.profile-content { }

.profile-hero {
  display: flex; align-items: flex-start; gap: 20px;
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 24px; margin-bottom: 16px;
}
.profile-avatar { font-size: 48px; line-height: 1; flex-shrink: 0; }
.profile-info { flex: 1; min-width: 0; }
.profile-name {
  font-size: 20px; font-weight: 700; margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px;
}
.profile-level { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.level-badge {
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 20px;
  background: var(--done-subtle);
  border: 1px solid var(--done);
  color: var(--done);
}
.level-title { font-size: 13px; color: var(--fg-muted); }
.xp-bar-wrap { max-width: 380px; }
.xp-bar {
  height: 6px; background: var(--bg-inset); border-radius: 6px;
  overflow: hidden; margin-bottom: 4px; border: 1px solid var(--border);
}
.xp-bar__fill { height: 100%; background: var(--accent); border-radius: 6px; transition: width 1s ease; }
.xp-label { font-size: 11px; color: var(--fg-subtle); font-family: var(--mono); }

.profile-stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px;
}
.stat-card {
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 12px; text-align: center;
}
.stat-card__icon  { font-size: 18px; margin-bottom: 6px; }
.stat-card__val   { font-family: var(--mono); font-size: 20px; font-weight: 700; color: var(--fg); margin-bottom: 2px; }
.stat-card__label { font-size: 11px; color: var(--fg-muted); }

.profile-section { margin-bottom: 24px; }
.profile-section__title {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--fg-muted); margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Achievements */
.achievement-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.achievement-card {
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px 8px; text-align: center;
  transition: border-color var(--t);
}
.achievement-card--earned { border-color: var(--warning); }
.achievement-card--locked { opacity: .35; }
.achievement-card:hover { border-color: var(--fg-subtle); }
.achievement-card--earned:hover { border-color: var(--warning); }
.achievement-card__icon { font-size: 24px; margin-bottom: 4px; }
.achievement-card__name { font-size: 11px; font-weight: 500; line-height: 1.3; color: var(--fg); }
.achievement-card__date { font-size: 10px; color: var(--fg-subtle); margin-top: 3px; font-family: var(--mono); }

/* History */
.history-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.history-row {
  display: grid;
  grid-template-columns: 1fr 1fr 48px 80px 60px 80px;
  align-items: center; gap: 8px;
  padding: 10px 14px; font-size: 12px;
  border-bottom: 1px solid var(--border-muted);
  background: var(--bg-subtle);
}
.history-row:last-child { border-bottom: none; }
.history-row:nth-child(even) { background: var(--bg-overlay); }
.history-mode   { font-weight: 600; text-transform: capitalize; color: var(--fg); }
.history-region { color: var(--fg-muted); }
.history-rank   { font-family: var(--mono); font-weight: 700; color: var(--warning); }
.history-score  { font-family: var(--mono); font-weight: 700; }
.history-xp     { font-family: var(--mono); font-size: 11px; color: var(--accent); }
.history-date   { font-family: var(--mono); font-size: 11px; color: var(--fg-subtle); }


/* ============================================================
   PUBLIC LOBBIES VIEW
   ============================================================ */
.lobbies-page { max-width: 640px; margin: 0 auto; padding: 32px 20px 80px; }
.lobbies-page__header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.lobbies-page__header h2 { flex: 1; font-size: 20px; font-weight: 700; }
.lobbies-page__subtitle { color: var(--fg-muted); font-size: 13px; margin-bottom: 20px; }

.lobbies-list { display: flex; flex-direction: column; gap: 8px; }
.lobbies-empty {
  text-align: center; padding: 40px; color: var(--fg-muted); font-size: 13px;
  background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--r-lg);
}

.lobby-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 12px 16px;
  transition: border-color var(--t);
}
.lobby-card:hover { border-color: var(--accent); }
.lobby-card__icon { font-size: 22px; flex-shrink: 0; }
.lobby-card__info { flex: 1; min-width: 0; }
.lobby-card__mode { font-weight: 600; font-size: 13px; text-transform: capitalize; }
.lobby-card__host { font-size: 12px; color: var(--fg-muted); }
.lobby-card__region { font-size: 11px; color: var(--fg-subtle); }
.lobby-card__players { min-width: 72px; text-align: right; }
.lobby-card__count { font-family: var(--mono); font-size: 12px; font-weight: 600; display: block; margin-bottom: 4px; }
.lobby-card__bar { height: 3px; background: var(--border); border-radius: 3px; overflow: hidden; }
.lobby-card__bar > div { height: 100%; background: var(--success); border-radius: 3px; }
.lobby-card__actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.lobby-card__lock { font-size: 13px; color: var(--fg-muted); }


/* ============================================================
   DAILY RESULTS OVERLAY
   ============================================================ */
.daily-results-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.daily-results-card {
  position: relative;
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 28px;
  max-width: 420px; width: 100%; max-height: 90vh; overflow-y: auto;
}
.daily-results-card h2 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.daily-results-card h3 {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--fg-muted); margin: 16px 0 10px;
}
.daily-results-card__close {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; color: var(--fg-muted); cursor: pointer;
  padding: 4px 7px; border-radius: var(--r-sm); font-size: 14px; line-height: 1;
}
.daily-results-card__close:hover { background: var(--bg-overlay); color: var(--fg); }
.daily-results__already { color: var(--fg-muted); font-size: 12px; margin-bottom: 10px; }
.daily-results__my-score { font-size: 13px; margin-bottom: 6px; }
.daily-score { font-family: var(--mono); font-weight: 700; color: var(--warning); font-size: 16px; }

.daily-lb { display: flex; flex-direction: column; gap: 4px; }
.daily-lb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--r-sm);
  background: var(--bg-overlay); font-size: 12px;
}
.daily-lb-row--me { background: var(--accent-subtle); border: 1px solid var(--accent); }
.daily-lb-row__rank  { font-family: var(--mono); font-weight: 700; color: var(--fg-muted); min-width: 24px; }
.daily-lb-row__name  { flex: 1; font-weight: 500; }
.daily-lb-row__score { font-family: var(--mono); font-weight: 700; color: var(--warning); }


/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 860px) {
  .home__body { grid-template-columns: 1fr; }
  .home__quickplay { grid-template-columns: 1fr; }
  .mode-grid { grid-template-columns: repeat(2, 1fr); }
  .profile-stats-grid { grid-template-columns: repeat(3, 1fr); }
  .results__body { grid-template-columns: 1fr; grid-template-rows: 280px auto auto; overflow-y: auto; }
  .results__my-score, .results__players { border-left: none; border-top: 1px solid var(--border); }
  .summary__podium { gap: 8px; }
}

@media (max-width: 720px) {
  .lobby__body { grid-template-columns: 1fr; }
  .lobby__panel--chat { max-height: 280px; }
  .lobby__panel { border-right: none; border-bottom: 1px solid var(--border); }
  .lobby__panel:last-child { border-left: none; border-bottom: none; }
}

@media (max-width: 600px) {
  .home { padding: 0 16px 40px; }
  .home__logo { font-size: 20px; }
  .mode-grid { grid-template-columns: 1fr 1fr; }
  .profile-hero { flex-direction: column; }
  .profile-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .history-row { grid-template-columns: 1fr auto auto; }
  .history-region, .history-xp { display: none; }
  .achievement-grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
  .guess-map-wrap { width: 240px; height: 170px; }
  .guess-map-wrap--expanded { width: calc(100vw - 24px); height: 240px; }
  .game__hud { padding: 8px 10px; }
  .hud__players { display: none; }
  .timer { font-size: 1.5rem; }
  .summary__podium { flex-direction: column; align-items: center; }
  .podium-card--1, .podium-card--2, .podium-card--3 { order: unset; padding-bottom: 16px; max-width: 100%; width: 100%; }
}
