:root {
  --bg: #070b11;
  --panel-bg: #0d141f;
  --frame-bg: #0a1017;
  --line: #1c2a3d;
  --green: #54ff74;
  --cyan: #38eaff;
  --red: #ff3838;
  --yellow: #ffd166;
  --text: #b9d2e2;
  --font: 'Press Start 2P', 'Courier New', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #0c1420 0%, var(--bg) 70%);
  font-family: var(--font);
  color: var(--text);
}

#frame {
  position: relative;
  width: 768px;
  background: var(--frame-bg);
  border: 3px solid var(--line);
  box-shadow: 0 0 40px rgba(56, 234, 255, 0.12), inset 0 0 60px rgba(0, 0, 0, 0.6);
  padding: 10px;
}

#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--panel-bg);
  border: 2px solid var(--line);
  padding: 8px 10px;
  margin-bottom: 8px;
}

.hud-label {
  font-size: 10px;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(56, 234, 255, 0.8);
  letter-spacing: 1px;
}

#stats { display: flex; gap: 14px; }

.stat { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.stat .k { font-size: 7px; color: #5f7d95; }
.stat .v { font-size: 11px; color: var(--green); text-shadow: 0 0 6px rgba(84, 255, 116, 0.6); }

#buttons { display: flex; gap: 6px; align-items: center; }

.btn {
  font-family: var(--font);
  font-size: 8px;
  color: var(--green);
  background: #0f1a12;
  border: 2px solid var(--green);
  padding: 8px 10px;
  cursor: pointer;
  text-shadow: 0 0 6px rgba(84, 255, 116, 0.5);
}
.btn:hover:not(:disabled) { background: rgba(84, 255, 116, 0.15); box-shadow: 0 0 12px rgba(84, 255, 116, 0.35); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn.accent { color: var(--cyan); border-color: var(--cyan); background: #0a161a; text-shadow: 0 0 6px rgba(56, 234, 255, 0.5); }
.btn.accent:hover:not(:disabled) { background: rgba(56, 234, 255, 0.12); box-shadow: 0 0 12px rgba(56, 234, 255, 0.35); }
.btn.danger { color: var(--red); border-color: var(--red); background: #180b0b; text-shadow: 0 0 6px rgba(255, 56, 56, 0.5); }
.btn.danger:hover:not(:disabled) { background: rgba(255, 56, 56, 0.12); box-shadow: 0 0 12px rgba(255, 56, 56, 0.35); }
.btn.small { font-size: 7px; padding: 6px 7px; }
.btn.off { color: #5f7d95; border-color: #2a3b52; text-shadow: none; background: #0d141f; }

#stage { position: relative; }

canvas {
  display: block;
  background: #0a0e14;
  border: 2px solid var(--line);
  image-rendering: pixelated;
  cursor: crosshair;
}

#panel {
  position: absolute;
  z-index: 5;
  min-width: 172px;
  background: rgba(10, 16, 23, 0.96);
  border: 2px solid var(--cyan);
  box-shadow: 0 0 16px rgba(56, 234, 255, 0.35);
  padding: 10px;
  font-size: 8px;
  line-height: 1.9;
}

#panel h3 { margin: 0 0 6px; font-size: 9px; color: var(--cyan); }
#panel .row { display: flex; justify-content: space-between; gap: 10px; }
#panel .dim { color: #5f7d95; }
#panel .btn { width: 100%; margin-top: 8px; }

#log {
  margin-top: 8px;
  border: 2px solid var(--line);
  background: var(--panel-bg);
  padding: 7px 10px;
  font-size: 7px;
  line-height: 1.7;
  color: var(--text);
  min-height: 14px;
}
#log.good { color: var(--green); }
#log.bad { color: var(--red); }
#log.gold { color: var(--yellow); }

#overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(5, 7, 10, 0.88);
}

#overlay-title {
  font-size: 26px;
  color: var(--red);
  text-shadow: 0 0 18px rgba(255, 56, 56, 0.8);
  animation: blink 1s steps(2) infinite;
}

@keyframes blink { 50% { opacity: 0.7; } }

#overlay-sub { font-size: 8px; line-height: 2; text-align: center; color: var(--text); }
#overlay .btn { font-size: 10px; }

.hidden { display: none !important; }
