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

body {
  background: #0a0f1a;
  font-family: 'Segoe UI', sans-serif;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  user-select: none;
}

/* ── HUD ── */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 56px;
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  z-index: 10;
}

.hud-item {
  color: #e0f0ff;
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.hud-item span { color: #38bdf8; }

#timer.urgent {
  color: #f87171 !important;
  animation: pulse 0.6s infinite alternate;
}

@keyframes pulse {
  from { opacity: 1; }
  to   { opacity: 0.4; }
}

/* ── Wrong-key flash on body ── */
body.wrong-key {
  animation: wrong-flash 0.25s ease;
}

@keyframes wrong-flash {
  0%   { background: #0a0f1a; }
  40%  { background: #3b0a0a; }
  100% { background: #0a0f1a; }
}

/* ── Arena ── */
#arena {
  position: fixed;
  top: 56px; left: 0; right: 0; bottom: 0;
}


/* ── Target squares ── */
.target {
  position: absolute;
  width: 80px;
  height: 80px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 900;
  color: rgba(255,255,255,0.95);
  letter-spacing: 0.02em;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  animation: pop-in 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  cursor: default;
}

@keyframes pop-in {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

@keyframes pop-out {
  0%   { transform: scale(1);   opacity: 1; }
  50%  { transform: scale(1.5); opacity: 0.5; }
  100% { transform: scale(0);   opacity: 0; }
}

.target.hit {
  animation: pop-out 0.22s ease forwards;
}

/* Highlight matching square when that key is pressed */
.target.active-press {
  box-shadow: 0 0 0 4px #fff, 0 4px 24px rgba(0,0,0,0.5);
}

/* ── Floating score ── */
.float-point {
  position: absolute;
  font-size: 1.2rem;
  font-weight: 800;
  color: #fde68a;
  pointer-events: none;
  animation: float-up 0.7s ease forwards;
  z-index: 20;
}

@keyframes float-up {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-60px); }
}

/* ── Overlay ── */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 26, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#overlay.visible {
  opacity: 1;
  pointer-events: all;
}

#overlay-box {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 44px 52px;
  text-align: center;
  color: #e0f0ff;
  max-width: 440px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

#overlay-box h1 {
  font-size: 2.6rem;
  font-weight: 800;
  color: #38bdf8;
  margin-bottom: 16px;
}

#overlay-box p {
  font-size: 1rem;
  line-height: 1.6;
  color: #b0cfe0;
  margin-bottom: 28px;
}

#overlay-box .result-score {
  font-size: 3.5rem;
  font-weight: 900;
  color: #fde68a;
  display: block;
  margin: 12px 0 4px;
}

#overlay-box .result-wave {
  font-size: 1rem;
  color: #38bdf8;
  margin-bottom: 28px;
  display: block;
}

#start-btn, #restart-btn {
  background: #0284c7;
  color: #fff;
  border: none;
  padding: 14px 40px;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

#start-btn:hover, #restart-btn:hover  { background: #0369a1; transform: scale(1.04); }
#start-btn:active, #restart-btn:active { transform: scale(0.97); }

/* ── Scores table ── */
.scores-heading {
  font-size: 1rem;
  font-weight: 700;
  color: #38bdf8;
  margin: 20px 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 0.92rem;
}

.score-table th {
  color: #4a7a9b;
  font-weight: 600;
  padding: 4px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.score-table td {
  color: #c4dff0;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.score-table tr.new-entry td {
  color: #fde68a;
  font-weight: 700;
}

.no-scores {
  font-size: 0.9rem;
  color: #4a7a9b;
  margin-bottom: 24px !important;
}
