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

:root {
  --bg: #0b0e16;
  --panel: #1a2032;
  --accent: #4aa3ff;
  --text: #e8ecf5;
  --muted: #8a93ab;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
}

header {
  width: 100%;
  max-width: 520px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

#hud {
  display: flex;
  gap: 10px;
}

.hud-item {
  background: var(--panel);
  border: 1px solid #2a3350;
  border-radius: 8px;
  padding: 4px 10px;
  text-align: center;
  min-width: 62px;
}

.hud-item label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
}

.hud-item span {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#stage {
  position: relative;
  line-height: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px #232b42;
  touch-action: none;
}

canvas {
  display: block;
  cursor: crosshair;
  max-width: 96vw;
  max-height: 76vh;
  height: auto !important;
}

/* Overlay */
#overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 18, 0.78);
  backdrop-filter: blur(4px);
  line-height: 1.45;
  z-index: 10;
}

#overlay.show { display: flex; }

.panel {
  background: var(--panel);
  border: 1px solid #33405f;
  border-radius: 14px;
  padding: 26px 30px;
  max-width: 420px;
  width: 88%;
  text-align: center;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
}

.panel h2 {
  font-size: 24px;
  margin-bottom: 12px;
}

.panel p {
  color: #c3cadd;
  font-size: 14.5px;
  margin-bottom: 18px;
}

button.primary {
  background: linear-gradient(180deg, #5cb0ff, #3a7bd5);
  color: white;
  border: 0;
  border-radius: 9px;
  padding: 11px 26px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s, filter 0.15s;
}

button.primary:hover { filter: brightness(1.12); }
button.primary:active { transform: scale(0.96); }

#level-buttons {
  display: none;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}

.level-btn {
  flex: 1;
  max-width: 120px;
  background: #232c45;
  color: var(--text);
  border: 1px solid #38466a;
  border-radius: 9px;
  padding: 8px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: background 0.15s;
}

.level-btn:hover:not(.locked) { background: #2c3855; }

.level-btn b { font-size: 18px; }
.level-btn span { font-size: 11px; color: var(--muted); }

.level-btn.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.level-btn.locked span::after { content: ' 🔒'; }

footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

.legend { display: inline-flex; align-items: center; gap: 6px; }

.b {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  vertical-align: -2px;
  margin-right: 2px;
}

.b.bomb { background: radial-gradient(circle at 35% 30%, #888, #111); }
.b.chain {
  background: radial-gradient(circle at 35% 30%, #fff, #3498db 40%, #1d639e);
  box-shadow: inset 0 0 0 3px rgba(30, 30, 30, 0.7);
}

@media (max-width: 560px) {
  h1 { font-size: 16px; }
  .hud-item { min-width: 54px; padding: 3px 7px; }
  .hud-item span { font-size: 15px; }
}
