:root {
  --ink: #ecf7ef;
  --muted: #93a59a;
  --line: rgba(236, 247, 239, 0.16);
  --panel: rgba(7, 17, 13, 0.62);
  --hot: #ffbf45;
  --danger: #ff4f64;
  --goal: #62e38c;
  --level-bg: url("assets/level-1-bg.png");
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #07110d;
  color: var(--ink);
  font-family: "Avenir Next Condensed", "DIN Condensed", "Bahnschrift", sans-serif;
}

body {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.shell {
  position: fixed;
  inset: 0;
  min-width: 0;
  min-height: 0;
  background:
    linear-gradient(rgba(3, 8, 11, 0.24), rgba(3, 8, 11, 0.44)),
    radial-gradient(circle at center, transparent 0%, rgba(2, 7, 10, 0.18) 58%, rgba(2, 7, 10, 0.68) 100%),
    var(--level-bg) center / cover no-repeat,
    linear-gradient(140deg, #07110d 0%, #0f2119 47%, #10140f 100%);
}

.shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.1;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at center, black, transparent 82%);
}

.shell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 48%, transparent 0%, transparent 45%, rgba(0, 0, 0, 0.34) 100%),
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: auto, 100% 3px;
  mix-blend-mode: multiply;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  pointer-events: none;
}

.readouts {
  display: grid;
  grid-template-columns: minmax(48px, 64px);
}

.readouts div {
  min-height: 50px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.22);
}

.readouts span,
.readouts strong {
  display: block;
  line-height: 1;
  text-align: left;
}

.readouts span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.readouts strong {
  margin-top: 6px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
}

.message {
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  min-width: min(280px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 17, 13, 0.7);
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.message.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(3, 8, 11, 0.48);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.overlay.loss {
  pointer-events: none;
}

.overlay.loss .overlay-panel {
  width: auto;
  max-width: min(420px, 100%);
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  text-align: center;
}

.overlay.loss .overlay-actions {
  display: none;
}

.overlay.loss h1 {
  text-shadow: 0 0 18px rgba(236, 247, 239, 0.52);
}

.overlay.loss p {
  text-shadow: 0 0 14px rgba(98, 227, 140, 0.46);
}

.overlay-panel {
  width: min(620px, 100%);
  max-height: calc(100dvh - 44px);
  overflow: auto;
  padding: 18px 20px;
  border: 1px solid rgba(236, 247, 239, 0.22);
  border-radius: 8px;
  background: rgba(7, 17, 13, 0.72);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.42);
}

.overlay h1 {
  margin: 0;
  font-size: clamp(34px, 9vw, 64px);
  line-height: 0.9;
}

.overlay p {
  margin: 14px 0 0;
  color: var(--ink);
  font-size: clamp(16px, 4vw, 20px);
  font-weight: 800;
  line-height: 1.2;
}

.overlay.start #overlay-copy {
  font-size: clamp(14px, 2.8vw, 18px);
  line-height: 1.28;
}

.level-select-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(236, 247, 239, 0.14);
  border-radius: 8px;
  background: rgba(3, 8, 11, 0.34);
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  text-transform: uppercase;
}

.level-select-wrap[hidden] {
  display: none;
}

.level-select-wrap select {
  min-width: 118px;
  border: 1px solid rgba(98, 227, 140, 0.36);
  border-radius: 8px;
  background: rgba(7, 17, 13, 0.9);
  color: var(--ink);
  font: 900 16px/1 "Avenir Next Condensed", "DIN Condensed", "Bahnschrift", sans-serif;
  padding: 8px 10px;
}

.overlay-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.mode-choice {
  display: flex;
  min-height: 148px;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(236, 247, 239, 0.12);
  border-radius: 8px;
  background: rgba(236, 247, 239, 0.05);
}

.mode-choice p {
  margin: 0;
  color: var(--ink);
  font-size: clamp(14px, 3vw, 17px);
  line-height: 1.2;
}

.overlay button,
.planned-controls button {
  margin-top: 18px;
  min-width: 108px;
  min-height: 44px;
  border: 1px solid rgba(236, 247, 239, 0.28);
  border-radius: 8px;
  background: rgba(98, 227, 140, 0.18);
  color: var(--ink);
  font: 900 18px/1 "Avenir Next Condensed", "DIN Condensed", "Bahnschrift", sans-serif;
  text-transform: uppercase;
}

.overlay button {
  margin-top: 0;
}

.overlay button.secondary {
  background: rgba(236, 247, 239, 0.1);
}

.overlay button:active,
.planned-controls button:active {
  transform: translateY(1px);
  background: rgba(98, 227, 140, 0.3);
}

.planned-controls {
  position: absolute;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 4;
  display: flex;
  gap: 8px;
}

.planned-controls[hidden] {
  display: none;
}

.planned-controls button {
  margin-top: 0;
  min-width: 92px;
  background: rgba(7, 17, 13, 0.62);
  backdrop-filter: blur(12px);
}

.radio-controls {
  position: absolute;
  right: max(10px, env(safe-area-inset-right));
  top: max(10px, env(safe-area-inset-top));
  z-index: 4;
  display: flex;
  max-width: calc(100vw - 20px - env(safe-area-inset-left) - env(safe-area-inset-right));
  gap: 6px;
  justify-content: flex-end;
}

.sfx-toggle,
.radio-toggle,
.radio-next {
  min-width: 104px;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid rgba(236, 247, 239, 0.24);
  border-radius: 8px;
  background: rgba(7, 17, 13, 0.62);
  color: var(--ink);
  font: 900 13px/1 "Avenir Next Condensed", "DIN Condensed", "Bahnschrift", sans-serif;
  text-transform: uppercase;
  backdrop-filter: blur(12px);
}

.sfx-toggle {
  min-width: 72px;
}

.radio-next {
  min-width: 42px;
  padding-inline: 10px;
}

.sfx-toggle[aria-pressed="true"] {
  border-color: rgba(255, 79, 100, 0.42);
  background: rgba(255, 79, 100, 0.14);
}

.radio-toggle[aria-pressed="true"] {
  border-color: rgba(98, 227, 140, 0.44);
  background: rgba(98, 227, 140, 0.16);
}

.sfx-toggle:active,
.radio-toggle:active,
.radio-next:active {
  transform: translateY(1px);
}

.sfx-toggle span,
.radio-toggle span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .readouts {
    grid-template-columns: 48px;
  }

  .readouts div {
    min-height: 44px;
    padding: 7px;
  }

  .readouts strong {
    font-size: 20px;
  }

  .overlay-panel {
    padding: 16px;
  }

  .overlay-actions {
    grid-template-columns: 1fr;
  }

  .mode-choice {
    min-height: 0;
  }

  .sfx-toggle,
  .radio-toggle {
    min-width: 92px;
    max-width: 42vw;
    min-height: 34px;
    padding: 7px 9px;
    font-size: 12px;
  }

  .sfx-toggle {
    min-width: 68px;
    max-width: 24vw;
  }

  .radio-next {
    min-width: 38px;
    min-height: 34px;
    padding: 7px 8px;
    font-size: 12px;
  }
}
