@import url("https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@600;800&display=swap");

:root {
  color-scheme: light;
  font-family: "Nunito", system-ui, -apple-system, sans-serif;
  background: #060b2a;
  --ink: #fef9c3;
  --ink-dark: #0b1b3a;
  --accent: #ffd166;
  --accent-2: #2dd4bf;
  --accent-3: #f97316;
  --panel: rgba(10, 20, 60, 0.85);
  --panel-bright: rgba(255, 255, 255, 0.95);
  --shadow: 0 20px 40px rgba(8, 12, 40, 0.4);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #1b2b6f 0%, #09102b 55%, #030618 100%);
  color: var(--ink);
}

#app {
  width: min(96vw, 1200px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
}

#title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

#title-bar h1 {
  margin: 0;
  font-family: "Fredoka One", "Nunito", sans-serif;
  font-size: clamp(1.6rem, 2.2vw, 2.4rem);
  letter-spacing: 1px;
}

#title-bar .subtitle {
  font-size: 0.95rem;
  color: #c7d2fe;
}

#game-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #0c1438;
}

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

#ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.panel {
  position: absolute;
  inset: 10% 10%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px;
  background: var(--panel);
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  text-align: center;
  pointer-events: auto;
}

.panel h2 {
  font-family: "Fredoka One", "Nunito", sans-serif;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  margin: 0;
  color: #fef3c7;
}

.panel p {
  margin: 0;
  font-size: 1.1rem;
  color: #e0e7ff;
}

.ship-select {
  width: min(520px, 100%);
  display: grid;
  gap: 8px;
  align-items: center;
}

.ship-select-title {
  font-size: 1rem;
  color: #fef9c3;
}

.ship-select-hint {
  font-size: 0.9rem;
  color: #cbd5f5;
}

.ship-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.ship-card {
  border-radius: 14px;
  padding: 10px;
  background: rgba(17, 24, 69, 0.85);
  border: 2px solid transparent;
  display: grid;
  gap: 6px;
  align-items: center;
  justify-items: center;
  color: #e0e7ff;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, opacity 0.2s ease;
}

.ship-card span {
  font-size: 1.7rem;
}

.ship-card strong {
  font-size: 0.75rem;
  text-align: center;
}

.ship-card.selected {
  border-color: #ffd166;
  transform: translateY(-2px);
}

.ship-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.ship-card .lock-label {
  font-size: 0.65rem;
  color: #fcd34d;
}

.panel .options {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  justify-content: center;
  font-size: 1rem;
  color: #fef9c3;
}

.panel input[type="checkbox"] {
  accent-color: var(--accent);
  transform: scale(1.2);
}

.primary-btn {
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffd166, #f97316);
  color: #351400;
  font-size: 1.2rem;
  font-family: "Fredoka One", "Nunito", sans-serif;
  padding: 14px 36px;
  cursor: pointer;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.25);
}

.primary-btn:active {
  transform: translateY(3px);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25);
}

.secondary-btn {
  border: 2px solid #c7d2fe;
  border-radius: 999px;
  background: transparent;
  color: #e0e7ff;
  font-size: 0.95rem;
  padding: 8px 18px;
  cursor: pointer;
}

#hud {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.hud-card {
  background: rgba(16, 24, 72, 0.85);
  border-radius: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.hud-card h3 {
  margin: 0 0 6px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #c7d2fe;
}

.hud-card p {
  margin: 0;
  font-family: "Fredoka One", "Nunito", sans-serif;
  font-size: 1.2rem;
  color: #fef3c7;
}

#keyboard-nudge {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 16px 20px;
  background: rgba(12, 18, 52, 0.9);
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#keyboard-nudge.active {
  opacity: 1;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.keycap {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #111b4c;
  border: 2px solid #3b82f6;
  color: #e0e7ff;
  font-family: "Fredoka One", "Nunito", sans-serif;
  display: grid;
  place-items: center;
  font-size: 1rem;
}

.keycap.is-target {
  background: #ffd166;
  color: #4a2c00;
  border-color: #fbbf24;
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.9);
}

#result-chart {
  width: min(520px, 90%);
  background: var(--panel-bright);
  color: #0f172a;
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.chart-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
}

.chart-bar {
  flex: 1;
  height: 12px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.chart-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #2dd4bf, #38bdf8);
}

#sr-help {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

@media (max-width: 700px) {
  .panel {
    inset: 8% 6%;
    padding: 22px;
  }

  #keyboard-nudge {
    bottom: 16px;
    transform: translateX(-50%) scale(0.9);
  }
}
