/* ==========================================================================
   WanderPenh — "Painted street sign" design system
   Warm paper, temple gold, hard ink borders, ticket edges and a tuk-tuk.
   ========================================================================== */

:root {
  --paper: #fff8ee;
  --paper-2: #f7ead5;
  --card: #fffdf8;
  --ink: #223331;
  --ink-2: #53645f;
  --line: #223331;
  --gold: #e0a526;
  --gold-deep: #b9800e;
  --on-gold: #2a1d00;
  --lotus: #e4578a;
  --mekong: #1f7fb8;
  --rice: #4caf6a;
  --danger: #c8402f;
  --hard: 5px 6px 0 rgba(34, 51, 49, 0.16);
  --hard-sm: 0 3px 0 rgba(34, 51, 49, 0.9);
  --radius-card: 22px;
  --radius-btn: 13px;
  --radius-pill: 999px;
  --safe-top: max(14px, env(safe-area-inset-top));
  --safe-bottom: max(14px, env(safe-area-inset-bottom));
  --sheet-peek: 100px;
  color-scheme: light;
}

[data-theme='dark'] {
  --paper: #0f1e1f;
  --paper-2: #16292a;
  --card: #152728;
  --ink: #fff3e2;
  --ink-2: #bfcdc8;
  --line: #eadcc8;
  --hard: 5px 6px 0 rgba(0, 0, 0, 0.45);
  --hard-sm: 0 3px 0 rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  font-family: 'Plus Jakarta Sans', 'Kantumruy Pro', system-ui, sans-serif;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(0deg, transparent 0 43px, rgba(34, 51, 49, 0.045) 43px 44px),
    repeating-linear-gradient(90deg, transparent 0 43px, rgba(34, 51, 49, 0.045) 43px 44px);
  overflow: hidden;
  width: 100%;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

html[lang='km'] body {
  font-family: 'Kantumruy Pro', 'Plus Jakarta Sans', system-ui, sans-serif;
  line-height: 1.7;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
h4 {
  line-height: 1.05;
  letter-spacing: -0.035em;
  font-weight: 800;
}

html[lang='km'] h1,
html[lang='km'] h2,
html[lang='km'] h3,
html[lang='km'] h4 {
  letter-spacing: 0;
  line-height: 1.45;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--mekong);
  outline-offset: 3px;
  border-radius: 6px;
}

::selection {
  background: var(--gold);
  color: var(--on-gold);
}

/* --- icons ---------------------------------------------------------------- */
.icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 28px; height: 28px; }

/* --- buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 11px 20px;
  border: 2px solid var(--line);
  border-radius: var(--radius-btn);
  background: var(--card);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.94rem;
  text-decoration: none;
  box-shadow: var(--hard-sm);
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
  text-align: center;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 rgba(0, 0, 0, 0); }
.btn-primary { background: var(--gold); color: var(--on-gold); }
.btn-pink { background: var(--lotus); color: #fff; }
.btn-blue { background: var(--mekong); color: #fff; }
.btn-green { background: var(--rice); color: #08240f; }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-sm { min-height: 44px; padding: 8px 14px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-icon-only {
  width: 46px;
  height: 46px;
  min-height: 0;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--hard-sm);
  transition: transform 0.14s ease;
}
.btn-icon-only:hover { transform: translateY(-2px) rotate(-4deg); }
.btn-icon-only:active { transform: translateY(2px); box-shadow: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--paper);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.chip-gold { background: var(--gold); color: var(--on-gold); }
.chip-ink { background: var(--ink); color: var(--paper); }

/* --- screens -------------------------------------------------------------- */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 10;
}
.screen.active { display: block; }

/* Opaque backdrops: game/result screens sit on top of each other. */
#start-screen,
#lobby-screen,
#result-screen,
#final-screen { background-color: var(--paper); }

@keyframes riseIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==========================================================================
   DOORS
   ========================================================================== */
#doors-screen {
  z-index: 60;
  overflow-y: auto;
  padding: var(--safe-top) 18px var(--safe-bottom);
  background:
    radial-gradient(circle at 88% 8%, rgba(224, 165, 38, 0.24), transparent 46%),
    radial-gradient(circle at 4% 88%, rgba(31, 127, 184, 0.16), transparent 42%),
    var(--paper);
}
.doors-wrap {
  max-width: 960px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  padding: 24px 0;
}
.doors-head { text-align: center; }
.doors-kicker {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 4px;
  margin-bottom: 12px;
}
.doors-head h1 {
  font-size: clamp(2rem, 6vw, 3.2rem);
  margin-bottom: 10px;
}
.doors-head p { color: var(--ink-2); max-width: 44ch; margin: 0 auto; font-weight: 500; }
.doors-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.door {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-height: 240px;
  padding: 24px;
  border: 2.5px solid var(--line);
  border-radius: 28px;
  box-shadow: 7px 8px 0 rgba(34, 51, 49, 0.2);
  text-align: left;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.door:hover { transform: translateY(-4px) rotate(-0.6deg); box-shadow: 10px 12px 0 rgba(34, 51, 49, 0.22); }
.door:active { transform: translateY(2px); box-shadow: 2px 3px 0 rgba(34, 51, 49, 0.2); }
.door-kh { background: var(--gold); color: var(--on-gold); }
.door-world { background: var(--mekong); color: #fff; }
.door-art { position: absolute; right: -10px; bottom: -14px; width: 150px; height: 150px; opacity: 0.95; pointer-events: none; }
.door-km { font-size: clamp(1.6rem, 4vw, 2.3rem); font-weight: 700; line-height: 1.35; }
.door-en { font-size: 1.05rem; font-weight: 800; letter-spacing: -0.01em; }
.door-desc { font-size: 0.86rem; font-weight: 600; max-width: 22ch; opacity: 0.86; margin-top: auto; }
.door-go {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  font-weight: 900;
  font-size: 0.85rem;
  border-bottom: 2px solid currentColor;
  padding-bottom: 2px;
}
.doors-foot { text-align: center; font-size: 0.78rem; color: var(--ink-2); font-weight: 600; }

/* ==========================================================================
   HOME
   ========================================================================== */
#start-screen { overflow-y: auto; }
.home-layout {
  max-width: 1060px;
  margin: 0 auto;
  padding: var(--safe-top) 18px calc(32px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0 2px;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 0;
  background: transparent;
  padding: 4px;
  margin-right: auto;
}
.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--gold);
  border: 2px solid var(--line);
  border-radius: 14px 14px 14px 4px;
  box-shadow: var(--hard-sm);
  color: var(--on-gold);
}
.brand-name {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1;
}
.brand-sub {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 800;
  margin-top: 3px;
}

.region-switch {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border: 2px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card);
}
.region-switch button {
  border: 0;
  background: transparent;
  border-radius: var(--radius-pill);
  min-height: 44px;
  padding: 4px 13px;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ink-2);
}
.region-switch button[aria-pressed='true'] {
  background: var(--ink);
  color: var(--paper);
}
.region-switch .flag { margin-right: 4px; }
.region-switch .flag { width: 20px; height: 14px; border-radius: 2px; flex: none; box-shadow: 0 0 0 1px rgba(34, 51, 49, 0.35); }
.region-switch .flag-icon { margin-right: 4px; width: 17px; height: 17px; }

.top-actions { display: inline-flex; align-items: center; gap: 8px; }
.lang-toggle {
  min-height: 46px;
  padding: 0 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card);
  font-weight: 800;
  font-size: 0.82rem;
  box-shadow: var(--hard-sm);
}
.lang-toggle:hover { background: var(--paper-2); }

.profile-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 2px solid var(--line);
  background: var(--card);
  border-radius: var(--radius-pill);
  padding: 4px 14px 4px 4px;
  box-shadow: var(--hard-sm);
  min-height: 46px;
}
.profile-thumb {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--line);
  overflow: hidden;
  display: grid;
  place-items: center;
  flex: none;
}
.profile-name { font-size: 0.86rem; font-weight: 800; line-height: 1.2; text-align: left; }
.profile-title { display: block; font-size: 0.65rem; font-weight: 700; color: var(--ink-2); max-width: 16ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* hero */
.hero {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  align-items: center;
  gap: 12px;
  padding: 10px 0 0;
}
.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 10px;
}
.hero-kicker::before {
  content: '';
  width: 22px;
  height: 3px;
  background: var(--lotus);
  border-radius: 4px;
}
.hero h1 {
  font-size: clamp(2.6rem, 7vw, 4.4rem);
  letter-spacing: -0.055em;
  line-height: 0.95;
  margin-bottom: 12px;
}
html[lang='km'] .hero h1 { font-size: clamp(2.2rem, 6vw, 3.4rem); }
.hero h1 .dot { color: var(--gold); }
.hero-km {
  font-family: 'Kantumruy Pro', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold-deep);
  margin-bottom: 8px;
  line-height: 1.5;
}
.hero-lead { color: var(--ink-2); font-weight: 500; max-width: 42ch; font-size: 1.02rem; }
.hero-art { width: 100%; max-width: 300px; justify-self: end; }

/* play strip */
.play-strip {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 14px;
  align-items: stretch;
}
.ticket-play {
  position: relative;
  display: flex;
  align-items: stretch;
  border: 2.5px solid var(--line);
  border-radius: 22px;
  background: var(--gold);
  color: var(--on-gold);
  box-shadow: var(--hard);
  text-align: left;
  overflow: hidden;
  min-height: 132px;
  padding: 0;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.ticket-play:hover { transform: translateY(-3px) rotate(-0.4deg); }
.ticket-play:active { transform: translateY(3px); box-shadow: 1px 2px 0 rgba(34, 51, 49, 0.2); }
.ticket-main {
  flex: 1;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ticket-kicker {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.72;
}
.ticket-title {
  font-size: clamp(1.55rem, 3.4vw, 2.05rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
}
.ticket-title-km { font-size: 0.92rem; font-weight: 700; opacity: 0.8; }
.ticket-meta { margin-top: auto; font-size: 0.8rem; font-weight: 700; opacity: 0.78; padding-top: 10px; }
.ticket-stub {
  position: relative;
  width: 88px;
  flex: none;
  display: grid;
  place-items: center;
  border-left: 2px dashed rgba(42, 29, 0, 0.42);
}
.ticket-stub::before,
.ticket-stub::after {
  content: '';
  position: absolute;
  left: -9px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--paper);
  border: 2.5px solid var(--line);
}
.ticket-stub::before { top: -10px; }
.ticket-stub::after { bottom: -10px; }
.ticket-stub span {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--on-gold);
  color: var(--gold);
  display: grid;
  place-items: center;
}
.quick-stack { display: flex; flex-direction: column; gap: 12px; }
.quick-card {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--hard-sm);
  text-align: left;
  transition: transform 0.14s ease;
  min-height: 60px;
}
.quick-card:hover { transform: translateY(-2px); }
.quick-card:active { transform: translateY(2px); box-shadow: none; }
.quick-icon {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--paper-2);
  border: 2px solid var(--line);
}
.quick-card.pink .quick-icon { background: var(--lotus); color: #fff; }
.quick-card.blue .quick-icon { background: var(--mekong); color: #fff; }
.quick-title { font-size: 0.92rem; font-weight: 800; line-height: 1.2; }
.quick-sub { font-size: 0.72rem; color: var(--ink-2); font-weight: 600; }
.join-line {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.join-line input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 0 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ranked-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background:
    radial-gradient(circle at 92% 20%, rgba(31, 127, 184, 0.18), transparent 55%),
    var(--card);
  box-shadow: var(--hard-sm);
  text-align: left;
  transition: transform 0.14s ease;
}
.ranked-strip:hover { transform: translateY(-2px); }
.ranked-strip:active { transform: translateY(2px); box-shadow: none; }
.ranked-strip .quick-icon { background: var(--mekong); color: #fff; }
.ranked-copy { display: flex; flex-direction: column; min-width: 0; }
.ranked-strip .chip { margin-left: auto; }

/* section head */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--line);
  padding-bottom: 8px;
}
.section-title { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.03em; }
.section-note { font-size: 0.76rem; font-weight: 700; color: var(--ink-2); }

/* featured grid */
.featured-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.modes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.mode-card {
  --accent: var(--gold);
  position: relative;
  display: flex;
  flex-direction: column;
  border: 2px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--card);
  box-shadow: var(--hard);
  padding: 16px 16px 0;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  overflow: hidden;
}
.mode-card:hover { transform: translateY(-3px); }
.mode-card.selected { outline: 3px solid var(--mekong); outline-offset: 2px; }
.mode-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 7px;
  background: var(--accent);
}
.mode-card[data-accent='gold'] { --accent: var(--gold); }
.mode-card[data-accent='lotus'] { --accent: var(--lotus); }
.mode-card[data-accent='mekong'] { --accent: var(--mekong); }
.mode-card[data-accent='rice'] { --accent: var(--rice); }
.mode-top { display: flex; align-items: flex-start; gap: 11px; padding-left: 4px; }
.mode-stamp {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 13px;
  background: color-mix(in srgb, var(--accent) 26%, var(--card));
  color: var(--ink);
  transform: rotate(-4deg);
}
.mode-title-wrap { min-width: 0; }
.mode-title { font-size: 1.04rem; font-weight: 800; letter-spacing: -0.025em; line-height: 1.15; }
.mode-km { display: block; font-size: 0.78rem; font-weight: 700; color: var(--ink-2); margin-top: 2px; }
.mode-desc {
  font-size: 0.83rem;
  line-height: 1.5;
  color: var(--ink-2);
  font-weight: 500;
  margin: 10px 0 12px;
  padding-left: 4px;
  min-height: 2.4em;
}
.mode-chips { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 4px; margin-bottom: 13px; }
.mode-play-row {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding: 11px 0;
  border-top: 2px dashed color-mix(in srgb, var(--line) 30%, transparent);
}
.mode-play-row .btn { flex: 1; }
.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  align-self: flex-start;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 4px 4px;
}
.mode-more { display: grid; gap: 14px; }
.mode-more[hidden] { display: none; }
.more-toggle {
  align-self: flex-start;
  border: 2px dashed var(--line);
  background: transparent;
  border-radius: 12px;
  min-height: 46px;
  padding: 8px 18px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.more-toggle:hover { background: var(--paper-2); }

/* small footer */
.home-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 2px solid var(--line);
  padding-top: 14px;
  font-size: 0.72rem;
  color: var(--ink-2);
  font-weight: 600;
}
.home-foot a { color: var(--ink-2); }

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 32, 31, 0.46);
  backdrop-filter: blur(3px);
}
.modal-overlay.active { display: flex; animation: fadeIn 0.16s ease; }
.modal-card {
  width: min(560px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--card);
  border: 2.5px solid var(--line);
  border-radius: 24px;
  padding: 20px;
  box-shadow: 9px 10px 0 rgba(20, 32, 31, 0.28);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-title { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.03em; }
.modal-sub { font-size: 0.84rem; color: var(--ink-2); font-weight: 500; line-height: 1.55; }

.field-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 5px;
}
input[type='text'],
select {
  width: 100%;
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  padding: 10px 12px;
  font-weight: 700;
}

/* character studio */
.studio-preview-box {
  position: relative;
  display: grid;
  place-items: center;
  background: var(--paper-2);
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  min-height: 150px;
}
.studio-avatar-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--gold);
  border: 2.5px solid var(--line);
  box-shadow: var(--hard-sm);
}
.studio-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.studio-tab-btn {
  flex: none;
  min-height: 40px;
  padding: 6px 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--paper);
  font-size: 0.78rem;
  font-weight: 800;
}
.studio-tab-btn.active { background: var(--ink); color: var(--paper); }
.studio-picker-grid { display: block; max-height: 42dvh; overflow-y: auto; padding-right: 2px; }
.studio-section-title { font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); margin: 10px 0 6px; }
.studio-thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.studio-swatch-row { display: flex; flex-wrap: wrap; gap: 10px; }
.studio-thumb { position: relative; padding: 3px; border: 2px solid var(--line); border-radius: 14px; background: var(--paper); aspect-ratio: 1; min-width: 44px; min-height: 44px; }
.studio-thumb-art { display: block; width: 100%; height: 100%; }
.studio-thumb.selected { background: var(--gold); box-shadow: inset 0 0 0 2px var(--line); }
.studio-thumb.locked .studio-thumb-art { filter: grayscale(1); opacity: 0.45; }
.studio-lock { position: absolute; right: 3px; bottom: 1px; font-size: 0.9rem; }
.studio-history-btns { display: flex; gap: 6px; margin-top: 10px; }
.studio-preview-box { padding-top: 52px; }
@media (min-width: 760px) {
  #profile-modal .modal-card { max-width: 760px; display: grid; grid-template-columns: 240px 1fr; gap: 12px 16px; align-items: start; }
  #profile-modal .modal-header, #profile-modal > .modal-card > button.btn-primary { grid-column: 1 / -1; }
  #profile-modal .studio-preview-box { grid-column: 1; grid-row: 2 / span 3; position: sticky; top: 0; min-height: 260px; }
  #profile-modal .studio-avatar-circle { width: 200px; height: 200px; }
  #profile-modal .studio-tabs, #profile-modal #studio-picker-container, #profile-modal .modal-card > div:nth-of-type(3) { grid-column: 2; }
}
.studio-opt-btn {
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  min-height: 44px;
  padding: 8px 10px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}
.studio-opt-btn.selected { background: var(--gold); color: var(--on-gold); box-shadow: inset 0 0 0 2px var(--line); }
.color-swatch-opt {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--line);
  cursor: pointer;
  box-shadow: var(--hard-sm);
}
.color-swatch-opt.selected { outline: 3px solid var(--mekong); outline-offset: 3px; }

/* ==========================================================================
   LOBBY
   ========================================================================== */
#lobby-screen {
  overflow-y: auto;
  padding: var(--safe-top) 16px var(--safe-bottom);
}
.lobby-box {
  width: min(660px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--card);
  border: 2.5px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--hard);
  padding: 20px;
}
.room-code-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 12px 16px;
}
.room-code-val {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 800;
  letter-spacing: 0.12em;
}
.party-settings {
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  padding: 14px;
}
.party-mode-detail { color: var(--ink-2); font-size: 0.82rem; line-height: 1.55; margin-top: 8px; }
.party-settings-note { display: block; margin-top: 8px; font-size: 0.72rem; color: var(--ink-2); line-height: 1.55; }
#party-mode-owner { color: var(--ink-2); font-size: 0.72rem; font-weight: 600; }
.player-chips-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 9px; }
.lobby-player-card {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  padding: 8px 10px;
  min-height: 54px;
}
.lobby-player-thumb {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gold);
  overflow: hidden;
  border: 2px solid var(--line);
  flex: none;
  display: grid;
  place-items: center;
}
.lobby-player-card.is-me { background: color-mix(in srgb, var(--gold) 22%, var(--paper)); }
.emote-shelf { display: flex; gap: 7px; flex-wrap: wrap; }
.emote-pill {
  border: 2px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--paper);
  min-height: 40px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
}
.lobby-customize {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  justify-content: flex-start;
}
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid color-mix(in srgb, var(--ink) 20%, transparent);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   GAME
   ========================================================================== */
#game-screen { background: #0d1414; }
#streetview-container { position: absolute; inset: 0; background: #0d1414; overflow: hidden; }
/* Google's svembed place card lives inside a cross-origin iframe and cannot be
   styled, so oversize the iframe and shift it up-left: the card falls outside
   the visible container and real panorama shows in that corner instead. */
#streetview-iframe {
  position: absolute;
  top: -110px;
  left: -210px;
  width: calc(100% + 210px);
  height: calc(100% + 110px);
  border: 0;
  display: block;
}

#hud-top {
  position: absolute;
  top: var(--safe-top);
  left: 12px;
  right: 12px;
  z-index: 30;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}
.hud-group { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; pointer-events: auto; }
.hud-card {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--card);
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 5px 11px;
  min-height: 38px;
  box-shadow: var(--hard-sm);
  font-size: 0.85rem;
}
.hud-label { font-size: 0.6rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); }
.hud-value { font-size: 1rem; font-weight: 800; }
.timer-card {
  pointer-events: auto;
  background: var(--gold);
  color: var(--on-gold);
  padding: 5px 13px 5px 7px;
  gap: 6px;
  min-height: 44px;
}
.timer-ring-box { width: 28px; height: 28px; }
.timer-ring-svg { width: 28px; height: 28px; transform: rotate(-90deg); }
.timer-ring-circle { transition: stroke-dashoffset 1s linear; }
.timer-val { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Leaflet's default 30px zoom buttons are too small for thumbs. */
.leaflet-bar a.leaflet-control-zoom-in,
.leaflet-bar a.leaflet-control-zoom-out {
  width: 44px !important;
  height: 44px !important;
  line-height: 44px !important;
  font-size: 1.15rem;
}
.hud-player-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card);
  padding: 2px 7px 2px 2px;
  font-size: 0.68rem;
  font-weight: 800;
}
.hud-player-chip.guessed { background: color-mix(in srgb, var(--rice) 32%, var(--card)); }
.hud-player-chip-avatar { width: 22px; height: 22px; border-radius: 50%; overflow: hidden; background: var(--gold); flex: none; }

/* the map sheet */
#map-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 2.5px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 0 rgba(34, 51, 49, 0.14);
  transform: translateY(calc(100% - var(--sheet-peek)));
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  touch-action: none;
}
#map-panel[data-state='half'] { transform: translateY(40%); }
#map-panel[data-state='full'] { transform: translateY(0); }

.sheet-handle {
  min-height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: grab;
  background: transparent;
  border: 0;
  width: 100%;
  color: var(--ink-2);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.sheet-handle::before {
  content: '';
  width: 46px;
  height: 5px;
  border-radius: 4px;
  background: var(--line);
  opacity: 0.55;
}
.sheet-handle:active { cursor: grabbing; }

#mode-choice-shelf {
  flex: none;
  padding: 6px 12px 10px;
  border-bottom: 2px dashed color-mix(in srgb, var(--line) 30%, transparent);
}
.choice-shelf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 7px;
}
#mode-choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-height: 130px; overflow-y: auto; }
.choice-opt-btn {
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  min-height: 44px;
  padding: 5px 8px;
  font-size: 0.76rem;
  font-weight: 700;
  text-align: left;
}
.choice-opt-btn.selected { background: var(--gold); color: var(--on-gold); }

#map-wrapper { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#guess-map { position: absolute; inset: 0; background: var(--paper-2); }
.map-floating-bar {
  position: absolute;
  top: 9px;
  left: 9px;
  right: 9px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  pointer-events: none;
}
.map-tool-pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 2px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card);
  min-height: 44px;
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 800;
  box-shadow: var(--hard-sm);
}
#expand-toggle {
  min-height: 54px;
  padding: 10px 18px;
  font-size: 0.95rem;
  gap: 8px;
}
#expand-toggle .icon {
  width: 22px;
  height: 22px;
}
#map-pin-status {
  pointer-events: auto;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 6px 11px;
  font-size: 0.72rem;
  font-weight: 800;
  box-shadow: var(--hard-sm);
}
#map-pin-status.placed { background: var(--rice); color: #08240f; }
#guess-action-bar {
  flex: none;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: var(--card);
  border-top: 2px solid var(--line);
}
#guess-btn {
  width: 100%;
  min-height: 54px;
  border: 2.5px solid var(--line);
  border-radius: 14px;
  background: var(--paper-2);
  color: var(--ink-2);
  font-size: 1rem;
  font-weight: 800;
  box-shadow: var(--hard-sm);
  transition: background 0.15s ease, transform 0.15s ease;
}
#guess-btn.ready { background: var(--gold); color: var(--on-gold); }
#guess-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }

/* markers */
.marker-pin-guess {
  width: 20px;
  height: 20px;
  border-radius: 50% 50% 50% 0;
  background: var(--gold);
  border: 2.5px solid var(--ink);
  transform: rotate(-45deg);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}
.marker-pin-actual {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--rice);
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--ink);
}
.marker-player-pin { position: relative; width: 40px; height: 52px; }
.marker-pin-bubble {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2.5px solid;
  overflow: hidden;
  background: var(--gold);
  display: grid;
  place-items: center;
}
.marker-pin-point {
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 11px solid;
  margin: -2px auto 0;
}
.marker-pin-label {
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  border: 1.5px solid;
  border-radius: 8px;
  background: #fff;
  color: #223331;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
}


/* ==========================================================================
   RESULT
   ========================================================================== */
#result-screen { overflow-y: auto; padding: var(--safe-top) 14px calc(20px + var(--safe-bottom)); }
#result-screen.active { display: flex; flex-direction: column; }
.result-card {
  width: min(780px, 100%);
  margin: 0 auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.result-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.result-head h2 { font-size: clamp(1.5rem, 4vw, 2rem); }
.result-score { font-size: clamp(2rem, 6vw, 3rem); font-weight: 800; color: var(--rice); line-height: 1; font-variant-numeric: tabular-nums; }
#res-mode-banner {
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  background: var(--paper-2);
  font-weight: 800;
  font-size: 0.9rem;
  line-height: 1.5;
}
#res-mode-banner.success { background: color-mix(in srgb, var(--rice) 26%, var(--card)); }
#res-mode-banner.warning { background: color-mix(in srgb, var(--gold) 30%, var(--card)); }
.banner-line { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.banner-chip { padding: 2px 9px; border-radius: 99px; border: 1.5px solid var(--line); font-size: 0.72rem; font-weight: 800; }
.banner-chip.ok { background: var(--rice); color: #08240f; }
.banner-chip.miss { background: var(--lotus); color: #fff; }
#result-map-container {
  border: 2px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  height: 240px;
  box-shadow: var(--hard-sm);
  background: var(--paper-2);
}
#result-map { width: 100%; height: 100%; }
.result-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.result-stat-box {
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  padding: 10px 12px;
  box-shadow: var(--hard-sm);
}
.result-stat-label { font-size: 0.66rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 2px; }
.result-stat-val { font-size: clamp(1.1rem, 3vw, 1.45rem); font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.result-friend {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 7px 10px;
  font-size: 0.82rem;
  font-weight: 700;
}
.result-friend .name { flex: 1; min-width: 0; }
#mp-round-leaderboard { display: flex; flex-direction: column; gap: 7px; }
.result-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 2px dashed color-mix(in srgb, var(--line) 30%, transparent);
  padding-top: 10px;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--ink-2);
}
#mp-round-players-list { display: flex; flex-direction: column; gap: 7px; }
.mp-leaderboard-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 2px solid var(--line);
  border-radius: 13px;
  background: var(--card);
  padding: 8px 11px;
  font-size: 0.85rem;
  font-weight: 700;
}
.mp-leaderboard-row.rank-1 { background: color-mix(in srgb, var(--gold) 26%, var(--card)); }
.mp-leaderboard-row.is-me { outline: 2px solid var(--mekong); outline-offset: 1px; }
#res-next-btn {
  position: sticky;
  bottom: 0;
  width: 100%;
  min-height: 56px;
  margin-top: auto;
  font-size: 1.05rem;
  z-index: 5;
}

/* ==========================================================================
   FINAL
   ========================================================================== */
#final-screen { overflow-y: auto; padding: var(--safe-top) 14px calc(20px + var(--safe-bottom)); }
#final-screen.active { display: flex; align-items: center; justify-content: center; }
.final-box {
  width: min(680px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 2.5px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--hard);
  padding: 24px 20px;
  text-align: center;
}
.final-badge-icon { font-size: 3.2rem; line-height: 1; }
.final-box h2 { font-size: clamp(1.7rem, 5vw, 2.3rem); }
.final-total { font-size: clamp(2.6rem, 9vw, 3.8rem); font-weight: 800; color: var(--rice); line-height: 1; font-variant-numeric: tabular-nums; }
#fin-rating { font-weight: 800; color: var(--gold-deep); font-size: 1rem; }
#fin-rounds-table { width: 100%; display: flex; flex-direction: column; gap: 6px; margin: 8px 0; text-align: left; }
.final-rank { min-width: 32px; font-weight: 800; color: var(--gold-deep); white-space: nowrap; }
.final-place { min-width: 92px; }
.final-avatar {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--gold);
  border: 2px solid var(--line);
  flex: none;
}
.final-player { font-weight: 800; color: var(--ink); }
.final-points { font-weight: 800; color: var(--rice); }
.final-area { color: var(--ink-2); }
.final-hint { font-size: 0.72rem; color: var(--ink-2); margin: 6px 0 14px; text-align: left; }
.final-actions { display: flex; gap: 10px; width: 100%; }
.final-actions .btn { flex: 1; }

/* ==========================================================================
   COACH MARKS
   ========================================================================== */
#coach {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 18px 14px calc(18px + var(--safe-bottom));
  background: rgba(20, 32, 31, 0.5);
  backdrop-filter: blur(2px);
}
#coach.active { display: flex; animation: fadeIn 0.2s ease; }
.coach-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 2.5px solid var(--line);
  border-radius: 22px;
  box-shadow: 8px 9px 0 rgba(20, 32, 31, 0.3);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: riseIn 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}
.coach-step { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--lotus); }
.coach-card h3 { font-size: 1.25rem; }
.coach-card p { font-size: 0.9rem; color: var(--ink-2); line-height: 1.55; }
.coach-actions { display: flex; gap: 8px; margin-top: 4px; }
.coach-actions .btn { flex: 1; }
.coach-dots { display: flex; gap: 5px; }
.coach-dots span { width: 8px; height: 8px; border-radius: 50%; background: color-mix(in srgb, var(--ink) 22%, transparent); }
.coach-dots span.on { background: var(--gold); }

/* ==========================================================================
   TOAST
   ========================================================================== */
#toast-notification {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-bottom));
  transform: translate(-50%, 16px);
  z-index: 120;
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 10px 18px;
  font-size: 0.85rem;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}
#toast-notification.active { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   SMALL SCREENS
   ========================================================================== */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .hero-art { display: none; }
  .featured-grid { grid-template-columns: 1fr 1fr; }
  .play-strip { grid-template-columns: 1fr; }
  .quick-stack { flex-direction: row; }
  .quick-card { min-width: 0; }
  .quick-card .quick-sub { display: none; }
  #start-screen .top-actions button[onclick="openTutorialModal()"],
  #sound-toggle-btn { display: none; }
}
@media (max-width: 620px) {
  .doors-grid { grid-template-columns: 1fr; }
  .door { min-height: 190px; }
  .featured-grid { grid-template-columns: 1fr; }
  .modes-grid { grid-template-columns: 1fr; }
  .topbar { gap: 8px; }
  .brand-name { font-size: 1.05rem; }
  .brand-sub { display: none; }
  .profile-name { display: none; }
  .profile-pill { padding-right: 4px; }
  #start-screen .top-actions button[onclick="openTutorialModal()"],
  #sound-toggle-btn { display: none; }
  .region-switch { order: 3; width: 100%; }
  .region-switch button { flex: 1; }
  .top-actions { margin-left: auto; }
  .quick-stack { flex-direction: column; }
  .quick-card .quick-sub { display: block; }
  #hud-player-name { display: none; }
  #hud-top { gap: 6px; }
  .hud-group { gap: 5px; }
  .hud-card { padding: 4px 8px; min-height: 34px; border-radius: 10px; }
  .result-stats-grid { gap: 6px; }
  .result-stat-box { padding: 8px; }
  .hud-label { display: none; }
  #fin-rounds-table .mp-leaderboard-row { font-size: 0.76rem; gap: 6px; padding: 7px 8px; }
  .final-points { white-space: nowrap; }
}
@media (max-width: 380px) {
  .home-layout { padding-left: 12px; padding-right: 12px; }
  .ticket-stub { width: 66px; }
  .top-actions .btn-icon-only:nth-child(2) { display: none; }
}

/* ==========================================================================
   ACCESSIBILITY / MOTION / PRINT
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--ink) 28%, transparent); border-radius: 99px; }

/* tuk-tuk that rides the result line */
.tuktuk-ride { background: transparent; border: 0; }
.tuktuk-bubble {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-size: 21px;
  background: var(--gold);
  border: 2.5px solid var(--ink);
  border-radius: 50% 50% 50% 8px;
  box-shadow: 0 3px 0 rgba(34, 51, 49, 0.35);
  transform: rotate(-8deg);
}

/* ---------------------------------------------------------------
   Tag-Team relay: lobby teams, role banner, eyes-only / hands-only
   --------------------------------------------------------------- */
.lobby-teams { margin: 14px 0; }
.lobby-teams[hidden] { display: none; }
.lobby-teams .field-label { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.lobby-teams-hint { font-size: 0.72rem; font-weight: 700; color: var(--ink-2); text-transform: none; letter-spacing: 0; }
#lobby-teams-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.lobby-team {
  border: 2.5px solid var(--team-color, var(--line));
  border-radius: 16px;
  background: color-mix(in srgb, var(--team-color, var(--gold)) 12%, var(--card));
  padding: 8px 10px 10px;
}
.lobby-team-badge {
  display: inline-block;
  font-weight: 900;
  font-size: 0.72rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--team-color, var(--gold));
  color: #fff;
  margin-bottom: 6px;
}
.lobby-team-members { display: grid; gap: 6px; }
.lobby-team-member {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 8px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}
.lobby-team-member:disabled { cursor: default; opacity: 1; }
.lobby-team-member.picked { outline: 3px solid var(--gold); outline-offset: 1px; background: color-mix(in srgb, var(--gold) 24%, var(--card)); }
.lobby-team-member .lobby-player-thumb { width: 30px; height: 30px; flex: none; }

.team-role-banner {
  position: absolute;
  top: calc(var(--safe-top) + 62px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 24px);
  padding: 8px 16px 8px 10px;
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  background: var(--gold);
  color: var(--on-gold, #2a1d00);
  box-shadow: 0 4px 0 rgba(34, 51, 49, 0.25);
  pointer-events: none;
}
.team-role-banner[hidden] { display: none; }
.team-role-banner[data-role='pinner'] { background: var(--lotus, #e4578a); color: #fff; }
.team-role-banner[data-role='both'] { background: var(--mekong, #1f7fb8); color: #fff; }
.team-role-emoji { font-size: 1.6rem; line-height: 1; }
.team-role-copy { display: grid; gap: 1px; min-width: 0; }
.team-role-copy strong { font-size: 0.95rem; font-weight: 900; }
.team-role-copy span { font-size: 0.74rem; font-weight: 700; opacity: 0.92; }

/* Viewer: street only. */
body[data-role='viewer'] #map-panel { display: none; }
/* Pinner: map only. The panorama is not even loaded. */
body[data-role='pinner'] #streetview-container { display: none; }
body[data-role='pinner'] #control-dock .dock-items > :not(.dock-emote):not(.dock-zoom) { display: none; }
body[data-role='pinner'] .sheet-handle { display: none; }
@media (min-width: 900px) {
  body[data-role='pinner'] #map-panel { inset: 0; width: auto; height: auto; --map-h: calc(100dvh - 86px); border-radius: 0; }
}

/* Team rows on results and the final board */
.team-row { border-left: 6px solid var(--team-color, var(--gold)); }
.team-row-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.team-row-rank { font-weight: 900; min-width: 28px; font-size: 1rem; }
.team-row-faces { display: inline-flex; }
.team-row-face {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--team-color, var(--gold));
  background: var(--gold);
  flex: none;
}
.team-row-face + .team-row-face { margin-left: -10px; }
.team-row-name { font-weight: 800; font-size: 0.92rem; }
.team-row-you { font-size: 0.7rem; font-weight: 800; padding: 1px 6px; border-radius: 4px; background: var(--rice); color: var(--paper); }
.team-row-detail { font-size: 0.75rem; color: var(--ink-2); }
.team-row-score { text-align: right; }
.team-row-round { font-weight: 900; font-size: 1.05rem; color: var(--rice); }
.team-row-total { font-size: 0.74rem; font-weight: 700; color: var(--gold-deep); }

/* ---------------------------------------------------------------
   Ranked screen, tiers and leaderboards
   --------------------------------------------------------------- */
#ranked-screen { background-color: var(--paper); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.ranked-wrap { max-width: 720px; margin: 0 auto; padding: calc(var(--safe-top, 0px) + 14px) 16px 40px; display: grid; gap: 18px; }
.ranked-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ranked-head h1 { margin: 0; font-size: 1.5rem; flex: 1; min-width: 0; }
.ranked-block { display: grid; gap: 10px; }
.ranked-note { margin: 0; color: var(--ink-2); font-size: 0.84rem; font-weight: 600; }

.rank-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 2.5px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 5px 0 rgba(34, 51, 49, 0.16);
}
.tier-badge {
  flex: none;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  font-size: 2rem;
  border-radius: 50%;
  border: 3px solid var(--line);
  background: var(--tier-color, var(--gold));
}
.tier-badge.sm { width: 28px; height: 28px; font-size: 0.95rem; border-width: 2px; }
.tier-tourist { --tier-color: #cfd8d4; }
.tier-moto { --tier-color: #9bd1a8; }
.tier-tuktuk { --tier-color: #8fc6e8; }
.tier-guide { --tier-color: var(--gold); }
.tier-khan { --tier-color: var(--lotus); }
.tier-legend { --tier-color: linear-gradient(135deg, #f7d36a, #e4578a); }
.rank-card-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.rank-card-tier { font-weight: 900; font-size: 1.15rem; }
.rank-card-rating { font-weight: 800; font-size: 0.85rem; color: var(--ink-2); }
.rank-bar { height: 10px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 12%, transparent); overflow: hidden; }
.rank-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--rice); }
.rank-card-hint { font-size: 0.74rem; font-weight: 700; color: var(--ink-2); }

.ranked-modes { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.ranked-mode-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px 12px;
  border: 2.5px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(34, 51, 49, 0.16);
}
.ranked-mode-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(34, 51, 49, 0.16); }
.ranked-mode-btn small { display: block; font-weight: 600; color: var(--ink-2); font-size: 0.72rem; }
.ranked-mode-btn[disabled] { opacity: 0.6; cursor: progress; }

.board-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.board-tabs button {
  min-height: 44px;
  padding: 6px 16px;
  border: 2.5px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.board-tabs button[aria-selected='true'] { background: var(--gold); color: var(--on-gold); }
.board-mode { display: grid; gap: 4px; font-weight: 800; font-size: 0.8rem; }
.board-mode[hidden] { display: none; }
.board-mode select { min-height: 44px; border: 2.5px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font: inherit; font-weight: 700; padding: 0 10px; }
.board-list { display: grid; gap: 6px; }
.board-empty { padding: 18px; text-align: center; color: var(--ink-2); font-weight: 700; border: 2px dashed var(--line); border-radius: 16px; }
.board-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 12px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}
.board-row.is-me { background: color-mix(in srgb, var(--gold) 26%, var(--card)); border-color: var(--gold-deep); }
.board-row.top-1 { border-color: var(--gold-deep); }
.board-rank { font-weight: 900; text-align: center; }
.board-name { font-weight: 800; display: flex; align-items: center; gap: 8px; min-width: 0; }
.board-name > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-value { font-weight: 900; font-variant-numeric: tabular-nums; color: var(--rice); }
.board-me { font-weight: 800; font-size: 0.85rem; color: var(--ink-2); }
.board-me strong { color: var(--ink); }
.board-foot { font-size: 0.74rem; font-weight: 700; color: var(--ink-2); }

.ranked-backup summary { cursor: pointer; font-weight: 800; min-height: 44px; display: flex; align-items: center; }
.backup-row { display: flex; gap: 8px; margin-top: 8px; }
.backup-row input { flex: 1; min-width: 0; min-height: 44px; border: 2.5px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font: inherit; font-size: 0.78rem; padding: 0 10px; }

.ranked-result { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin: 10px 0; border: 2.5px solid var(--line); border-radius: 18px; background: var(--card); text-align: left; }
.ranked-result-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.ranked-delta { font-weight: 900; font-size: 1.1rem; }
.ranked-delta.up { color: var(--rice); }
.ranked-delta.down { color: var(--lotus); }
.ranked-result .btn { flex: none; }

/* ==========================================================================
   Guess-map helpers (client/map/tools.js)
   ========================================================================== */
.map-tools {
  position: absolute; z-index: 520; left: 9px; right: 9px; top: 62px;
  display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none;
}
.map-chips {
  display: flex; gap: 6px; overflow-x: auto; max-width: 100%; padding: 2px 2px 6px;
  scrollbar-width: none; pointer-events: auto; flex: 1 1 100%;
}
.map-chips::-webkit-scrollbar { display: none; }
.map-chip {
  flex: none; pointer-events: auto; border: 2px solid var(--line); border-radius: var(--radius-pill);
  background: var(--card); color: var(--ink); min-height: 34px; padding: 3px 11px;
  font-size: 0.72rem; font-weight: 800; box-shadow: var(--hard-sm); white-space: nowrap;
}
.map-chip.reset { background: var(--gold); color: var(--on-gold); }
.map-chip.layers { margin-left: auto; }
.map-layer-panel {
  display: none; flex-direction: column; gap: 4px; pointer-events: auto; flex: 1 1 100%;
  background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 8px 10px;
  box-shadow: var(--hard-sm); font-size: 0.78rem; font-weight: 700; max-width: 240px; margin-left: auto;
}
.map-layer-panel.open { display: flex; }
.map-layer-panel label { display: flex; gap: 8px; align-items: center; min-height: 30px; }
#map-pin-where {
  pointer-events: none; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius-pill);
  padding: 4px 11px; font-size: 0.72rem; font-weight: 800; box-shadow: var(--hard-sm);
}
.map-crosshair {
  position: absolute; z-index: 510; left: 50%; top: 50%; width: 40px; height: 40px;
  margin: -20px 0 0 -20px; pointer-events: none; color: var(--line);
  filter: drop-shadow(0 0 2px var(--card));
}
.map-loupe {
  position: absolute; z-index: 600; width: 100px; height: 100px; margin: 0 0 0 -50px;
  border: 3px solid var(--line); border-radius: 50%; overflow: hidden; background: var(--paper-2);
  box-shadow: var(--hard-sm); pointer-events: none;
}
.map-loupe .loupe-map { position: absolute; inset: 0; }
.map-loupe i { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px; border-radius: 50%; border: 2px solid var(--gold); background: rgba(224, 165, 38, 0.3); z-index: 1000; }
.khan-label {
  background: transparent; border: 0; box-shadow: none; color: #7a5a06; font-weight: 800; font-size: 0.66rem;
  text-shadow: 0 0 3px var(--card), 0 0 3px var(--card);
}
.khan-label::before { display: none; }
.river-label span { display: block; width: 90px; text-align: center; font-style: italic; font-weight: 800; font-size: 0.74rem; color: #1f6f9a; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.lm-label { white-space: nowrap; font-size: 0.64rem; font-weight: 800; color: #3b2a07; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.lm-label i { font-style: normal; color: var(--gold); margin-right: 3px; }

/* ==========================================================================
   IN-GAME HUD (Part C). Phones: top bar + bottom sheet + one ⋯ button.
   >= 900px: full-screen panorama with frosted glass panels floating on it.
   ========================================================================== */
:root { --glass: rgba(255, 250, 240, 0.82); --glass-line: rgba(34, 51, 49, 0.85); }
[data-theme='dark'] { --glass: rgba(14, 44, 46, 0.82); --glass-line: rgba(234, 220, 200, 0.7); }

#compass-strip { display: none; }
#hud-top { align-items: flex-start; }
.ticket-panel { max-width: 62vw; justify-content: flex-end; }
.ticket-collapse { display: none; }
.who-chip { position: relative; width: 28px; height: 28px; flex: none; }
.who-chip-avatar {
  width: 100%; height: 100%; border-radius: 50%; overflow: hidden; background: var(--paper-2);
  border: 2px solid var(--line); filter: grayscale(1); opacity: 0.55; transition: filter 0.25s, opacity 0.25s;
}
.who-chip.guessed .who-chip-avatar { filter: none; opacity: 1; border-color: var(--rice); }
.who-chip-tick {
  position: absolute; right: -4px; bottom: -4px; min-width: 14px; height: 14px; border-radius: 50%;
  background: var(--rice); color: #08240f; font-size: 0.6rem; line-height: 14px; text-align: center; display: none;
}
.who-chip.guessed .who-chip-tick { display: block; }

/* tuk-tuk meter: the tuk-tuk drives along the track as time runs out */
.timer-track { display: none; }
.timer-card.danger { animation: meter-pulse 0.9s ease-in-out infinite; }
.timer-card.danger .timer-val { color: var(--lotus); }
@keyframes meter-pulse { 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .timer-card.danger { animation: none; } }

.control-dock { position: absolute; z-index: 35; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; top: calc(var(--safe-top) + 64px); right: 12px; }
.dock-items { display: none; flex-direction: column; gap: 8px; }
.control-dock.open .dock-items { display: flex; }
.dock-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 1.05rem; font-weight: 800; display: grid; place-items: center; box-shadow: var(--hard-sm);
}
.dock-btn[hidden] { display: none; }
.dock-btn.btn-alert { background: var(--lotus); color: #fff; }
.dock-zoom { display: none; }
#map-pin-toggle { display: none; }
.emote-radial { position: absolute; right: 22px; top: 22px; width: 0; height: 0; }
.emote-radial[hidden] { display: none; }
.emote-radial-item {
  position: absolute; transform: translate(calc(var(--x) - 100%), var(--y)); white-space: nowrap;
  border: 2px solid var(--line); border-radius: var(--radius-pill); background: var(--card); padding: 5px 10px; font-size: 0.78rem; font-weight: 800; box-shadow: var(--hard-sm);
}
#emote-float { position: absolute; z-index: 36; right: 12px; bottom: calc(var(--sheet-peek) + 14px); display: grid; gap: 6px; justify-items: end; pointer-events: none; }
.emote-float-item {
  display: inline-flex; align-items: center; gap: 6px; background: var(--glass); color: var(--ink); border: 2px solid var(--line);
  border-radius: var(--radius-pill); padding: 3px 12px 3px 3px; font-size: 0.8rem; font-weight: 800; animation: emote-in 0.25s ease-out;
}
.emote-float-avatar { width: 26px; height: 26px; border-radius: 50%; overflow: hidden; background: var(--gold); }
@keyframes emote-in { from { opacity: 0; transform: translateX(16px); } }

@media (min-width: 900px) {
  #streetview-container { position: absolute; inset: 0; }
  #hud-top { display: contents; }

  /* compass strip + tuk-tuk meter, top centre */
  #compass-strip {
    display: block; position: absolute; z-index: 30; top: calc(var(--safe-top) + 10px); left: 50%; transform: translateX(-50%);
    width: 280px; height: 30px; border-radius: 15px; background: var(--glass); backdrop-filter: blur(10px);
    border: 2px solid var(--glass-line); overflow: hidden; pointer-events: none;
  }
  #compass-strip[hidden] { display: none; }
  .compass-ticks { display: flex; justify-content: space-between; padding: 2px 10px 0; font-size: 0.66rem; font-weight: 800; color: var(--ink-2); }
  #compass-needle { position: absolute; bottom: 0; width: 3px; height: 12px; background: var(--lotus); border-radius: 2px; transform: translateX(-50%); }
  #compass-label { position: absolute; left: 0; right: 0; bottom: 1px; text-align: center; font-size: 0.6rem; font-weight: 800; color: var(--ink); }
  .timer-card {
    position: absolute; z-index: 31; top: calc(var(--safe-top) + 46px); left: 50%; transform: translateX(-50%);
    min-width: 240px; border-radius: 999px; justify-content: center; backdrop-filter: blur(10px);
    background: color-mix(in srgb, var(--gold) 88%, transparent);
  }
  .timer-card.danger { animation-name: meter-pulse-c; }
  @keyframes meter-pulse-c { 50% { transform: translateX(-50%) scale(1.06); } }
  .timer-ring-box { display: none; }
  .timer-track { display: block; position: relative; flex: 1; height: 8px; margin: 0 6px; border-radius: 4px; background: rgba(42, 29, 0, 0.18); }
  .timer-tuk { position: absolute; top: -9px; left: calc((1 - var(--p)) * (100% - 20px)); font-style: normal; font-size: 1.1rem; line-height: 1; transition: left 1s linear; }

  /* ticket panel, top right, with a perforated left edge */
  .ticket-panel {
    position: absolute; z-index: 30; top: calc(var(--safe-top) + 10px); right: 14px; max-width: 320px; width: max-content;
    flex-direction: column; align-items: stretch; gap: 6px; padding: 10px 12px 10px 18px;
    background: var(--glass); backdrop-filter: blur(12px); border: 2px solid var(--glass-line); border-radius: 18px 10px 10px 18px;
    box-shadow: var(--hard-sm);
    -webkit-mask: radial-gradient(circle at 0 10px, transparent 5px, #000 5.5px) 0 0 / 100% 20px repeat-y; mask: radial-gradient(circle at 0 10px, transparent 5px, #000 5.5px) 0 0 / 100% 20px repeat-y;
  }
  .ticket-panel .hud-card { background: transparent; border: 0; box-shadow: none; padding: 0 2px; min-height: 28px; }
  .ticket-panel.collapsed .hud-card:not(:nth-of-type(2)):not(:nth-of-type(3)) { display: none !important; }
  .ticket-collapse { display: block; position: absolute; top: 4px; right: 6px; width: 24px; height: 24px; border: 0; background: transparent; color: var(--ink); font-weight: 800; }
  .ticket-panel.collapsed .ticket-collapse { transform: rotate(180deg); }

  /* control dock, bottom left */
  .control-dock { top: auto; right: auto; left: 14px; bottom: 16px; align-items: flex-start; }
  .dock-more { display: none; }
  .dock-items, .control-dock.open .dock-items { display: flex; }
  .dock-btn { background: var(--glass); backdrop-filter: blur(10px); border-color: var(--glass-line); }
  .dock-btn.btn-alert { background: color-mix(in srgb, var(--lotus) 90%, transparent); }
  .dock-zoom { display: grid; }
  .emote-radial { left: 22px; right: auto; top: auto; bottom: 22px; }
  .emote-radial-item { transform: translate(var(--x), var(--y)); }
  #emote-float { right: 14px; bottom: calc(var(--map-h) + 150px); }

  /* guess map, bottom right: small, grows on hover / tap / pin */
  #map-panel {
    --map-w: 300px; --map-h: 200px;
    position: absolute; inset: auto 14px 14px auto; z-index: 40; height: auto; width: var(--map-w);
    transform: none !important; transition: width 0.22s ease; touch-action: auto;
    background: var(--glass); backdrop-filter: blur(12px); border: 2px solid var(--glass-line); border-radius: 18px;
    box-shadow: var(--hard-sm); overflow: hidden;
  }
  #map-panel:hover, #map-panel:focus-within, #map-panel.pinned, #map-panel.touch-open {
    --map-w: min(760px, calc(100vw - 28px));
    --map-h: min(580px, calc(100dvh - 200px));
  }
  #map-wrapper { flex: none; height: var(--map-h); transition: height 0.22s ease; }
  @media (prefers-reduced-motion: reduce) { #map-panel, #map-wrapper { transition: none; } }
  .sheet-handle, #expand-toggle { display: none; }
  #map-pin-toggle { display: inline-flex; min-width: 44px; justify-content: center; }
  #map-pin-toggle[aria-pressed='true'] { background: var(--gold); }
  #guess-action-bar { background: transparent; border-top: 0; padding: 8px 10px 10px; }
  #guess-btn.ready { box-shadow: 0 5px 0 rgba(34, 51, 49, 0.9); }
  #guess-btn.ready:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(34, 51, 49, 0.9); }
  .map-tools { top: 56px; }
  body[data-role='viewer'] .control-dock .dock-zoom { display: none; }
}

/* ==========================================================================
   Standings (client/ui/standings.js): podium, rows, tabs, final bars
   ========================================================================== */
.st-tabs { display: flex; gap: 6px; margin: 6px 0 10px; }
.st-tabs button { flex: 1; min-height: 40px; border: 2px solid var(--line); border-radius: var(--radius-pill); background: var(--card); color: var(--ink); font-weight: 800; font-size: 0.8rem; }
.st-tabs button.active { background: var(--gold); color: var(--on-gold); box-shadow: var(--hard-sm); }
.st-list { display: grid; gap: 6px; }
.st-row { display: grid; grid-template-columns: 32px 38px 1fr auto; align-items: center; gap: 9px; padding: 7px 10px; border: 2px solid var(--line); border-radius: 14px; background: var(--card); }
.st-row.is-me { outline: 2px solid var(--mekong); outline-offset: 1px; }
.st-row.winner { background: color-mix(in srgb, var(--gold) 26%, var(--card)); }
.st-row.no-guess { opacity: 0.7; }
.st-rank { font-weight: 900; text-align: center; }
.st-face { width: 36px; height: 36px; border-radius: 50%; overflow: hidden; border: 2.5px solid var(--aura, var(--line)); background: var(--gold); display: inline-block; flex: none; }
.st-face.big { width: 52px; height: 52px; }
.st-name { font-weight: 800; font-size: 0.92rem; display: flex; align-items: center; gap: 6px; min-width: 0; }
.st-you { font-size: 0.66rem; font-weight: 800; padding: 1px 6px; border-radius: 4px; background: var(--rice); color: #08240f; }
.st-sub { font-size: 0.72rem; color: var(--ink-2); }
.st-main { font-weight: 900; font-size: 1.02rem; color: var(--rice); text-align: right; display: flex; align-items: center; gap: 6px; justify-content: flex-end; font-variant-numeric: tabular-nums; }
.st-move { font-size: 0.68rem; font-weight: 800; }
.st-move.up { color: var(--rice); } .st-move.down { color: var(--lotus); } .st-move.same { color: var(--ink-2); }
.st-hit.broke { color: var(--lotus); font-size: 0.9rem; }
.st-podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin: 4px 0 12px; }
.st-step { flex: 1; max-width: 120px; text-align: center; display: grid; justify-items: center; gap: 3px; }
.st-step-name { font-weight: 800; font-size: 0.78rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-step-pts { font-weight: 900; color: var(--rice); font-size: 0.9rem; }
.st-step-block { width: 100%; border: 2px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; display: grid; place-items: center; font-size: 1.4rem; background: var(--paper-2); }
.st-step.place-1 .st-step-block { height: 64px; background: color-mix(in srgb, var(--gold) 70%, var(--card)); }
.st-step.place-2 .st-step-block { height: 48px; }
.st-step.place-3 .st-step-block { height: 36px; background: color-mix(in srgb, #c47a3d 40%, var(--card)); }
.st-step.is-me .st-step-name { color: var(--mekong); }
.st-bars { display: flex; align-items: flex-end; gap: 3px; height: 18px; margin-top: 3px; }
.st-bars i { width: 8px; background: var(--gold); border-radius: 2px 2px 0 0; display: block; }
.st-in { animation: st-slide 0.35s ease-out backwards; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes st-slide { from { opacity: 0; transform: translateY(14px); } }
@media (prefers-reduced-motion: reduce) { .st-in { animation: none; } }

/* ==========================================================================
   Spectators (Part F)
   ========================================================================== */
.lobby-toggle { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 700; font-size: 0.86rem; }
.lobby-toggle input { width: 20px; height: 20px; }
#spectator-banner, #spect-results { position: absolute; z-index: 32; }
#spectator-banner { top: calc(var(--safe-top) + 8px); left: 12px; display: grid; gap: 6px; max-width: min(92vw, 360px); background: var(--glass); backdrop-filter: blur(10px); border: 2px solid var(--glass-line); border-radius: 16px; padding: 8px 10px; box-shadow: var(--hard-sm); }
#spectator-banner[hidden], #spect-results[hidden] { display: none; }
.spect-title { display: flex; flex-direction: column; font-size: 0.86rem; }
.spect-title span { font-size: 0.68rem; color: var(--ink-2); font-weight: 700; }
.spect-follow { display: flex; gap: 6px; flex-wrap: wrap; }
.spect-chip { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); padding: 0; overflow: hidden; display: grid; place-items: center; font-weight: 800; }
.spect-chip .who-chip-avatar { filter: grayscale(0.8); opacity: 0.7; border: 0; }
.spect-chip.guessed .who-chip-avatar, .spect-chip.on .who-chip-avatar { filter: none; opacity: 1; }
.spect-chip.on { outline: 3px solid var(--gold); outline-offset: 1px; }
.spect-card { display: flex; align-items: center; gap: 10px; font-size: 0.86rem; }
.spect-avatar { width: 48px; height: 48px; border-radius: 50%; overflow: hidden; border: 3px solid var(--aura, var(--line)); background: var(--gold); flex: none; }
.spect-state { font-size: 0.72rem; color: var(--ink-2); font-weight: 700; }
.spect-score { margin-left: auto; text-align: right; display: grid; }
.spect-score span { color: var(--rice); font-size: 0.74rem; font-weight: 800; }
#spect-results { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(94vw, 440px); max-height: 70dvh; overflow: auto; background: var(--glass); backdrop-filter: blur(12px); border: 2px solid var(--glass-line); border-radius: 18px; padding: 12px; }
.watching-faces { display: inline-flex; margin-left: 6px; }
.watching-face { width: 22px; height: 22px; border-radius: 50%; overflow: hidden; border: 1.5px solid var(--line); margin-left: -6px; background: var(--gold); }
#hud-watching[hidden] { display: none; }
/* Spectators watch the Part C layout without the Guess button and with a read-only map. */
body[data-spectator='1'] #guess-action-bar,
body[data-spectator='1'] #mode-choice-shelf,
body[data-spectator='1'] .map-crosshair,
body[data-spectator='1'] #map-pin-status,
body[data-spectator='1'] .map-chips { display: none !important; }
@media (min-width: 900px) { body[data-spectator='1'] #hud-top .ticket-panel { top: calc(var(--safe-top) + 10px); } body[data-spectator='1'] #spectator-banner { top: calc(var(--safe-top) + 10px); } }
body[data-spectator='1'] .control-dock .btn-alert { display: none; }

/* ==========================================================================
   Battle Royale (Part B)
   ========================================================================== */
.royale-settings { display: grid; gap: 8px; padding: 12px; border: 2px solid var(--line); border-radius: 14px; background: var(--card); }
.royale-settings[hidden] { display: none; }
.royale-settings label { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; font-size: 0.86rem; }
.royale-settings select { width: 90px; min-height: 40px; }
#royale-alive { font-weight: 900; font-size: 0.72rem; letter-spacing: 0.06em; color: var(--lotus); white-space: nowrap; }
.who-hearts { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); font-size: 0.55rem; white-space: nowrap; line-height: 1; margin-top: 1px; }
.who-chip.royale-ghost .who-chip-avatar { filter: grayscale(1); opacity: 0.4; }
.who-chip { margin-bottom: 10px; }
.royale-zone-ring { filter: drop-shadow(0 0 6px #e4578a) drop-shadow(0 0 14px rgba(228, 87, 138, 0.8)); animation: zone-glow 1.6s ease-in-out infinite alternate; }
@keyframes zone-glow { to { stroke-opacity: 0.55; } }
.ghost-pin span { font-size: 1.5rem; opacity: 0.6; filter: drop-shadow(0 0 4px #fff); display: block; text-align: center; }
body[data-ghost='1'] #game-screen { filter: grayscale(0.75); }
body[data-ghost='1'] #hud-top .timer-card, body[data-ghost='1'] #spectator-banner, body[data-ghost='1'] #guess-action-bar { filter: none; }
body[data-ghost='1'] #mode-choice-shelf { display: none !important; }
/* The final duel is pure skill: no quick-jump chips. */
body[data-duel='1'] .map-chips { display: none !important; }

#royale-hit { position: absolute; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(8, 20, 20, 0.55); pointer-events: none; }
#royale-hit[hidden], #duel-splash[hidden] { display: none; }
.hit-row { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; max-width: 92vw; }
.hit-chip { position: relative; display: grid; justify-items: center; gap: 2px; width: 92px; color: #fff; font-weight: 800; font-size: 0.78rem; text-align: center; }
.hit-avatar { width: 64px; height: 64px; border-radius: 50%; overflow: hidden; border: 3px solid #fff; background: var(--gold); }
.hit-badge { position: absolute; top: -6px; right: 6px; font-size: 1.5rem; }
.hit-lives { font-size: 0.8rem; min-height: 1em; }
.hit-note { font-size: 0.68rem; color: #fecdd3; }
.hit-chip.hurt, .hit-chip.out { animation: hit-shake 0.5s ease-in-out 2; }
.hit-chip.hurt .hit-badge { animation: heart-break 1s ease-out both; }
.hit-chip.out .hit-avatar { animation: crash-out 1.2s ease-in 0.5s both; }
.hit-chip.shield .hit-avatar { box-shadow: 0 0 0 4px #38bdf8, 0 0 18px #38bdf8; }
@keyframes hit-shake { 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }
@keyframes heart-break { from { transform: scale(0.4); } 50% { transform: scale(1.5); } to { transform: scale(1); } }
@keyframes crash-out { to { transform: translate(40px, 80px) rotate(50deg); filter: grayscale(1); opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .hit-chip.hurt, .hit-chip.out, .hit-chip.hurt .hit-badge, .royale-zone-ring { animation: none; } .hit-chip.out .hit-avatar { animation: none; filter: grayscale(1); opacity: 0.45; } }

#duel-splash { position: absolute; inset: 0; z-index: 70; display: grid; place-content: center; justify-items: center; gap: 18px; background: radial-gradient(circle, rgba(228, 87, 138, 0.9), rgba(10, 24, 26, 0.96)); color: #fff; animation: duel-in 0.35s ease-out; }
.duel-title { font-size: clamp(2rem, 9vw, 4.5rem); font-weight: 900; letter-spacing: 0.04em; text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35); }
.duel-faces { display: flex; align-items: center; gap: clamp(14px, 5vw, 40px); }
.duel-face { display: grid; justify-items: center; gap: 6px; font-weight: 800; }
.duel-face span { width: clamp(84px, 22vw, 140px); aspect-ratio: 1; border-radius: 50%; overflow: hidden; border: 4px solid #fff; background: var(--gold); }
.duel-faces i { font-style: normal; font-weight: 900; font-size: clamp(1.4rem, 5vw, 2.4rem); color: #fde68a; }
@keyframes duel-in { from { opacity: 0; transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { #duel-splash { animation: none; } }

/* ---- Wiki ---- */
#wiki-screen { background-color: var(--paper); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.wiki-search { width: 100%; box-sizing: border-box; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line, #0002); font: inherit; background: var(--card, #fff); color: inherit; margin: 8px 0 12px; }
.wiki-section h2 { margin: 18px 0 8px; font-size: 1.15rem; }
.wiki-item { background: var(--card, #fff); border: 1px solid var(--line, #0001); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; }
.wiki-item h3 { margin: 0 0 4px; font-size: 0.98rem; }
.wiki-item p, .wiki-item li { font-size: 0.88rem; line-height: 1.45; margin: 4px 0; }
.wiki-item ul { padding-left: 18px; margin: 4px 0; }
.wiki-small { font-size: 0.78rem !important; color: var(--ink-2); }
.wiki-table-wrap { overflow-x: auto; }
.wiki-table { border-collapse: collapse; font-size: 0.78rem; }
.wiki-table th, .wiki-table td { padding: 3px 8px; border-bottom: 1px solid #0001; text-align: right; white-space: nowrap; }
.wiki-table th:first-child { text-align: left; }
.wiki-map { width: 100%; height: auto; }
.wiki-sea { fill: #8ec5e622; }
.wiki-dot { fill: var(--gold-deep, #b8860b); fill-opacity: 0.55; }
