/* === Design Tokens === */
:root {
  --font-display: 'Anton', 'Barlow Condensed', sans-serif;
  --font-body: 'Inter', 'Barlow Condensed', sans-serif;
  --font-hud: 'Barlow Condensed', 'Inter', sans-serif;

  /* Stadium night palette */
  --color-bg: #0a0e0f;
  --color-surface: rgba(10, 20, 15, 0.75);
  --color-surface-2: rgba(15, 30, 22, 0.85);
  --color-border: rgba(100, 255, 150, 0.2);
  --color-text: #e8f5e9;
  --color-text-muted: #8aa39a;
  --color-primary: #4aff80;
  --color-primary-dim: #2ecc60;
  --color-danger: #ff4466;
  --color-warning: #ffaa22;
  --color-accent: #4fc3f7;
  --color-team-home: #2196f3;
  --color-team-away: #ff5722;

  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 20px;
  --text-xl: 28px;
  --text-2xl: 48px;
  --text-3xl: 72px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;

  --panel-blur: 10px;
  --panel-radius: 8px;
  --transition-ui: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--color-bg);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
}

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

/* === Game UI === */
.game-ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  font-family: var(--font-hud);
}

.hidden {
  display: none !important;
}

/* === HUD Top Bar === */
.hud-top {
  position: absolute;
  top: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: var(--space-3);
  align-items: stretch;
}

.hud-panel {
  background: var(--color-surface);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--color-border);
  border-radius: var(--panel-radius);
  padding: var(--space-2) var(--space-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 110px;
}

.hud-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.hud-value {
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--color-text);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* === Burst Meter === */
.burst-container {
  position: absolute;
  bottom: var(--space-6);
  left: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.burst-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--color-text-muted);
}

.burst-bar {
  width: 180px;
  height: 12px;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
}

.burst-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--color-primary-dim), var(--color-primary));
  border-radius: 5px;
  transition: width 0.1s linear;
  box-shadow: 0 0 8px var(--color-primary);
}

/* === Minimap === */
#minimap {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 200px;
  height: 320px;
  background: rgba(0,0,0,0.6);
  border: 1px solid var(--color-border);
  border-radius: var(--panel-radius);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
}

/* === Crosshair === */
.crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
}

.crosshair::before, .crosshair::after {
  content: '';
  position: absolute;
  background: rgba(255,255,255,0.6);
}

.crosshair::before {
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  transform: translateY(-50%);
}

.crosshair::after {
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-50%);
}

/* === Controls Hint === */
.controls-hint {
  position: absolute;
  bottom: var(--space-6);
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  align-items: flex-end;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.controls-hint span {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: var(--font-hud);
  font-size: 11px;
  font-weight: 700;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  color: var(--color-text);
  line-height: 1.4;
}

/* === Banners === */
.banner {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  animation: bannerPulse 0.5s ease-out;
}

.banner-text {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  color: var(--color-primary);
  text-shadow: 0 0 20px var(--color-primary), 0 4px 8px rgba(0,0,0,0.8);
  letter-spacing: 0.05em;
  line-height: 1;
}

.banner-sub {
  font-family: var(--font-hud);
  font-size: var(--text-base);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

@keyframes bannerPulse {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  50% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* === Overlay Screens === */
.overlay-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(10,30,15,0.95) 0%, rgba(5,10,8,0.98) 100%);
}

.screen-content {
  text-align: center;
  padding: var(--space-8);
  max-width: 500px;
}

.game-title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  line-height: 0.9;
  letter-spacing: 0.03em;
  color: var(--color-primary);
  text-shadow: 0 0 30px rgba(74,255,128,0.5), 0 4px 12px rgba(0,0,0,0.8);
  margin-bottom: var(--space-2);
}

.gameover-title {
  color: var(--color-danger);
  text-shadow: 0 0 30px rgba(255,68,102,0.5), 0 4px 12px rgba(0,0,0,0.8);
}

.touchdown-title {
  color: var(--color-warning);
  text-shadow: 0 0 30px rgba(255,170,34,0.5), 0 4px 12px rgba(0,0,0,0.8);
  animation: tdGlow 0.8s ease-in-out infinite alternate;
}

@keyframes tdGlow {
  from { text-shadow: 0 0 20px rgba(255,170,34,0.4), 0 4px 12px rgba(0,0,0,0.8); }
  to { text-shadow: 0 0 50px rgba(255,170,34,0.8), 0 4px 12px rgba(0,0,0,0.8); }
}

.game-subtitle {
  font-family: var(--font-hud);
  font-size: var(--text-base);
  color: var(--color-text-muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: var(--space-6);
}

.instructions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  text-align: left;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.instruction-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text);
}

.instruction-row kbd {
  min-width: 24px;
  text-align: center;
}

.objective {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
  line-height: 1.6;
}

.game-btn {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  letter-spacing: 0.1em;
  padding: var(--space-3) var(--space-8);
  background: var(--color-primary);
  color: var(--color-bg);
  border: none;
  border-radius: var(--panel-radius);
  cursor: pointer;
  transition: all var(--transition-ui);
  pointer-events: auto;
  box-shadow: 0 4px 16px rgba(74,255,128,0.3);
}

.game-btn:hover {
  background: #6affa0;
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(74,255,128,0.4);
}

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

/* === Result Stats === */
.result-stats {
  display: flex;
  justify-content: center;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stat-value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--color-primary);
}

/* === Debug === */
#debug-overlay {
  position: fixed;
  bottom: var(--space-1);
  left: var(--space-2);
  z-index: 30;
  font-family: monospace;
  font-size: 11px;
  color: var(--color-primary);
  background: rgba(0,0,0,0.5);
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
  display: none;
}

#debug-overlay.visible {
  display: block;
}

/* === Mobile Touch Controls === */
.mobile-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  display: none;
}

.mobile-controls.visible {
  display: block;
}

/* Virtual Joystick */
.joystick-zone {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 45%;
  height: 55%;
  pointer-events: auto;
  touch-action: none;
}

.joystick-base {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: 2px solid rgba(74,255,128,0.4);
  bottom: 30px;
  left: 30px;
  transition: opacity 0.2s;
  opacity: 0.85;
}

.joystick-base.active {
  opacity: 1;
  border-color: var(--color-primary);
  box-shadow: 0 0 20px rgba(74,255,128,0.3);
}

.joystick-thumb {
  position: absolute;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(74,255,128,0.5);
  border: 2px solid var(--color-primary);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: none;
  box-shadow: 0 0 12px rgba(74,255,128,0.4);
}

/* Look zone (right side, invisible) */
.look-zone {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 55%;
  height: 75%;
  pointer-events: auto;
  touch-action: none;
  z-index: 14;
}

/* Action Buttons */
.action-buttons {
  position: absolute;
  bottom: 30px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  pointer-events: auto;
}

.action-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.05em;
  color: #fff;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.1;
  transition: transform 0.1s, opacity 0.2s;
}

.burst-btn {
  background: rgba(74,255,128,0.25);
  border-color: var(--color-primary);
  box-shadow: 0 0 16px rgba(74,255,128,0.2);
}

.burst-btn:active,
.burst-btn.held {
  background: rgba(74,255,128,0.5);
  transform: scale(0.92);
}

.juke-btn {
  background: rgba(79,195,247,0.25);
  border-color: var(--color-accent);
  box-shadow: 0 0 16px rgba(79,195,247,0.2);
}

.juke-btn:active,
.juke-btn.held {
  background: rgba(79,195,247,0.5);
  transform: scale(0.92);
}

/* === Responsive / Mobile === */
@media (max-width: 768px), (pointer: coarse) {
  .controls-hint {
    display: none;
  }

  .mobile-controls {
    display: block;
  }

  /* Smaller HUD panels */
  .hud-top {
    gap: var(--space-1);
    flex-wrap: nowrap;
    top: var(--space-2);
  }

  .hud-panel {
    padding: var(--space-1) var(--space-2);
    min-width: 70px;
  }

  .hud-label {
    font-size: 9px;
  }

  .hud-value {
    font-size: 13px;
  }

  /* Smaller minimap, moved down to avoid HUD */
  #minimap {
    width: 100px;
    height: 150px;
    top: 50px;
    right: var(--space-1);
  }

  /* Burst meter repositioned to avoid joystick */
  .burst-container {
    bottom: auto;
    top: 60px;
    left: 8px;
  }

  .burst-bar {
    width: 80px;
    height: 8px;
  }

  .burst-label {
    font-size: 8px;
  }

  /* Screen content adjustments */
  .screen-content {
    padding: var(--space-4);
    max-width: 90vw;
  }

  .game-title {
    font-size: 48px;
  }

  .game-subtitle {
    font-size: 12px;
  }

  .instructions {
    gap: var(--space-1);
  }

  .instruction-row {
    font-size: 13px;
  }

  .objective {
    font-size: 12px;
  }

  .game-btn {
    font-size: 18px;
    padding: var(--space-2) var(--space-6);
  }

  .stat-value {
    font-size: 32px;
  }

  .stat-label {
    font-size: 10px;
  }

  .result-stats {
    gap: var(--space-4);
  }
}

/* Landscape phone recommendation */
@media (max-height: 500px) and (orientation: landscape) {
  .screen-content {
    padding: var(--space-2);
  }

  .game-title {
    font-size: 36px;
  }

  .instructions {
    margin-bottom: var(--space-2);
  }

  .objective {
    margin-bottom: var(--space-2);
    font-size: 11px;
  }

  .game-btn {
    font-size: 16px;
    padding: var(--space-1) var(--space-4);
  }

  .stat-value {
    font-size: 24px;
  }
}

/* === Install Button === */
.install-btn {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: var(--space-2) var(--space-6);
  margin-top: var(--space-3);
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--panel-radius);
  cursor: pointer;
  transition: all var(--transition-ui);
  pointer-events: auto;
}

.install-btn:hover {
  color: var(--color-text);
  border-color: var(--color-primary);
  background: rgba(74,255,128,0.05);
}

/* === Difficulty Selector === */
.difficulty-selector {
  margin-bottom: var(--space-6);
  text-align: center;
}

.difficulty-label {
  font-family: var(--font-hud);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.difficulty-options {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
}

.difficulty-btn {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  letter-spacing: 0.08em;
  padding: var(--space-2) var(--space-4);
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--panel-radius);
  cursor: pointer;
  transition: all var(--transition-ui);
  pointer-events: auto;
}

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

.difficulty-btn.selected {
  background: var(--color-primary);
  color: var(--color-bg);
  border-color: var(--color-primary);
  box-shadow: 0 0 12px rgba(74,255,128,0.3);
}

@media (max-width: 768px) {
  .difficulty-btn {
    font-size: 12px;
    padding: var(--space-1) var(--space-3);
  }
}
