:root {
  --bg: #0d0d0d;
  --surface: #1a1a19;
  --border: #2c2c2a;
  --text: #ffffff;
  --text2: #c3c2b7;
  --muted: #898781;
  --gold: #f5c243;
}

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

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

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 14px;
}

#app {
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* HUD */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  flex-wrap: wrap;
}
.hud-group { display: flex; align-items: center; gap: 10px; }
.hud-group.right { flex-wrap: wrap; justify-content: flex-end; }
.hud-title {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--gold);
  font-size: 15px;
  white-space: nowrap;
}
.stat { display: flex; flex-direction: column; line-height: 1.1; min-width: 46px; }
.stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.stat-val { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.stat-val.lives { color: var(--gold); font-size: 15px; letter-spacing: 1px; }

.mini-btn {
  background: #232320;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.mini-btn:hover { background: #2c2c28; color: var(--text); }
.mini-btn:active { transform: translateY(1px); }

/* Stage + canvas */
#stage {
  position: relative;
  width: 100%;
  aspect-ratio: 800 / 600;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0b0b0d;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: none;
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(8, 8, 10, 0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 5;
}
.overlay.show { display: flex; animation: fade 0.18s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.panel {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px 24px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.panel.wide { max-width: 620px; }
.panel h1 { font-size: 30px; letter-spacing: 0.02em; margin-bottom: 8px; color: var(--gold); }
.panel h2 { font-size: 24px; margin-bottom: 8px; }
.panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gold); margin: 12px 0 6px; }
.sub { color: var(--text2); font-size: 14px; line-height: 1.55; margin-bottom: 14px; }
.sub b { color: var(--text); }

.menu-stats {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 14px 0;
}
.menu-stats > div {
  flex: 1;
  max-width: 160px;
  background: #131311;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ms-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.ms-val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--gold); }

.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.btn {
  background: #232320;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.12s ease;
}
.btn:hover { background: #2d2d29; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--gold); color: #1a1408; border-color: var(--gold); }
.btn.primary:hover { background: #ffd35e; }
.btn.ghost { background: transparent; color: var(--text2); margin-top: 12px; }
.btn.ghost:hover { color: var(--text); }

/* Help */
.help-grid { display: flex; gap: 20px; text-align: left; flex-wrap: wrap; }
.help-col { flex: 1; min-width: 220px; }
.help-col ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.help-col li { font-size: 13px; color: var(--text2); line-height: 1.45; display: flex; align-items: center; gap: 7px; }
.help-col li b { color: var(--text); }
.dot { width: 13px; height: 13px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.tag {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 16px; border-radius: 4px; color: #0d0d0d;
  font-weight: 700; font-size: 11px; flex-shrink: 0;
}
.tip { font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.5; }
#ovHelp .btn { margin-top: 18px; }

#foot {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 560px) {
  .hud-title { display: none; }
  .panel h1 { font-size: 24px; }
  .stat-val { font-size: 16px; }
  #foot { display: none; }
}
@media (max-width: 400px) {
  body { padding: 8px; }
  .stat { min-width: 38px; }
  .mini-btn { padding: 5px 8px; font-size: 11px; }
}
