/* ═══════════════════════════════════════════════════════════════
   WORDS OF WONDERS — Telegram Mini App
   Mobile-first, pure CSS, vendor-prefixed for old WebKit/Safari
═══════════════════════════════════════════════════════════════ */

/* ─── RESET & ROOT ─────────────────────────────────────────── */
*, *::before, *::after {
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
  margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
      -ms-user-select: none;
          user-select: none;
}

:root {
  --clr-gold:      #FFD700;
  --clr-gold-dark: #E6A800;
  --clr-white:     #FFFFFF;
  --clr-text:      rgba(255,255,255,0.95);
  --clr-text-dim:  rgba(255,255,255,0.55);
  --clr-cell-bg:   rgba(255,255,255,0.12);
  --clr-cell-border: rgba(255,255,255,0.30);
  --clr-cell-reveal: rgba(255,255,255,0.92);
  --clr-letter:    #1a1a2e;
  --clr-disk-bg:   rgba(255,255,255,0.08);
  --clr-disk-ring: rgba(255,255,255,0.20);
  --clr-btn-bg:    rgba(255,255,255,0.15);
  --clr-btn-hover: rgba(255,255,255,0.25);
  --radius-cell:   6px;
  --radius-btn:    50%;
  --header-h:      52px;
  --preview-h:     44px;
  --bonus-h:       32px;
  --disk-h:        42vh;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: #0d0d1a;
}

/* ─── BIOME BACKGROUNDS ─────────────────────────────────────── */
#biome-bg {
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center;
  -webkit-transition: background 1.2s ease;
          transition: background 1.2s ease;
  will-change: background;
}

#biome-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 20, 0.62);
  -webkit-backdrop-filter: blur(0px);
          backdrop-filter: blur(0px);
  pointer-events: none;
}

/* Biome gradient themes */
.biome-paris {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(120,180,255,0.35) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(80,60,200,0.40) 0%, transparent 60%),
    linear-gradient(160deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
}
.biome-china {
  background:
    radial-gradient(ellipse at 70% 15%, rgba(255,120,80,0.40) 0%, transparent 55%),
    radial-gradient(ellipse at 20% 85%, rgba(200,40,40,0.35) 0%, transparent 55%),
    linear-gradient(160deg, #1a0500 0%, #4a0a00 50%, #2d1200 100%);
}
.biome-egypt {
  background:
    radial-gradient(ellipse at 50% 10%, rgba(255,200,80,0.45) 0%, transparent 60%),
    radial-gradient(ellipse at 10% 90%, rgba(180,100,20,0.35) 0%, transparent 55%),
    linear-gradient(160deg, #1a1000 0%, #3d2800 50%, #241500 100%);
}
.biome-moscow {
  background:
    radial-gradient(ellipse at 60% 15%, rgba(200,30,30,0.40) 0%, transparent 55%),
    radial-gradient(ellipse at 20% 80%, rgba(100,10,10,0.40) 0%, transparent 55%),
    linear-gradient(160deg, #1a0000 0%, #3d0505 50%, #200000 100%);
}
.biome-baikal {
  background:
    radial-gradient(ellipse at 40% 20%, rgba(0,200,255,0.35) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(0,80,180,0.40) 0%, transparent 60%),
    linear-gradient(160deg, #000d1a 0%, #003060 50%, #001230 100%);
}
.biome-volga {
  background:
    radial-gradient(ellipse at 30% 30%, rgba(0,200,120,0.30) 0%, transparent 55%),
    radial-gradient(ellipse at 70% 70%, rgba(0,100,200,0.35) 0%, transparent 55%),
    linear-gradient(160deg, #001a0d 0%, #00301a 50%, #001510 100%);
}
.biome-kyiv {
  background:
    radial-gradient(ellipse at 40% 20%, rgba(255,220,0,0.35) 0%, transparent 55%),
    radial-gradient(ellipse at 60% 80%, rgba(0,80,200,0.35) 0%, transparent 55%),
    linear-gradient(160deg, #0a0a1a 0%, #1a1a3d 50%, #0d0d28 100%);
}
.biome-carpathians {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(60,180,60,0.35) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 80%, rgba(100,60,200,0.35) 0%, transparent 55%),
    linear-gradient(160deg, #050d05 0%, #0d200d 50%, #081208 100%);
}
.biome-dnieper {
  background:
    radial-gradient(ellipse at 50% 15%, rgba(0,160,220,0.35) 0%, transparent 55%),
    radial-gradient(ellipse at 20% 80%, rgba(0,40,120,0.40) 0%, transparent 55%),
    linear-gradient(160deg, #000a14 0%, #001428 50%, #000c1e 100%);
}
.biome-greece {
  background:
    radial-gradient(ellipse at 50% 10%, rgba(80,160,255,0.40) 0%, transparent 55%),
    radial-gradient(ellipse at 20% 80%, rgba(255,255,255,0.10) 0%, transparent 55%),
    linear-gradient(160deg, #000d28 0%, #001840 50%, #001230 100%);
}
.biome-italy {
  background:
    radial-gradient(ellipse at 40% 15%, rgba(220,60,60,0.35) 0%, transparent 55%),
    radial-gradient(ellipse at 70% 70%, rgba(80,220,80,0.20) 0%, transparent 55%),
    linear-gradient(160deg, #120005 0%, #250010 50%, #0a0005 100%);
}
.biome-japan {
  background:
    radial-gradient(ellipse at 60% 20%, rgba(255,120,160,0.40) 0%, transparent 55%),
    radial-gradient(ellipse at 20% 70%, rgba(255,60,80,0.20) 0%, transparent 55%),
    linear-gradient(160deg, #120008 0%, #28000f 50%, #0c0006 100%);
}
.biome-india {
  background:
    radial-gradient(ellipse at 50% 10%, rgba(255,160,0,0.45) 0%, transparent 55%),
    radial-gradient(ellipse at 20% 80%, rgba(255,100,0,0.25) 0%, transparent 55%),
    linear-gradient(160deg, #140800 0%, #2a1000 50%, #0e0500 100%);
}
.biome-mexico {
  background:
    radial-gradient(ellipse at 30% 15%, rgba(220,180,0,0.45) 0%, transparent 55%),
    radial-gradient(ellipse at 70% 75%, rgba(200,60,0,0.30) 0%, transparent 55%),
    linear-gradient(160deg, #141000 0%, #281800 50%, #100800 100%);
}
.biome-peru {
  background:
    radial-gradient(ellipse at 40% 10%, rgba(80,220,120,0.35) 0%, transparent 55%),
    radial-gradient(ellipse at 70% 70%, rgba(0,160,80,0.25) 0%, transparent 55%),
    linear-gradient(160deg, #000d08 0%, #001a10 50%, #000c06 100%);
}
.biome-turkey {
  background:
    radial-gradient(ellipse at 60% 15%, rgba(220,40,40,0.40) 0%, transparent 55%),
    radial-gradient(ellipse at 20% 80%, rgba(255,200,0,0.20) 0%, transparent 55%),
    linear-gradient(160deg, #1a0000 0%, #320000 50%, #100000 100%);
}

/* ─── APP LAYOUT ────────────────────────────────────────────── */
#app {
  position: relative;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
          flex-direction: column;
  width: 100%;
  height: 100%;
  height: 100svh; /* safe viewport height */
  z-index: 1;
  overflow: hidden;
}

/* ─── HEADER ────────────────────────────────────────────────── */
#header {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  -webkit-justify-content: space-between;
          justify-content: space-between;
  padding: 8px 12px;
  height: var(--header-h);
  background: rgba(0,0,0,0.25);
  -webkit-backdrop-filter: blur(12px);
          backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  -webkit-flex-shrink: 0;
          flex-shrink: 0;
  gap: 8px;
}

#header-left {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  gap: 8px;
  min-width: 0;
}

#header-right {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  gap: 8px;
  -webkit-flex-shrink: 0;
          flex-shrink: 0;
}

#level-info {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
          flex-direction: column;
  min-width: 0;
}

#level-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--clr-gold);
  letter-spacing: 0.5px;
  line-height: 1;
}

#biome-name {
  font-size: 11px;
  color: var(--clr-text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  max-width: 140px;
}

.icon-btn {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  -webkit-justify-content: center;
          justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--clr-btn-bg);
  color: var(--clr-white);
  cursor: pointer;
  -webkit-transition: background 0.15s, -webkit-transform 0.1s;
          transition: background 0.15s, transform 0.1s;
  -webkit-flex-shrink: 0;
          flex-shrink: 0;
  padding: 0;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:active { background: var(--clr-btn-hover); -webkit-transform: scale(0.9); transform: scale(0.9); }

#lang-btn { font-size: 20px; background: transparent; }

/* ── Back-to-menu button in game header ────────────────────── */
.back-menu-btn {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 20px;
  padding: 6px 12px 6px 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.back-menu-btn svg { width: 16px; height: 16px; stroke: #fff; }
.back-menu-btn:active { background: rgba(255,255,255,0.25); }

/* ── Buy coins button ────────────────────────────────────────── */
.buy-coins-btn {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  gap: 4px;
  background: rgba(255,215,0,0.15);
  border: 1px solid rgba(255,215,0,0.40);
  border-radius: 20px;
  padding: 4px 10px 4px 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.buy-coins-btn:active { background: rgba(255,215,0,0.30); }
.coin-svg { width: 18px; height: 18px; -webkit-flex-shrink: 0; flex-shrink: 0; }
#coins-count {
  font-size: 14px;
  font-weight: 700;
  color: var(--clr-gold);
  min-width: 24px;
}
.plus-star {
  font-size: 11px;
  opacity: 0.85;
  color: var(--clr-gold);
}

#hint-btn svg { stroke: var(--clr-gold); }

/* ─── CROSSWORD AREA ────────────────────────────────────────── */
#crossword-area {
  -webkit-flex: 1 1 0;
          flex: 1 1 0;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  -webkit-justify-content: center;
          justify-content: center;
  padding: 10px 8px 4px;
  overflow: hidden;
  min-height: 0;
}

#crossword-scroll-inner {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  -webkit-justify-content: center;
          justify-content: center;
  width: 100%;
  height: 100%;
}

#crossword-grid {
  display: grid;
  gap: 3px;
  /* column/row count & cell size set by JS via CSS custom properties */
}

/* ─── GRID CELLS ────────────────────────────────────────────── */
.cell {
  width: var(--cs, 40px);
  height: var(--cs, 40px);
  border-radius: var(--radius-cell);
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  -webkit-justify-content: center;
          justify-content: center;
  font-weight: 800;
  font-size: calc(var(--cs, 40px) * 0.44);
  line-height: 1;
  -webkit-transition: -webkit-transform 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
          transition: transform 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
  -webkit-perspective: 400px;
          perspective: 400px;
}

.cell-empty {
  /* transparent placeholder, keeps grid spacing */
  background: transparent;
  border: none;
  pointer-events: none;
}

.cell-hidden {
  background: var(--clr-cell-bg);
  border: 1.5px solid var(--clr-cell-border);
  color: transparent;
  -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
          box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

.cell-revealed {
  background: var(--clr-cell-reveal);
  border: 1.5px solid rgba(255,255,255,0.6);
  color: var(--clr-letter);
  -webkit-box-shadow: 0 2px 8px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.8);
          box-shadow: 0 2px 8px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.8);
  -webkit-animation: cellReveal 0.45s cubic-bezier(0.34,1.56,0.64,1);
          animation: cellReveal 0.45s cubic-bezier(0.34,1.56,0.64,1);
}

@-webkit-keyframes cellReveal {
  0%   { -webkit-transform: rotateY(90deg) scale(0.7); transform: rotateY(90deg) scale(0.7); opacity: 0; }
  60%  { -webkit-transform: rotateY(-8deg) scale(1.08); transform: rotateY(-8deg) scale(1.08); opacity: 1; }
  100% { -webkit-transform: rotateY(0deg) scale(1); transform: rotateY(0deg) scale(1); opacity: 1; }
}
@keyframes cellReveal {
  0%   { -webkit-transform: rotateY(90deg) scale(0.7); transform: rotateY(90deg) scale(0.7); opacity: 0; }
  60%  { -webkit-transform: rotateY(-8deg) scale(1.08); transform: rotateY(-8deg) scale(1.08); opacity: 1; }
  100% { -webkit-transform: rotateY(0deg) scale(1); transform: rotateY(0deg) scale(1); opacity: 1; }
}

/* stagger reveal animation by word-letter index */
.cell-revealed[data-idx="1"] { -webkit-animation-delay: 0.06s; animation-delay: 0.06s; }
.cell-revealed[data-idx="2"] { -webkit-animation-delay: 0.12s; animation-delay: 0.12s; }
.cell-revealed[data-idx="3"] { -webkit-animation-delay: 0.18s; animation-delay: 0.18s; }
.cell-revealed[data-idx="4"] { -webkit-animation-delay: 0.24s; animation-delay: 0.24s; }
.cell-revealed[data-idx="5"] { -webkit-animation-delay: 0.30s; animation-delay: 0.30s; }
.cell-revealed[data-idx="6"] { -webkit-animation-delay: 0.36s; animation-delay: 0.36s; }

/* ─── WORD PREVIEW BAR ──────────────────────────────────────── */
#word-preview-bar {
  -webkit-flex-shrink: 0;
          flex-shrink: 0;
  height: var(--preview-h);
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  -webkit-justify-content: center;
          justify-content: center;
  padding: 0 16px;
  gap: 4px;
}

#word-tiles-row {
  display: -webkit-flex;
  display: flex;
  gap: 4px;
  -webkit-align-items: center;
          align-items: center;
  -webkit-justify-content: center;
          justify-content: center;
  min-height: 32px;
}

.word-tile {
  width: 28px; height: 28px;
  border-radius: 5px;
  background: rgba(255,255,255,0.18);
  border: 1.5px solid rgba(255,255,255,0.40);
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  -webkit-justify-content: center;
          justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: var(--clr-white);
  -webkit-animation: tileAppear 0.15s ease;
          animation: tileAppear 0.15s ease;
}

@-webkit-keyframes tileAppear {
  from { -webkit-transform: scale(0); transform: scale(0); opacity: 0; }
  to   { -webkit-transform: scale(1); transform: scale(1); opacity: 1; }
}
@keyframes tileAppear {
  from { -webkit-transform: scale(0); transform: scale(0); opacity: 0; }
  to   { -webkit-transform: scale(1); transform: scale(1); opacity: 1; }
}

/* ─── BONUS STRIP ───────────────────────────────────────────── */
#bonus-strip {
  -webkit-flex-shrink: 0;
          flex-shrink: 0;
  height: var(--bonus-h);
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  gap: 8px;
  padding: 0 14px;
  overflow: hidden;
}

#bonus-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--clr-gold);
  letter-spacing: 0.5px;
  -webkit-flex-shrink: 0;
          flex-shrink: 0;
}

#bonus-words-list {
  display: -webkit-flex;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#bonus-words-list::-webkit-scrollbar { display: none; }

.bonus-word-chip {
  background: rgba(255,215,0,0.18);
  border: 1px solid rgba(255,215,0,0.40);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--clr-gold);
  white-space: nowrap;
  -webkit-animation: chipPop 0.3s cubic-bezier(0.34,1.56,0.64,1);
          animation: chipPop 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

@-webkit-keyframes chipPop {
  from { -webkit-transform: scale(0) translateY(8px); transform: scale(0) translateY(8px); opacity: 0; }
  to   { -webkit-transform: scale(1) translateY(0); transform: scale(1) translateY(0); opacity: 1; }
}
@keyframes chipPop {
  from { -webkit-transform: scale(0) translateY(8px); transform: scale(0) translateY(8px); opacity: 0; }
  to   { -webkit-transform: scale(1) translateY(0); transform: scale(1) translateY(0); opacity: 1; }
}

/* ─── DISK AREA ─────────────────────────────────────────────── */
#disk-area {
  -webkit-flex-shrink: 0;
          flex-shrink: 0;
  position: relative;
  height: var(--disk-h);
  min-height: 220px;
  max-height: 340px;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  -webkit-justify-content: center;
          justify-content: center;
  padding: 8px 0 12px;
}

#line-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

#disk-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--clr-disk-ring);
  background: var(--clr-disk-bg);
  -webkit-box-shadow:
    inset 0 0 40px rgba(255,255,255,0.04),
    0 0 30px rgba(0,0,0,0.5);
          box-shadow:
    inset 0 0 40px rgba(255,255,255,0.04),
    0 0 30px rgba(0,0,0,0.5);
  z-index: 1;
  pointer-events: none;
  /* size set by JS */
}

#letter-disk {
  position: relative;
  z-index: 3;
  /* size set by JS */
}

.letter-btn {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.30);
  background: rgba(255,255,255,0.14);
  color: var(--clr-white);
  font-weight: 800;
  cursor: pointer;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  -webkit-justify-content: center;
          justify-content: center;
  -webkit-transition:
    background 0.12s,
    border-color 0.12s,
    -webkit-transform 0.12s,
    -webkit-box-shadow 0.12s;
          transition:
    background 0.12s,
    border-color 0.12s,
    transform 0.12s,
    box-shadow 0.12s;
  -webkit-box-shadow: 0 2px 8px rgba(0,0,0,0.35);
          box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  -webkit-backdrop-filter: blur(4px);
          backdrop-filter: blur(4px);
  /* size & position set by JS */
}

.letter-btn.selected {
  background: var(--clr-gold);
  border-color: var(--clr-gold-dark);
  color: #1a1000;
  -webkit-transform: scale(1.15) !important;
          transform: scale(1.15) !important;
  -webkit-box-shadow: 0 0 16px rgba(255,215,0,0.7), 0 4px 12px rgba(0,0,0,0.4);
          box-shadow: 0 0 16px rgba(255,215,0,0.7), 0 4px 12px rgba(0,0,0,0.4);
  z-index: 10;
}

.letter-btn:active {
  -webkit-transform: scale(1.08);
          transform: scale(1.08);
}

/* shake animation for wrong word */
@-webkit-keyframes diskShake {
  0%, 100% { -webkit-transform: translateX(0); transform: translateX(0); }
  15%  { -webkit-transform: translateX(-8px); transform: translateX(-8px); }
  30%  { -webkit-transform: translateX(8px);  transform: translateX(8px);  }
  45%  { -webkit-transform: translateX(-6px); transform: translateX(-6px); }
  60%  { -webkit-transform: translateX(6px);  transform: translateX(6px);  }
  75%  { -webkit-transform: translateX(-3px); transform: translateX(-3px); }
  90%  { -webkit-transform: translateX(3px);  transform: translateX(3px);  }
}
@keyframes diskShake {
  0%, 100% { -webkit-transform: translateX(0); transform: translateX(0); }
  15%  { -webkit-transform: translateX(-8px); transform: translateX(-8px); }
  30%  { -webkit-transform: translateX(8px);  transform: translateX(8px);  }
  45%  { -webkit-transform: translateX(-6px); transform: translateX(-6px); }
  60%  { -webkit-transform: translateX(6px);  transform: translateX(6px);  }
  75%  { -webkit-transform: translateX(-3px); transform: translateX(-3px); }
  90%  { -webkit-transform: translateX(3px);  transform: translateX(3px);  }
}
#letter-disk.shake {
  -webkit-animation: diskShake 0.5s ease;
          animation: diskShake 0.5s ease;
}

#shuffle-btn {
  position: absolute;
  bottom: 14px;
  right: 16px;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.20);
  background: rgba(255,255,255,0.10);
  color: var(--clr-text-dim);
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  -webkit-justify-content: center;
          justify-content: center;
  cursor: pointer;
  z-index: 4;
  -webkit-transition: background 0.15s, -webkit-transform 0.2s;
          transition: background 0.15s, transform 0.2s;
}
#shuffle-btn svg { width: 16px; height: 16px; }
#shuffle-btn:active { background: rgba(255,255,255,0.20); -webkit-transform: rotate(90deg) scale(0.9); transform: rotate(90deg) scale(0.9); }

/* ─── MODAL ─────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.7);
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: flex-end;
          align-items: flex-end;
  -webkit-justify-content: center;
          justify-content: center;
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
  -webkit-animation: overlayIn 0.2s ease;
          animation: overlayIn 0.2s ease;
}

@-webkit-keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#modal-box {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: linear-gradient(160deg, #1a1a3e, #0d0d20);
  border: 1px solid rgba(255,255,255,0.12);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding: 28px 24px 32px;
  -webkit-animation: sheetUp 0.35s cubic-bezier(0.34,1.56,0.64,1);
          animation: sheetUp 0.35s cubic-bezier(0.34,1.56,0.64,1);
  text-align: center;
}

@-webkit-keyframes sheetUp {
  from { -webkit-transform: translateY(100%); transform: translateY(100%); }
  to   { -webkit-transform: translateY(0); transform: translateY(0); }
}
@keyframes sheetUp {
  from { -webkit-transform: translateY(100%); transform: translateY(100%); }
  to   { -webkit-transform: translateY(0); transform: translateY(0); }
}

#modal-close {
  position: absolute;
  top: 12px; right: 14px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--clr-text-dim);
  border-radius: 50%;
  width: 28px; height: 28px;
  font-size: 14px;
  cursor: pointer;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: center; justify-content: center;
}

#modal-icon { font-size: 44px; margin-bottom: 12px; line-height: 1; }
#modal-title { color: var(--clr-white); font-size: 20px; font-weight: 800; margin-bottom: 8px; }
#modal-body { color: var(--clr-text-dim); font-size: 14px; line-height: 1.5; margin-bottom: 20px; }

#modal-actions {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
          flex-direction: column;
  gap: 10px;
}

.modal-btn {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  -webkit-transition: -webkit-transform 0.1s, opacity 0.1s;
          transition: transform 0.1s, opacity 0.1s;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  -webkit-justify-content: center;
          justify-content: center;
  gap: 8px;
}
.modal-btn:active { -webkit-transform: scale(0.97); transform: scale(0.97); opacity: 0.9; }

.modal-btn-gold {
  background: linear-gradient(135deg, #FFD700, #E6A800);
  color: #1a1000;
}
.modal-btn-video {
  background: linear-gradient(135deg, #7B68EE, #5B4FD4);
  color: white;
}
.modal-btn-stars {
  background: linear-gradient(135deg, #1a1a3e, #2d2d6e);
  color: var(--clr-gold);
  border: 1px solid rgba(255,215,0,0.30);
}
.modal-btn-cancel {
  background: rgba(255,255,255,0.07);
  color: var(--clr-text-dim);
}

/* ─── LEVEL COMPLETE ────────────────────────────────────────── */
#level-complete-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  -webkit-justify-content: center;
          justify-content: center;
  background: rgba(0,0,0,0.5);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
}

#fireworks-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#level-complete-card {
  position: relative;
  z-index: 1;
  background: linear-gradient(160deg, #1a1a3e, #0d0d20);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 24px;
  padding: 36px 32px;
  text-align: center;
  max-width: 320px;
  width: 88%;
  -webkit-animation: cardPop 0.5s cubic-bezier(0.34,1.56,0.64,1);
          animation: cardPop 0.5s cubic-bezier(0.34,1.56,0.64,1);
}

@-webkit-keyframes cardPop {
  from { -webkit-transform: scale(0.5); transform: scale(0.5); opacity: 0; }
  to   { -webkit-transform: scale(1); transform: scale(1); opacity: 1; }
}
@keyframes cardPop {
  from { -webkit-transform: scale(0.5); transform: scale(0.5); opacity: 0; }
  to   { -webkit-transform: scale(1); transform: scale(1); opacity: 1; }
}

#lc-stars {
  font-size: 36px;
  letter-spacing: 8px;
  color: var(--clr-gold);
  margin-bottom: 8px;
  -webkit-filter: drop-shadow(0 0 8px rgba(255,215,0,0.7));
          filter: drop-shadow(0 0 8px rgba(255,215,0,0.7));
}

#lc-title {
  font-size: 28px;
  font-weight: 900;
  color: var(--clr-white);
  margin-bottom: 6px;
  text-shadow: 0 2px 12px rgba(255,215,0,0.4);
}

#lc-biome {
  font-size: 14px;
  color: var(--clr-text-dim);
  margin-bottom: 16px;
}

#lc-bonus-label {
  font-size: 13px;
  color: var(--clr-gold);
  margin-bottom: 20px;
  min-height: 18px;
}

#next-level-btn {
  background: linear-gradient(135deg, #FFD700, #E6A800);
  color: #1a1000;
  border: none;
  border-radius: 14px;
  padding: 14px 36px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  -webkit-box-shadow: 0 4px 16px rgba(255,215,0,0.45);
          box-shadow: 0 4px 16px rgba(255,215,0,0.45);
  -webkit-transition: -webkit-transform 0.1s;
          transition: transform 0.1s;
}
#next-level-btn:active { -webkit-transform: scale(0.96); transform: scale(0.96); }

/* ─── LANGUAGE PICKER ───────────────────────────────────────── */
#lang-picker {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0,0,0,0.65);
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  -webkit-justify-content: center;
          justify-content: center;
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
}

#lang-picker-box {
  background: linear-gradient(160deg, #1a1a3e, #0d0d20);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  padding: 28px 24px;
  text-align: center;
  width: 80%;
  max-width: 300px;
  -webkit-animation: cardPop 0.35s cubic-bezier(0.34,1.56,0.64,1);
          animation: cardPop 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

#lang-picker-box h3 {
  color: var(--clr-white);
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 16px;
}

.lang-option {
  display: block;
  width: 100%;
  padding: 13px;
  margin-bottom: 8px;
  border-radius: 12px;
  border: 1.5px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
  color: var(--clr-white);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  -webkit-transition: background 0.15s, -webkit-transform 0.1s;
          transition: background 0.15s, transform 0.1s;
}
.lang-option:active { background: rgba(255,255,255,0.18); -webkit-transform: scale(0.97); transform: scale(0.97); }
.lang-option.active {
  background: rgba(255,215,0,0.20);
  border-color: rgba(255,215,0,0.50);
  color: var(--clr-gold);
}

/* ─── AD OVERLAY ────────────────────────────────────────────── */
#ad-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.85);
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  -webkit-justify-content: center;
          justify-content: center;
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
}

#ad-box {
  text-align: center;
  color: var(--clr-text-dim);
  font-size: 14px;
}

#ad-progress-ring {
  position: relative;
  width: 60px; height: 60px;
  margin: 0 auto 12px;
}
#ad-progress-ring svg { width: 60px; height: 60px; }

#ad-timer {
  position: absolute;
  inset: 0;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  -webkit-justify-content: center;
          justify-content: center;
  font-size: 20px;
  font-weight: 800;
  color: var(--clr-white);
}

/* ─── TOAST NOTIFICATION ────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  -webkit-transform: translateX(-50%) translateY(0);
          transform: translateX(-50%) translateY(0);
  z-index: 400;
  background: rgba(30,30,60,0.95);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--clr-white);
  white-space: nowrap;
  pointer-events: none;
  -webkit-box-shadow: 0 4px 16px rgba(0,0,0,0.4);
          box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  -webkit-animation: toastIn 0.3s ease;
          animation: toastIn 0.3s ease;
}
#toast.fade-out {
  -webkit-animation: toastOut 0.4s ease forwards;
          animation: toastOut 0.4s ease forwards;
}

@-webkit-keyframes toastIn {
  from { opacity: 0; -webkit-transform: translateX(-50%) translateY(16px); transform: translateX(-50%) translateY(16px); }
  to   { opacity: 1; -webkit-transform: translateX(-50%) translateY(0); transform: translateX(-50%) translateY(0); }
}
@keyframes toastIn {
  from { opacity: 0; -webkit-transform: translateX(-50%) translateY(16px); transform: translateX(-50%) translateY(16px); }
  to   { opacity: 1; -webkit-transform: translateX(-50%) translateY(0); transform: translateX(-50%) translateY(0); }
}
@-webkit-keyframes toastOut {
  to { opacity: 0; -webkit-transform: translateX(-50%) translateY(-12px); transform: translateX(-50%) translateY(-12px); }
}
@keyframes toastOut {
  to { opacity: 0; -webkit-transform: translateX(-50%) translateY(-12px); transform: translateX(-50%) translateY(-12px); }
}

/* ─── HINT GLOW ON REVEALED CELL ────────────────────────────── */
.cell-hint-glow {
  -webkit-animation: hintGlow 1.2s ease infinite alternate !important;
          animation: hintGlow 1.2s ease infinite alternate !important;
}
@-webkit-keyframes hintGlow {
  from { -webkit-box-shadow: 0 0 6px rgba(255,215,0,0.4); box-shadow: 0 0 6px rgba(255,215,0,0.4); }
  to   { -webkit-box-shadow: 0 0 18px rgba(255,215,0,0.9), 0 0 6px rgba(255,215,0,0.5); box-shadow: 0 0 18px rgba(255,215,0,0.9), 0 0 6px rgba(255,215,0,0.5); }
}
@keyframes hintGlow {
  from { -webkit-box-shadow: 0 0 6px rgba(255,215,0,0.4); box-shadow: 0 0 6px rgba(255,215,0,0.4); }
  to   { -webkit-box-shadow: 0 0 18px rgba(255,215,0,0.9), 0 0 6px rgba(255,215,0,0.5); box-shadow: 0 0 18px rgba(255,215,0,0.9), 0 0 6px rgba(255,215,0,0.5); }
}

/* ─── HIDDEN UTILITY ────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── SCROLLBAR HIDE ────────────────────────────────────────── */
::-webkit-scrollbar { display: none; }

/* ─── SAFE AREA SUPPORT (iPhone notch) ─────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #disk-area { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  #header    { padding-top: max(8px, env(safe-area-inset-top)); }
}

/* ─── VERY SMALL SCREENS (<360px width) ────────────────────── */
@media (max-height: 580px) {
  :root {
    --header-h: 44px;
    --preview-h: 36px;
    --bonus-h:  26px;
    --disk-h:   38vh;
  }
}

/* ═══════════════════════════════════════════════════════════════
   MAIN MENU — SCREEN SWAP SYSTEM
   (no z-index overlay; each screen is a full-page flex column)
═══════════════════════════════════════════════════════════════ */

/* Every app screen: full viewport flex column */
.app-screen {
  position: fixed;
  inset: 0;
  display: none;        /* hidden by default; JS shows via showScreen() */
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  /* background comes from #biome-bg + #biome-overlay behind it */
}

/* ─── SCREEN-MENU — full banner background ──────────────────── */
#screen-menu {
  display: flex;        /* visible by default — no JS needed to show menu */
  justify-content: space-between;
  padding: env(safe-area-inset-top, 16px) 20px 32px;
  gap: 0;
  /* Banner image as background, fallback to gradient */
  background-image: url('banner.png');
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}
/* Semi-transparent overlay so text stays readable over the banner */
#screen-menu::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(10,6,30,0.50)  0%,
    rgba(10,6,30,0.30) 30%,
    rgba(10,6,30,0.45) 55%,
    rgba(10,6,30,0.88) 100%
  );
  pointer-events: none;
}
/* Make all children sit above the ::before overlay */
#screen-menu > * { position: relative; z-index: 1; }

/* ─── Floating letter tiles (match the banner) ──────────────── */
.sm-float-tiles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.sm-tile {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) rotate(var(--rot));
  width: 52px; height: 52px;
  border-radius: 12px;
  background: linear-gradient(145deg, #ffe066 0%, #c8860a 100%);
  box-shadow:
    0 4px 16px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(255,255,220,0.45);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 900; color: #3a1e00;
  text-shadow: 0 1px 0 rgba(255,255,200,0.5);
  animation: tile-float 4s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes tile-float {
  0%,100% { transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) rotate(var(--rot)); }
  50%      { transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty) - 8px)) rotate(var(--rot)); }
}

/* ─── Top bar ──────────────────────────────────────────────── */
.sm-topbar {
  width: 100%;
  max-width: 420px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sm-icon-btn {
  background: rgba(0,0,0,0.35);
  border: 1.5px solid rgba(255,255,255,0.22);
  border-radius: 12px;
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
  backdrop-filter: blur(6px);
}
.sm-icon-btn:active { transform: scale(0.90); }

/* Language button with globe + flag */
.sm-lang-btn {
  width: auto;
  padding: 0 10px;
  gap: 4px;
  flex-direction: row;
}
.lang-globe {
  font-size: 17px;
  line-height: 1;
  filter: drop-shadow(0 0 3px rgba(100,200,255,0.6));
}
#sm-lang-flag {
  font-size: 16px;
  line-height: 1;
}

.sm-coins-badge {
  display: flex; align-items: center; gap: 5px;
  background: rgba(0,0,0,0.40);
  border: 1.5px solid rgba(255,215,0,0.45);
  border-radius: 20px;
  padding: 7px 14px 7px 8px;
  font-size: 15px; font-weight: 700; color: #FFD700;
  backdrop-filter: blur(6px);
}
.sm-coin-svg { width: 20px; height: 20px; flex-shrink: 0; }

/* ─── Hero — big gold title matching banner ─────────────────── */
.sm-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  justify-content: center;
  gap: 0;
  padding-bottom: 8px;
}

.sm-logo-block {
  display: flex; flex-direction: column; align-items: center;
  gap: 0;
  background: rgba(5,3,18,0.45);
  border: 1px solid rgba(255,215,0,0.18);
  border-radius: 18px;
  padding: 14px 24px 10px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.40), inset 0 1px 0 rgba(255,255,255,0.08);
}
.sm-logo-words {
  font-size: clamp(38px, 11vw, 56px);
  font-weight: 900;
  letter-spacing: 4px;
  line-height: 1;
  background: linear-gradient(180deg, #fff8c0 0%, #FFD700 40%, #c87000 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 8px rgba(200,120,0,0.70));
}
.sm-logo-of {
  font-size: 14px; font-weight: 600;
  color: rgba(255,220,120,0.80);
  letter-spacing: 6px;
  text-transform: uppercase;
  margin: 2px 0;
}
.sm-logo-wonders {
  font-size: clamp(30px, 9vw, 46px);
  font-weight: 900;
  letter-spacing: 3px;
  line-height: 1;
  background: linear-gradient(180deg, #fff8c0 0%, #FFD700 40%, #c87000 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 10px rgba(200,120,0,0.70));
}

/* ─── Player card ──────────────────────────────────────────── */
.sm-player-card {
  margin-top: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: rgba(0,0,0,0.45);
  border: 1.5px solid rgba(255,215,0,0.30);
  border-radius: 16px;
  padding: 10px 28px;
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}
.sm-player-name {
  font-size: 16px; font-weight: 700; color: #fff;
}
.sm-player-id {
  font-size: 11px; color: rgba(255,255,255,0.40); letter-spacing: 0.3px;
}
.sm-player-stats {
  display: flex; gap: 18px; margin-top: 4px;
  font-size: 14px; color: rgba(255,255,255,0.70);
}
.sm-player-stats b { color: #FFD700; }

/* ─── CTA buttons ──────────────────────────────────────────── */
.sm-buttons {
  display: flex; flex-direction: column; gap: 11px;
  width: 100%; max-width: 320px;
  flex-shrink: 0;
}
.sm-btn-row {
  display: flex; gap: 11px;
}
.sm-btn-row .sm-btn { flex: 1; }

.sm-btn {
  padding: 16px 20px;
  border: none; border-radius: 16px;
  font-size: 17px; font-weight: 700;
  font-family: var(--font);
  cursor: pointer; letter-spacing: 0.2px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.sm-btn:active { transform: scale(0.95); }

.sm-btn-play {
  background: linear-gradient(135deg, #ffe566 0%, #FF8C00 100%);
  color: #1a0800;
  box-shadow: 0 6px 28px rgba(255,190,0,0.50), 0 2px 0 rgba(255,255,180,0.20) inset;
  text-shadow: 0 1px 0 rgba(255,255,200,0.30);
}
.sm-btn-play:active { box-shadow: 0 2px 10px rgba(255,190,0,0.30); }

.sm-btn-secondary {
  background: rgba(0,0,0,0.40);
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.28);
  font-size: 15px;
  backdrop-filter: blur(6px);
}

/* small logo-icon (used in sub-screens) */
.sm-logo-icon {
  width: 54px; height: 54px; border-radius: 14px;
  background: linear-gradient(135deg, #FFD700 0%, #FF8C00 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 900; color: #0d0d1a;
  box-shadow: 0 6px 20px rgba(255,200,0,0.40);
  margin-bottom: 12px; flex-shrink: 0; user-select: none;
}

/* ─── Play choice / generic sub-screens ────────────────────── */
#screen-play-choice,
#screen-leaderboard {
  background:
    radial-gradient(ellipse at 25% 0%,  rgba(100,170,255,0.18) 0%, transparent 55%),
    linear-gradient(175deg, #0b1332 0%, #0d0d1a 60%, #110a28 100%);
  padding: env(safe-area-inset-top, 12px) 20px 28px;
  justify-content: flex-start;
  overflow: hidden;
}

/* Missions screen gets its own treasure-map background */
#screen-missions {
  background:
    radial-gradient(ellipse at 15% 20%, rgba(139,90,43,0.22) 0%, transparent 45%),
    radial-gradient(ellipse at 85% 60%, rgba(60,120,60,0.18) 0%, transparent 45%),
    radial-gradient(ellipse at 50% 90%, rgba(100,60,20,0.18) 0%, transparent 50%),
    linear-gradient(175deg, #060e08 0%, #07100a 50%, #050d07 100%);
  padding: env(safe-area-inset-top, 12px) 0 0;
  justify-content: flex-start;
}
#screen-missions .sc-header {
  padding: 0 16px;
  width: 100%;
  max-width: none;
  margin-bottom: 8px;
  box-sizing: border-box;
}

/* ─── TREASURE MAP ──────────────────────────────────────────── */
#missions-list {
  /* override sc-scroll-list for treasure map */
  display: block !important;
  flex-direction: unset !important;
  gap: 0 !important;
  padding: 0 !important;
  max-width: none !important;
}

.mission-map {
  position: relative;
  width: 100%;
  overflow: visible;
}

/* rank banner at top of map */
.map-rank-banner {
  text-align: center;
  padding: 10px 20px 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: rgba(255,215,0,0.80);
  text-shadow: 0 0 12px rgba(255,215,0,0.45);
  flex-shrink: 0;
}

/* mission node wrapper */
.mission-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  width: 82px;
  transition: transform 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.mission-node:not(.locked):active { transform: translateX(-50%) scale(0.93) !important; }
.mission-node.locked { opacity: 0.42; cursor: default; }

/* the circular icon */
.mn-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  box-shadow:
    0 4px 14px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(255,255,255,0.18);
  transition: box-shadow 0.2s;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.mn-circle::after {
  content: '';
  position: absolute;
  top: 6px; left: 10px;
  width: 20px; height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  transform: rotate(-30deg);
}

/* glow pulse on current level */
.mission-node.current .mn-circle {
  animation: mapCurrentPulse 2.2s ease-in-out infinite;
}
@keyframes mapCurrentPulse {
  0%,100% { box-shadow: 0 4px 14px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.18); }
  50%      { box-shadow: 0 0 28px var(--mn-accent, rgba(255,215,0,0.7)), 0 4px 14px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.18); }
}

.mn-num {
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.mn-flag {
  font-size: 14px;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
}

.mn-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.82);
  text-align: center;
  max-width: 82px;
  line-height: 1.25;
  text-shadow: 0 1px 4px rgba(0,0,0,0.90), 0 0 8px rgba(0,0,0,0.70);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mn-sublabel {
  font-size: 9px;
  color: rgba(255,215,0,0.55);
  text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* rank-upgrade node at the end */
.mission-node.rank-upgrade {
  width: 90px;
  cursor: default;
}
.rank-upgrade .mn-circle {
  width: 74px !important;
  height: 74px !important;
  font-size: 28px !important;
}
.rank-upgrade .mn-label {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,215,0,0.60);
  text-shadow: 0 0 10px rgba(255,215,0,0.30);
}

/* ─── Leaderboard separator ─────────────────────────────────── */
.lb-separator {
  text-align: center;
  color: rgba(255,255,255,0.22);
  font-size: 11px;
  padding: 6px 0 2px;
  letter-spacing: 5px;
  flex-shrink: 0;
}

.sc-back {
  align-self: flex-start;
  background: rgba(255,255,255,0.10);
  border: 1.5px solid rgba(255,255,255,0.18);
  color: #fff;
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 14px; font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.15s, transform 0.12s;
  flex-shrink: 0;
}
.sc-back:active { background: rgba(255,255,255,0.20); transform: scale(0.95); }

.sc-header {
  display: flex; align-items: center; gap: 12px;
  width: 100%; max-width: 420px;
  margin-top: 8px; margin-bottom: 14px;
  flex-shrink: 0;
}
.sc-header-title {
  flex: 1; font-size: 20px; font-weight: 800;
  color: var(--clr-gold); text-align: center;
  padding-right: 80px; /* optical balance with back btn */
}

.sc-body {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; width: 100%; max-width: 320px;
  margin-top: auto; margin-bottom: auto;
}
.sc-title {
  font-size: 22px; font-weight: 800; color: var(--clr-gold);
  text-align: center; margin: 0;
}

.sc-scroll-list {
  flex: 1;
  width: 100%; max-width: 420px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding-bottom: 24px;
  -webkit-overflow-scrolling: touch;
}

/* ─── Mission cards ────────────────────────────────────────── */
.mission-card {
  display: flex; align-items: center; gap: 14px;
  background: rgba(255,255,255,0.07);
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 13px 15px;
  cursor: pointer;
  transition: background 0.18s, transform 0.12s;
  flex-shrink: 0;
}
.mission-card:active { transform: scale(0.98); }
.mission-card:hover  { background: rgba(255,255,255,0.11); }
.mission-card.locked { opacity: 0.45; cursor: default; }
.mission-card.done   { border-color: rgba(255,215,0,0.35); }
.mission-card.current { border-color: rgba(100,200,255,0.45); }

.mc-num {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.mission-card.done .mc-num { background: rgba(255,215,0,0.22); color: #FFD700; }

.mc-info { flex: 1; min-width: 0; }
.mc-title { font-size: 15px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-sub   { font-size: 12px; color: rgba(255,255,255,0.45); margin-top: 2px; }
.mc-badge { font-size: 20px; flex-shrink: 0; }

/* ─── Leaderboard ──────────────────────────────────────────── */
.lb-my-rank {
  background: rgba(255,215,0,0.12);
  border: 1.5px solid rgba(255,215,0,0.35);
  border-radius: 12px;
  padding: 11px 16px;
  width: 100%; max-width: 420px;
  margin-bottom: 10px;
  text-align: center;
  font-size: 14px; font-weight: 600; color: #FFD700;
  flex-shrink: 0;
}
#lb-my-rank { /* same as .lb-my-rank but for id selector */ }

.lb-row {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 10px 14px;
  flex-shrink: 0;
}
.lb-row.my-row { background: rgba(255,215,0,0.12); border: 1px solid rgba(255,215,0,0.28); }
.lb-rank { font-size: 14px; font-weight: 700; color: rgba(255,255,255,0.48); width: 30px; text-align: center; flex-shrink: 0; }
.lb-rank.top3 { font-size: 20px; }
.lb-name  { flex: 1; font-size: 15px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-score { font-size: 13px; color: rgba(255,255,255,0.50); flex-shrink: 0; }
.lb-loading { text-align: center; color: rgba(255,255,255,0.40); padding: 32px 0; font-size: 14px; }

/* ─── Screen-game wraps the original #app ──────────────────── */
#screen-game {
  display: none;          /* must be hidden; JS shows it via showScreen() */
  background: transparent;
  justify-content: flex-start;
  overflow: hidden;
}

/* removed — replaced by new .app-screen system above */
