:root {
  color-scheme: dark;
  --void: #030406;
  --ink: #101417;
  --ink-soft: rgba(10, 14, 17, 0.72);
  --panel: rgba(9, 13, 16, 0.68);
  --panel-strong: rgba(8, 11, 13, 0.88);
  --line: rgba(232, 239, 233, 0.18);
  --paper: #f3f0e8;
  --muted: #aab4ae;
  --gold: #ffd166;
  --amber: #f8a13f;
  --cyan: #4be4d3;
  --mint: #85e5a2;
  --coral: #ff7065;
  --rust: #c75e40;
  --shadow: rgba(0, 0, 0, 0.46);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--void);
}

body {
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--void);
  color: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="range"] {
  cursor: pointer;
}

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

#space-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 209, 102, 0.12), transparent 16rem),
    linear-gradient(180deg, #050607 0%, #020303 100%);
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px;
  pointer-events: none;
}

.topbar,
.workbench,
.signal-ticker,
.decoder-pill {
  pointer-events: auto;
}

.topbar {
  width: min(1180px, 100%);
  min-height: 58px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(3, 4, 6, 0.66);
  box-shadow: 0 18px 48px var(--shadow);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 209, 102, 0.55);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 46%, rgba(255, 209, 102, 0.88) 48%, transparent 52%),
    linear-gradient(0deg, transparent 46%, rgba(75, 228, 211, 0.55) 48%, transparent 52%);
  box-shadow: inset 0 0 0 5px rgba(255, 209, 102, 0.06), 0 0 22px rgba(255, 209, 102, 0.24);
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.05;
  letter-spacing: 0;
}

.brand strong {
  font-size: 0.95rem;
  text-transform: uppercase;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

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

.icon-button,
.primary-button {
  min-height: 44px;
  border: 1px solid rgba(255, 209, 102, 0.34);
  border-radius: 7px;
  color: var(--paper);
  background: rgba(255, 209, 102, 0.11);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.icon-button {
  width: 46px;
  padding: 0 8px;
  display: grid;
  place-items: center;
  position: relative;
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.icon-button.wide {
  width: 54px;
}

.icon-button.is-active {
  background: rgba(75, 228, 211, 0.16);
  border-color: rgba(75, 228, 211, 0.62);
}

.icon-button::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  color: var(--paper);
  font-size: 0.74rem;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
  white-space: nowrap;
}

.icon-button:hover::after,
.icon-button:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.primary-button {
  min-width: 112px;
  padding: 0 18px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.95), rgba(255, 112, 101, 0.88));
  color: #130d08;
}

.icon-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 209, 102, 0.72);
}

.dock-symbol,
.warp-symbol,
.audio-symbol {
  position: relative;
  width: 20px;
  height: 20px;
  display: block;
}

.dock-symbol {
  border: 2px solid currentColor;
  border-radius: 5px;
}

.dock-symbol::before,
.dock-symbol::after {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  height: 2px;
  background: currentColor;
}

.dock-symbol::before {
  top: 5px;
}

.dock-symbol::after {
  bottom: 5px;
}

.warp-symbol::before,
.warp-symbol::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 2px solid currentColor;
  border-radius: 50%;
  transform: rotate(-22deg) scaleX(1.28);
}

.warp-symbol::after {
  inset: 8px 2px;
  border-width: 1px;
  opacity: 0.78;
  transform: rotate(22deg) scaleX(1.7);
}

.audio-symbol::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 4px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 10px solid currentColor;
}

#audio-toggle.is-playing .audio-symbol::before {
  left: 4px;
  top: 3px;
  width: 4px;
  height: 14px;
  border: 0;
  background: currentColor;
  box-shadow: 8px 0 0 currentColor;
}

.decoder-pill {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 3;
  min-height: 58px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 8px 10px;
  border: 1px solid rgba(75, 228, 211, 0.44);
  border-radius: 999px;
  color: var(--paper);
  background: rgba(3, 4, 6, 0.68);
  box-shadow: 0 20px 54px var(--shadow);
  backdrop-filter: blur(18px);
  transform: translateX(-50%);
  transition: opacity 180ms ease, transform 180ms ease, border-color 180ms ease;
}

.decoder-pill:hover {
  border-color: rgba(255, 209, 102, 0.72);
  transform: translateX(-50%) translateY(-2px);
}

.decoder-pill-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 209, 102, 0.85) 0 3px, transparent 4px),
    conic-gradient(from 20deg, rgba(75, 228, 211, 0.14), rgba(255, 209, 102, 0.76), rgba(75, 228, 211, 0.14));
  box-shadow: inset 0 0 0 10px rgba(3, 4, 6, 0.78), 0 0 22px rgba(75, 228, 211, 0.24);
}

.decoder-pill strong,
.decoder-pill small {
  display: block;
  line-height: 1.05;
  text-align: left;
}

.decoder-pill strong {
  font-size: 0.9rem;
  text-transform: uppercase;
}

.decoder-pill small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.app-shell:not(.is-stargazing) .decoder-pill {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(18px) scale(0.96);
}

.workbench {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 4;
  width: min(1120px, calc(100vw - 48px));
  max-height: calc(100vh - 126px);
  margin: 0;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(260px, 310px);
  gap: 12px;
  align-items: end;
  opacity: 1;
  transform: translate3d(-50%, 0, 0);
  transition: opacity 220ms ease, transform 220ms ease;
}

.app-shell.is-stargazing .workbench {
  opacity: 0;
  pointer-events: none;
  transform: translate3d(-50%, calc(100% + 72px), 0) scale(0.98);
}

.dock-close {
  position: absolute;
  right: 0;
  top: -54px;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(243, 240, 232, 0.22);
  border-radius: 50%;
  background: rgba(3, 4, 6, 0.68);
  color: var(--paper);
  box-shadow: 0 18px 44px var(--shadow);
  backdrop-filter: blur(18px);
}

.dock-close span::before,
.dock-close span::after {
  content: "";
  position: absolute;
  left: 14px;
  top: 22px;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.dock-close span::before {
  transform: rotate(45deg);
}

.dock-close span::after {
  transform: rotate(-45deg);
}

.cipher-console,
.mission-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 24px 70px var(--shadow);
  backdrop-filter: blur(18px);
}

.cipher-console {
  max-height: min(56vh, 510px);
  overflow: auto;
  padding: 18px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: none;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.72rem;
  line-height: 1;
  letter-spacing: 0;
  text-wrap: balance;
}

.console-copy {
  max-width: 52ch;
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.console-copy cite {
  color: var(--paper);
  font-style: italic;
}

.cipher-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
  padding: 10px;
  border: 1px solid rgba(75, 228, 211, 0.28);
  border-radius: 7px;
  background: rgba(4, 10, 11, 0.68);
}

.cipher-strip span,
.cipher-strip code {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 5px;
  color: var(--paper);
  background: rgba(255, 255, 255, 0.06);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.cipher-strip span {
  color: var(--gold);
  background: rgba(255, 209, 102, 0.14);
}

.decoder-form label,
.panel-section label {
  display: block;
  margin: 0 0 8px;
  color: var(--paper);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

#key-input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(243, 240, 232, 0.22);
  border-radius: 7px;
  color: var(--paper);
  background: rgba(0, 0, 0, 0.34);
}

#key-input {
  padding: 0 14px;
  cursor: text;
}

#key-input::placeholder {
  color: rgba(170, 180, 174, 0.74);
}

select {
  padding: 0 12px;
}

.status-line {
  min-height: 22px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.status-line.is-good {
  color: var(--mint);
}

.status-line.is-wrong {
  color: var(--coral);
}

.secret-vault {
  margin-top: 12px;
  padding: 16px;
  border: 1px solid rgba(255, 209, 102, 0.25);
  border-radius: 7px;
  background:
    linear-gradient(90deg, rgba(255, 209, 102, 0.1), transparent),
    rgba(255, 255, 255, 0.045);
  transition: border-color 220ms ease, background 220ms ease, transform 220ms ease;
}

.secret-vault.is-locked p {
  filter: blur(4px);
  user-select: none;
}

.secret-vault.is-unlocked {
  border-color: rgba(133, 229, 162, 0.7);
  background:
    linear-gradient(90deg, rgba(133, 229, 162, 0.14), transparent),
    rgba(255, 255, 255, 0.055);
  transform: translateY(-2px);
}

.vault-label {
  display: block;
  margin-bottom: 6px;
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.secret-vault p {
  margin: 0;
  line-height: 1.55;
}

.secret-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  margin-top: 12px;
  padding: 0 14px;
  border: 1px solid rgba(75, 228, 211, 0.42);
  border-radius: 7px;
  color: #030406;
  background: linear-gradient(135deg, rgba(75, 228, 211, 0.96), rgba(133, 229, 162, 0.9));
  font-weight: 800;
  text-decoration: none;
}

.secret-link[hidden] {
  display: none;
}

.mission-panel {
  max-height: min(56vh, 510px);
  overflow: auto;
  padding: 18px;
}

.panel-section + .panel-section,
.planet-readout {
  margin-top: 18px;
}

.range-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

output {
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 800;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

.planet-readout {
  min-height: 96px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(75, 228, 211, 0.22);
  border-radius: 7px;
  background: rgba(4, 10, 11, 0.5);
}

.planet-readout strong {
  color: var(--cyan);
}

.planet-readout span {
  color: var(--muted);
  line-height: 1.45;
}

.signal-ticker {
  position: fixed;
  left: 50%;
  bottom: 94px;
  z-index: 2;
  width: min(1180px, calc(100vw - 48px));
  min-height: 40px;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(3, 4, 6, 0.56);
  color: var(--muted);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.75rem;
  backdrop-filter: blur(18px);
  transform: translateX(-50%);
  transition: opacity 180ms ease, transform 180ms ease;
}

.app-shell:not(.is-stargazing) .signal-ticker {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(12px);
}

.signal-ticker span::before {
  content: "";
  width: 6px;
  height: 6px;
  display: inline-block;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 12px rgba(133, 229, 162, 0.62);
  vertical-align: 1px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 860px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    min-height: 100vh;
    padding: 14px;
  }

  .topbar {
    position: relative;
    top: 0;
  }

  .workbench {
    width: calc(100vw - 28px);
    max-height: calc(100svh - 108px);
    bottom: 14px;
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: stretch;
    overflow: auto;
  }

  .cipher-console {
    max-height: none;
    padding: 16px;
  }

  h1 {
    max-width: none;
    font-size: 1.55rem;
  }

  .mission-panel {
    max-height: none;
    order: -1;
  }

  .console-copy {
    display: none;
  }

  .dock-close {
    right: 0;
    top: -50px;
  }

  .signal-ticker {
    width: calc(100vw - 28px);
    bottom: 88px;
  }
}

@media (max-width: 560px) {
  .brand small {
    display: none;
  }

  .topbar {
    gap: 10px;
  }

  .icon-button.wide {
    width: 50px;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  .primary-button {
    width: 100%;
  }
}

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