:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-soft: rgba(15, 23, 42, 0.88);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #2ec4b6;
  --accent-dark: #1f9d91;
  --danger: #ff4d6d;
  --warn: #ffd166;
  --border: rgba(255, 255, 255, 0.12);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  background: radial-gradient(circle at top, #1e293b 0%, #0b1120 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.app-shell {
  min-height: 100dvh;
  max-width: 680px;
  margin: 0 auto;
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-card {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 10px;
  display: flex;
  flex-direction: column;
  min-width: 58px;
}

.hud-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hud-value {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.lives-card .hud-value {
  color: var(--danger);
  letter-spacing: 2px;
}

.icon-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.92);
  color: var(--text);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.12s ease, background 0.15s ease;
}

.icon-btn:hover {
  background: #334155;
}

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

.stage-wrap {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 440px;
  max-height: calc(100dvh - 88px);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #1b222c;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
  cursor: pointer;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 15, 28, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

.overlay.hidden {
  display: none;
}

.panel {
  width: 100%;
  max-width: 390px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.5);
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #082f2c;
  background: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.badge-danger {
  background: var(--danger);
  color: #fff;
}

.panel h1,
.panel h2 {
  margin: 0 0 10px;
  font-size: 26px;
  line-height: 1.15;
}

.lead {
  margin: 0 0 14px;
  color: #cbd5e1;
  font-size: 14px;
  line-height: 1.5;
}

.tips {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: #e2e8f0;
}

.tips li {
  display: flex;
  align-items: center;
  gap: 9px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.dot-danger {
  background: var(--danger);
}

.dot-safe {
  background: var(--accent);
}

.dot-warn {
  background: var(--warn);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.stat-box {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat-box strong {
  font-size: 20px;
}

.btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.primary-btn,
.secondary-btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.primary-btn {
  background: var(--accent);
  color: #062825;
  width: 100%;
}

.primary-btn:hover {
  background: #3dd5c6;
}

.secondary-btn {
  background: #334155;
  color: var(--text);
  width: 100%;
}

.secondary-btn:hover {
  background: #475569;
}

.primary-btn:active,
.secondary-btn:active {
  transform: scale(0.98);
}

@media (max-width: 400px) {
  .app-shell {
    padding: 8px 8px 10px;
  }

  .hud-card {
    padding: 4px 8px;
    min-width: 50px;
  }

  .hud-value {
    font-size: 14px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .panel {
    padding: 16px;
  }
}
