:root {
  --felt: #0c3b2e;
  --felt-deep: #071f18;
  --brass: #c9a227;
  --brass-bright: #e8c547;
  --brass-dark: #8a6b12;
  --chrome: #d8d2c4;
  --ink: #f3efe4;
  --muted: #b8c4b6;
  --window: #0a1210;
  --payline: #ff3b4a;
  --glow: rgba(232, 197, 71, 0.35);
  --column: min(24rem, calc(100vw - 2rem));
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  color: var(--ink);
  background: var(--felt-deep);
  overflow-x: hidden;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(201, 162, 39, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(12, 59, 46, 0.9), transparent 60%),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.015) 0 1px,
      transparent 1px 7px
    ),
    linear-gradient(180deg, #0a2a20 0%, var(--felt-deep) 45%, #040e0b 100%);
  pointer-events: none;
}

.top-nav {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.55rem 0.75rem;
  padding: 1rem 1rem 0;
}

.top-nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 0.15s ease;
}

.top-nav-link:hover {
  color: var(--brass-bright);
}

.top-nav-link.is-active {
  color: var(--brass-bright);
}

.top-nav-sep {
  color: rgba(201, 162, 39, 0.45);
  user-select: none;
}

.stage {
  position: relative;
  z-index: 1;
  width: var(--column);
  margin: 0 auto;
  padding: 1.25rem 0 3.5rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1.5rem;
}

.stage-wide {
  width: min(42rem, calc(100vw - 2rem));
}

.prose h1 {
  margin: 0;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: clamp(2.2rem, 8vw, 3.2rem);
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--brass-bright);
  text-shadow: 0 2px 0 var(--brass-dark), 0 0 28px var(--glow);
}

.prose .lede {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.prose h2 {
  margin: 1.75rem 0 0.55rem;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: 1.45rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--brass-bright);
}

.prose h3 {
  margin: 1.15rem 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brass);
}

.prose p,
.prose li {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.prose p {
  margin: 0 0 0.85rem;
}

.prose ul {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
}

.prose code,
.prose pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
}

.prose code {
  color: var(--chrome);
}

.prose pre {
  margin: 0 0 1rem;
  padding: 0.85rem 0.95rem;
  overflow-x: auto;
  border-radius: 0.45rem;
  background: rgba(7, 20, 16, 0.85);
  border: 1px solid rgba(201, 162, 39, 0.28);
  color: var(--chrome);
  line-height: 1.45;
}

.api-toc {
  margin: 0.25rem 0 0.5rem;
  padding: 0.85rem 0;
  border-top: 1px solid rgba(201, 162, 39, 0.22);
  border-bottom: 1px solid rgba(201, 162, 39, 0.22);
}

.api-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}

.api-toc-item {
  margin: 0;
}

.api-toc-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  line-height: 1.35;
}

.api-toc-link:hover {
  color: var(--brass-bright);
}

.api-basics {
  margin-top: 1.25rem;
}

.api-endpoint {
  margin-top: 1.75rem;
  padding-top: 1.1rem;
  border-top: 1px solid rgba(201, 162, 39, 0.22);
  scroll-margin-top: 3.5rem;
}

.api-endpoint-title {
  margin: 0 0 0.4rem;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: 1.45rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--brass-bright);
}

.api-endpoint-summary,
.api-endpoint-notes {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.api-meta-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 0.65rem 0.85rem;
  margin-bottom: 0.85rem;
  align-items: start;
}

.api-meta-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brass);
  padding-top: 0.35rem;
}

.api-path {
  display: inline-block;
  padding: 0.35rem 0;
  color: var(--chrome);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  word-break: break-all;
}

.api-meta-block {
  min-width: 0;
}

.api-code {
  margin: 0;
  padding: 0.85rem 0.95rem;
  overflow-x: auto;
  border-radius: 0.45rem;
  background: rgba(7, 20, 16, 0.85);
  border: 1px solid rgba(201, 162, 39, 0.28);
  color: var(--chrome);
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
}

.api-field-list {
  margin: 0.55rem 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.75rem;
}

.api-field-name {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  color: var(--chrome);
}

.api-field-desc {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.4;
}

.api-snippets {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.api-snippet-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.85rem;
}

.api-snippet-tab {
  appearance: none;
  border: 0;
  padding: 0.2rem 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.api-snippet-tab:hover {
  color: var(--brass-bright);
}

.api-snippet-tab.is-active {
  color: var(--brass-bright);
}

.api-snippet-tab:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

@media (max-width: 560px) {
  .api-meta-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .api-meta-label {
    padding-top: 0;
  }
}

.brand {
  text-align: center;
}

.brand h1 {
  margin: 0;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: clamp(2.8rem, 10vw, 4rem);
  font-weight: 400;
  letter-spacing: 0.06em;
  line-height: 0.95;
  color: var(--brass-bright);
  text-shadow: 0 2px 0 var(--brass-dark), 0 0 28px var(--glow);
}

.brand p {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.machine {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.9rem;
}

.machine-frame {
  position: relative;
  padding: 1.1rem 1rem 1rem;
  border-radius: 1.1rem;
  background:
    linear-gradient(160deg, #3a3328 0%, #1a1712 40%, #2c261c 100%);
  border: 2px solid var(--brass-dark);
  box-shadow:
    0 0 0 3px rgba(201, 162, 39, 0.25),
    0 18px 40px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.machine-lights {
  display: flex;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  padding: 0 0.2rem;
}

.machine-lights span {
  flex: 1;
  height: 0.55rem;
  border-radius: 999px;
  background: radial-gradient(circle at 50% 35%, #ffe08a, var(--brass) 55%, var(--brass-dark));
  box-shadow: 0 0 10px var(--glow);
  animation: bulb 1.6s ease-in-out infinite;
}

.machine-lights span:nth-child(2) {
  animation-delay: 0.15s;
}
.machine-lights span:nth-child(3) {
  animation-delay: 0.3s;
}
.machine-lights span:nth-child(4) {
  animation-delay: 0.45s;
}
.machine-lights span:nth-child(5) {
  animation-delay: 0.6s;
}

.machine.spinning .machine-lights span {
  animation-duration: 0.28s;
}

@keyframes bulb {
  0%,
  100% {
    opacity: 0.55;
    filter: brightness(0.85);
  }
  50% {
    opacity: 1;
    filter: brightness(1.25);
  }
}

.reel-window {
  position: relative;
  height: 13.5rem;
  overflow: hidden;
  border-radius: 0.55rem;
  background: var(--window);
  border: 2px solid #4a4336;
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.85),
    inset 0 12px 18px rgba(0, 0, 0, 0.45);
}

.reel-window::before,
.reel-window::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  height: 2.6rem;
  pointer-events: none;
}

.reel-window::before {
  top: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.75), transparent);
}

.reel-window::after {
  bottom: 0;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.75), transparent);
}

.payline {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  z-index: 3;
  height: 4.5rem;
  margin-top: -2.25rem;
  border-top: 2px solid rgba(255, 59, 74, 0.85);
  border-bottom: 2px solid rgba(255, 59, 74, 0.85);
  box-shadow: inset 0 0 24px rgba(255, 59, 74, 0.12);
  pointer-events: none;
}

.reel {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  will-change: transform;
}

.reel.is-spinning {
  animation: reel-scroll var(--spin-duration, 0.4s) linear infinite;
}

@keyframes reel-scroll {
  from {
    transform: translateY(var(--spin-from, 0px));
  }
  to {
    transform: translateY(var(--spin-to, 0px));
  }
}

.reel.stop-shake {
  animation: reel-stop-shake 0.32s ease-out;
}

@keyframes reel-stop-shake {
  0% {
    transform: translateY(var(--land-y, 0px));
  }
  28% {
    transform: translateY(calc(var(--land-y, 0px) - 6px));
  }
  58% {
    transform: translateY(calc(var(--land-y, 0px) + 4px));
  }
  100% {
    transform: translateY(var(--land-y, 0px));
  }
}

.reel-item {
  height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1rem;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: clamp(1.4rem, 5vw, 1.85rem);
  letter-spacing: 0.04em;
  color: var(--chrome);
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.machine.landed .payline {
  animation: winflash 0.7s ease-out 2;
}

@keyframes winflash {
  0%,
  100% {
    box-shadow: inset 0 0 24px rgba(255, 59, 74, 0.12);
  }
  50% {
    box-shadow: inset 0 0 36px rgba(255, 59, 74, 0.45), 0 0 18px rgba(255, 59, 74, 0.35);
  }
}

.machine-plate {
  margin-top: 0.85rem;
  padding: 0.65rem 0.85rem;
  border-radius: 0.45rem;
  background: linear-gradient(180deg, #1f1a14, #0f0d0a);
  border: 1px solid var(--brass-dark);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.plate-label {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
}

.result {
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: 1.55rem;
  letter-spacing: 0.04em;
  color: var(--ink);
  min-height: 1.2em;
}

.spin {
  appearance: none;
  width: 100%;
  padding: 0.95rem 1rem;
  border: 0;
  border-radius: 0.55rem;
  background: linear-gradient(180deg, var(--brass-bright), var(--brass) 45%, var(--brass-dark));
  color: #1a1205;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: 1.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 4px 0 #5c4708,
    0 10px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.08s ease, filter 0.15s ease;
}

.spin:hover:not(:disabled) {
  filter: brightness(1.06);
}

.spin:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 #5c4708,
    0 4px 12px rgba(0, 0, 0, 0.35);
}

.spin:disabled {
  cursor: not-allowed;
  filter: grayscale(0.45) brightness(0.7);
  box-shadow: 0 2px 0 #3d320a;
}

.status {
  margin: 0;
  min-height: 1.2em;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.names-panel {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.names-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.names-panel label {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass);
}

.share {
  appearance: none;
  border: 1px solid rgba(201, 162, 39, 0.45);
  border-radius: 0.35rem;
  padding: 0.35rem 0.65rem;
  background: rgba(12, 10, 7, 0.55);
  color: var(--brass-bright);
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease;
}

.share:hover:not(:disabled) {
  filter: brightness(1.1);
  background: rgba(20, 16, 10, 0.85);
}

.share:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.share:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.names-panel textarea {
  width: 100%;
  resize: vertical;
  min-height: 10rem;
  padding: 0.85rem 0.95rem;
  border-radius: 0.55rem;
  border: 1px solid rgba(201, 162, 39, 0.35);
  background: rgba(7, 20, 16, 0.85);
  color: var(--ink);
  font: inherit;
  line-height: 1.45;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.names-panel textarea:focus {
  outline: 2px solid var(--brass);
  outline-offset: 1px;
}

.names-panel textarea::placeholder {
  color: #6f7f74;
}

.panel-title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass);
}

.history-panel {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.history-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.history-empty[hidden],
.history-list[hidden] {
  display: none;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0;
}

.history-name {
  min-width: 0;
  flex: 1;
  color: var(--ink);
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.history-btn {
  appearance: none;
  border: 0;
  border-radius: 0;
  padding: 0.2rem 0;
  background: transparent;
  color: var(--brass-bright);
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.01em;
  text-transform: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.history-add-all {
  font-size: 0.72rem;
}

.history-btn:hover:not(:disabled) {
  color: var(--brass);
}

.history-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.history-btn:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.about-random {
  margin-top: 0.5rem;
  padding-top: 1.35rem;
  border-top: 1px solid rgba(201, 162, 39, 0.28);
}

.about-random h2 {
  margin: 0 0 0.75rem;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: 1.45rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--brass-bright);
}

.about-random h3 {
  margin: 1rem 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brass);
}

.about-random h3:first-of-type {
  margin-top: 0.15rem;
}

.about-random p {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.about-random p:last-child {
  margin-bottom: 0;
}

.guides-panel {
  margin-top: 0.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid rgba(201, 162, 39, 0.28);
}

.guide-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.guide-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  line-height: 1.4;
}

.guide-links a:hover {
  color: var(--brass-bright);
}

.guide-cta {
  display: inline-block;
  margin: 0.35rem 0 1rem;
  color: var(--brass-bright);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
}

.guide-cta:hover {
  text-decoration: underline;
}

.related-guides {
  margin-top: 1.75rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(201, 162, 39, 0.22);
}

@media (max-width: 480px) {
  .stage {
    padding-top: 1.4rem;
  }

  .reel-window {
    height: 12rem;
  }

  .reel-item,
  .payline {
    height: 4rem;
  }

  .payline {
    margin-top: -2rem;
  }
}
