/* ==========================================================================
   GeoGame — light, friendly, game-like
   Flat white cards, soft shadows, chunky "pressable" buttons.
   ========================================================================== */

:root {
  --bg: #eaf4fd;
  --bg-2: #f6fafe;
  --card: #ffffff;
  --card-2: #f4f7fb;
  --card-3: #eaf0f7;
  --line: #e1e8f1;
  --line-strong: #cdd8e6;
  --text: #1f2d48;
  --text-dim: #586a87;
  --text-faint: #8d9bb3;
  --blue: #3d7cf5;
  --blue-dark: #2a5fcc;
  --blue-soft: #e3edff;
  --green: #2fbf71;
  --green-dark: #22995a;
  --green-soft: #e1f6ea;
  --orange: #ff9b2f;
  --orange-dark: #d97a14;
  --red: #f25c5c;
  --red-dark: #cc4040;
  --red-soft: #fde8e8;
  --yellow: #ffc93c;
  --yellow-dark: #e0a51a;
  --purple: #8b6cf0;
  --points: #e58a00;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 2px 4px rgba(31, 45, 72, 0.05), 0 8px 24px rgba(31, 45, 72, 0.08);
  --shadow-lg: 0 4px 8px rgba(31, 45, 72, 0.06), 0 16px 40px rgba(31, 45, 72, 0.14);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --topbar-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 600;
  color: var(--text);
  background: linear-gradient(180deg, #d9ecfc 0%, var(--bg) 45%, var(--bg-2) 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--blue); text-decoration: none; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
::selection { background: rgba(61, 124, 245, 0.25); }

* { scrollbar-width: thin; scrollbar-color: #c6d2e2 transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #c6d2e2; border-radius: 8px; }

/* ---------------------------------------------------------------- backdrop */

#stars { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.stars { display: none; }
.nebula {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.9) 0, rgba(255, 255, 255, 0) 22%),
    radial-gradient(circle at 88% 82%, rgba(255, 230, 190, 0.55) 0, rgba(255, 230, 190, 0) 30%),
    radial-gradient(circle at 85% 12%, rgba(200, 230, 255, 0.8) 0, rgba(200, 230, 255, 0) 25%);
}

#globe { position: fixed; inset: 0; z-index: 1; transition: opacity 0.6s ease, filter 0.6s ease; }
#globe canvas { outline: none; }
#globe.dimmed { opacity: 0.55; filter: saturate(0.8); }
#globe-vignette { display: none; }

/* ---------------------------------------------------------------- boot */

#boot {
  position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; gap: 18px; justify-items: center;
  background: var(--bg);
  transition: opacity 0.5s ease, visibility 0.5s;
}
#boot.gone { opacity: 0; visibility: hidden; }
.boot-globe {
  width: 76px; height: 76px; border-radius: 50%; position: relative;
  background: radial-gradient(circle at 35% 30%, #bfe3ff, #5aa9f0 60%, #3d7cf5);
  box-shadow: 0 6px 0 #2a5fcc;
  animation: hop 0.9s ease-in-out infinite;
}
.boot-ring { display: none; }
.boot-title { font-weight: 900; font-size: 28px; color: var(--text); }
@keyframes hop { 50% { transform: translateY(-12px); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- top bar */

#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right));
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 23px; color: var(--text); }
.logo img { width: 34px; height: 34px; transition: transform 0.5s var(--ease-spring); }
.logo:hover img { transform: rotate(-20deg) scale(1.1); }
.logo span { color: var(--text); }
.nav { display: flex; gap: 4px; margin-left: 14px; padding: 4px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); }
.nav a {
  position: relative; padding: 7px 16px; border-radius: 999px; color: var(--text-dim); font-weight: 800;
  transition: color 0.2s, background 0.2s;
}
.nav a:hover { color: var(--text); background: var(--card-2); }
.nav a.active { color: #fff; background: var(--blue); }
.nav .badge { position: absolute; top: -4px; right: -2px; }
.topbar-spacer { flex: 1; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 18px;
  background: var(--card); box-shadow: 0 3px 0 var(--line-strong), var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.icon-btn:hover { transform: translateY(-1px); }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--line-strong); }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 4px 16px 4px 4px; border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow); font-weight: 800; color: var(--text);
}
.user-chip:hover { background: var(--card-2); }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff;
  font-size: 11px; font-weight: 900; display: inline-grid; place-items: center; box-shadow: 0 2px 0 var(--red-dark);
  animation: pop 0.4s var(--ease-spring);
}

/* ---------------------------------------------------------------- avatars */

.avatar {
  --c: #3d7cf5;
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 900; font-size: 15px; color: #fff; text-transform: uppercase; position: relative;
  background: var(--c);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15), 0 0 0 3px #fff;
}
.avatar.sm { width: 28px; height: 28px; font-size: 12px; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15), 0 0 0 2px #fff; }
.avatar.lg { width: 64px; height: 64px; font-size: 26px; }
.avatar.xl { width: 96px; height: 96px; font-size: 40px; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.15), 0 0 0 5px #fff, var(--shadow); }
.avatar .dot {
  position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%;
  background: #b7c2d3; box-shadow: 0 0 0 2px #fff;
}
.avatar .dot.on { background: var(--green); }
.avatar .dot.play { background: var(--orange); }

/* ---------------------------------------------------------------- layout */

#view { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#view > * { pointer-events: none; }
.view-root > * { pointer-events: auto; }
.page {
  position: absolute; inset: var(--topbar-h) 0 0 0; overflow-y: auto; overflow-x: hidden;
  padding: 16px max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left));
  animation: page-in 0.45s var(--ease-out);
}
/* The game page lets clicks through to the globe except on its panels. */
.page.passthrough { pointer-events: none; }
.view-root > .page.passthrough { pointer-events: none; }
.container { max-width: 1180px; margin: 0 auto; }
.narrow { max-width: 760px; margin: 0 auto; }
@keyframes page-in { from { opacity: 0; transform: translateY(12px); } }

.glass { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { padding: 22px; }
.panel h2, .panel h3 { margin: 0 0 14px; font-weight: 900; }
h1, h2, h3 { font-weight: 900; letter-spacing: -0.01em; }
.section-title { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-faint); margin: 22px 0 10px; }
.section-title::after { content: ''; flex: 1; height: 2px; border-radius: 2px; background: var(--line); }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.stagger > * { animation: rise 0.45s var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay: 0.03s; } .stagger > *:nth-child(2) { animation-delay: 0.08s; }
.stagger > *:nth-child(3) { animation-delay: 0.13s; } .stagger > *:nth-child(4) { animation-delay: 0.18s; }
.stagger > *:nth-child(5) { animation-delay: 0.23s; } .stagger > *:nth-child(6) { animation-delay: 0.28s; }
.stagger > *:nth-child(7) { animation-delay: 0.33s; } .stagger > *:nth-child(8) { animation-delay: 0.38s; }
.stagger > *:nth-child(n+9) { animation-delay: 0.42s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes pop { 0% { transform: scale(0.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* ---------------------------------------------------------------- buttons
   Chunky game buttons: a solid face with a darker "edge" below that
   disappears when pressed. */

.btn {
  --face: var(--card);
  --edge: var(--line-strong);
  --ink: var(--text);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 22px; border-radius: 14px; font-weight: 900; font-size: 15px;
  background: var(--face); color: var(--ink);
  box-shadow: 0 4px 0 var(--edge), 0 6px 14px rgba(31, 45, 72, 0.1);
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.15s;
  user-select: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.04); transform: translateY(-1px); box-shadow: 0 5px 0 var(--edge), 0 8px 18px rgba(31, 45, 72, 0.12); }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--edge), 0 2px 6px rgba(31, 45, 72, 0.1); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.primary { --face: var(--blue); --edge: var(--blue-dark); --ink: #fff; }
.btn.go { --face: var(--green); --edge: var(--green-dark); --ink: #fff; }
.btn.warm { --face: var(--orange); --edge: var(--orange-dark); --ink: #fff; }
.btn.danger { --face: #fff; --edge: #f3c4c4; --ink: var(--red-dark); }
.btn.ghost { --face: transparent; --ink: var(--text-dim); box-shadow: none; }
.btn.ghost:hover { --face: var(--card-2); box-shadow: none; transform: none; }
.btn.ghost:active { transform: scale(0.97); }
.btn.sm { height: 34px; padding: 0 14px; font-size: 13px; border-radius: 11px; box-shadow: 0 3px 0 var(--edge); }
.btn.sm:active { transform: translateY(3px); box-shadow: none; }
.btn.lg { height: 56px; padding: 0 32px; font-size: 18px; border-radius: 18px; box-shadow: 0 5px 0 var(--edge), 0 8px 18px rgba(31, 45, 72, 0.12); }
.btn.lg:active { transform: translateY(5px); box-shadow: none; }
.btn.block { width: 100%; }
.btn .kbd { font-size: 11px; opacity: 0.85; padding: 2px 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.12); }

/* ---------------------------------------------------------------- inputs */

.field { display: block; }
.field > span { display: block; font-size: 13px; font-weight: 800; color: var(--text-dim); margin-bottom: 6px; }
.input {
  width: 100%; height: 48px; padding: 0 16px; border-radius: 14px; border: 2px solid var(--line); outline: none;
  background: var(--card-2); color: var(--text); font-size: 16px; font-weight: 700;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--text-faint); font-weight: 600; }
.input:focus { border-color: var(--blue); background: #fff; box-shadow: 0 0 0 4px var(--blue-soft); }
.input.code { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 900; text-align: center; font-size: 20px; }
select.input { cursor: pointer; }

.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: 14px; background: var(--card-3); flex-wrap: wrap; }
.seg button {
  padding: 7px 14px; border-radius: 10px; font-weight: 800; font-size: 14px; color: var(--text-dim);
  transition: background 0.2s, color 0.2s, transform 0.12s;
}
.seg button:hover:not(:disabled) { color: var(--text); }
.seg button:active:not(:disabled) { transform: scale(0.95); }
.seg button.on { background: #fff; color: var(--blue); box-shadow: 0 2px 0 var(--line-strong); }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }

.toggle { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; cursor: pointer; transition: background 0.2s; user-select: none; }
.toggle:hover { background: var(--card-2); }
.toggle.disabled { opacity: 0.45; cursor: not-allowed; }
.toggle .sw { width: 46px; height: 28px; border-radius: 999px; background: #d3dce8; position: relative; flex: none; transition: background 0.2s; }
.toggle .sw::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 4px rgba(31, 45, 72, 0.25); transition: transform 0.25s var(--ease-spring);
}
.toggle.on .sw { background: var(--green); }
.toggle.on .sw::after { transform: translateX(18px); }
.toggle .t-label { font-weight: 800; }
.toggle .t-desc { font-size: 12px; color: var(--text-faint); }

.range { display: flex; align-items: center; gap: 14px; }
.range input[type=range] { flex: 1; -webkit-appearance: none; appearance: none; height: 8px; border-radius: 8px; background: var(--card-3); outline: none; }
.range input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: var(--blue); border: 4px solid #fff; box-shadow: 0 2px 6px rgba(31, 45, 72, 0.3); cursor: pointer; transition: transform 0.15s; }
.range input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.15); }
.range input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--blue); border: 4px solid #fff; box-shadow: 0 2px 6px rgba(31, 45, 72, 0.3); cursor: pointer; }
.range input[type=range]:disabled { opacity: 0.5; }
.range .val { min-width: 52px; text-align: center; font-weight: 900; font-size: 18px; padding: 5px 10px; border-radius: 12px; background: var(--blue-soft); color: var(--blue-dark); }

/* ---------------------------------------------------------------- toasts */

#toasts { position: fixed; top: calc(var(--topbar-h) + 8px); right: 16px; z-index: 90; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; max-width: calc(100vw - 32px); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 16px; max-width: 380px;
  background: #fff; box-shadow: var(--shadow-lg); font-weight: 700; border-left: 5px solid var(--blue);
  animation: toast-in 0.4s var(--ease-spring);
}
.toast.out { animation: toast-out 0.25s ease forwards; }
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }
.toast .t-icon { font-size: 20px; }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px) scale(0.9); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(40px) scale(0.95); } }

/* ---------------------------------------------------------------- modal */

.modal-back {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px;
  background: rgba(31, 45, 72, 0.35); animation: fade 0.25s ease;
}
.modal { width: min(460px, 100%); padding: 26px; animation: modal-in 0.4s var(--ease-spring); }
.modal h2 { margin: 0 0 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(24px) scale(0.94); } }

/* ---------------------------------------------------------------- auth */

.auth-wrap { min-height: 100%; display: grid; grid-template-columns: 1.1fr 0.9fr; align-items: center; gap: 40px; }
.hero-title {
  font-size: clamp(48px, 8vw, 100px); font-weight: 900; line-height: 0.95; margin: 0; letter-spacing: -0.03em;
  color: var(--text); text-shadow: 0 4px 0 #fff, 0 6px 0 var(--line-strong);
}
.hero-sub { font-size: clamp(17px, 2vw, 21px); color: var(--text-dim); max-width: 520px; margin: 18px 0 26px; line-height: 1.5; font-weight: 700; }
.hero-features { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; font-weight: 800; font-size: 14px;
  background: #fff; box-shadow: var(--shadow);
}
.auth-card { padding: 28px; max-width: 420px; width: 100%; justify-self: end; }
.auth-tabs { margin-bottom: 22px; }
.auth-tabs .seg { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
.form-error { min-height: 22px; color: var(--red-dark); font-size: 14px; margin: 8px 0; font-weight: 700; }
.shake { animation: shake 0.45s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

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

.home-hero { text-align: center; padding: 5vh 0 2vh; }
.home-hero .hero-title { font-size: clamp(42px, 6.5vw, 80px); }
.home-hero .hero-sub { margin: 14px auto 0; }
.play-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 28px; }
.play-card {
  position: relative; padding: 24px 22px 22px; border-radius: 24px; text-align: left;
  background: #fff; box-shadow: 0 6px 0 var(--line-strong), var(--shadow);
  transition: transform 0.25s var(--ease-spring), box-shadow 0.25s;
  display: flex; flex-direction: column; gap: 8px; min-height: 210px;
}
.play-card:hover { transform: translateY(-5px); box-shadow: 0 11px 0 var(--line-strong), var(--shadow-lg); }
.play-card .pc-icon {
  width: 62px; height: 62px; border-radius: 18px; display: grid; place-items: center; font-size: 32px; margin-bottom: 6px;
  background: var(--blue-soft); transition: transform 0.4s var(--ease-spring);
}
.play-card:hover .pc-icon { transform: rotate(-8deg) scale(1.1); }
.play-card.c2 .pc-icon { background: #fff0dd; }
.play-card.c3 .pc-icon { background: var(--green-soft); }
.play-card h3 { margin: 0; font-size: 22px; }
.play-card p { margin: 0; color: var(--text-dim); line-height: 1.45; flex: 1; }
.join-row { display: flex; gap: 8px; }
.join-row .input { height: 46px; }
.home-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; margin-top: 22px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; transition: background 0.2s; }
.list-item:hover { background: var(--card-2); }
.empty { padding: 24px 10px; text-align: center; color: var(--text-faint); }
.empty .big { font-size: 34px; display: block; margin-bottom: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 900; background: var(--card-3); color: var(--text-dim); }
.pill.live { background: #fff0dd; color: var(--orange-dark); }
.pill.open { background: var(--green-soft); color: var(--green-dark); }

/* ---------------------------------------------------------------- settings */

.settings { display: flex; flex-direction: column; gap: 4px; }
.mode-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.mode-card {
  position: relative; padding: 14px 12px; border-radius: 18px; text-align: left;
  background: var(--card-2); border: 2px solid transparent;
  transition: transform 0.2s var(--ease-spring), border-color 0.2s, background 0.2s;
}
.mode-card:hover:not(:disabled) { transform: translateY(-3px); background: #fff; border-color: var(--line); }
.mode-card.on { background: var(--blue-soft); border-color: var(--blue); }
.mode-card.on::after { content: '✓'; position: absolute; top: 8px; right: 10px; width: 22px; height: 22px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 900; animation: pop 0.3s var(--ease-spring); }
.mode-card:disabled { opacity: 0.4; cursor: not-allowed; }
.mode-card .mc-icon { font-size: 30px; display: inline-block; margin-bottom: 6px; transition: transform 0.35s var(--ease-spring); }
.mode-card:hover .mc-icon, .mode-card.on .mc-icon { transform: scale(1.15) rotate(-6deg); }
.mode-card .mc-name { font-weight: 900; font-size: 15px; }
.mode-card .mc-desc { font-size: 12px; color: var(--text-dim); line-height: 1.35; margin-top: 4px; font-weight: 600; }
.region-picker { display: flex; flex-direction: column; gap: 10px; }
.region-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 236px; overflow-y: auto; padding: 2px; }
.region-chip {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 14px; text-align: left;
  background: var(--card-2); border: 2px solid transparent;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.region-chip:hover:not(:disabled) { transform: translateY(-2px); background: #fff; border-color: var(--line); }
.region-chip.on { background: var(--blue-soft); border-color: var(--blue); }
.region-chip:disabled { cursor: default; }
.region-chip .rc-name { font-weight: 800; font-size: 14px; line-height: 1.15; }
.region-chip .rc-unit { font-size: 11px; color: var(--text-faint); }
.region-chip.world .globe-ico { width: 30px; height: 22px; border-radius: 5px; display: grid; place-items: center; font-size: 17px; background: #cfe8fb; }
.flag { width: 30px; height: 22.5px; border-radius: 4px; flex: none; object-fit: cover; box-shadow: 0 0 0 1px rgba(31, 45, 72, 0.12); background: var(--card-3); }
.flag.lg { width: 64px; height: 48px; border-radius: 7px; }
.flag.xl { width: 220px; height: 165px; border-radius: 12px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; }
.setting-label { font-size: 13px; font-weight: 800; color: var(--text-dim); margin: 6px 0 8px; display: flex; align-items: center; gap: 8px; }
.inputs-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.input-opt {
  padding: 12px 6px; border-radius: 16px; text-align: center; font-weight: 800; font-size: 13px;
  background: var(--card-2); border: 2px solid transparent;
  transition: transform 0.15s, background 0.2s, border-color 0.2s;
}
.input-opt .io-icon { display: block; font-size: 22px; margin-bottom: 4px; }
.input-opt.on { background: var(--green-soft); border-color: var(--green); color: var(--green-dark); }
.input-opt:hover:not(:disabled) { transform: translateY(-2px); }
.input-opt:disabled { opacity: 0.35; cursor: not-allowed; text-decoration: line-through; }
.readonly-note { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 14px; font-size: 14px; color: var(--blue-dark); background: var(--blue-soft); margin-bottom: 8px; }

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

.lobby-layout { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; align-items: start; }
.room-code-card { display: flex; align-items: center; gap: 12px; padding: 18px 22px; margin-bottom: 18px; flex-wrap: wrap; }
.room-code { font-size: 34px; font-weight: 900; letter-spacing: 0.2em; color: var(--blue); }
.player-list { display: flex; flex-direction: column; gap: 6px; }
.player-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--card-2); animation: rise 0.4s var(--ease-spring) both; }
.player-row.offline { opacity: 0.5; }
.player-row .crown { animation: bob 2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-3px) rotate(-6deg); } }
.chat { display: flex; flex-direction: column; height: 280px; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 4px 2px 8px; }
.chat-msg { font-size: 14px; line-height: 1.4; animation: rise 0.3s var(--ease-out); word-wrap: break-word; }
.chat-msg b { margin-right: 6px; }
.chat-msg.system { color: var(--text-faint); font-style: italic; font-size: 13px; }
.chat-form { display: flex; gap: 8px; align-items: center; }
.chat-form .input { height: 40px; font-size: 14px; }
.start-bar { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.waiting-dots span { display: inline-block; animation: dot 1.4s infinite; }
.waiting-dots span:nth-child(2) { animation-delay: 0.2s; } .waiting-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot { 0%, 60%, 100% { opacity: 0.2; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

/* ==========================================================================
   GAME HUD
   ========================================================================== */

.hud { position: absolute; inset: 0; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-top {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px; z-index: 5; pointer-events: none;
  max-width: calc(100vw - 32px);
}
.hud-top > * { pointer-events: auto; }
.round-pill {
  display: flex; align-items: center; gap: 12px; padding: 6px 8px 6px 16px; border-radius: 999px; font-weight: 900;
  background: #fff; box-shadow: var(--shadow);
}
.round-dots { display: flex; gap: 5px; }
.round-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--card-3); transition: background 0.3s, transform 0.3s var(--ease-spring); }
.round-dots i.done { background: var(--line-strong); }
.round-dots i.win { background: var(--green); }
.round-dots i.miss { background: var(--red); }
.round-dots i.now { background: var(--blue); transform: scale(1.3); }
.score-chip { padding: 4px 12px; border-radius: 999px; background: #fff3d6; color: var(--points); font-weight: 900; }

.clue-card {
  display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-radius: 22px;
  background: #fff; box-shadow: 0 5px 0 var(--line-strong), var(--shadow);
  animation: clue-in 0.6s var(--ease-spring);
}
.clue-card .clue-icon { font-size: 32px; animation: wiggle 3s ease-in-out infinite; }
.clue-card .clue-title { font-size: 20px; font-weight: 900; }
.clue-card .clue-sub { font-size: 13px; color: var(--text-dim); }
.clue-card.flag-clue { flex-direction: column; gap: 10px; padding: 14px; }
.clue-card .flag.xl { width: min(220px, 50vw); height: auto; aspect-ratio: 4 / 3; animation: flag-wave 4s ease-in-out infinite; transform-origin: left center; }
.clue-card.outline-clue { flex-direction: column; gap: 6px; padding: 12px 18px; }
.outline-svg { width: min(200px, 44vw); height: min(150px, 33vw); }
.outline-svg path { fill: #ffe7c2; stroke: var(--orange-dark); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; stroke-dasharray: 2000; stroke-dashoffset: 2000; animation: draw 2s var(--ease-out) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes clue-in { from { opacity: 0; transform: translateY(-24px) scale(0.85); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 10% { transform: rotate(-12deg); } 20% { transform: rotate(10deg); } 30% { transform: rotate(0); } }
@keyframes flag-wave { 0%, 100% { transform: perspective(400px) rotateY(0deg); } 50% { transform: perspective(400px) rotateY(-10deg); } }

.timer { position: relative; width: 56px; height: 56px; flex: none; background: #fff; border-radius: 50%; box-shadow: var(--shadow); }
.timer svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.timer circle { fill: none; stroke-width: 5; }
.timer .track { stroke: var(--card-3); }
.timer .bar { stroke: var(--blue); stroke-linecap: round; transition: stroke 0.3s; }
.timer .t-num { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; font-size: 16px; }
.timer.warn .bar { stroke: var(--orange); }
.timer.crit .bar { stroke: var(--red); }
.timer.crit { animation: heartbeat 0.8s ease-in-out infinite; }
@keyframes heartbeat { 50% { transform: scale(1.12); } }

/* guesses (left) */
.guess-panel { position: absolute; left: 16px; top: 10px; bottom: 120px; width: 310px; display: flex; flex-direction: column; padding: 14px; z-index: 4; }
.guess-panel h4 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-faint); font-weight: 900; }
.pips { display: flex; gap: 4px; flex-wrap: wrap; margin: 10px 0 12px; }
.pips i { width: 16px; height: 8px; border-radius: 4px; background: var(--blue); transition: all 0.4s var(--ease-spring); }
.pips i.used { background: var(--card-3); transform: scaleX(0.7); }
.guess-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 2px; }
.guess-list:empty::after { content: '🌍  Make your first guess — it will light up on the globe.'; color: var(--text-faint); font-size: 14px; line-height: 1.5; padding: 18px 6px; text-align: center; }
.guess-row {
  --heat: #60a5fa;
  position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: 10px 12px 14px; border-radius: 14px; background: var(--card-2); overflow: hidden;
  border: 2px solid color-mix(in srgb, var(--heat) 35%, transparent);
  animation: guess-in 0.5s var(--ease-spring);
}
.guess-row.best { border-color: var(--heat); background: color-mix(in srgb, var(--heat) 10%, #fff); }
.guess-row.correct { --heat: var(--green); background: var(--green-soft); border-color: var(--green); }
.guess-row .g-idx { width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; font-weight: 900; background: #fff; }
.guess-row .g-name { font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.guess-row .g-word { font-size: 11px; font-weight: 900; color: color-mix(in srgb, var(--heat) 75%, #1f2d48); text-transform: uppercase; letter-spacing: 0.06em; }
.guess-row .g-dist { text-align: right; font-weight: 900; font-size: 15px; white-space: nowrap; color: color-mix(in srgb, var(--heat) 70%, #1f2d48); display: flex; align-items: center; gap: 8px; }
.guess-row .g-arrow { width: 26px; height: 26px; border-radius: 50%; background: var(--heat); color: #fff; display: grid; place-items: center; font-size: 15px; transition: transform 0.8s var(--ease-spring); }
.guess-row .g-bar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--heat); width: 0; transition: width 0.9s var(--ease-out); }
@keyframes guess-in { 0% { opacity: 0; transform: translateX(-24px) scale(0.92); } 100% { transform: none; } }

/* pick list (right) */
.pick-panel { position: absolute; right: 16px; top: 10px; bottom: 120px; width: 290px; display: flex; flex-direction: column; padding: 12px; z-index: 4; }
.pick-tabs { display: flex; margin-bottom: 10px; }
.pick-tabs .seg { width: 100%; display: grid; grid-auto-flow: column; }
.pick-search { height: 40px; font-size: 14px; margin-bottom: 10px; }
.pick-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.pick-letter { position: sticky; top: 0; z-index: 1; font-size: 11px; font-weight: 900; color: var(--text-faint); padding: 6px 8px 4px; background: linear-gradient(#fff 70%, rgba(255, 255, 255, 0)); }
.pick-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; text-align: left; font-weight: 700; font-size: 14px; transition: background 0.15s, transform 0.15s; }
.pick-item:hover:not(:disabled) { background: var(--blue-soft); transform: translateX(3px); }
.pick-item:disabled { opacity: 0.4; cursor: default; }
.pick-item .flag { width: 24px; height: 18px; }
.pick-item .heat-dot { width: 10px; height: 10px; border-radius: 50%; margin-left: auto; }
.flag-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; align-content: start; }
.flag-tile { border-radius: 10px; padding: 3px; aspect-ratio: 4 / 3; background: var(--card-2); transition: transform 0.15s var(--ease-spring), box-shadow 0.15s; }
.flag-tile img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; display: block; }
.flag-tile:hover:not(:disabled) { transform: scale(1.08); box-shadow: 0 0 0 3px var(--blue); z-index: 1; }
.flag-tile:disabled { opacity: 0.25; filter: grayscale(1); cursor: default; }

/* bottom input */
.hud-bottom {
  position: absolute; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px)); z-index: 6; display: flex; flex-direction: column; gap: 10px; align-items: stretch;
}
.guess-form { position: relative; display: flex; gap: 8px; padding: 8px; border-radius: 22px; background: #fff; box-shadow: 0 5px 0 var(--line-strong), var(--shadow-lg); }
.guess-form .input { height: 52px; font-size: 17px; }
.guess-form .btn { height: 52px; }
.autocomplete {
  position: absolute; left: 8px; right: 8px; bottom: calc(100% + 10px); padding: 6px; border-radius: 18px;
  background: #fff; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 2px;
  animation: ac-in 0.2s var(--ease-out); max-height: 50vh; overflow-y: auto;
}
.autocomplete button { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; text-align: left; font-weight: 800; }
.autocomplete button.sel, .autocomplete button:hover { background: var(--blue-soft); }
.autocomplete button:disabled { opacity: 0.45; }
.autocomplete .alias { font-size: 12px; color: var(--text-faint); font-weight: 600; }
@keyframes ac-in { from { opacity: 0; transform: translateY(8px); } }
.hud-actions { display: flex; justify-content: center; gap: 8px; }
.hud-actions .btn.ghost { background: rgba(255, 255, 255, 0.85); }
.choices { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 10px; border-radius: 22px; background: #fff; box-shadow: var(--shadow-lg); }
.choice {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 58px; padding: 8px 6px; border-radius: 14px;
  font-weight: 800; font-size: 13px; line-height: 1.15; text-align: center;
  background: var(--card-2); box-shadow: 0 3px 0 var(--line-strong);
  transition: transform 0.1s, background 0.15s, box-shadow 0.1s;
  animation: pop 0.35s var(--ease-spring) both;
}
.choice:hover:not(:disabled) { background: var(--blue-soft); transform: translateY(-2px); box-shadow: 0 5px 0 #b9cdf3; }
.choice:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.choice:disabled { opacity: 0.35; cursor: default; box-shadow: none; }
.choice.correct { opacity: 1; background: var(--green-soft); }
.choice .flag { width: 40px; height: 30px; }
.hud-bottom.wide { width: min(820px, calc(100vw - 32px)); }

.pick-confirm {
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 18px; border-radius: 20px;
  background: #fff; box-shadow: var(--shadow-lg); border: 2px solid var(--yellow);
  animation: rise 0.3s var(--ease-spring);
}
.pick-confirm .pc-text { flex: 1; font-weight: 800; }

/* players strip (multiplayer) */
.players-strip { position: absolute; left: 50%; transform: translateX(-50%); bottom: 150px; display: flex; gap: 8px; z-index: 3; flex-wrap: wrap; justify-content: center; max-width: 70vw; }
.ps-player { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 999px; background: #fff; box-shadow: var(--shadow); font-size: 13px; font-weight: 800; border: 2px solid transparent; transition: border-color 0.3s; }
.ps-player.solved { border-color: var(--green); }
.ps-player.out { border-color: var(--red); opacity: 0.8; }
.ps-player .ps-count { font-size: 12px; color: var(--text-dim); }
.ps-player.bump { animation: bump 0.45s var(--ease-spring); }
@keyframes bump { 40% { transform: scale(1.15); } }

/* guess feedback burst */
.feedback {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 7; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 14px 28px; border-radius: 26px; background: #fff; box-shadow: 0 6px 0 var(--heat, var(--line-strong)), var(--shadow-lg);
  animation: fb 2s var(--ease-out) forwards;
}
.feedback .fb-word { font-size: clamp(28px, 5vw, 48px); font-weight: 900; letter-spacing: -0.02em; color: color-mix(in srgb, var(--heat, #1f2d48) 80%, #1f2d48); }
.feedback .fb-dist { font-size: clamp(18px, 2.6vw, 24px); font-weight: 900; display: flex; align-items: center; gap: 10px; }
.feedback .fb-arrow { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--heat); color: #fff; }
@keyframes fb {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.5); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  25% { transform: translate(-50%, -50%) scale(1); }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(0.95); }
}

/* countdown */
.countdown { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; pointer-events: none; background: rgba(234, 244, 253, 0.6); animation: fade 0.25s; }
.countdown .cd-inner { text-align: center; }
.countdown .cd-round { font-size: 20px; font-weight: 900; letter-spacing: 0.25em; text-transform: uppercase; color: var(--text-dim); animation: rise 0.4s var(--ease-out); }
.countdown .cd-mode { font-size: 15px; color: var(--text-faint); margin-top: 6px; }
.countdown .cd-num {
  font-size: clamp(110px, 22vw, 210px); font-weight: 900; line-height: 1; margin-top: 10px;
  color: var(--blue); text-shadow: 0 8px 0 var(--blue-dark);
  animation: cd 1s var(--ease-out) both;
}
.countdown .cd-num.go { color: var(--green); text-shadow: 0 8px 0 var(--green-dark); }
@keyframes cd { 0% { transform: scale(2); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: scale(0.75); opacity: 0; } }

/* round result */
.reveal {
  position: absolute; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  width: min(620px, calc(100vw - 32px)); padding: 22px; text-align: center;
  box-shadow: 0 6px 0 var(--line-strong), var(--shadow-lg);
  animation: reveal-in 0.6s var(--ease-spring);
}
@keyframes reveal-in { from { opacity: 0; transform: translate(-50%, 60px) scale(0.92); } }
.reveal .rv-status { display: inline-block; font-size: 13px; font-weight: 900; letter-spacing: 0.15em; text-transform: uppercase; padding: 4px 12px; border-radius: 999px; }
.reveal .rv-status.win { color: var(--green-dark); background: var(--green-soft); }
.reveal .rv-status.lose { color: var(--red-dark); background: var(--red-soft); }
.reveal .rv-target { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 12px 0 6px; font-size: clamp(26px, 4vw, 36px); font-weight: 900; }
.reveal .rv-points { font-size: 42px; font-weight: 900; color: var(--points); }
.reveal .rv-points small { font-size: 18px; }
.results-table { width: 100%; border-collapse: separate; border-spacing: 0 6px; margin-top: 10px; text-align: left; }
.results-table td { padding: 8px 10px; background: var(--card-2); }
.results-table td:first-child { border-radius: 12px 0 0 12px; }
.results-table td:last-child { border-radius: 0 12px 12px 0; text-align: right; }
.results-table tr { animation: rise 0.45s var(--ease-out) both; }
.next-bar { height: 6px; border-radius: 6px; background: var(--card-3); overflow: hidden; margin-top: 14px; }
.next-bar i { display: block; height: 100%; background: var(--blue); transform-origin: left; }

/* final */
.final { position: absolute; inset: 0; z-index: 25; display: grid; place-items: center; padding: 16px; overflow-y: auto; background: rgba(234, 244, 253, 0.75); animation: fade 0.4s; }
.final-card { width: min(720px, 100%); padding: 28px; text-align: center; box-shadow: 0 8px 0 var(--line-strong), var(--shadow-lg); animation: modal-in 0.6s var(--ease-spring); }
.final-title { font-size: clamp(34px, 6vw, 52px); font-weight: 900; margin: 0; color: var(--text); text-shadow: 0 4px 0 var(--line); }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 12px; margin: 26px 0 18px; min-height: 230px; }
.podium-col { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 140px; }
.podium-col .pd-name { font-weight: 900; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-col .pd-score { font-weight: 900; color: var(--points); }
.podium-block {
  width: 100%; border-radius: 16px 16px 6px 6px; display: grid; place-items: start center; padding-top: 10px;
  font-size: 34px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
  transform-origin: bottom; animation: grow 0.8s var(--ease-spring) both;
}
.podium-col.p1 .podium-block { height: 130px; background: var(--yellow); box-shadow: inset 0 -8px 0 var(--yellow-dark); animation-delay: 0.9s; }
.podium-col.p2 .podium-block { height: 95px; background: #b6c3d6; box-shadow: inset 0 -8px 0 #94a3b8; animation-delay: 0.5s; }
.podium-col.p3 .podium-block { height: 70px; background: #f0a36b; box-shadow: inset 0 -8px 0 #d07a3e; animation-delay: 0.2s; }
.podium-col .avatar { animation: pop 0.5s var(--ease-spring) both; }
.podium-col.p1 .avatar { animation-delay: 1.5s; } .podium-col.p2 .avatar { animation-delay: 1.1s; } .podium-col.p3 .avatar { animation-delay: 0.8s; }
.podium-col.p1 .crown-big { font-size: 34px; animation: pop 0.5s var(--ease-spring) 1.8s both, bob 2s ease-in-out 2.4s infinite; }
@keyframes grow { from { transform: scaleY(0); } }
.big-score { font-size: clamp(60px, 12vw, 104px); font-weight: 900; line-height: 1; margin: 18px 0 4px; color: var(--blue); text-shadow: 0 6px 0 var(--blue-soft); }
.stars-row { display: flex; justify-content: center; gap: 10px; font-size: 46px; margin: 8px 0 16px; }
.stars-row span { filter: grayscale(1) opacity(0.3); animation: star 0.5s var(--ease-spring) both; }
.stars-row span.lit { filter: none; }
.stars-row span:nth-child(1) { animation-delay: 0.6s; } .stars-row span:nth-child(2) { animation-delay: 0.85s; } .stars-row span:nth-child(3) { animation-delay: 1.1s; }
@keyframes star { from { transform: scale(0) rotate(-180deg); opacity: 0; } }
.round-summary { display: grid; gap: 6px; text-align: left; margin: 10px 0 20px; max-height: 32vh; overflow-y: auto; }
.round-summary .rs { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 12px; background: var(--card-2); animation: rise 0.4s var(--ease-out) both; }
.final-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

.spectate-banner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 18px 26px; text-align: center; z-index: 6; }

/* target tag on the globe */
.globe-tag {
  display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; border-radius: 999px; white-space: nowrap;
  background: #fff; border: 3px solid var(--green); box-shadow: 0 4px 12px rgba(31, 45, 72, 0.25);
  font-weight: 900; font-size: 15px; color: var(--text); transform: translate(-50%, -140%); pointer-events: none;
  animation: tag-in 0.5s var(--ease-spring);
}
.globe-tag .flag { width: 28px; height: 21px; }
.globe-tag.guess { border-color: var(--heat, #60a5fa); font-size: 12px; padding: 3px 10px 3px 4px; }
.globe-tag.guess .flag { width: 20px; height: 15px; }
@keyframes tag-in { from { opacity: 0; transform: translate(-50%, -80%) scale(0.5); } }

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

.lb-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.lb-table { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.lb-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-faint); padding: 0 12px 4px; font-weight: 900; }
.lb-table td { padding: 10px 12px; background: var(--card-2); }
.lb-table td:first-child { border-radius: 14px 0 0 14px; width: 60px; }
.lb-table td:last-child { border-radius: 0 14px 14px 0; }
.lb-table tr.me td { background: var(--blue-soft); }
.lb-table tbody tr { animation: rise 0.4s var(--ease-out) both; cursor: pointer; }
.lb-table tbody tr:hover td { background: #e9f0fb; }
.rank-badge { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; font-weight: 900; background: #fff; box-shadow: 0 2px 0 var(--line-strong); }
.rank-badge.r1 { background: var(--yellow); color: #6b4a00; box-shadow: 0 3px 0 var(--yellow-dark); }
.rank-badge.r2 { background: #d6deea; color: #334155; box-shadow: 0 3px 0 #a9b6c9; }
.rank-badge.r3 { background: #f5bf94; color: #6b3511; box-shadow: 0 3px 0 #d58d57; }
.lb-top3 { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 14px; align-items: end; margin-bottom: 18px; }
.lb-top3 .t3 { text-align: center; padding: 20px 12px; cursor: pointer; background: var(--card-2); box-shadow: 0 5px 0 var(--line-strong); transition: transform 0.25s var(--ease-spring); }
.lb-top3 .t3:hover { transform: translateY(-4px); }
.lb-top3 .t3.first { padding: 28px 12px; background: #fff7df; box-shadow: 0 5px 0 #f1d38a; }
.lb-top3 .t3 .medal { font-size: 34px; display: block; margin-bottom: 6px; }
.lb-top3 .t3 .avatar { margin: 0 auto 8px; }
.lb-top3 .t3 .val { font-size: 21px; font-weight: 900; color: var(--points); }

/* ---------------------------------------------------------------- profile */

.profile-head { display: flex; align-items: center; gap: 22px; padding: 26px; flex-wrap: wrap; }
.profile-head h1 { margin: 0; font-size: 36px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 18px 0; }
.stat { padding: 18px; text-align: center; box-shadow: 0 4px 0 var(--line-strong), var(--shadow); }
.stat .s-val { font-size: 30px; font-weight: 900; color: var(--blue); }
.stat .s-label { font-size: 13px; color: var(--text-dim); font-weight: 700; }
.mode-bars { display: grid; gap: 10px; }
.mode-bar { display: grid; grid-template-columns: 130px 1fr 70px; gap: 12px; align-items: center; }
.mode-bar .mb-track { height: 12px; border-radius: 12px; background: var(--card-3); overflow: hidden; }
.mode-bar .mb-fill { height: 100%; border-radius: 12px; background: var(--green); width: 0; transition: width 1.1s var(--ease-out); }

/* ---------------------------------------------------------------- friends */

.friend-row { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--card-2); animation: rise 0.4s var(--ease-out) both; }
.friend-row .f-status { font-size: 13px; color: var(--text-faint); }
.friend-row .f-status.on { color: var(--green-dark); }
.friend-row .f-status.play { color: var(--orange-dark); }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 95; pointer-events: none; }

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

@media (max-width: 1100px) {
  .guess-panel { width: 260px; }
  .pick-panel { width: 240px; }
  .mode-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  :root { --topbar-h: 58px; }
  .nav { display: none; }
  .auth-wrap { grid-template-columns: 1fr; gap: 20px; padding-top: 2vh; }
  .auth-card { justify-self: stretch; max-width: none; }
  .hero-features { display: none; }
  .play-cards { grid-template-columns: 1fr; }
  .play-card { min-height: 0; }
  .home-cols, .lobby-layout, .grid-2 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
  .lb-top3 { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .mobile-nav { display: flex !important; }
  .page { padding-bottom: 90px; }

  .guess-panel {
    top: auto; bottom: 0; left: 0; right: 0; width: auto; height: auto; max-height: 40vh;
    border-radius: 22px 22px 0 0; transform: translateY(calc(100% - 46px)); transition: transform 0.4s var(--ease-out); z-index: 8;
  }
  .guess-panel.open { transform: none; }
  .guess-panel .drawer-handle { display: flex !important; }
  .pick-panel {
    top: auto; bottom: 0; left: 0; right: 0; width: auto; height: 62vh;
    border-radius: 22px 22px 0 0; transform: translateY(100%); transition: transform 0.4s var(--ease-out); z-index: 9;
  }
  .pick-panel.open { transform: none; box-shadow: 0 -10px 40px rgba(31, 45, 72, 0.2); }
  .pick-close { display: grid !important; }
  .hud-bottom { bottom: 58px; }
  .players-strip { bottom: auto; top: 64px; left: 16px; transform: none; max-width: calc(100vw - 32px); justify-content: flex-start; }
  .choices { grid-template-columns: repeat(2, 1fr); max-height: 46vh; overflow-y: auto; }
  .reveal { bottom: 58px; max-height: 70vh; overflow-y: auto; }
  .mobile-pick-btn { display: inline-flex !important; }
  .desktop-only { display: none; }
}

@media (max-width: 560px) {
  .clue-card { padding: 10px 14px; gap: 10px; }
  .clue-card .clue-title { font-size: 16px; }
  .clue-card .clue-icon { font-size: 26px; }
  .outline-svg { width: 130px; height: 98px; }
  .clue-card .flag.xl { width: 140px; }
  .mode-cards { grid-template-columns: 1fr 1fr; }
  .inputs-grid { grid-template-columns: repeat(2, 1fr); }
  .podium-col { width: 96px; }
  .room-code { font-size: 26px; }
  .user-chip .uc-name { display: none; }
  .user-chip { padding: 4px; }
  .mode-bar { grid-template-columns: 90px 1fr 50px; }
}

.drawer-handle { display: none; align-items: center; justify-content: space-between; cursor: pointer; padding-bottom: 6px; }
.drawer-handle::before { content: ''; position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; border-radius: 4px; background: var(--line-strong); transform: translateX(-50%); }
.pick-close { display: none; position: absolute; top: 10px; right: 10px; }
.mobile-pick-btn { display: none; }
.mobile-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; justify-content: space-around;
  padding: 8px 8px max(8px, env(safe-area-inset-bottom)); background: #fff; box-shadow: 0 -2px 12px rgba(31, 45, 72, 0.08);
}
.mobile-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 800; color: var(--text-dim); padding: 4px 14px; border-radius: 12px; position: relative; }
.mobile-nav a .mn-icon { font-size: 20px; }
.mobile-nav a.active { color: var(--blue); background: var(--blue-soft); }
.mobile-nav .badge { position: absolute; top: 0; right: 4px; }
body.in-game .mobile-nav { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
