/* ==========================================================================
   FLIPCOIN.SPACE - ADVANCED COIN FLIPPER STYLESHEET
   Production-ready, High Performance, Mobile-First, Accessible
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties / Design Tokens (Light & Dark Themes)
   -------------------------------------------------------------------------- */
:root {
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Primary Accent Palette */
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #eff6ff;
  --color-primary-border: #bfdbfe;

  /* Heads (Gold/Amber) & Tails (Indigo/Silver) accents */
  --color-heads: #d97706;
  --color-heads-bg: #fef3c7;
  --color-tails: #4f46e5;
  --color-tails-bg: #e0e7ff;
  --color-success: #10b981;
  --color-danger: #ef4444;

  /* Coin Specific Gradients (3D metallic realism) */
  --coin-gold-front: radial-gradient(circle at 35% 35%, #fff176, #fbc02d 45%, #f57f17 80%, #b26a00 100%);
  --coin-gold-back: radial-gradient(circle at 35% 35%, #fff59d, #fdd835 45%, #f57f17 85%, #9e5900 100%);
  --coin-silver-front: radial-gradient(circle at 35% 35%, #ffffff, #e2e8f0 45%, #94a3b8 80%, #64748b 100%);
  --coin-silver-back: radial-gradient(circle at 35% 35%, #f8fafc, #cbd5e1 45%, #94a3b8 85%, #475569 100%);
  --coin-rim: #b45309;
  --coin-edge-groove: repeating-conic-gradient(#b45309 0deg 4deg, #fef08a 4deg 8deg);

  /* Light Theme Variables */
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-alt: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 9999px;

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

/* Dark Theme Variables */
body.theme-dark {
  --bg-body: #0b0f19;
  --bg-card: #151d2f;
  --bg-subtle: #1e293b;
  --bg-alt: #101726;
  --border-color: #27354f;
  --border-focus: #60a5fa;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  --color-primary-light: #1e293b;
  --color-primary-border: #2563eb;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

/* --------------------------------------------------------------------------
   2. Reset & Base Styles
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-body);
  transition: background-color var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden; /* Strict prevent left/right scroll */
  width: 100%;
  min-height: 100vh;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  text-decoration: underline;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-to-content {
  position: absolute;
  top: -40px;
  left: 10px;
  background: var(--color-primary);
  color: #fff;
  padding: 8px 16px;
  z-index: 99999;
  border-radius: var(--radius-sm);
  transition: top 0.2s;
}
.skip-to-content:focus {
  top: 10px;
}

.container {
  width: 100%;
  max-width: 1140px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.text-center {
  text-align: center;
}

/* --------------------------------------------------------------------------
   3. Header & Navigation
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  text-decoration: none !important;
}

.logo-icon {
  font-size: 1.75rem;
  line-height: 1;
}

.logo-accent {
  color: var(--color-primary);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

.nav-link {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}

.nav-link:hover, .nav-link.active {
  color: var(--color-primary);
  text-decoration: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1.2rem;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.icon-btn:hover {
  background-color: var(--border-color);
}

.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 40px;
  height: 40px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
}

.hamburger-btn .bar {
  width: 100%;
  height: 2px;
  background-color: var(--text-primary);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

/* --------------------------------------------------------------------------
   4. Hero Section & Flipper Card
   -------------------------------------------------------------------------- */
.hero-app-section {
  padding: 2rem 0 3rem 0;
}

.hero-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.app-intro {
  text-align: center;
  max-width: 680px;
  margin-bottom: 1.75rem;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--color-primary-light);
  border: 1px solid var(--color-primary-border);
  color: var(--color-primary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  margin-bottom: 0.75rem;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-success);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.main-title {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
}

/* The Interactive Card */
.flipper-card {
  width: 100%;
  max-width: 780px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 1.5rem;
  position: relative;
  overflow: visible;
}

/* Mode Tabs - No horizontal scroll, responsive wrap */
.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-subtle);
  padding: 6px;
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
  overflow: visible;
}

.tab-btn {
  flex: 1 1 auto;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: all var(--transition-fast);
  text-align: center;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background-color: var(--bg-card);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

/* Controls Toolbar */
.controls-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}

.control-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-right: 4px;
}

.custom-select-wrapper {
  position: relative;
  display: inline-block;
}

.custom-select, .custom-select-sm {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
}

.custom-select:focus, .custom-select-sm:focus {
  border-color: var(--border-focus);
}

/* Prediction Pills */
.prediction-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.prediction-pills, .pill-group, .count-pills {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pill-btn {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.pill-btn:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
}

.pill-btn.active {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
}

/* Animation Switch Toggle */
.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
}

.switch-label input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: relative;
  width: 36px;
  height: 20px;
  background-color: var(--border-color);
  border-radius: var(--radius-pill);
  transition: background-color var(--transition-fast);
}

.switch-slider::before {
  content: "";
  position: absolute;
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: transform var(--transition-fast);
}

.switch-label input:checked + .switch-slider {
  background-color: var(--color-primary);
}

.switch-label input:checked + .switch-slider::before {
  transform: translateX(16px);
}

/* Sub-panels (Custom Coin, Tournament, Streak, Multi) */
.sub-panel {
  padding: 0.85rem 1rem;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  animation: fadeIn 0.2s ease-in-out;
}

.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Custom Coin Inputs */
.custom-inputs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 1rem;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.input-field input, .custom-count-wrap input {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  font-size: 0.85rem;
  color: var(--text-primary);
  outline: none;
}

.input-field input:focus, .custom-count-wrap input:focus {
  border-color: var(--border-focus);
}

/* Tournament Panel */
.tournament-scorecard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.score-team {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.score-val {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
}

.heads-team .score-val { color: var(--color-heads); }
.tails-team .score-val { color: var(--color-tails); }

.score-vs {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-muted);
}

.tournament-target {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-left: 1rem;
  padding-left: 1rem;
  border-left: 2px solid var(--border-color);
}

/* Streak Panel */
.streak-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-around;
  gap: 1rem;
}

.streak-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.streak-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.streak-number {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1.1;
}

.streak-type {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.streak-challenge-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.challenge-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.challenge-status {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-success);
}

/* Multi-coin Controls */
.multi-panel-content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.custom-count-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.custom-count-wrap input {
  width: 80px;
}

.validation-msg {
  font-size: 0.75rem;
  color: var(--color-danger);
  font-weight: 600;
  margin-left: 4px;
}

/* --------------------------------------------------------------------------
   5. 3D Animated Coin Arena & Mechanics
   -------------------------------------------------------------------------- */
.coin-arena {
  position: relative;
  min-height: 290px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 0 1rem;
  perspective: 1000px; /* Essential for 3D flip */
  user-select: none;
  overflow: hidden; /* Strict: prevent 3D rotation edges from pushing viewport */
  max-width: 100%;
  box-sizing: border-box;
}

.confetti-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}

.single-coin-wrapper {
  position: relative;
  width: 170px;
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The Coin Shadow */
.coin-shadow {
  position: absolute;
  bottom: -24px;
  width: 130px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0) 70%);
  transition: transform 0.2s, opacity 0.2s;
  pointer-events: none;
}

.coin-shadow.flipping {
  animation: shadowScale 1s ease-in-out infinite;
}

@keyframes shadowScale {
  0%, 100% { transform: scale(1); opacity: 0.35; }
  50% { transform: scale(0.4); opacity: 0.1; }
}

/* 3D Coin Structure */
.coin {
  width: 160px;
  height: 160px;
  position: relative;
  transform-style: preserve-3d;
  cursor: pointer;
  border-radius: 50%;
  transition: transform 1s cubic-bezier(0.2, 0.8, 0.2, 1);
  outline: none;
}

.coin:focus-visible {
  box-shadow: 0 0 0 4px var(--color-primary-border);
}

.coin-face {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.5),
              inset 0 0 12px rgba(0, 0, 0, 0.3),
              0 6px 14px rgba(0, 0, 0, 0.25);
}

/* Coin Front (Heads) */
.coin-front {
  background: var(--coin-gold-front);
  transform: rotateY(0deg);
}

/* Coin Back (Tails) */
.coin-back {
  background: var(--coin-gold-back);
  transform: rotateY(180deg);
}

.coin-inner-rim {
  width: 88%;
  height: 88%;
  border-radius: 50%;
  border: 2px dashed rgba(120, 53, 15, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.coin-art {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #78350f;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.5);
}

.coin-emblem {
  font-size: 3.2rem;
  font-weight: 900;
  line-height: 1;
}

.coin-title {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  margin-top: 2px;
}

.coin-year, .coin-sub {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  opacity: 0.85;
}

/* Coin Styles Variants */
/* Silver USD / EUR */
.coin-silver .coin-front {
  background: var(--coin-silver-front);
}
.coin-silver .coin-back {
  background: var(--coin-silver-back);
}
.coin-silver .coin-art {
  color: #334155;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.8);
}
.coin-silver .coin-inner-rim {
  border-color: rgba(51, 65, 85, 0.3);
}

/* Cyber Theme */
.coin-cyber .coin-front {
  background: radial-gradient(circle at 35% 35%, #06b6d4, #0891b2 50%, #0e7490 85%, #155e75 100%);
}
.coin-cyber .coin-back {
  background: radial-gradient(circle at 35% 35%, #ec4899, #db2777 50%, #be185d 85%, #9d174d 100%);
}
.coin-cyber .coin-art {
  color: #ffffff;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.7);
}
.coin-cyber .coin-inner-rim {
  border-color: rgba(255, 255, 255, 0.5);
}

/* Bronze Theme */
.coin-bronze .coin-front, .coin-bronze .coin-back {
  background: radial-gradient(circle at 35% 35%, #fdba74, #ea580c 50%, #9a3412 85%, #7c2d12 100%);
}
.coin-bronze .coin-art {
  color: #451a03;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.4);
}

/* TWO COINS DISPLAY */
.two-coins-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3rem;
  padding: 1rem 0;
}

.mini-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.coin-dual {
  width: 110px;
  height: 110px;
  position: relative;
  transform-style: preserve-3d;
  border-radius: 50%;
  transition: transform 1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.coin-dual .coin-emblem {
  font-size: 2.2rem;
}

.coin-shadow-sm {
  position: absolute;
  bottom: 18px;
  width: 90px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0) 70%);
}

.dual-coin-label {
  margin-top: 1.25rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
}

/* MULTI COINS GRID (1 to 100 coins) */
.multi-coins-grid-wrapper {
  width: 100%;
  max-height: 260px;
  overflow-y: auto;
  padding: 0.75rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  border: 1px solid var(--border-color);
}

.multi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 8px;
  align-items: center;
}

.mini-coin {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transition: transform 0.3s;
}

.mini-coin.heads {
  background: var(--coin-gold-front);
  color: #78350f;
  border: 2px solid #b45309;
}

.mini-coin.tails {
  background: var(--coin-silver-front);
  color: #334155;
  border: 2px solid #64748b;
}

/* Result Banner */
.result-banner {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0 10px;
}

.result-text {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
  transition: color var(--transition-fast);
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

.result-text.win {
  color: var(--color-success);
}

.prediction-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.prediction-badge.hit {
  background: #dcfce7;
  color: #15803d;
}

.prediction-badge.miss {
  background: #fee2e2;
  color: #b91c1c;
}

/* --------------------------------------------------------------------------
   6. Action Buttons Row & Controls
   -------------------------------------------------------------------------- */
.action-buttons-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 1.25rem 0 0.5rem;
}

.btn-flip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 190px;
  padding: 12px 28px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #ffffff;
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.btn-flip:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
  background: linear-gradient(135deg, #2563eb, #1e40af);
}

.btn-flip:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-flip:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(20%);
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background-color: var(--border-color);
}

.btn-secondary.active-state {
  background-color: #fee2e2;
  border-color: #f87171;
  color: #b91c1c;
}

.keyboard-hint {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.keyboard-hint kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: monospace;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

/* --------------------------------------------------------------------------
   7. Summary Statistics Bar
   -------------------------------------------------------------------------- */
.stats-overview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-top: 1.5rem;
  border: 1px solid var(--border-color);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.1rem;
}

.heads-circle {
  background-color: var(--color-heads-bg);
  color: var(--color-heads);
  border: 2px solid var(--color-heads);
}

.tails-circle {
  background-color: var(--color-tails-bg);
  color: var(--color-tails);
  border: 2px solid var(--color-tails);
}

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

.stat-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-count {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
}

.stat-pct {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.stat-ratio-container {
  flex: 1;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-ratio-bar {
  display: flex;
  height: 10px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background-color: var(--border-color);
}

.ratio-fill-heads {
  background-color: var(--color-heads);
  transition: width 0.3s ease;
}

.ratio-fill-tails {
  background-color: var(--color-tails);
  transition: width 0.3s ease;
}

.ratio-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

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

/* --------------------------------------------------------------------------
   8. History Log & Export Toolbar
   -------------------------------------------------------------------------- */
.history-section {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.25rem;
}

.history-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.history-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.history-count-badge {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.tool-btn:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.tool-btn.danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

/* EXPORT DROPDOWN MENU
   MANDATORY RULE ENFORCEMENT:
   Dropdown CSS should not be --> top: calc(100% + 8px);
   It MUST be --> top: 100% ;
*/
.export-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%; /* REQUIRED USER RULE: Exactly top: 100%; never calc(100% + 8px) */
  right: 0;
  min-width: 140px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
  z-index: 100;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  text-align: left;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: background-color var(--transition-fast);
}

.dropdown-item:hover {
  background-color: var(--bg-subtle);
}

.history-table-container {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.history-table th {
  position: sticky;
  top: 0;
  background-color: var(--bg-subtle);
  padding: 8px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-color);
  z-index: 2;
}

.history-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.history-table tr:hover td {
  background-color: var(--bg-subtle);
}

.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 1.5rem;
}

.res-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.78rem;
}

.res-tag.heads {
  background: var(--color-heads-bg);
  color: var(--color-heads);
}

.res-tag.tails {
  background: var(--color-tails-bg);
  color: var(--color-tails);
}

/* --------------------------------------------------------------------------
   9. Social Share Section (Before Features Section)
   -------------------------------------------------------------------------- */
.social-share-section {
  padding: 2rem 0;
}

.share-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  text-align: center;
}

.share-text h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.share-text p {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.social-buttons-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.social-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
  text-decoration: none !important;
}

.social-btn:hover {
  transform: translateY(-2px);
  opacity: 0.92;
}

.x-btn { background-color: #0f1419; }
.wa-btn { background-color: #25d366; }
.fb-btn { background-color: #1877f2; }
.li-btn { background-color: #0a66c2; }
.rd-btn { background-color: #ff4500; }
.copy-url-btn {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}
.copy-url-btn:hover {
  background-color: var(--border-color);
}

/* --------------------------------------------------------------------------
   10. Feature & Explanation Sections
   -------------------------------------------------------------------------- */
.section {
  padding: 4rem 0;
}

.section.alt-bg {
  background-color: var(--bg-alt);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.section-header {
  max-width: 680px;
  margin: 0 auto 2.5rem;
}

.section-tag {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

.section-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.section-desc {
  font-size: 1rem;
  color: var(--text-secondary);
}

/* Cards Grid 2 & 3 */
.cards-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.feature-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.card-icon {
  font-size: 2.2rem;
  margin-bottom: 1rem;
}

.feature-card h3 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.feature-list {
  list-style: none;
  margin: 1rem 0;
}

.feature-list li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.feature-list li::before {
  content: "✔";
  position: absolute;
  left: 0;
  color: var(--color-primary);
  font-weight: 800;
}

.card-subtext {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.cards-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.feature-card-compact {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
}

.card-badge {
  display: inline-block;
  padding: 3px 8px;
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.feature-card-compact h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.feature-card-compact p {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

/* Features Grid 6 */
.features-grid-6 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.grid-item {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.item-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.grid-item h4 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.grid-item p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Steps Container */
.steps-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}

.step-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.25rem;
  position: relative;
}

.step-num {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--color-primary);
  opacity: 0.4;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.step-card h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.step-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   11. SEO Humanized Content Article (~680 Words)
   -------------------------------------------------------------------------- */
.seo-article-section {
  padding: 4rem 0;
}

.content-container {
  max-width: 820px;
}

.article-header {
  margin-bottom: 2rem;
}

.article-header h2 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.25;
  color: var(--text-primary);
}

.article-body {
  font-size: 1.02rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

.article-body p {
  margin-bottom: 1.25rem;
}

.article-body h3 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 2rem 0 0.75rem;
}

.article-body ul {
  margin: 1rem 0 1.5rem 1.5rem;
}

.article-body li {
  margin-bottom: 0.75rem;
}

/* --------------------------------------------------------------------------
   12. FAQ Accordion Section
   -------------------------------------------------------------------------- */
.faq-container {
  max-width: 820px;
}

.accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.accordion-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.accordion-item.active {
  border-color: var(--color-primary-border);
}

.accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  text-align: left;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  background-color: transparent;
  gap: 1rem;
}

.accordion-header:hover {
  background-color: var(--bg-subtle);
}

.accordion-icon {
  font-size: 1.4rem;
  font-weight: 400;
  line-height: 1;
  color: var(--color-primary);
  transition: transform var(--transition-fast);
}

.accordion-item.active .accordion-icon {
  transform: rotate(45deg);
}

.accordion-content {
  padding: 0 1.25rem 1.25rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
}

/* --------------------------------------------------------------------------
   13. CTA Section
   -------------------------------------------------------------------------- */
.cta-section {
  padding: 4rem 0;
}

.cta-box {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #ffffff;
  border-radius: var(--radius-xl);
  padding: 3.5rem 2rem;
  box-shadow: var(--shadow-xl);
}

.cta-box h2 {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.cta-box p {
  font-size: 1.1rem;
  max-width: 580px;
  margin: 0 auto 2rem;
  opacity: 0.9;
}

.cta-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background-color: #ffffff;
  color: #1e3a8a;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  transition: transform var(--transition-fast);
}

.btn-primary:hover {
  transform: translateY(-2px);
  text-decoration: none;
}

.cta-share-btn {
  background-color: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
}

.cta-share-btn:hover {
  background-color: rgba(255, 255, 255, 0.25);
}

/* --------------------------------------------------------------------------
   14. Footer
   -------------------------------------------------------------------------- */
.site-footer {
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 3.5rem 0 2rem;
  margin-top: 2rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2.5rem;
  margin-bottom: 3rem;
}

.brand-col .footer-tagline {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 1rem 0;
  max-width: 380px;
}

.trademark-disclaimer {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 380px;
}

.footer-heading {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-links a {
  font-size: 0.88rem;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.footer-links a:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.footer-bottom {
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-bottom-links a {
  color: var(--text-muted);
  margin: 0 4px;
}

.footer-bottom-links a:hover {
  color: var(--color-primary);
}

/* --------------------------------------------------------------------------
   15. Cookie Banner & Toast Notifications
   -------------------------------------------------------------------------- */
.cookie-banner {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  max-width: 540px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 1rem 1.25rem;
  z-index: 9999;
  display: none;
  animation: slideUp 0.3s ease;
}

.cookie-banner.show {
  display: block;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

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

.cookie-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
}

.cookie-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
  flex: 1;
}

.cookie-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-cookie-accept {
  padding: 6px 14px;
  background-color: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 700;
  transition: background-color var(--transition-fast);
}

.btn-cookie-accept:hover {
  background-color: var(--color-primary-hover);
}

.btn-cookie-dismiss {
  font-size: 1.3rem;
  color: var(--text-muted);
  padding: 4px;
  line-height: 1;
}

/* Toast System */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  overflow: hidden; /* Strict: prevent offscreen animation from widening page */
}

.toast {
  pointer-events: auto;
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--color-primary);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1), toastOut 0.3s cubic-bezier(0.16, 1, 0.3, 1) 2.7s forwards;
}

@keyframes toastIn {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(30px); opacity: 0; }
}

/* --------------------------------------------------------------------------
   16. Responsive Breakpoints & Mobile Optimization
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }
}

@media (max-width: 768px) {
  /* Strict anti-overflow viewport lock */
  body, html {
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100vw;
  }

  .container {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
    max-width: 100%;
  }

  /* Mobile Navigation */
  .hamburger-btn {
    display: flex;
  }

  .nav-menu {
    position: absolute;
    top: 68px;
    left: 0;
    right: 0;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    padding: 1rem 1.25rem;
    display: none;
  }

  .nav-menu.open {
    display: block;
  }

  .nav-links {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .hero-app-section {
    padding: 1rem 0 2rem 0;
  }

  .app-intro {
    margin-bottom: 1rem;
  }

  .main-title {
    font-size: 1.85rem;
  }

  .subtitle {
    font-size: 0.95rem;
  }

  .flipper-card {
    padding: 0.85rem;
    border-radius: var(--radius-lg);
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Mode Tabs - 100% visible, ZERO scrollbar on mobile */
  .mode-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 6px;
    overflow: visible;
  }

  .mode-tabs .tab-btn {
    white-space: normal;
    padding: 10px 6px;
    font-size: 0.82rem;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
  }

  .mode-tabs .tab-btn:last-child {
    grid-column: span 2;
  }

  /* Controls Toolbar Mobile Layout */
  .controls-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
    padding: 0.75rem;
  }

  .dropdown-group {
    grid-column: span 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  .dropdown-group .custom-select-wrapper {
    flex: 1;
    margin-left: 8px;
  }

  .dropdown-group .custom-select {
    width: 100%;
  }

  .prediction-group {
    grid-column: span 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  .speed-group {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .toggle-group {
    display: flex;
    justify-content: flex-end;
  }

  /* Multi-coin Controls Mobile */
  .multi-panel-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
  }

  .count-pills {
    flex-wrap: wrap;
    width: 100%;
  }

  .count-pills .pill-btn {
    flex: 1 1 20%;
    text-align: center;
  }

  .custom-count-wrap {
    width: 100%;
    justify-content: space-between;
  }

  /* Tournament & Streak Mobile */
  .tournament-scorecard {
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.65rem;
  }

  .tournament-target {
    width: 100%;
    text-align: center;
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    border-top: 1px solid var(--border-color);
    padding-top: 0.5rem;
  }

  .streak-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .streak-challenge-box {
    grid-column: span 2;
    width: 100%;
  }

  .coin-arena {
    min-height: 230px;
    padding: 1rem 0 0.5rem;
  }

  .coin {
    width: 135px;
    height: 135px;
  }

  .single-coin-wrapper {
    width: 145px;
    height: 145px;
  }

  .two-coins-wrapper {
    gap: 1.25rem;
  }

  .coin-dual {
    width: 85px;
    height: 85px;
  }

  .result-text {
    font-size: 1.15rem;
    padding: 0 4px;
  }

  /* Action Buttons Mobile */
  .action-buttons-row {
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
  }

  .btn-flip {
    width: 100%;
    min-width: unset;
    padding: 14px 20px;
    font-size: 1.15rem;
  }

  .btn-secondary {
    flex: 1;
    text-align: center;
    padding: 9px 12px;
    font-size: 0.88rem;
  }

  .stats-overview-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    padding: 0.85rem;
  }

  .stat-ratio-container {
    max-width: 100%;
  }

  /* History Log Mobile Fitting */
  .history-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .history-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px;
  }

  .history-actions .tool-btn {
    flex: 1 1 auto;
    justify-content: center;
    padding: 6px 8px;
    font-size: 0.75rem;
  }

  .history-table th, .history-table td {
    padding: 6px 6px;
    font-size: 0.78rem;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .cookie-banner {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }

  .cookie-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .cookie-buttons {
    margin-top: 8px;
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 480px) {
  /* On compact smartphones, hide prediction and time columns to guarantee zero scroll */
  .history-table th:nth-child(4),
  .history-table td:nth-child(4),
  .history-table th:nth-child(5),
  .history-table td:nth-child(5) {
    display: none;
  }

  .history-table th, .history-table td {
    padding: 6px 4px;
  }

  .history-table {
    table-layout: fixed;
  }

  .history-table th:nth-child(1),
  .history-table td:nth-child(1) {
    width: 18%;
  }

  .history-table th:nth-child(2),
  .history-table td:nth-child(2) {
    width: 42%;
  }

  .history-table th:nth-child(3),
  .history-table td:nth-child(3) {
    width: 40%;
  }
}
