:root {
  color-scheme: dark;
  --bg-deep: #0d0716;
  --bg-mid: #170f28;
  --panel: #1c1330;
  --panel-border: #382a52;
  --accent-orange: #ff6b35;
  --accent-cyan: #39e0c8;
  --accent-yellow: #ffd23f;
  --accent-pink: #ff4d8d;
  --text-main: #f1eef9;
  --text-dim: #a99fc4;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100vh;
}

body {
  background: radial-gradient(ellipse at top, var(--bg-mid), var(--bg-deep) 70%);
  color: var(--text-main);
  font-family: 'Courier New', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  display: grid;
  place-items: center;
  padding: 16px;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 640px;
}

/* ---------- HUD ---------- */

.hud {
  display: none;
  width: 100%;
  max-width: 600px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 14px;
  background: linear-gradient(180deg, var(--panel), #150c26);
  border: 2px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 14px;
  box-shadow: 0 0 18px rgba(255, 107, 53, 0.12);
}

.hud.visible {
  display: flex;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 44px;
  line-height: 1.15;
}

.hud-label {
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.hud-item span:last-child {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent-yellow);
}

.hud-lives {
  color: var(--accent-pink) !important;
  letter-spacing: 2px;
}

.icon-btn {
  background: none;
  border: 2px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 1.1rem;
  padding: 4px 8px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.icon-btn:hover {
  border-color: var(--accent-cyan);
}

.icon-btn:active {
  transform: scale(0.92);
}

/* ---------- Stage / Canvas ---------- */

#stage {
  position: relative;
  width: 100%;
  max-width: 600px;
  aspect-ratio: 600 / 520;
  border-radius: 12px;
  overflow: hidden;
  border: 3px solid var(--panel-border);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(57, 224, 200, 0.08);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #16241a;
}

/* ---------- Overlay screens ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 6, 18, 0.82);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.2s ease-out;
}

.screen.visible {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.panel {
  text-align: center;
  max-width: 420px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.panel h1 {
  font-size: 1.9rem;
  margin: 0;
  letter-spacing: 0.04em;
  color: var(--accent-orange);
  text-shadow: 0 0 14px rgba(255, 107, 53, 0.55);
}

.panel h1 span {
  color: var(--accent-cyan);
  text-shadow: 0 0 14px rgba(57, 224, 200, 0.55);
}

.panel h2 {
  font-size: 1.5rem;
  margin: 0;
  color: var(--accent-cyan);
  text-shadow: 0 0 12px rgba(57, 224, 200, 0.5);
}

.subtitle {
  color: var(--text-dim);
  margin: 0;
}

.controls-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 4px 0;
}

.controls-info div {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.controls-info strong {
  color: var(--accent-yellow);
}

.controls-info span {
  color: var(--text-dim);
}

.rules {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0;
}

.score-line {
  font-size: 1rem;
  margin: 2px 0;
  color: var(--text-dim);
}

.score-line span {
  color: var(--accent-yellow);
  font-weight: 700;
}

.highscore {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.highscore span {
  color: var(--accent-pink);
  font-weight: 700;
}

button.btn-primary,
button.btn-secondary {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 10px 26px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s, box-shadow 0.2s;
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent-orange), #d9491a);
  color: #1a0e05;
  box-shadow: 0 0 18px rgba(255, 107, 53, 0.45);
}

.btn-primary:hover {
  box-shadow: 0 0 26px rgba(255, 107, 53, 0.7);
}

.btn-secondary {
  background: transparent;
  border-color: var(--panel-border);
  color: var(--text-main);
}

.btn-secondary:hover {
  border-color: var(--accent-cyan);
}

button:active {
  transform: scale(0.96);
}

/* ---------- Touch controls ---------- */

#touch-controls {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
  align-items: flex-end;
  justify-content: space-between;
  padding: 16px;
}

#touch-controls.visible {
  display: flex;
}

.dpad {
  position: relative;
  width: 140px;
  height: 140px;
  pointer-events: auto;
}

.dpad-btn {
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(20, 12, 34, 0.65);
  color: var(--text-main);
  font-size: 1.1rem;
  touch-action: none;
  user-select: none;
}

.dpad-up {
  top: 0;
  left: 47px;
}

.dpad-down {
  bottom: 0;
  left: 47px;
}

.dpad-left {
  left: 0;
  top: 47px;
}

.dpad-right {
  right: 0;
  top: 47px;
}

.bomb-btn {
  pointer-events: auto;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: radial-gradient(circle at 35% 30%, #3a3a46, #1c1c22);
  color: var(--text-main);
  font-size: 1.8rem;
  box-shadow: 0 0 16px rgba(255, 107, 53, 0.4);
  touch-action: none;
  user-select: none;
}

@media (max-width: 480px) {
  .panel h1 {
    font-size: 1.5rem;
  }
  .hud-label {
    font-size: 0.55rem;
  }
  .hud-item span:last-child {
    font-size: 0.85rem;
  }
}
