/* ═══════════════════════════════════════════════
   LUNAR DESCENT  —  Global Styles
   Font: Orbitron (display) + Share Tech Mono (data)
   Palette: deep-space black / neon cyan / amber
═══════════════════════════════════════════════ */

:root {
  --bg:       #03050f;
  --surface:  #080d1e;
  --border:   #1a2a4a;
  --cyan:     #00e5ff;
  --cyan-dim: #007a8a;
  --amber:    #ffb300;
  --red:      #ff3d3d;
  --green:    #00e676;
  --text:     #cce8ff;
  --text-dim: #4a6080;
  --font-hud: 'Share Tech Mono', monospace;
  --font-ui:  'Orbitron', sans-serif;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-hud);
}

/* ── SCREENS ─────────────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.screen.active { display: flex; }

/* ── STARFIELD BACKGROUND ────────────────────── */
.stars-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, #0b1535 0%, transparent 70%),
    var(--bg);
  overflow: hidden;
  z-index: 0;
}
.stars-bg::before,
.stars-bg::after {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, #fff 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 70%, #adf 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 60% 10%, #fff 0%, transparent 100%),
    radial-gradient(1px 1px at 80% 55%, #cef 0%, transparent 100%),
    radial-gradient(1px 1px at 45% 90%, #fff 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 5%  85%, #fff 0%, transparent 100%),
    radial-gradient(1px 1px at 92% 30%, #ddf 0%, transparent 100%),
    radial-gradient(1px 1px at 22% 45%, #fff 0%, transparent 100%),
    radial-gradient(1px 1px at 74% 78%, #aef 0%, transparent 100%),
    radial-gradient(1px 1px at 50% 50%, #fff 0%, transparent 100%);
  background-size: 250px 250px;
  animation: twinkle 4s ease-in-out infinite alternate;
}
.stars-bg::after {
  background-size: 400px 400px;
  animation-delay: 2s;
  opacity: .6;
}
@keyframes twinkle {
  from { opacity: .5; } to { opacity: 1; }
}

/* ── TITLE SCREEN ────────────────────────────── */
.title-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  align-items: center; gap: 12px;
  text-align: center;
  padding: 20px;
}

.title-glow {
  font-family: var(--font-ui);
  font-size: clamp(2.8rem, 10vw, 6rem);
  font-weight: 900;
  letter-spacing: .25em;
  color: var(--cyan);
  text-shadow:
    0 0 20px var(--cyan),
    0 0 60px var(--cyan-dim),
    0 0 120px #003040;
  animation: pulse-glow 3s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%,100% { text-shadow: 0 0 20px var(--cyan), 0 0 60px var(--cyan-dim); }
  50%      { text-shadow: 0 0 40px var(--cyan), 0 0 100px var(--cyan), 0 0 20px #fff; }
}

.title-main {
  font-family: var(--font-ui);
  font-size: clamp(1.2rem, 4vw, 2.2rem);
  font-weight: 700;
  letter-spacing: .4em;
  color: var(--text);
}

.title-sub {
  font-family: var(--font-hud);
  font-size: clamp(.7rem, 2vw, 1rem);
  letter-spacing: .3em;
  color: var(--amber);
  text-transform: uppercase;
  margin-bottom: 20px;
}

.title-buttons {
  display: flex; flex-direction: column; gap: 10px;
  width: min(320px, 90vw);
}

.title-level-select {
  display: flex; align-items: center; gap: 12px;
  margin-top: 10px;
}
.title-level-select .label {
  font-family: var(--font-ui);
  font-size: .65rem;
  letter-spacing: .15em;
  color: var(--text-dim);
}
.level-btns { display: flex; gap: 6px; }
.lvl-btn {
  width: 36px; height: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: .75rem;
  cursor: pointer;
  transition: all .2s;
}
.lvl-btn.active, .lvl-btn:hover {
  background: var(--cyan-dim);
  border-color: var(--cyan);
  color: #fff;
}

/* ── BUTTONS ─────────────────────────────────── */
.btn-primary {
  padding: 14px 28px;
  background: var(--cyan);
  border: none;
  border-radius: 4px;
  color: #000;
  font-family: var(--font-ui);
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .15em;
  cursor: pointer;
  transition: all .2s;
  box-shadow: 0 0 20px rgba(0,229,255,.4);
}
.btn-primary:hover {
  background: #fff;
  box-shadow: 0 0 40px rgba(0,229,255,.7);
  transform: translateY(-2px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  padding: 12px 24px;
  background: transparent;
  border: 1px solid var(--cyan-dim);
  border-radius: 4px;
  color: var(--cyan);
  font-family: var(--font-ui);
  font-size: .75rem;
  letter-spacing: .12em;
  cursor: pointer;
  transition: all .2s;
}
.btn-secondary:hover {
  background: rgba(0,229,255,.1);
  border-color: var(--cyan);
}

/* ── HOW-TO SCREEN ───────────────────────────── */
.howto-panel, .scores-panel {
  position: relative; z-index: 1;
  background: rgba(8,13,30,.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: clamp(20px, 4vw, 40px);
  max-width: 700px;
  width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
}
.howto-panel h2, .scores-panel h2 {
  font-family: var(--font-ui);
  letter-spacing: .2em;
  color: var(--cyan);
  margin-bottom: 20px;
  font-size: clamp(1.1rem, 3vw, 1.6rem);
}
.howto-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 500px) {
  .howto-cols { grid-template-columns: 1fr; }
}
.howto-col h3 {
  font-family: var(--font-ui);
  font-size: .8rem;
  letter-spacing: .15em;
  color: var(--amber);
  margin-bottom: 10px;
}
.key-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.key-table td { padding: 5px 6px; border-bottom: 1px solid var(--border); }
.key-table td:first-child { color: var(--cyan); white-space: nowrap; }
kbd {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  font-family: var(--font-hud);
  font-size: .75rem;
}
.howto-objectives { margin-bottom: 20px; }
.howto-objectives h3 {
  font-family: var(--font-ui);
  font-size: .8rem;
  letter-spacing: .15em;
  color: var(--amber);
  margin-bottom: 8px;
}
.howto-objectives ul { list-style: none; font-size: .85rem; line-height: 2; padding-left: 4px; }
.howto-objectives li::before { content: '› '; color: var(--cyan-dim); }
.hl-green { color: var(--green); }
.hl-yellow { color: var(--amber); }

/* ── SCORES SCREEN ───────────────────────────── */
.scores-panel { max-width: 500px; }
.scores-loading { color: var(--text-dim); text-align: center; padding: 20px; }
.score-row {
  display: grid;
  grid-template-columns: 2rem 1fr auto auto;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
  align-items: center;
}
.score-row .rank { color: var(--text-dim); font-size: .8rem; }
.score-row .sname { color: var(--text); font-family: var(--font-ui); font-size: .8rem; }
.score-row .slevel { color: var(--text-dim); font-size: .75rem; }
.score-row .spoints { color: var(--cyan); font-weight: bold; }
.score-row.gold   .rank { color: gold;   font-weight: bold; }
.score-row.silver .rank { color: silver; font-weight: bold; }
.score-row.bronze .rank { color: #cd7f32; font-weight: bold; }

/* ── GAME SCREEN ─────────────────────────────── */
#screen-game { background: #000; }
#game-canvas {
  display: block;
  width: 100%; height: 100%;
  image-rendering: crisp-edges;
}

/* ── HUD ─────────────────────────────────────── */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  background: rgba(3,5,15,.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(4px);
  z-index: 20;
  flex-wrap: wrap;
}
.hud-block { display: flex; flex-direction: column; align-items: center; min-width: 48px; }
.hud-label {
  font-family: var(--font-ui);
  font-size: .48rem;
  letter-spacing: .12em;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.hud-value {
  font-family: var(--font-hud);
  font-size: clamp(.75rem, 2.5vw, 1rem);
  color: var(--cyan);
}
.hud-value.warn { color: var(--amber); }
.hud-value.danger { color: var(--red); animation: blink .4s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

.fuel-bar-wrap {
  width: 60px; height: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.fuel-bar {
  height: 100%;
  width: 100%;
  background: var(--green);
  transition: width .1s, background .3s;
  border-radius: 2px;
}
.fuel-bar.warn { background: var(--amber); }
.fuel-bar.danger { background: var(--red); }

.hud-pause { margin-left: auto; }
#btn-pause {
  background: none; border: 1px solid var(--border);
  border-radius: 4px; color: var(--text-dim);
  font-size: 1.1rem; width: 32px; height: 32px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
#btn-pause:hover { border-color: var(--cyan); color: var(--cyan); }

/* ── TOUCH CONTROLS ──────────────────────────── */
#touch-controls {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 10px 16px 20px;
  pointer-events: none;
  z-index: 20;
}
.touch-btn {
  pointer-events: all;
  width: clamp(64px, 18vw, 90px);
  height: clamp(64px, 18vw, 90px);
  background: rgba(0,229,255,.08);
  border: 2px solid rgba(0,229,255,.25);
  border-radius: 12px;
  color: var(--cyan);
  font-size: clamp(1.2rem, 5vw, 1.8rem);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  line-height: 1.1;
  transition: background .1s, border-color .1s;
  touch-action: none;
}
.touch-btn:active, .touch-btn.pressed {
  background: rgba(0,229,255,.22);
  border-color: var(--cyan);
}
.touch-thrust {
  width: clamp(72px, 20vw, 100px);
  height: clamp(72px, 20vw, 100px);
}
.touch-btn small { font-family: var(--font-ui); font-size: .5rem; letter-spacing: .1em; }

/* ── RESULT SCREEN ───────────────────────────── */
.result-panel {
  position: relative; z-index: 1;
  background: rgba(8,13,30,.95);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: clamp(24px, 5vw, 48px);
  max-width: 480px;
  width: 92vw;
  text-align: center;
  display: flex; flex-direction: column; gap: 14px;
  align-items: center;
}
#result-icon {
  font-size: 3rem;
  animation: pop .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes pop { from { transform: scale(0); opacity: 0; } }
#result-title {
  font-family: var(--font-ui);
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  letter-spacing: .15em;
}
#result-stats {
  font-size: .88rem;
  line-height: 2;
  color: var(--text-dim);
  text-align: left;
  width: 100%;
}
#result-stats .stat-row { display: flex; justify-content: space-between; }
#result-stats .stat-val { color: var(--cyan); }

#result-name-wrap { width: 100%; display: flex; flex-direction: column; gap: 8px; align-items: center; }
#result-name-wrap p { font-size: .85rem; color: var(--amber); }
#result-name-input {
  width: 100%; max-width: 280px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--cyan);
  border-radius: 4px;
  color: #fff;
  font-family: var(--font-ui);
  font-size: .9rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-align: center;
  outline: none;
}
#result-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ── PAUSE SCREEN ────────────────────────────── */
#screen-pause { background: rgba(0,0,0,.6); }
.pause-panel {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  background: rgba(8,13,30,.96);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 40px 60px;
  text-align: center;
}
.pause-panel h2 {
  font-family: var(--font-ui);
  font-size: 2rem;
  letter-spacing: .3em;
  color: var(--cyan);
}

/* ── FOOTER ──────────────────────────────────── */
.site-footer {
  position: absolute; bottom: 10px; left: 0; right: 0;
  text-align: center;
  font-size: .6rem;
  color: var(--text);
  letter-spacing: .1em;
  z-index: 1;
  opacity: .45;
}
.site-footer .heart { color: #e05; }

/* ── HIDE TOUCH ON NON-TOUCH DEVICES ─────────── */
@media (hover: hover) and (pointer: fine) {
  #touch-controls { display: none; }
}

/* ── SCROLLBAR ───────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
