:root {
  --void: #070a14;
  --deep: #0d1226;
  --ion: #35e0d0;
  --plasma: #a06bff;
  --ember: #ff7a3d;
  --win: #34d399;
  --danger: #ff3b6b;
  --ink: #eef2f8;
  --muted: #8b97b4;
  --panel: #0b0f1e;

  /* Asset seam: app.js overwrites these at boot from its ASSETS map, so
     dropping raster art into /assets/ needs no CSS edits. Each one is a
     background layer, so a missing file simply falls back to the gradient
     underneath instead of showing a broken image. */
  --asset-rocket: url("/assets/rocket.svg");
  --asset-flame: url("/assets/flame.svg");
  --asset-explosion: url("/assets/explosion.svg");
  --asset-starfield: url("/assets/starfield.svg");
  --asset-nebula: url("/assets/nebula.svg");
  --asset-mark: url("/assets/nova-mark.svg");

  --stage-h: 340px;
}

/* G5: #toast and #modalOverlay carry the `hidden` attribute *and* a class
   that sets display, so without this override neither would ever hide. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background-color: var(--void);
  background-image:
    radial-gradient(circle at 50% -10%, rgba(53, 224, 208, 0.14), transparent 55%),
    radial-gradient(circle at 82% 12%, rgba(160, 107, 255, 0.14), transparent 50%),
    linear-gradient(170deg, rgba(13, 18, 38, 0.9), rgba(7, 10, 20, 0.96));
}

.layout {
  position: relative;
  z-index: 1;
  width: min(1120px, 96vw);
  margin: 1rem auto;
  padding: 1rem;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(13, 18, 38, 0.72), rgba(0, 0, 0, 0.5));
  border: 1px solid rgba(53, 224, 208, 0.22);
}

/* ---- ambience ---- */

.starfield { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }

.star-layer {
  position: absolute;
  inset: -20% -20%;
  background-image: var(--asset-starfield);
  background-repeat: repeat;
  background-size: 320px 320px;
  opacity: 0.35;
  animation: drift linear infinite;
}

.star-layer.far { opacity: 0.22; background-size: 220px 220px; animation-duration: 150s; }
.star-layer.near { opacity: 0.4; animation-duration: 70s; }

@keyframes drift {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(0, 320px, 0); }
}

/* ---- topbar ---- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.3rem 0 0.6rem;
  flex-wrap: wrap;
}

.logo-wrap { position: relative; display: flex; align-items: center; gap: 0.7rem; }

.nova-mark {
  display: inline-block;
  width: 46px;
  height: 46px;
  background: var(--asset-mark) center/contain no-repeat;
  filter: drop-shadow(0 0 10px rgba(53, 224, 208, 0.55));
}

.wordmark h1 {
  margin: 0;
  font-size: clamp(1.2rem, 3.4vw, 2rem);
  color: var(--ion);
  letter-spacing: 0.18em;
  text-shadow: 0 2px 0 #05070f, 0 0 20px rgba(53, 224, 208, 0.3);
}

.wordmark .tagline { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.76rem; letter-spacing: 0.04em; }

h2 { margin: 0 0 0.5rem; color: var(--ion); font-size: 1rem; }

.topbar-right { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.pill {
  border: 1px solid rgba(53, 224, 208, 0.35);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  background: rgba(0, 0, 0, 0.45);
  font-weight: 700;
}

.mode-pill { color: var(--plasma); font-size: 0.78rem; letter-spacing: 0.1em; }
.balance-pill { color: var(--ion); transition: transform 220ms ease; }
.balance-pill.credit { transform: scale(1.12); }

.demo-toggle { display: flex; align-items: center; gap: 0.35rem; color: var(--muted); font-size: 0.82rem; }
.demo-toggle input { accent-color: var(--ion); width: 1.05rem; height: 1.05rem; }

.ghost-btn {
  background: none;
  border: 1px solid rgba(160, 107, 255, 0.5);
  color: var(--plasma);
  padding: 0.3rem 0.7rem;
  font-size: 0.72rem;
  border-radius: 999px;
}

.sprinkle-zone { position: absolute; inset: -60% -40%; pointer-events: none; overflow: visible; }

.sprinkle-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, var(--ion) 45%, rgba(53, 224, 208, 0) 70%);
  animation: sprinkle-fly 900ms ease-out forwards;
}

@keyframes sprinkle-fly {
  0% { transform: translate(0, 0) scale(0.3); opacity: 0; }
  18% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; }
}

/* ---- stage ---- */

.stage {
  position: relative;
  margin-top: 0.4rem;
  border-radius: 18px;
  overflow: hidden;
  height: var(--stage-h);
  border: 2px solid rgba(53, 224, 208, 0.3);
  background:
    radial-gradient(circle at 20% 90%, rgba(160, 107, 255, 0.2), transparent 60%),
    linear-gradient(180deg, #0a0f22, #05070f);
  box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.75), 0 10px 30px rgba(0, 0, 0, 0.55);
}

#flightCanvas { display: block; width: 100%; height: 100%; }

.stage-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  pointer-events: none;
  text-align: center;
}

.mult-readout {
  font-size: clamp(2.6rem, 9vw, 5rem);
  line-height: 1;
  color: var(--ion);
  text-shadow: 0 0 34px rgba(53, 224, 208, 0.55), 0 3px 0 rgba(0, 0, 0, 0.6);
}

.mult-readout.danger { color: var(--danger); text-shadow: 0 0 34px rgba(255, 59, 107, 0.6); }
.mult-readout.win { color: var(--win); text-shadow: 0 0 34px rgba(52, 211, 153, 0.6); }
.mult-readout.pulse-win { animation: mult-pulse 620ms ease-out; }

@keyframes mult-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.16) translateY(-6px); }
  100% { transform: scale(1); }
}

.stage-status { color: var(--muted); font-size: 0.82rem; letter-spacing: 0.24em; }
.band-label { color: var(--plasma); font-size: 0.68rem; letter-spacing: 0.3em; }

.explosion-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: var(--asset-explosion) center/160px 160px no-repeat;
  opacity: 0;
}

.explosion-layer.burst { animation: burst 700ms ease-out 1; }

@keyframes burst {
  0% { opacity: 0; transform: scale(0.3); }
  25% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(1.6); }
}

.stage.flash-crash { animation: flash-crash 520ms ease-in-out 2; }

@keyframes flash-crash {
  0%, 100% { border-color: rgba(53, 224, 208, 0.3); box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.75); }
  50% { border-color: var(--danger); box-shadow: inset 0 0 70px rgba(255, 59, 107, 0.5), 0 0 30px rgba(255, 59, 107, 0.4); }
}

/* ---- HUD ---- */

.hud {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.8rem;
  align-items: center;
  padding: 0.7rem 0.9rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(53, 224, 208, 0.2);
}

.hud-label { display: block; color: var(--muted); font-size: 0.7rem; letter-spacing: 0.16em; }

.hud-mult {
  display: block;
  font-size: clamp(1.7rem, 5vw, 2.6rem);
  color: var(--ion);
  line-height: 1.05;
}

.hud-side { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.hud-side strong { display: block; margin-top: 0.2rem; color: var(--ion); font-size: 1rem; }

/* ---- controls ---- */

.controls {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(200px, 1.2fr) auto auto;
  gap: 0.6rem;
  align-items: stretch;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  cursor: pointer;
  color: #fff;
}

button:disabled { opacity: 0.42; cursor: not-allowed; }

.control-block { background: rgba(0, 0, 0, 0.45); border-radius: 10px; padding: 0.4rem 0.55rem; }
.control-block label { display: block; color: var(--muted); font-size: 0.74rem; }
.control-block select,
.control-block input[type="number"] {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0.45rem;
  color: var(--ink);
  background: #131a30;
}

.auto-block { display: flex; flex-direction: column; gap: 0.3rem; }
.auto-label { display: flex; align-items: center; gap: 0.35rem; }
.auto-label input { accent-color: var(--ion); width: 1.05rem; height: 1.05rem; }

.primary {
  background: linear-gradient(180deg, #7dfff0, var(--ion));
  color: #04231f;
  min-width: 148px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.collect { background: linear-gradient(180deg, #3ec98a, #14663f); min-width: 190px; }

/* ---- history ---- */

.history-wrap { margin-top: 0.8rem; }
.history-strip { display: flex; gap: 0.35rem; overflow-x: auto; padding: 0.4rem 0; }
.history-empty { color: var(--muted); font-size: 0.82rem; }

.history-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.76rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.history-chip .chip-tag {
  font-style: normal;
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
}

.history-chip.loss { background: rgba(255, 59, 107, 0.16); border-color: var(--danger); color: #ffc6d5; }
.history-chip.mid { background: rgba(160, 107, 255, 0.16); border-color: var(--plasma); color: #dcc9ff; }
.history-chip.win { background: rgba(52, 211, 153, 0.16); border-color: var(--win); color: #b9f5dc; }

/* ---- results / panels ---- */

.results {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.results div {
  background: linear-gradient(180deg, rgba(13, 18, 38, 0.85), rgba(0, 0, 0, 0.55));
  border: 1px solid rgba(53, 224, 208, 0.2);
  border-radius: 10px;
  padding: 0.55rem;
}

.results span { display: block; color: var(--muted); font-size: 0.74rem; }
.results strong { display: block; margin-top: 0.25rem; font-size: 0.92rem; color: var(--ion); overflow-wrap: anywhere; }

.verify-link {
  display: block;
  margin: 0.7rem auto 0;
  background: none;
  border: 1px solid rgba(53, 224, 208, 0.4);
  color: var(--ion);
  padding: 0.4rem 1rem;
  font-size: 0.78rem;
  border-radius: 8px;
}

.panels {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.7rem;
}

.panel {
  background: var(--panel);
  border-radius: 12px;
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-note { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.76rem; }
.table-scroll { max-height: 260px; overflow-y: auto; }
.panel table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.panel th, .panel td { text-align: left; padding: 0.25rem 0.4rem; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.panel th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--panel); }
.panel ul { margin: 0; padding-left: 1.1rem; color: #dbe4f0; }
.panel ul li { margin: 0.2rem 0; }

/* ---- toast / modal ---- */

.toast {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(11, 15, 30, 0.97);
  color: #e6fbf8;
  border: 1px solid rgba(53, 224, 208, 0.45);
  border-radius: 10px;
  padding: 0.6rem 1.1rem;
  z-index: 60;
  max-width: 90vw;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 12, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
  overflow: auto;
}

.modal-card {
  margin: auto;
  background: linear-gradient(180deg, #131a30, #070a14);
  border: 2px solid var(--ion);
  border-radius: 16px;
  padding: 1.3rem 1.5rem;
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

.modal-card h2 { margin-bottom: 0.4rem; }
.modal-card p { margin: 0.2rem 0 0.6rem; color: var(--muted); }

.verify-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 0.7rem;
  text-align: left;
  margin: 0 0 0.9rem;
  font-size: 0.8rem;
}

.verify-details dt { color: var(--muted); }
.verify-details dd { margin: 0; color: var(--ion); overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .controls { grid-template-columns: 1fr 1fr; }
  .primary, .collect, .rebet { min-width: 0; }
  .practice-row { grid-template-columns: 1fr; }
  .results { grid-template-columns: 1fr 1fr; }
  .panels { grid-template-columns: 1fr; }
  .hud { grid-template-columns: 1fr; }
}

/* ---- profit-practice presentation ---- */

.rebet { background: linear-gradient(180deg, #b79cff, var(--plasma)); color: #170b38; min-width: 132px; }

.practice-row { margin-top: 0.7rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.chip-block { background: rgba(0, 0, 0, 0.45); border-radius: 10px; padding: 0.45rem 0.55rem; }
.chip-row { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.35rem; }
.stake-chip, .auto-chip {
  padding: 0.38rem 0.65rem; border-radius: 999px; font-size: 0.76rem;
  background: #131a30; color: var(--ink); border: 1px solid rgba(255, 255, 255, 0.16);
}
.stake-chip.active, .auto-chip.active { border-color: var(--ion); color: var(--ion); box-shadow: 0 0 0 1px var(--ion); }
.stake-chip.anchor { border-color: var(--ember); color: #ffd9c4; font-weight: 900; }

.social-wrap { margin-top: 0.7rem; }
.social-list { display: flex; gap: 0.35rem; overflow-x: auto; padding: 0.35rem 0; }
.social-item {
  flex: 0 0 auto; border-radius: 999px; padding: 0.28rem 0.7rem; font-size: 0.76rem; font-weight: 700;
  background: rgba(52, 211, 153, 0.13); border: 1px solid rgba(52, 211, 153, 0.45); color: #b9f5dc;
}

.win-tier-banner {
  pointer-events: none; max-width: 94%; margin-top: 0.45rem; padding: 0.35rem 0.9rem; border-radius: 999px;
  font-weight: 900; letter-spacing: 0.08em; color: #04231f; background: linear-gradient(180deg, #7dfff0, var(--ion));
}
.win-tier-banner.tier-big { background: linear-gradient(180deg, #ffe9a8, #f2c94c); color: #3b2f06; }
.win-tier-banner.tier-mega { background: linear-gradient(180deg, #ffc4ec, #f06bd8); color: #3d0730; }
.win-tier-banner.tier-epic { background: linear-gradient(180deg, #fff3b0, #ff8a3d); color: #431407; }

.near-miss-banner {
  pointer-events: none; max-width: 94%; margin-top: 0.4rem; padding: 0.35rem 0.9rem; border-radius: 999px;
  font-weight: 900; letter-spacing: 0.05em; color: #2b1503;
  background: linear-gradient(180deg, #ffd9a0, var(--ember));
  animation: near-miss-pop 420ms ease-out;
}
@keyframes near-miss-pop { 0% { transform: scale(0.82); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }

.stage.tension { box-shadow: inset 0 0 90px rgba(255, 122, 61, 0.38), 0 0 34px rgba(255, 122, 61, 0.3); }
.stage.tension .mult-readout { animation: tension-pulse 480ms ease-in-out infinite alternate; }
@keyframes tension-pulse { from { transform: scale(1); } to { transform: scale(1.045); } }

/* The page is fully playable without motion: app.js drops the parallax, the
   particles and the shake when this query matches, and keeps drawing the
   trail and the number. */
@media (prefers-reduced-motion: reduce) {
  .star-layer { animation: none; }
  .sprinkle-icon,
  .explosion-layer.burst,
  .stage.flash-crash,
  .mult-readout.pulse-win { animation: none; }
  .balance-pill { transition: none; }
  .stage.tension .mult-readout, .near-miss-banner { animation: none; }
}
