/* ==========================================================================
   GRAVITY LAB — POLISHED ARCADE STYLESHEET
   ========================================================================== */

/* ==========================================================================
   1. VARIABLES & DESIGN TOKENS
   ========================================================================== */
:root {
  --bg-deep: #05070c;
  --bg-panel: rgba(13, 18, 30, 0.85);
  --bg-card: rgba(18, 24, 38, 0.9);
  --border-light: rgba(255, 255, 255, 0.1);
  --border-active: rgba(0, 243, 255, 0.4);
  --neon-cyan: #00f3ff;
  --neon-purple: #bd00ff;
  --neon-pink: #ff007c;
  --neon-green: #00ff66;
  --neon-yellow: #ffaa00;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --color-earth: #3b82f6;
  --color-moon: #9ca3af;
  --color-mars: #ef4444;
  --color-zero: #06b6d4;
  --color-reverse: #ec4899;
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --shadow-neon: 0 0 15px rgba(0, 243, 255, 0.25);
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   2. RESET & BASE
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  position: fixed;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-deep);
  color: var(--text-primary);
  background-image:
    radial-gradient(circle at 50% 10%, rgba(20, 35, 65, 0.4) 0%, transparent 60%),
    radial-gradient(circle at 90% 90%, rgba(30, 10, 50, 0.3) 0%, transparent 50%);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}

.font-mono { font-family: var(--font-mono); }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--neon-cyan); }

/* Utilities */
.hidden { display: none !important; }
.text-cyan { color: var(--neon-cyan); }
.text-pink { color: var(--neon-pink); }
.text-yellow { color: var(--neon-yellow); }
.text-red { color: #ef4444; }

/* ==========================================================================
   3. APP CONTAINER & HEADER
   ========================================================================== */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

.app-header {
  height: 52px;
  background: rgba(7, 10, 18, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 10;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 1.5px;
}

.logo-icon {
  color: var(--neon-cyan);
  filter: drop-shadow(0 0 6px rgba(0, 243, 255, 0.6));
  font-size: 1.3rem;
  animation: rotateLogo 10s linear infinite;
}

@keyframes rotateLogo {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.logo-accent {
  color: var(--neon-purple);
  filter: drop-shadow(0 0 6px rgba(189, 0, 255, 0.6));
}

.header-game-info {
  display: flex;
  align-items: center;
}

.header-score-group {
  display: flex;
  gap: 16px;
}

.header-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.header-stat-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.8px;
}

.header-stat-value {
  font-size: 1.05rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 6px rgba(0, 243, 255, 0.4);
  font-weight: 700;
}

/* ==========================================================================
   4. CONTAINED ARCADE GAME VIEWPORT (PROPORTIONAL ASPECT-RATIO BOX)
   ========================================================================== */
.game-main {
  width: 100%;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  padding: 8px 12px 28px;
  background: transparent;
}

.game-viewport-container {
  width: 100%;
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  max-width: 100%;
  max-height: 100%;
}

/* Fixed aspect ratio box scaled via JS / CSS */
.game-viewport {
  position: relative;
  overflow: hidden;
  background-color: #030509;
  touch-action: none;
  width: 1000px;
  height: 550px;
  max-width: 100%;
  max-height: 100%;
  border-radius: 14px;
  border: 1px solid rgba(0, 243, 255, 0.25);
  box-shadow: 0 0 25px rgba(0, 243, 255, 0.1), 0 15px 40px rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.game-viewport.shake {
  animation: screenShake 0.3s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes screenShake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ==========================================================================
   5. GAME HUD
   ========================================================================== */
.game-hud {
  position: absolute;
  top: 12px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 18px;
  pointer-events: none;
  z-index: 10;
}

.hud-left, .hud-right {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hud-right { align-items: flex-end; }

.hud-center {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.hud-score-display, .hud-highscore-display {
  display: flex;
  flex-direction: column;
  background: rgba(10, 15, 26, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: 6px;
  min-width: 85px;
}

.hud-score-label, .hud-highscore-label {
  font-size: 0.58rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.8px;
}

.hud-score-value, .hud-highscore-value {
  font-size: 1.1rem;
  color: var(--text-primary);
  font-weight: 700;
}

.hud-score-value {
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0, 243, 255, 0.4);
}

.hud-fps {
  font-size: 0.65rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
}

.gravity-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(10, 15, 26, 0.8);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-active);
  padding: 5px 14px;
  border-radius: 30px;
  box-shadow: 0 0 12px rgba(0, 243, 255, 0.12);
}

#gravity-arrow {
  font-size: 1.1rem;
  color: var(--neon-cyan);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.gravity-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ==========================================================================
   6. GRAVITY NOTIFICATION TOAST
   ========================================================================== */
.gravity-notification {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(4, 8, 16, 0.9);
  backdrop-filter: blur(12px);
  padding: 10px 22px;
  border-radius: 30px;
  border: 1px solid var(--border-active);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 243, 255, 0.5);
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  white-space: nowrap;
}

.gravity-notification.show { opacity: 1; }

/* ==========================================================================
   7. SCORE POPUPS
   ========================================================================== */
.score-popups {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 15;
}

.score-popup {
  position: absolute;
  color: var(--neon-cyan);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.25rem;
  text-shadow: 0 0 8px rgba(0, 243, 255, 0.8);
  pointer-events: none;
  animation: scoreFloat 0.9s forwards cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes scoreFloat {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  20% { transform: translateY(-15px) scale(1.1); opacity: 1; }
  100% { transform: translateY(-45px) scale(1); opacity: 0; }
}

/* ==========================================================================
   8. BUTTONS
   ========================================================================== */
.btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: var(--transition-smooth);
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  line-height: 1.2;
}

.btn-primary {
  background: linear-gradient(135deg, var(--neon-cyan), #00bfff);
  color: #030712;
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.25);
  border-color: rgba(0, 243, 255, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 18px rgba(0, 243, 255, 0.45);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-light);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-glass {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-glass:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(0, 243, 255, 0.35);
  box-shadow: 0 0 12px rgba(0, 243, 255, 0.15);
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.15rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close:hover { color: var(--neon-pink); }

/* ==========================================================================
   9. POPUP & MODAL SYSTEM (CONSTRAINED & SCROLLABLE)
   ========================================================================== */
.game-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 4, 8, 0.88);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 10px;
  box-sizing: border-box;
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay-content {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  max-width: 100%;
  max-height: 100%;
}

.glass-card {
  background: rgba(11, 16, 28, 0.94);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6), 0 0 25px rgba(0, 243, 255, 0.1);
  border-radius: 12px;
  overflow: hidden;
  max-width: min(480px, 96%);
  max-height: min(480px, 94%);
  display: flex;
  flex-direction: column;
}

.overlay-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.overlay-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 7px;
}

.overlay-header h2 i { color: var(--neon-cyan); font-size: 1rem; }

.overlay-body {
  padding: 12px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.overlay-footer {
  padding: 8px 16px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

/* ==========================================================================
   10. SCREEN: DEVICE SELECTION
   ========================================================================== */
.device-content {
  width: min(440px, 96%);
  max-height: min(430px, 94%);
}

.device-body {
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 16px;
}

.device-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
}

.device-subtitle {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: -4px;
}

.device-options {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  margin-top: 4px;
}

.device-card {
  flex: 1 1 130px;
  max-width: 170px;
  padding: 16px 12px;
  border-radius: 10px;
  background: rgba(16, 23, 38, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-light);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: var(--transition-smooth);
  color: var(--text-primary);
  font-family: var(--font-sans);
}

.device-card:hover {
  border-color: var(--neon-cyan);
  box-shadow: var(--shadow-neon);
  transform: translateY(-2px);
}

.device-card:active { transform: scale(0.98); }

.device-card-icon {
  font-size: 2rem;
  color: var(--neon-cyan);
}

.device-card-label {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 1px;
}

.device-card-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ==========================================================================
   11. SCREEN: MAIN MENU
   ========================================================================== */
.menu-bg-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
}

.menu-content {
  position: relative;
  z-index: 1;
  align-items: center;
  gap: 12px;
  width: min(420px, 96%);
  max-height: min(460px, 95%);
  padding: 16px 18px;
  text-align: center;
  overflow-y: auto;
}

.menu-logo {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.menu-logo-icon {
  font-size: 2.3rem;
  color: var(--neon-cyan);
  filter: drop-shadow(0 0 12px rgba(0, 243, 255, 0.6));
  margin-bottom: 4px;
  animation: rotateLogo 10s linear infinite;
}

.menu-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 2px;
  line-height: 1.1;
}

.menu-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 2px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
  max-width: 220px;
}

.menu-buttons .btn {
  padding: 8px 14px;
  font-size: 0.88rem;
  width: 100%;
}

.menu-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.menu-fact-box {
  background: rgba(0, 243, 255, 0.04);
  border: 1px solid rgba(0, 243, 255, 0.15);
  border-left: 3px solid var(--neon-cyan);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 340px;
  width: 100%;
  text-align: left;
  box-sizing: border-box;
  cursor: pointer;
  font-family: var(--font-sans);
  color: inherit;
  outline: none;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.menu-fact-box:hover {
  background: rgba(0, 243, 255, 0.08);
  border-color: rgba(0, 243, 255, 0.35);
  box-shadow: 0 0 14px rgba(0, 243, 255, 0.15);
}

.menu-fact-box:active {
  transform: scale(0.97);
  background: rgba(0, 243, 255, 0.12);
  border-color: rgba(0, 243, 255, 0.5);
  box-shadow: 0 0 20px rgba(0, 243, 255, 0.25);
}

.menu-fact-box:focus-visible {
  box-shadow: 0 0 0 2px var(--neon-cyan), 0 0 14px rgba(0, 243, 255, 0.2);
  border-color: var(--neon-cyan);
}

.fact-box-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fact-box-header i {
  color: var(--neon-cyan);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.fact-box-title {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--neon-cyan);
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.fact-box-text {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.35;
  margin: 0;
  transition: opacity 0.2s ease;
}

.fact-box-text.fade-out {
  opacity: 0;
}

.fact-box-hint {
  font-size: 0.58rem;
  color: var(--text-muted);
  text-align: right;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.menu-fact-box:hover .fact-box-hint {
  opacity: 1;
  color: var(--neon-cyan);
}

.menu-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  animation: pulseOpacity 2s infinite ease-in-out;
}

@keyframes pulseOpacity {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Shahriar Fact Card — purple/pink accent variant */
.shahriar-fact-box {
  border-left-color: var(--neon-purple);
  background: rgba(189, 0, 255, 0.04);
  border-color: rgba(189, 0, 255, 0.15);
}

.shahriar-fact-box:hover {
  background: rgba(189, 0, 255, 0.08);
  border-color: rgba(189, 0, 255, 0.35);
  box-shadow: 0 0 14px rgba(189, 0, 255, 0.15);
}

.shahriar-fact-box:active {
  background: rgba(189, 0, 255, 0.12);
  border-color: rgba(189, 0, 255, 0.5);
  box-shadow: 0 0 20px rgba(189, 0, 255, 0.25);
}

.shahriar-fact-box:focus-visible {
  box-shadow: 0 0 0 2px var(--neon-purple), 0 0 14px rgba(189, 0, 255, 0.2);
  border-color: var(--neon-purple);
}

.shahriar-fact-box .fact-box-header i,
.shahriar-fact-box .fact-box-title {
  color: var(--neon-purple);
}

.shahriar-fact-box:hover .fact-box-hint {
  color: var(--neon-purple);
}

/* ==========================================================================
   12. SCREEN: INSTRUCTIONS
   ========================================================================== */
.instructions-content {
  width: min(480px, 96%);
  max-height: min(450px, 94%);
}

.instructions-body {
  padding: 12px 16px;
  gap: 8px;
}

.instruction-step {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 8px 10px;
}

.instruction-step h3 {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--neon-cyan);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.instruction-step p {
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

kbd {
  font-family: var(--font-mono);
  background: #111827;
  border: 1px solid #374151;
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 0.7rem;
  color: #e5e7eb;
}

/* ==========================================================================
   13. SCREEN: SETTINGS
   ========================================================================== */
.settings-content {
  width: min(460px, 96%);
  max-height: min(460px, 94%);
}

.settings-body {
  padding: 12px 16px;
  gap: 12px;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--neon-cyan);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--border-light);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-row label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.slider-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  cursor: pointer;
}

.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--neon-cyan);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(0, 243, 255, 0.4);
}

.settings-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--neon-cyan);
  cursor: pointer;
  border: none;
}

.settings-value {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 32px;
  text-align: right;
}

.color-picker-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.color-picker {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  padding: 0;
}

.color-preview {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.settings-row-themes {
  flex-direction: column;
  align-items: flex-start;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
  margin-top: 4px;
}

.theme-option {
  padding: 5px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  transition: var(--transition-smooth);
}

.theme-option.active {
  border-color: var(--neon-cyan);
  background: rgba(0, 243, 255, 0.1);
  color: var(--text-primary);
  box-shadow: 0 0 8px rgba(0, 243, 255, 0.2);
}

.theme-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.ts-deep-space { background: linear-gradient(135deg, #0a0e1a, #1a1040); }
.ts-bright-sky { background: linear-gradient(135deg, #87ceeb, #4a90d9); }
.ts-sunset { background: linear-gradient(135deg, #ff6b35, #9b2335); }
.ts-galaxy { background: linear-gradient(135deg, #1a0533, #4a1a8a); }
.ts-nebula { background: linear-gradient(135deg, #4a1a6b, #1a6b6b); }
.ts-dark-laboratory { background: linear-gradient(135deg, #0a1a0a, #1a2a1a); }

/* ==========================================================================
   14. SCREEN: HIGH SCORES
   ========================================================================== */
.highscores-content {
  width: min(420px, 96%);
  max-height: min(430px, 94%);
}

.highscores-body {
  padding: 12px 16px;
}

.highscores-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.highscore-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 0.8rem;
}

.highscore-entry:first-child {
  border-color: rgba(255, 170, 0, 0.35);
  background: rgba(255, 170, 0, 0.06);
}

.highscore-rank {
  font-weight: 700;
  color: var(--neon-cyan);
  font-family: var(--font-mono);
  min-width: 25px;
}

.highscore-entry:first-child .highscore-rank { color: var(--neon-yellow); }

.highscore-score {
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.highscore-date {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.highscore-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 16px 0;
  font-style: italic;
  font-size: 0.8rem;
}

/* ==========================================================================
   15. SCREEN: COUNTDOWN
   ========================================================================== */
.countdown-content {
  display: flex;
  justify-content: center;
  align-items: center;
}

.countdown-number {
  font-size: 6.5rem;
  font-weight: 800;
  color: var(--neon-cyan);
  text-shadow: 0 0 35px rgba(0, 243, 255, 0.6);
  animation: countdownPulse 0.8s ease-out forwards;
}

@keyframes countdownPulse {
  0% { transform: scale(1.4); opacity: 0; }
  20% { transform: scale(1); opacity: 1; }
  80% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.85); opacity: 0; }
}

/* ==========================================================================
   16. SCREEN: PAUSE + PC PAUSE BTN + EXIT CONFIRM
   ========================================================================== */

/* Danger button (red) */
.btn-danger {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(185, 28, 28, 0.15));
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  transition: all 0.2s ease;
}
.btn-danger:hover {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.35), rgba(185, 28, 28, 0.25));
  border-color: rgba(239, 68, 68, 0.7);
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.35);
  color: #fff;
}
.btn-danger:active {
  transform: scale(0.97);
}

/* PC Pause button — top-right corner of the game viewport */
.pc-pause-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(0, 243, 255, 0.25);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.72rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.pc-pause-btn:hover {
  background: rgba(0, 243, 255, 0.12);
  border-color: rgba(0, 243, 255, 0.5);
  color: #fff;
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}
.pc-pause-btn:active { transform: scale(0.95); }
.pc-pause-label { font-size: 0.65rem; opacity: 0.7; }

/* Hide PC pause btn in Android mode */
.device-android .pc-pause-btn { display: none !important; }

.pause-content {
  width: min(360px, 92%);
  max-height: min(480px, 92vh);
}

.pause-body {
  padding: 16px;
  align-items: center;
  text-align: center;
  gap: 12px;
}

.pause-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--neon-cyan);
  letter-spacing: 1px;
}

/* Score row inside pause menu */
.pause-score-row {
  display: flex;
  gap: 20px;
  justify-content: center;
  background: rgba(0, 243, 255, 0.05);
  border: 1px solid rgba(0, 243, 255, 0.12);
  border-radius: 8px;
  padding: 8px 16px;
  width: 100%;
  box-sizing: border-box;
}
.pause-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.pause-stat-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.pause-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--neon-cyan);
}

.pause-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 220px;
}

.pause-buttons .btn {
  padding: 9px 14px;
  font-size: 0.9rem;
  width: 100%;
  justify-content: center;
}

.pause-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.pause-hint kbd {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 0.7rem;
}

/* Exit Confirmation modal */
.exit-confirm-content {
  width: min(360px, 92%);
  max-height: min(360px, 92vh);
  text-align: center;
}
.exit-confirm-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fca5a5;
}
.exit-confirm-title i { color: #f87171; }
.exit-confirm-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}
.exit-confirm-msg {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.exit-confirm-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 220px;
}
.exit-confirm-buttons .btn {
  width: 100%;
  justify-content: center;
}

/* Settings Change Warning modal */
.settings-warn-content {
  width: min(420px, 94%);
  max-height: min(560px, 94vh);
  text-align: center;
}
.settings-warn-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #fca5a5;
}
.settings-warn-title i { color: #f87171; }
.settings-warn-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.settings-warn-heading {
  font-size: 0.82rem;
  font-weight: 700;
  color: #fbbf24;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.settings-warn-msg {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
  text-align: left;
}
.settings-warn-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 220px;
  margin-top: 4px;
}
.settings-warn-buttons .btn {
  width: 100%;
  justify-content: center;
}

/* Settings footer with optional Back to Pause */
.settings-footer {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

/* ==========================================================================
   17. SCREEN: GAME OVER (HUMOROUS & COMPACT)
   ========================================================================== */
.gameover-content {
  width: min(420px, 96%);
  max-height: min(450px, 95%);
  padding: 14px 16px;
  align-items: center;
  gap: 8px;
  text-align: center;
  overflow-y: auto;
}

#gameover-face-canvas {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  flex-shrink: 0;
}

.gameover-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: #ff4a4a;
  text-shadow: 0 0 12px rgba(255, 74, 74, 0.4);
  line-height: 1.1;
}

.gameover-funny-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--neon-yellow);
  text-shadow: 0 0 8px rgba(255, 170, 0, 0.3);
  line-height: 1.1;
}

.gameover-new-highscore {
  color: var(--neon-yellow);
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 1px;
  animation: celebrationPulse 1s infinite alternate;
}

@keyframes celebrationPulse {
  from { transform: scale(1); text-shadow: 0 0 10px rgba(255, 170, 0, 0.5); }
  to { transform: scale(1.04); text-shadow: 0 0 18px rgba(255, 170, 0, 0.8); }
}

.gameover-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
}

.gameover-stat {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 5px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.gameover-stat-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.gameover-stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

#gameover-score { color: var(--neon-cyan); }

.gameover-fact {
  background: rgba(0, 243, 255, 0.04);
  border: 1px solid rgba(0, 243, 255, 0.15);
  border-left: 3px solid var(--neon-cyan);
  border-radius: 6px;
  padding: 6px 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
}

.gameover-fact i {
  color: var(--neon-cyan);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.gameover-fact p {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.3;
}

.gameover-buttons {
  display: flex;
  gap: 8px;
  width: 100%;
  flex-wrap: wrap;
}

.gameover-buttons .btn {
  flex: 1 1 120px;
  padding: 9px 12px;
  font-size: 0.88rem;
}

/* ==========================================================================
   18. WATERMARK
   ========================================================================== */
.watermark {
  position: fixed;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.5px;
  pointer-events: none;
  z-index: 200;
  white-space: nowrap;
  text-align: center;
}

/* ==========================================================================
   19. VIRTUAL GAMEPAD / ANDROID MOVEMENT CONTROLS
   ========================================================================== */
.mobile-controls-panel {
  display: none;
  width: 100%;
  max-width: 500px;
  margin-top: 10px;
  padding: 0 10px 4px;
  justify-content: space-between;
  align-items: center;
  z-index: 40;
  flex-shrink: 0;
}

/* D-PAD */
.mobile-dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.dpad-middle-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.mobile-ctrl-btn {
  background: linear-gradient(135deg, rgba(16, 25, 45, 0.85), rgba(8, 14, 28, 0.9));
  backdrop-filter: blur(10px);
  border: 1.5px solid rgba(0, 243, 255, 0.45);
  color: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 243, 255, 0.18), inset 0 0 8px rgba(0, 243, 255, 0.1);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
}

.mobile-dpad .mobile-ctrl-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  font-size: 1.25rem;
}

.mobile-ctrl-btn:active, .mobile-ctrl-btn.active {
  transform: scale(0.92);
  background: linear-gradient(135deg, rgba(0, 243, 255, 0.35), rgba(189, 0, 255, 0.35));
  border-color: #00f3ff;
  box-shadow: 0 0 20px rgba(0, 243, 255, 0.6), inset 0 0 12px rgba(0, 243, 255, 0.3);
  color: #ffffff;
}

/* REVERSE GRAVITY BUTTON */
.mobile-action-group {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-reverse-btn {
  height: 52px;
  padding: 0 18px;
  border-radius: 26px;
  background: linear-gradient(135deg, rgba(0, 243, 255, 0.3), rgba(189, 0, 255, 0.3));
  border: 2px solid rgba(0, 243, 255, 0.65);
  color: #ffffff;
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 1px;
  gap: 8px;
  box-shadow: 0 0 18px rgba(0, 243, 255, 0.3);
}

.mobile-reverse-btn:active, .mobile-reverse-btn.active {
  transform: scale(0.94);
  box-shadow: 0 0 28px rgba(0, 243, 255, 0.7);
  background: linear-gradient(135deg, rgba(0, 243, 255, 0.5), rgba(189, 0, 255, 0.5));
}

/* Floating mobile pause */
.mobile-pause-btn {
  display: none;
  position: fixed;
  top: 58px;
  right: 12px;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(10, 15, 26, 0.8);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-secondary);
  font-size: 0.9rem;
  z-index: 150;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.mobile-pause-btn:active {
  background: rgba(10, 15, 26, 0.95);
  color: var(--text-primary);
}

/* Device Mode Specific Visibility */
.device-pc .mobile-controls-panel,
.device-pc .mobile-pause-btn {
  display: none !important;
}

/* ==========================================================================
   20. ORIENTATION HINT
   ========================================================================== */
.orientation-hint {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(2, 4, 8, 0.94);
  backdrop-filter: blur(12px);
  z-index: 500;
  align-items: center;
  justify-content: center;
}

.orientation-hint.visible { display: flex; }

.orientation-hint-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px;
}

.orientation-icon {
  font-size: 3rem;
  color: var(--neon-cyan);
  filter: drop-shadow(0 0 10px rgba(0, 243, 255, 0.5));
  animation: rotateHint 2.5s ease-in-out infinite;
}

@keyframes rotateHint {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(90deg); }
  75% { transform: rotate(90deg); }
}

.orientation-hint-content p {
  font-size: 1.1rem;
  color: var(--text-primary);
  font-weight: 600;
  max-width: 260px;
  line-height: 1.4;
}

.orientation-dismiss {
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 14px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  transition: var(--transition-smooth);
}

.orientation-dismiss:hover,
.orientation-dismiss:active {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.25);
}

/* ==========================================================================
   21. DESKTOP / MOBILE HINTS
   ========================================================================== */
.mobile-hint { display: none; }
.desktop-hint { display: inline; }

/* ==========================================================================
   22. RESPONSIVE MEDIA QUERIES (360px - 1920px)
   ========================================================================== */

/* --- Tablet / Mobile Layout (<= 768px) --- */
@media (max-width: 768px) {
  .app-header { height: 46px; padding: 0 14px; }
  .logo { font-size: 1rem; }
  .logo-icon { font-size: 1.1rem; }
  .header-score-group { gap: 12px; }
  .header-stat-value { font-size: 0.95rem; }

  .game-main {
    padding: 6px 8px 18px;
    justify-content: center;
  }

  .game-hud { top: 8px; padding: 0 12px; }
  .hud-score-display, .hud-highscore-display { padding: 3px 8px; min-width: 70px; }
  .hud-score-value, .hud-highscore-value { font-size: 0.95rem; }
  .gravity-indicator { padding: 4px 10px; gap: 6px; }
  #gravity-arrow { font-size: 0.95rem; }
  .gravity-label { font-size: 0.8rem; }
  .hud-fps { font-size: 0.65rem; }

  .theme-grid { grid-template-columns: repeat(2, 1fr); }

  .mobile-hint { display: inline; }
  .desktop-hint { display: none; }

  .watermark { font-size: 0.62rem; bottom: 4px; }
}

/* --- Small Mobile Phones (<= 480px, e.g. 360x800, 390x844, 412x915) --- */
@media (max-width: 480px) {
  .app-header { height: 42px; padding: 0 10px; }
  .logo { font-size: 0.9rem; letter-spacing: 1px; }
  .logo-icon { font-size: 1rem; }
  .header-stat-label { font-size: 0.55rem; }
  .header-stat-value { font-size: 0.85rem; }

  .game-main {
    padding: 4px 6px 14px;
  }

  .mobile-dpad .mobile-ctrl-btn {
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
    border-radius: 10px;
  }

  .mobile-reverse-btn {
    height: 44px;
    font-size: 0.85rem;
    padding: 0 14px;
  }

  .glass-card {
    max-width: 98%;
    max-height: 96%;
    border-radius: 10px;
  }

  .device-card {
    max-width: 130px;
    padding: 12px 8px;
    gap: 6px;
  }
  .device-card-icon { font-size: 1.6rem; }
  .device-card-label { font-size: 0.95rem; }
  .device-card-desc { font-size: 0.68rem; }

  .menu-logo-icon { font-size: 1.8rem; }
  .menu-title { font-size: 1.65rem; }
  .menu-buttons .btn { padding: 7px 12px; font-size: 0.82rem; }
  .menu-fact-box { max-width: 280px; }
  .fact-box-text { font-size: 0.68rem; }

  #gameover-face-canvas { width: 56px; height: 56px; }
  .gameover-title { font-size: 1.3rem; }
  .gameover-funny-text { font-size: 0.85rem; }
  .gameover-stat-value { font-size: 0.9rem; }
  .gameover-buttons .btn { padding: 7px 10px; font-size: 0.8rem; }

  .settings-slider { width: 80px; }
  .theme-option { font-size: 0.65rem; padding: 4px 5px; }

  .mobile-pause-btn {
    top: 48px;
    right: 8px;
    width: 34px;
    height: 34px;
  }
}

/* --- Orientation check: Mobile Portrait --- */
@media (orientation: portrait) and (max-width: 768px) {
  .orientation-hint:not(.dismissed) { display: flex; }
}

/* --- Short Screen Landscape Mode (<= 450px height) --- */
@media (max-height: 450px) {
  .app-header { height: 32px; padding: 0 10px; }
  .logo { font-size: 0.8rem; }
  .header-stat-value { font-size: 0.8rem; }

  .game-main {
    padding: 2px 6px 4px;
  }

  .mobile-controls-panel {
    margin-top: 4px;
    padding: 0 4px;
  }

  .mobile-dpad .mobile-ctrl-btn {
    width: 34px;
    height: 34px;
    font-size: 0.9rem;
    border-radius: 8px;
  }

  .mobile-reverse-btn {
    height: 36px;
    font-size: 0.78rem;
    padding: 0 10px;
  }

  .game-hud { top: 4px; padding: 0 8px; }
  .hud-score-display, .hud-highscore-display { padding: 2px 6px; }
  .gravity-indicator { padding: 2px 8px; }

  .glass-card { max-height: 94%; }

  .menu-logo-icon { font-size: 1.4rem; }
  .menu-title { font-size: 1.35rem; }
  .menu-subtitle { font-size: 0.7rem; }
  .menu-buttons { flex-direction: row; flex-wrap: wrap; justify-content: center; max-width: 320px; }
  .menu-buttons .btn { width: auto; flex: 1 1 120px; padding: 5px 8px; font-size: 0.75rem; }
  .menu-fact-box { display: none; }
  .menu-shahriar-fact p { font-size: 0.62rem; }

  #gameover-face-canvas { width: 44px; height: 44px; }
  .gameover-title { font-size: 1.15rem; }
  .gameover-content { padding: 8px 12px; gap: 4px; }

  .mobile-pause-btn { top: 36px; }
  .watermark { display: none; }
}
