:root {
  --bg: #0b1220;
  --panel-bg: rgba(10, 20, 30, 0.94);
  --accent: #ffb400;
  --danger: #ef4444;
  --text: #f8fafc;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}

#game-app {
  height: 100dvh;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #5a8f3c;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(rgba(0, 0, 0, 0.65), transparent);
  pointer-events: none;
  z-index: 4;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(6px);
  pointer-events: none;
}

.hud-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #cbd5e1;
}

#score,
#high-score,
#lives,
#speed {
  font-size: 1.1rem;
  font-weight: 800;
}

#btn-pause {
  pointer-events: auto;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

#btn-pause:hover {
  background: rgba(0, 0, 0, 0.7);
  transform: scale(1.05);
}

#btn-sound {
  pointer-events: auto;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

#btn-sound:hover {
  background: rgba(0, 0, 0, 0.7);
  transform: scale(1.05);
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 10, 20, 0.86);
  z-index: 5;
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(94%, 460px);
  padding: clamp(20px, 4vw, 32px);
  border-radius: 22px;
  background: var(--panel-bg);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.game-icon {
  font-size: clamp(44px, 10vw, 72px);
  margin: 0 0 10px;
}

h1,
h2 {
  margin: 0 0 12px;
  letter-spacing: 0.04em;
}

h1 {
  font-size: clamp(1.6rem, 5vw, 2.5rem);
  color: var(--accent);
}

h2 {
  font-size: clamp(1.4rem, 4vw, 2rem);
  color: var(--danger);
}

.tagline {
  margin: 0 0 18px;
  line-height: 1.5;
  color: #cbd5e1;
  font-size: 0.95rem;
}

.controls-info {
  margin: 0 0 20px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  text-align: left;
  line-height: 1.6;
  font-size: 0.92rem;
}

.controls-info p {
  margin: 4px 0;
}

.level-select {
  margin: 0 0 18px;
  text-align: left;
}

.level-select-title {
  margin: 0 0 8px;
  font-weight: 700;
  color: #e2e8f0;
  font-size: 0.95rem;
}

.level-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.level-btn {
  padding: 10px 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.12s ease;
}

.level-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}

.level-btn.is-selected {
  background: rgba(245, 158, 11, 0.2);
  border-color: #f59e0b;
  color: #fbbf24;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.35);
}

.btn-primary {
  width: 100%;
  padding: 14px 18px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #1e293b;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.3);
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(245, 158, 11, 0.4);
}

.btn-primary:active {
  transform: translateY(1px);
  box-shadow: 0 6px 14px rgba(245, 158, 11, 0.25);
}

.final-score {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 12px 0 4px;
  color: #fbbf24;
}

.final-best {
  margin: 4px 0 18px;
  color: #94a3b8;
}

#touch-controls {
  display: none;
}

@media (max-width: 600px) {
  .hud-item {
    min-width: 46px;
    padding: 5px 6px;
  }

  .hud-label {
    font-size: 0.62rem;
  }

  #score,
  #high-score,
  #lives,
  #speed {
    font-size: 0.95rem;
  }

  .panel {
    padding: 18px;
    border-radius: 18px;
  }
}