/* Space Lander — Deep Space Vector Aesthetic & Phone-First UI */
@import url("../css/tokens.css");

:root {
  --space-bg-deep: #060A14;
  --space-bg-slate: #0F172A;
  --space-bg-card: rgba(15, 23, 42, 0.88);
  --space-border: rgba(56, 189, 248, 0.28);
  --space-border-glow: #38BDF8;
  --space-cyan: #38BDF8;
  --space-teal: #2DD4BF;
  --space-green: #22C55E;
  --space-amber: #F59E0B;
  --space-red: #EF4444;
  --space-text-main: #F8FAFC;
  --space-text-dim: #94A3B8;
  --space-font-mono: "JetBrains Mono", monospace;
  --space-font-sans: "Plus Jakarta Sans", sans-serif;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  background-color: var(--space-bg-deep);
  color: var(--space-text-main);
  font-family: var(--space-font-sans);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

* {
  box-sizing: border-box;
}

/* Hub navigation bar */
.hub-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--page-gutter);
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--space-border);
  font-size: var(--text-sm);
  z-index: 50;
  position: relative;
}

.hub-bar a {
  color: var(--space-cyan);
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
}

.hub-bar a:hover {
  text-decoration: underline;
}

.hub-bar span {
  color: var(--space-text-dim);
  font-size: var(--text-xs);
}

.hub-bar-tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Ad Rails */
.playyard-ad {
  padding: var(--space-xs) var(--page-gutter);
  text-align: center;
  background: var(--space-bg-deep);
}

.ad-well {
  display: block;
  margin: 0 auto;
}

/* Screen state toggles */
#screen-title, #screen-how, #screen-missions {
  display: none;
  padding: var(--space-lg) var(--page-gutter) var(--space-2xl);
}

body[data-screen="title"] #screen-title,
body[data-screen="how"] #screen-how,
body[data-screen="missions"] #screen-missions {
  display: block;
}

#screen-play {
  display: none;
}

body[data-screen="play"] #screen-play {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--space-bg-deep);
  z-index: 100;
}

body[data-screen="play"] .hub-bar,
body[data-screen="play"] .playyard-ad,
body[data-screen="play"] .content-below {
  display: none !important;
}

/* Hero card & Content containers */
.hero {
  max-width: 48rem;
  margin: 0 auto;
  padding: var(--space-lg);
  background: var(--space-bg-card);
  border: 1px solid var(--space-border);
  border-radius: 20px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.kicker {
  margin: 0 0 var(--space-xs);
  font-family: var(--space-font-mono);
  font-size: var(--text-xs);
  color: var(--space-cyan);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1, h2, h3 {
  font-family: var(--space-font-sans);
  font-weight: 800;
  margin: 0 0 var(--space-sm);
  line-height: 1.2;
}

h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  background: linear-gradient(135deg, #FFFFFF 30%, var(--space-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

h2 {
  font-size: clamp(1.4rem, 4vw, 2rem);
  color: #FFFFFF;
}

.lede {
  color: var(--space-text-dim);
  font-size: var(--text-md);
  margin-bottom: var(--space-md);
  line-height: 1.6;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  list-style: none;
  padding: 0;
  margin: var(--space-md) 0 var(--space-lg);
}

.facts li {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(56, 189, 248, 0.15);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: var(--text-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.facts li b {
  font-size: var(--text-xs);
  color: var(--space-cyan);
  font-family: var(--space-font-mono);
  text-transform: uppercase;
}

/* Buttons */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: var(--space-font-sans);
  font-size: var(--text-md);
  font-weight: 700;
  color: #FFFFFF;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid var(--space-border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.18s ease-out;
  min-height: 46px;
  touch-action: manipulation;
}

.btn:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: var(--space-cyan);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: linear-gradient(135deg, #0284C7, #0369A1);
  border-color: var(--space-cyan);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.35);
}

.btn--primary:hover {
  background: linear-gradient(135deg, #0EA5E9, #0284C7);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.55);
}

.btn--soft {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.2);
  color: var(--space-text-dim);
}

.btn--soft:hover {
  color: #FFFFFF;
  border-color: var(--space-border);
}

.btn--sm {
  padding: 6px 14px;
  font-size: var(--text-xs);
  min-height: 34px;
  border-radius: 8px;
  font-family: var(--space-font-mono);
}

/* Mission Selector Tray */
.mission-tray {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: var(--space-md);
}

.mission-card {
  background: var(--space-bg-card);
  border: 1px solid var(--space-border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s ease;
}

.mission-card.is-locked {
  opacity: 0.45;
  border-color: rgba(148, 163, 184, 0.15);
}

.mission-card.is-unlocked:hover {
  border-color: var(--space-cyan);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-num {
  font-family: var(--space-font-mono);
  font-size: var(--text-xs);
  color: var(--space-cyan);
  font-weight: 700;
}

.card-stars {
  font-size: 14px;
  color: #475569;
  letter-spacing: 2px;
}

.card-stars .filled {
  color: var(--space-amber);
}

.card-title {
  font-size: var(--text-md);
  margin: 0;
  color: #FFFFFF;
}

.card-desc {
  font-size: var(--text-xs);
  color: var(--space-text-dim);
  line-height: 1.4;
  margin: 0;
  flex-grow: 1;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--space-font-mono);
  font-size: 11px;
  color: var(--space-cyan);
  background: rgba(2, 6, 23, 0.6);
  padding: 6px 8px;
  border-radius: 6px;
}

.card-best {
  font-family: var(--space-font-mono);
  font-size: 11px;
  color: var(--space-green);
  text-align: right;
}

.btn--launch {
  width: 100%;
  margin-top: 4px;
}

/* In-Game Arena Layout */
.game-viewport {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000000;
}

#arena {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* In-Game HUD */
.in-game-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 10;
}

.telemetry-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 80%;
}

.telemetry-pill {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 8px;
  padding: 4px 8px;
  font-family: var(--space-font-mono);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  backdrop-filter: blur(8px);
}

.telemetry-pill .lbl {
  color: var(--space-text-dim);
  font-size: 9px;
  text-transform: uppercase;
}

.telemetry-pill .stat-val {
  font-weight: 700;
  color: #FFFFFF;
}

.stat-val.is-safe {
  color: var(--space-green) !important;
}

.stat-val.is-danger {
  color: var(--space-red) !important;
}

.fuel-gauge-pill {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 85px;
}

.fuel-bar-wrap {
  width: 100%;
  height: 4px;
  background: rgba(51, 65, 85, 0.6);
  border-radius: 2px;
  overflow: hidden;
}

.fuel-bar {
  height: 100%;
  background: var(--space-cyan);
  transition: width 0.1s linear;
}

.fuel-bar.is-low {
  background: var(--space-red);
}

.hud-actions {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

/* Touch Control Controls Area (Phone First) */
.touch-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 160px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
  z-index: 20;
}

.touch-cluster-rcs {
  display: flex;
  gap: 14px;
  pointer-events: auto;
}

.touch-cluster-thrust {
  pointer-events: auto;
}

.ctrl-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.75);
  border: 2px solid var(--space-border);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--space-font-mono);
  font-size: 10px;
  font-weight: 700;
  backdrop-filter: blur(10px);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.08s ease, background 0.08s ease, border-color 0.08s ease;
}

.ctrl-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.ctrl-btn:active, .ctrl-btn.active {
  transform: scale(0.92);
  background: rgba(56, 189, 248, 0.35);
  border-color: var(--space-cyan);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.6);
}

.ctrl-btn--thrust {
  width: 90px;
  height: 90px;
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(30, 20, 10, 0.75);
}

.ctrl-btn--thrust:active, .ctrl-btn--thrust.active {
  background: rgba(245, 158, 11, 0.4);
  border-color: var(--space-amber);
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.7);
}

/* Modal Overlay Sheet */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 20, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 150;
}

.sheet {
  background: var(--space-bg-card);
  border: 2px solid var(--space-border);
  border-radius: 24px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  text-align: center;
  animation: popIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popIn {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.sheet h2.is-success {
  color: var(--space-green);
  text-shadow: 0 0 16px rgba(34, 197, 94, 0.4);
}

.sheet h2.is-danger {
  color: var(--space-red);
  text-shadow: 0 0 16px rgba(239, 68, 68, 0.4);
}

.sheet-stats {
  background: rgba(2, 6, 23, 0.7);
  border: 1px solid rgba(56, 189, 248, 0.15);
  border-radius: 14px;
  padding: 12px 16px;
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--space-font-mono);
  font-size: var(--text-xs);
}

.stat-row .stat-lbl {
  color: var(--space-text-dim);
}

.stat-row .stat-val {
  color: #FFFFFF;
  font-weight: 700;
}

.stat-row.is-highlight .stat-val {
  color: var(--space-cyan);
  font-size: var(--text-sm);
}

/* How to Play Rules */
.how-steps {
  list-style: none;
  padding: 0;
  margin: var(--space-md) 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.how-steps li {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(56, 189, 248, 0.15);
  border-radius: 14px;
  padding: 14px;
}

.how-steps li b {
  display: block;
  color: var(--space-cyan);
  margin-bottom: 4px;
  font-size: var(--text-md);
}

/* Editorial / SEO section below */
.content-below {
  max-width: 48rem;
  margin: var(--space-2xl) auto var(--space-xl);
  padding: 0 var(--page-gutter);
  color: var(--space-text-dim);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.content-below h2 {
  font-size: var(--text-lg);
  color: #FFFFFF;
}

.content-below a {
  color: var(--space-cyan);
  text-decoration: none;
}

.content-below a:hover {
  text-decoration: underline;
}
