:root {
  --bg-deep: #050714;
  --panel-bg: rgba(12, 16, 38, 0.78);
  --panel-border: rgba(110, 215, 255, 0.28);
  --accent-cyan: #38e8ff;
  --accent-pink: #ff3e9d;
  --accent-gold: #ffc845;
  --accent-green: #3dff9e;
  --text-main: #f2f7ff;
  --text-muted: #93a6cc;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  outline: none;
  touch-action: manipulation;
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 28px;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  background: radial-gradient(circle at 50% 20%, rgba(18, 28, 68, 0.55), rgba(4, 6, 18, 0.86));
  backdrop-filter: blur(6px);
  z-index: 20;
}

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

.hidden {
  display: none !important;
}

/* Header & Language Switcher */
.menu-topbar {
  width: 100%;
  max-width: 1240px;
  display: flex;
  justify-content: flex-end;
  margin-bottom: -8px;
}

.lang-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid rgba(56, 232, 255, 0.38);
  background: rgba(10, 16, 40, 0.78);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.lang-switch-btn:hover {
  border-color: var(--accent-cyan);
  background: rgba(24, 38, 86, 0.85);
}

.lang-switch-btn:active {
  transform: scale(0.96);
}

.lang-switch-btn .lang-opt.active {
  color: var(--accent-cyan);
  text-shadow: 0 0 8px rgba(56, 232, 255, 0.65);
}

.lang-switch-btn .lang-sep {
  opacity: 0.4;
}

.lang-mini-btn {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--accent-cyan);
}

.menu-header {
  text-align: center;
  margin-top: 0;
}

.subtitle-tag {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 232, 255, 0.35);
  background: rgba(56, 232, 255, 0.08);
  margin-bottom: 8px;
}

.game-title {
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 900;
  letter-spacing: 4px;
  text-shadow: 0 0 28px rgba(56, 232, 255, 0.55);
}

.game-title span {
  background: linear-gradient(90deg, var(--accent-cyan), #a77dff, var(--accent-pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.game-desc {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
  letter-spacing: 1px;
}

/* Planet Cards Grid */
.planet-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 1240px;
  margin: auto 0;
}

@media (max-width: 1120px) {
  .planet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}

@media (max-width: 620px) {
  .planet-grid {
    grid-template-columns: 1fr;
  }
}

.planet-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--panel-bg);
  border: 1px solid var(--card-accent-soft, rgba(110, 215, 255, 0.25));
  border-radius: 18px;
  padding: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.planet-card:hover {
  transform: translateY(-5px);
  border-color: var(--card-accent, var(--accent-cyan));
  box-shadow: 0 12px 32px -8px var(--card-glow, rgba(56, 232, 255, 0.35));
}

.planet-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.planet-preview {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 50%;
}

.planet-meta {
  flex: 1;
  min-width: 0;
}

.planet-code {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--card-accent, var(--accent-cyan));
}

.planet-name {
  font-size: clamp(15px, 1.3vw, 18px);
  font-weight: 800;
  margin: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.planet-diff {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--accent-gold);
}

.planet-desc {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-muted);
  margin-bottom: 12px;
  min-height: 36px;
}

.planet-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.mech-tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: #cde0ff;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.planet-progress-section {
  margin-bottom: 14px;
}

.best-row {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.best-row strong {
  color: var(--text-main);
}

.mini-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 7px;
}

.mini-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--card-accent, var(--accent-cyan));
  box-shadow: 0 0 8px var(--card-accent, var(--accent-cyan));
  transition: width 0.3s ease;
}

.mini-bar-fill.practice {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.btn-play-normal {
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #040814;
  background: var(--card-accent, var(--accent-cyan));
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.btn-play-normal:hover {
  filter: brightness(1.15);
}

.btn-play-normal:active {
  transform: scale(0.97);
}

.btn-play-practice {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-green);
  background: rgba(61, 255, 158, 0.1);
  border: 1px solid rgba(61, 255, 158, 0.38);
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-play-practice:hover {
  background: rgba(61, 255, 158, 0.22);
}

/* Menu Footer */
.menu-footer {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(10, 14, 34, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.skin-selector {
  display: flex;
  align-items: center;
  gap: 12px;
}

.footer-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.skin-swatches {
  display: flex;
  gap: 8px;
}

.skin-swatch {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.skin-swatch.active {
  transform: scale(1.18);
  border-color: #ffffff;
  box-shadow: 0 0 12px currentColor;
}

.controls-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 700;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 5px;
}

/* In-Game HUD */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.hud-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  padding: 14px 16px;
  width: 100%;
}

.hud-top-left,
.hud-top-right {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.hud-top-center {
  flex: 1 1 200px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 auto;
}

@media (max-width: 720px) {
  .hud-top-center {
    order: 3;
    flex: 1 1 100%;
    max-width: 100%;
  }
  .planet-badge {
    display: none;
  }
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(10, 14, 34, 0.86);
  color: var(--text-main);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  background: rgba(35, 52, 105, 0.92);
  border-color: var(--accent-cyan);
}

.planet-badge,
.mode-badge {
  padding: 7px 11px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  white-space: nowrap;
  background: rgba(10, 14, 34, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.mode-badge {
  color: var(--accent-cyan);
  border-color: rgba(56, 232, 255, 0.35);
}

.progress-wrap {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(8, 12, 28, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.22);
  overflow: visible;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-pink));
  box-shadow: 0 0 12px var(--accent-cyan);
}

.progress-checkpoints {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.cp-tick {
  position: absolute;
  top: -3px;
  width: 8px;
  height: 14px;
  transform: translateX(-50%);
  color: var(--accent-green);
  font-size: 11px;
  line-height: 14px;
  text-shadow: 0 0 6px var(--accent-green);
}

.progress-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
  font-size: 13px;
  font-weight: 800;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

.practice-tag {
  color: var(--accent-green);
  font-size: 12px;
}

/* Practice Bottom Bar */
.practice-bar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 24px);
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(8, 16, 32, 0.9);
  border: 1px solid rgba(61, 255, 158, 0.35);
  pointer-events: auto;
}

.cp-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  transition: background 0.15s ease, transform 0.1s ease;
}

.cp-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.cp-btn:active {
  transform: scale(0.96);
}

.cp-btn.place {
  color: var(--accent-green);
  border-color: rgba(61, 255, 158, 0.45);
  background: rgba(61, 255, 158, 0.12);
}

.cp-btn.auto.active {
  color: var(--accent-cyan);
  border-color: rgba(56, 232, 255, 0.45);
  background: rgba(56, 232, 255, 0.12);
}

.cp-btn.remove {
  color: #ff859d;
  border-color: rgba(255, 95, 130, 0.38);
}

.cp-count {
  font-size: 12px;
  color: var(--text-muted);
  padding-left: 4px;
}

/* Modals */
.modal-overlay {
  justify-content: center;
}

.modal-card {
  width: min(420px, 90vw);
  background: rgba(12, 18, 44, 0.92);
  border: 1px solid rgba(56, 232, 255, 0.35);
  border-radius: 22px;
  padding: 30px 28px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65), 0 0 40px rgba(56, 232, 255, 0.16);
}

.victory-card {
  border-color: rgba(255, 200, 69, 0.55);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65), 0 0 48px rgba(255, 200, 69, 0.22);
}

.modal-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--accent-cyan);
  margin-bottom: 6px;
}

.victory-card .modal-kicker {
  color: var(--accent-gold);
}

.modal-card h2 {
  font-size: 28px;
  font-weight: 900;
  margin-bottom: 10px;
}

.modal-stat,
.victory-stats {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 22px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.primary-btn {
  border: none;
  color: #050918;
  background: linear-gradient(90deg, var(--accent-cyan), #6ef3ff);
}

.victory-card .primary-btn {
  background: linear-gradient(90deg, var(--accent-gold), #ffe083);
}

.secondary-btn {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.ghost-btn {
  color: var(--text-muted);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover {
  filter: brightness(1.15);
}
