:root {
  --ink: #f8f4df;
  --muted: #b8c7d7;
  --panel: rgba(7, 12, 28, 0.72);
  --line: rgba(255, 255, 255, 0.22);
  --amber: #ffbb4d;
  --green: #52ff9c;
  --red: #ff5d62;
  --deep: #070b1d;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 185, 77, 0.28), transparent 28%),
    radial-gradient(circle at 82% 72%, rgba(82, 255, 156, 0.18), transparent 24%),
    linear-gradient(135deg, #0a0d21 0%, #15192f 45%, #261526 100%);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  overflow: hidden;
}

button {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.game-wrap {
  position: relative;
  width: min(100vw - 24px, 1120px);
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 36px);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #050817;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.46);
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
}

.hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
  gap: 10px;
}

.hud > div {
  min-width: 86px;
  padding: 9px 12px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(10px);
}

.label {
  display: block;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.1;
}

.hud strong {
  display: block;
  color: var(--ink);
  font-size: clamp(18px, 3vw, 28px);
  line-height: 1;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 28px;
  text-align: center;
  background:
    linear-gradient(90deg, rgba(3, 7, 21, 0.72), rgba(3, 7, 21, 0.12)),
    radial-gradient(circle at 50% 50%, rgba(82, 255, 156, 0.12), transparent 34%);
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  margin: 0;
  color: var(--ink);
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(42px, 8vw, 104px);
  line-height: 0.9;
  letter-spacing: 0;
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.38), 0 0 30px rgba(255, 187, 77, 0.38);
}

.overlay p {
  max-width: 560px;
  margin: 18px 0 24px;
  color: #e8f1ff;
  font-size: clamp(15px, 2vw, 19px);
  line-height: 1.45;
}

.story {
  display: grid;
  gap: 6px;
  max-width: 620px;
  margin: 0 0 24px;
  color: #c9d7e4;
  font-size: clamp(12px, 1.55vw, 15px);
  line-height: 1.35;
}

.story span {
  display: block;
}

.story.hidden {
  display: none;
}

#start {
  min-width: 186px;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  color: #061008;
  background: linear-gradient(180deg, #91ffc0, var(--green));
  box-shadow: 0 9px 0 #178a4d, 0 0 30px rgba(82, 255, 156, 0.42);
  cursor: pointer;
  font-weight: 800;
  text-transform: uppercase;
}

#start:active {
  transform: translateY(5px);
  box-shadow: 0 4px 0 #178a4d, 0 0 22px rgba(82, 255, 156, 0.34);
}

#start:focus-visible,
.pad:focus-visible,
.pause-button:focus-visible,
.sound-button:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

.pause-button,
.sound-button {
  position: absolute;
  right: 14px;
  width: 54px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  backdrop-filter: blur(10px);
  cursor: pointer;
  font-weight: 900;
  line-height: 1;
}

.pause-button {
  bottom: 14px;
}

.sound-button {
  bottom: 62px;
}

.pause-button:hover,
.sound-button:hover {
  border-color: rgba(82, 255, 156, 0.58);
  box-shadow: 0 0 20px rgba(82, 255, 156, 0.18);
}

.sound-button[aria-pressed="true"] {
  color: var(--muted);
  border-color: rgba(255, 255, 255, 0.12);
  text-decoration: line-through;
}

.touch-controls {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: none;
  grid-template-columns: repeat(5, 48px);
  gap: 8px;
}

.pad {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(7, 12, 28, 0.66);
  backdrop-filter: blur(10px);
  cursor: pointer;
}

.pad.fire {
  color: #051407;
  background: var(--green);
  font-size: 17px;
  font-weight: 900;
}

@media (pointer: coarse), (max-width: 760px) {
  body {
    overflow: auto;
  }

  .shell {
    align-items: start;
    padding: 8px;
  }

  .game-wrap {
    width: calc(100vw - 16px);
    max-height: none;
    margin-top: 8px;
  }

  .hud {
    top: 8px;
    left: 8px;
    right: 8px;
  }

  .hud > div {
    min-width: 68px;
    padding: 7px 8px;
  }

  .pause-button,
  .sound-button {
    right: 14px;
  }

  .pause-button {
    bottom: 14px;
  }

  .sound-button {
    bottom: 62px;
  }

  .touch-controls {
    display: grid;
  }
}
