/* Snack Snake — Phone-First Arcade Styles */
@import "../css/tokens.css";

:root {
  --snake-primary: #22C55E;
  --snake-light: #4ADE80;
  --snake-dark: #15803D;
  --snake-glow: rgba(34, 197, 94, 0.35);
  --apple-red: #EF4444;
  --gold-yellow: #F59E0B;
  --speed-cyan: #06B6D4;
  --portal-purple: #A855F7;

  --bg-main: #0B1410;
  --bg-surface: #112019;
  --bg-card: #162B22;
  --bg-card-hover: #1C372B;
  --border-subtle: rgba(74, 222, 128, 0.18);
  --border-bright: rgba(74, 222, 128, 0.4);

  --text-main: #F0FDF4;
  --text-muted: #86EFAC;
  --text-dim: #4B7A63;

  --font-title: "Plus Jakarta Sans", ui-rounded, sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-title);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

/* --- Hub Header Bar --- */
.hub-nav {
  width: 100%;
  max-width: 600px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(11, 20, 16, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 50;
}

.hub-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  transition: opacity 0.15s ease;
}

.hub-brand:hover {
  opacity: 0.85;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--snake-primary);
  box-shadow: 0 0 8px var(--snake-primary);
}

.hub-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hub-link, .nav-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-title);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  transition: all 0.15s ease;
}

.hub-link:hover, .nav-btn:hover {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-bright);
}

.nav-btn.is-muted {
  opacity: 0.7;
}

/* --- Ad Rails & Wells --- */
.ad-container {
  width: 100%;
  max-width: 600px;
  margin: 6px 0;
  display: flex;
  justify-content: center;
}

.ad-well {
  width: 100%;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-empty {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
}

/* --- Game Shell --- */
.game-shell {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px 20px;
  gap: 10px;
}

/* Title & Kicker */
.game-header {
  text-align: center;
  width: 100%;
}

.kicker {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--snake-light);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.game-title {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #FFFFFF;
  text-shadow: 0 0 16px var(--snake-glow);
}

/* Mode Selection Pills */
.mode-selector {
  display: flex;
  gap: 6px;
  background: var(--bg-surface);
  padding: 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  width: 100%;
  max-width: 380px;
}

.mode-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-title);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.18s ease;
  min-height: 34px;
}

.mode-tab:hover {
  color: var(--text-muted);
}

.mode-tab.is-active {
  background: var(--snake-dark);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* HUD Bar */
.hud-bar {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: stretch;
  background: var(--bg-card);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.hud-item {
  display: flex;
  flex-direction: column;
}

.hud-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 700;
}

.hud-val {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 800;
  color: #FFFFFF;
  line-height: 1.1;
}

.hud-val--gold {
  color: var(--gold-yellow);
}

.hud-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-icon {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.btn-icon.is-active {
  background: var(--snake-dark);
  border-color: var(--snake-light);
}

/* Status & Multiplier Pill */
.status-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-surface);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.badge-speed {
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.badge-speed.is-boosted {
  background: rgba(6, 182, 212, 0.2);
  border-color: var(--speed-cyan);
  color: #38BDF8;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.04); }
}

.powerup-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-surface);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.powerup-fill {
  height: 100%;
  background: linear-gradient(90deg, #06B6D4, #38BDF8);
  width: 0%;
  transition: width 0.1s linear;
}

/* Canvas Wrapper */
.canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 480px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border-subtle);
  touch-action: none;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Ready Prompt */
.ready-prompt {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(11, 20, 16, 0.65);
  backdrop-filter: blur(3px);
  gap: 10px;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.ready-badge {
  background: var(--snake-primary);
  color: #052E16;
  font-weight: 800;
  font-size: 1rem;
  padding: 8px 20px;
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 16px var(--snake-glow);
  animation: bounce 1.2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.ready-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* --- Virtual D-Pad --- */
.dpad-controls {
  width: 100%;
  max-width: 260px;
  margin-top: 4px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  touch-action: manipulation;
}

.dpad-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  color: var(--text-main);
  border-radius: var(--radius-md);
  font-size: 1.4rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  min-height: 52px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  transition: transform 0.08s ease, background 0.08s ease;
  user-select: none;
}

.dpad-btn:active, .dpad-btn.is-active {
  background: var(--snake-dark);
  color: #FFFFFF;
  transform: scale(0.92);
  border-color: var(--snake-light);
}

.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-center {
  grid-column: 2;
  grid-row: 2;
  border-radius: 50%;
  font-size: 1rem;
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  color: var(--text-dim);
}
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

/* --- Overlays & Modals --- */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.overlay-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.8), 0 0 24px var(--snake-glow);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: modalPop 0.22s var(--ease-spring);
}

@keyframes modalPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.overlay-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #FFFFFF;
}

.record-badge {
  display: inline-block;
  background: var(--gold-yellow);
  color: #451A03;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 auto;
}

.score-showcase {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  justify-content: space-around;
  border: 1px solid var(--border-subtle);
}

.score-col {
  display: flex;
  flex-direction: column;
}

.score-col-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 700;
}

.score-col-val {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 800;
  color: #FFFFFF;
}

.score-col-val--best {
  color: var(--gold-yellow);
}

.stats-breakdown {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  text-align: left;
  background: var(--bg-card);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
}

.stat-row b {
  color: #FFFFFF;
  font-family: var(--font-mono);
}

.button-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-primary {
  background: var(--snake-primary);
  color: #052E16;
  border: none;
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 800;
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow: 0 4px 14px var(--snake-glow);
  transition: all 0.15s ease;
  min-height: 48px;
}

.btn-primary:hover {
  background: var(--snake-light);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-title);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px;
}

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

/* Dialog: How to Play */
dialog {
  margin: auto;
  padding: 0;
  background: transparent;
  border: none;
  max-width: 440px;
  width: calc(100% - 32px);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
}

.dialog-body {
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 24px;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.8);
}

.dialog-body h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: #FFFFFF;
}

.legend-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.85rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.legend-icon {
  font-size: 1.4rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.legend-desc strong {
  color: #FFFFFF;
  display: block;
}

.legend-desc span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* --- SEO Editorial & FAQ Articles --- */
.editorial-section {
  width: 100%;
  max-width: 600px;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  margin-top: 16px;
}

.editorial-section h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: -0.02em;
}

.editorial-section h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--snake-light);
  margin-top: 8px;
}

.editorial-section p {
  line-height: 1.6;
}

.editorial-section a {
  color: var(--snake-light);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.editorial-section code {
  font-family: var(--font-mono);
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: #FFFFFF;
}

/* --- Footer --- */
.site-footer {
  width: 100%;
  max-width: 600px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.footer-nav a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-nav a:hover {
  color: #FFFFFF;
}

/* Media Query Tweaks */
@media (min-width: 600px) {
  .game-shell {
    padding: 16px 20px 24px;
    gap: 14px;
  }
}
