/* ==========================================================================
   SHOCK CIRCUIT - MODERN TESLA COIL & REALISTIC PLASMA GLOBE
   ========================================================================== */

:root {
  --bg-dark: #03060c;
  --bg-surface: #070e1a;
  
  /* Player 1 - Ionic Cyan Theme */
  --p1-neon: #00f0ff;
  --p1-glow: rgba(0, 240, 255, 0.7);
  --p1-dark: #003740;
  --p1-mesh: rgba(0, 240, 255, 0.08);

  /* Player 2 - High-Voltage Magenta Theme */
  --p2-neon: #ff0077;
  --p2-glow: rgba(255, 0, 119, 0.7);
  --p2-dark: #40001f;
  --p2-mesh: rgba(255, 0, 119, 0.08);

  /* Realistic Plasma Palette */
  --plasma-purple: #9d00ff;
  --plasma-fuchsia: #ff00aa;
  --plasma-blue: #00d4ff;
  --plasma-core: #ffffff;

  /* Shared Core & Alerts */
  --core-gold: #ffcc00;
  --alert-red: #ff2a2a;
  --alert-glow: rgba(255, 42, 42, 0.8);
  --text-dim: #7e8c9f;
  --text-bright: #ffffff;
  
  --font-display: 'Orbitron', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-tech: 'Chakra Petch', 'Rajdhani', monospace;
  --font-body: 'Rajdhani', -apple-system, sans-serif;
}

/* Reset & Mobile Viewport Locking */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  background-color: var(--bg-dark);
  color: var(--text-bright);
  font-family: var(--font-body);
  touch-action: none;
}

/* ==========================================================================
   CANVAS & FLASH OVERLAYS
   ========================================================================== */

#lightning-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
}

.flash-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #ffffff;
  opacity: 0;
  z-index: 50;
  pointer-events: none;
  transition: opacity 0.04s ease-out;
}

.flash-overlay.active {
  opacity: 1;
  box-shadow: inset 0 0 120px rgba(255, 255, 255, 1);
}

/* ==========================================================================
   MAIN GAME SPLIT SCREEN CONTAINER
   ========================================================================== */

.game-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  background: radial-gradient(circle at 50% 50%, #0c1527 0%, var(--bg-dark) 85%);
  transition: background 0.3s ease;
}

/* State: Waiting (Pitch Black Mode) */
.game-container.state-waiting {
  background: #000000 !important;
}

.game-container.state-waiting .player-content-wrapper,
.game-container.state-waiting .center-bar {
  opacity: 0;
  filter: blur(8px);
  pointer-events: none;
  transition: opacity 0.25s ease-out, filter 0.25s ease-out;
}

/* State: Round Over (Absolute Visual Rest & Clean Darkness) */
.game-container.state-round-over {
  background: #03060c !important;
}

.game-container.state-round-over .touch-target-center {
  opacity: 0.15;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* ==========================================================================
   PLAYER ZONES (SPLIT SCREEN)
   ========================================================================== */

.player-zone {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.5rem;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.player2-zone {
  background: radial-gradient(ellipse at 50% 0%, var(--p2-mesh) 0%, transparent 70%);
  border-bottom: 1px solid rgba(255, 0, 119, 0.2);
}

.player1-zone {
  background: radial-gradient(ellipse at 50% 100%, var(--p1-mesh) 0%, transparent 70%);
  border-top: 1px solid rgba(0, 240, 255, 0.2);
}

/* Mirrored 180° for Player 2 (Top Half) */
.mirrored {
  transform: rotate(180deg);
  transform-origin: center center;
}

.player-content-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  width: 100%;
  position: relative;
  transition: opacity 0.3s ease, filter 0.3s ease;
  z-index: 5;
}

/* Zone Background Ambient Grid */
.zone-bg-mesh {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  opacity: 0.5;
}

/* ==========================================================================
   HEADER & SCORE PIPS
   ========================================================================== */

.player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  z-index: 10;
}

.player-identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.player-badge {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 2px;
}

.p1-badge {
  color: var(--p1-neon);
  text-shadow: 0 0 12px var(--p1-glow);
}

.p2-badge {
  color: var(--p2-neon);
  text-shadow: 0 0 12px var(--p2-glow);
}

.player-role {
  font-family: var(--font-tech);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}

/* Score Pips (Capacitors) */
.score-container {
  display: flex;
  gap: 8px;
  align-items: center;
}

.score-pip {
  width: 14px;
  height: 24px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  position: relative;
  overflow: hidden;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.player1-zone .score-pip.active {
  background: var(--p1-neon);
  border-color: #ffffff;
  box-shadow: 0 0 15px var(--p1-glow), 0 0 30px var(--p1-neon);
  transform: scale(1.15);
}

.player2-zone .score-pip.active {
  background: var(--p2-neon);
  border-color: #ffffff;
  box-shadow: 0 0 15px var(--p2-glow), 0 0 30px var(--p2-neon);
  transform: scale(1.15);
}

/* ==========================================================================
   CENTERED TOUCH TARGET & FINGERPRINT SVG
   ========================================================================== */

.touch-target-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 8;
  pointer-events: auto;
  transition: opacity 0.3s ease;
}

.fingerprint-wrapper {
  position: relative;
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.05);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.fingerprint-svg {
  width: 58px;
  height: 58px;
  transition: all 0.25s ease;
}

.player1-zone .fingerprint-svg {
  color: rgba(0, 240, 255, 0.5);
  filter: drop-shadow(0 0 4px rgba(0, 240, 255, 0.4));
}

.player2-zone .fingerprint-svg {
  color: rgba(255, 0, 119, 0.5);
  filter: drop-shadow(0 0 4px rgba(255, 0, 119, 0.4));
}

.fingerprint-glow-ring {
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  pointer-events: none;
  animation: rotateClockwise 18s linear infinite;
}

.fingerprint-pulse-wave {
  position: absolute;
  top: -14px;
  left: -14px;
  right: -14px;
  bottom: -14px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
  animation: pulseScale 3s infinite ease-in-out;
}

.touch-prompt {
  margin-top: 8px;
  font-family: var(--font-tech);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-shadow: 0 0 8px rgba(0,0,0,0.8);
  white-space: nowrap;
}

/* Active Holding on Fingerprint */
.player1-zone.holding .fingerprint-wrapper {
  background: rgba(0, 240, 255, 0.18);
  border-color: var(--p1-neon);
  box-shadow: 0 0 35px var(--p1-glow), inset 0 0 20px var(--p1-neon);
  transform: scale(1.12);
}

.player1-zone.holding .fingerprint-svg {
  color: #ffffff;
  filter: drop-shadow(0 0 10px var(--p1-neon)) drop-shadow(0 0 20px var(--p1-neon));
}

.player1-zone.holding .fingerprint-glow-ring {
  border-color: var(--p1-neon);
  animation-duration: 3.5s;
}

.player2-zone.holding .fingerprint-wrapper {
  background: rgba(255, 0, 119, 0.18);
  border-color: var(--p2-neon);
  box-shadow: 0 0 35px var(--p2-glow), inset 0 0 20px var(--p2-neon);
  transform: scale(1.12);
}

.player2-zone.holding .fingerprint-svg {
  color: #ffffff;
  filter: drop-shadow(0 0 10px var(--p2-neon)) drop-shadow(0 0 20px var(--p2-neon));
}

.player2-zone.holding .fingerprint-glow-ring {
  border-color: var(--p2-neon);
  animation-duration: 3.5s;
}

/* ==========================================================================
   REPOSITIONED COUNTDOWN CONTAINERS (NEAR CENTER DIVIDER)
   ========================================================================== */

.center-countdown-container {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 25;
  pointer-events: none;
}

.countdown-p1 {
  top: 14px;
}

.countdown-p2 {
  top: 14px;
}

.countdown-text {
  font-family: var(--font-display);
  font-size: 5rem;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 0 25px var(--plasma-purple), 0 0 50px var(--plasma-blue), 0 0 80px #ffffff;
  opacity: 0;
  transform: scale(0.5);
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s;
}

.countdown-text.pop {
  transform: scale(1.2);
  opacity: 1;
}

/* ==========================================================================
   STATUS WRAPPER, REACTION BADGES & MANUAL CONTINUE BUTTON
   ========================================================================== */

.player-status-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  position: relative;
  z-index: 10;
  padding-bottom: 0.25rem;
}

.status-primary {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  margin-bottom: 2px;
  transition: color 0.2s, transform 0.2s;
}

.player1-zone .status-primary {
  color: #cffffd;
  text-shadow: 0 0 14px var(--p1-glow);
}

.player2-zone .status-primary {
  color: #ffd8ec;
  text-shadow: 0 0 14px var(--p2-glow);
}

.status-secondary {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 1px;
}

/* Reaction Time Badge */
.reaction-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 20px;
  font-family: var(--font-tech);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  margin-top: 6px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  white-space: nowrap;
}

.reaction-badge.show {
  opacity: 1;
  transform: translateY(0);
}

.reaction-badge.winner {
  background: rgba(0, 240, 255, 0.22);
  border: 1px solid var(--p1-neon);
  color: #ffffff;
  box-shadow: 0 0 25px var(--p1-glow);
}

.player2-zone .reaction-badge.winner {
  background: rgba(255, 0, 119, 0.22);
  border: 1px solid var(--p2-neon);
  box-shadow: 0 0 25px var(--p2-glow);
}

.reaction-badge.loser {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #d0d8e2;
}

.reaction-badge.early {
  background: rgba(255, 42, 42, 0.25);
  border: 1px solid var(--alert-red);
  color: #ff8888;
  box-shadow: 0 0 25px var(--alert-glow);
}

/* Manual Next Round Continue Button */
.btn-round-continue {
  margin-top: 12px;
  padding: 10px 22px;
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 2px;
  cursor: pointer;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: pulseContinue 1.8s infinite ease-in-out;
  transition: all 0.2s ease;
  pointer-events: auto;
}

.player1-zone .btn-round-continue {
  background: rgba(0, 240, 255, 0.15);
  border: 1.5px solid var(--p1-neon);
  color: #ffffff;
  box-shadow: 0 0 20px var(--p1-glow);
}

.player2-zone .btn-round-continue {
  background: rgba(255, 0, 119, 0.15);
  border: 1.5px solid var(--p2-neon);
  color: #ffffff;
  box-shadow: 0 0 20px var(--p2-glow);
}

.btn-round-continue:active {
  transform: scale(0.95);
}

.btn-round-continue.hidden {
  display: none !important;
}

/* ==========================================================================
   CENTER BAR & TESLA REACTOR
   ========================================================================== */

.center-bar {
  height: 44px;
  width: 100%;
  background: #060b14;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  position: relative;
  z-index: 15;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}

.center-reactor {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: #091220;
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.5);
}

.reactor-coil {
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--core-gold);
  animation: pulseGold 2s infinite ease-in-out;
}

.round-indicator {
  font-family: var(--font-tech);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-bright);
}

.btn-quick-reset {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-dim);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-quick-reset:hover,
.btn-quick-reset:active {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-bright);
}

/* ==========================================================================
   SHORT CIRCUIT & ALERT ANIMATIONS
   ========================================================================== */

.short-circuit {
  background: radial-gradient(circle at center, rgba(255, 42, 42, 0.35) 0%, #150000 80%) !important;
  animation: screenShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.short-circuit .status-primary {
  color: var(--alert-red) !important;
  text-shadow: 0 0 20px var(--alert-glow) !important;
}

/* ==========================================================================
   AUDIO UNLOCK & VICTORY MODALS
   ========================================================================== */

.audio-unlock-overlay,
.match-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(2, 4, 8, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.audio-unlock-overlay.hidden,
.match-modal.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.unlock-content,
.modal-card {
  background: #091220;
  border: 1px solid rgba(0, 240, 255, 0.3);
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.15), 0 20px 40px rgba(0,0,0,0.8);
  border-radius: 16px;
  padding: 2rem 1.75rem;
  max-width: 380px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.coil-icon,
.modal-sparkles {
  font-size: 2.2rem;
  margin-bottom: 0.5rem;
  animation: pulseGold 2s infinite ease-in-out;
}

.unlock-content h2,
.winner-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--text-bright);
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
}

.tagline,
.winner-desc {
  font-family: var(--font-tech);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--p1-neon);
  margin-bottom: 1.25rem;
}

.instructions-card {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  padding: 1rem;
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
  color: #ccd6e0;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.inst-row span {
  color: var(--p1-neon);
  font-weight: 700;
  font-family: var(--font-tech);
}

.inst-warn {
  color: #ff9955;
  font-size: 0.75rem;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

.pinch-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 1rem;
}

.btn-start {
  width: 100%;
  padding: 14px 20px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, var(--p1-neon) 0%, #0088ff 100%);
  color: #030712;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 0 25px var(--p1-glow);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-start:active {
  transform: scale(0.97);
}

/* Match Stats Grid */
.match-stats-grid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  width: 100%;
  margin: 1.25rem 0;
}

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

.stat-label {
  font-family: var(--font-tech);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-dim);
}

.stat-val {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 900;
}

.p1-stat .stat-val {
  color: var(--p1-neon);
  text-shadow: 0 0 15px var(--p1-glow);
}

.p2-stat .stat-val {
  color: var(--p2-neon);
  text-shadow: 0 0 15px var(--p2-glow);
}

.stat-divider {
  font-family: var(--font-tech);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-dim);
}

.best-reaction-container {
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 16px;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.reaction-title {
  font-family: var(--font-tech);
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}

.best-time-val {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--core-gold);
  text-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
}

/* ==========================================================================
   FAKE SPARK ELEMENT
   ========================================================================== */

.fake-spark-element {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.9);
  pointer-events: none;
  opacity: 0;
  z-index: 40;
  transition: opacity 0.05s ease-out;
}

.fake-spark-element.flash-spark {
  opacity: 0.6;
  transform: scale(2.2);
}

/* ==========================================================================
   KEYFRAME ANIMATIONS
   ========================================================================== */

@keyframes rotateClockwise {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulseScale {
  0%, 100% { transform: scale(1); opacity: 0.2; }
  50% { transform: scale(1.12); opacity: 0.6; }
}

@keyframes pulseGold {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 4px var(--core-gold)); }
  50% { transform: scale(1.2); filter: drop-shadow(0 0 12px var(--core-gold)); }
}

@keyframes pulseContinue {
  0%, 100% { transform: scale(1); box-shadow: 0 0 15px var(--p1-glow); }
  50% { transform: scale(1.06); box-shadow: 0 0 28px var(--p1-neon); }
}

@keyframes screenShake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(3px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}
