/* ==========================================================================
   SNAKE ARCADE // MULTI-EDITION STYLESHEET
   1. Game Hub (Modern Dark-Mode Menu)
   2. Authentic Classic Snake v1 (Exact colors & triple-borders from past commits)
   3. Next-Gen Cyber Snake v2 (Glassmorphism + Neon Glows + Canvas)
   ========================================================================== */

:root {
  /* Common Palette */
  --bg-dark: #070a12;
  --surface-card: rgba(15, 23, 42, 0.7);
  --surface-border: rgba(255, 255, 255, 0.08);

  /* Next-Gen v2 Accents */
  --neon-emerald: #10b981;
  --neon-emerald-bright: #34d399;
  --neon-emerald-glow: rgba(16, 185, 129, 0.35);
  --neon-cyan: #06b6d4;
  --neon-cyan-glow: rgba(6, 182, 212, 0.3);
  --neon-rose: #f43f5e;
  --neon-amber: #f59e0b;

  /* AUTHENTIC ORIGINAL v1 PALETTE (From commit 9b3f8ca) */
  --v1-b1-color: #595f43;
  --v1-b2-color: #abb78a;
  --v1-b3-color: #8b966c;
  --v1-board-bg: #c4cfa3;
  --v1-snake-bg: #414141;
  --v1-snake-border: #5a5a5a;
  --v1-food-bg: #dedede;
  --v1-food-border: #999999;
  --v1-score-color: #abb78a;
  --v1-high-color: #d8ddca;
  --v1-body-bg: #414141;

  /* Responsive v1 scaling: exact 20px on desktop, scaling down gracefully on mobile */
  --v1-tile-size: min(20px, calc((92vw - 70px) / 20));
  --v1-b1-width: clamp(5px, 1.8vw, 10px);
  --v1-b2-width: clamp(4px, 1.5vw, 8px);
  --v1-b3-width: clamp(12px, 4.5vw, 30px);

  /* Fonts */
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;
  --font-retro: 'VT323', monospace;

  /* Transitions */
  --trans-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --trans-bounce: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==========================================================================
   Base & Resets
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background-color: var(--bg-dark);
  color: #f8fafc;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 2.5vw, 20px);
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* Ambient Backdrop Glows */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
}

.glow-top {
  top: -12%;
  left: 20%;
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.2) 0%, transparent 70%);
}

.glow-bottom {
  bottom: -15%;
  right: 15%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.16) 0%, transparent 70%);
}

/* Glassmorphism Card Utility */
.glass-card {
  background: var(--surface-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--surface-border);
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.6), inset 0 1px 0 0 rgba(255, 255, 255, 0.08);
}

/* App Root Container */
.app-root {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: auto;
}

/* View Panel State Switcher */
.view-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 1;
  transform: scale(1);
  transition: opacity var(--trans-fast), transform var(--trans-fast);
}

.view-panel.hidden {
  display: none !important;
  opacity: 0;
  transform: scale(0.97);
  pointer-events: none;
}

/* ==========================================================================
   VIEW 1: GAME HUB (MAIN MENU)
   ========================================================================== */

#hub-view {
  max-width: 760px;
  gap: clamp(14px, 3vh, 24px);
  animation: fadeIn 300ms ease;
}

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

.hub-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.hub-logo-badge {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.2));
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.hub-main-title {
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #ffffff;
}

.gradient-text {
  background: linear-gradient(135deg, #34d399 20%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hub-subtitle {
  font-size: clamp(0.85rem, 2.2vw, 1rem);
  color: #94a3b8;
}

.hub-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(14px, 2.5vw, 22px);
  width: 100%;
}

.hub-card {
  position: relative;
  border-radius: 20px;
  padding: clamp(16px, 3vw, 24px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  cursor: pointer;
  transition: transform var(--trans-bounce), border-color var(--trans-fast), box-shadow var(--trans-fast);
  outline: none;
}

.hub-card:hover, .hub-card:focus-visible {
  transform: translateY(-5px);
}

.hub-card:active {
  transform: translateY(-1px);
}

/* Classic Card Preview with authentic colors */
.classic-card:hover, .classic-card:focus-visible {
  border-color: rgba(171, 183, 138, 0.5);
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.6), 0 0 25px rgba(171, 183, 138, 0.25);
}

.nextgen-card:hover, .nextgen-card:focus-visible {
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.6), 0 0 25px rgba(16, 185, 129, 0.35);
}

.card-badge {
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 3px 10px;
  border-radius: 9999px;
}

.retro-badge {
  font-family: var(--font-retro);
  font-size: 0.95rem;
  background: rgba(171, 183, 138, 0.15);
  color: var(--v1-b2-color);
  border: 1px solid rgba(171, 183, 138, 0.35);
}

.modern-badge {
  font-family: var(--font-mono);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.2));
  color: var(--neon-emerald-bright);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.card-visual {
  width: 100%;
  height: 90px;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Authentic v1 Thumbnail Mirroring Commit 9b3f8ca */
.v1-thumb-preview {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--v1-body-bg);
  border-radius: 8px;
}

.v1-thumb-b1 {
  border: var(--v1-b1-color) solid 4px;
  border-radius: 12px;
  box-shadow: inset 0 0 0 4px var(--v1-b1-color);
  padding: 2px;
}

.v1-thumb-b2 {
  border: var(--v1-b2-color) solid 3px;
  border-radius: 10px;
  box-shadow: inset 0 0 0 4px var(--v1-b2-color);
  padding: 2px;
}

.v1-thumb-b3 {
  border: var(--v1-b3-color) solid 10px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px var(--v1-b3-color);
  background-color: var(--v1-board-bg);
  width: 80px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.v1-thumb-snake {
  width: 28px;
  height: 8px;
  background-color: var(--v1-snake-bg);
  border: var(--v1-snake-border) 1px dotted;
}

.v1-thumb-food {
  width: 8px;
  height: 8px;
  background-color: var(--v1-food-bg);
  border: var(--v1-food-border) 2px solid;
}

/* Modern v2 Thumbnail */
.v2-thumb-preview {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #101a2f 0%, #080c14 100%);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.v2-thumb-glow-snake {
  width: 70px;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, #10b981, #06b6d4);
  box-shadow: 0 0 15px var(--neon-emerald-glow);
}

.v2-thumb-glow-food {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #f43f5e;
  box-shadow: 0 0 14px #f43f5e;
  margin-left: 20px;
  animation: pulse 1.8s infinite;
}

.v2-thumb-particles span {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 6px #34d399;
  opacity: 0.6;
}

.v2-thumb-particles span:nth-child(1) { top: 30%; right: 28%; animation: floatP 2s infinite; }
.v2-thumb-particles span:nth-child(2) { bottom: 25%; left: 35%; animation: floatP 2.5s infinite 0.5s; }
.v2-thumb-particles span:nth-child(3) { top: 20%; left: 20%; animation: floatP 3s infinite 1s; }

@keyframes floatP {
  0%, 100% { transform: translateY(0); opacity: 0.3; }
  50% { transform: translateY(-6px); opacity: 0.9; }
}

.card-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #ffffff;
}

.card-desc {
  font-size: 0.82rem;
  color: #94a3b8;
  line-height: 1.45;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}

.tag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.05);
  color: #64748b;
  border: 1px solid var(--surface-border);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--surface-border);
  gap: 12px;
}

.card-best-score {
  display: flex;
  flex-direction: column;
}

.best-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #64748b;
}

.best-num {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
}

.v1-best-num {
  color: var(--v1-b2-color);
  font-family: var(--font-retro);
  font-size: 1.4rem;
}

.v2-best-num {
  color: var(--neon-amber);
}

.launch-btn {
  padding: 8px 16px;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all var(--trans-fast);
}

.retro-launch-btn {
  background: var(--v1-b2-color);
  color: #1e2417;
  font-family: var(--font-retro);
  font-size: 1.2rem;
  letter-spacing: 1px;
}

.retro-launch-btn:hover {
  background: #c2cfa0;
  box-shadow: 0 4px 14px rgba(171, 183, 138, 0.4);
}

.modern-launch-btn {
  background: linear-gradient(135deg, var(--neon-emerald), #059669);
  color: #042014;
}

.modern-launch-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 16px var(--neon-emerald-glow);
}

.hub-footer {
  text-align: center;
  font-size: 0.78rem;
  color: #64748b;
}

/* ==========================================================================
   VIEW 2: AUTHENTIC CLASSIC SNAKE (v1) STYLING
   Directly from commit 9b3f8ca with responsive fluid bounds
   ========================================================================== */

.v1-game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'VT323', monospace;
  position: relative;
  width: 100%;
  max-width: 520px;
}

.v1-nav-bar {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  margin-bottom: 4px;
}

.v1-back-btn {
  font-family: 'VT323', monospace;
  font-size: 1.3rem;
  background: var(--v1-b1-color);
  color: var(--v1-b2-color);
  border: 2px solid var(--v1-b2-color);
  border-radius: 8px;
  padding: 4px 14px;
  cursor: pointer;
  transition: background var(--trans-fast);
}

.v1-back-btn:hover {
  background: #6e7653;
  color: #ffffff;
}

/* Scores from commit 9b3f8ca */
.v1-scores {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

#v1-score {
  color: var(--v1-b2-color);
}

#v1-score,
#v1-highScore {
  font-size: clamp(30px, 8vw, 40px);
  font-weight: bolder;
  margin: 6px 0;
  font-family: 'VT323', monospace;
}

#v1-highScore {
  color: var(--v1-high-color);
  display: none;
}

/* Game Borders from commit 9b3f8ca */
.game-border-1 {
  border: var(--v1-b1-color) solid var(--v1-b1-width);
  border-radius: 30px;
  box-shadow: inset 0 0 0 var(--v1-b1-width) var(--v1-b1-color);
  position: relative;
}

.game-border-2 {
  border: var(--v1-b2-color) solid var(--v1-b2-width);
  border-radius: 26px;
  box-shadow: inset 0 0 0 clamp(5px, 2vw, 10px) var(--v1-b2-color);
}

.game-border-3 {
  border: var(--v1-b3-color) solid var(--v1-b3-width);
  border-radius: 20px;
  box-shadow: inset 0 0 0 5px var(--v1-b3-color);
  background-color: var(--v1-board-bg);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Game Board Grid from commit 9b3f8ca */
#v1-game-board {
  border-radius: 100px;
  display: grid;
  grid-template-columns: repeat(20, var(--v1-tile-size));
  grid-template-rows: repeat(20, var(--v1-tile-size));
  margin: 5px;
  position: relative;
  z-index: 1;
}

/* Snake & Food from commit 9b3f8ca */
.snake {
  background-color: var(--v1-snake-bg);
  border: var(--v1-snake-border) 1px dotted;
}

.food {
  background-color: var(--v1-food-bg);
  border: var(--v1-food-border) clamp(2px, 1vw, 5px) solid;
}

/* Centered Logo & Instruction Text from commit 9b3f8ca */
#v1-logo {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--v1-board-bg);
  max-width: 140px;
  z-index: 5;
}

#v1-instruction-text {
  position: absolute;
  top: 60%;
  left: 50%;
  transform: translateX(-50%);
  color: #333333;
  width: 280px;
  text-align: center;
  text-transform: capitalize;
  padding: 10px;
  margin: 0;
  font-family: 'VT323', monospace;
  font-size: clamp(1.2rem, 3.8vw, 1.6rem);
  z-index: 5;
}

/* Classic Mobile D-Pad Controls */
.v1-touch-controls {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.v1-dpad {
  background: #333827;
  border: 2px solid var(--v1-b1-color);
}

.v1-dpad-btn {
  font-family: 'VT323', monospace;
  font-size: 1.5rem;
  background: var(--v1-b1-color);
  color: var(--v1-b2-color);
  border-color: var(--v1-b3-color);
}

.v1-dpad-btn:active {
  background: var(--v1-b2-color);
  color: #1e2417;
}

.v1-footer {
  font-family: 'VT323', monospace;
  font-size: 1.15rem;
  color: var(--v1-b2-color);
  text-align: center;
  margin-top: 10px;
}

.v1-footer kbd {
  background: #333827;
  padding: 1px 6px;
  border: 1px solid var(--v1-b1-color);
  border-radius: 4px;
}

/* ==========================================================================
   VIEW 3: NEXT-GEN CYBER SNAKE (v2) STYLING
   ========================================================================== */

.game-wrapper {
  position: relative;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9999px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--surface-border);
  color: #ffffff;
  transition: all var(--trans-fast);
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(-2px);
}

.modern-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-radius: 14px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.brand-logo-wrap {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.2));
  border: 1px solid rgba(16, 185, 129, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.game-title {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, #ffffff 40%, var(--neon-emerald-bright) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.version-badge {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 9999px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--neon-emerald-bright);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

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

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--surface-border);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--trans-fast);
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}

.action-btn.icon-only {
  padding: 6px;
  width: 32px;
  height: 32px;
  justify-content: center;
}

.svg-icon {
  width: 16px;
  height: 16px;
}

.hidden {
  display: none !important;
}

/* Stat HUD */
.stats-hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  padding: 8px 12px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stat-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-bottom: 2px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  color: #ffffff;
}

#v2-score-display {
  color: var(--neon-emerald-bright);
  text-shadow: 0 0 12px var(--neon-emerald-glow);
}

#v2-high-score-display {
  color: var(--neon-amber);
}

#v2-level-display {
  color: var(--neon-cyan);
}

/* Next-Gen Board Canvas */
.board-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.6), 0 0 35px -10px var(--neon-emerald-glow);
  background: #080c14;
}

.board-container.wrap-mode {
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.6), 0 0 35px -10px var(--neon-cyan-glow);
}

#v2-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(7, 10, 18, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10;
  transition: opacity var(--trans-fast);
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
  display: none !important;
}

.overlay-card {
  width: 100%;
  max-width: 320px;
  padding: 24px 20px;
  border-radius: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.overlay-icon {
  font-size: 2.2rem;
  line-height: 1;
}

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

@keyframes pulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.4)); }
  50% { transform: scale(1.12); filter: drop-shadow(0 0 16px rgba(16, 185, 129, 0.8)); }
}

.overlay-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.overlay-subtitle {
  font-size: 0.88rem;
  color: #94a3b8;
}

.key-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.overlay-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 4px 0;
}

.tag-pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
  border: 1px solid var(--surface-border);
}

.game-over-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--neon-rose);
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.3);
  padding: 3px 12px;
  border-radius: 9999px;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--surface-border);
  border-bottom: 1px solid var(--surface-border);
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-label {
  font-size: 0.65rem;
  color: #64748b;
  font-weight: 600;
}

.summary-val {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
}

.high-score-banner {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--neon-amber);
  animation: pulse 1.5s infinite;
}

.overlay-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}

.primary-btn {
  width: 100%;
  padding: 10px 18px;
  border-radius: 14px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  background: linear-gradient(135deg, var(--neon-emerald), #059669);
  color: #042014;
  cursor: pointer;
  transition: all var(--trans-fast);
}

.primary-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 8px 20px -4px var(--neon-emerald-glow);
}

.glow-btn {
  box-shadow: 0 6px 18px -4px var(--neon-emerald-glow);
}

.secondary-btn {
  width: 100%;
  padding: 10px 18px;
  border-radius: 14px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--surface-border);
  color: #ffffff;
  cursor: pointer;
  transition: all var(--trans-fast);
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Touch Controls & Virtual D-Pads */
.touch-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-top: 4px;
}

.dpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  gap: 6px;
  padding: 10px;
  background: var(--surface-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--surface-border);
  border-radius: 28px;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.6);
}

.dpad-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  color: #94a3b8;
  cursor: pointer;
  transition: all var(--trans-fast);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.dpad-btn svg {
  width: 22px;
  height: 22px;
}

.dpad-btn:active,
.dpad-btn.active {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--neon-emerald);
  color: var(--neon-emerald-bright);
  transform: scale(0.92);
  box-shadow: 0 0 14px var(--neon-emerald-glow);
}

.dpad-btn.up { grid-column: 2; grid-row: 1; }
.dpad-btn.left { grid-column: 1; grid-row: 2; }
.dpad-btn.center {
  grid-column: 2;
  grid-row: 2;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: 50%;
}
.dpad-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #64748b;
}
.dpad-btn.center:active .dpad-dot {
  background: var(--neon-emerald);
}
.dpad-btn.right { grid-column: 3; grid-row: 2; }
.dpad-btn.down { grid-column: 2; grid-row: 3; }

.game-footer {
  text-align: center;
  font-size: 0.75rem;
  color: #64748b;
}

.controls-hint {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.controls-hint kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 1px 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  color: #94a3b8;
}

.mobile-only {
  display: none;
}

/* Modal Dialog */
.modal-dialog {
  border: 1px solid var(--surface-border);
  border-radius: 20px;
  padding: 0;
  max-width: 420px;
  width: 90%;
  margin: auto;
  background: #0d1322;
  color: #ffffff;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

.modal-dialog::backdrop {
  background: rgba(4, 7, 14, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 0.85rem;
  color: #94a3b8;
  line-height: 1.5;
}

.modal-section h3 {
  font-size: 0.92rem;
  color: #ffffff;
  margin-bottom: 6px;
}

.modal-section ul {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

@media (max-width: 640px) {
  body {
    padding: 6px;
    justify-content: flex-start;
  }

  .hub-cards-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .card-visual {
    height: 70px;
  }

  .card-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .hub-card {
    padding: 16px;
    gap: 10px;
  }

  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: block;
  }

  .dpad-grid {
    grid-template-columns: repeat(3, 48px);
    grid-template-rows: repeat(3, 48px);
    gap: 4px;
    padding: 8px;
  }
}

@media (min-width: 768px) {
  .touch-controls {
    display: none;
  }
}
