/* ============================================================
   THE ORION TRAIL — Styles
   Mobile-first. Glassmorphism + neon glow + motion.
   ============================================================ */
:root {
  --bg-0: #05060f;
  --bg-1: #0a0e1f;
  --bg-2: #111634;
  --glass: rgba(18, 24, 56, 0.55);
  --glass-brd: rgba(120, 160, 255, 0.22);
  --cyan: #5fd0ff;
  --cyan-d: #2bb8e6;
  --magenta: #ff5cc8;
  --gold: #ffd166;
  --green: #5ff2a0;
  --red: #ff5c6c;
  --amber: #ffb454;
  --txt: #e8eeff;
  --txt-dim: #9aa6c8;
  --txt-faint: #5c6488;
  --r: 16px;
  --r-sm: 10px;
  --shadow: 0 10px 40px rgba(0,0,0,0.55);
  --glow-cyan: 0 0 18px rgba(95, 208, 255, 0.55);
  --font-display: 'Orbitron', system-ui, sans-serif;
  --font-mono: 'Share Tech Mono', ui-monospace, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--txt);
  font-family: var(--font-mono);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  position: relative;
  background:
    radial-gradient(1200px 800px at 80% -10%, rgba(255,92,200,0.10), transparent 60%),
    radial-gradient(900px 700px at 0% 110%, rgba(95,208,255,0.12), transparent 60%),
    linear-gradient(180deg, #05060f 0%, #080b1c 60%, #05060f 100%);
}

#stars {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; display: block;
}

#vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(120% 120% at 50% 40%, transparent 55%, rgba(0,0,0,0.55) 100%);
}

#app {
  position: relative; z-index: 2;
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- SCREENS ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bot));
  overflow-y: auto;
  animation: screenIn 0.45s cubic-bezier(.2,.8,.2,1) both;
}
.screen[hidden] { display: none; }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

/* ---------- TITLE ---------- */
#screen-title { align-items: center; justify-content: center; text-align: center; gap: 22px; }

.kicker {
  font-family: var(--font-display);
  letter-spacing: 0.5em; font-size: 11px;
  color: var(--cyan); text-transform: uppercase;
  text-shadow: var(--glow-cyan);
  animation: pulseGlow 3s ease-in-out infinite;
}
@keyframes pulseGlow {
  0%,100% { text-shadow: 0 0 10px rgba(95,208,255,0.4); }
  50% { text-shadow: 0 0 22px rgba(95,208,255,0.8); }
}

.game-title {
  font-family: var(--font-display);
  font-weight: 900;
  line-height: 0.92;
  display: flex; flex-direction: column;
  gap: 2px;
}
.title-word { display: block; }
.title-word:first-child { font-size: 22px; letter-spacing: 0.3em; color: var(--txt-dim); }
.title-orion {
  font-size: clamp(54px, 22vw, 96px);
  background: linear-gradient(180deg, #fff 0%, var(--cyan) 50%, var(--magenta) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 24px rgba(95,208,255,0.5));
  letter-spacing: 0.02em;
  animation: orionFloat 5s ease-in-out infinite;
}
.title-word:last-child {
  font-size: clamp(34px, 14vw, 60px);
  letter-spacing: 0.16em; color: var(--txt);
  text-shadow: 0 0 18px rgba(255,92,200,0.4);
}
@keyframes orionFloat {
  0%,100% { transform: translateY(0); filter: drop-shadow(0 0 18px rgba(95,208,255,0.45)); }
  50% { transform: translateY(-6px); filter: drop-shadow(0 8px 28px rgba(255,92,200,0.5)); }
}

.subtitle {
  color: var(--txt-dim); font-size: 13px; line-height: 1.6;
  max-width: 320px; margin: 4px auto 0;
}

.title-buttons { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 300px; margin-top: 8px; }

.audio-toggle { position: absolute; top: calc(12px + var(--safe-top)); right: 14px; }
.credits { position: absolute; bottom: calc(10px + var(--safe-bot)); left: 0; right: 0; font-size: 10px; color: var(--txt-faint); letter-spacing: 0.2em; text-transform: uppercase; }

/* ---------- PANELS ---------- */
.panel {
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: var(--r);
  padding: 22px 18px;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: var(--shadow);
  width: 100%;
  margin: auto 0;
}
.panel.scroll { overflow-y: auto; max-height: 100%; }
.panel h2 {
  font-family: var(--font-display); font-weight: 700;
  font-size: 22px; letter-spacing: 0.04em;
  margin-bottom: 14px; color: var(--cyan);
  text-shadow: 0 0 14px rgba(95,208,255,0.35);
}
.panel h2 i { font-style: italic; color: var(--magenta); }
.lead { color: var(--txt-dim); font-size: 13px; line-height: 1.6; margin-bottom: 18px; }
.lead b, .credit-display { color: var(--gold); }
.label { display:block; font-size: 11px; color: var(--txt-faint); letter-spacing: 0.2em; text-transform: uppercase; margin: 18px 0 8px; }

/* ---------- BUTTONS ---------- */
.btn {
  font-family: var(--font-display); font-weight: 700;
  font-size: 14px; letter-spacing: 0.06em;
  border: 1px solid var(--glass-brd);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  background: rgba(20, 28, 64, 0.6);
  color: var(--txt);
  cursor: pointer;
  position: relative;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
  min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, rgba(43,184,230,0.9), rgba(95,208,255,0.85));
  color: #03101e; border-color: rgba(95,208,255,0.6);
  box-shadow: 0 0 18px rgba(95,208,255,0.4), inset 0 1px 0 rgba(255,255,255,0.3);
}
.btn-primary:active { box-shadow: 0 0 26px rgba(95,208,255,0.6); }
.btn-ghost { background: rgba(20,28,64,0.4); color: var(--txt); }
.btn-ghost:active { background: rgba(40,54,110,0.6); }
.btn-danger { background: rgba(255,92,108,0.16); color: var(--red); border-color: rgba(255,92,108,0.4); }
.btn-tall { min-height: 60px; font-size: 16px; }
.btn[disabled] { opacity: 0.4; filter: grayscale(0.5); }
.btn::after {
  content: ''; position: absolute; inset: 0; border-radius: var(--r-sm);
  background: radial-gradient(circle at var(--mx,50%) var(--my,50%), rgba(255,255,255,0.18), transparent 40%);
  opacity: 0; transition: opacity .2s;
  pointer-events: none;
}
.btn:hover::after { opacity: 1; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--glass); border: 1px solid var(--glass-brd);
  color: var(--txt); font-size: 18px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform .12s;
}
.icon-btn:active { transform: scale(0.92); }

/* ---------- HOW TO ---------- */
.howto-list { list-style: none; display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.howto-list li {
  font-size: 13px; line-height: 1.55; color: var(--txt-dim);
  padding-left: 18px; position: relative;
}
.howto-list li::before { content: '▹'; position: absolute; left: 0; color: var(--cyan); }
.howto-list b { color: var(--gold); }

/* ---------- OUTFITTING ---------- */
.outfit-grid { display: flex; flex-direction: column; gap: 10px; }
.outfit-row {
  display: flex; align-items: center; gap: 12px;
  background: rgba(10,16,40,0.5); border: 1px solid var(--glass-brd);
  border-radius: var(--r-sm); padding: 12px;
}
.outfit-icon { font-size: 22px; width: 30px; text-align: center; }
.outfit-info { flex: 1; }
.outfit-name { font-family: var(--font-display); font-size: 13px; letter-spacing: 0.04em; }
.outfit-cost { font-size: 11px; color: var(--txt-faint); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: 34px; height: 34px; border-radius: 8px;
  background: rgba(40,54,110,0.6); border: 1px solid var(--glass-brd);
  color: var(--cyan); font-size: 18px; font-weight: 700; cursor: pointer;
}
.stepper button:active { transform: scale(0.9); }
.stepper .val { min-width: 40px; text-align: center; font-family: var(--font-display); color: var(--gold); }

.outfit-summary { margin-top: 16px; border-top: 1px solid var(--glass-brd); padding-top: 12px; }
.sum-row { display: flex; justify-content: space-between; font-size: 13px; }
.sum-row b { color: var(--gold); font-family: var(--font-display); }

.profiles { display: flex; flex-direction: column; gap: 8px; }
.profile-card {
  border: 1px solid var(--glass-brd); border-radius: var(--r-sm);
  padding: 12px; background: rgba(10,16,40,0.4); cursor: pointer;
  transition: border-color .2s, background .2s;
}
.profile-card.active { border-color: var(--cyan); background: rgba(43,184,230,0.12); box-shadow: var(--glow-cyan); }
.profile-card .pname { font-family: var(--font-display); font-size: 13px; color: var(--cyan); }
.profile-card .pdesc { font-size: 11px; color: var(--txt-dim); margin-top: 4px; line-height: 1.4; }

.outfit-actions { display: flex; gap: 10px; margin-top: 22px; }
.outfit-actions .btn { width: auto; flex: 1; }

/* ---------- JOURNEY HUD ---------- */
#screen-journey { gap: 12px; padding-top: calc(10px + var(--safe-top)); }
.hud-top { display: flex; justify-content: space-between; align-items: center; }
.day-pill {
  display: flex; align-items: baseline; gap: 6px;
  background: var(--glass); border: 1px solid var(--glass-brd);
  border-radius: 999px; padding: 6px 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.day-label { font-size: 10px; letter-spacing: 0.2em; color: var(--txt-faint); }
.day-num { font-family: var(--font-display); font-weight: 900; font-size: 20px; color: var(--cyan); }
.day-total { font-size: 12px; color: var(--txt-dim); }

.route-wrap { margin: 4px 0 2px; }
.route-track {
  position: relative; height: 10px; border-radius: 999px;
  background: rgba(10,16,40,0.7); border: 1px solid var(--glass-brd);
  overflow: visible;
}
.route-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  border-radius: 999px; transition: width .8s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 0 12px rgba(95,208,255,0.5);
}
.route-ship {
  position: absolute; top: 50%; left: 0%; transform: translate(-50%,-50%);
  font-size: 18px; transition: left .8s cubic-bezier(.2,.8,.2,1);
  filter: drop-shadow(0 0 8px rgba(95,208,255,0.7));
}
.route-end { position: absolute; right: -2px; top: 50%; transform: translateY(-50%); color: var(--gold); font-size: 16px; filter: drop-shadow(0 0 8px var(--gold)); }
.route-labels { display: flex; justify-content: space-between; font-size: 9px; color: var(--txt-faint); letter-spacing: 0.1em; margin-top: 6px; text-transform: uppercase; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat {
  background: var(--glass); border: 1px solid var(--glass-brd);
  border-radius: var(--r-sm); padding: 10px 12px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.stat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.stat-name { font-size: 10px; letter-spacing: 0.12em; color: var(--txt-faint); text-transform: uppercase; }
.stat-ic { font-size: 14px; }
.stat-val { font-family: var(--font-display); font-size: 18px; color: var(--txt); }
.stat-val .max { font-size: 11px; color: var(--txt-faint); }
.bar { height: 6px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden; }
.bar > div { height: 100%; border-radius: 999px; transition: width .5s ease, background .3s ease; }
.bar.fuel > div { background: linear-gradient(90deg, var(--cyan), #bfeaff); }
.bar.food > div { background: linear-gradient(90deg, var(--green), #c4ffd9); }
.bar.hull > div { background: linear-gradient(90deg, var(--amber), var(--gold)); }
.bar.morale > div { background: linear-gradient(90deg, var(--magenta), #ffb0e6); }

.crew-strip {
  display: flex; gap: 6px; flex-wrap: wrap; min-height: 30px;
  padding: 8px; background: var(--glass); border: 1px solid var(--glass-brd);
  border-radius: var(--r-sm); align-items: center;
}
.crew-strip .label { margin: 0; }
.crew-av {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; background: rgba(43,184,230,0.15); border: 1px solid var(--glass-brd);
  transition: transform .2s, filter .3s;
}
.crew-av.sick { filter: grayscale(0.7) brightness(0.7); border-color: var(--amber); }
.crew-av.dead { filter: grayscale(1) brightness(0.4); opacity: 0.4; }

.journey-actions { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.action-row { display: flex; gap: 8px; }
.action-row .btn { width: auto; flex: 1; font-size: 12px; padding: 12px 8px; }

/* menu overlay */
.menu-overlay {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.menu-panel {
  background: var(--bg-1); border: 1px solid var(--glass-brd);
  border-radius: var(--r) var(--r) 0 0; padding: 20px;
  width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 10px;
  animation: slideUp .3s cubic-bezier(.2,.8,.2,1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.menu-panel h3 { font-family: var(--font-display); color: var(--cyan); letter-spacing: 0.1em; font-size: 14px; margin-bottom: 4px; }

/* ---------- MODALS ---------- */
.modal {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
  animation: fadeIn .25s ease;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--bg-1); border: 1px solid var(--glass-brd);
  border-radius: var(--r); padding: 22px 18px;
  width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow), 0 0 30px rgba(95,208,255,0.15);
  animation: modalIn .35s cubic-bezier(.2,.8,.2,1);
  text-align: center;
}
.modal-card.wide { max-width: 460px; }
@keyframes modalIn { from { opacity:0; transform: translateY(20px) scale(0.96); } to { opacity:1; transform:none; } }
.modal-icon { font-size: 40px; margin-bottom: 10px; filter: drop-shadow(0 0 12px rgba(95,208,255,0.5)); animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.modal-card h2 { font-family: var(--font-display); color: var(--cyan); font-size: 20px; margin-bottom: 10px; }
.modal-card p { color: var(--txt-dim); font-size: 13px; line-height: 1.6; margin-bottom: 16px; }

.event-choices { display: flex; flex-direction: column; gap: 10px; }
.event-choices .btn { text-align: left; justify-content: flex-start; font-size: 13px; white-space: normal; }
.event-choices .btn .hint { display:block; font-size: 11px; color: var(--txt-faint); font-family: var(--font-mono); letter-spacing: 0; margin-top: 2px; }

/* trade */
.trade-table { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.trade-row {
  display: flex; align-items: center; gap: 10px;
  background: rgba(10,16,40,0.5); border: 1px solid var(--glass-brd);
  border-radius: var(--r-sm); padding: 10px;
}
.trade-row .ti { font-size: 18px; width: 26px; text-align: center; }
.trade-row .tn { flex: 1; text-align: left; }
.trade-row .tn b { display:block; font-family: var(--font-display); font-size: 12px; }
.trade-row .tn span { font-size: 10px; color: var(--txt-faint); }
.trade-row .stepper button { width: 30px; height: 30px; font-size: 14px; }
.trade-balance { font-size: 13px; color: var(--txt-dim); margin-bottom: 14px; }
.trade-balance b { color: var(--gold); font-family: var(--font-display); }

/* combat */
.combat-stage { height: 90px; display:flex; align-items:center; justify-content:center; gap: 30px; margin-bottom: 10px; font-size: 40px; }
.combat-stage .ship { filter: drop-shadow(0 0 12px var(--cyan)); animation: bob 1.6s infinite; }
.combat-stage .enemy { filter: drop-shadow(0 0 12px var(--red)); animation: bob 1.8s infinite reverse; }
.combat-stage .vs { font-family: var(--font-display); color: var(--txt-faint); font-size: 14px; }
.combat-hp { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; text-align: left; }
.hp-row { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--txt-dim); }
.hp-row span { width: 48px; }
.hp-row .bar { flex: 1; }
#combat-hull { background: var(--gold); }
#combat-enemy { background: var(--red); }
.combat-actions { display: flex; flex-direction: column; gap: 8px; }
.combat-actions .btn { font-size: 13px; }
.combat-flash { animation: flash .3s ease; }
@keyframes flash { 0%{filter:brightness(3);} 100%{filter:brightness(1);} }

/* ---------- END ---------- */
#screen-end { align-items: center; justify-content: center; }
#screen-end .panel { max-width: 420px; text-align: center; }
.end-icon { font-size: 56px; margin-bottom: 12px; animation: bob 3s infinite; }
.end-stats { display: flex; flex-direction: column; gap: 6px; margin: 16px 0; text-align: left; }
.end-stats .er { display: flex; justify-content: space-between; font-size: 13px; color: var(--txt-dim); border-bottom: 1px dashed var(--glass-brd); padding: 4px 0; }
.end-stats .er b { color: var(--cyan); font-family: var(--font-display); }
.memorial { margin: 16px 0; text-align: left; }
.memorial h3 { font-family: var(--font-display); font-size: 13px; color: var(--red); letter-spacing: 0.1em; margin-bottom: 8px; }
.memorial ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.memorial li { font-size: 12px; color: var(--txt-dim); padding-left: 14px; position: relative; }
.memorial li::before { content: '✦'; position: absolute; left: 0; color: var(--red); font-size: 10px; }

/* ---------- TOAST ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bot)); transform: translateX(-50%);
  background: var(--bg-1); border: 1px solid var(--cyan); border-radius: 999px;
  padding: 10px 18px; font-size: 12px; color: var(--cyan); z-index: 40;
  box-shadow: var(--glow-cyan); max-width: 90vw; text-align: center;
  animation: toastIn .3s cubic-bezier(.2,.8,.2,1);
}
.toast[hidden] { display: none; }
@keyframes toastIn { from { opacity:0; transform: translate(-50%, 12px); } to { opacity:1; transform: translate(-50%, 0); } }
.toast.bad { border-color: var(--red); color: var(--red); box-shadow: 0 0 18px rgba(255,92,108,0.5); }
.toast.good { border-color: var(--green); color: var(--green); box-shadow: 0 0 18px rgba(95,242,160,0.5); }

/* shake */
.shake { animation: shake .4s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake {
  10%,90% { transform: translateX(-2px); }
  20%,80% { transform: translateX(3px); }
  30%,50%,70% { transform: translateX(-5px); }
  40%,60% { transform: translateX(5px); }
}

/* ---------- RESPONSIVE: bigger screens ---------- */
@media (min-width: 600px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .outfit-grid { grid-template-columns: 1fr 1fr; display: grid; gap: 10px; }
  .title-buttons { max-width: 360px; }
}

@media (min-width: 900px) {
  #app { max-width: 720px; }
  .game-title { gap: 6px; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
