:root {
  --orange: #ff4c1d;
  --orange-hot: #ff6a33;
  --magenta: #9b0063;
  --pink: #e0217a;
  --paper: #f6e9e1;
  --muted: rgba(246, 233, 225, 0.48);
  --faint: rgba(246, 233, 225, 0.16);
  --ink: #05030a;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Menlo, monospace;
  --sans: "Helvetica Neue", "Arial Nova", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

html {
  background: var(--ink);
}

body {
  overflow: hidden;
  overscroll-behavior: none;
  background: radial-gradient(120% 80% at 50% 70%, #1a0714 0%, #06030a 58%, #020106 100%);
  color: var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#stage {
  position: fixed;
  touch-action: none;
  inset: 0;
  isolation: isolate;
  overflow: hidden;
}

#gl {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transform: scale(1.012);
  transition: opacity 1.6s ease, transform 2.8s cubic-bezier(0.2, 0.7, 0.2, 1);
}

body.ready #gl {
  opacity: 1;
  transform: scale(1);
}

.screen-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    linear-gradient(180deg, rgba(3, 2, 7, 0.66) 0%, rgba(3, 2, 7, 0.08) 19%, rgba(3, 2, 7, 0) 48%, rgba(3, 2, 7, 0.36) 72%, rgba(3, 2, 7, 0.86) 100%),
    radial-gradient(88% 74% at 50% 48%, rgba(3, 2, 7, 0) 42%, rgba(3, 2, 7, 0.35) 100%);
}

.screen-frame {
  position: absolute;
  inset: 18px;
  z-index: 3;
  pointer-events: none;
  border: 1px solid rgba(255, 106, 51, 0.07);
}

.screen-frame::before,
.screen-frame::after {
  content: "";
  position: absolute;
  width: 32px;
  height: 32px;
  border-color: rgba(255, 106, 51, 0.45);
  border-style: solid;
  border-width: 0;
}

.screen-frame::before {
  top: -1px;
  left: -1px;
  border-top-width: 1px;
  border-left-width: 1px;
}

.screen-frame::after {
  right: -1px;
  bottom: -1px;
  border-right-width: 1px;
  border-bottom-width: 1px;
}

/* ------------------------------------------------------------------ HUD */

.hud {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  transition: opacity 0.7s ease, transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.topbar {
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 30px 36px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 1.1s ease 0.2s, transform 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) 0.2s;
}

body.settled .brand {
  opacity: 1;
  transform: translateY(0);
}

.brand-mark {
  display: block;
  width: 42px;
  height: 28px;
  overflow: visible;
  filter: drop-shadow(0 0 14px rgba(255, 76, 29, 0.25));
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 13px;
  border-left: 1px solid rgba(255, 106, 51, 0.28);
}

.brand-title {
  font-size: 15px;
  text-shadow: 0 1px 12px rgba(3, 2, 8, 0.8);
  font-weight: 700;
  letter-spacing: 0.23em;
  line-height: 1;
  white-space: nowrap;
}

.brand-title b {
  font-weight: 700;
  background: linear-gradient(90deg, var(--orange), var(--magenta));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-sub {
  font-family: var(--mono);
  text-shadow: 0 1px 8px rgba(3, 2, 8, 0.9);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.31em;
  line-height: 1;
  color: var(--muted);
  white-space: nowrap;
}

.status {
  display: flex;
  text-shadow: 0 1px 10px rgba(3, 2, 8, 0.9);
  align-items: center;
  gap: 9px;
  padding-top: 6px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--muted);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 1.1s ease 0.35s, transform 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) 0.35s;
}

body.settled .status {
  opacity: 1;
  transform: translateY(0);
}

.live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 9px 1px rgba(255, 76, 29, 0.75);
  animation: livePulse 2.4s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

/* --------------------------------------------------------------- intro */

.intro-backdrop {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    radial-gradient(62% 72% at 31% 48%, rgba(4, 2, 9, 0.72) 0%, rgba(4, 2, 9, 0.34) 46%, rgba(4, 2, 9, 0) 72%),
    linear-gradient(90deg, rgba(4, 2, 9, 0.34), rgba(4, 2, 9, 0) 46%);
  opacity: 0;
  transition: opacity 1.2s ease;
}

body.ready .intro-backdrop {
  opacity: 1;
}

body.settled .intro-backdrop {
  opacity: 0;
  transition: opacity 1.4s ease;
}

body.hud-hidden .intro-backdrop {
  opacity: 0 !important;
}

.intro {
  top: 48%;
  left: 6.2vw;
  width: min(78vw, 980px);
  transform: translateY(-50%);
  opacity: 0;
}

body.ready .intro {
  opacity: 1;
  animation: introIn 1.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

body.settled .intro {
  opacity: 0;
  transform: translateY(calc(-50% - 18px));
  transition: opacity 1.4s ease, transform 1.8s cubic-bezier(0.2, 0.7, 0.2, 1);
  animation: none;
}

@keyframes introIn {
  from {
    opacity: 0;
    transform: translateY(calc(-50% + 26px));
    filter: blur(10px);
  }
  to {
    opacity: 1;
    transform: translateY(-50%);
    filter: blur(0);
  }
}

.intro-rule {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(100%, 620px);
  margin-bottom: 30px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.28em;
  color: rgba(246, 233, 225, 0.58);
  white-space: nowrap;
}

.intro-rule i {
  display: block;
  width: 46px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--orange));
}

.intro-rule em {
  color: var(--orange);
  font-style: normal;
}

.intro-title {
  margin: 0;
  font-size: clamp(76px, 13.6vw, 212px);
  font-weight: 800;
  line-height: 0.74;
  letter-spacing: -0.045em;
  display: flex;
  flex-direction: column;
  text-transform: uppercase;
}

.word-solid {
  color: var(--paper);
  text-shadow: 0 2px 22px rgba(3, 2, 8, 0.55), 0 0 46px rgba(255, 118, 66, 0.16);
}

.word-grad {
  padding-right: 0.08em;
  background: linear-gradient(102deg, #ff6a33 0%, var(--orange) 34%, #d21b6b 66%, var(--magenta) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 10px 50px rgba(255, 76, 29, 0.12));
}

.intro-caption {
  margin: 34px 0 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  line-height: 1.9;
  color: var(--muted);
  max-width: min(540px, 100%);
  white-space: normal;
  overflow-wrap: break-word;
}

/* ----------------------------------------------------------- telemetry */

.telemetry {
  bottom: 34px;
  left: 36px;
  display: flex;
  align-items: flex-start;
  gap: clamp(22px, 3.4vw, 54px);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 1s ease 0.45s, transform 1s cubic-bezier(0.2, 0.7, 0.2, 1) 0.45s;
}

body.settled .telemetry {
  opacity: 1;
  transform: translateY(0);
}

.readout {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  column-gap: 7px;
  align-items: baseline;
  font-family: var(--mono);
}

.readout .k {
  grid-column: 1 / -1;
  text-shadow: 0 1px 8px rgba(3, 2, 8, 0.9);
  margin-bottom: 7px;
  font-size: 8px;
  letter-spacing: 0.25em;
  color: rgba(246, 233, 225, 0.60);
}

.readout .v {
  font-size: 15px;
  text-shadow: 0 1px 10px rgba(3, 2, 8, 0.85);
  letter-spacing: 0.08em;
  color: var(--paper);
  font-variant-numeric: tabular-nums;
}

.readout .u {
  font-size: 8px;
  text-shadow: 0 1px 8px rgba(3, 2, 8, 0.9);
  letter-spacing: 0.14em;
  color: rgba(246, 233, 225, 0.46);
}

.slash {
  padding: 0 3px;
  color: var(--orange);
}

.bar {
  position: absolute;
  bottom: -12px;
  left: 0;
  width: min(46vw, 340px);
  height: 2px;
  background: rgba(246, 233, 225, 0.18);
  overflow: hidden;
}

.bar i {
  display: block;
  width: 30%;
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--pink), var(--magenta));
  box-shadow: 0 0 12px rgba(255, 76, 29, 0.6);
  transform-origin: left center;
  transition: width 0.35s ease;
}

/* --------------------------------------------------------------- hints */

.touch-only {
  display: none;
}

.hints {
  right: 36px;
  text-shadow: 0 1px 10px rgba(3, 2, 8, 0.9);
  bottom: 36px;
  display: flex;
  gap: 22px;
  align-items: center;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.2em;
  color: rgba(246, 233, 225, 0.46);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 1s ease 0.6s, transform 1s cubic-bezier(0.2, 0.7, 0.2, 1) 0.6s;
}

body.settled .hints {
  opacity: 1;
  transform: translateY(0);
}

kbd {
  display: inline-block;
  padding: 4px 6px 3px;
  margin-right: 6px;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: rgba(246, 233, 225, 0.66);
  border: 1px solid rgba(246, 233, 225, 0.16);
  border-radius: 2px;
  background: rgba(246, 233, 225, 0.03);
}

body.hud-hidden .hud {
  opacity: 0 !important;
  transition: opacity 0.5s ease;
}

/* ------------------------------------------------------------ fallback */

.fallback {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(70% 60% at 50% 42%, rgba(155, 0, 99, 0.24), transparent 68%),
    #05030a;
}

.fallback[hidden] {
  display: none;
}

.fallback-inner {
  max-width: 560px;
  text-align: center;
}

.fallback-mark {
  width: 92px;
  height: 62px;
  margin: 0 auto 26px;
}

.fallback-inner h2 {
  margin: 0 0 14px;
  font-size: clamp(20px, 3vw, 30px);
  font-weight: 700;
  letter-spacing: 0.18em;
}

.fallback-inner p {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.8;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* --------------------------------------------------------------- small */

@media (max-width: 760px) {
  .topbar {
    padding: 22px 22px;
  }

  .brand-mark {
    width: 34px;
    height: 23px;
  }

  .brand-title {
    font-size: 12px;
  }

  .brand-sub {
    font-size: 7px;
  }

  .status {
    font-size: 8px;
  }

  .intro {
    top: 44%;
    left: 7vw;
    width: 86vw;
  }

  .intro-rule {
    margin-bottom: 22px;
    font-size: 8px;
  }

  .intro-title {
    font-size: clamp(58px, 17.5vw, 124px);
  }

  .intro-caption {
    margin-top: 24px;
    font-size: 8px;
    letter-spacing: 0.12em;
    line-height: 2;
    max-width: 90%;
    color: rgba(246, 233, 225, 0.62);
  }

  .telemetry {
    bottom: 26px;
    left: 22px;
    gap: 22px;
  }

  .telemetry .readout:nth-child(2) {
    display: none;
  }

  .bar {
    width: 42vw;
  }

  .hints {
    right: 22px;
    bottom: 28px;
    gap: 12px;
    font-size: 7px;
  }

  .hints span:nth-child(2) {
    display: none;
  }

  .screen-frame {
    inset: 10px;
  }
}

@media (pointer: coarse) {
  .hints > span:not(.touch-only) {
    display: none;
  }

  .hints .touch-only {
    display: inline;
  }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot {
    animation: none;
    opacity: 0.8;
  }

  #gl {
    transition-duration: 0.01ms;
  }

  body.ready .intro {
    animation-duration: 0.01ms;
  }
}
