/* Last Jump — neon geometric portrait UI */
:root {
  --bg: #050510;
  --bg-panel: #0a0a1a;
  --cyan: #00e5ff;
  --cyan-dim: #00a8b8;
  --magenta: #ff2bd6;
  --orange: #ff8c2a;
  --green: #3dff8a;
  --red: #ff4466;
  --text: #e8f0ff;
  --text-dim: #8890b0;
  --border: #1a2040;
  --glow-cyan: 0 0 8px rgba(0, 229, 255, 0.55), 0 0 20px rgba(0, 229, 255, 0.2);
  --glow-magenta: 0 0 8px rgba(255, 43, 214, 0.55);
  --glow-orange: 0 0 8px rgba(255, 140, 42, 0.55);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-display: "Orbitron", system-ui, sans-serif;
  --font-ui: "Rajdhani", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app {
  width: 100%;
  max-width: 480px;
  height: 100%;
  max-height: 100vh; max-height: 100dvh;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex-direction: column;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  z-index: 1;
}
.screen.active { display: flex; }

/* ——— Title ——— */
#screen-title {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #12123a 0%, var(--bg) 70%);
}
.title-content {
  text-align: center;
  padding: 2rem 1.5rem;
  z-index: 2;
}
.title-eyebrow {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.35em;
  color: var(--cyan-dim);
  margin-bottom: 0.75rem;
}
.title-logo {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 12vw, 3.4rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
  margin-bottom: 0.6rem;
}
.title-tagline {
  color: var(--text-dim);
  font-size: 1.05rem;
  margin-bottom: 2rem;
}
.title-meta-hint {
  margin-top: 1.25rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* ——— Buttons ——— */
.btn-primary {
  display: block;
  width: min(260px, 80vw);
  margin: 0.6rem auto;
  padding: 0.9rem 1.2rem;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  border: 2px solid var(--cyan);
  background: rgba(0, 229, 255, 0.12);
  color: var(--cyan);
  border-radius: 6px;
  cursor: pointer;
  box-shadow: var(--glow-cyan);
  transition: transform 0.1s, background 0.15s;
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary.neon-magenta {
  border-color: var(--magenta);
  color: var(--magenta);
  background: rgba(255, 43, 214, 0.12);
  box-shadow: var(--glow-magenta);
}
.btn-ghost {
  display: block;
  width: min(260px, 80vw);
  margin: 0.5rem auto;
  padding: 0.7rem;
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  cursor: pointer;
}
.btn-danger {
  display: block;
  width: 100%;
  margin: 1rem 0;
  padding: 0.75rem;
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  background: rgba(255, 68, 102, 0.15);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 6px;
  cursor: pointer;
}

/* ——— Settings / panels ——— */
#screen-settings, #screen-howto, #screen-salvage, #screen-jump, #screen-over {
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 16, 0.96);
  padding: 1rem;
  overflow-y: auto;
}
.panel-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 0 40px rgba(0, 229, 255, 0.08);
}
.panel-card h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin-bottom: 1rem;
  color: var(--cyan);
}
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 1.1rem;
}
.toggle-row input { width: 1.25rem; height: 1.25rem; accent-color: var(--cyan); }

/* ——— Run layout ——— */
#screen-run {
  position: relative;
  height: 100%;
}
#playfield-wrap {
  position: relative;
  flex: 1 1 52%;
  min-height: 0;
  background: #030308;
  overflow: hidden;
}
#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0.65rem;
  pointer-events: none;
  z-index: 5;
  background: linear-gradient(180deg, rgba(5,5,16,0.75) 0%, transparent 100%);
}
.hud-left, .hud-right { display: flex; gap: 0.75rem; align-items: center; }
.hud-stat {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
}
.hud-stat.scrap { color: var(--orange); text-shadow: var(--glow-orange); }
.hud-stat.hull { color: var(--cyan); }
.hud-stat.sector, .hud-stat.wave { color: var(--magenta); font-size: 0.8rem; }
.hud-icon { margin-right: 0.2rem; }


.speed-btn.run-menu-btn {
  min-width: auto;
  padding: 0 0.45rem;
  border-color: var(--cyan);
  color: var(--cyan);
  letter-spacing: 0.06em;
}
.speed-btn.run-menu-btn.exit {
  border-color: var(--magenta);
  color: var(--magenta);
}

#pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 16, 0.78);
  backdrop-filter: blur(2px);
}
#pause-overlay.hidden { display: none; }
.pause-card {
  text-align: center;
  padding: 1.5rem 1.25rem;
  background: rgba(10, 10, 30, 0.95);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: min(280px, 86%);
}
.pause-card h2 {
  font-family: var(--font-display);
  color: var(--cyan);
  letter-spacing: 0.2em;
  margin-bottom: 1.2rem;
  text-shadow: var(--glow-cyan);
}

/* ——— Ship Status overlay (mid-run) ——— */
#ship-status-overlay {
  position: absolute;
  inset: 0;
  z-index: 22;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 16, 0.82);
  backdrop-filter: blur(2px);
  padding: 0.75rem;
  box-sizing: border-box;
}
#ship-status-overlay.hidden { display: none; }
.ship-status-card {
  max-height: min(88dvh, 640px);
  display: flex;
  flex-direction: column;
  width: min(400px, 100%);
  margin: 0 auto;
  padding: 1.15rem 1rem 0.9rem;
  box-sizing: border-box;
}
.ship-status-card h2 {
  text-align: center;
  margin: 0 0 0.55rem;
  flex: 0 0 auto;
  font-size: 1.2rem;
}
.ship-status-scroll {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  text-align: left;
  padding: 0.1rem 0.1rem 0.45rem;
  margin: 0 0 0.55rem;
  flex: 1 1 auto;
  min-height: 0;
  font-size: 0.92rem;
  line-height: 1.4;
  color: var(--text-dim);
}
.ship-status-scroll h3 {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--cyan);
  margin: 0.85rem 0 0.35rem;
}
.ship-status-scroll h3:first-child { margin-top: 0.1rem; }
.ship-status-scroll .ss-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.22rem 0;
  border-bottom: 1px solid rgba(60, 70, 110, 0.35);
  color: var(--text);
  font-size: 0.9rem;
}
.ship-status-scroll .ss-row span:last-child {
  color: var(--text-dim);
  text-align: right;
  flex: 1 1 auto;
}
.ship-status-scroll .ss-row span:first-child {
  color: var(--text);
  font-weight: 600;
  flex: 0 0 auto;
  min-width: 5.5rem;
}
.ship-status-scroll .ss-failure {
  padding: 0.55rem 0.65rem;
  background: rgba(255, 43, 214, 0.1);
  border: 1px solid rgba(255, 43, 214, 0.4);
  border-radius: 6px;
  color: var(--text);
}
.ship-status-scroll .ss-failure .ss-fail-name {
  font-family: var(--font-display);
  color: var(--magenta);
  margin-bottom: 0.2rem;
  font-size: 0.95rem;
}
.ship-status-scroll .ss-nominal {
  color: var(--green);
  padding: 0.35rem 0;
}
.ship-status-card .btn-ghost {
  flex: 0 0 auto;
  width: 100%;
  margin-top: 0.15rem;
}

#speed-controls {
  position: absolute;
  bottom: 0.55rem;
  right: 0.4rem;
  left: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  z-index: 8;
  justify-content: flex-end;
  pointer-events: auto;
}
.speed-btn {
  min-width: 2.2rem;
  height: 1.8rem;
  padding: 0 0.4rem;
  font-family: var(--font-display);
  font-size: 0.65rem;
  background: rgba(10, 10, 30, 0.85);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 4px;
  cursor: pointer;
}
.speed-btn.active {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: var(--glow-cyan);
}
.mute-btn { font-size: 0.75rem; }

#failure-banner {
  position: absolute;
  top: 2.4rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 43, 214, 0.18);
  border: 1px solid var(--magenta);
  color: var(--magenta);
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 5;
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
}
#failure-banner.hidden { display: none; }

#wave-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255,255,255,0.08);
  z-index: 4;
}
#wave-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  transition: width 0.15s linear;
  box-shadow: 0 0 6px var(--cyan);
}

/* Status bar */
#status-bar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.status-left {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: center;
  font-size: 0.9rem;
  color: var(--text-dim);
  font-weight: 600;
}
.bot-focus {
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  border: 1px solid var(--border);
}
.bot-focus.hull {
  color: var(--green);
  border-color: rgba(61, 255, 138, 0.45);
}
.bot-focus.thrusters {
  color: var(--orange);
  border-color: rgba(255, 140, 42, 0.45);
}
.hud-stat.thrusters {
  color: var(--orange);
  text-shadow: var(--glow-orange);
}
.status-hull-bar {
  position: relative;
  height: 1.35rem;
  background: #12122a;
  border: 1px solid var(--cyan-dim);
  border-radius: 3px;
  overflow: hidden;
}
#hull-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--cyan-dim), var(--cyan));
  box-shadow: inset 0 0 8px rgba(0,229,255,0.4);
  transition: width 0.12s linear;
}
#hull-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.7rem;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}

/* Upgrade panel */
#upgrade-panel {
  flex: 0 0 auto;
  background: var(--bg-panel);
  padding: 0.4rem 0.5rem calc(0.55rem + var(--safe-bottom));
  max-height: 42%;
  overflow-y: auto;
}
.upgrade-header {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--magenta);
  text-align: center;
  padding: 0.35rem;
  margin-bottom: 0.35rem;
  background: rgba(255, 43, 214, 0.1);
  border: 1px solid rgba(255, 43, 214, 0.35);
  border-radius: 4px;
}
#upgrade-grid, .meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}
.upgrade-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  height: 100%;
  gap: 0.15rem;
  padding: 0.55rem 0.5rem;
  background: rgba(8, 12, 28, 0.95);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-ui);
  transition: border-color 0.12s, box-shadow 0.12s, opacity 0.12s;
}
.upgrade-card:active { transform: scale(0.98); }
.upgrade-card.affordable {
  border-color: var(--cyan);
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.25);
}
.upgrade-card.unaffordable { opacity: 0.55; }
.up-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.up-value {
  font-size: 0.8rem;
  color: var(--text-dim);
}
.up-cost {
  margin-top: auto; /* pin buy row to bottom so short cards align with tall ones */
  padding: 0.25rem;
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--orange);
  background: rgba(255, 140, 42, 0.12);
  border-radius: 3px;
  border: 1px solid rgba(255, 140, 42, 0.35);
}

/* Jump interstitial */
.jump-card, .over-card, .salvage-card { text-align: center; }
.jump-eyebrow, .over-eyebrow {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  color: var(--green);
  margin-bottom: 0.5rem;
}
.over-eyebrow { color: var(--red); }
.failure-reveal {
  margin: 1.25rem 0;
  padding: 1rem;
  background: rgba(255, 43, 214, 0.1);
  border: 1px solid var(--magenta);
  border-radius: 8px;
}
.failure-icon { font-size: 2rem; margin-bottom: 0.35rem; }
.failure-name {
  font-family: var(--font-display);
  color: var(--magenta);
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}
.failure-desc { color: var(--text-dim); font-size: 1rem; }

.over-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 1rem 0;
  text-align: left;
}
.over-stats > div {
  background: rgba(0,0,0,0.35);
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.over-stats span { font-size: 0.75rem; color: var(--text-dim); }
.over-stats strong { font-family: var(--font-display); font-size: 1.05rem; color: var(--cyan); }
.over-card {
  max-width: 440px;
  max-height: min(92vh, 900px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.salvage-card {
  max-width: 440px;
  max-height: min(92vh, 900px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#screen-salvage .btn-ghost { margin-top: 0.25rem; }
.over-sector-times-block {
  text-align: left;
  background: rgba(0,0,0,0.35);
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin: 0 0 0.65rem;
}
.over-sector-times-block .over-block-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 0.2rem;
}
.over-sector-times-block strong {
  font-family: var(--font-display);
  font-size: 0.92rem;
  color: var(--cyan);
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}
.over-extras {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 0 0 0.75rem;
  letter-spacing: 0.02em;
}
.neon-text-orange { color: var(--orange) !important; }
.salvage-bank {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: var(--text-dim);
}
.salvage-bank strong { color: var(--orange); font-family: var(--font-display); }
.meta-grid { margin-bottom: 1rem; }
.meta-card .up-cost {
  color: var(--magenta);
  background: rgba(255, 43, 214, 0.12);
  border-color: rgba(255, 43, 214, 0.35);
}
.meta-card.affordable {
  border-color: var(--magenta);
  box-shadow: 0 0 6px rgba(255, 43, 214, 0.3);
}

@media (max-height: 700px) {
  .title-logo { font-size: 2.2rem; }
  #upgrade-panel { padding-bottom: 0.4rem; }
  .upgrade-card { padding: 0.4rem; }
  .up-name { font-size: 0.85rem; }
}

.title-version {
  margin-top: 0.75rem;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  color: var(--text-dim);
}
.hud-version {
  position: absolute;
  top: 0.4rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  color: rgba(136, 144, 176, 0.7);
  pointer-events: none;
}

.jump-bots-note {
  margin: 0.85rem 1rem 0.25rem;
  font-size: 0.85rem;
  color: var(--orange);
  text-align: center;
  line-height: 1.35;
}

.howto-card {
  max-height: min(90dvh, 900px);
  display: flex;
  flex-direction: column;
  width: min(400px, 100%);
  margin: 0 auto;
  padding: 1.25rem 1.1rem 1rem;
  box-sizing: border-box;
}
.howto-card h2 {
  text-align: center;
  margin: 0 0 0.65rem;
  flex: 0 0 auto;
}
.howto-scroll {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  text-align: left;
  padding: 0.15rem 0.15rem 0.5rem;
  margin: 0 0 0.65rem;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text-dim);
}
.howto-scroll h3 {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: var(--cyan);
  margin: 0.95rem 0 0.4rem;
  text-align: left;
}
.howto-scroll h3:first-child { margin-top: 0.15rem; }
.howto-scroll p { margin: 0 0 0.45rem; }
.howto-scroll ul {
  margin: 0 0 0.55rem;
  padding: 0 0 0 1.15rem;
}
.howto-scroll li { margin: 0.25rem 0; }
.howto-scroll strong { color: var(--text); }
.howto-scroll em { color: var(--magenta); font-style: normal; }

.howto-fig {
  display: block;
  margin: 0.6rem 0 0.9rem;
  padding: 0;
  width: 100%;
}
.howto-fig img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #030308;
  object-fit: contain;
}
.howto-fig figcaption {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.3;
}
#screen-howto .btn-ghost {
  flex: 0 0 auto;
  margin-top: 0.15rem;
}
