:root {
  --bg-900: #0b0f14;
  --bg-800: rgba(10, 18, 31, 0.84);
  --bg-700: rgba(5, 12, 22, 0.68);
  --fg-100: #e6f1ff;
  --muted-200: #a5bfd8;
  --neon-cyan: #00e5ff;
  --neon-magenta: #ff2bd6;
  --neon-green: #9cff00;
  --accent-yellow: #ffd400;
  --danger: #ff3b30;
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-neon: 0 0 24px rgba(0, 229, 255, 0.28);
  --radius-button: 10px;
  --radius-card: 12px;
  --radius-panel: 18px;
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --safe-bottom: max(20px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(0, 229, 255, 0.08), transparent 32%),
    linear-gradient(180deg, #0e1221 0%, var(--bg-900) 65%);
  color: var(--fg-100);
  font-family: "JetBrains Mono", monospace;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
  overflow: hidden;
}

body {
  position: relative;
}

button,
canvas {
  image-rendering: pixelated;
}

button {
  font: inherit;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at center, rgba(0, 229, 255, 0.08), transparent 44%),
    linear-gradient(180deg, rgba(14, 20, 39, 0.8), rgba(5, 8, 16, 0.92));
}

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

.screen-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at center, transparent 44%, rgba(0, 0, 0, 0.26) 100%),
    linear-gradient(180deg, rgba(1, 6, 18, 0.24), rgba(1, 5, 12, 0.48));
}

.hud {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 18px 18px 0;
  pointer-events: none;
  z-index: 4;
}

.hud-cluster {
  display: flex;
  gap: var(--space-2);
}

.hud-card {
  min-width: 108px;
  padding: 12px 14px;
  border: 1px solid rgba(0, 229, 255, 0.24);
  border-radius: var(--radius-card);
  background:
    linear-gradient(180deg, rgba(11, 18, 34, 0.92), rgba(6, 10, 20, 0.8));
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

.hud-card-highlight {
  border-color: rgba(255, 212, 0, 0.36);
}

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

.hud-value {
  display: block;
  margin-top: 8px;
  font-family: "Press Start 2P", monospace;
  font-size: 22px;
  line-height: 1.1;
  text-shadow:
    0 0 12px rgba(0, 229, 255, 0.3),
    0 0 22px rgba(255, 43, 214, 0.16);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease-out;
  z-index: 5;
}

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

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(5, 8, 16, 0.45), rgba(3, 6, 12, 0.82)),
    radial-gradient(circle at top, rgba(255, 43, 214, 0.12), transparent 28%);
  backdrop-filter: blur(8px);
}

.overlay-panel {
  position: relative;
  width: min(100%, 620px);
  padding: 28px;
  border: 1px solid rgba(0, 229, 255, 0.28);
  border-radius: var(--radius-panel);
  background:
    linear-gradient(180deg, rgba(11, 17, 31, 0.94), rgba(6, 10, 20, 0.92));
  box-shadow:
    var(--shadow-soft),
    inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  text-align: center;
}

.overlay-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(0, 229, 255, 0.09), transparent 28%),
    linear-gradient(315deg, rgba(255, 43, 214, 0.11), transparent 36%);
}

.logo-image,
.logo-fallback {
  position: relative;
  z-index: 1;
}

.logo-image {
  width: min(100%, 520px);
  height: auto;
  margin-inline: auto;
  display: block;
  filter: drop-shadow(0 10px 26px rgba(0, 229, 255, 0.22));
}

.logo-fallback {
  display: none;
  margin: 0 0 12px;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(28px, 7vw, 54px);
  line-height: 1.1;
  color: var(--fg-100);
  text-shadow:
    3px 3px 0 rgba(255, 43, 214, 0.9),
    -3px -3px 0 rgba(0, 229, 255, 0.9);
}

.overlay-title {
  position: relative;
  z-index: 1;
  margin: 18px 0 10px;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(18px, 3vw, 28px);
  line-height: 1.35;
}

.overlay-copy {
  position: relative;
  z-index: 1;
  max-width: 48ch;
  margin: 0 auto;
  color: var(--muted-200);
  font-size: 15px;
  line-height: 1.6;
}

.overlay-stats {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 22px 0;
  flex-wrap: wrap;
}

.overlay-stat {
  min-width: 132px;
  padding: 12px 14px;
  border-radius: var(--radius-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.overlay-stat span {
  display: block;
  font-size: 12px;
  color: var(--muted-200);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.overlay-stat strong {
  display: block;
  margin-top: 8px;
  font-family: "Press Start 2P", monospace;
  font-size: 18px;
}

.overlay-actions {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.game-button {
  min-width: 178px;
  padding: 14px 18px;
  border: 1px solid rgba(0, 229, 255, 0.42);
  border-radius: var(--radius-button);
  background:
    linear-gradient(180deg, rgba(0, 229, 255, 0.24), rgba(0, 92, 122, 0.2)),
    rgba(4, 12, 22, 0.94);
  color: var(--fg-100);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition:
    transform 150ms ease-out,
    filter 150ms ease-out,
    box-shadow 150ms ease-out,
    border-color 150ms ease-out;
}

.game-button:hover,
.game-button:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.1);
  border-color: rgba(0, 229, 255, 0.7);
  box-shadow: var(--shadow-soft), var(--shadow-neon);
  outline: none;
}

.game-button:active,
.game-button.is-pressed {
  transform: translateY(2px);
  filter: saturate(1.16);
}

.game-button-secondary {
  border-color: rgba(255, 43, 214, 0.36);
  background:
    linear-gradient(180deg, rgba(255, 43, 214, 0.22), rgba(110, 0, 78, 0.2)),
    rgba(4, 12, 22, 0.94);
}

.overlay-hint {
  position: relative;
  z-index: 1;
  margin: 16px 0 0;
  color: var(--muted-200);
  font-size: 12px;
}

.touch-controls {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 6px);
  transform: translateX(-50%);
  width: min(280px, calc(100vw - 28px));
  height: 220px;
  display: none;
  z-index: 6;
  transition:
    opacity 150ms ease-out,
    transform 150ms ease-out;
}

.overlay.is-visible ~ .touch-controls {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(14px);
}

.dpad-button {
  position: absolute;
  width: 78px;
  height: 78px;
  border: 1px solid rgba(0, 229, 255, 0.34);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(6, 16, 31, 0.9), rgba(4, 10, 20, 0.76)),
    rgba(0, 0, 0, 0.3);
  color: var(--fg-100);
  font-size: 28px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
  transition:
    transform 120ms ease-out,
    border-color 120ms ease-out,
    box-shadow 120ms ease-out;
  touch-action: manipulation;
}

.dpad-button:focus-visible,
.dpad-button.is-active {
  outline: none;
  border-color: rgba(156, 255, 0, 0.72);
  box-shadow:
    var(--shadow-soft),
    0 0 22px rgba(156, 255, 0, 0.28);
}

.dpad-button:active {
  transform: translateY(2px);
}

.dpad-up {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.dpad-down {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.dpad-left {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

.dpad-right {
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.legend {
  position: absolute;
  inset: auto 18px 18px auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 260px;
  padding: 12px 14px;
  border-radius: var(--radius-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(4, 10, 20, 0.64);
  color: var(--muted-200);
  font-size: 12px;
  line-height: 1.5;
  z-index: 3;
  backdrop-filter: blur(10px);
}

@media (max-width: 1023px) {
  .touch-controls {
    display: block;
  }

  .legend {
    display: none;
  }
}

@media (max-width: 767px) {
  .hud {
    padding: 12px 12px 0;
    gap: var(--space-2);
  }

  .hud-cluster {
    gap: 8px;
  }

  .hud-card {
    min-width: 88px;
    padding: 10px 10px 11px;
  }

  .hud-label {
    font-size: 10px;
  }

  .hud-value {
    margin-top: 6px;
    font-size: 16px;
  }

  .overlay {
    padding: 16px;
  }

  .overlay-panel {
    padding: 22px 18px;
  }

  .overlay-copy {
    font-size: 14px;
  }

  .overlay-actions {
    gap: 10px;
  }

  .game-button {
    min-width: 100%;
  }

  .touch-controls {
    height: 196px;
  }

  .dpad-button {
    width: 72px;
    height: 72px;
    font-size: 25px;
  }
}
