@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Kanit:wght@400;700&display=swap');

:root {
  --ink: #e5f4ff;
  --bg1: #060b1f;
  --bg2: #101f3b;
  --accent: #56ffd2;
  --accent-2: #ffd659;
  --danger: #ff5d75;
  --panel: rgba(11, 21, 45, 0.84);
}

* {
  box-sizing: border-box;
}

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

body.space-page {
  min-height: 100vh;
  color: var(--ink);
  font-family: 'Kanit', sans-serif;
  background:
    radial-gradient(circle at 20% 20%, rgba(86, 255, 210, 0.18), transparent 40%),
    radial-gradient(circle at 80% 30%, rgba(255, 214, 89, 0.16), transparent 35%),
    linear-gradient(160deg, var(--bg1), var(--bg2));
  padding: clamp(12px, 2vw, 24px);
}

.space-layout {
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.space-header {
  background: var(--panel);
  border: 2px solid rgba(86, 255, 210, 0.45);
  padding: 14px;
  border-radius: 14px;
}

.space-header h1 {
  margin: 8px 0 6px;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(18px, 4vw, 30px);
  color: var(--accent);
}

.subtitle {
  margin: 0;
  color: #c9daff;
}

.back-link {
  color: var(--accent-2);
  font-weight: 700;
}

.game-shell,
.leaderboard-panel,
.game-over {
  background: var(--panel);
  border-radius: 14px;
  border: 2px solid rgba(201, 218, 255, 0.25);
  padding: 14px;
}

#game-canvas {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 2px solid rgba(86, 255, 210, 0.5);
  background: #050816;
  touch-action: none;
  cursor: pointer;
}

#start-button {
  display: none !important;
}

.ship-skins {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.ship-skins-title {
  margin: 0;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #c9daff;
  letter-spacing: 0.06em;
}

.ship-skin-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.ship-skin-option {
  border: 1px solid rgba(201, 218, 255, 0.35);
  background: linear-gradient(145deg, #1a2a4d, #121b38);
  border-radius: 8px;
  min-height: 38px;
  padding: 6px 4px;
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
}

.ship-skin-option:focus-visible {
  outline: 2px solid #fff2b2;
  outline-offset: 2px;
}

.ship-skin-option.is-selected {
  border-color: rgba(86, 255, 210, 0.85);
  box-shadow: inset 0 0 0 1px rgba(86, 255, 210, 0.7);
}

.ship-skin-options.is-locked .ship-skin-option {
  opacity: 0.55;
  cursor: not-allowed;
}

.ship-skin-preview {
  width: 30px;
  height: 16px;
  position: relative;
  display: block;
}

.ship-skin-preview::before,
.ship-skin-preview::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.ship-skin-preview::before {
  top: 7px;
  width: 30px;
  height: 9px;
  background: var(--ship-body, #56ffd2);
}

.ship-skin-preview::after {
  top: 0;
  width: 18px;
  height: 7px;
  background: var(--ship-canopy, #afe8ff);
}

.hud {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
}

.hud p {
  margin: 0;
}

.status-text,
.panel-note {
  margin: 12px 0 0;
  min-height: 20px;
  color: #d7e6ff;
}

.primary-btn,
.secondary-btn,
.touch-btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), #2ec5ff);
  color: #031423;
}

.secondary-btn {
  background: linear-gradient(135deg, #d7e6ff, #9ec5ff);
  color: #07172d;
}

.touch-controls {
  display: none;
  margin-top: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.touch-btn {
  background: linear-gradient(145deg, #1f2f59, #101936);
  color: #ddedff;
  border: 1px solid rgba(221, 237, 255, 0.35);
  min-height: 54px;
  touch-action: manipulation;
  user-select: none;
}

.touch-btn.action {
  background: linear-gradient(145deg, #56301c, #ab4a2a);
}

.touch-btn.is-active {
  transform: translateY(1px) scale(0.98);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.leaderboard-list {
  margin: 0;
  padding-left: 24px;
}

.leaderboard-list li {
  margin: 6px 0;
}

.game-over-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#initials-input {
  margin-top: 6px;
  width: 120px;
  font-size: 20px;
  text-transform: uppercase;
  text-align: center;
  border-radius: 10px;
  border: 2px solid rgba(255, 214, 89, 0.5);
  padding: 8px;
  background: #0f1a39;
  color: #fff2b2;
}

.hidden {
  display: none;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
}

.skip-link:focus-visible {
  left: 12px;
  top: 12px;
  z-index: 1000;
  background: #fff;
  color: #000;
  padding: 8px 10px;
}

@media (max-width: 760px) {
  .space-layout {
    gap: 12px;
  }

  .ship-skin-options {
    gap: 6px;
  }

  .ship-skin-option {
    min-height: 34px;
    padding: 5px 3px;
  }

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

@media (pointer: coarse) {
  .touch-controls {
    display: grid;
  }
}
