* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --ink: #160b06;
  --blue-dark: #a04632;
  --blue: #d87d3a;
  --blue-light: #f0b35c;
  --teal: #6ccad0;
  --steel: #f29a63;
  --gold: #f6c35f;
  --orange: #e8743a;
  --red: #d9574c;
  --plum: #8f6db2;
  --lavender: #c7b5ff;
  --text: #f4d7ad;
  --muted: #b78367;
  --panel: rgba(7, 10, 18, 0.78);
  --panel-soft: rgba(9, 12, 22, 0.66);
  --line: rgba(246, 195, 95, 0.32);
  --active-series: var(--gold);
  --archive-width: 1180px;
  font-family: "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: #000;
  color: var(--blue-light);
}

button,
input {
  font: inherit;
  letter-spacing: inherit;
}

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  padding: 18px;
  position: relative;
}

.starfield {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(0, 0, 0, 0.36), rgba(0, 0, 0, 0.58)),
    url("./nebula.jpg") center / cover no-repeat;
  opacity: 0.72;
}

.archive-panel {
  width: min(100%, var(--archive-width));
  margin: 0 auto;
  position: relative;
  z-index: 1;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: var(--panel);
  box-shadow: inset 0 0 36px rgba(232, 116, 58, 0.18), 0 0 30px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.archive-top {
  min-height: 56px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(90deg, var(--red), var(--steel) 20%, var(--gold) 70%, var(--plum));
  color: var(--ink);
}

.archive-top p {
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: "Elms Sans", "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}

.archive-top > span,
.archive-top > time {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.archive-top > span:last-child,
.archive-top > time {
  justify-self: end;
}

.fleet-mark {
  width: min(180px, 22vw);
  height: 54px;
  display: grid;
  place-items: center;
  color: var(--ink);
  overflow: hidden;
}

.fleet-mark img {
  max-width: 100%;
  max-height: 54px;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 0 5px rgba(22, 11, 6, 0.24));
}

.app-nav {
  min-height: 44px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(246, 195, 95, 0.24);
  background: rgba(8, 6, 10, 0.68);
}

.nav-chip {
  border: 1px solid rgba(246, 195, 95, 0.46);
  background: rgba(246, 195, 95, 0.08);
  color: var(--gold);
  padding: 8px 14px;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-align: center;
  text-transform: uppercase;
}

.nav-chip[data-sync-state="syncing"] {
  border-color: rgba(108, 202, 208, 0.64);
  color: var(--teal);
  animation: pulse 1.2s ease-in-out infinite;
}

.nav-chip[data-sync-state="complete"] {
  border-color: rgba(108, 202, 208, 0.64);
  color: var(--teal);
}

.nav-chip[data-sync-state="warning"] {
  border-color: rgba(217, 87, 76, 0.68);
  color: var(--red);
}

.nav-sync-button {
  border: 1px solid rgba(108, 202, 208, 0.52);
  border-radius: 4px;
  background: rgba(108, 202, 208, 0.1);
  color: var(--teal);
  padding: 8px 14px;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-align: center;
  text-transform: uppercase;
}

.nav-sync-button:hover,
.nav-sync-button:focus-visible {
  border-color: var(--gold);
  color: var(--gold);
  outline: none;
}

.nav-sync-button:disabled {
  border-color: rgba(108, 202, 208, 0.24);
  color: rgba(108, 202, 208, 0.46);
  cursor: progress;
}

.randomizer-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(380px, 0.82fr);
  gap: 14px;
  padding: 14px;
  border-bottom: 1px solid rgba(246, 195, 95, 0.24);
}

.panel {
  border: 1px solid rgba(232, 116, 58, 0.34);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 16px;
}

.wheel-panel {
  display: grid;
  align-content: center;
  gap: 14px;
  min-height: 520px;
}

.panel-heading,
.filter-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-heading span,
.filter-heading span {
  flex: 1;
  height: 1px;
  background: rgba(246, 195, 95, 0.3);
}

.panel-heading h2,
.filter-heading h2,
.command-panel h2 {
  margin: 0;
  color: var(--blue);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}

.wheel-frame {
  position: relative;
  width: min(100%, 460px);
  aspect-ratio: 1;
  justify-self: center;
}

#zora-wheel {
  display: block;
  width: 100%;
  height: 100%;
}

.target-line {
  position: absolute;
  top: 4%;
  left: 50%;
  width: 2px;
  height: 14%;
  transform: translateX(-50%);
  background: var(--red);
  box-shadow: 0 0 18px rgba(217, 87, 76, 0.82);
}

.target-line::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 18px;
  height: 18px;
  transform: translateX(-50%) rotate(45deg);
  border-right: 2px solid var(--red);
  border-bottom: 2px solid var(--red);
}

.spin-orb {
  position: absolute;
  inset: 50% auto auto 50%;
  min-width: 132px;
  min-height: 132px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(246, 195, 95, 0.76);
  border-radius: 50%;
  background: rgba(7, 6, 12, 0.92);
  color: var(--gold);
  text-transform: uppercase;
  box-shadow: 0 0 0 10px rgba(246, 195, 95, 0.06), 0 24px 54px rgba(0, 0, 0, 0.46);
  transition: transform 180ms ease, border-color 180ms ease, color 180ms ease;
}

.spin-orb strong {
  font-size: 14px;
  letter-spacing: 0.08em;
}

.spin-orb:hover,
.spin-orb:focus-visible {
  color: var(--ink);
  border-color: var(--teal);
  background: var(--gold);
  transform: translate(-50%, -50%) scale(1.04);
  outline: none;
}

.spin-orb:disabled {
  cursor: progress;
  opacity: 0.78;
}

.play-mark {
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 13px solid currentColor;
}

.control-stack {
  min-width: 0;
  display: grid;
  gap: 14px;
}

.selector-panel {
  display: grid;
  gap: 14px;
  min-height: 360px;
}

.selector {
  min-height: 274px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--scan-color, var(--blue-light));
  transition: color 280ms ease;
}

.idle-state {
  width: min(100%, 520px);
  display: grid;
  justify-items: center;
  gap: 14px;
}

.micro-lines {
  width: 96px;
  display: grid;
  gap: 3px;
}

.micro-lines span {
  height: 1px;
  background: var(--blue-light);
  opacity: 0.6;
}

.micro-lines span + span {
  opacity: 0.25;
}

.micro-lines.reverse span {
  opacity: 0.25;
}

.micro-lines.reverse span + span {
  opacity: 0.6;
}

.eyebrow {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.32em;
  text-align: center;
  text-transform: uppercase;
}

.subcopy {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.34em;
  opacity: 0.58;
  text-align: center;
  text-transform: uppercase;
}

.result {
  display: none;
  width: 100%;
  text-align: center;
}

.selector.has-episode .idle-state {
  display: none;
}

.selector.has-episode .result {
  display: block;
}

.designation,
.numbers p {
  margin: 0;
  color: var(--blue-light);
  font-size: 14px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
}

#selected-series {
  margin: 8px 0;
  min-height: 64px;
  display: grid;
  place-items: center;
  font-size: 28px;
  line-height: 1.12;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-wrap: balance;
}

.divider {
  width: min(100%, 344px);
  max-width: 384px;
  margin: 14px auto 16px;
  display: grid;
  gap: 3px;
  color: currentColor;
}

.divider div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.divider span {
  height: 1px;
  flex: 1;
  background: currentColor;
}

.divider div:first-child span {
  opacity: 0.5;
}

.divider div:last-child span {
  opacity: 0.2;
}

.divider i,
.divider b {
  width: 6px;
  flex: 0 0 6px;
}

.divider i {
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.divider b {
  height: 1px;
}

.numbers {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 34px;
}

.numbers > div:not(.beads) {
  width: 136px;
  text-align: center;
}

.numbers strong {
  display: block;
  font-size: 62px;
  line-height: 1;
  letter-spacing: 0.05em;
}

.beads {
  display: grid;
  justify-items: center;
  align-items: center;
  gap: 8px;
  opacity: 0.35;
}

.beads span {
  width: 1px;
  height: 16px;
  background: currentColor;
}

.beads i,
.locked i,
.series-button i {
  border-radius: 50%;
}

.beads i,
.locked i {
  width: 6px;
  height: 6px;
  background: currentColor;
}

.locked {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  color: var(--teal);
  font-size: 10px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
}

.locked span {
  width: 32px;
  height: 1px;
  background: currentColor;
  opacity: 0.5;
}

.locked i {
  animation: pulse 1.5s ease-in-out infinite;
}

.selector.landed .locked {
  display: flex;
}

.search {
  width: min(100%, 512px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search input {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(246, 195, 95, 0.3);
  border-radius: 4px;
  color: var(--blue-light);
  caret-color: var(--blue);
  outline: none;
  padding: 10px 12px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.search input:focus {
  border-color: var(--gold);
}

.search-results {
  display: grid;
  gap: 1px;
  max-height: 170px;
  overflow: auto;
}

.search-hit {
  display: grid;
  grid-template-columns: 54px 76px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: rgba(7, 6, 12, 0.94);
  color: var(--gold);
  padding: 8px 12px;
  text-align: left;
  font-size: 14px;
}

.search-hit:hover,
.search-hit:focus-visible {
  opacity: 0.78;
  outline: none;
}

.search-hit.excluded {
  opacity: 0.62;
}

.search-hit .abbr {
  font-size: 18px;
  font-weight: 700;
}

.search-hit .code {
  color: var(--lavender);
}

.search-empty {
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.title-row {
  min-height: 112px;
  display: grid;
  grid-template-rows: 58px 24px;
  align-content: center;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}

.title-row a {
  margin: 0;
  color: var(--gold);
  min-height: 58px;
  max-height: 58px;
  display: -webkit-box;
  overflow: hidden;
  font-size: 24px;
  line-height: 1.18;
  letter-spacing: 0.08em;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.title-row a[href]:hover,
.title-row a[href]:focus-visible {
  opacity: 0.76;
  outline: none;
}

.title-row a[aria-disabled="true"] {
  cursor: default;
}

.episode-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  min-height: 24px;
  color: var(--blue-light);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-align: center;
  text-transform: uppercase;
}

.command-panel {
  min-height: 144px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.primary-button {
  position: relative;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: transparent;
  outline: none;
}

.primary-button::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--orange), var(--gold));
  filter: blur(6px);
  opacity: 0.4;
}

.primary-button span {
  position: relative;
  display: block;
  min-width: 238px;
  padding: 12px 38px;
  border-radius: inherit;
  background: var(--orange);
  color: var(--ink);
  box-shadow: 0 0 24px rgba(232, 116, 58, 0.28), inset 0 1px 0 rgba(246, 195, 95, 0.42);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.34em;
  text-transform: uppercase;
}

.primary-button.scanning span {
  background: var(--gold);
}

.primary-button:disabled span {
  background: #19100c;
  color: #60402f;
  box-shadow: none;
}

.reset-button {
  padding: 8px 24px;
  border: 1px solid rgba(246, 195, 95, 0.28);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.reset-button:hover,
.reset-button:focus-visible {
  color: var(--blue-light);
  border-color: var(--gold);
  outline: none;
}

.pool-count {
  margin: 0;
  color: var(--blue-light);
  font-size: 14px;
  line-height: 1.35;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}

.filters {
  margin: 0 14px 14px;
}

.filter-heading {
  margin-bottom: 12px;
}

.filter-heading button {
  border: 1px solid rgba(246, 195, 95, 0.28);
  border-radius: 4px;
  background: rgba(246, 195, 95, 0.07);
  color: var(--blue-light);
  padding: 4px 8px;
  font-size: 9px;
  text-transform: uppercase;
}

.filter-heading button:hover,
.filter-heading button:focus-visible {
  border-color: var(--gold);
  outline: none;
}

.series-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.series-button {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(246, 195, 95, 0.24);
  border-radius: 4px;
  background: rgba(7, 6, 12, 0.94);
  color: #60402f;
  padding: 6px 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.series-button i {
  width: 8px;
  height: 8px;
  background: rgba(246, 195, 95, 0.24);
}

.series-button strong {
  font-weight: 700;
}

.series-button small {
  font-size: 9px;
  opacity: 0.7;
}

.series-button.active {
  border-color: var(--series);
  color: var(--series);
  background: color-mix(in srgb, var(--series) 16%, transparent);
  box-shadow: 0 0 8px color-mix(in srgb, var(--series) 22%, transparent);
}

.series-button.active i {
  background: var(--series);
  box-shadow: 0 0 6px var(--series);
}

.history-panel {
  margin: 0 14px 14px;
}

.history-heading button {
  border: 1px solid rgba(246, 195, 95, 0.46);
  border-radius: 4px;
  background: rgba(246, 195, 95, 0.08);
  color: var(--gold);
  padding: 5px 10px;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.history-heading button:disabled {
  border-color: rgba(246, 195, 95, 0.18);
  color: #60402f;
  background: rgba(246, 195, 95, 0.04);
  cursor: default;
}

.history-status {
  margin: 0 0 12px;
  color: var(--blue-light);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-align: center;
  text-transform: uppercase;
}

.history-list {
  max-height: 240px;
  display: grid;
  gap: 6px;
  overflow: auto;
}

.history-item {
  display: grid;
  grid-template-columns: 132px 1fr 118px;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(246, 195, 95, 0.22);
  border-left: 4px solid var(--series);
  border-radius: 4px;
  background: rgba(7, 6, 12, 0.76);
  color: var(--gold);
  padding: 9px 12px;
  text-decoration: none;
}

.history-item:hover,
.history-item:focus-visible {
  border-color: var(--series);
  outline: none;
}

.history-item strong {
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.history-code,
.history-item small {
  color: var(--blue-light);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.history-item small {
  text-align: right;
}

.history-empty {
  margin: 0;
  color: #60402f;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-align: center;
  text-transform: uppercase;
}

.archive-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 14px 18px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-align: center;
  text-transform: uppercase;
}

.archive-footer p {
  margin: 2px 0;
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

@media (max-width: 920px) {
  .randomizer-grid {
    grid-template-columns: 1fr;
  }

  .wheel-panel {
    min-height: auto;
  }

  .wheel-frame {
    width: min(100%, 460px);
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 10px;
  }

  .archive-top {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .fleet-mark {
    width: min(220px, 62vw);
  }

  .archive-top p {
    font-size: 24px;
    white-space: normal;
  }

  .archive-top > span:last-child,
  .archive-top > time {
    justify-self: center;
  }

  .randomizer-grid,
  .filters,
  .history-panel {
    padding: 10px;
    margin-left: 0;
    margin-right: 0;
  }

  .selector {
    min-height: 300px;
  }

  .numbers {
    gap: 18px;
  }

  .numbers > div:not(.beads) {
    width: 116px;
  }

  .numbers strong {
    font-size: 50px;
  }

  #selected-series {
    font-size: 23px;
    min-height: 54px;
  }

  .filter-heading {
    flex-wrap: wrap;
    justify-content: center;
  }

  .filter-heading h2 {
    order: -1;
    width: 100%;
    text-align: center;
    font-size: 16px;
    letter-spacing: 0.22em;
  }

  .series-button small {
    display: none;
  }

  .primary-button span {
    min-width: 216px;
    padding-inline: 28px;
  }
}

@media (max-width: 440px) {
  .panel {
    padding: 12px;
  }

  .spin-orb {
    min-width: 104px;
    min-height: 104px;
  }

  .numbers {
    flex-wrap: wrap;
    gap: 14px;
  }

  .beads {
    display: none;
  }

  .title-row a {
    font-size: 20px;
    min-height: 50px;
    max-height: 50px;
  }

  .search-hit {
    grid-template-columns: 42px 62px 1fr;
    font-size: 12px;
    padding: 8px;
  }

  .history-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .history-item small {
    text-align: left;
  }
}
