:root {
  --bg: #0a0e1a;
  --panel: #121a2b;
  --accent: #f9d648;
  --text: #e6eaf2;
}

* {
  box-sizing: border-box;
}

html,
body {
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  overflow: hidden;
  place-items: center;
  background: radial-gradient(circle at top, #141b2e, #070a12 60%);
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  touch-action: manipulation;
}

.wrap {
  display: grid;
  gap: 16px;
  justify-items: center;
  touch-action: none;
  padding: 16px 12px 24px;
  width: 100%;
  max-width: 680px;
}

header {
  text-align: center;
}

h1 {
  margin: 0 0 4px;
  font-size: 28px;
  letter-spacing: 1px;
}

p {
  margin: 0;
  opacity: 0.8;
}

.view-stack {
  position: relative;
  width: min(92vw, 504px);
  transition: opacity 0.2s ease;
  min-height: 0;
  overflow: hidden;
  font-size: 14px;
  aspect-ratio: 504 / 408;
  display: grid;
  grid-template-areas: "stack";
}

.game-shell {
  grid-area: stack;
  width: 100%;
  height: 100%;
  display: block;
}

.highscores-panel {
  grid-area: stack;
  display: flex;
  height: 100%;
  padding: 18px 20px;
  border: 2px solid #31406b;
  border-radius: 12px;
  background: #0b1022;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  color: var(--text);
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  overflow: hidden;
}

.highscores-panel h2 {
  margin: 0 0 12px;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.highscores-panel ol {
  margin: 0;
  padding-left: 20px;
}

.highscores-panel li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 600;
  font-size: 13px;
}

.show-scores .game-shell {
  opacity: 0;
  pointer-events: none;
}

.show-scores .highscores-panel {
  opacity: 1;
  pointer-events: auto;
}

#game {
  background: #000;
  border: 2px solid #31406b;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  height: 100%;
}

.joystick-shell {
  position: relative;
  z-index: 10;
  display: none;
  justify-content: center;
}

body.touch-device .joystick-shell {
  display: flex;
}

.joystick {
  width: 240px;
  height: 240px;
  border-radius: 999px;
  background: rgba(15, 20, 38, 0.7);
  box-shadow: inset 0 0 0 2px #31406b, 0 10px 25px rgba(0, 0, 0, 0.35);
  position: relative;
  touch-action: none;
}

.joystick-knob {
  width: 100px;
  height: 100px;
  border-radius: 999px;
  background: #f9d648;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  transition: transform 0.05s linear;
}


.hud {
  display: flex;
  gap: 20px;
  padding: 10px 18px;
  background: var(--panel);
  border-radius: 999px;
  font-weight: 600;
  flex-wrap: wrap;
  justify-content: center;
}

.version {
  font-size: 12px;
  letter-spacing: 0.5px;
  opacity: 0.7;
  position: fixed;
  right: 10px;
  bottom: 8px;
  pointer-events: none;
}

.controls {
  display: flex;
  justify-content: center;
  min-height: 44px;
}

.name-bar {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  padding: 10px 12px;
  border-radius: 12px;
  margin-top: 10px;
}

.name-bar-label {
  font-size: 12px;
  opacity: 0.8;
}

.name-bar input {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #31406b;
  background: #0a0e1a;
  color: var(--text);
  min-width: 120px;
}

.name-bar .ghost {
  background: transparent;
  border: 1px solid #31406b;
  color: var(--text);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(5, 6, 11, 0.75);
  z-index: 999;
  padding: 20px;
  touch-action: auto;
  pointer-events: none;
}

.modal.is-open {
  display: grid;
  pointer-events: auto;
}

.modal-card {
  width: min(92vw, 360px);
  background: #0b1022;
  border: 2px solid #31406b;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  display: grid;
  gap: 12px;
  touch-action: auto;
}

.modal-card h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 1px;
}

.modal-label {
  font-size: 13px;
  opacity: 0.8;
}

.modal-card input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #31406b;
  background: #0a0e1a;
  color: var(--text);
  touch-action: auto;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-actions .ghost {
  background: transparent;
  border: 1px solid #31406b;
  color: var(--text);
}

#startButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 0;
  padding: 10px 22px;
  border-radius: 999px;
  background: var(--accent);
  color: #1b1b1b;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

#startButton:disabled {
  opacity: 0.7;
  cursor: default;
}

.controls.is-hidden {
  visibility: hidden;
}

@media (max-width: 600px) {
  h1 {
    font-size: 22px;
  }

  .hud {
    gap: 12px;
    padding: 8px 14px;
    font-size: 14px;
  }

  .highscores-panel {
    font-size: 12px;
  }

  .highscores-panel li {
    font-size: 11px;
    padding: 4px 0;
  }
}

.view-stack {
  position: relative;
}

.view-stack .game-shell,
.view-stack .highscores-panel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.view-stack .highscores-panel {
  padding: 12px 14px;
}

