@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap");

:root {
  --bg: #0d1224;
  --bg-accent: #18204a;
  --screen: #0b0f1c;
  --neon: #ffd74f;
  --mint: #6cf5ff;
  --danger: #ff5a6f;
  --ink: #f5f1e6;
  --shadow: #05070f;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  min-height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top, var(--bg-accent), var(--bg));
  color: var(--ink);
  font-family: "VT323", monospace;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

.frame {
  width: min(980px, 95vw);
  display: grid;
  gap: 12px;
}

.title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #1b244f, #10162d);
  border: 4px solid #2d3b73;
  box-shadow: 0 0 0 4px var(--shadow), 0 12px 30px rgba(0, 0, 0, 0.4);
}

.title-bar h1 {
  font-family: "Press Start 2P", system-ui;
  font-size: 18px;
  letter-spacing: 1px;
}

.hud {
  display: flex;
  gap: 16px;
  font-size: 20px;
  color: var(--neon);
  flex-wrap: wrap;
}

.boss {
  color: var(--danger);
  text-shadow: 0 0 8px rgba(255, 90, 111, 0.6);
}

.lives {
  color: #ffb84f;
}

.jammed {
  color: #ff7a7a;
  text-transform: uppercase;
}

.hidden {
  display: none;
}

.game-shell {
  position: relative;
  border: 6px solid #2d3b73;
  background: var(--screen);
  box-shadow: 0 0 0 6px var(--shadow), inset 0 0 30px rgba(0, 0, 0, 0.6);
  touch-action: none;
}

.control-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  padding: 10px 14px;
  border: 4px solid #2d3b73;
  background: linear-gradient(135deg, #141c3d, #0d142b);
  font-size: 16px;
  color: #b8c6ff;
  box-shadow: 0 0 0 4px var(--shadow);
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  image-rendering: pixelated;
  background: linear-gradient(180deg, #101a3d 0%, #0b0f1c 65%);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 10, 20, 0.75);
  text-align: center;
  padding: 16px;
  z-index: 3;
}

.overlay.hidden {
  display: none;
}

.touch-controls {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom)) 20px;
  pointer-events: none;
  z-index: 2;
}

.touch-left,
.touch-right {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.touch-right {
  align-items: flex-end;
}

.touch-btn {
  font-family: "Press Start 2P", system-ui;
  font-size: 12px;
  padding: 12px 14px;
  border: 3px solid var(--mint);
  background: rgba(9, 17, 38, 0.8);
  color: var(--mint);
  border-radius: 10px;
  box-shadow: 0 0 0 3px var(--shadow);
  min-width: 64px;
}

.touch-btn:active,
.touch-btn.is-active {
  background: rgba(28, 44, 90, 0.9);
  transform: translateY(1px);
}

.touch-small {
  font-size: 10px;
  padding: 10px 10px;
  min-width: 52px;
}

.touch-move {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  pointer-events: none;
}

.touch-zone {
  background: transparent;
  border: none;
  padding: 0;
  position: absolute;
  top: 0;
  bottom: 0;
  pointer-events: auto;
}

.overlay:not(.hidden) ~ .touch-controls {
  display: none;
}

.rotate-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px;
  background: rgba(9, 14, 30, 0.86);
  color: var(--mint);
  font-family: "Press Start 2P", system-ui;
  font-size: 14px;
  line-height: 1.4;
  text-shadow: 0 0 8px rgba(108, 245, 255, 0.5);
  z-index: 4;
}

.rotate-hint.hidden {
  display: none;
}

.panel {
  max-width: 520px;
  padding: 22px;
  border: 4px solid var(--mint);
  background: #091126;
  box-shadow: 0 0 0 4px var(--shadow);
}

.panel h2 {
  font-family: "Press Start 2P", system-ui;
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--mint);
}

.panel p {
  font-size: 20px;
  margin-bottom: 16px;
  line-height: 1.4;
}

.name-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  font-size: 18px;
}

.name-row input {
  font-family: "VT323", monospace;
  font-size: 18px;
  padding: 6px 8px;
  border: 2px solid var(--mint);
  background: #0d1736;
  color: var(--ink);
  box-shadow: 0 0 0 3px var(--shadow);
}

.leaderboard {
  margin-top: 16px;
  text-align: left;
}

.leaderboard h3 {
  font-family: "Press Start 2P", system-ui;
  font-size: 12px;
  color: var(--neon);
  margin-bottom: 8px;
}

.leaderboard ol {
  list-style-position: inside;
  font-size: 18px;
  color: #b8c6ff;
}

.leaderboard li {
  margin-bottom: 4px;
}

button {
  font-family: "Press Start 2P", system-ui;
  font-size: 14px;
  padding: 12px 20px;
  border: 4px solid var(--neon);
  background: #1a1f3d;
  color: var(--neon);
  cursor: pointer;
  text-transform: uppercase;
  box-shadow: 0 0 0 4px var(--shadow);
}

button:hover {
  background: #242a57;
}

.tip {
  text-align: center;
  padding-bottom: 8px;
  font-size: 18px;
  color: #9aa6d1;
}

@media (max-width: 600px) {
  .title-bar {
    flex-direction: column;
    align-items: flex-start;
  }

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

@media (hover: none) and (pointer: coarse) {
  body {
    place-items: start center;
  }

  .frame {
    width: 100vw;
    height: calc(var(--vh, 1vh) * 100);
    max-height: calc(var(--vh, 1vh) * 100);
  }

  .game-shell {
    aspect-ratio: 16 / 9;
    max-height: 62svh;
  }

  canvas {
    height: 100%;
  }

  .control-bar {
    display: none;
  }

  .touch-controls {
    display: flex;
  }

  .touch-left {
    display: flex;
    gap: 10px;
  }

  .touch-left .touch-btn {
    min-width: 128px;
  }
}

@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
  body {
    place-items: center;
  }

  .frame {
    width: 100vw;
    height: calc(var(--vh, 1vh) * 100);
    max-height: calc(var(--vh, 1vh) * 100);
  }

  .title-bar,
  .control-bar,
  .tip {
    display: none;
  }

  .game-shell {
    width: 100vw;
    height: calc(var(--vh, 1vh) * 100);
    max-height: none;
    aspect-ratio: auto;
  }

  canvas {
    height: 100%;
  }
}

@media (hover: hover) and (pointer: fine) {
  .touch-controls {
    display: none;
  }
}
