/* Phone fix: pop-up boxes scroll when their content is taller than the screen,
   so the buttons at the bottom can always be reached. */
.modal:not(#leaderboard-modal) {
  align-items: flex-start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  height: 100vh;
  height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 0 max(16px, env(safe-area-inset-bottom));
  box-sizing: border-box;
}
.modal:not(#leaderboard-modal) > .modal-content {
  margin: auto;          /* stays centered when it fits, scrolls when it doesn't */
  flex-shrink: 0;
  max-height: none;
}
.home-card { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

/* Links to the guide pages on the home menu */
.home-site-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin-top: 18px; padding-top: 12px; border-top: 1px solid rgba(56, 189, 248, 0.2); font-size: 0.95rem; }
.home-site-links a { color: #7dd3fc; text-decoration: none; font-weight: 600; }
.home-site-links a:hover { color: #fff; text-decoration: underline; }

/* ==========================================
   COMPACT HOME MENU: a smaller card so the moon scene shows and nothing scrolls
========================================== */
#home-screen .home-card {
  max-width: 440px;
  padding: 22px 26px 16px;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  box-sizing: border-box;
}
#home-screen .glow-title { font-size: clamp(1.5rem, 4.2vw, 2rem); margin: 0 0 10px; }
#home-screen .game-desc { font-size: 0.95rem; line-height: 1.35; margin: 0 0 10px; }
#home-screen .space-btn { padding: 10px 14px; font-size: 0.88rem; margin-bottom: 8px; }
#home-screen #daily-launch-btn { padding: 13px 14px; font-size: 1rem; }
#daily-menu .daily-home-badge { margin-bottom: 10px; }
#daily-menu .daily-home-schedule { margin: 0 0 8px; gap: 6px; }
#daily-menu .daily-home-schedule .dhs-chip { font-size: 0.72rem; padding: 2px 8px; }
#daily-menu .daily-home-stats { font-size: 0.92rem; gap: 4px 12px; margin-bottom: 10px; }
#home-screen #show-race-btn { margin-top: 4px; }
#home-screen #show-race-btn span { font-size: 0.8rem; margin-top: 1px; }
#home-screen #show-practice-btn { margin-top: 0; }
.home-btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.home-btn-row .space-btn { margin: 0 0 8px; padding-left: 6px; padding-right: 6px; font-size: 0.8rem; }
#elim-menu .theme-switch { margin-bottom: 8px; }
#elim-menu .mode-picker { margin-bottom: 8px; }
#home-screen #home-subtitle { display: none; }
#home-screen .home-stats { margin: 0 0 10px; font-size: 0.95rem; }
#home-screen .home-back-btn { background: transparent; border-color: transparent; box-shadow: none; padding: 4px; font-size: 0.75rem; margin: 0; color: #7dd3fc; width: auto; }
#home-screen .home-back-btn:hover { color: #fff; transform: none; }
#home-screen .home-site-links { margin-top: 10px; padding-top: 8px; font-size: 0.8rem; gap: 2px 12px; }
@media (max-height: 640px) {
  #home-screen .home-card { padding: 16px 20px 12px; }
  #home-screen .game-desc { font-size: 0.88rem; }
  #daily-menu .daily-home-schedule { display: none; }
}
#elim-menu .mode-pick { flex-direction: row; gap: 6px; padding: 7px 4px; font-size: 0.72rem; letter-spacing: 1px; }
#elim-menu .theme-pick { padding-top: 6px; padding-bottom: 6px; }

/* Home page "About the game" section, below the first screen */
#home-screen.active { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
#home-about { position: absolute; top: 100vh; left: 0; width: 100%; z-index: 6; background: #020617; border-top: 1px solid rgba(56, 189, 248, 0.25); color: #e2e8f0; font-family: 'Rajdhani', system-ui, sans-serif; font-size: 18px; line-height: 1.6; }
#home-about .ha-inner { max-width: 820px; margin: 0 auto; padding: 40px 22px 48px; }
#home-about h2 { font-family: 'Orbitron', sans-serif; font-size: clamp(1.3rem, 3.4vw, 1.8rem); line-height: 1.25; margin: 0 0 14px; color: #fff; }
#home-about h3 { font-family: 'Orbitron', sans-serif; font-size: 1.05rem; margin: 30px 0 8px; color: #bae6fd; }
#home-about p, #home-about li { color: #cbd5e1; }
#home-about ul { padding-left: 1.3em; }
#home-about li { margin: 6px 0; }
#home-about a { color: #38bdf8; }
#home-about .ha-cta { text-align: center; margin-top: 34px; }
#home-about .ha-top { font-family: 'Orbitron', sans-serif; font-weight: 700; text-decoration: none; }
#home-about .ha-foot { text-align: center; color: #64748b; font-size: 0.9rem; margin-top: 18px; }
@media (max-width: 600px) { #home-about { font-size: 16.5px; } #home-about .ha-inner { padding: 28px 16px 36px; } }
/* Home page ad: first thing below the menu, clearly labelled, away from game buttons */
#home-about .home-ad { margin: 0 auto 34px; padding: 10px; min-height: 120px; border: 1px dashed rgba(56, 189, 248, 0.3); border-radius: 12px; max-width: 100%; overflow: hidden; }
#home-about .home-ad-label { display: block; font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: #64748b; margin-bottom: 6px; }

/* REVERSE TRIVIA button on the home screen */

#home-screen #show-duo-btn { display: block; margin-top: 10px; text-decoration: none; text-align: center; color: #fff; background: linear-gradient(135deg, #fb7185, #c084fc 50%, #60a5fa); border: none; box-shadow: 0 0 20px rgba(192, 132, 252, 0.4); }
#home-screen #show-duo-btn span { display: block; font-family: 'Rajdhani', sans-serif; font-size: 0.8rem; font-weight: 700; letter-spacing: 0; color: rgba(255, 255, 255, 0.85); margin-top: 1px; }
#home-screen #show-duo-btn .race-new { font-style: normal; font-size: 0.62rem; letter-spacing: 1.5px; vertical-align: middle; background: #04111f; color: #fde047; padding: 2px 6px; border-radius: 6px; margin-left: 4px; }

/* home screen sound switches */
#home-screen .home-sound-row { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: -4px 0 12px; }
#home-screen .home-sound-btn { font: 700 0.85rem 'Rajdhani', sans-serif; letter-spacing: .3px; color: #e2e8f0; background: rgba(56, 189, 248, 0.14); border: 1px solid rgba(56, 189, 248, 0.45); border-radius: 999px; padding: 5px 12px; cursor: pointer; transition: background .15s, opacity .15s; }
#home-screen .home-sound-btn:hover { background: rgba(56, 189, 248, 0.28); }
#home-screen .home-sound-btn b { color: #4ade80; }
#home-screen .home-sound-btn.off { opacity: .7; border-color: rgba(148, 163, 184, 0.45); background: rgba(148, 163, 184, 0.1); }
#home-screen .home-sound-btn.off b { color: #f87171; }
