/* ═══════════════════════════════════════════════════════════
   PUNCH ARKING — style.css
   Cyberpunk dark theme with cyan/magenta accents
   ═══════════════════════════════════════════════════════════ */

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

:root {
  --bg-deep:      #05071400;
  --bg-dark:      #080c1a;
  --bg-card:      rgba(10, 15, 35, 0.85);
  --cyan:         #00f5ff;
  --cyan-dim:     rgba(0, 245, 255, 0.15);
  --cyan-glow:    rgba(0, 245, 255, 0.5);
  --magenta:      #ff00aa;
  --magenta-dim:  rgba(255, 0, 170, 0.15);
  --orange:       #ff6622;
  --yellow:       #ffdd00;
  --green:        #00ff88;
  --red:          #ff2244;
  --text-primary: #e8f0fe;
  --text-dim:     rgba(232, 240, 254, 0.5);
  --border:       rgba(0, 245, 255, 0.25);
  --font-hud:     'Orbitron', monospace;
  --font-body:    'Inter', sans-serif;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* ─── Screens ───────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 1;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ─── Background grid ──────────────────────────────────────── */
.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,245,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,245,255,0.04) 1px, transparent 1px);
  background-size: 50px 50px;
  animation: gridPulse 8s ease-in-out infinite;
  z-index: 0;
}
@keyframes gridPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ─── Animated BG gradient ─────────────────────────────────── */
#start-screen, #gameover-screen {
  background:
    radial-gradient(ellipse 80% 60% at 20% 50%, rgba(0,245,255,0.07) 0%, transparent 70%),
    radial-gradient(ellipse 60% 80% at 80% 40%, rgba(255,0,170,0.07) 0%, transparent 70%),
    #080c1a;
}

/* ─── BG Particles ─────────────────────────────────────────── */
.bg-particles {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.bg-particle {
  position: absolute;
  border-radius: 50%;
  animation: particleFloat linear infinite;
  opacity: 0;
}
@keyframes particleFloat {
  0%   { transform: translateY(100vh) scale(0); opacity: 0; }
  10%  { opacity: 0.6; }
  90%  { opacity: 0.3; }
  100% { transform: translateY(-20vh) scale(1.5); opacity: 0; }
}

/* ─── Glass Card ───────────────────────────────────────────── */
.glass-card {
  position: relative;
  z-index: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 48px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    0 0 60px rgba(0,245,255,0.08),
    0 0 0 1px rgba(0,245,255,0.1) inset,
    0 32px 64px rgba(0,0,0,0.5);
  max-width: 560px;
  width: 90%;
  text-align: center;
}

/* ─── Logo ─────────────────────────────────────────────────── */
.logo-text {
  font-family: var(--font-hud);
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  margin-bottom: 10px;
}
.logo-punch {
  color: var(--cyan);
  text-shadow: 0 0 20px var(--cyan-glow), 0 0 60px rgba(0,245,255,0.3);
}
.logo-arking {
  color: var(--magenta);
  text-shadow: 0 0 20px rgba(255,0,170,0.8), 0 0 60px rgba(255,0,170,0.3);
  margin-left: 12px;
}

.tagline {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 28px;
  font-weight: 300;
}

/* ─── Camera notice ────────────────────────────────────────── */
.camera-permission-notice {
  background: rgba(0,245,255,0.06);
  border: 1px solid rgba(0,245,255,0.2);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}
.notice-icon { font-size: 1.8rem; flex-shrink: 0; }
.camera-permission-notice p { font-size: 0.85rem; color: var(--text-dim); line-height: 1.5; }
.camera-permission-notice strong { color: var(--cyan); }

/* ─── Controls ─────────────────────────────────────────────── */
.start-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 28px;
}
.control-label {
  font-family: var(--font-hud);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  display: block;
  margin-bottom: 8px;
}
.btn-group {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.dur-btn, .sens-btn {
  flex: 1;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: var(--text-dim);
  font-family: var(--font-hud);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.2s;
}
.dur-btn:hover, .sens-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: var(--cyan-dim);
}
.dur-btn.active, .sens-btn.active {
  background: var(--cyan-dim);
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 12px rgba(0,245,255,0.2);
}

/* ─── Buttons ──────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 36px;
  background: linear-gradient(135deg, rgba(0,245,255,0.2), rgba(0,245,255,0.05));
  border: 2px solid var(--cyan);
  border-radius: 12px;
  color: var(--cyan);
  font-family: var(--font-hud);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: all 0.25s;
  width: 100%;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0,245,255,0.1) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.25s;
}
.btn-primary:hover::before { opacity: 1; }
.btn-primary:hover {
  box-shadow: 0 0 30px rgba(0,245,255,0.4), 0 0 60px rgba(0,245,255,0.15);
  transform: translateY(-2px);
}
.btn-primary:active { transform: translateY(1px); }
.btn-icon { font-size: 1.2rem; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  color: var(--text-dim);
  font-family: var(--font-hud);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
}
.btn-secondary:hover {
  border-color: rgba(255,255,255,0.4);
  color: var(--text-primary);
}

/* ─── Instructions ─────────────────────────────────────────── */
.instructions {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}
.inst-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.inst-key {
  font-size: 1.1rem;
}

/* ─── Hidden webcam ────────────────────────────────────────── */
#webcam-video {
  position: fixed;
  left: -9999px;
  top: -9999px;
  width: 640px;
  height: 480px;
}

/* ─── Game Canvas ──────────────────────────────────────────── */
#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: none;
}

/* ─── Hand Preview Canvas ──────────────────────────────────── */
.hand-preview {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 180px;
  height: 135px;
  border: 1px solid rgba(0,245,255,0.25);
  border-radius: 12px;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  z-index: 10;
}

/* ─── HUD ──────────────────────────────────────────────────── */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 24px;
  z-index: 10;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(5,7,20,0.9) 0%, transparent 100%);
}
.hud-left, .hud-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 110px;
}
.hud-right { align-items: flex-end; }

.hud-label {
  font-family: var(--font-hud);
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.hud-value {
  font-family: var(--font-hud);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}
.combo-value {
  color: var(--yellow);
  text-shadow: 0 0 16px rgba(255,220,0,0.6);
  transition: transform 0.1s;
}
.combo-value.pop {
  animation: comboPop 0.3s ease;
}
@keyframes comboPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* ─── Timer Ring ───────────────────────────────────────────── */
.hud-center { display: flex; align-items: center; justify-content: center; }
.timer-ring {
  position: relative;
  width: 90px;
  height: 90px;
}
.timer-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.timer-bg {
  fill: none;
  stroke: rgba(255,255,255,0.06);
  stroke-width: 6;
}
.timer-fill {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 327px;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.5s;
  filter: drop-shadow(0 0 6px var(--cyan));
}
.timer-fill.warning { stroke: var(--orange); filter: drop-shadow(0 0 6px var(--orange)); }
.timer-fill.critical { stroke: var(--red); filter: drop-shadow(0 0 6px var(--red)); animation: timerPulse 0.5s ease-in-out infinite; }
@keyframes timerPulse {
  0%, 100% { filter: drop-shadow(0 0 6px var(--red)); }
  50% { filter: drop-shadow(0 0 20px var(--red)); }
}

.timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-hud);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ─── Status Indicators ────────────────────────────────────── */
.fist-indicator {
  position: absolute;
  bottom: 160px;
  right: 16px;
  font-family: var(--font-hud);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--green);
  background: rgba(0,255,136,0.1);
  border: 1px solid rgba(0,255,136,0.3);
  border-radius: 20px;
  padding: 6px 14px;
  z-index: 11;
  opacity: 0;
  transition: opacity 0.2s;
}
.fist-indicator.visible { opacity: 1; }

.hand-lost-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-hud);
  font-size: 1rem;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.6);
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 14px 28px;
  z-index: 12;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.hand-lost-msg.visible { opacity: 1; }

/* ─── Combo Popup ──────────────────────────────────────────── */
.combo-popup {
  position: absolute;
  font-family: var(--font-hud);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--yellow);
  text-shadow: 0 0 20px rgba(255,220,0,0.8);
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  transform: translateY(0);
  transition: none;
}

/* ─── Countdown Overlay ────────────────────────────────────── */
.countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5,7,20,0.85);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.countdown-overlay.visible { opacity: 1; pointer-events: all; }
.countdown-number {
  font-family: var(--font-hud);
  font-size: clamp(6rem, 15vw, 12rem);
  font-weight: 900;
  color: var(--cyan);
  text-shadow: 0 0 40px var(--cyan-glow), 0 0 100px rgba(0,245,255,0.3);
  animation: countdownPop 0.8s ease forwards;
}
@keyframes countdownPop {
  0%   { transform: scale(2); opacity: 0; }
  30%  { transform: scale(1); opacity: 1; }
  80%  { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.5); opacity: 0; }
}

/* ─── Game Over ────────────────────────────────────────────── */
.gameover-card { max-width: 600px; }
.gameover-title {
  font-family: var(--font-hud);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--cyan);
  text-shadow: 0 0 20px var(--cyan-glow);
  margin-bottom: 20px;
}
.final-score-display { margin-bottom: 28px; }
.final-score-label {
  font-family: var(--font-hud);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.final-score-value {
  font-family: var(--font-hud);
  font-size: clamp(3rem, 8vw, 5rem);
  font-weight: 900;
  color: var(--yellow);
  text-shadow: 0 0 30px rgba(255,220,0,0.5);
  animation: scoreReveal 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes scoreReveal {
  0%   { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.stat-box {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 14px;
}
.stat-value {
  font-family: var(--font-hud);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--cyan);
}
.stat-label {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-top: 4px;
}

.rank-display {
  background: linear-gradient(135deg, rgba(255,0,170,0.08), rgba(0,245,255,0.08));
  border: 1px solid rgba(255,0,170,0.2);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 24px;
}
.rank-label {
  font-family: var(--font-hud);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
}
.rank-value {
  font-family: var(--font-hud);
  font-size: 2rem;
  font-weight: 900;
  color: var(--magenta);
  text-shadow: 0 0 20px rgba(255,0,170,0.6);
}
.rank-desc { font-size: 0.8rem; color: var(--text-dim); margin-top: 4px; }

.gameover-buttons {
  display: flex;
  gap: 12px;
}
.gameover-buttons .btn-primary { margin-bottom: 0; flex: 2; }

/* ─── Loading Overlay ──────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5,7,20,0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.5s ease;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.loading-content { text-align: center; }
.loading-spinner {
  width: 60px;
  height: 60px;
  border: 3px solid rgba(0,245,255,0.15);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-family: var(--font-hud);
  font-size: 0.9rem;
  color: var(--cyan);
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}
.loading-sub { font-size: 0.75rem; color: var(--text-dim); }

/* ─── Screen flash effect ──────────────────────────────────── */
.screen-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.05s;
}
.screen-flash.flash-hit {
  background: radial-gradient(ellipse at center, rgba(0,245,255,0.2) 0%, transparent 70%);
  animation: flashAnim 0.2s ease-out;
}
.screen-flash.flash-miss {
  background: radial-gradient(ellipse at center, rgba(255,34,68,0.15) 0%, transparent 70%);
  animation: flashAnim 0.2s ease-out;
}
@keyframes flashAnim {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* ─── 3D Mascot area (start screen) ───────────────────────── */
.mascot-row {
  margin: -40px -48px 18px;        /* bleed outside card padding */
  border-radius: 20px 20px 0 0;
  overflow: hidden;
  position: relative;
  background: radial-gradient(ellipse at center,
    rgba(0,245,255,0.06) 0%, rgba(255,0,170,0.04) 50%, transparent 80%);
  border-bottom: 1px solid rgba(0,245,255,0.12);
}

#mascot-canvas {
  display: block;
  width: 100%;
  height: 210px;
}

/* Speech bubble "LET'S PUNCH!" */
.mascot-shout {
  position: absolute;
  top: 16px;
  right: 22px;
  pointer-events: none;
  animation: shoutFloat 3s ease-in-out infinite;
}
@keyframes shoutFloat {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%       { transform: translateY(-6px) rotate(1deg); }
}
.shout-bubble {
  display: inline-block;
  background: linear-gradient(135deg,
    rgba(255, 0, 170, 0.25),
    rgba(0, 245, 255, 0.15));
  border: 1.5px solid var(--magenta);
  border-radius: 18px 18px 18px 4px;
  padding: 7px 14px;
  font-family: var(--font-hud);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fff;
  white-space: nowrap;
  box-shadow:
    0 0 14px rgba(255,0,170,0.3),
    0 0 0 1px rgba(255,0,170,0.1) inset;
  animation: bubblePulse 2s ease-in-out infinite;
}
@keyframes bubblePulse {
  0%, 100% { box-shadow: 0 0 14px rgba(255,0,170,0.3), 0 0 0 1px rgba(255,0,170,0.1) inset; }
  50%       { box-shadow: 0 0 28px rgba(255,0,170,0.6), 0 0 0 1px rgba(255,0,170,0.2) inset; }
}

/* ─── 3D Glove cursor overlay (in-game) ───────────────────── */
.glove-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;   /* above game canvas, below HUD (z-index 10) */
}

/* ─── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
  .glass-card { padding: 28px 20px; }
  .hud { padding: 10px 12px; }
  .hud-value { font-size: 1.2rem; }
  .timer-ring { width: 70px; height: 70px; }
  .hand-preview { width: 120px; height: 90px; bottom: 10px; right: 10px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .gameover-buttons { flex-direction: column; }
  .gameover-buttons .btn-primary { margin-bottom: 0; flex: unset; }
}

@media (max-width: 400px) {
  .logo-text { font-size: 1.8rem; }
  .instructions { flex-direction: column; align-items: center; }
}

/* ─── Glow pulse animation for active targets ──────────────── */
@keyframes targetPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.4); }
}
