
/* ═══════════════════════════════════════════════════════════
   DHARAVERSE MAP MYSTERY — CANDY CRUSH INSPIRED UI
   SCROLL-FIX VERSION
   File: /games/daily-mystery/css/game.css
   ═══════════════════════════════════════════════════════════ */

/* ───────────────────────────────────────────────────────────
   1. CSS CUSTOM PROPERTIES
   ─────────────────────────────────────────────────────────── */
:root {
  --bg-primary: #0a0a2e;
  --bg-card: #12123d;
  --bg-secondary: #1a1a4e;
  --bg-gradient: linear-gradient(180deg, #0a0a2e 0%, #0e0e36 30%, #141450 60%, #0a0a2e 100%);

  --candy-purple: #A855F7;
  --candy-pink: #F472B6;
  --candy-blue: #60A5FA;
  --candy-cyan: #22D3EE;
  --candy-mint: #34D399;
  --candy-yellow: #FBBF24;
  --candy-orange: #FB923C;
  --candy-red: #FB7185;
  --candy-lime: #A3E635;

  --game-gold: #FFD700;
  --game-green: #34D399;
  --game-red: #FB7185;
  --game-yellow: #FBBF24;
  --game-orange: #FB923C;

  --text-primary: #F8FAFC;
  --text-secondary: #CBD5E1;
  --text-muted: #64748B;

  --border-candy: rgba(168, 85, 247, 0.3);
  --glass-bg: rgba(18, 18, 61, 0.92);
  --glass-border: rgba(168, 85, 247, 0.15);
  --glass-shine: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.08) 0%,
    transparent 50%,
    rgba(255, 255, 255, 0.03) 100%
  );

  --grad-purple: linear-gradient(135deg, #A855F7, #7C3AED);
  --grad-pink: linear-gradient(135deg, #F472B6, #EC4899);
  --grad-mint: linear-gradient(135deg, #34D399, #10B981);
  --grad-gold: linear-gradient(135deg, #FBBF24, #F59E0B, #D97706);
  --grad-fire: linear-gradient(135deg, #FB7185, #FB923C, #FBBF24);
  --grad-cosmic: linear-gradient(135deg, #A855F7, #EC4899, #F472B6);
  --grad-candy-btn: linear-gradient(180deg, #C084FC 0%, #A855F7 40%, #7C3AED 100%);
  --grad-candy-green: linear-gradient(180deg, #6EE7B7 0%, #34D399 40%, #10B981 100%);
  --grad-card: linear-gradient(160deg, rgba(18, 18, 61, 0.95), rgba(26, 26, 78, 0.85));
  --grad-header: linear-gradient(180deg, rgba(10, 10, 46, 0.98), rgba(10, 10, 46, 0.92));

  --fs-h1: clamp(22px, 5vw, 42px);
  --fs-h2: clamp(18px, 4vw, 32px);
  --fs-h3: clamp(15px, 3vw, 22px);
  --fs-body: clamp(13.5px, 2.2vw, 16px);
  --fs-small: clamp(11.5px, 1.8vw, 14px);
  --fs-tiny: clamp(10px, 1.4vw, 12px);
  --fs-micro: clamp(9px, 1.2vw, 10px);

  --sp-xs: clamp(4px, 1vw, 8px);
  --sp-sm: clamp(8px, 2vw, 14px);
  --sp-md: clamp(14px, 3vw, 22px);
  --sp-lg: clamp(20px, 4vw, 36px);
  --sp-xl: clamp(28px, 5vw, 48px);

  --header-h: 56px;
  --map-h-mobile: 32vh;
  --map-h-tablet: 40vh;
  --map-h-desktop: 50vh;
  --sidebar-w: 280px;
  --max-content: 660px;
  --max-page: 1400px;

  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-full: 9999px;

  --sh-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --sh-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --sh-lg: 0 8px 32px rgba(0, 0, 0, 0.45);
  --sh-candy: 0 4px 0 rgba(0, 0, 0, 0.15);
  --sh-glow-purple: 0 0 24px rgba(168, 85, 247, 0.35);
  --sh-glow-green: 0 0 24px rgba(52, 211, 153, 0.35);
  --sh-glow-gold: 0 0 24px rgba(255, 215, 0, 0.35);
  --sh-glow-red: 0 0 24px rgba(251, 113, 133, 0.35);
  --sh-inset-candy: inset 0 2px 4px rgba(255, 255, 255, 0.06);

  --t-fast: 120ms ease;
  --t-normal: 220ms ease;
  --t-slow: 380ms ease;
  --t-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-bounce: 600ms cubic-bezier(0.68, -0.55, 0.265, 1.55);

  --z-map: 1;
  --z-map-ui: 10;
  --z-header: 100;
  --z-autocomplete: 200;
  --z-game-over: 300;
  --z-toast: 400;
  --z-modal: 500;
  --z-loading: 600;
}


/* ───────────────────────────────────────────────────────────
   2. RESET & BASE
   THE KEY FIX: html/body use height:100% + overflow:hidden
   #game-area is the ONLY scrollable element on mobile
   ─────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--fs-body);
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--bg-gradient);
  height: 100%;
  margin: 0;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* ⚠️ NO position:fixed — that kills mobile scrolling */
}

/* Ambient glow particles */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 15% 30%, rgba(168, 85, 247, 0.07) 0%, transparent 70%),
    radial-gradient(ellipse 50% 50% at 85% 20%, rgba(244, 114, 182, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse 40% 60% at 50% 85%, rgba(34, 211, 238, 0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

a {
  color: var(--candy-purple);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--candy-pink); }

a:focus-visible,
button:focus-visible {
  outline: 2.5px solid var(--candy-purple);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  -webkit-appearance: none;
  touch-action: manipulation;
}

input {
  font-family: inherit;
  /* max(16px) prevents iOS auto-zoom on focus */
  font-size: max(16px, var(--fs-body));
  -webkit-appearance: none;
  touch-action: manipulation;
}

ul { list-style: none; }
img { max-width: 100%; display: block; }

::selection {
  background: rgba(168, 85, 247, 0.4);
  color: var(--text-primary);
}

/* Desktop scrollbar */
@media (min-width: 1024px) {
  ::-webkit-scrollbar { width: 6px; }
  ::-webkit-scrollbar-track { background: var(--bg-primary); }
  ::-webkit-scrollbar-thumb {
    background: var(--grad-cosmic);
    border-radius: var(--r-full);
  }
}


/* ───────────────────────────────────────────────────────────
   3. UTILITY CLASSES
   ─────────────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Glass card */
.glass-card {
  background: var(--grad-card);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md), var(--sh-inset-candy);
  position: relative;
  overflow: hidden;
}

.glass-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--glass-shine);
  pointer-events: none;
  z-index: 0;
}

.glass-card > * {
  position: relative;
  z-index: 1;
}

/* ── Primary Button — Candy style ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 26px;
  background: var(--grad-candy-btn);
  color: var(--text-primary);
  font-weight: 800;
  font-size: var(--fs-body);
  border-radius: var(--r-md);
  cursor: pointer;
  min-height: 48px;
  user-select: none;
  position: relative;
  overflow: hidden;
  box-shadow: var(--sh-candy), 0 2px 12px rgba(168, 85, 247, 0.25);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
  letter-spacing: 0.3px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0%, transparent 100%);
  pointer-events: none;
  border-radius: inherit;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.12), var(--sh-glow-purple);
}

.btn-primary:active {
  transform: translateY(2px) scale(0.98);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: var(--sh-sm);
}

/* ── Secondary Button ── */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 26px;
  background: rgba(168, 85, 247, 0.08);
  color: var(--candy-purple);
  font-weight: 700;
  font-size: var(--fs-body);
  border-radius: var(--r-md);
  border: 2px solid rgba(168, 85, 247, 0.35);
  cursor: pointer;
  min-height: 48px;
  touch-action: manipulation;
  transition: all var(--t-fast);
}

.btn-secondary:hover {
  background: rgba(168, 85, 247, 0.15);
  border-color: var(--candy-purple);
  transform: translateY(-1px);
  box-shadow: var(--sh-glow-purple);
}

.btn-secondary:active { transform: translateY(1px); }

/* ── Icon Button ── */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border-radius: var(--r-full);
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-candy);
  font-weight: 800;
  font-size: 16px;
  color: var(--text-primary);
  cursor: pointer;
  touch-action: manipulation;
  transition: all var(--t-fast);
}

.btn-icon:hover {
  background: var(--candy-purple);
  border-color: var(--candy-purple);
  transform: scale(1.12) rotate(5deg);
  box-shadow: var(--sh-glow-purple);
}

.btn-icon:active { transform: scale(0.95); }


/* ───────────────────────────────────────────────────────────
   4. LOADING SCREEN
   ─────────────────────────────────────────────────────────── */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: var(--z-loading);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  background-image:
    radial-gradient(circle at 30% 40%, rgba(168, 85, 247, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 70% 60%, rgba(244, 114, 182, 0.06) 0%, transparent 50%);
  transition: opacity 0.6s ease, visibility 0.6s ease;
  opacity: 1;
  visibility: visible;
}

#loading-screen.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-inner {
  text-align: center;
  padding: var(--sp-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-md);
}

.loading-globe {
  font-size: clamp(56px, 15vw, 80px);
  animation: candyBounce 1.8s ease-in-out infinite;
  filter: drop-shadow(0 8px 24px rgba(168, 85, 247, 0.4));
}

@keyframes candyBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  25%       { transform: translateY(-16px) scale(1.05); }
  50%       { transform: translateY(0) scale(0.95); }
  75%       { transform: translateY(-10px) scale(1.03); }
}

.loading-text {
  font-size: var(--fs-body);
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.loading-bar {
  width: clamp(180px, 50vw, 240px);
  height: 8px;
  background: var(--bg-secondary);
  border-radius: var(--r-full);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.loading-bar-fill {
  height: 100%;
  width: 30%;
  background: var(--grad-cosmic);
  border-radius: var(--r-full);
  animation: candySlide 1.4s ease-in-out infinite;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.5);
}

@keyframes candySlide {
  0%   { transform: translateX(-110%); width: 30%; }
  50%  { width: 55%; }
  100% { transform: translateX(380%); width: 30%; }
}


/* ───────────────────────────────────────────────────────────
   5. TOASTS
   ─────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: calc(var(--header-h) + var(--sp-xs) + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-xs);
  pointer-events: none;
  width: 92%;
  max-width: 400px;
}

.toast {
  padding: 12px 22px;
  border-radius: var(--r-lg);
  font-size: var(--fs-small);
  font-weight: 800;
  text-align: center;
  pointer-events: auto;
  box-shadow: var(--sh-candy), var(--sh-md);
  animation: toastPop 0.4s var(--t-bounce) forwards;
  max-width: 100%;
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 45%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0%, transparent 100%);
  pointer-events: none;
}

.toast.removing { animation: toastDrop 0.3s ease forwards; }

@keyframes toastPop {
  0%   { opacity: 0; transform: translateY(-24px) scale(0.8); }
  60%  { transform: translateY(4px) scale(1.03); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastDrop {
  to { opacity: 0; transform: translateY(-20px) scale(0.85); }
}

.toast.success { background: var(--grad-candy-green); color: #064E3B; box-shadow: var(--sh-candy), var(--sh-glow-green); }
.toast.error   { background: var(--grad-fire); color: #fff; box-shadow: var(--sh-candy), var(--sh-glow-red); }
.toast.info    { background: var(--bg-secondary); color: var(--text-primary); border: 1.5px solid var(--border-candy); }
.toast.warning { background: var(--grad-gold); color: #422006; box-shadow: var(--sh-candy), var(--sh-glow-gold); }


/* ───────────────────────────────────────────────────────────
   6. MODAL
   ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px) saturate(0.8);
  -webkit-backdrop-filter: blur(10px) saturate(0.8);
  padding: var(--sp-sm);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: var(--sp-lg);
  position: relative;
  transform: translateY(40px) scale(0.9);
  transition: transform 0.5s var(--t-spring);
}

.modal-overlay[aria-hidden="false"] .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-md);
}

.modal-title {
  font-size: var(--fs-h3);
  font-weight: 900;
  background: var(--grad-cosmic);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-close {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-full);
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-candy);
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--candy-red);
  color: #fff;
  border-color: var(--candy-red);
  transform: rotate(90deg) scale(1.1);
}

.modal-body { display: flex; flex-direction: column; gap: var(--sp-md); }
.modal-intro { font-size: var(--fs-body); color: var(--text-secondary); line-height: 1.65; }
.modal-intro strong { color: var(--game-gold); font-weight: 800; }

.modal-steps { display: flex; flex-direction: column; gap: var(--sp-sm); }

.modal-step {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-sm);
  padding: var(--sp-sm);
  background: rgba(168, 85, 247, 0.04);
  border-radius: var(--r-md);
  border: 1.5px solid rgba(168, 85, 247, 0.1);
  transition: all var(--t-fast);
}

.modal-step:hover {
  border-color: rgba(168, 85, 247, 0.3);
  transform: translateX(4px);
}

.step-icon {
  font-size: clamp(24px, 5vw, 30px);
  flex-shrink: 0;
  width: 40px;
  text-align: center;
}

.step-text { display: flex; flex-direction: column; gap: 3px; }
.step-text strong { font-size: var(--fs-body); font-weight: 800; color: var(--text-primary); }
.step-text span { font-size: var(--fs-small); color: var(--text-muted); line-height: 1.45; }

.modal-feedback-legend {
  padding: var(--sp-sm);
  background: rgba(168, 85, 247, 0.04);
  border-radius: var(--r-md);
  border: 1.5px solid rgba(168, 85, 247, 0.1);
}

.modal-feedback-legend h3 {
  font-size: var(--fs-tiny);
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: var(--sp-xs);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 5px 0;
  font-size: var(--fs-small);
  color: var(--text-secondary);
}

.legend-dot {
  width: 14px; height: 14px;
  border-radius: var(--r-full);
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}

.legend-dot.correct { background: var(--game-green); color: var(--game-green); }
.legend-dot.close   { background: var(--game-yellow); color: var(--game-yellow); }
.legend-dot.wrong   { background: var(--game-red); color: var(--game-red); }

.modal-news-note {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-sm);
  padding: var(--sp-sm);
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.08), rgba(244, 114, 182, 0.04));
  border: 1.5px solid rgba(168, 85, 247, 0.2);
  border-radius: var(--r-md);
  font-size: var(--fs-small);
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-news-note span { font-size: 22px; flex-shrink: 0; }

.modal-footer { margin-top: var(--sp-md); }

.modal-footer .btn-primary {
  width: 100%;
  padding: 16px;
  font-size: clamp(15px, 3vw, 17px);
  font-weight: 900;
  border-radius: var(--r-lg);
}


/* ───────────────────────────────────────────────────────────
   7. GAME WRAPPER
   ★ KEY LAYOUT: flex column, fixed height, no overflow
     #game-area is the ONLY scrollable child
   ─────────────────────────────────────────────────────────── */
#game-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  width: 100%;
  max-width: var(--max-page);
  margin: 0 auto;
  position: relative;
  z-index: 1;
  /* wrapper clips map/header — does NOT scroll */
  overflow: hidden;
}


/* ───────────────────────────────────────────────────────────
   8. HEADER
   ─────────────────────────────────────────────────────────── */
#game-header {
  position: relative;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 var(--sp-sm);
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--grad-header);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border-bottom: 1px solid rgba(168, 85, 247, 0.12);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  flex-shrink: 0; /* never compress */
}

@supports (padding-top: env(safe-area-inset-top)) {
  #game-header {
    height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  }
}

.header-left { flex: 0 0 auto; display: flex; align-items: center; }

.header-back {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  font-size: var(--fs-small);
  font-weight: 700;
  color: var(--text-secondary);
  transition: all var(--t-fast);
  min-height: 44px;
  min-width: 44px;
  text-decoration: none;
}

.header-back:hover { color: var(--text-primary); background: rgba(168, 85, 247, 0.1); }
.header-back span:first-child { font-size: 18px; }
.header-back-text { display: none; }

.header-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
}

.header-title {
  font-size: clamp(15px, 4vw, 22px);
  font-weight: 900;
  letter-spacing: -0.3px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: clamp(4px, 1.5vw, 8px);
  background: var(--grad-cosmic);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-globe {
  font-size: clamp(14px, 3.5vw, 22px);
  -webkit-text-fill-color: initial;
  filter: drop-shadow(0 2px 8px rgba(168, 85, 247, 0.4));
  animation: gentlePulse 3s ease-in-out infinite;
}

@keyframes gentlePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

#day-number {
  font-size: var(--fs-micro);
  font-weight: 800;
  color: var(--candy-purple);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.header-right { flex: 0 0 auto; display: flex; align-items: center; gap: var(--sp-xs); }

.streak-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(251, 191, 36, 0.05));
  border: 1.5px solid rgba(255, 215, 0, 0.3);
  border-radius: var(--r-full);
  font-size: var(--fs-small);
  font-weight: 800;
  min-height: 36px;
  transition: all var(--t-fast);
}

.streak-badge:hover { box-shadow: var(--sh-glow-gold); border-color: var(--game-gold); transform: scale(1.05); }

.streak-fire {
  font-size: 16px;
  animation: fireFlicker 1.5s ease-in-out infinite alternate;
}

@keyframes fireFlicker {
  0%   { transform: scale(1) rotate(0deg); }
  50%  { transform: scale(1.15) rotate(-5deg); }
  100% { transform: scale(1.05) rotate(3deg); }
}

.streak-count { color: var(--game-gold); min-width: 12px; text-align: center; text-shadow: 0 0 8px rgba(255, 215, 0, 0.4); }


/* ───────────────────────────────────────────────────────────
   9. NEWS FACT BANNER
   ─────────────────────────────────────────────────────────── */
#news-fact {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 10px var(--sp-sm);
  padding-left: calc(var(--sp-sm) + 4px);
  background: linear-gradient(
    90deg,
    rgba(168, 85, 247, 0.06),
    rgba(244, 114, 182, 0.04),
    rgba(34, 211, 238, 0.05)
  );
  border-bottom: 1px solid rgba(168, 85, 247, 0.1);
  font-size: var(--fs-small);
  color: var(--text-secondary);
  line-height: 1.45;
  flex-shrink: 0; /* never compress */
  min-height: 42px;
  position: relative;
  overflow: hidden;
}

#news-fact::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--grad-cosmic);
}

.news-icon { font-size: 18px; flex-shrink: 0; }

.news-text {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}


/* ───────────────────────────────────────────────────────────
   10. MAP SECTION — fixed height, flex-shrink: 0
   ─────────────────────────────────────────────────────────── */
.map-section {
  position: relative;
  width: 100%;
  height: var(--map-h-mobile);
  flex-shrink: 0;
  border-bottom: 1px solid rgba(168, 85, 247, 0.12);
  overflow: hidden;
}

#game-map {
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  z-index: var(--z-map);
}

/* Leaflet dark overrides */
.leaflet-container { background: var(--bg-primary) !important; font-family: inherit !important; }

.leaflet-control-zoom { border: none !important; box-shadow: var(--sh-md) !important; border-radius: var(--r-md) !important; }
.leaflet-control-zoom a {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-candy) !important;
  width: 36px !important; height: 36px !important;
  line-height: 36px !important; font-size: 18px !important;
  transition: all 0.15s ease !important;
}
.leaflet-control-zoom a:hover { background: var(--candy-purple) !important; border-color: var(--candy-purple) !important; }
.leaflet-control-zoom-in  { border-radius: var(--r-sm) var(--r-sm) 0 0 !important; }
.leaflet-control-zoom-out { border-radius: 0 0 var(--r-sm) var(--r-sm) !important; border-top: none !important; }

.leaflet-control-attribution {
  font-size: 9px !important;
  background: rgba(10, 10, 46, 0.85) !important;
  color: var(--text-muted) !important;
  padding: 2px 6px !important;
}
.leaflet-control-attribution a { color: var(--candy-purple) !important; }

.leaflet-popup-content-wrapper {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--sh-lg) !important;
  border: 1.5px solid var(--border-candy) !important;
}
.leaflet-popup-tip { background: var(--bg-card) !important; }

/* Attempts pill overlay */
.map-overlay-top {
  position: absolute;
  top: var(--sp-sm);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-map-ui);
  pointer-events: none;
}

.attempts-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--r-full);
  font-size: var(--fs-small);
  font-weight: 800;
  color: var(--text-primary);
  box-shadow: var(--sh-md);
  white-space: nowrap;
  pointer-events: auto;
}


/* ───────────────────────────────────────────────────────────
   11. GAME AREA ← THE SCROLLABLE CONTAINER
   ★ This is the ONLY element that scrolls on mobile
   ─────────────────────────────────────────────────────────── */
#/* Update #game-area to leave room for mobile bottom nav */
#game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--max-content);
  margin: 0 auto;
  padding: var(--sp-sm);
  /* Extra bottom padding for mobile nav */
  padding-bottom: calc(var(--sp-xl) + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scroll-behavior: smooth;
}

/* ───────────────────────────────────────────────────────────
   12. GUESS INPUT FORM
   ─────────────────────────────────────────────────────────── */
.guess-section {
  position: relative;
  flex-shrink: 0;
  margin-bottom: var(--sp-sm);
}

.guess-form { display: flex; gap: var(--sp-xs); width: 100%; }

.input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  font-size: 16px;
  pointer-events: none;
  z-index: 1;
  opacity: 0.45;
}

.guess-input {
  width: 100%;
  padding: 13px 42px 13px 42px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-candy);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: max(16px, var(--fs-body));
  font-weight: 600;
  min-height: 52px;
  transition: all var(--t-fast);
  box-shadow: var(--sh-inset-candy);
}

.guess-input::placeholder { color: var(--text-muted); font-weight: 400; }

.guess-input:focus {
  border-color: var(--candy-purple);
  box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.12), var(--sh-glow-purple);
  background: var(--bg-card);
  outline: none;
}

.guess-input:disabled { opacity: 0.35; cursor: not-allowed; }

.input-clear-btn {
  position: absolute;
  right: 6px;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-full);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: color var(--t-fast), transform var(--t-fast);
}

.input-clear-btn:hover { color: var(--text-primary); transform: scale(1.15); }

.btn-guess {
  flex-shrink: 0;
  padding: 13px 20px;
  min-width: 80px;
  font-weight: 900;
  letter-spacing: 0.5px;
  border-radius: var(--r-md);
  font-size: var(--fs-body);
}


/* ───────────────────────────────────────────────────────────
   13. AUTOCOMPLETE
   ─────────────────────────────────────────────────────────── */
.autocomplete-list {
  position: absolute;
  top: 100%; left: 0; right: 0;
  z-index: var(--z-autocomplete);
  background: var(--bg-card);
  border: 1.5px solid var(--border-candy);
  border-radius: 0 0 var(--r-md) var(--r-md);
  box-shadow: var(--sh-lg);
  max-height: 240px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  margin-top: -2px;
}

.autocomplete-list[hidden] { display: none; }

.autocomplete-item {
  display: flex; align-items: center; gap: var(--sp-sm);
  padding: 12px 16px;
  font-size: var(--fs-body);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--t-fast);
  border-bottom: 1px solid rgba(168, 85, 247, 0.05);
  min-height: 48px;
  touch-action: manipulation;
}

.autocomplete-item:last-child { border-bottom: none; }

.autocomplete-item:hover,
.autocomplete-item.highlighted {
  background: linear-gradient(90deg, rgba(168, 85, 247, 0.12), rgba(244, 114, 182, 0.06));
}

.autocomplete-flag { font-size: clamp(18px, 4vw, 24px); flex-shrink: 0; }

.autocomplete-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600;
}

.autocomplete-name mark {
  background: rgba(168, 85, 247, 0.3);
  color: var(--text-primary);
  border-radius: 3px;
  padding: 0 2px;
}


/* ───────────────────────────────────────────────────────────
   14. COLUMN HEADERS
   ─────────────────────────────────────────────────────────── */
.attempt-headers {
  display: grid;
  grid-template-columns: 1.5fr 1fr 0.6fr 0.6fr 1fr;
  gap: 4px;
  padding: 8px var(--sp-xs);
  margin-bottom: 4px;
}

.attempt-headers[hidden] { display: none; }

.col-header {
  font-size: var(--fs-micro);
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  text-align: center;
}

.col-header.col-country { text-align: left; }


/* ───────────────────────────────────────────────────────────
   15. ATTEMPTS CONTAINER + ROWS
   ─────────────────────────────────────────────────────────── */
.attempts-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: var(--sp-lg);
}

/* Empty state */
.attempts-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  padding: var(--sp-xl) var(--sp-md);
  text-align: center;
  color: var(--text-muted);
}

.attempts-empty[hidden] { display: none; }

.empty-icon {
  font-size: clamp(40px, 10vw, 56px);
  opacity: 0.35;
  animation: gentleFloat 4s ease-in-out infinite;
}

@keyframes gentleFloat {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

.attempts-empty p { font-size: var(--fs-body); font-weight: 700; }
.attempts-empty .empty-sub { font-size: var(--fs-small); opacity: 0.55; }

/* ── Attempt Row ── */
.attempt-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 0.6fr 0.6fr 1fr;
  gap: 4px;
  padding: var(--sp-xs) var(--sp-sm);
  background: var(--grad-card);
  border: 1.5px solid rgba(168, 85, 247, 0.15);
  border-radius: var(--r-md);
  min-height: 54px;
  align-items: center;
  box-shadow: var(--sh-sm), var(--sh-candy);
  position: relative;
  overflow: hidden;
  /* Lazy load: starts invisible */
  opacity: 0;
  transform: translateX(-16px);
  animation: rowSlideIn 0.4s ease forwards;
}

@keyframes rowSlideIn {
  to { opacity: 1; transform: translateX(0); }
}

/* Loaded class applied by JS */
.attempt-row.loaded {
  opacity: 1;
  transform: translateX(0);
}

.attempt-row:hover {
  border-color: rgba(168, 85, 247, 0.35);
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.1), var(--sh-candy);
}

.attempt-row.correct-row {
  border-color: var(--game-green);
  box-shadow: var(--sh-glow-green), 0 4px 0 rgba(16, 185, 129, 0.2);
  background: linear-gradient(145deg, rgba(52, 211, 153, 0.1), rgba(16, 185, 129, 0.05));
}

.attempt-row.close-row {
  border-color: rgba(251, 191, 36, 0.35);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.08), var(--sh-candy);
}

/* ── Cells ── */
.attempt-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 5px 3px;
  border-radius: var(--r-xs);
  min-height: 42px;
  gap: 2px;
  overflow: hidden;
}

.attempt-cell .cell-label {
  font-size: var(--fs-tiny);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.attempt-cell .cell-sub {
  font-size: var(--fs-micro);
  color: var(--text-muted);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.attempt-cell .cell-emoji {
  font-size: clamp(16px, 4vw, 22px);
  line-height: 1;
}

.cell-country {
  align-items: flex-start;
  flex-direction: row;
  gap: 7px;
}

.cell-country .cell-flag {
  font-size: clamp(20px, 5vw, 26px);
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3));
}

.cell-country .cell-name-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cell-country .cell-label {
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  font-weight: 800;
  font-size: var(--fs-small);
}

/* Cell color states */
.cell-correct { background: rgba(52, 211, 153, 0.12); box-shadow: inset 0 0 8px rgba(52, 211, 153, 0.06); }
.cell-close   { background: rgba(251, 191, 36, 0.12); box-shadow: inset 0 0 8px rgba(251, 191, 36, 0.06); }
.cell-wrong   { background: rgba(251, 113, 133, 0.06); }


/* ───────────────────────────────────────────────────────────
   16. HINT CHIPS — Progressive hint system
   Unlocks: guess 1=blue, 2=orange, 3=green,
            4=purple, 5=pink, 6=red+warning
   ─────────────────────────────────────────────────────────── */
.hint-chips-row {
  grid-column: 1 / -1;       /* span all columns */
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 0 2px;
  margin-top: 2px;
  border-top: 1px solid rgba(168, 85, 247, 0.08);
}

.hint-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: var(--r-full);
  font-size: var(--fs-tiny);
  font-weight: 700;
  line-height: 1.3;
  white-space: normal;        /* allow wrapping long hints */
  word-break: break-word;
  box-shadow: var(--sh-sm);
  animation: chipPop 0.35s var(--t-bounce) forwards;
  position: relative;
  overflow: hidden;
}

/* Candy shine on chips */
.hint-chip::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
  pointer-events: none;
}

@keyframes chipPop {
  0%   { opacity: 0; transform: scale(0.7); }
  70%  { transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}

/* Hint type colors */
.hint-chip.hint-blue     { background: rgba(96, 165, 250, 0.15);  color: #60A5FA; border: 1px solid rgba(96, 165, 250, 0.3); }
.hint-chip.hint-orange   { background: rgba(251, 146, 60, 0.15);  color: #FB923C; border: 1px solid rgba(251, 146, 60, 0.3); }
.hint-chip.hint-green    { background: rgba(52, 211, 153, 0.15);  color: #34D399; border: 1px solid rgba(52, 211, 153, 0.3); }
.hint-chip.hint-purple   { background: rgba(168, 85, 247, 0.15);  color: #A855F7; border: 1px solid rgba(168, 85, 247, 0.3); }
.hint-chip.hint-pink     { background: rgba(244, 114, 182, 0.15); color: #F472B6; border: 1px solid rgba(244, 114, 182, 0.3); }
.hint-chip.hint-gold     { background: rgba(251, 191, 36, 0.15);  color: #FBBF24; border: 1px solid rgba(251, 191, 36, 0.3); }
.hint-chip.hint-red      { background: rgba(251, 113, 133, 0.15); color: #FB7185; border: 1px solid rgba(251, 113, 133, 0.3); }
.hint-chip.hint-distance { background: rgba(34, 211, 238, 0.12);  color: #22D3EE; border: 1px solid rgba(34, 211, 238, 0.25); }

/* Pulsing last-chance warning */
.hint-chip.hint-warning {
  background: rgba(251, 113, 133, 0.2);
  color: #FCA5A5;
  border: 1.5px solid rgba(251, 113, 133, 0.5);
  font-weight: 900;
  animation: chipPop 0.35s var(--t-bounce) forwards, warningPulse 1.5s ease-in-out infinite 0.4s;
}

@keyframes warningPulse {
  0%, 100% { box-shadow: var(--sh-sm); }
  50%       { box-shadow: var(--sh-glow-red); }
}


/* ───────────────────────────────────────────────────────────
   17. GAME OVER BANNER
   Lives INSIDE #game-area so it scrolls into view
   ─────────────────────────────────────────────────────────── */
#game-over-banner {
  padding: var(--sp-sm);
  margin-top: var(--sp-md);
  display: none;
}

#game-over-banner[hidden] { display: none; }

#game-over-banner.visible {
  display: block;
  animation: bannerSlideUp 0.6s var(--t-spring) forwards;
}

@keyframes bannerSlideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.game-over-inner {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: var(--sp-lg);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
  background: linear-gradient(155deg, rgba(18, 18, 61, 0.96), rgba(26, 26, 78, 0.92), rgba(40, 18, 60, 0.88));
  border: 1.5px solid rgba(168, 85, 247, 0.25);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg), var(--sh-glow-purple);
}

.game-over-won[hidden],
.game-over-lost[hidden] { display: none; }

.game-over-emoji {
  font-size: clamp(44px, 12vw, 64px);
  margin-bottom: var(--sp-xs);
  animation: emojiPop 0.6s var(--t-bounce) forwards;
}

@keyframes emojiPop {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.game-over-title {
  font-size: var(--fs-h3);
  font-weight: 900;
  background: var(--grad-cosmic);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.game-over-subtitle { font-size: var(--fs-body); color: var(--text-secondary); line-height: 1.5; }

.game-over-answer-name {
  color: var(--game-gold);
  font-size: clamp(20px, 5vw, 30px);
  font-weight: 900;
  display: inline-block;
  margin-top: 4px;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
  animation: goldPulse 2s ease-in-out infinite alternate;
}

@keyframes goldPulse {
  0%   { text-shadow: 0 0 20px rgba(255, 215, 0, 0.4); }
  100% { text-shadow: 0 0 30px rgba(255, 215, 0, 0.6); }
}

.game-over-streak {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 20px;
  background: rgba(255, 215, 0, 0.08);
  border: 1.5px solid rgba(255, 215, 0, 0.25);
  border-radius: var(--r-full);
  font-size: var(--fs-body); font-weight: 700;
}

#game-over-streak-count { color: var(--game-gold); font-weight: 900; text-shadow: 0 0 8px rgba(255, 215, 0, 0.4); }

.game-over-actions { display: flex; gap: var(--sp-sm); width: 100%; max-width: 360px; }
.game-over-actions .btn-primary,
.game-over-actions .btn-secondary { flex: 1; padding: 13px 16px; }

.btn-share { background: var(--grad-candy-green) !important; }
.btn-share:hover { box-shadow: var(--sh-glow-green), 0 6px 0 rgba(0, 0, 0, 0.12) !important; }

.next-game-timer { display: flex; align-items: center; gap: var(--sp-xs); font-size: var(--fs-small); color: var(--text-muted); }
.timer-value { color: var(--game-gold); font-weight: 800; font-variant-numeric: tabular-nums; font-size: clamp(14px, 3vw, 17px); }


/* ───────────────────────────────────────────────────────────
   18. DESKTOP SIDEBAR
   ─────────────────────────────────────────────────────────── */
#desktop-sidebar { display: none; }

.sidebar-card { padding: var(--sp-md); margin-bottom: var(--sp-sm); }
.sidebar-title { font-size: var(--fs-tiny); font-weight: 900; color: var(--candy-purple); text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: var(--sp-sm); }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-sm); }

.stat-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: var(--sp-sm);
  background: rgba(168, 85, 247, 0.05);
  border-radius: var(--r-md);
  border: 1px solid rgba(168, 85, 247, 0.1);
  transition: all var(--t-fast);
}

.stat-item:hover { border-color: rgba(168, 85, 247, 0.25); transform: scale(1.03); }
.stat-value { font-size: clamp(22px, 4vw, 32px); font-weight: 900; color: var(--game-gold); text-shadow: 0 0 10px rgba(255, 215, 0, 0.25); }
.stat-label { font-size: var(--fs-tiny); color: var(--text-muted); font-weight: 700; }

.guess-distribution { display: flex; flex-direction: column; gap: 6px; }
.dist-row { display: flex; align-items: center; gap: var(--sp-xs); }
.dist-label { font-size: var(--fs-small); font-weight: 800; color: var(--text-muted); width: 16px; text-align: right; flex-shrink: 0; }

.dist-bar-wrap { flex: 1; height: 26px; background: var(--bg-secondary); border-radius: var(--r-sm); overflow: hidden; box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2); }

.dist-bar {
  height: 100%;
  background: var(--grad-purple);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 8px; min-width: 26px;
  transition: width 0.6s ease;
  position: relative;
}

.dist-bar span { font-size: var(--fs-tiny); font-weight: 800; color: var(--text-primary); position: relative; z-index: 1; }
.dist-bar.highlight { background: var(--grad-candy-green); box-shadow: var(--sh-glow-green); }

.sidebar-links { display: flex; flex-direction: column; gap: 4px; }

.sidebar-link {
  display: flex; align-items: center; gap: var(--sp-sm);
  padding: 12px var(--sp-sm);
  border-radius: var(--r-sm);
  font-size: var(--fs-small); font-weight: 700;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--t-fast);
}

.sidebar-link:hover { background: rgba(168, 85, 247, 0.08); color: var(--text-primary); transform: translateX(4px); }


/* ───────────────────────────────────────────────────────────
   19. CONFETTI
   ─────────────────────────────────────────────────────────── */
.confetti-container {
  position: fixed;
  inset: 0;
  z-index: 299;
  pointer-events: none;
  overflow: hidden;
}


/* ───────────────────────────────────────────────────────────
   20. SHAKE ANIMATION (invalid input)
   ─────────────────────────────────────────────────────────── */
.shake {
  animation: shakeIt 0.5s ease !important;
}

@keyframes shakeIt {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-6px); }
  30%, 70% { transform: translateX(6px); }
}


/* ───────────────────────────────────────────────────────────
   21. RESPONSIVE — TABLET 768px+
   ─────────────────────────────────────────────────────────── */
@media (min-width: 768px) {
  .header-back-text { display: inline; }
  .map-section { height: var(--map-h-tablet); }
  #game-area { padding: var(--sp-md); }
  .guess-input { min-height: 56px; }
  .btn-guess { min-width: 100px; padding: 14px 26px; }
  .attempt-row { padding: var(--sp-sm); min-height: 62px; }
  .attempt-cell .cell-label { font-size: var(--fs-small); }
  .attempt-cell .cell-emoji { font-size: 24px; }
  .cell-country .cell-flag { font-size: 28px; }
  .cell-country .cell-label { font-size: var(--fs-body); }
  .modal { max-width: 520px; padding: var(--sp-lg); }
  .hint-chip { padding: 6px 14px; font-size: var(--fs-small); }
}


/* ───────────────────────────────────────────────────────────
   22. RESPONSIVE — DESKTOP 1280px+
   Grid layout with sidebar
   ─────────────────────────────────────────────────────────── */
@media (min-width: 1280px) {
  #game-wrapper {
    display: grid;
    grid-template-columns: 1fr var(--sidebar-w);
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas:
      "header  header"
      "news    news"
      "map     sidebar"
      "game    sidebar";
    overflow: hidden;
  }

  #game-header  { grid-area: header; padding: 0 var(--sp-md); }
  #news-fact    { grid-area: news; padding: 10px var(--sp-md); }

  .map-section  {
    grid-area: map;
    height: var(--map-h-desktop);
    border-right: 1px solid rgba(168, 85, 247, 0.08);
  }

  #game-area {
    grid-area: game;
    padding: var(--sp-md);
    padding-bottom: var(--sp-lg);
    border-right: 1px solid rgba(168, 85, 247, 0.08);
    max-width: none;
    overflow-y: auto; /* still scrollable on desktop */
  }

  #desktop-sidebar {
    grid-area: sidebar;
    display: flex;
    flex-direction: column;
    padding: var(--sp-md);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .attempt-row      { grid-template-columns: 1.8fr 1fr 0.6fr 0.6fr 1fr; }
  .attempt-headers  { grid-template-columns: 1.8fr 1fr 0.6fr 0.6fr 1fr; }
}


/* ───────────────────────────────────────────────────────────
   23. LANDSCAPE MOBILE
   ─────────────────────────────────────────────────────────── */
@media (max-width: 767px) and (orientation: landscape) {
  :root { --header-h: 46px; }
  .map-section { height: 30vh; }
  .game-over-inner { padding: var(--sp-md); }
  .game-over-emoji { font-size: 36px; }
}


/* ───────────────────────────────────────────────────────────
   24. SMALL MOBILE 375px and below
   ─────────────────────────────────────────────────────────── */
@media (max-width: 374px) {
  .header-title  { font-size: 13px; gap: 4px; }
  .header-globe  { font-size: 13px; }
  .streak-badge  { padding: 4px 8px; font-size: var(--fs-micro); min-height: 30px; }
  .streak-fire   { font-size: 13px; }
  .btn-guess     { min-width: 60px; padding: 10px 12px; font-size: var(--fs-small); }
  .guess-input   { padding: 10px 32px 10px 34px; min-height: 46px; }
  .attempt-row   { grid-template-columns: 1.3fr 0.9fr 0.5fr 0.5fr 0.9fr; gap: 2px; padding: 4px 6px; min-height: 48px; }
  .attempt-cell  { padding: 4px 2px; min-height: 38px; }
  .attempt-cell .cell-label { font-size: 10px; }
  .attempt-cell .cell-emoji { font-size: 15px; }
  .cell-country .cell-flag  { font-size: 18px; }
  .hint-chip     { padding: 4px 8px; font-size: var(--fs-micro); gap: 3px; }
  .game-over-actions { flex-direction: column; }
}

/* Very tiny (320px) */
@media (max-width: 320px) {
  #news-fact { display: none; }
  .attempt-headers { display: none; }
}


/* ───────────────────────────────────────────────────────────
   25. iOS SAFE AREAS
   ─────────────────────────────────────────────────────────── */
@supports (padding: max(0px)) {
  #game-header {
    padding-left:  max(var(--sp-sm), env(safe-area-inset-left));
    padding-right: max(var(--sp-sm), env(safe-area-inset-right));
    padding-top:   env(safe-area-inset-top, 0px);
  }

  #game-area {
    padding-left:   max(var(--sp-sm), env(safe-area-inset-left));
    padding-right:  max(var(--sp-sm), env(safe-area-inset-right));
    padding-bottom: max(var(--sp-xl), calc(env(safe-area-inset-bottom, 0px) + var(--sp-lg)));
  }

  #toast-container {
    top: calc(var(--header-h) + env(safe-area-inset-top, 0px) + var(--sp-xs));
  }
}


/* ───────────────────────────────────────────────────────────
   26. REDUCED MOTION
   ─────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* ───────────────────────────────────────────────────────────
   27. RESULT / COUNTRY PAGE
   ─────────────────────────────────────────────────────────── */
.result-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--sp-md);
  padding-top: var(--sp-xl);
}

.result-card {
  width: 100%;
  max-width: 460px;
  padding: var(--sp-lg);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-md);
}

.result-emoji-grid {
  font-family: monospace;
  font-size: clamp(18px, 4vw, 24px);
  line-height: 2;
  letter-spacing: 6px;
  padding: var(--sp-md);
  background: var(--bg-secondary);
  border-radius: var(--r-md);
  border: 1.5px solid var(--border-candy);
  width: 100%;
  text-align: center;
}
/* ───────────────────────────────────────────────────────────
   28. MOBILE BOTTOM NAV — Explore links visible on mobile
   ─────────────────────────────────────────────────────────── */
.mobile-bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 4px;
  padding: 10px var(--sp-sm);
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--grad-header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(168, 85, 247, 0.15);
  flex-shrink: 0;
  width: 100%;
}

.mobile-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  border-radius: var(--r-md);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--t-fast);
  min-width: 56px;
  text-align: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-link:hover,
.mobile-nav-link:active {
  color: var(--text-primary);
  background: rgba(168, 85, 247, 0.1);
}

.mobile-nav-link.active {
  color: var(--candy-purple);
  background: rgba(168, 85, 247, 0.08);
}

.mobile-nav-icon {
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.mobile-nav-label {
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

/* Hide on desktop (sidebar has links instead) */
@media (min-width: 1280px) {
  .mobile-bottom-nav {
    display: none;
  }
}


/* ───────────────────────────────────────────────────────────
   29. NEWS BANNER — Enhanced with rotating fun facts
   ─────────────────────────────────────────────────────────── */
#news-fact {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 10px var(--sp-sm);
  padding-left: calc(var(--sp-sm) + 4px);
  background: linear-gradient(
    90deg,
    rgba(168, 85, 247, 0.08),
    rgba(244, 114, 182, 0.04),
    rgba(34, 211, 238, 0.06),
    rgba(251, 191, 36, 0.04)
  );
  border-bottom: 1px solid rgba(168, 85, 247, 0.15);
  font-size: var(--fs-small);
  color: var(--text-secondary);
  line-height: 1.5;
  flex-shrink: 0;
  min-height: 46px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: background 0.3s ease;
}

#news-fact:hover {
  background: linear-gradient(
    90deg,
    rgba(168, 85, 247, 0.12),
    rgba(244, 114, 182, 0.06),
    rgba(34, 211, 238, 0.08),
    rgba(251, 191, 36, 0.06)
  );
}

/* Left accent bar */
#news-fact::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--grad-cosmic);
  border-radius: 0 var(--r-full) var(--r-full) 0;
}

/* Tap hint text */
.news-tap-hint {
  font-size: 9px;
  color: var(--text-muted);
  opacity: 0.6;
  margin-left: 4px;
  white-space: nowrap;
}


/* ───────────────────────────────────────────────────────────
   30. FUN FACT CARD — Shows on tap of news banner
   ─────────────────────────────────────────────────────────── */
.fun-fact-popup {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-game-over);
  padding: var(--sp-md);
  padding-bottom: calc(var(--sp-md) + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(
    180deg,
    rgba(18, 18, 61, 0.98),
    rgba(10, 10, 46, 0.99)
  );
  border-top: 1.5px solid rgba(168, 85, 247, 0.25);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 50vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.fun-fact-popup.visible {
  transform: translateY(0);
}

.fun-fact-inner {
  max-width: var(--max-content);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.fun-fact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fun-fact-title {
  font-size: var(--fs-body);
  font-weight: 900;
  color: var(--candy-purple);
  display: flex;
  align-items: center;
  gap: 8px;
}

.fun-fact-close {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-full);
  background: var(--bg-secondary);
  border: 1px solid var(--border-candy);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  transition: all var(--t-fast);
}

.fun-fact-close:hover {
  background: var(--candy-red);
  color: #fff;
}

.fun-fact-text {
  font-size: var(--fs-body);
  color: var(--text-secondary);
  line-height: 1.65;
  padding: var(--sp-sm);
  background: rgba(168, 85, 247, 0.04);
  border-radius: var(--r-md);
  border: 1px solid rgba(168, 85, 247, 0.1);
}

.fun-fact-joke {
  font-size: var(--fs-small);
  color: var(--candy-yellow);
  font-weight: 700;
  padding: var(--sp-sm);
  background: rgba(251, 191, 36, 0.06);
  border-radius: var(--r-md);
  border: 1px solid rgba(251, 191, 36, 0.15);
  text-align: center;
}

.fun-fact-source {
  font-size: var(--fs-micro);
  color: var(--text-muted);
  text-align: center;
  opacity: 0.7;
}
