/* ── Variables ── */
:root {
  --bg: #050a0e;
  --accent: #00e5ff;
  --accent2: #39ff14;
  --accent3: #ffe566;
  --danger: #ff2d55;
  --text: #c8f0e0;
  --dim: #2a4a38;
  --panel: rgba(5, 10, 14, 0.92);
  --glow:  0 0 10px #00e5ff88, 0 0 28px #00e5ff33;
  --glow2: 0 0 10px #39ff1488, 0 0 28px #39ff1433;
  --glow-d:0 0 10px #ff2d5588, 0 0 28px #ff2d5533;
}

/* ── Reset & Base ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; background: var(--bg); overflow: hidden; font-family: 'Share Tech Mono', monospace; color: var(--text); }

/* ── Scanlines overlay ── */
body::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 500;
  background: repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,0,0,0.07) 3px, rgba(0,0,0,0.07) 4px);
}

/* ── Matrix rain canvas ── */
#rain-canvas {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0; opacity: 0.06;
}

/* ── HUD ── */
#hud {
  position: fixed; top: 0; left: 0; right: 0; height: 50px;
  display: flex; align-items: center; justify-content: space-between; padding: 0 18px;
  background: linear-gradient(180deg, rgba(5,10,14,0.98) 60%, transparent 100%);
  border-bottom: 1px solid rgba(0,229,255,0.1); z-index: 10;
}
.hud-block { display: flex; align-items: center; gap: 8px; }
.hud-label { font-family: 'Orbitron', monospace; font-size: 9px; color: var(--dim); letter-spacing: 3px; text-transform: uppercase; }
.hud-val   { font-family: 'Orbitron', monospace; font-size: 20px; color: var(--accent2); text-shadow: var(--glow2); min-width: 38px; text-align: right; }
#title-hud { font-family: 'Orbitron', monospace; font-size: 14px; font-weight: 900; color: var(--accent); text-shadow: var(--glow); letter-spacing: 7px; }

/* ── Mute button ── */
#mute-btn {
  position: fixed; top: 10px; right: 60px; z-index: 20;
  background: transparent; border: 1px solid rgba(0,229,255,0.2);
  color: var(--dim); font-size: 16px; width: 30px; height: 30px;
  border-radius: 4px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
#mute-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Danger bar (bottom edge flash) ── */
#danger-bar {
  position: fixed; bottom: 0; left: 0; right: 0; height: 3px;
  background: var(--danger); box-shadow: var(--glow-d);
  z-index: 20; opacity: 0; transition: opacity 0.2s;
}
/* ── Danger proximity line ── */
#danger-line {
  position: fixed; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,45,85,0.35), transparent);
  z-index: 2;
}

/* ── Game area ── */
#game-area {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none; z-index: 3;
}

/* ── Falling word elements ── */
.word-el {
  position: absolute;
  font-family: 'Share Tech Mono', monospace;
  font-size: 15px; letter-spacing: 2px;
  color: var(--text);
  padding: 4px 11px;
  border: 1px solid rgba(0,229,255,0.18);
  border-radius: 3px;
  background: rgba(5,10,14,0.78);
  backdrop-filter: blur(3px);
  white-space: nowrap; user-select: none;
  transition: border-color 0.1s, box-shadow 0.1s, color 0.1s;
}
.word-el .typed     { color: var(--accent2); text-shadow: var(--glow2); }
.word-el.targeted   { border-color: var(--accent); box-shadow: var(--glow); }
.word-el.danger-word{ border-color: var(--danger); color: var(--danger); box-shadow: var(--glow-d); animation: w-shake 0.12s infinite; }

@keyframes w-shake {
  0%, 100% { transform: translateX(0); }
  33%       { transform: translateX(-2px); }
  66%       { transform: translateX(2px); }
}

/* ── Explosion effects ── */
.exp-ring {
  position: fixed; border-radius: 50%;
  border: 2px solid var(--accent2); box-shadow: 0 0 10px var(--accent2);
  transform: translate(-50%, -50%); pointer-events: none; z-index: 50;
  animation: ring-ex 0.45s ease-out forwards;
}
@keyframes ring-ex { 0% { width:0; height:0; opacity:1; } 100% { width:120px; height:120px; opacity:0; } }

.exp-ring2 {
  position: fixed; border-radius: 50%;
  border: 1px solid var(--accent3); box-shadow: 0 0 8px var(--accent3);
  transform: translate(-50%, -50%); pointer-events: none; z-index: 50;
  animation: ring-ex2 0.6s ease-out forwards;
}
@keyframes ring-ex2 { 0% { width:0; height:0; opacity:0.8; } 100% { width:180px; height:180px; opacity:0; } }

.exp-pt {
  position: fixed; width: 5px; height: 5px; border-radius: 50%;
  transform: translate(-50%, -50%); pointer-events: none; z-index: 50;
  transition: all 0.5s ease-out;
}
.exp-flash {
  position: fixed; border-radius: 50%;
  background: radial-gradient(circle, rgba(57,255,20,0.6) 0%, transparent 70%);
  transform: translate(-50%, -50%); pointer-events: none; z-index: 49;
  animation: flash-ex 0.3s ease-out forwards;
}
@keyframes flash-ex { 0% { width:0; height:0; opacity:1; } 100% { width:90px; height:90px; opacity:0; } }

.exp-sc {
  position: fixed; font-family: 'Orbitron', monospace; font-weight: 900; font-size: 20px;
  color: var(--accent2); text-shadow: var(--glow2);
  transform: translate(-50%, -50%); pointer-events: none; z-index: 51;
  animation: sc-pop 0.65s ease-out forwards;
}
@keyframes sc-pop {
  0%   { opacity: 1; transform: translate(-50%,-50%) scale(0.4); }
  40%  { opacity: 1; transform: translate(-50%,-65%) scale(1.3); }
  100% { opacity: 0; transform: translate(-50%,-130%) scale(0.9); }
}

/* ── Input area ── */
#input-area {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 15;
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 16px 14px;
  background: linear-gradient(0deg, rgba(5,10,14,0.97) 0%, transparent 100%);
}
#input-box {
  width: 100%; max-width: 520px;
  background: rgba(0,229,255,0.04);
  border: 1px solid rgba(0,229,255,0.28);
  border-radius: 4px; padding: 10px 16px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 18px; color: var(--accent);
  text-shadow: var(--glow); letter-spacing: 4px;
  outline: none; caret-color: var(--accent2);
  text-align: center; box-shadow: var(--glow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
#input-box::placeholder { color: var(--dim); letter-spacing: 2px; font-size: 12px; }
#input-box.wrong {
  border-color: var(--danger); box-shadow: var(--glow-d);
  animation: inp-shake 0.25s ease;
}
@keyframes inp-shake {
  0%,100%{ transform: translateX(0); }
  20%    { transform: translateX(-6px); }
  40%    { transform: translateX(6px); }
  60%    { transform: translateX(-4px); }
  80%    { transform: translateX(4px); }
}

/* ── Overlay ── */
#overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(5,10,14,0.93); backdrop-filter: blur(5px);
}
#overlay.hidden { display: none; }

.ov-logo {
  font-family: 'Orbitron', monospace; font-weight: 900;
  font-size: clamp(28px, 8vw, 54px);
  color: var(--accent); text-shadow: var(--glow), 0 0 70px #00e5ff22;
  letter-spacing: 10px; margin-bottom: 6px; text-align: center;
  animation: logo-pulse 3s ease-in-out infinite;
}
@keyframes logo-pulse {
  0%,100%{ text-shadow: var(--glow), 0 0 70px #00e5ff22; }
  50%    { text-shadow: 0 0 20px #00e5ffcc, 0 0 50px #00e5ff66, 0 0 100px #00e5ff22; }
}
.ov-logo.gameover { color: var(--danger); text-shadow: var(--glow-d); animation: none; }

.ov-sub  { font-size: 11px; color: var(--dim); letter-spacing: 8px; margin-bottom: 40px; }

.stat-row { display: flex; gap: 48px; margin-bottom: 36px; }
.stat     { text-align: center; }
.stat-n   { font-family: 'Orbitron', monospace; font-size: 40px; font-weight: 700; color: var(--accent2); text-shadow: var(--glow2); display: block; }
.stat-n.record { color: var(--accent3); text-shadow: 0 0 10px #ffe56688; animation: rec-flash 0.5s 3; }
@keyframes rec-flash { 0%,100%{opacity:1;} 50%{opacity:0.3;} }
.stat-l   { font-size: 10px; color: var(--dim); letter-spacing: 3px; margin-top: 4px; text-transform: uppercase; }

.big-btn {
  font-family: 'Orbitron', monospace; font-size: 12px; font-weight: 700;
  letter-spacing: 4px; padding: 14px 46px;
  border: 1px solid var(--accent); background: transparent; color: var(--accent);
  cursor: pointer; border-radius: 3px; transition: all 0.15s;
  box-shadow: var(--glow); animation: btn-pulse 2s ease-in-out infinite;
}
@keyframes btn-pulse { 0%,100%{box-shadow:var(--glow);} 50%{box-shadow:0 0 22px #00e5ffbb,0 0 55px #00e5ff44;} }
.big-btn:hover, .big-btn:active { background: var(--accent); color: var(--bg); box-shadow: none; }

.ov-hint { font-size: 10px; color: var(--dim); letter-spacing: 3px; margin-top: 18px; }

/* ── Level badge (top center, brief) ── */
#level-toast {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  font-family: 'Orbitron', monospace; font-size: 11px; font-weight: 700;
  color: var(--accent3); letter-spacing: 4px;
  padding: 5px 18px; border: 1px solid rgba(255,229,102,0.3);
  background: rgba(5,10,14,0.9); border-radius: 3px;
  opacity: 0; transition: opacity 0.3s; z-index: 30;
  text-shadow: 0 0 10px #ffe56688;
}
#level-toast.show { opacity: 1; }
