/* Halfway Scrimmage - Bespoke Air Soccer Table Duel
   Styles & Visual Design System */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Orbitron:wght@600;800;900&family=Rajdhani:wght@600;700;800&display=swap');

:root {
  --bg-obsidian: #080c14;
  --pitch-dark: #041e17;
  --pitch-emerald: #064e3b;
  --halfway-cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.45);
  --mallet-red: #dc2626;
  --red-glow: rgba(220, 38, 38, 0.45);
  --victory-gold: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.5);
  --titanium-silver: #e2e8f0;
  --line-white: #ffffff;
  --card-bg: rgba(8, 12, 20, 0.88);
  --card-border: rgba(6, 182, 212, 0.35);
  --font-display: 'Orbitron', -apple-system, sans-serif;
  --font-ui: 'Rajdhani', -apple-system, sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-obsidian);
  color: var(--titanium-silver);
  font-family: var(--font-body);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Background Atmosphere */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center, rgba(6, 78, 59, 0.18) 0%, rgba(8, 12, 20, 0.95) 70%);
  pointer-events: none;
  z-index: 0;
}

#app-viewport {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100%;
  max-height: 920px;
  display: flex;
  flex-direction: column;
  background: var(--bg-obsidian);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.9), 0 0 30px rgba(6, 182, 212, 0.15);
  overflow: hidden;
  z-index: 1;
}

/* Chamfered Utility */
.chamfer-sm {
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
}

.chamfer-md {
  clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 14px, 100% calc(100% - 14px), calc(100% - 14px) 100%, 14px 100%, 0 calc(100% - 14px), 0 14px);
}

.chamfer-lg {
  clip-path: polygon(20px 0, calc(100% - 20px) 0, 100% 20px, 100% calc(100% - 20px), calc(100% - 20px) 100%, 20px 100%, 0 calc(100% - 20px), 0 20px);
}

/* Button Component */
.btn-chamfer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.25), rgba(6, 182, 212, 0.08));
  border: 1px solid var(--halfway-cyan);
  color: var(--line-white);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  outline: none;
}

.btn-chamfer:hover {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.4), rgba(6, 182, 212, 0.18));
  box-shadow: 0 0 16px var(--cyan-glow);
  transform: translateY(-1px);
}

.btn-chamfer:active {
  transform: scale(0.97);
  background: var(--halfway-cyan);
  color: var(--bg-obsidian);
}

.btn-primary {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.35), rgba(220, 38, 38, 0.12));
  border-color: var(--mallet-red);
}

.btn-primary:hover {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.5), rgba(220, 38, 38, 0.25));
  box-shadow: 0 0 20px var(--red-glow);
}

.btn-gold {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.35), rgba(245, 158, 11, 0.12));
  border-color: var(--victory-gold);
  color: var(--victory-gold);
}

.btn-gold:hover {
  box-shadow: 0 0 20px var(--gold-glow);
}

.btn-secondary {
  background: rgba(226, 232, 240, 0.08);
  border-color: rgba(226, 232, 240, 0.3);
  color: var(--titanium-silver);
}

/* Game Screens Framework */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* 1. ONBOARDING SCREEN */
#screen-onboarding {
  padding: 24px 20px;
  justify-content: space-between;
  align-items: center;
  background: radial-gradient(circle at 50% 30%, rgba(6, 78, 59, 0.3) 0%, var(--bg-obsidian) 70%);
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(4, 30, 23, 0.85);
  border: 1px solid var(--halfway-cyan);
  color: var(--halfway-cyan);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
}

.onboarding-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-top: 10px;
}

.onboarding-title-main {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--line-white);
  line-height: 1.1;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

.onboarding-title-sub {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 6px;
  color: var(--halfway-cyan);
  text-shadow: 0 0 24px var(--cyan-glow);
}

.onboarding-icon-preview {
  width: 180px;
  height: 180px;
  margin: 20px 0;
  border: 2px solid var(--halfway-cyan);
  box-shadow: 0 0 32px var(--cyan-glow), 0 0 60px rgba(6, 78, 59, 0.4);
  position: relative;
  overflow: hidden;
}

.onboarding-icon-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.feature-cards {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feature-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: rgba(4, 30, 23, 0.5);
  border: 1px solid rgba(6, 182, 212, 0.25);
}

.feature-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(6, 182, 212, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--halfway-cyan);
  font-size: 18px;
  flex-shrink: 0;
}

.feature-info h4 {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: var(--line-white);
  margin-bottom: 2px;
}

.feature-info p {
  font-size: 11px;
  color: rgba(226, 232, 240, 0.7);
  line-height: 1.3;
}

/* 2. MAIN HUB SCREEN */
#screen-hub {
  padding: 16px;
  justify-content: space-between;
}

.hub-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.topbar-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(4, 30, 23, 0.85);
  border: 1px solid var(--halfway-cyan);
}

.topbar-pill.gold {
  border-color: var(--victory-gold);
  color: var(--victory-gold);
}

.topbar-pill span {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
}

.hub-hero-box {
  width: 100%;
  padding: 10px;
  background: rgba(4, 30, 23, 0.6);
  border: 1px solid rgba(6, 182, 212, 0.4);
  display: flex;
  flex-direction: column;
}

.hero-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--halfway-cyan);
}

.live-badge {
  background: rgba(220, 38, 38, 0.25);
  color: var(--mallet-red);
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 800;
  border-radius: 2px;
}

#preview-canvas-container {
  width: 100%;
  height: 240px;
  position: relative;
  background: #000;
  overflow: hidden;
}

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

.hub-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hub-modules-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.hub-module-btn {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: rgba(8, 12, 20, 0.7);
  border: 1px solid rgba(6, 182, 212, 0.35);
  color: var(--line-white);
  cursor: pointer;
  transition: all 0.15s ease;
}

.hub-module-btn:hover {
  background: rgba(6, 182, 212, 0.15);
  border-color: var(--halfway-cyan);
  box-shadow: 0 0 14px var(--cyan-glow);
}

.hub-module-btn .icon {
  font-size: 22px;
  margin-bottom: 4px;
}

.hub-module-btn .title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
}

.hub-module-btn .subtitle {
  font-size: 9px;
  color: rgba(226, 232, 240, 0.6);
  margin-top: 2px;
}

/* 3. ARENA GAME SCREEN */
#screen-arena {
  width: 100%;
  height: 100%;
  position: relative;
  touch-action: none;
}

#arena-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

.arena-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 5;
  pointer-events: none;
}

.arena-hud > * {
  pointer-events: auto;
}

.hud-score-card {
  padding: 6px 14px;
  background: rgba(8, 12, 20, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.4);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-score-card.player {
  border-color: var(--mallet-red);
  color: var(--mallet-red);
}

.hud-center-timer {
  padding: 6px 14px;
  background: rgba(4, 30, 23, 0.9);
  border: 1px solid var(--halfway-cyan);
  text-align: center;
}

.hud-center-timer .timer-val {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--line-white);
}

.hud-center-timer .target-label {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  color: var(--halfway-cyan);
  letter-spacing: 1px;
}

/* Overdrive HUD indicator */
.arena-overdrive-bar {
  position: absolute;
  bottom: 12px;
  left: 20px;
  right: 20px;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  z-index: 5;
  pointer-events: none;
}

.arena-overdrive-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--halfway-cyan), var(--victory-gold));
  box-shadow: 0 0 10px var(--gold-glow);
  transition: width 0.15s ease-out;
}

/* Goal Celebration Banner */
#goal-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  padding: 16px 28px;
  background: rgba(8, 12, 20, 0.95);
  border: 2px solid var(--victory-gold);
  box-shadow: 0 0 30px var(--gold-glow);
  text-align: center;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#goal-banner.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

#goal-banner h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--victory-gold);
  margin-bottom: 4px;
}

#goal-banner p {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 900;
  color: var(--halfway-cyan);
}

/* MODALS (STRIKER LAB, TOURNAMENT, SETTINGS, MATCH OVER) */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 100;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-obsidian);
  border: 2px solid var(--halfway-cyan);
  box-shadow: 0 0 40px rgba(6, 182, 212, 0.25);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-box::-webkit-scrollbar {
  width: 4px;
}

.modal-box::-webkit-scrollbar-thumb {
  background: var(--halfway-cyan);
}

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

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--line-white);
}

.close-btn {
  background: none;
  border: none;
  color: var(--titanium-silver);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

.close-btn:hover {
  color: var(--halfway-cyan);
}

/* Tuning Lab Styles */
.mallet-showcase {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(4, 30, 23, 0.6);
  border: 1px solid var(--halfway-cyan);
  padding: 16px;
}

.mallet-showcase-canvas-wrap {
  width: 140px;
  height: 140px;
  margin: 14px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 23, 42, 0.95) 0%, rgba(6, 12, 22, 0.98) 70%);
  border: 2px solid var(--halfway-cyan);
  box-shadow: 0 0 24px rgba(6, 182, 212, 0.35), inset 0 0 20px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

#showcase-canvas {
  width: 130px;
  height: 130px;
  display: block;
  background: transparent;
}

.stat-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}

.stat-track {
  width: 140px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  background: var(--halfway-cyan);
}

.mallet-selector-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.mallet-pick-card {
  padding: 8px 4px;
  background: rgba(8, 12, 20, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mallet-pick-card.selected {
  border-color: var(--halfway-cyan);
  box-shadow: 0 0 12px var(--cyan-glow);
  background: rgba(6, 182, 212, 0.15);
}

.mallet-color-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  margin: 0 auto 6px auto;
  border: 1px solid #fff;
}

/* Tournament Ladder Styles */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric-tile {
  padding: 10px;
  background: rgba(4, 30, 23, 0.6);
  border: 1px solid rgba(6, 182, 212, 0.3);
  display: flex;
  align-items: center;
  gap: 10px;
}

.trophy-item {
  padding: 12px;
  background: rgba(8, 12, 20, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trophy-item.unlocked {
  border-color: var(--victory-gold);
  background: rgba(245, 158, 11, 0.08);
}

.trophy-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.trophy-progress-fill {
  height: 100%;
  background: var(--victory-gold);
}

/* Settings Row */
.setting-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #334155;
  transition: .2s;
  border-radius: 24px;
}

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

input:checked + .slider {
  background-color: var(--halfway-cyan);
}

input:checked + .slider:before {
  transform: translateX(20px);
}


/* ===== v2 layout overrides ===== */
#screen-hub { padding: 14px 14px 16px; gap: 12px; justify-content: flex-start; }
.hub-hero-box { flex: 1; min-height: 0; }
#preview-canvas-container { flex: 1; height: auto; min-height: 0; background: #04070d; }
#preview-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

#screen-arena { position: absolute; inset: 0; width: 100%; height: 100%; display: flex; flex-direction: column; touch-action: none; background: #04070d; }
.arena-hud { position: relative; top: auto; left: auto; right: auto; flex: 0 0 auto; padding: 10px 12px 8px; gap: 8px; }
#arena-stage { position: relative; flex: 1; min-height: 0; }
#arena-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.arena-footer { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 8px 16px calc(12px + env(safe-area-inset-bottom)); }
.od-label { font-family: var(--font-ui); font-size: 11px; font-weight: 800; letter-spacing: 2px; color: var(--victory-gold); }
.arena-overdrive-bar { position: relative; left: auto; right: auto; bottom: auto; flex: 1; height: 10px; border-radius: 0; clip-path: polygon(5px 0, 100% 0, calc(100% - 5px) 100%, 0 100%); border: 0; background: rgba(255,255,255,0.1); }
.arena-overdrive-fill.burning { animation: odpulse .35s ease-in-out infinite alternate; }
@keyframes odpulse { from { filter: brightness(1); } to { filter: brightness(1.6); } }

#countdown { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-family: var(--font-display); font-size: 104px; font-weight: 900; color: #fff; text-shadow: 0 0 36px var(--cyan-glow), 0 0 8px rgba(255,255,255,.6); pointer-events: none; opacity: 0; z-index: 15; }
#countdown.pop { animation: cdpop .75s ease-out forwards; }
@keyframes cdpop { 0% { transform: translate(-50%, -50%) scale(2); opacity: 0; } 25% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(.85); opacity: 0; } }
