:root {
  --bg-top: #17324d;
  --bg-bottom: #6abf69;
  --panel: rgba(9, 24, 39, 0.78);
  --panel-border: rgba(255, 255, 255, 0.16);
  --ink: #f4f7fb;
  --accent: #ffd166;
  --accent-2: #6ef3a5;
  --danger: #ff6b6b;
  --blue: #118ab2;
  --night: #0b132b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Verdana, Geneva, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 209, 102, 0.18) 0 16%, transparent 16% 100%),
    linear-gradient(315deg, rgba(255, 107, 107, 0.18) 0 18%, transparent 18% 100%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.shell {
  width: min(1240px, calc(100vw - 20px));
  margin: 0 auto;
  padding: 12px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 48px;
  margin-bottom: 10px;
}

h1,
.hud,
.menu-box,
.touch-controls button {
  font-family: "Courier New", Courier, monospace;
  font-weight: 800;
}

h1 {
  font-size: 2rem;
  margin: 0;
  line-height: 1.1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 8px 12px;
  color: #102038;
  background: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
}

.icon-button,
.menu-actions button,
.level-grid button {
  border: 0;
  cursor: pointer;
  font: inherit;
  color: #102038;
  background: linear-gradient(180deg, #fff5cc, #ffd166);
}

.icon-button {
  min-width: 58px;
  border-radius: 999px;
  padding: 8px 12px;
}

.game-wrap {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
}

.game-wrap {
  border-radius: 12px;
  overflow: hidden;
}

.hud {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: rgba(0, 0, 0, 0.32);
  font-size: 0.78rem;
  line-height: 1.5;
}

.hud-stats {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  background: linear-gradient(180deg, #7bdff6 0%, #d9ed92 100%);
}

.screen {
  position: absolute;
  inset: 48px 0 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(7, 14, 27, 0.45);
}

.screen.is-open {
  display: flex;
}

.menu-box {
  width: min(460px, calc(100vw - 44px));
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-radius: 10px;
  padding: 22px;
  color: #f8fbff;
  background: rgba(12, 23, 38, 0.88);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.36);
}

.kicker,
.menu-box h2,
.menu-box p {
  margin: 0;
}

.kicker {
  color: var(--accent);
  font-size: 0.85rem;
}

.menu-box h2 {
  margin-top: 10px;
  font-size: 1.8rem;
}

.menu-box p {
  margin-top: 10px;
  line-height: 1.5;
}

.menu-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.menu-actions button,
.level-grid button {
  border-radius: 8px;
  min-height: 44px;
  padding: 10px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.level-grid button.is-active {
  background: linear-gradient(180deg, #9fffc4, #06d6a0);
}

.touch-controls {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.34);
}

.touch-controls button {
  border: 0;
  border-radius: 8px;
  padding: 16px;
  font-size: 1rem;
  color: #102038;
  background: linear-gradient(180deg, #fff5cc, #ffd166);
}

@media (max-width: 840px) {
  .hud {
    flex-direction: column;
  }

  .touch-controls {
    display: grid;
  }
}

@media (max-width: 520px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 1.55rem;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .menu-actions,
  .level-grid {
    grid-template-columns: 1fr;
  }
}
