/* ════════════════════════════════════════════════════════════
   DESIGN TOKENS — all colours/fonts here.
   ════════════════════════════════════════════════════════════ */
:root {
  /* Background layers — darkest (#050505) to lightest (#2a2a2a) */
  --bg:           #050505;
  --bg2:          #0a0a0a;
  --bg3:          #1a1a1a;
  --bg4:          #2a2a2a;
  --panel:        #141414;   /* side-panel background */

  /* Primary accent — orange used for highlights, borders, scores */
  --orange:        #ff8a1a;
  --orange-bright: #ffb366;
  --orange-dim:    rgba(255, 138, 26, 0.15);  /* subtle fill */
  --orange-glow:   rgba(255, 138, 26, 0.30);  /* box-shadow glow */
  --orange-trace:  rgba(255, 138, 26, 0.06);  /* barely-there tint */

  /* Morse symbol colours — dot = cyan, dash = orange */
  --dot-color:    #00BFFF;
  --dot-dim:      rgba(0, 191, 255, 0.18);
  --dash-color:   #ff8a1a;
  --dash-dim:     rgba(255, 138, 26, 0.18);

  /* Feedback colours — correct/wrong/pending states */
  --correct:      #22c55e;
  --correct-dim:  rgba(34, 197, 94, 0.18);
  --wrong:        #ef4444;
  --wrong-dim:    rgba(239, 68, 68, 0.18);
  --pending:      #ffaa00;
  --pending-dim:  rgba(255, 170, 0, 0.18);
  --success:      #22c55e;

  /* Text hierarchy — --text brightest, --text3 dimmest */
  --text:         #f5f5f5;
  --text2:        #bdbdbd;
  --text3:        #7a7a7a;
  --soft-white:   #f5f5f5;

  /* Aliases used by the hero/footer section */
  --off-white:    #f5f5f5;
  --gold:         #ff8a1a;

  /* Border colours */
  --border:       rgba(255, 138, 26, 0.12);  /* subtle */
  --border2:      rgba(255, 138, 26, 0.35);  /* prominent */

  /* Per-round accent colours: r1=Round I orange, r2=Round II cyan,
     r3=Round III red-orange, r4=Bonus purple                       */
  --r1: #ff8a1a;  --r1-dim: rgba(255, 138, 26, 0.15);
  --r2: #00BFFF;  --r2-dim: rgba(0, 191, 255, 0.15);
  --r3: #ff6b35;  --r3-dim: rgba(255, 107, 53, 0.15);
  --r4: #a855f7;  --r4-dim: rgba(168, 85, 247, 0.15);

  /* Font stack: display title / UI labels / morse code / monospace */
  --font-title: 'Montserrat', 'Arial Black', sans-serif;
  --font-main:  'Orbitron', sans-serif;
  --font-mono:  'JetBrains Mono', 'Courier New', monospace;
}
@font-face {
  font-family: 'Montserrat';
  src: url('assets/montserrat-v31-latin-regular.woff2') format('woff2');
}

@font-face {
  font-family: 'Orbitron';
  src: url('assets/orbitron-v35-latin-regular.woff2') format('woff2');
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('assets/jetbrains-mono-v24-latin-regular.woff2') format('woff2');
}

@font-face {
  font-family: 'Open Sans';
  src: url('assets/open-sans-v44-latin-regular.woff2') format('woff2');
}

/* ── RESET & BASE ── */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
}

/* Full-viewport dark canvas; no horizontal scroll */
body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.4;
  overflow-x: hidden;
  user-select: none;   /* prevent accidental text selection while typing */
}

/* Faint orange grid lines overlaid across the whole page */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(255,138,26,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,138,26,0.03) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none; z-index: 0;
}

/* Subtle CRT scanline effect */
body::after {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent, transparent 2px,
    rgba(0,0,0,0.04) 2px, rgba(0,0,0,0.04) 4px
  );
  pointer-events: none; z-index: 0;
}

/* Each "page" is hidden until .active is toggled on by JS */
.screen          { display: none; min-height: 100vh; position: relative; z-index: 1; }
.screen.active   { display: block; }

/* Thin orange scrollbar across the app */
::-webkit-scrollbar       { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ════════════════════════════════════════════════════════════
   SPLASH SCREEN — logo intro shown before the hero screen
   ════════════════════════════════════════════════════════════ */
#splash-screen.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.splash-content {
  text-align: center;
  position: relative;
  animation: splash-fade 0.6s ease-out;
}
.splash-logo-icon {
  font-size: 3.4rem;
  line-height: 1;
  margin-bottom: 0.4rem;
  position: relative;
}
.splash-title {
  font-family: var(--font-title);
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 900;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  line-height: 1;
  margin-bottom: 0.6rem;
}
.splash-loading {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text3);
  letter-spacing: 0.2em;
  animation: splash-blink 1.4s ease-in-out infinite;
}
@keyframes splash-fade {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes splash-blink {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}

/* ════════════════════════════════════════════════════════════
   HERO SCREEN — landing page with a single Play Game button
   ════════════════════════════════════════════════════════════ */
#hero-screen.screen.active {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.hero-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem 2rem;
  position: relative;
  z-index: 1;
}
.hero-title-white,
.hero-title-orange {
  font-family: var(--font-title);
  font-size: clamp(1.9rem, 6vw, 3.6rem);
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1.08;
  text-transform: uppercase;
}
.hero-title-white  { color: var(--soft-white); }
.hero-title-orange { color: var(--orange); margin-bottom: 1.1rem; text-shadow: 0 0 30px var(--orange-glow); }

.hero-tagline {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text2);
  letter-spacing: 0.02em;
  margin-bottom: 2.2rem;
  max-width: 460px;
  line-height: 1.6;
}
.hero-play-btn {
  max-width: 300px;
  font-size: 1.05rem;
  padding: 0.85rem 1.5rem;
}

/* ── FOOTER — bottom of the hero screen ── */
.footer-bottom {
  text-align: center;
  padding: 1.25rem 1rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text3);
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 1;
}
.footer-bottom p { line-height: 1.7; }

.launch {
    color: var(--off-white);
    font-size: 0.9rem; 
}
.launch a {
    text-decoration: none;
    color: var(--off-white);
    transition: color 0.2s ease-in-out; 
} 
.launch a:hover {
    color: var(--gold);
}

/* ════════════════════════════════════════════════════════════
   PAGE LAYOUTS
   Both screens use a 3-column CSS grid:
     [side panel] [centre content] [side panel]
   Centre column scrolls; side panels are sticky/full-height.
   ════════════════════════════════════════════════════════════ */
.home-layout {
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  min-height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
}

.home-center {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1.25rem 1.25rem 1.5rem;
  background: var(--bg2);
  overflow-y: auto;
}

/* ── HOME SIDE PANELS (left reference + right leaderboard) ──
   sticky so they stay in view while home-center scrolls.
   flex-direction:column lets the leaderboard-list stretch to fill
   the remaining height via flex:1 on #home-leaderboard.          */
.home-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-left {
  border-right: 1px solid var(--border);
}

.panel-left.home-panel {
  overflow-y: auto;
}

.game-layout {
  display: grid;
  grid-template-columns: 250px 1fr 250px;
  min-height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
}

.game-center, .bonus-center {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.5rem 0.75rem 1rem;
  background: var(--bg2);
  overflow-y: auto;
  min-height: 100vh;
}

.game-right {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.panel {
  background: var(--panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-right {
  border-left: 1px solid var(--border);
}

/* ── GAME SIDE PANELS (reference left + leaderboard right) ──
   flex-direction:column + overflow-y:auto lets the inner
   leaderboard-list use flex:1 to fill all available height,
   then scroll when entries overflow.                        */
.game-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* ── PANEL HEADER — orange label bar at top of each side panel ── */
.panel-header {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.6rem 0.9rem;
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-main); font-weight: 700; font-size: 0.7rem;
  letter-spacing: 0.1em; color: var(--orange); text-transform: uppercase;
  flex-shrink: 0;
}
.panel-icon  { font-size: 0.9rem; }
.panel-title-morse { color: #ffffff; text-shadow: none; }

.panel-title-ref{ color: var(--orange); text-shadow: none; }
.panel-hint  {
  font-size: 0.6rem; color: var(--text3);
  padding: 0.25rem 0.9rem; letter-spacing: 0.04em; flex-shrink: 0;
}

/* ── MORSE REFERENCE GRID — letter/number tiles in side panels ── */
.morse-grid {
  display: grid;
  gap: 2px;
  padding: 0.2rem 0;
}

.home-grid {
  grid-template-columns: repeat(3, 1fr);
}

.game-grid {
  grid-template-columns: repeat(3, 1fr);
}

/* Individual morse tile button — letter on top, dot/dash code below */
.morse-btn {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 0.18rem 0.1rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.12s ease;
  min-height: 28px;
  position: relative; overflow: hidden;
}
.morse-btn::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--orange-dim), transparent);
  opacity: 0; transition: opacity 0.12s;
}
.morse-btn:hover::before { opacity: 1; }
.morse-btn:hover {
  border-color: var(--orange);
  transform: scale(1.06);
  box-shadow: 0 0 8px var(--orange-glow);
}
.morse-btn:active { transform: scale(0.95); }

/* Highlight the tile for the current target letter during Round I-II */
.morse-btn.active-hint {
  border-color: var(--pending);
  box-shadow: 0 0 10px var(--pending-dim);
  background: rgba(255,215,0,0.07);
}

.mb-letter {
  font-weight: 700;
  font-size: 0.7rem;
  color: var(--orange);
  line-height: 1;
}

.mb-dots       { font-family: var(--font-mono); font-size: 0.46rem; line-height: 1; letter-spacing: 0.02em; }
.mb-dot-char   { color: var(--dot-color); }   
.mb-dash-char  { color: var(--dash-color); }  

.morse-grid-divider {
  grid-column: 1 / -1;
  text-align: center;
  font-family: var(--font-main);
  font-size: 0.45rem; font-weight: 700;
  letter-spacing: 0.15em; color: var(--text3);
  padding: 2px 0 2px;
  border-top: 1px solid var(--border);
  margin-top: 1px;
}

.number-btn .mb-letter { color: var(--dot-color); }
.number-btn             { border-color: rgba(0,191,255,0.22); }
.number-btn:hover       { border-color: var(--dot-color); box-shadow: 0 0 8px rgba(0,191,255,0.4); }
.number-btn:hover::before { background: linear-gradient(135deg, rgba(0,191,255,0.1), transparent); }
.number-btn.active-hint {
  border-color: var(--dot-color);
  box-shadow: 0 0 10px rgba(0,191,255,0.3);
  background: rgba(0,191,255,0.07);
}

/* ── DATA MANAGER BUTTON ── */
.data-manager-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.45rem 0.6rem;
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 5px;
  font-family: var(--font-main); font-weight: 700; font-size: 0.6rem;
  letter-spacing: 0.1em; color: var(--text3);
  cursor: pointer; transition: all 0.18s;
  text-transform: uppercase;
}
.data-manager-btn:hover {
  border-color: var(--wrong);
  color: var(--wrong);
  background: var(--wrong-dim);
  box-shadow: 0 0 10px rgba(239,68,68,0.15);
}

/* ── DONATE BUTTON — sits under Data Manager ── */
.donate-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.45rem 0.6rem;
  margin-top: 0.5rem;
  background: transparent;
  border: 1px solid rgba(255, 138, 26, 0.35);
  border-radius: 5px;
  font-family: var(--font-main); font-weight: 700; font-size: 0.6rem;
  letter-spacing: 0.1em; color: var(--orange);
  cursor: pointer; transition: all 0.18s;
  text-transform: uppercase;
}
.donate-btn:hover {
  border-color: var(--orange);
  color: var(--orange);
  background: var(--orange-dim);
  box-shadow: 0 0 10px var(--orange-glow);
}

/* ── TERMS & CONDITIONS BUTTON — sits under Donate ── */
.terms-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.45rem 0.6rem;
  margin-top: 0.5rem;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 5px;
  font-family: var(--font-main); font-weight: 700; font-size: 0.6rem;
  letter-spacing: 0.1em; color: var(--text2);
  cursor: pointer; transition: all 0.18s;
  text-transform: uppercase;
}
.terms-btn:hover {
  border-color: var(--text2);
  color: var(--text);
  background: var(--bg4);
}

/* ── DATA MANAGER MODAL ── */
.data-mgr-overlay {
  position: fixed; inset: 0; z-index: 9998;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5,5,5,0.92); backdrop-filter: blur(8px);
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.data-mgr-overlay.active { opacity: 1; pointer-events: all; }

.data-mgr-box {
  background: var(--bg3);
  border: 2px solid rgba(239,68,68,0.45);
  border-radius: 14px;
  padding: 2rem 2rem 1.5rem;
  max-width: 420px; width: 92%;
  position: relative;
  box-shadow: 0 0 60px rgba(239,68,68,0.15), 0 20px 50px rgba(0,0,0,0.7);
  animation: tile-pop 0.22s cubic-bezier(.18,.89,.32,1.28);
}

.data-mgr-close {
  position: absolute; top: 0.75rem; right: 0.75rem;
  background: none; border: 1px solid var(--border2); border-radius: 4px;
  color: var(--text3); cursor: pointer; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center; font-size: 0.8rem;
  transition: all 0.15s;
}
.data-mgr-close:hover { background: var(--wrong-dim); border-color: var(--wrong); color: var(--wrong); }

.data-mgr-icon {
  text-align: center; font-size: 2.2rem; margin-bottom: 0.5rem;
}
.data-mgr-title {
  font-family: var(--font-mono); font-size: 1.2rem; font-weight: 700;
  color: var(--wrong); text-align: center; margin-bottom: 0.3rem;
  letter-spacing: 0.05em;
}
.data-mgr-sub {
  font-family: var(--font-mono); font-size: 0.68rem; color: var(--text3);
  text-align: center; margin-bottom: 1.25rem; line-height: 1.6;
}

.data-mgr-info {
  background: var(--bg4); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.data-mgr-info-label {
  font-family: var(--font-mono); font-size: 0.6rem; color: var(--text3);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.data-mgr-info-value {
  font-family: var(--font-mono); font-size: 1rem; font-weight: 700;
  color: var(--orange);
}

.data-mgr-warning {
  display: flex; align-items: flex-start; gap: 0.5rem;
  background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.25);
  border-radius: 7px; padding: 0.65rem 0.8rem;
  margin-bottom: 1.25rem;
  font-family: var(--font-mono); font-size: 0.62rem; color: var(--text2);
  line-height: 1.6;
}
.data-mgr-warning-icon { font-size: 0.9rem; flex-shrink: 0; margin-top: 1px; }

.data-mgr-actions {
  display: flex; gap: 0.65rem;
}
.data-mgr-cancel {
  flex: 1; padding: 0.65rem;
  background: transparent; border: 1px solid var(--border2); border-radius: 7px;
  font-family: var(--font-main); font-weight: 700; font-size: 0.75rem;
  letter-spacing: 0.08em; color: var(--text2);
  cursor: pointer; transition: all 0.18s;
}
.data-mgr-cancel:hover { border-color: var(--orange); color: var(--orange); background: var(--orange-dim); }

.data-mgr-delete {
  flex: 1; padding: 0.65rem;
  background: var(--wrong-dim); border: 2px solid var(--wrong); border-radius: 7px;
  font-family: var(--font-main); font-weight: 700; font-size: 0.75rem;
  letter-spacing: 0.08em; color: var(--wrong);
  cursor: pointer; transition: all 0.18s;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
}
.data-mgr-delete:hover { background: var(--wrong); color: #fff; box-shadow: 0 0 20px rgba(239,68,68,0.4); }

.data-mgr-success {
  text-align: center; padding: 0.5rem 0;
}
.data-mgr-success-icon { font-size: 2.5rem; margin-bottom: 0.4rem; }
.data-mgr-success-msg {
  font-family: var(--font-mono); font-size: 0.75rem; color: var(--correct);
  letter-spacing: 0.06em;
}

/* ── DONATE MODALS (prompt + info) ── */
.donate-box {
  background: var(--bg3);
  border: 2px solid var(--orange);
  border-radius: 14px;
  padding: 2rem 2rem 1.5rem;
  max-width: 400px; width: 92%;
  position: relative;
  text-align: center;
  box-shadow: 0 0 60px var(--orange-glow), 0 20px 50px rgba(0,0,0,0.7);
  animation: tile-pop 0.22s cubic-bezier(.18,.89,.32,1.28);
}
.donate-close {
  position: absolute; top: 0.75rem; right: 0.75rem;
  background: none; border: 1px solid var(--border2); border-radius: 4px;
  color: var(--text3); cursor: pointer; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center; font-size: 0.8rem;
  transition: all 0.15s;
}
.donate-close:hover { background: var(--wrong-dim); border-color: var(--wrong); color: var(--wrong); }
.donate-icon {
  font-size: 2.4rem; margin-bottom: 0.5rem;
}
.donate-title {
  font-family: var(--font-mono); font-size: 1.15rem; font-weight: 700;
  color: var(--orange); margin-bottom: 0.4rem; letter-spacing: 0.05em;
}
.donate-sub {
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--text2);
  margin-bottom: 1.1rem; line-height: 1.6;
}
.gcash-number {
  font-family: var(--font-mono); font-size: 1.3rem; font-weight: 700;
  color: var(--soft-white); background: var(--bg4);
  border: 1px dashed var(--border2); border-radius: 8px;
  padding: 0.7rem; margin-bottom: 1rem; letter-spacing: 0.1em;
  cursor: pointer; transition: all 0.15s;
}
.gcash-number:hover { border-color: var(--orange); color: var(--orange); }
.donate-thanks {
  font-family: var(--font-mono); font-size: 0.68rem; color: var(--text3);
  line-height: 1.6;
}

/* ── TERMS & CONDITIONS MODAL ── */
.terms-box {
  background: var(--bg3);
  border: 2px solid var(--border2);
  border-radius: 14px;
  padding: 1.75rem 2rem;
  max-width: 520px; width: 92%;
  position: relative;
  text-align: left;
  box-shadow: 0 0 60px rgba(255,255,255,0.05), 0 20px 50px rgba(0,0,0,0.7);
  animation: tile-pop 0.22s cubic-bezier(.18,.89,.32,1.28);
  max-height: 88vh; overflow-y: auto;
}
.terms-close {
  position: absolute; top: 0.75rem; right: 0.75rem;
  background: none; border: 1px solid var(--border2); border-radius: 4px;
  color: var(--text3); cursor: pointer; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center; font-size: 0.8rem;
  transition: all 0.15s;
}
.terms-close:hover { background: var(--wrong-dim); border-color: var(--wrong); color: var(--wrong); }
.terms-title {
  font-family: var(--font-mono); font-size: 1.2rem; font-weight: 700;
  color: var(--orange); margin-bottom: 0.2rem; letter-spacing: 0.05em; text-align: center;
}
.terms-date {
  font-family: var(--font-mono); font-size: 0.62rem; color: var(--text3);
  text-align: center; margin-bottom: 1rem; letter-spacing: 0.05em;
}
.terms-content { font-size: 0.78rem; color: var(--text2); line-height: 1.7; }
.terms-content p { margin-bottom: 0.75rem; }
.terms-content ol { padding-left: 1.2rem; margin-bottom: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.terms-content strong { color: var(--soft-white); }
.terms-content a { color: var(--orange); text-decoration: none; }
.terms-content a:hover { text-decoration: underline; }
.terms-signoff { color: var(--orange); font-style: italic; text-align: center; margin-top: 0.5rem; }

/* ════════════════════════════════════════════════════════════
   TILE DETAIL POPUP
   Full-screen overlay shown when a morse tile is clicked.
   Displays the letter large, its code, dot/dash shapes, and
   a Play button to hear the sound.
   ════════════════════════════════════════════════════════════ */
.morse-tile-popup {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5,5,5,0.92); backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.morse-tile-popup.active { opacity: 1; pointer-events: all; }

.morse-tile-popup-inner {
  background: var(--bg3);
  border: 2px solid var(--orange);
  border-radius: 12px;
  padding: 2rem 2.5rem;
  text-align: center;
  position: relative;
  min-width: 240px;
  box-shadow: 0 0 50px var(--orange-glow), 0 20px 50px rgba(0,0,0,0.7);
  animation: tile-pop 0.22s cubic-bezier(.18,.89,.32,1.28);
}
@keyframes tile-pop {
  from { transform: scale(0.65); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.tile-popup-close {
  position: absolute; top: 0.6rem; right: 0.6rem;
  background: none; border: 1px solid var(--border2); border-radius: 4px;
  color: var(--text3); cursor: pointer; width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center; font-size: 0.75rem;
  transition: all 0.15s;
}
.tile-popup-close:hover { background: var(--wrong-dim); border-color: var(--wrong); color: var(--wrong); }

.tile-popup-letter {
  font-family: var(--font-main); font-size: 4.5rem; font-weight: 700;
  color: var(--orange); line-height: 1;
  text-shadow: 0 0 25px var(--orange-glow); margin-bottom: 0.3rem;
}
.tile-popup-code {
  font-family: var(--font-mono); font-size: 1.8rem;
  letter-spacing: 0.2em; margin-bottom: 0.8rem;
}
.tile-popup-dots {
  display: flex; justify-content: center; gap: 6px;
  margin-bottom: 0.8rem; min-height: 20px; align-items: center;
}

.dot-circle {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--dot-color); box-shadow: 0 0 8px var(--dot-dim);
}

.dash-rect {
  width: 30px; height: 12px; border-radius: 6px;
  background: var(--dash-color); box-shadow: 0 0 8px var(--dash-dim);
}

.tile-popup-play {
  display: block; width: 100%;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 0.45rem 0.75rem;
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.08em; color: var(--text2);
  cursor: pointer; transition: all 0.18s;
  margin-bottom: 0.6rem;
}
.tile-popup-play:hover:not(:disabled) {
  border-color: var(--orange); color: var(--orange);
  background: var(--orange-dim);
}
.tile-popup-play:disabled {
  opacity: 0.5; cursor: default;
}

.tile-popup-hint {
  font-family: var(--font-mono); font-size: 0.65rem;
  color: var(--text3); letter-spacing: 0.08em;
}

/* ── HOW TO PLAY modal box — shown by the "How to Play" button ── */
.instruction-box {
  background: var(--bg3);
  border: 2px solid var(--orange);
  border-radius: 14px;
  padding: 1.75rem 2rem;
  max-width: 520px; width: 92%;
  position: relative;
  box-shadow: 0 0 60px var(--orange-glow);
  animation: tile-pop 0.25s cubic-bezier(.18,.89,.32,1.28);
  max-height: 88vh; overflow-y: auto;
}
.instr-close {
  position: absolute; top: 0.75rem; right: 0.75rem;
  background: none; border: 1px solid var(--border2); border-radius: 4px;
  color: var(--text3); cursor: pointer; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center; font-size: 0.8rem;
  transition: all 0.15s;
}
.instr-close:hover { background: var(--wrong-dim); border-color: var(--wrong); color: var(--wrong); }

.instr-title {
  font-family: var(--font-mono); font-size: 1.4rem; color: var(--orange);
  text-shadow: 0 0 20px var(--orange-glow);
  margin-bottom: 0.6rem; text-align: center;
}
.instr-intro    { font-size: 0.82rem; color: var(--text2); margin-bottom: 1rem; line-height: 1.6; text-align: center; }
.instr-section  { margin-bottom: 0.9rem; }
.instr-section-title {
  font-family: var(--font-mono); font-size: 0.68rem; color: var(--orange);
  letter-spacing: 0.1em; border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem; margin-bottom: 0.5rem;
}
.instr-keys     { display: flex; flex-direction: column; gap: 0.35rem; }
.ik-row         { display: flex; align-items: center; gap: 0.6rem; font-size: 0.78rem; color: var(--text); }
.ik-key {
  font-family: var(--font-mono); font-weight: 700; font-size: 0.75rem;
  padding: 0.25rem 0.5rem; border-radius: 4px; border: 1px solid;
  flex-shrink: 0; min-width: 36px; text-align: center;
}
.dash-key-style  { border-color: var(--dash-color); color: var(--dash-color); background: var(--dash-dim); }
.dot-key-style   { border-color: var(--dot-color);  color: var(--dot-color);  background: var(--dot-dim); }
.space-key-style { border-color: var(--orange);     color: var(--orange);     background: var(--orange-dim); }
.back-key-style  { border-color: var(--wrong);      color: var(--wrong);      background: var(--wrong-dim); }
.skip-key-style  { border-color: var(--text2); color: var(--text3); background: var(--panel); }
.ik-desc         { font-size: 0.76rem; color: var(--text2); }
.ik-desc strong  { color: var(--soft-white); }
.instr-text      { font-size: 0.78rem; color: var(--text2); line-height: 1.6; }
.c-correct       { color: var(--correct); font-weight: 700; }
.c-wrong         { color: var(--wrong);   font-weight: 700; }
.instr-example {
  margin-top: 0.5rem; background: var(--bg4);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 0.4rem 0.75rem;
  display: flex; flex-direction: column; gap: 0.15rem;
}
.ie-label        { font-family: var(--font-mono); font-size: 0.72rem; color: var(--orange); }
.ie-keys         { font-family: var(--font-mono); font-size: 0.7rem;  color: var(--text3); }
.instr-rounds    { display: flex; flex-direction: column; gap: 0.4rem; }
.ir-item {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--bg4); border-left: 3px solid;
  border-radius: 4px; padding: 0.5rem 0.75rem;
  font-size: 0.76rem; color: var(--text2); line-height: 1.5;
}
.ir-item small   { color: var(--text3); }
.easy-border     { border-color: var(--r1); }
.medium-border   { border-color: var(--r2); }
.hard-border     { border-color: var(--r3); }
.ir-badge {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-main); font-weight: 700; font-size: 0.72rem; color: var(--bg);
}
.easy-bg   { background: var(--r1); }
.medium-bg { background: var(--r2); }
.hard-bg   { background: var(--r3); }
.instr-got-it {
  margin-top: 1rem; width: 100%;
  background: var(--orange-dim); border: 2px solid var(--orange);
  border-radius: 7px; padding: 0.7rem;
  font-family: var(--font-mono); font-size: 0.85rem; font-weight: 700;
  letter-spacing: 0.1em; color: var(--orange);
  cursor: pointer; transition: all 0.2s;
}
.instr-got-it:hover { background: var(--orange); color: var(--bg); box-shadow: 0 0 20px var(--orange-glow); }

/* ════════════════════════════════════════════════════════════
   HOME SCREEN CENTRE CONTENT
   ════════════════════════════════════════════════════════════ */

/* Logo + pulse ring animation above the MORSETYPE title */
.logo-area {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 0.5rem 0; position: relative;
}

.logo-pulse {
  position: absolute; width: 64px; height: 64px;
  border: 2px solid var(--orange-glow);
  border-radius: 50%;
  animation: pulse-ring 2.8s ease-out infinite;
}
@keyframes pulse-ring {
  0%   { transform: scale(0.7); opacity: 0.8; }
  70%  { transform: scale(1.8); opacity: 0; }
  100% { opacity: 0; }
}
.logo-icon {
  font-size: 2.2rem; line-height: 1;
  margin-bottom: 0.3rem; position: relative;
}

.game-title-logo { display: none; }
.logo-img { display: none; }

/* Giant MORSETYPE wordmark */
.game-title {
  font-family: var(--font-title);
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  font-weight: 900;          
  letter-spacing: -0.01em;   
  line-height: 1;
  margin-bottom: 0.2rem;
  text-transform: uppercase;
  display: block;             
}

.morse { color: #ffffff; text-shadow: none; }

.type  { color: var(--orange); text-shadow: none; }
.game-tagline {
  
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text3);
  letter-spacing: 0.08em;
  font-weight: 400;
}

.how-to-play-btn {
  width: 100%; background: transparent;
  border: 1px dashed var(--border2); border-radius: 7px;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.08em; color: var(--text2);
  cursor: pointer; transition: all 0.2s;
}
.how-to-play-btn:hover {
  border-color: var(--orange); color: var(--orange);
  background: var(--orange-trace);
}

.round-preview {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.55rem;
}
.rp-item  { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; text-align: center; }
.rp-badge {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.7rem; font-family: var(--font-main);
}
.rp-badge.easy         { background: var(--r1-dim); border: 2px solid var(--r1); color: var(--r1); }
.rp-badge.medium       { background: var(--r2-dim); border: 2px solid var(--r2); color: var(--r2); }
.rp-badge.hard         { background: var(--r3-dim); border: 2px solid var(--r3); color: var(--r3); }
.rp-badge.bonus-badge-chip {
  background: rgba(168,85,247,0.15); border: 2px solid #a855f7; color: #a855f7;
}
.rp-label  { font-size: 0.58rem; color: var(--text2); font-family: var(--font-main); font-weight: 600; line-height: 1.3; }
.rp-label small { color: var(--text3); display: block; }
.rp-arrow  { color: var(--text3); font-size: 1rem; }

/* Call-sign entry form — player name input + start button */
.name-form  { display: flex; flex-direction: column; gap: 0.5rem; }
.form-label {
  font-family: var(--font-mono); font-size: 0.62rem;
  letter-spacing: 0.12em; color: var(--text2);
}
.name-input {
  background: var(--bg3); border: 2px solid var(--border2); border-radius: 6px;
  padding: 0.65rem 0.875rem;
  font-family: var(--font-mono); font-size: 0.95rem; font-weight: 600;
  color: var(--soft-white); text-transform: uppercase; letter-spacing: 0.1em;
  transition: all 0.2s; width: 100%;
}
.name-input::placeholder { color: var(--text3); text-transform: none; letter-spacing: 0.05em; font-weight: 400; }
.name-input:focus        { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-dim); }

/* Orange "BEGIN TRAINING" CTA button */
.start-btn {
  background: linear-gradient(135deg, var(--orange-dim), transparent);
  border: 2px solid var(--orange); border-radius: 6px; padding: 0.7rem 1.25rem;
  font-family: var(--font-main); font-size: 1rem; font-weight: 700;
  letter-spacing: 0.12em; color: var(--orange);
  cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 0.6rem; width: 100%;
}
.start-btn:hover {
  background: var(--orange); color: var(--bg);
  box-shadow: 0 0 25px var(--orange-glow); transform: translateY(-2px);
}
.btn-arrow { font-size: 1.1rem; }

/* ── LEADERBOARD ── */

/* Tab row above the leaderboard list (All / Round I / II / III) */
.lb-tabs {
  display: flex; gap: 4px; padding: 0.5rem 0.6rem 0; flex-shrink: 0;
}
.lb-tab {
  flex: 1; background: transparent;
  border: 1px solid var(--border); border-radius: 4px;
  color: var(--text3);
  font-family: var(--font-main); font-weight: 600; font-size: 0.55rem;
  letter-spacing: 0.06em; padding: 0.3rem 0.15rem;
  cursor: pointer; transition: all 0.15s; text-transform: uppercase;
}
.lb-tab:hover  { color: var(--text); border-color: var(--border2); }
.lb-tab.active { background: var(--orange-dim); border-color: var(--orange); color: var(--orange); }

/* Scrollable list of score entries */
.leaderboard-list {
  flex: 1; overflow-y: auto;
  padding: 0.4rem 0.6rem 0.6rem;
  display: flex; flex-direction: column; gap: 3px;
}
/* Leaderboard list fills remaining panel height and scrolls */
#home-leaderboard {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.lb-empty {
  text-align: center; padding: 1.5rem 0.75rem;
  color: var(--text3); font-size: 0.65rem;
  font-family: var(--font-mono);
  border: 1px dashed var(--border); border-radius: 6px;
  margin-top: 0.4rem; line-height: 1.6;
}
.lb-entry {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg3); border-left: 3px solid var(--border);
  border-radius: 3px; transition: all 0.15s;
}
.lb-entry:hover           { background: rgba(255,138,26,0.05); transform: translateX(2px); }
.lb-entry:nth-child(1)    { border-left-color: #ffd700; }
.lb-entry:nth-child(2)    { border-left-color: #c0c0c0; }
.lb-entry:nth-child(3)    { border-left-color: #cd7f32; }
.lb-rank   { font-family: var(--font-mono); font-size: 0.7rem; color: var(--orange); min-width: 24px; }
.lb-info   { flex: 1; min-width: 0; }
.lb-name   { font-weight: 700; font-size: 0.72rem; color: var(--soft-white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-detail { font-size: 0.55rem; color: var(--text3); font-family: var(--font-mono); }
.lb-score  { font-family: var(--font-mono); font-size: 0.85rem; color: var(--orange); font-weight: 700; min-width: 28px; text-align: right; }

.overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5,5,5,0.92); backdrop-filter: blur(8px);
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.overlay.active { opacity: 1; pointer-events: all; }

/* ════════════════════════════════════════════════════════════
   COUNTDOWN OVERLAY  — shown before each round starts
   ════════════════════════════════════════════════════════════ */
.countdown-box { text-align: center; animation: pop-in 0.3s ease-out; }
@keyframes pop-in { from { transform: scale(0.75); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.cd-badge {
  display: inline-block; padding: 0.25rem 0.875rem; border-radius: 20px;
  font-family: var(--font-main); font-weight: 700; font-size: 0.75rem;
  letter-spacing: 0.12em; margin-bottom: 0.75rem;
}
.cd-badge.easy   { background: var(--r1-dim); border: 1px solid var(--r1); color: var(--r1); }
.cd-badge.medium { background: var(--r2-dim); border: 1px solid var(--r2); color: var(--r2); }
.cd-badge.hard   { background: var(--r3-dim); border: 1px solid var(--r3); color: var(--r3); }
.cd-title { font-family: var(--font-mono); font-size: 2.2rem; font-weight: 700; color: var(--soft-white); margin-bottom: 0.15rem; }
.cd-sub   { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text2); margin-bottom: 1rem; }
.cd-number {
  font-family: var(--font-mono); font-size: 7rem; font-weight: 700;
  color: var(--orange); text-shadow: 0 0 50px var(--orange-glow);
  line-height: 1; animation: cd-pulse 1s ease-in-out;
}
@keyframes cd-pulse {
  0%   { transform: scale(1.5); opacity: 0; }
  60%  { transform: scale(0.95); }
  100% { transform: scale(1);   opacity: 1; }
}
.cd-hint { font-size: 0.68rem; color: var(--text3); font-family: var(--font-mono); margin-top: 0.4rem; }

/* ── ROUND TRANSITION popup — shown between rounds ── */
.transition-box {
  background: var(--bg3); border: 2px solid var(--orange); border-radius: 12px;
  padding: 1.75rem; max-width: 400px; width: 90%;
  text-align: center; box-shadow: 0 0 60px var(--orange-glow); animation: pop-in 0.3s ease-out;
}
.transition-ribbon {
  display: inline-block; padding: 0.25rem 1rem; border-radius: 20px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em; margin-bottom: 0.7rem;
}
.transition-icon  { font-size: 2.8rem; margin-bottom: 0.4rem; }
.transition-title { font-family: var(--font-mono); font-size: 1.6rem; font-weight: 700; color: var(--soft-white); margin-bottom: 0.2rem; }
.transition-sub   { font-size: 0.78rem; color: var(--text2); margin-bottom: 0.9rem; }
.transition-stats { display: flex; gap: 0.75rem; justify-content: center; margin-bottom: 1rem; }
.ts-item  { background: var(--bg4); border: 1px solid var(--border); border-radius: 7px; padding: 0.5rem 0.875rem; min-width: 80px; }
.ts-value { font-family: var(--font-mono); font-size: 1.2rem; color: var(--orange); font-weight: 700; }
.ts-label { font-size: 0.55rem; color: var(--text3); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 0.15rem; }
.transition-next {
  background: var(--bg4); border: 1px solid var(--border); border-radius: 7px;
  padding: 0.65rem; margin-bottom: 1rem; text-align: left;
}
.tn-label  { font-size: 0.55rem; color: var(--text3); letter-spacing: 0.1em; margin-bottom: 0.15rem; }
.tn-title  { font-weight: 700; font-size: 0.88rem; color: var(--orange); margin-bottom: 0.1rem; font-family: var(--font-mono); }
.tn-detail { font-size: 0.65rem; color: var(--text2); font-family: var(--font-mono); }
.transition-btn {
  background: var(--orange-dim); border: 2px solid var(--orange); border-radius: 7px;
  padding: 0.65rem 1.5rem;
  font-family: var(--font-main); font-weight: 700; font-size: 0.9rem;
  letter-spacing: 0.1em; color: var(--orange);
  cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; gap: 0.6rem; width: 100%; justify-content: center;
}
.transition-btn:hover { background: var(--orange); color: var(--bg); box-shadow: 0 0 25px var(--orange-glow); }

/* ════════════════════════════════════════════════════════════
   GAME SCREEN — TOPBAR
   Three-zone row: [home btn] [stats] [help + volume]
   ════════════════════════════════════════════════════════════ */
.game-topbar { 
  display: flex; 
  align-items: center; 
  gap: 0.5rem; 
  flex-shrink: 0; 
  position: relative;
}

.home-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 4px;
  color: var(--text2); font-family: var(--font-mono); font-size: 0.72rem;
  padding: 0.3rem 0.5rem; cursor: pointer; transition: all 0.15s; flex-shrink: 0;
}
.home-btn:hover { border-color: var(--wrong); color: var(--wrong); }

.game-stats { 
  display: flex; 
  gap: 0.4rem; 
  flex: 1; 
  justify-content: center;
}

.topbar-left {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  min-width: 80px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  min-width: 80px;
}

.game-topbar > .home-btn {
  min-width: 70px; 
}

.gs-item {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 5px;
  padding: 0.2rem 0.5rem; text-align: center; min-width: 60px;
}
.gs-label { font-size: 0.48rem; color: var(--text3); letter-spacing: 0.1em; line-height: 1; margin-bottom: 1px; }
.gs-val   { font-family: var(--font-mono); font-weight: 700; font-size: 0.78rem; color: var(--orange); line-height: 1; }

.round-indicator { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ri-dot {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-main); font-weight: 700; font-size: 0.65rem;
  color: var(--text3); background: var(--bg3); transition: all 0.3s;
}
.ri-dot.active { border-color: var(--orange); color: var(--orange); background: var(--orange-dim); box-shadow: 0 0 14px var(--orange-glow); }
.ri-dot.done   { border-color: var(--orange-bright); color: var(--orange-bright); background: rgba(0,255,65,0.08); }
.ri-line       { height: 2px; width: 40px; background: var(--border); transition: background 0.3s; }
.ri-line.done  { background: var(--orange-bright); }

/* ── ROUND TIMER — progress bar + numeric countdown ── */
.timer-bar-wrap {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 7px; padding: 0.5rem 0.75rem; flex-shrink: 0;
}
.timer-bar-label {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.3rem;
  font-size: 0.6rem; color: var(--text2); font-family: var(--font-mono); letter-spacing: 0.06em;
}
.timer-num        { font-family: var(--font-mono); font-size: 1.1rem; color: var(--orange); line-height: 1; }
.timer-bar-track  { height: 5px; background: var(--bg4); border-radius: 3px; overflow: hidden; }
.timer-bar-fill   {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #7a3800, var(--orange));
  border-radius: 3px; transition: width 1s linear, background 0.5s;
}

.timer-bar-fill.warning { background: linear-gradient(90deg, var(--wrong), #FF8C00); }

/* ── TARGET DISPLAY — shows the letter/word to decode ── */
.target-area {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.5rem 0.875rem; text-align: center; flex-shrink: 0;
}
.target-label   { font-family: var(--font-mono); font-size: 0.52rem; color: var(--text3); letter-spacing: 0.15em; margin-bottom: 0.15rem; }
.target-display {
  font-family: var(--font-mono); font-size: 2.2rem; font-weight: 700;
  color: var(--orange); letter-spacing: 0.12em;
  text-shadow: 0 0 18px var(--orange-glow); line-height: 1; margin-bottom: 0.1rem;
}
.target-morse   { font-family: var(--font-mono); font-size: 0.85rem; color: var(--text2); letter-spacing: 0.18em; min-height: 1.2rem; }

/* Tile row showing each letter of the current word with status colours */
.word-progress { display: flex; gap: 4px; justify-content: center; margin-top: 0.4rem; flex-wrap: wrap; }
.wletter {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 0.2rem 0.4rem; background: var(--bg4);
  border: 1px solid var(--border); border-radius: 4px;
  min-width: 28px; transition: all 0.18s;
}
.wletter.done-correct { border-color: var(--correct); background: var(--correct-dim); }
.wletter.done-wrong   { border-color: var(--wrong);   background: var(--wrong-dim); }
.wletter.current      { border-color: var(--pending); background: var(--pending-dim); box-shadow: 0 0 8px var(--pending-dim); }
.wl-char  { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text); font-weight: 700; }
.wl-morse { font-family: var(--font-mono); font-size: 0.44rem; color: var(--text3); letter-spacing: 0.03em; }
.wletter.done-correct .wl-char { color: var(--correct); }
.wletter.done-wrong   .wl-char { color: var(--wrong); }
.wletter.current      .wl-char { color: var(--pending); }
.wletter.current      .wl-morse{ color: var(--pending); }

/* ── INPUT STAGE — shows typed dots/dashes + feedback state ──
   border colour changes: orange=idle, green=correct, red=wrong   */
.input-stage {
  background: var(--bg3); border: 2px solid var(--border2); border-radius: 8px;
  padding: 0.6rem 0.875rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
  flex-shrink: 0; transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 75px; justify-content: center;
}
.input-stage.state-correct { border-color: var(--correct); box-shadow: 0 0 16px var(--correct-dim); }
.input-stage.state-wrong   { border-color: var(--wrong);   box-shadow: 0 0 16px var(--wrong-dim);   animation: shake 0.3s ease; }
.input-stage.state-pending { border-color: var(--pending); box-shadow: 0 0 10px var(--pending-dim); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.current-input-pips {
  display: flex; gap: 5px; align-items: center; justify-content: center;
  min-height: 18px; flex-wrap: wrap;
}

/* Individual dot/dash pip inside the input stage.
   pip-dot = small circle, pip-dash = wide rect.
   .lit = actively pressed; .correct/.wrong = after submit */
.pip { display: flex; align-items: center; justify-content: center; border-radius: 4px; border: 1px solid; transition: all 0.08s; font-family: var(--font-mono); }
.pip-dot  { width: 16px; height: 16px; border-radius: 50%; border-color: var(--dot-color); background: var(--dot-dim);  color: var(--dot-color);  font-size: 0.7rem;  box-shadow: 0 0 5px var(--dot-dim); }
.pip-dash { width: 36px; height: 16px; border-radius: 4px;  border-color: var(--dash-color); background: var(--dash-dim); color: var(--dash-color); font-size: 0.65rem; box-shadow: 0 0 5px var(--dash-dim); }
.pip-dot.lit  { background: var(--dot-color);  color: var(--bg); box-shadow: 0 0 12px var(--dot-dim); }
.pip-dash.lit { background: var(--dash-color); color: var(--bg); box-shadow: 0 0 12px var(--dash-dim); }
.pip.correct  { border-color: var(--correct); background: var(--correct-dim); color: var(--correct); box-shadow: 0 0 8px var(--correct-dim); }
.pip.wrong    { border-color: var(--wrong);   background: var(--wrong-dim);   color: var(--wrong);   box-shadow: 0 0 8px var(--wrong-dim); }

.pip-blind {
  width: 18px; height: 14px; border-radius: 3px;
  border: 1px solid var(--border2);
  background: var(--bg4);
  display: inline-flex;
}

.decoded-so-far {
  font-family: var(--font-mono); font-size: 1rem;
  letter-spacing: 0.18em; color: var(--orange); min-height: 1.4rem; text-align: center;
}

.input-status {
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.07em;
  text-align: center; padding: 0.2rem 0.5rem; border-radius: 3px; transition: all 0.2s;
}
.input-status.neutral { color: var(--text3); }
.input-status.correct { color: var(--correct); background: var(--correct-dim); }
.input-status.wrong   { color: var(--wrong);   background: var(--wrong-dim); }
.input-status.pending { color: var(--pending); }

/* ── CLICK PADS — clickable left=DASH / right=DOT buttons ── */
.mouse-pad-area {
  display: flex; gap: 0; flex-shrink: 0; height: 64px;
  border-radius: 8px; overflow: hidden; border: 1px solid var(--border);
}
.click-pad {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; cursor: pointer; transition: all 0.1s; position: relative; overflow: hidden;
}
.click-pad::before {
  content: ''; position: absolute; inset: 0; opacity: 0; transition: opacity 0.1s;
}
.dash-pad           { background: rgba(255,140,0,0.06); border-right: 1px solid var(--border); }
.dash-pad::before   { background: var(--dash-dim); }
.dot-pad            { background: rgba(0,191,255,0.06); }
.dot-pad::before    { background: var(--dot-dim); }
.dash-pad:active::before, .dash-pad.pressed::before,
.dot-pad:active::before,  .dot-pad.pressed::before { opacity: 1; }
.pad-symbol { font-family: var(--font-mono); font-size: 1.3rem; line-height: 1; transition: all 0.1s; }
.dash-pad .pad-symbol { color: var(--dash-color); }
.dot-pad  .pad-symbol { color: var(--dot-color); }
.dash-pad:active .pad-symbol, .dash-pad.pressed .pad-symbol { transform: scale(1.25); text-shadow: 0 0 16px var(--dash-color); }
.dot-pad:active  .pad-symbol, .dot-pad.pressed  .pad-symbol { transform: scale(1.25); text-shadow: 0 0 16px var(--dot-color); }
.pad-label { font-family: var(--font-mono); font-size: 0.52rem; letter-spacing: 0.07em; }
.dash-pad .pad-label { color: rgba(255,140,0,0.5); }
.dot-pad  .pad-label { color: rgba(0,191,255,0.5); }
.pad-key  { font-size: 0.48rem; opacity: 0.65; }
.pad-divider { width: 1px; background: var(--border); }

/* Row of Confirm / Delete / Skip buttons below the pads */
.action-row { display: flex; gap: 0.4rem; flex-shrink: 0; }
.confirm-btn, .delete-btn {
  flex: 1; border-radius: 6px; padding: 0.45rem 0.4rem;
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.05em;
  cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 0.3rem;
}
.confirm-btn { background: var(--orange-dim); border: 2px solid var(--orange); color: var(--orange); }
.confirm-btn:hover { background: var(--orange); color: var(--bg); }
.delete-btn  { background: var(--wrong-dim);  border: 2px solid var(--wrong);  color: var(--wrong); }
.delete-btn:hover  { background: var(--wrong);  color: var(--bg); }
.action-key {
  background: var(--bg4); border: 1px solid currentColor;
  border-radius: 3px; padding: 0.08rem 0.3rem; font-size: 0.58rem; opacity: 0.7;
}
.skip-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 6px;
  padding: 0.45rem 0.75rem;
  font-family: var(--font-mono); font-size: 0.65rem;
  color: var(--text3); cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.skip-btn:hover { border-color: rgba(255,59,59,0.5); color: var(--wrong); }

.hint-area {
  background: var(--bg4); border: 1px solid rgba(0,255,65,0.18);
  border-radius: 5px; padding: 0.3rem 0.75rem; text-align: center; flex-shrink: 0;
}
.hint-label   { font-size: 0.5rem; color: var(--text2); letter-spacing: 0.1em; font-family: var(--font-mono); margin-bottom: 0.1rem; }
.hint-content { font-family: var(--font-mono); font-size: 0.82rem; color: var(--orange); letter-spacing: 0.14em; }

/* Full-viewport green/red flash on correct/wrong answer */
#flash-overlay {
  position: fixed; inset: 0; z-index: 2; pointer-events: none; opacity: 0;
}
#flash-overlay.flash-success { animation: fl-ok  0.55s ease-out forwards; }
#flash-overlay.flash-error   { animation: fl-err 0.55s ease-out forwards; }
@keyframes fl-ok {
  0%   { opacity: 0; box-shadow: inset 0 0 0px   0px  rgba(34, 197, 94, 0); }
  25%  { opacity: 1; box-shadow: inset 0 0 80px 40px rgba(34, 197, 94, 0.55); }
  100% { opacity: 0; box-shadow: inset 0 0 0px   0px  rgba(34, 197, 94, 0); }
}
@keyframes fl-err {
  0%   { opacity: 0; box-shadow: inset 0 0 0px   0px  rgba(239, 68, 68, 0); }
  25%  { opacity: 1; box-shadow: inset 0 0 80px 40px rgba(239, 68, 68, 0.55); }
  100% { opacity: 0; box-shadow: inset 0 0 0px   0px  rgba(239, 68, 68, 0); }
}

/* ════════════════════════════════════════════════════════════
   FINAL RESULT POPUP — shown after completing all 3 rounds
   ════════════════════════════════════════════════════════════ */
.result-box {
  background: var(--bg3); border: 2px solid var(--orange); border-radius: 12px;
  padding: 1.5rem 1.75rem; max-width: 480px; width: 92%; text-align: center;
  box-shadow: 0 0 60px var(--orange-glow); animation: pop-in 0.35s ease-out;
  max-height: 88vh; overflow-y: auto;
}
.result-confetti  { font-size: 2.4rem; margin-bottom: 0.3rem; animation: confetti-drop 0.5s ease-out; }
@keyframes confetti-drop { from { transform: translateY(-16px) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
.result-title     { font-family: var(--font-mono); font-size: 1.5rem; color: var(--orange); text-shadow: 0 0 25px var(--orange-glow); margin-bottom: 0.2rem; }
.result-sub       { font-size: 0.78rem; color: var(--text2); margin-bottom: 1rem; }
.result-rounds    { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-bottom: 0.875rem; }
.rr-item { background: var(--bg4); border: 1px solid var(--border); border-radius: 7px; padding: 0.6rem 0.3rem; display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }
.rr-badge { font-size: 0.55rem; font-weight: 700; letter-spacing: 0.1em; padding: 0.15rem 0.45rem; border-radius: 10px; }
.rr-badge.easy   { background: var(--r1-dim); color: var(--r1); }
.rr-badge.medium { background: var(--r2-dim); color: var(--r2); }
.rr-badge.hard   { background: var(--r3-dim); color: var(--r3); }
.rr-name  { font-size: 0.6rem; color: var(--text2); }
.rr-score { font-family: var(--font-mono); font-size: 0.95rem; color: var(--orange); font-weight: 700; }
.rr-acc   { font-size: 0.6rem; color: var(--text3); font-family: var(--font-mono); }
.result-total {
  display: flex; gap: 0.875rem; justify-content: center;
  background: var(--bg4); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.875rem; margin-bottom: 0.3rem;
}
.rt-item   { text-align: center; }
.rt-val    { font-family: var(--font-mono); font-size: 2rem; color: var(--orange); font-weight: 700; line-height: 1; }
.rt-label  { font-size: 0.55rem; color: var(--text3); letter-spacing: 0.1em; margin-top: 0.15rem; }

/* ════════════════════════════════════════════════════════════
   BONUS ROUND UI
   Purple theme (#a855f7). Player decodes a full phrase
   without any morse hints. +10 pts per completed phrase.
   ════════════════════════════════════════════════════════════ */
.bonus-header {
  text-align: center; flex-shrink: 0; padding: 0.3rem 0;
}

.bonus-badge {
  display: inline-block; padding: 0.2rem 0.875rem; border-radius: 20px;
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.12em; margin-bottom: 0.3rem;
  background: var(--r4-dim); border: 1px solid var(--r4); color: var(--r4);
}
.bonus-title {
  font-family: var(--font-main); font-size: 1.4rem; font-weight: 700;
  color: var(--r4); text-shadow: 0 0 20px rgba(168,85,247,0.4); line-height: 1; margin-bottom: 0.15rem;
}
.bonus-subtitle { font-family: var(--font-mono); font-size: 0.6rem; color: var(--text3); letter-spacing: 0.1em; }

.bonus-timer-wrap {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 7px; padding: 0.4rem 0.75rem; flex-shrink: 0;
}
.bonus-timer-label {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.25rem;
  font-size: 0.6rem; color: var(--text2); font-family: var(--font-mono); letter-spacing: 0.06em;
}
.bonus-timer-num   { font-family: var(--font-mono); font-size: 1.3rem; color: var(--r4); line-height: 1; font-weight: 700; }
.bonus-timer-track { height: 5px; background: var(--bg4); border-radius: 3px; overflow: hidden; }
.bonus-timer-fill  {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #4a1880, var(--r4));
  border-radius: 3px; transition: width 1s linear, background 0.5s;
}
.bonus-timer-fill.warning { background: linear-gradient(90deg, var(--wrong), #ff8a1a); }

.bonus-phrase-area {
  background: var(--bg3); border: 1px solid rgba(168,85,247,0.25);
  border-radius: 8px; padding: 0.5rem 0.875rem; text-align: center; flex-shrink: 0;
}
.bonus-phrase-label {
  font-family: var(--font-mono); font-size: 0.5rem; color: var(--text3);
  letter-spacing: 0.15em; margin-bottom: 0.25rem;
}
.bonus-word-progress {
  display: flex; gap: 3px; justify-content: center; flex-wrap: wrap; margin-top: 0.3rem;
}

.bonus-input-stage {
  background: var(--bg3); border: 2px solid rgba(168,85,247,0.3); border-radius: 8px;
  padding: 0.5rem 0.875rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  flex-shrink: 0; transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 65px; justify-content: center;
}
.bonus-input-stage.state-correct { border-color: var(--correct); box-shadow: 0 0 16px var(--correct-dim); }
.bonus-input-stage.state-wrong   { border-color: var(--wrong);   box-shadow: 0 0 16px var(--wrong-dim); animation: shake 0.3s ease; }
.bonus-input-stage.state-pending { border-color: var(--pending); box-shadow: 0 0 10px var(--pending-dim); }

.bwletter {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 0.25rem 0.4rem; background: var(--bg4);
  border: 1px solid var(--border); border-radius: 4px;
  min-width: 26px; transition: all 0.18s;
}
.bwletter.done-correct { border-color: var(--correct); background: var(--correct-dim); }
.bwletter.done-wrong   { border-color: var(--wrong);   background: var(--wrong-dim); }
.bwletter.current      { border-color: var(--r4); background: rgba(168,85,247,0.15); box-shadow: 0 0 10px rgba(168,85,247,0.4); transform: scale(1.12); }
.bwletter.space-gap    { background: transparent; border-color: transparent; min-width: 10px; }
.bwl-char  { font-family: var(--font-mono); font-size: 0.85rem; color: var(--text2); font-weight: 700; }
.bwletter.done-correct .bwl-char { color: var(--correct); }
.bwletter.done-wrong   .bwl-char { color: var(--wrong); }
.bwletter.current      .bwl-char { color: var(--r4); font-size: 1rem; }

.bonus-result-box {
  background: var(--bg3); border: 2px solid var(--r4); border-radius: 12px;
  padding: 1.5rem 1.75rem; max-width: 480px; width: 92%; text-align: center;
  box-shadow: 0 0 60px rgba(168,85,247,0.35); animation: pop-in 0.35s ease-out;
  max-height: 88vh; overflow-y: auto;
}
.bonus-result-title {
  font-family: var(--font-main); font-size: 1.4rem; color: var(--r4);
  text-shadow: 0 0 25px rgba(168,85,247,0.4); margin-bottom: 0.2rem;
}
.bonus-result-phrase {
  font-family: var(--font-mono); font-size: 0.88rem; color: var(--text);
  background: var(--bg4); border: 1px solid var(--border); border-radius: 6px;
  padding: 0.5rem 0.75rem; margin: 0.5rem 0; letter-spacing: 0.08em;
}
.bonus-score-breakdown {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; margin: 0.75rem 0;
}
.bsb-item {
  background: var(--bg4); border: 1px solid var(--border); border-radius: 7px;
  padding: 0.5rem 0.2rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
}
.bsb-label { font-size: 0.5rem; color: var(--text3); letter-spacing: 0.08em; }
.bsb-val   { font-family: var(--font-mono); font-size: 0.9rem; font-weight: 700; }
.bsb-val.orange { color: var(--success); }
.bsb-val.purple { color: var(--r4); }
.bonus-grand-total {
  background: var(--bg4); border: 1px solid rgba(168,85,247,0.3);
  border-radius: 8px; padding: 0.875rem; margin: 0.5rem 0;
}
.bgt-val   { font-family: var(--font-main); font-size: 2.2rem; color: var(--r4); font-weight: 700; line-height: 1; }
.bgt-label { font-size: 0.55rem; color: var(--text3); letter-spacing: 0.1em; margin-top: 0.15rem; }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   1100px — shrink side panel widths
   900px  — collapse to single-column, hide side panels,
            show FAB drawer buttons instead
   500px  — tighten padding and font sizes
   360px  — minimal padding for very small phones
   ════════════════════════════════════════════════════════════ */

/* ── 1100px: slightly narrower panels ── */
@media (max-width: 1100px) {
  .home-layout { grid-template-columns: 220px 1fr 220px; }
  .game-layout  { grid-template-columns: 200px 1fr 200px; }
}

/* ── 900px: tablet/phone — single column, panels collapse ── */
@media (max-width: 900px) {
  
  .home-layout,
  .game-layout {
    grid-template-columns: 1fr;
  }

  
  .panel-left,
  .panel-left.home-panel {
    position: static;
    height: auto;
    max-height: none;
    overflow-y: visible;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  
  .home-center { overflow-y: visible; }

  
  .game-center,
  .bonus-center {
    min-height: unset;
    overflow-y: visible;
  }

  
  .game-right,
  .home-panel.panel-right {
    position: static;
    height: auto;
    max-height: 320px; 
    overflow-y: auto;
  }

  
  .game-panel {
    position: static;
    height: auto;
    max-height: 280px;
    overflow-y: auto;
  }

  
  .home-layout .panel-right {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 300px;
    overflow-y: auto;
  }

  
  .home-grid  { grid-template-columns: repeat(3, 1fr); }
  .game-grid  { grid-template-columns: repeat(3, 1fr); }

  /* Equal-width side slots so game-stats centres correctly */
  .topbar-left,
  .topbar-right {
    flex: 1;
    min-width: 0;
  }
  .topbar-left  { justify-content: flex-start; }
  .topbar-right { justify-content: flex-end; }
  .game-stats   { flex: 2; }

  /* Bigger DASH / DOT tap targets on mobile */
  .mouse-pad-area { height: 112px; }
  .pad-symbol     { font-size: 2.2rem; }
  .pad-label      { font-size: 0.7rem; }
  .pad-key        { font-size: 0.6rem; }
  .action-row     { gap: 0.5rem; }
  .confirm-btn, .delete-btn, .skip-btn {
    padding: 0.65rem 0.5rem;
    font-size: 0.78rem;
  }
}

/* ── 500px: small phones — tighten spacing ── */
@media (max-width: 500px) {
  .home-center,
  .game-center,
  .bonus-center {
    padding: 0.4rem 0.5rem 1rem;
    gap: 0.35rem;
  }

  
  .home-grid,
  .game-grid  { grid-template-columns: repeat(3, 1fr); }

  .target-display  { font-size: 1.8rem; }
  .mouse-pad-area  { height: 96px; }
  .pad-symbol      { font-size: 1.9rem; }
  .pad-label       { font-size: 0.62rem; }
  .result-rounds   { grid-template-columns: 1fr; }
  .bonus-score-breakdown { grid-template-columns: repeat(2, 1fr); }

  /* Force equal-width side slots so game-stats is truly centred */
  .topbar-left,
  .topbar-right {
    flex: 1;
    min-width: 0;
  }
  .topbar-left  { justify-content: flex-start; }
  .topbar-right { justify-content: flex-end; }
  .game-stats   { flex: 2; }
}

/* ── 360px: very small phones ── */
@media (max-width: 360px) {
  .game-center,
  .bonus-center,
  .home-center { padding: 0.3rem; gap: 0.25rem; }
  .timer-num   { font-size: 0.9rem; }
}

/* ════════════════════════════════════════════════════════════
   MOBILE FAB BAR
   Fixed bottom-right floating buttons on narrow screens.
   Hidden on desktop; visible via the 900px media query below.
   Tap REF to open the morse reference drawer,
   tap RANKS to open the leaderboard drawer.
   ════════════════════════════════════════════════════════════ */
.mobile-fab-bar {
  
  display: none;
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  left: auto;
  z-index: 600;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
  
  pointer-events: none;
}

/* Hidden entirely on the Splash and Hero screens */
.mobile-fab-bar.fab-hidden {
  display: none !important;
}

/* ── Toggle button — keyboard icon, always visible at the bottom of the stack ── */
.mobile-fab-toggle {
  pointer-events: auto;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--bg3);
  border: 1.5px solid var(--border2);
  color: var(--orange);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 12px var(--orange-dim);
  -webkit-tap-highlight-color: transparent;
}
.mobile-fab-toggle:hover,
.mobile-fab-toggle.open {
  border-color: var(--orange);
  background: var(--orange-dim);
  box-shadow: 0 4px 24px rgba(0,0,0,0.65), 0 0 18px var(--orange-glow);
}
.mobile-fab-toggle .mob-fab-icon { font-size: 1.4rem; line-height: 1; }

/* ── Expandable list — hidden until the toggle is tapped ── */
.mobile-fab-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(0.92);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}
.mobile-fab-bar.expanded .mobile-fab-list {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* The buttons themselves default to pointer-events:auto (see .mobile-fab
   below), so this list-scoped override is required to actually block
   taps while the list is collapsed — otherwise the invisible buttons
   still sit there clickable ("ghost touch"). */
.mobile-fab-list .mobile-fab {
  pointer-events: none;
}
.mobile-fab-bar.expanded .mobile-fab-list .mobile-fab {
  pointer-events: auto;
}

.mobile-fab {
  pointer-events: auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.9rem;
  background: var(--bg3);
  border: 1.5px solid var(--border2);
  border-radius: 24px;
  color: var(--orange);
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.18s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 12px var(--orange-dim);
  
  -webkit-tap-highlight-color: transparent;
}
.mobile-fab:hover,
.mobile-fab.active {
  background: var(--orange-dim);
  border-color: var(--orange);
  box-shadow: 0 4px 24px rgba(0,0,0,0.65), 0 0 18px var(--orange-glow);
  transform: translateY(-2px);
}
.mob-fab-icon  { font-size: 1rem; line-height: 1; }
.mob-fab-label { font-size: 0.63rem; }

/* Danger variant for the Data Manager FAB */
.mob-fab-danger {
  color: var(--wrong);
  border-color: rgba(239,68,68,0.35);
  box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 12px rgba(239,68,68,0.12);
}
.mob-fab-danger:hover,
.mob-fab-danger.active {
  background: var(--wrong-dim);
  border-color: var(--wrong);
  box-shadow: 0 4px 24px rgba(0,0,0,0.65), 0 0 18px rgba(239,68,68,0.3);
}

/* Gold variant for the Donate FAB */
.mob-fab-gold {
  color: var(--orange);
  border-color: rgba(255,138,26,0.4);
  box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 12px var(--orange-dim);
}
.mob-fab-gold:hover,
.mob-fab-gold.active {
  background: var(--orange-dim);
  border-color: var(--orange);
  box-shadow: 0 4px 24px rgba(0,0,0,0.65), 0 0 18px var(--orange-glow);
}

/* Gray variant for the Terms & Conditions FAB */
.mob-fab-gray {
  color: var(--text2);
  border-color: var(--border2);
}
.mob-fab-gray:hover,
.mob-fab-gray.active {
  background: var(--bg4);
  border-color: var(--text2);
  color: var(--text);
}

.mob-backdrop {
  position: fixed;
  inset: 0;
  z-index: 700;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(3px);
  
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.mob-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* Bottom-sheet drawer that slides up from below the screen */
.mob-drawer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 800;
  background: var(--panel);
  border-top: 2px solid var(--border2);
  border-radius: 18px 18px 0 0;
  max-height: 75dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.75);
  
  transform: translateY(100%);
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.mob-drawer.open {
  transform: translateY(0);
  pointer-events: auto;
}

.mob-drawer-handle {
  width: 38px;
  height: 4px;
  background: var(--border2);
  border-radius: 2px;
  margin: 0.55rem auto 0;
  flex-shrink: 0;
}

.mob-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 1rem 0.4rem;
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--orange);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mob-drawer-close {
  background: none;
  border: 1px solid var(--border2);
  border-radius: 4px;
  color: var(--text3);
  cursor: pointer;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
  transition: all 0.15s;
  
  -webkit-tap-highlight-color: transparent;
}
.mob-drawer-close:hover {
  background: var(--wrong-dim);
  border-color: var(--wrong);
  color: var(--wrong);
}

.mob-grid {
  grid-template-columns: repeat(5, 1fr);
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.75rem 1.5rem;
  align-content: start;
}

#mob-lb-drawer .lb-tabs        { padding: 0.4rem 0.75rem 0; flex-shrink: 0; }
#mob-lb-drawer .leaderboard-list { flex: 1; overflow-y: auto; padding: 0.35rem 0.75rem 1.5rem; }

/* ── 900px (2nd block): show FAB bar, hide side panels entirely ── */
@media (max-width: 900px) {
  
  .mobile-fab-bar { display: flex; }

  
  .panel-left,
  .panel-left.home-panel,
  .game-right,
  .home-panel.panel-right,
  .game-panel.panel-left { display: none !important; }

  
  .home-layout,
  .game-layout { grid-template-columns: 1fr; min-height: auto; }

  
  .home-center,
  .game-center,
  .bonus-center { min-height: unset; overflow-y: auto; }

  
  .home-layout,
  .game-layout { align-content: start; }
}

/* ════════════════════════════════════════════════════════════
   VOLUME CONTROL
   Small speaker button; hovering reveals a slider that
   floats to the left via absolute positioning.
   Three instances: home / game / bonus screens all sync.
   ════════════════════════════════════════════════════════════ */
.home-volume-row {
  display: flex;
  justify-content: flex-end;
  padding: 0.4rem 0.4rem 0;
  flex-shrink: 0;
}
.volume-control {
  position: relative;
  flex-shrink: 0;
  
  /* padding-left: 170px;
  margin-left: -170px; */
}
.volume-btn {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  color: #aaa;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  padding: 0;
  position: relative;
  z-index: 1;
}
.volume-control:hover .volume-btn,
.volume-btn:hover {
  background: rgba(255,140,0,0.18);
  border-color: var(--orange);
  color: var(--orange);
}
.volume-btn.muted { color: #444; border-color: rgba(255,255,255,0.08); }

.volume-slider-wrap {
  position: absolute;
  top: 50%;
  right: calc(100% - 160px);
  transform: translateY(75%) translateX(-65%) scaleX(0.9);
  transform-origin: right center;
  background: rgba(8,8,14,0.97);
  border: 1px solid rgba(255,140,0,0.5);
  border-radius: 10px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 9001;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  box-shadow: 0 4px 24px rgba(0,0,0,0.8);
  white-space: nowrap;
}
/* JS adds .vol-open to .volume-control to show the slider */
.volume-control.vol-open .volume-slider-wrap {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(75%) translateX(-65%) scaleX(1);
}
.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 120px; height: 5px;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--orange);
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.25);
  box-shadow: 0 0 10px rgba(255,140,0,0.7);
}
.volume-slider::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--orange);
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.25);
  box-shadow: 0 0 10px rgba(255,140,0,0.7);
}
.volume-pct {
  font-family: 'Orbitron', monospace;
  font-size: 0.6rem;
  color: var(--orange);
  min-width: 34px;
  text-align: right;
}

/* Pop animation for dot/dash shapes inside the tile popup when played */
.dot-circle, .dash-rect {
  transition: background 0.05s, box-shadow 0.06s, transform 0.06s;
}
.dot-circle.sym-active {
  background: #fff !important;
  box-shadow: 0 0 18px 6px rgba(0,191,255,1), 0 0 40px rgba(0,191,255,0.6) !important;
  transform: scale(1.5) !important;
}
.dash-rect.sym-active {
  background: #fff !important;
  box-shadow: 0 0 20px 6px rgba(255,140,0,1), 0 0 44px rgba(255,140,0,0.6) !important;
  transform: scale(1.1) !important;
}

.skip-btn kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 4px;
  line-height: 1.6;
  vertical-align: middle;
  opacity: 0.75;
}