/* ==========================================================================
   AMIT RUNNER — MOBILE-OPTIMIZED STYLESHEET
   Design System, Mobile Touch Gamepad, Safe-Areas, Gestures, & Responsive
   ========================================================================== */

:root {
  /* Color Palette - Default Light / Day Mode */
  --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
  --card-bg: rgba(255, 255, 255, 0.88);
  --card-border: rgba(220, 225, 235, 0.85);
  --card-shadow: 0 16px 36px -12px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
  
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  
  --accent-primary: #2563eb;
  --accent-primary-hover: #1d4ed8;
  --accent-primary-glow: rgba(37, 99, 235, 0.35);
  
  --accent-secondary: #f59e0b;
  --accent-danger: #ef4444;
  --accent-success: #10b981;
  
  /* Canvas World Colors */
  --canvas-sky: #f7f9fc;
  --canvas-ground: #535353;
  --canvas-cactus: #4a5568;
  --canvas-cloud: #cbd5e1;
  --canvas-star: #e2e8f0;
  
  /* Fonts */
  --font-retro: 'Press Start 2P', monospace;
  --font-display: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Transitions */
  --transition-fast: 0.12s ease;
  --transition-normal: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ================= Dark Theme ================= */
body.theme-dark {
  --bg-gradient: linear-gradient(135deg, #090d16 0%, #111827 100%);
  --card-bg: rgba(17, 24, 39, 0.88);
  --card-border: rgba(55, 65, 81, 0.65);
  --card-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  
  --accent-primary: #3b82f6;
  --accent-primary-hover: #60a5fa;
  --accent-primary-glow: rgba(59, 130, 246, 0.45);
  
  --canvas-sky: #0f172a;
  --canvas-ground: #94a3b8;
  --canvas-cactus: #cbd5e1;
  --canvas-cloud: #334155;
  --canvas-star: #f8fafc;
}

/* ================= Retro GameBoy Theme ================= */
body.theme-retro {
  --bg-gradient: linear-gradient(135deg, #8bac0f 0%, #9bbc0f 100%);
  --card-bg: rgba(155, 188, 15, 0.92);
  --card-border: #306230;
  --card-shadow: 6px 6px 0px #0f380f;
  
  --text-main: #0f380f;
  --text-muted: #306230;
  
  --accent-primary: #306230;
  --accent-primary-hover: #0f380f;
  --accent-primary-glow: rgba(48, 98, 48, 0.4);
  
  --canvas-sky: #9bbc0f;
  --canvas-ground: #0f380f;
  --canvas-cactus: #0f380f;
  --canvas-cloud: #8bac0f;
  --canvas-star: #0f380f;
}

/* ================= Synthwave Sunset Theme ================= */
body.theme-sunset {
  --bg-gradient: linear-gradient(135deg, #180928 0%, #2a0845 50%, #64144e 100%);
  --card-bg: rgba(30, 15, 45, 0.88);
  --card-border: rgba(255, 0, 128, 0.35);
  --card-shadow: 0 25px 50px -12px rgba(255, 0, 128, 0.25), 0 0 0 1px rgba(255, 0, 128, 0.2);
  
  --text-main: #fed7aa;
  --text-muted: #f472b6;
  
  --accent-primary: #ec4899;
  --accent-primary-hover: #f43f5e;
  --accent-primary-glow: rgba(236, 72, 153, 0.5);
  
  --canvas-sky: #1e0b36;
  --canvas-ground: #ff71ce;
  --canvas-cactus: #01cdfe;
  --canvas-cloud: #7a226c;
  --canvas-star: #ffe375;
}

/* ================= Global Reset & Mobile Prevention ================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic mobile viewport height */
  font-family: var(--font-display);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
  overscroll-behavior-y: none; /* Prevent mobile pull-to-refresh reload */
  transition: background 0.4s ease, color 0.3s ease;
}

/* Container Structure with Safe-Area Insets */
.app-container {
  max-width: 1040px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ================= Header Bar ================= */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 18px;
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  box-shadow: var(--card-shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-badge {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  padding: 2px;
  background: linear-gradient(135deg, var(--accent-primary), #ec4899);
  box-shadow: 0 4px 12px var(--accent-primary-glow);
  flex-shrink: 0;
}

.header-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 2px solid #fff;
  transition: transform var(--transition-fast);
}

.avatar-badge:hover .header-avatar {
  transform: scale(1.06);
}

.status-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: var(--accent-success);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent-success);
}

.brand-text .game-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--text-main), var(--accent-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.15;
}

.brand-text .game-subtitle {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Header Buttons & Controls */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 8px 12px;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  touch-action: manipulation;
  transition: all var(--transition-fast);
}

body.theme-dark .pill-btn,
body.theme-sunset .pill-btn {
  background: rgba(255, 255, 255, 0.07);
}

.pill-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

body.theme-dark .pill-btn:hover,
body.theme-sunset .pill-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.pill-btn:active {
  transform: scale(0.96);
}

.pill-btn.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
  box-shadow: 0 4px 12px var(--accent-primary-glow);
}

.pill-btn.icon-only {
  padding: 8px 11px;
  font-size: 1rem;
}

/* Theme Dropdown */
.select-dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 185px;
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.25);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}

.select-dropdown.open .dropdown-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.dropdown-item:hover {
  background: rgba(0, 0, 0, 0.06);
}

body.theme-dark .dropdown-item:hover,
body.theme-sunset .dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.dropdown-item.active {
  background: var(--accent-primary);
  color: #fff;
  font-weight: 600;
}

/* ================= Viewport Card & HUD ================= */
.game-viewport-card {
  position: relative;
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 14px 16px 16px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

/* Stats HUD */
.stats-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  flex-wrap: wrap;
  gap: 8px;
}

body.theme-dark .stats-hud,
body.theme-sunset .stats-hud {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.hud-left-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

body.theme-dark .stat-pill,
body.theme-sunset .stat-pill {
  background: rgba(255, 255, 255, 0.06);
}

.stat-label {
  color: var(--text-muted);
}

.stat-value {
  color: var(--accent-primary);
  font-weight: 700;
}

/* Retro Chrome Dino Score Numbers */
.score-display {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-retro);
  font-size: 1.1rem;
  letter-spacing: 1.5px;
}

.hi-score {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  opacity: 0.85;
}

.score-label {
  font-size: 0.75rem;
}

.current-score {
  color: var(--text-main);
  font-weight: bold;
}

.score-flash {
  animation: scoreMilestoneFlash 0.3s ease infinite alternate;
}

@keyframes scoreMilestoneFlash {
  0% { opacity: 0.3; transform: scale(1); }
  100% { opacity: 1; transform: scale(1.08); color: var(--accent-secondary); }
}

/* ================= Canvas & Overlays ================= */
.canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1000 / 320;
  max-height: 380px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--canvas-sky);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.08);
  touch-action: none; /* Prevent scrolling when dragging over canvas */
  -webkit-touch-callout: none;
  transition: background 0.4s ease;
}

canvas#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
  touch-action: none;
}

/* Floating On-Canvas Corner Controls (For Landscape/Mobile) */
.on-screen-overlay-controls {
  display: none;
  position: absolute;
  bottom: 12px;
  left: 0;
  width: 100%;
  padding: 0 16px;
  pointer-events: none;
  justify-content: space-between;
  z-index: 10;
}

.float-btn {
  pointer-events: auto;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(15, 23, 42, 0.65);
  color: #ffffff;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-retro);
  font-size: 0.72rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  touch-action: manipulation;
  transition: transform 0.05s ease, background 0.15s ease;
}

.float-jump {
  background: rgba(37, 99, 235, 0.75);
  border-color: rgba(96, 165, 250, 0.8);
}

.float-duck {
  background: rgba(15, 23, 42, 0.75);
}

.float-btn:active {
  transform: scale(0.92);
  filter: brightness(1.2);
}

/* Overlays (Start, Game Over, Pause) */
.game-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.25s ease;
  z-index: 20;
  touch-action: manipulation;
}

.game-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 20px 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  text-align: center;
  max-width: 420px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: overlayPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes overlayPop {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.avatar-hero-container {
  position: relative;
  width: 68px;
  height: 68px;
}

.avatar-hero {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent-primary);
  box-shadow: 0 6px 18px var(--accent-primary-glow);
  background: #fff;
}

.dino-rider-icon {
  position: absolute;
  bottom: -4px;
  right: -6px;
  font-size: 1.4rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.pulse-anim {
  animation: heroPulse 2s infinite ease-in-out;
}

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

.shake-anim {
  animation: shakeAvatar 0.5s ease;
}

@keyframes shakeAvatar {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px) rotate(-4deg); }
  40%, 80% { transform: translateX(6px) rotate(4deg); }
}

.overlay-title {
  font-family: var(--font-retro);
  font-size: 1.05rem;
  color: var(--text-main);
  letter-spacing: 0.5px;
}

.game-over-title {
  color: var(--accent-danger);
}

.overlay-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.game-over-stats {
  font-size: 0.9rem;
  color: var(--text-main);
  background: rgba(0,0,0,0.04);
  padding: 6px 14px;
  border-radius: 10px;
}

body.theme-dark .game-over-stats,
body.theme-sunset .game-over-stats {
  background: rgba(255,255,255,0.06);
}

.new-record-banner {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  color: #fff;
  font-family: var(--font-retro);
  font-size: 0.72rem;
  padding: 6px 12px;
  border-radius: 20px;
  animation: bannerPulse 1s infinite alternate;
}

@keyframes bannerPulse {
  0% { transform: scale(0.98); }
  100% { transform: scale(1.03); }
}

.new-record-banner.hidden {
  display: none;
}

.key-hints {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 2px 0 6px;
}

.key-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.04);
  padding: 3px 8px;
  border-radius: 6px;
}

body.theme-dark .key-badge,
body.theme-sunset .key-badge {
  background: rgba(255, 255, 255, 0.08);
}

/* Overlay Buttons */
.primary-play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent-primary);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 12px 26px;
  font-family: var(--font-retro);
  font-size: 0.85rem;
  font-weight: bold;
  letter-spacing: 0.5px;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 6px 20px var(--accent-primary-glow);
  transition: all var(--transition-fast);
}

.primary-play-btn:active {
  transform: scale(0.96);
}

.restart-btn {
  background: linear-gradient(135deg, var(--accent-primary), #6366f1);
}

.secondary-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.06);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  padding: 10px 16px;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: all var(--transition-fast);
}

body.theme-dark .secondary-btn,
body.theme-sunset .secondary-btn {
  background: rgba(255,255,255,0.08);
}

.secondary-btn:active {
  transform: scale(0.96);
}

.game-over-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* Milestone Toast notification */
.milestone-toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.5);
  padding: 8px 16px;
  border-radius: 20px;
  font-family: var(--font-retro);
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toastFade 1.6s forwards ease;
  pointer-events: none;
  z-index: 30;
}

.milestone-toast.hidden {
  display: none;
}

@keyframes toastFade {
  0% { opacity: 0; transform: translate(-50%, -10px); }
  15% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}

/* ================= Dedicated Mobile Touch Gamepad ================= */
.touch-controls-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 2px;
}

.touch-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 64px;
  border-radius: 16px;
  border: 2px solid transparent;
  font-family: var(--font-retro);
  cursor: pointer;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.05s ease, box-shadow 0.15s ease, filter 0.1s ease;
}

.btn-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.touch-icon {
  font-size: 1.4rem;
}

.touch-text-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.touch-label {
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.touch-sublabel {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  opacity: 0.8;
  letter-spacing: 0.5px;
}

/* Jump Button styling */
.jump-touch-btn {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border-color: rgba(147, 197, 253, 0.4);
  box-shadow: 0 6px 18px var(--accent-primary-glow);
}

.jump-touch-btn:active,
.jump-touch-btn.active {
  transform: scale(0.95);
  filter: brightness(1.15);
  box-shadow: 0 2px 8px var(--accent-primary-glow);
}

/* Duck Button styling */
.duck-touch-btn {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-main);
  border-color: var(--card-border);
}

body.theme-dark .duck-touch-btn,
body.theme-sunset .duck-touch-btn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

.duck-touch-btn:active,
.duck-touch-btn.active {
  transform: scale(0.95);
  background: var(--accent-secondary);
  color: #fff;
  border-color: var(--accent-secondary);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4);
}

.mobile-gesture-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 2px 4px 0;
}

/* ================= Customizer Section & Skins ================= */
.customizer-section {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
}

.section-title {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-main);
}

.section-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.skins-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.skin-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.03);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
  transition: all var(--transition-fast);
}

body.theme-dark .skin-card,
body.theme-sunset .skin-card {
  background: rgba(255, 255, 255, 0.04);
}

.skin-card:active {
  transform: scale(0.97);
}

.skin-card.active {
  border-color: var(--accent-primary);
  background: rgba(37, 99, 235, 0.09);
  box-shadow: 0 4px 14px var(--accent-primary-glow);
}

body.theme-dark .skin-card.active,
body.theme-sunset .skin-card.active {
  background: rgba(59, 130, 246, 0.18);
}

.skin-preview {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

body.theme-dark .skin-preview,
body.theme-sunset .skin-preview {
  background: rgba(255,255,255,0.08);
}

.preview-rex-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.skin-img-rex {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  position: relative;
  z-index: 2;
}

.preview-dino-body {
  position: absolute;
  bottom: -4px;
  right: -5px;
  font-size: 0.95rem;
  z-index: 1;
}

.skin-img-body {
  height: 90%;
  width: auto;
  object-fit: contain;
}

.skin-img-surfer, .skin-img-pixel {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 50%;
}

.skin-info {
  display: flex;
  flex-direction: column;
}

.skin-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

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

/* Accessory Bar */
.accessories-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

body.theme-dark .accessories-bar,
body.theme-sunset .accessories-bar {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.accessory-toggle-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toggle-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
  touch-action: manipulation;
}

.toggle-control input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.toggle-slider {
  position: relative;
  width: 32px;
  height: 18px;
  background-color: rgba(0, 0, 0, 0.15);
  border-radius: 18px;
  transition: 0.2s ease;
}

body.theme-dark .toggle-slider,
body.theme-sunset .toggle-slider {
  background-color: rgba(255, 255, 255, 0.2);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: 0.2s ease;
}

.toggle-control input:checked + .toggle-slider {
  background-color: var(--accent-primary);
}

.toggle-control input:checked + .toggle-slider:before {
  transform: translateX(14px);
}

.stats-counter-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.strip-item strong {
  color: var(--text-main);
}

/* ================= Modal Dialog ================= */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 999;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.2s ease;
}

.modal-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  padding-bottom: 10px;
}

body.theme-dark .modal-header,
body.theme-sunset .modal-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.help-section h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 4px;
}

.help-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-main);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
}

/* ================= Footer ================= */
.game-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 4px 0;
}

/* ================= Mobile-Specific Layout & Breakpoints ================= */
@media (max-width: 768px) {
  .app-container {
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    gap: 10px;
  }

  .game-header {
    padding: 10px 12px;
  }

  .brand-text .game-title {
    font-size: 1.2rem;
  }

  .brand-text .game-subtitle {
    display: none;
  }

  .game-viewport-card {
    padding: 10px 10px 14px;
    border-radius: 16px;
  }

  .score-display {
    font-size: 0.95rem;
    gap: 8px;
  }

  /* Make skins horizontal swipe-scroll on mobile */
  .skins-grid {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .skin-card {
    flex: 0 0 160px;
    scroll-snap-align: start;
  }

  .accessories-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .stats-counter-strip {
    width: 100%;
    justify-content: space-between;
  }
}

/* ================= Landscape Mobile Mode ================= */
@media (max-height: 500px) and (orientation: landscape) {
  .app-container {
    padding: 4px env(safe-area-inset-right) 8px env(safe-area-inset-left);
    gap: 6px;
  }

  .game-header {
    padding: 6px 12px;
  }

  .brand-text .game-subtitle,
  .customizer-section,
  .game-footer {
    display: none; /* Focus 100% on the game in landscape! */
  }

  .game-viewport-card {
    padding: 6px 8px 8px;
  }

  .canvas-wrapper {
    max-height: calc(100vh - 80px);
  }

  /* Hide bottom portrait bar, reveal corner thumb controls */
  .touch-controls-bar {
    display: none;
  }

  .on-screen-overlay-controls {
    display: flex;
  }
}

/* ================= Fullscreen Mode ================= */
:fullscreen .app-container,
:-webkit-full-screen .app-container {
  max-width: 100vw;
  height: 100vh;
  justify-content: center;
}

:fullscreen .canvas-wrapper,
:-webkit-full-screen .canvas-wrapper {
  max-height: calc(100vh - 120px);
}
