:root {
  color-scheme: dark;
  --ink: #080a0b;
  --panel: rgba(8, 10, 11, 0.9);
  --panel-soft: rgba(8, 10, 11, 0.72);
  --line: rgba(255, 255, 255, 0.16);
  --line-strong: rgba(255, 255, 255, 0.3);
  --text: #f4f7f8;
  --muted: #9ca6aa;
  --cyan: #63efff;
  --yellow: #f5d94d;
  --red: #f34b45;
  --green: #62e6a7;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
output {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

button:active {
  transform: scale(0.97);
}

.app,
#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#scene {
  display: block;
  touch-action: none;
}

.topbar {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 20px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 10, 11, 0.82);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.brand img {
  width: 62px;
  height: 32px;
  object-fit: contain;
  object-position: left center;
  margin-right: 12px;
}

.brand span,
.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
  line-height: 1.1;
  text-transform: uppercase;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.1;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.quiet-button,
.close-button,
.hud-exit {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background-color 160ms ease, transform 140ms var(--ease-out);
}

.quiet-button:hover,
.close-button:hover,
.hud-exit:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
}

.builder-panel {
  position: fixed;
  z-index: 15;
  top: 96px;
  left: 24px;
  width: min(336px, calc(100vw - 48px));
  padding: 2px 0 0;
  transition: opacity 180ms var(--ease-out), transform 240ms var(--ease-out);
}

.app[data-mode="flight"] .builder-panel,
.app[data-mode="result"] .builder-panel,
.app[data-mode="flight"] .build-readout,
.app[data-mode="result"] .build-readout {
  pointer-events: none;
  opacity: 0;
  transform: translateX(-18px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.machine-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.machine-heading h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 0.95;
  text-transform: uppercase;
}

.machine-heading > span {
  flex: 0 0 auto;
  padding-bottom: 3px;
  color: var(--yellow);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.control-group {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.control-label {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.control-label output {
  color: var(--text);
}

.segment-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
}

.segment-control button {
  min-width: 0;
  height: 34px;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
  transition: color 160ms ease, background-color 160ms ease, transform 140ms var(--ease-out);
}

.segment-control button:hover {
  color: var(--text);
}

.segment-control button.active {
  background: var(--text);
  color: var(--ink);
}

.swatch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}

.swatch-row button {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: var(--swatch);
  cursor: pointer;
  transition: border-color 160ms ease, transform 140ms var(--ease-out);
}

.swatch-row button:hover,
.swatch-row button.active {
  border-color: #fff;
}

.swatch-row button.active {
  box-shadow: 0 0 0 3px rgba(99, 239, 255, 0.24);
}

.stats {
  padding: 14px 0 18px;
  border-top: 1px solid var(--line);
}

.stats > div {
  display: grid;
  grid-template-columns: 58px 1fr 26px;
  align-items: center;
  gap: 10px;
  min-height: 27px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.stats i,
.hud-energy i {
  display: block;
  height: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.15);
}

.stats b,
.hud-energy b {
  display: block;
  width: 50%;
  height: 100%;
  background: var(--cyan);
  transition: width 260ms var(--ease-out), background-color 160ms ease;
}

.stats output {
  color: var(--text);
  text-align: right;
}

.launch-button {
  width: 100%;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  border-radius: 5px;
  background: var(--yellow);
  color: #090a0b;
  cursor: pointer;
  text-align: left;
  transition: filter 160ms ease, transform 140ms var(--ease-out);
}

.launch-button:hover {
  filter: brightness(1.08);
}

.launch-button span,
.launch-button small {
  display: block;
}

.launch-button span {
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.launch-button small {
  max-width: 118px;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.25;
  text-align: right;
  text-transform: uppercase;
}

.build-readout {
  position: fixed;
  z-index: 10;
  right: 22px;
  bottom: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 11px;
  border-left: 2px solid var(--cyan);
  background: var(--panel-soft);
  backdrop-filter: blur(12px);
  font-size: 10px;
  text-transform: uppercase;
  transition: opacity 180ms var(--ease-out), transform 240ms var(--ease-out);
}

.build-readout span {
  color: var(--muted);
}

.race-hud {
  position: fixed;
  z-index: 14;
  top: 88px;
  left: 18px;
  right: 18px;
  display: grid;
  grid-template-columns: 90px minmax(180px, 1fr) 116px auto;
  align-items: stretch;
  gap: 6px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 180ms var(--ease-out), transform 240ms var(--ease-out);
}

.app[data-mode="flight"] .race-hud,
.app[data-mode="result"] .race-hud {
  opacity: 1;
  transform: translateY(0);
}

.hud-block,
.hud-energy {
  min-height: 54px;
  padding: 9px 11px;
  background: var(--panel-soft);
  backdrop-filter: blur(12px);
}

.hud-block span,
.hud-energy span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.hud-block strong {
  font-size: 18px;
}

.hud-energy {
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 10px;
}

.hud-energy span {
  margin: 0;
}

.hud-energy b {
  width: 100%;
  background: var(--green);
}

.hud-speed {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
}

.hud-speed span {
  grid-column: 1 / -1;
}

.hud-speed small {
  padding-bottom: 3px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
}

.hud-exit {
  pointer-events: auto;
}

.countdown {
  position: fixed;
  z-index: 16;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: var(--yellow);
  font-size: clamp(74px, 14vw, 180px);
  font-weight: 950;
  line-height: 1;
  text-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
}

.countdown.pulse {
  animation: countdown-pulse 480ms var(--ease-out) both;
}

@keyframes countdown-pulse {
  from { opacity: 0; transform: scale(0.94); }
  28% { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(1.04); }
}

.flight-actions {
  position: fixed;
  z-index: 17;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms var(--ease-out);
}

.app[data-mode="flight"] .flight-actions {
  pointer-events: auto;
  opacity: 1;
}

.boost-button {
  width: 86px;
  height: 86px;
  border: 1px solid rgba(245, 217, 77, 0.65);
  border-radius: 50%;
  background: rgba(8, 10, 11, 0.72);
  color: var(--yellow);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  backdrop-filter: blur(12px);
  transition: background-color 160ms ease, color 160ms ease, transform 140ms var(--ease-out);
}

.boost-button:hover,
.boost-button.active {
  background: var(--yellow);
  color: var(--ink);
}

.result-panel {
  position: fixed;
  z-index: 22;
  left: 50%;
  top: 50%;
  width: min(420px, calc(100vw - 32px));
  padding: 26px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: rgba(8, 10, 11, 0.94);
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.6);
  transform: translate(-50%, -50%);
  animation: panel-enter 240ms var(--ease-out) both;
}

@keyframes panel-enter {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.result-panel h2 {
  margin: 0 0 22px;
  font-size: 34px;
  text-transform: uppercase;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.result-grid > div {
  padding: 14px 10px;
  border-right: 1px solid var(--line);
}

.result-grid > div:last-child {
  border-right: 0;
}

.result-grid span,
.result-grid strong {
  display: block;
}

.result-grid span {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.result-grid strong {
  color: var(--yellow);
  font-size: 18px;
}

.result-actions,
.route-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.result-actions button,
.route-footer button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  transition: filter 160ms ease, transform 140ms var(--ease-out);
}

.result-actions .primary,
.route-footer .primary {
  border-color: transparent;
  background: var(--yellow);
  color: var(--ink);
}

.route-dialog {
  width: min(880px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #0b0e0f;
  color: var(--text);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.72);
}

.route-dialog[open] {
  animation: dialog-enter 260ms var(--ease-out) both;
}

.route-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
}

@keyframes dialog-enter {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.route-head {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 14, 15, 0.96);
  backdrop-filter: blur(16px);
}

.route-head h2 {
  margin: 0;
  font-size: clamp(28px, 5vw, 52px);
  line-height: 0.96;
  text-transform: uppercase;
}

.route-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.route-summary > div {
  padding: 18px 24px;
  border-right: 1px solid var(--line);
}

.route-summary > div:last-child {
  border-right: 0;
}

.route-summary span,
.route-summary strong {
  display: block;
}

.route-summary span {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.route-summary strong {
  font-size: 13px;
}

.release-steps {
  margin: 0;
  padding: 8px 24px;
  list-style: none;
}

.release-steps li {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 16px;
  min-height: 92px;
  border-bottom: 1px solid var(--line);
}

.release-steps li > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.release-steps li strong,
.release-steps li p {
  display: block;
  margin: 0;
}

.release-steps li strong {
  margin-bottom: 5px;
  font-size: 14px;
  text-transform: uppercase;
}

.release-steps li p {
  max-width: 560px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.release-steps li em {
  min-width: 64px;
  color: var(--muted);
  font-size: 9px;
  font-style: normal;
  font-weight: 900;
  text-align: right;
  text-transform: uppercase;
}

.release-steps li.done > span,
.release-steps li.done em {
  color: var(--green);
}

.release-steps li.active > span,
.release-steps li.active em {
  color: var(--yellow);
}

.route-footer {
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 24px;
}

.route-footer > span {
  color: var(--muted);
  font-size: 11px;
}

.loading-state,
.error-state {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  background: var(--ink);
  transition: opacity 320ms var(--ease-out), visibility 320ms;
}

.loading-state img {
  width: 126px;
  height: auto;
}

.loading-state span,
.error-state span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.loading-state.ready {
  visibility: hidden;
  opacity: 0;
}

.error-state strong {
  font-size: 20px;
}

@media (max-width: 760px) {
  .topbar {
    height: 64px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .brand img {
    width: 52px;
    height: 26px;
    margin-right: 8px;
  }

  .brand small {
    display: none;
  }

  .quiet-button {
    min-height: 34px;
    padding: 0 9px;
    font-size: 10px;
  }

  .builder-panel {
    top: auto;
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: 53vh;
    overflow: auto;
    padding: 16px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    background: rgba(8, 10, 11, 0.93);
    backdrop-filter: blur(18px);
  }

  .machine-heading {
    align-items: center;
    margin-bottom: 12px;
  }

  .machine-heading h1 {
    font-size: 26px;
  }

  .control-group {
    padding: 9px 0;
  }

  .control-label {
    margin-bottom: 7px;
  }

  .segment-control button {
    height: 30px;
  }

  .stats {
    padding: 9px 0 10px;
  }

  .stats > div {
    min-height: 22px;
  }

  .launch-button {
    min-height: 50px;
  }

  .build-readout {
    top: 76px;
    right: 12px;
    bottom: auto;
  }

  .race-hud {
    top: 74px;
    left: 8px;
    right: 8px;
    grid-template-columns: 58px 1fr 82px;
  }

  .race-hud .hud-exit {
    position: fixed;
    top: 138px;
    right: 8px;
    min-height: 30px;
    font-size: 9px;
  }

  .hud-block,
  .hud-energy {
    min-height: 48px;
    padding: 7px 8px;
  }

  .hud-energy {
    grid-template-columns: 38px 1fr;
    gap: 5px;
  }

  .hud-block strong {
    font-size: 14px;
  }

  .flight-actions {
    bottom: max(14px, env(safe-area-inset-bottom));
  }

  .boost-button {
    width: 72px;
    height: 72px;
  }

  .route-head,
  .route-summary > div,
  .release-steps,
  .route-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .route-summary {
    grid-template-columns: 1fr;
  }

  .route-summary > div {
    padding-top: 12px;
    padding-bottom: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .release-steps li {
    grid-template-columns: 30px 1fr;
    gap: 10px;
    padding: 13px 0;
  }

  .release-steps li em {
    grid-column: 2;
    text-align: left;
  }

  .route-footer {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-height: 720px) and (min-width: 761px) {
  .builder-panel {
    top: 82px;
    transform: scale(0.88);
    transform-origin: top left;
  }
}

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