:root {
  --bg: #050816;
  --panel: #0b1224;
  --text: #e2e8f0;
  --accent: #38bdf8;
  --danger: #ef4444;
  --ok: #22c55e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Outfit", sans-serif;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(56, 189, 248, 0.12), transparent 45%),
    radial-gradient(ellipse at 80% 20%, rgba(99, 102, 241, 0.1), transparent 40%),
    radial-gradient(ellipse at top, #111827, var(--bg));
  min-height: 100vh;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
}

.hidden { display: none !important; }

.level-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
}

.level-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.level-header h1,
.header h1 {
  margin: 0;
  font-size: clamp(1.3rem, 4vw, 2rem);
}

.level-screen > p {
  margin: 0 0 24px;
  opacity: 0.9;
}

.level-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 360px;
}

.level-btn {
  padding: 16px 20px;
  min-height: 44px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.level-btn:hover { background: rgba(255, 255, 255, 0.15); }

.level-name {
  font-weight: 700;
  font-size: 1.1rem;
}

.level-desc {
  font-size: 0.85rem;
  opacity: 0.85;
}

.help-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  font-weight: 700;
  cursor: pointer;
}

.game-screen {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 10px;
}

.level-badge {
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(56, 189, 248, 0.25);
  font-size: 0.8rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
  align-items: center;
}

.hud {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.85rem;
}

.btn {
  padding: 10px 14px;
  min-height: 44px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.25);
  color: inherit;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.btn-large {
  padding: 12px 22px;
  width: 100%;
}

#gameCanvas {
  width: 100%;
  max-width: 480px;
  height: auto;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.06) 0 1px, transparent 2px),
    radial-gradient(circle at 70% 60%, rgba(255, 255, 255, 0.05) 0 1px, transparent 2px),
    var(--panel);
  border-radius: 12px;
  display: block;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.touch-controls {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 480px;
  margin-top: 10px;
}

.ctrl-btn {
  flex: 1;
  min-height: 52px;
  min-width: 44px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  color: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.ctrl-btn.fire {
  background: var(--accent);
  color: #0b1224;
}

.ctrl-btn.hs {
  background: rgba(34, 197, 94, 0.35);
}

.result-overlay,
.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.help-overlay { z-index: 300; }

.result-box,
.help-modal {
  background: var(--panel);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  padding: 28px;
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.help-modal { text-align: left; }

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.help-header h2 { margin: 0; }

.help-close {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  font-size: 1.5rem;
  cursor: pointer;
}

.help-body ul { padding-left: 20px; }

.result-box h2 {
  color: var(--ok);
  margin: 0 0 8px;
}

.result-box h2.lose { color: var(--danger); }

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.result-actions .btn {
  width: 100%;
  margin: 0;
}

@media (max-width: 480px) {
  .header-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
  }
}
