/* ============================================================
   Kus see on? v2 — uniform orange theme, mobile + desktop
   ============================================================ */

:root {
  --orange-50:  #fff7ed;
  --orange-100: #ffedd5;
  --orange-200: #fed7aa;
  --orange-300: #fdba74;
  --orange-400: #fb923c;
  --orange-500: #f97316;
  --orange-600: #ea580c;
  --orange-700: #c2410c;
  --orange-800: #9a3412;
  --orange-900: #7c2d12;

  --bg:        #1c1210;
  --bg-soft:   #261915;
  --surface:   #2e1f1a;
  --surface-2: #3a2820;
  --border:    #4d352a;
  --text:      #fff7ed;
  --text-dim:  #d8b8a5;
  --danger:    #ef4444;
  --success:   #22c55e;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .45);
  --font: 'Outfit', system-ui, -apple-system, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background:
    radial-gradient(1200px 800px at 80% -10%, rgba(249, 115, 22, .18), transparent 60%),
    radial-gradient(900px 700px at -10% 110%, rgba(194, 65, 12, .15), transparent 60%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button { font-family: inherit; }
input { font-family: inherit; }

.hidden { display: none !important; }
.muted { color: var(--text-dim); font-size: .9rem; }
.accent { color: var(--orange-500); }

/* ---------------- screens ---------------- */

.screen {
  display: none;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen.active { display: block; }
.screen-game { padding: 0; }

/* ---------------- buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border: none;
  border-radius: var(--radius-sm);
  padding: .7rem 1.4rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--orange-500), var(--orange-600));
  color: white;
  box-shadow: 0 4px 18px rgba(249, 115, 22, .35);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 24px rgba(249, 115, 22, .5); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-ghost { background: transparent; color: var(--orange-300); border: 1px solid var(--orange-700); }
.btn-ghost:hover { background: rgba(249, 115, 22, .12); }

.btn-xl { padding: 1rem 2rem; font-size: 1.15rem; border-radius: var(--radius); }
.btn-small { padding: .4rem .8rem; font-size: .85rem; }

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s;
  position: relative;
}
.icon-btn:hover { background: var(--border); }

/* ---------------- topbar / home ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.4rem;
  max-width: 1100px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.15rem; }
.brand-pin {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 0;
  background: linear-gradient(135deg, var(--orange-400), var(--orange-600));
  transform: rotate(-45deg);
  box-shadow: 0 2px 10px rgba(249, 115, 22, .5);
}
.topbar-actions { display: flex; align-items: center; gap: .6rem; }

.user-chip {
  display: flex; align-items: center; gap: .4rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: .25rem .35rem .25rem .9rem;
}
.user-chip-name { background: none; border: none; color: var(--orange-300); font-weight: 700; cursor: pointer; font-size: .95rem; }

.home-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.4rem 4rem;
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 2.5rem;
  align-items: start;
}

.hero { padding-top: 3rem; }
.hero-title { font-size: clamp(2.6rem, 6vw, 4.2rem); font-weight: 800; line-height: 1.05; }
.hero-sub { margin: 1rem 0 2rem; color: var(--text-dim); font-size: 1.15rem; max-width: 30rem; }
.hero-actions { display: flex; gap: 1rem; flex-wrap: wrap; }

/* ---------------- cards & panels ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.3rem;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-head h2 { font-size: 1.2rem; }
.card-inset { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; }

.panel {
  max-width: 640px;
  margin: 4vh auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.6rem;
}
.panel-narrow { max-width: 440px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.2rem; }
.panel-head h2 { font-size: 1.4rem; font-weight: 800; }
.panel-actions { display: flex; gap: .8rem; justify-content: flex-end; align-items: center; margin-top: 1.6rem; flex-wrap: wrap; }

/* ---------------- forms ---------------- */

.form-grid { display: grid; gap: 1.1rem; }
.field { display: grid; gap: .45rem; }
.field-label { font-size: .85rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }

input[type="text"], input[type="password"] {
  background: var(--bg-soft);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: .75rem 1rem;
  font-size: 1rem;
  outline: none;
  transition: border-color .12s;
  width: 100%;
}
input[type="text"]:focus, input[type="password"]:focus { border-color: var(--orange-500); }
.code-input { letter-spacing: .4em; text-align: center; font-size: 1.3rem !important; font-weight: 700; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 3px;
  background: var(--surface-2);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--orange-500);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(249, 115, 22, .6);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border: none; border-radius: 50%;
  background: var(--orange-500); cursor: pointer;
}

.seg {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.seg-wide { display: flex; }
.seg-wide .seg-btn { flex: 1; }
.seg-btn {
  border: none; background: transparent; color: var(--text-dim);
  padding: .5rem 1rem; border-radius: 999px;
  font-weight: 600; font-size: .9rem; cursor: pointer;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.seg-btn.active { background: var(--orange-600); color: white; }

.toggles { display: flex; gap: .6rem; flex-wrap: wrap; }
.toggle {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--bg-soft); border: 1.5px solid var(--border);
  padding: .5rem .9rem; border-radius: 999px;
  cursor: pointer; font-size: .9rem; font-weight: 600;
  user-select: none;
}
.toggle:has(input:checked) { border-color: var(--orange-500); color: var(--orange-300); }
.toggle input { accent-color: var(--orange-500); }

.form-error { color: var(--danger); font-size: .9rem; }
.field-hint { font-size: .82rem; color: var(--text-dim); }

/* ---------------- leaderboard ---------------- */

.leaderboard-list { display: grid; gap: .4rem; }
.lb-row {
  display: flex; align-items: center; gap: .8rem;
  background: var(--bg-soft); border-radius: var(--radius-sm);
  padding: .6rem .9rem;
}
.lb-rank { width: 1.6rem; font-weight: 800; color: var(--orange-400); }
.lb-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 700; color: var(--orange-300); }
.lb-games { font-size: .78rem; color: var(--text-dim); }

/* ---------------- lobby ---------------- */

.lobby-code-box {
  background: linear-gradient(135deg, rgba(249, 115, 22, .15), rgba(194, 65, 12, .1));
  border: 1px dashed var(--orange-600);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1.4rem;
  text-align: center;
}
.lobby-code-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim); }
.lobby-code-row { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: .3rem; flex-wrap: wrap; }
.lobby-code { font-size: 2.4rem; font-weight: 800; letter-spacing: .18em; color: var(--orange-400); }

.lobby-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.lobby-players h3 { margin-bottom: .7rem; font-size: 1rem; }
.player-list { list-style: none; display: grid; gap: .4rem; }
.player-item {
  display: flex; align-items: center; gap: .6rem;
  background: var(--bg-soft); border-radius: var(--radius-sm);
  padding: .55rem .8rem; font-weight: 600;
}
.player-item .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--success); flex: none; }
.player-item.offline .dot { background: var(--text-dim); }
.player-item .host-tag { font-size: .7rem; background: var(--orange-600); color: white; padding: .1rem .5rem; border-radius: 999px; }
.player-item .spectator-tag {
  font-size: .7rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: .1rem .5rem;
  border-radius: 999px;
}
.player-item .kick { margin-left: auto; background: none; border: none; color: var(--danger); cursor: pointer; font-size: 1rem; }

.lobby-settings { font-size: .92rem; display: grid; gap: .5rem; align-content: start; }
.lobby-settings .row { display: flex; justify-content: space-between; gap: 1rem; }
.lobby-settings .row b { color: var(--orange-300); }

/* ---------------- game screen ---------------- */

.streetview-wrap { position: fixed; inset: 0; background: #000; }
.streetview { width: 100%; height: 100%; }

/* Swapping panoramas (observer following a player) blanks the canvas to black
   for a frame or two. Veil it in the app's own background so the change reads
   as a crossfade rather than a flicker: snap the veil on, ease it back off. */
.streetview-wrap::after {
  content: '';
  position: absolute; inset: 0;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  transition: opacity .3s ease;
}
.streetview-wrap.sv-switching::after { opacity: 1; transition: opacity .09s ease; }

.hud {
  position: fixed;
  top: calc(.8rem + env(safe-area-inset-top));
  left: .8rem;
  display: flex; gap: .5rem; flex-wrap: wrap;
  z-index: 30;
  max-width: calc(100vw - 7rem);
}
.hud-pill {
  background: rgba(28, 18, 16, .82);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: .45rem .95rem;
  font-weight: 700;
  font-size: .92rem;
}
.hud-timer { color: var(--orange-400); border-color: var(--orange-700); }

.hud-compass { display: flex; align-items: center; gap: .45rem; font-variant-numeric: tabular-nums; }
.compass-dial {
  width: 18px; height: 18px;
  border: 1.5px solid var(--orange-600);
  border-radius: 50%;
  position: relative;
  flex: none;
}
.compass-needle {
  position: absolute;
  left: 50%; top: 50%;
  width: 0; height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-bottom: 9px solid var(--orange-400);
  transform-origin: 50% 75%;
  transform: translate(-50%, -70%) rotate(0deg);
  transition: transform .1s linear;
}
.hud-timer.urgent { color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .5; } }

.game-side-actions {
  position: fixed;
  top: calc(.8rem + env(safe-area-inset-top));
  right: .8rem;
  display: flex; flex-direction: column; gap: .5rem;
  z-index: 30;
}
.game-btn {
  position: relative;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 14px;
  /* same surface as the HUD pills */
  background: rgba(28, 18, 16, .82);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  color: var(--orange-200);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .38);
  transition: background .14s ease, color .14s ease, border-color .14s ease, transform .14s ease;
}
.game-btn svg {
  width: 21px; height: 21px;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.game-btn:hover {
  background: var(--orange-600);
  border-color: transparent;
  color: #fff;
  transform: translateY(-1px);
}
.game-btn:active { transform: scale(.93); }
.game-btn-danger:hover { background: var(--danger); }

/* hover label, pointer devices only */
.game-btn::after {
  content: attr(data-label);
  position: absolute;
  right: calc(100% + .55rem);
  top: 50%;
  transform: translateY(-50%);
  background: rgba(28, 18, 16, .92);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: .8rem; font-weight: 600;
  padding: .3rem .6rem;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .14s ease;
}
@media (hover: hover) { .game-btn:hover::after { opacity: 1; } }

.chat-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--orange-500); color: white;
  font-size: .65rem; font-weight: 800;
  min-width: 17px; height: 17px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* ---------------- observer (host watches instead of playing) ---------------- */

/* Sits over the panorama; the HUD (z 30) and bars stay on top.
   The wrapper owns the layout because Maps overwrites the mount point's
   inline position — sizing the mount point directly collapses it to 0px.
   Never display:none either: a Google map built inside a zero-size container
   comes up blank. Kept laid out and merely invisible, it initialises at full
   size, its tiles stay warm, and switching to it is instant. */
.spectate-map-wrap {
  position: fixed; inset: 0;
  z-index: 20;
  background: var(--bg);
  transition: opacity .18s ease;
}
.spectate-map-wrap.map-off {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.spectate-map { width: 100%; height: 100%; }

.hud-spectating { color: var(--orange-300); border-color: var(--orange-700); }

.spectate-bar {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  display: flex; align-items: center; gap: .6rem;
  max-width: min(760px, calc(100vw - 1.6rem));
  padding: .5rem .8rem;
  background: rgba(28, 18, 16, .86);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.spectate-bar-label {
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-dim);
  flex: none;
}
.spectate-players {
  display: flex; gap: .4rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
}
.spectate-players::-webkit-scrollbar { display: none; }
.spectate-chip {
  display: flex; align-items: center; gap: .4rem;
  flex: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: .35rem .8rem;
  font-family: inherit;
  font-size: .88rem; font-weight: 600;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease, transform .14s ease;
}
.spectate-chip:hover { background: var(--surface-2); transform: translateY(-1px); }
.spectate-chip.active { border-color: var(--orange-500); background: rgba(249, 115, 22, .18); color: var(--orange-200); }
.spectate-chip .swatch { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.spectate-chip .state { font-size: .74rem; color: var(--text-dim); }
.spectate-chip.done .state { color: var(--success); }
.spectate-chip.gone { opacity: .5; }

/* name labels drawn on the observer map */
.spectate-map-label { text-shadow: 0 1px 3px rgba(0, 0, 0, .9), 0 0 2px rgba(0, 0, 0, .9); }

/* guess map — corner widget desktop, bottom sheet mobile */
.guess-wrap {
  position: fixed;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .5rem;
}
.guess-toggle {
  background: linear-gradient(135deg, var(--orange-500), var(--orange-600));
  color: white; border: none;
  border-radius: 999px;
  padding: .8rem 1.3rem;
  font-size: 1rem; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(249, 115, 22, .45);
  display: flex; align-items: center; gap: .5rem;
}
.guess-toggle svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.guess-map-box {
  display: flex; flex-direction: column; gap: .5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem;
  box-shadow: var(--shadow);
  width: min(420px, calc(100vw - 2rem));
}
.guess-map { width: 100%; height: 300px; border-radius: var(--radius-sm); overflow: hidden; }
.guess-submit { width: 100%; }
.guess-wrap.collapsed .guess-map-box { display: none; }
.guess-wrap.expanded .guess-toggle span { display: inline; }

/* ---------------- overlays ---------------- */

.overlay {
  position: fixed; inset: 0;
  background: rgba(15, 9, 7, .78);
  backdrop-filter: blur(6px);
  z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}
.overlay-clear { background: rgba(15, 9, 7, .35); }
.overlay-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.6rem;
  width: min(480px, 100%);
  text-align: center;
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
}
.overlay-card-wide { width: min(680px, 100%); text-align: left; }
.overlay-card h3 { font-size: 1.3rem; margin-bottom: 1rem; }
.overlay-actions { display: flex; justify-content: center; margin-top: 1.2rem; }

.spinner {
  width: 46px; height: 46px;
  border: 4px solid var(--surface-2);
  border-top-color: var(--orange-500);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ready-list { display: grid; gap: .35rem; margin-top: 1rem; text-align: left; }
.ready-item {
  display: flex; align-items: center; gap: .6rem;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: .45rem .8rem;
  font-size: .92rem; font-weight: 600;
}
.ready-item .state { margin-left: auto; font-size: .85rem; color: var(--text-dim); }
.ready-item.is-ready .state { color: var(--success); }

.countdown-num {
  font-size: clamp(6rem, 25vw, 11rem);
  font-weight: 800;
  color: var(--orange-500);
  text-shadow: 0 0 60px rgba(249, 115, 22, .6);
  animation: pop .9s ease infinite;
}
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 25% { transform: scale(1.05); opacity: 1; } 100% { transform: scale(1); opacity: .9; } }

.results-map { width: 100%; height: 280px; border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 1rem; background: var(--bg-soft); }
.results-list { display: grid; gap: .4rem; }
.result-row {
  display: flex; align-items: center; gap: .8rem;
  background: var(--bg-soft); border-radius: var(--radius-sm);
  padding: .6rem .9rem; font-size: .95rem;
}
.result-row.me { border: 1.5px solid var(--orange-600); }
.result-rank { font-weight: 800; color: var(--orange-400); width: 1.4rem; }
.result-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-dist { color: var(--text-dim); font-size: .85rem; }
.result-pts { font-weight: 800; color: var(--orange-300); }
.result-total { font-size: .8rem; color: var(--text-dim); }

/* ---------------- chat ---------------- */

.chat-panel {
  position: fixed;
  right: .8rem;
  top: calc(4rem + env(safe-area-inset-top));
  width: min(340px, calc(100vw - 1.6rem));
  height: min(440px, 60dvh);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 55;
  display: flex; flex-direction: column;
}
.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1rem; font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.chat-messages { flex: 1; overflow-y: auto; padding: .8rem; display: grid; gap: .5rem; align-content: start; }
.chat-msg { background: var(--bg-soft); border-radius: var(--radius-sm); padding: .45rem .7rem; font-size: .9rem; word-break: break-word; }
.chat-msg .chat-author { color: var(--orange-400); font-weight: 700; margin-right: .4rem; }
.chat-msg.mine { background: rgba(249, 115, 22, .16); }
.chat-input-row { display: flex; gap: .5rem; padding: .7rem; border-top: 1px solid var(--border); }
.chat-input-row input { flex: 1; }

/* ---------------- summary ---------------- */

.summary-podium { display: flex; justify-content: center; gap: 1rem; margin-bottom: 1.6rem; flex-wrap: wrap; }
.podium-slot {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.4rem;
  text-align: center; min-width: 120px;
}
.podium-slot.first { border-color: var(--orange-500); background: rgba(249, 115, 22, .12); }
.podium-medal { font-size: 1.8rem; }
.podium-name { font-weight: 700; margin: .3rem 0; }
.podium-score { color: var(--orange-300); font-weight: 800; font-size: 1.2rem; }

.summary-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .8rem; margin-bottom: 1.6rem; }
.stat-box { background: var(--bg-soft); border-radius: var(--radius-sm); padding: .9rem; text-align: center; }
.stat-box .v { font-size: 1.3rem; font-weight: 800; color: var(--orange-400); }
.stat-box .l { font-size: .8rem; color: var(--text-dim); margin-top: .2rem; }

.summary-rounds { display: grid; gap: .4rem; }
.summary-round-row {
  display: flex; align-items: center; gap: .8rem;
  background: var(--bg-soft); border-radius: var(--radius-sm);
  padding: .55rem .9rem; font-size: .92rem;
}
.summary-round-row .rn { font-weight: 800; color: var(--orange-400); width: 1.6rem; }
.summary-round-row .loc { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); }
.summary-round-row .pts { font-weight: 700; color: var(--orange-300); }

/* ---------------- modals & toast ---------------- */

.modal {
  position: fixed; inset: 0;
  background: rgba(15, 9, 7, .7);
  backdrop-filter: blur(5px);
  z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.6rem;
  width: min(420px, 100%);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
}
.modal-card .seg { margin-bottom: 1.2rem; }

.profile-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; margin-bottom: 1.2rem; }
.profile-games { display: grid; gap: .4rem; }
.profile-game-row {
  display: flex; justify-content: space-between; gap: .8rem;
  background: var(--bg-soft); border-radius: var(--radius-sm);
  padding: .5rem .8rem; font-size: .88rem;
}

.toast {
  position: fixed;
  bottom: calc(1.4rem + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--orange-600);
  color: var(--text);
  border-radius: 999px;
  padding: .7rem 1.4rem;
  font-weight: 600;
  z-index: 100;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 2rem);
  text-align: center;
}

/* ---------------- responsive ---------------- */

@media (max-width: 900px) {
  .home-main { grid-template-columns: 1fr; gap: 1.6rem; }
  .hero { padding-top: 1rem; text-align: center; }
  .hero-sub { margin-inline: auto; }
  .hero-actions { justify-content: center; }
  .lobby-columns { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .panel { margin: 0; min-height: 100dvh; border-radius: 0; border: none; padding: 1.2rem 1rem calc(1.2rem + env(safe-area-inset-bottom)); }
  .panel-actions { position: sticky; bottom: 0; background: var(--surface); padding-top: .8rem; }
  .panel-actions .btn { flex: 1; }

  /* guess map becomes a bottom sheet */
  .guess-wrap { left: 0; right: 0; bottom: 0; align-items: stretch; }
  .guess-toggle { margin: 0 auto calc(.8rem + env(safe-area-inset-bottom)); }
  .guess-wrap.expanded .guess-toggle { display: none; }
  .guess-map-box {
    width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    padding-bottom: calc(.6rem + env(safe-area-inset-bottom));
  }
  .guess-map { height: min(46dvh, 340px); }

  .chat-panel { top: auto; bottom: 0; right: 0; width: 100%; height: 55dvh; border-radius: var(--radius) var(--radius) 0 0; }

  .hud-pill { font-size: .8rem; padding: .35rem .7rem; }
  .results-map { height: 220px; }
  .game-btn { width: 42px; height: 42px; border-radius: 12px; }
  .game-btn svg { width: 19px; height: 19px; }
}

/* ================= kakahoot embed mode ================= */
/* Strip navigation chrome when running inside a kakahoot minigame iframe. */

body.kk-embed .topbar,
body.kk-embed .leaderboard-card,
body.kk-embed #btn-copy-link,
body.kk-embed #btn-leave-lobby,
body.kk-embed #btn-leave-lobby-2,
body.kk-embed #btn-open-auth,
body.kk-embed #screen-summary .panel-actions {
  display: none !important;
}
