:root {
  color-scheme: dark;
  --ink: #151214;
  --ink-2: #21191d;
  --panel: rgba(35, 28, 31, 0.92);
  --panel-strong: #2c2026;
  --line: rgba(246, 207, 117, 0.34);
  --gold: #f4c85e;
  --gold-2: #ffe08d;
  --ruby: #d7394f;
  --teal: #2bd6c4;
  --cream: #fff4da;
  --muted: #cbbda0;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(135deg, rgba(215, 57, 79, 0.18), transparent 34%),
    linear-gradient(315deg, rgba(43, 214, 196, 0.13), transparent 40%),
    repeating-linear-gradient(90deg, rgba(244, 200, 94, 0.04) 0 1px, transparent 1px 18px),
    var(--ink);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--cream);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.6);
  opacity: 0.55;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar,
.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 18px 0 20px;
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.title-row {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px 16px;
  min-width: 0;
}

.spin-counters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
}

.spin-counters span {
  padding: 5px 8px;
  border: 1px solid rgba(255, 224, 141, 0.28);
  border-radius: 999px;
  background: rgba(33, 25, 29, 0.76);
  white-space: nowrap;
}

.spin-counters strong {
  color: var(--gold-2);
  font-variant-numeric: tabular-nums;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background:
    conic-gradient(from 0deg, var(--ruby), var(--gold), var(--teal), var(--ruby)),
    var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 244, 218, 0.1), 0 10px 30px rgba(244, 200, 94, 0.24);
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold-2);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 2rem;
  line-height: 1.05;
}

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1rem;
}

.speed-panel {
  display: grid;
  grid-template-columns: auto minmax(150px, 240px) 56px;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(33, 25, 29, 0.88);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.22);
}

.speed-panel label,
.speed-panel output {
  color: var(--cream);
  font-weight: 800;
}

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

.machine-grid {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.machine-grid > *,
.roulette-stage,
.story-stage,
.db-stage,
.share-stage {
  min-width: 0;
}

.lever-panel {
  position: sticky;
  top: 104px;
  display: grid;
  gap: 14px;
}

.lever-machine {
  position: relative;
  --lever-pull: 142px;
  min-height: 440px;
  border: 1px solid rgba(255, 224, 141, 0.46);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 10%, rgba(255, 224, 141, 0.28), transparent 24%),
    linear-gradient(155deg, rgba(215, 57, 79, 0.26), rgba(43, 214, 196, 0.12)),
    repeating-linear-gradient(90deg, rgba(255, 244, 218, 0.04) 0 1px, transparent 1px 18px),
    var(--panel-strong);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 244, 218, 0.08);
  overflow: hidden;
}

.lever-machine::before,
.lever-machine::after {
  content: "";
  position: absolute;
  left: 22px;
  right: 22px;
  height: 18px;
  border-radius: 999px;
  background:
    radial-gradient(circle, rgba(255, 224, 141, 0.95) 0 25%, transparent 28%) 0 50% / 28px 10px repeat-x,
    linear-gradient(90deg, transparent, rgba(255, 224, 141, 0.55), transparent);
  opacity: 0.72;
  z-index: 1;
}

.lever-machine::before {
  top: 20px;
}

.lever-machine::after {
  bottom: 20px;
}

.lever-lights {
  position: absolute;
  inset: 18px;
  border: 2px solid rgba(244, 200, 94, 0.45);
  border-radius: 14px;
  background:
    repeating-linear-gradient(0deg, rgba(244, 200, 94, 0.12) 0 5px, transparent 5px 18px),
    repeating-linear-gradient(90deg, transparent 0 12px, rgba(255, 255, 255, 0.06) 12px 13px);
  opacity: 0.7;
}

.lever-slot {
  position: absolute;
  inset: 68px 38px 54px;
  border-radius: 999px;
  border: 1px solid rgba(255, 224, 141, 0.22);
  background:
    radial-gradient(ellipse at 50% 18%, rgba(255, 255, 255, 0.1), transparent 28%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.66), rgba(255, 244, 218, 0.1) 48%, rgba(0, 0, 0, 0.7));
  box-shadow: inset 0 0 34px rgba(0, 0, 0, 0.78), 0 14px 34px rgba(0, 0, 0, 0.28);
}

.lever-slot::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 18px;
  bottom: 18px;
  width: 20px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.42), rgba(255, 244, 218, 0.1), rgba(0, 0, 0, 0.42));
  transform: translateX(-50%);
}

.lever-slot::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 24px;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 244, 218, 0.18), transparent 34%),
    linear-gradient(135deg, rgba(255, 224, 141, 0.2), rgba(0, 0, 0, 0.42));
  transform: translateX(-50%);
  box-shadow: inset 0 0 26px rgba(0, 0, 0, 0.68);
}

.lever-arm {
  position: absolute;
  left: 50%;
  top: 40px;
  width: 18px;
  height: 178px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, #4d3822 0 12%, #dca936 32%, #fff1ae 48%, #b77b19 70%, #3b2819 100%);
  transform: translateX(-50%);
  transform-origin: 50% 12px;
  transition: transform 180ms ease;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.48), inset 0 0 0 1px rgba(255, 244, 218, 0.22);
  z-index: 3;
}

.lever-arm::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -14px;
  width: 44px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffe08d 0 30%, #a86e18 70%, #3d2812 100%);
  transform: translateX(-50%);
}

.lever-knob {
  position: absolute;
  left: 50%;
  top: 4px;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 24%, #fff8d8 0 9%, transparent 10%),
    radial-gradient(circle at 38% 34%, #ff7b8e 0 20%, #d7193b 42%, #7d1324 70%, #2c0b12 100%);
  transform: translate3d(-50%, 0, 0);
  cursor: grab;
  touch-action: none;
  box-shadow:
    0 18px 30px rgba(0, 0, 0, 0.5),
    0 0 0 8px rgba(28, 16, 20, 0.82),
    0 0 0 12px rgba(255, 224, 141, 0.32),
    inset -12px -16px 26px rgba(0, 0, 0, 0.36);
  transition: transform 180ms ease, box-shadow 180ms ease;
  z-index: 4;
}

.lever-knob:active {
  cursor: grabbing;
}

.lever-machine.is-pulling .lever-knob {
  animation: lever-knob-pull 820ms cubic-bezier(0.18, 0.9, 0.22, 1) both;
  cursor: grabbing;
}

.lever-machine.is-pulling .lever-arm {
  animation: lever-arm-pull 820ms cubic-bezier(0.18, 0.9, 0.22, 1) both;
}

.lever-machine.is-pulling .lever-lights {
  animation: lever-light-flash 820ms ease both;
}

@keyframes lever-knob-pull {
  0% {
    transform: translate3d(-50%, 0, 0) scale(1);
    box-shadow:
      0 18px 30px rgba(0, 0, 0, 0.5),
      0 0 0 8px rgba(28, 16, 20, 0.82),
      0 0 0 12px rgba(255, 224, 141, 0.32),
      inset -12px -16px 26px rgba(0, 0, 0, 0.36);
  }

  38% {
    transform: translate3d(-50%, var(--lever-pull), 0) scale(0.98);
    box-shadow:
      0 28px 42px rgba(0, 0, 0, 0.62),
      0 0 0 8px rgba(28, 16, 20, 0.9),
      0 0 0 14px rgba(255, 224, 141, 0.5),
      inset -12px -16px 26px rgba(0, 0, 0, 0.42);
  }

  58% {
    transform: translate3d(-50%, calc(var(--lever-pull) * 0.76), 0) scale(1.02);
  }

  78% {
    transform: translate3d(-50%, calc(var(--lever-pull) * 0.12), 0) scale(1.01);
  }

  100% {
    transform: translate3d(-50%, 0, 0) scale(1);
  }
}

@keyframes lever-arm-pull {
  0% {
    transform: translateX(-50%) scaleY(1);
    filter: none;
  }

  38% {
    transform: translateX(-50%) scaleY(1.78);
    filter: drop-shadow(0 0 14px rgba(255, 224, 141, 0.62));
  }

  58% {
    transform: translateX(-50%) scaleY(1.54);
  }

  78% {
    transform: translateX(-50%) scaleY(1.12);
  }

  100% {
    transform: translateX(-50%) scaleY(1);
    filter: none;
  }
}

@keyframes lever-light-flash {
  0%, 100% {
    opacity: 0.7;
  }

  35%, 58% {
    opacity: 1;
    filter: saturate(1.35) brightness(1.25);
  }
}

.lever-knob:focus-visible,
.primary-action:focus-visible,
.ghost-action:focus-visible,
.icon-action:focus-visible,
.delete-candidate:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
}

.primary-action,
.ghost-action {
  min-height: 44px;
  border-radius: var(--radius);
  font-weight: 900;
  color: var(--ink);
  cursor: pointer;
}

.primary-action {
  background: linear-gradient(135deg, var(--gold-2), var(--gold) 58%, #d59a23);
  box-shadow: 0 14px 34px rgba(244, 200, 94, 0.26);
}

.ghost-action {
  padding: 0 14px;
  border: 1px solid rgba(255, 224, 141, 0.42);
  background: rgba(255, 244, 218, 0.08);
  color: var(--cream);
}

.spin-state {
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(43, 214, 196, 0.34);
  border-radius: var(--radius);
  color: var(--teal);
  background: rgba(43, 214, 196, 0.08);
  font-weight: 800;
}

.db-alert {
  margin: 0 0 18px;
  border: 1px solid rgba(43, 214, 196, 0.34);
  border-radius: var(--radius);
  color: #c9fffa;
  background: rgba(43, 214, 196, 0.08);
  padding: 11px 13px;
  font-size: 0.9rem;
  font-weight: 850;
}

.db-alert.is-error {
  border-color: rgba(215, 57, 79, 0.62);
  color: #ffd7dc;
  background: rgba(215, 57, 79, 0.1);
}

.db-alert[hidden] {
  display: none;
}

.roulette-stage,
.story-stage,
.db-stage,
.share-stage {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.reel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 16px;
  margin-top: 16px;
}

.reel-card {
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 224, 141, 0.28);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 224, 141, 0.09), transparent 28%),
    var(--panel);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  padding: 14px;
}

.reel-card > *,
.story-card > * {
  min-width: 0;
  max-width: 100%;
}

.reel-card.is-empty {
  border-color: rgba(215, 57, 79, 0.74);
  box-shadow: 0 0 0 2px rgba(215, 57, 79, 0.22), 0 18px 48px rgba(0, 0, 0, 0.28);
}

.reel-card.is-spinning .slot-window {
  border-color: rgba(43, 214, 196, 0.62);
  box-shadow: inset 0 0 28px rgba(43, 214, 196, 0.14), 0 0 28px rgba(43, 214, 196, 0.1);
}

.reel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.reel-name {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid rgba(255, 224, 141, 0.28);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.25);
  color: var(--cream);
  font-weight: 900;
  padding: 10px 11px;
}

.icon-action {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: rgba(215, 57, 79, 0.16);
  color: #ffd7dc;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.source-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid rgba(255, 224, 141, 0.25);
  border-radius: var(--radius);
  overflow: hidden;
}

.source-switch label {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 38px;
  padding: 0 8px;
  min-width: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 900;
  text-align: center;
  background: rgba(0, 0, 0, 0.18);
}

.source-switch span {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-switch label + label {
  border-left: 1px solid rgba(255, 224, 141, 0.2);
}

.source-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.source-switch label.is-selected {
  color: var(--ink);
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
}

.slot-window {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 188px;
  overflow: hidden;
  border: 1px solid rgba(255, 224, 141, 0.34);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.64), transparent 34%, transparent 66%, rgba(0, 0, 0, 0.64)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 10px),
    #120f11;
}

.slot-window::before,
.slot-window::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-2), transparent);
  z-index: 2;
}

.slot-window::before {
  top: 72px;
}

.slot-window::after {
  bottom: 72px;
}

.slot-line {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 72px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--cream);
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  min-width: 0;
  padding: 0 4px;
  word-break: keep-all;
  white-space: nowrap;
  overflow-wrap: anywhere;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.72);
  will-change: transform, opacity;
}

.slot-line.is-center {
  color: var(--gold-2);
}

.slot-window.is-winner .slot-line.is-center {
  color: #ffffff;
  text-shadow: 0 0 16px rgba(244, 200, 94, 0.72), 0 2px 14px rgba(0, 0, 0, 0.72);
}

.material-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.material-box {
  width: 100%;
  max-width: 100%;
  min-height: 92px;
  resize: vertical;
  border: 1px solid rgba(255, 224, 141, 0.22);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.24);
  color: var(--cream);
  padding: 11px;
}

.material-box::placeholder {
  color: rgba(203, 189, 160, 0.72);
}

.add-material-button {
  min-width: 92px;
  border: 1px solid rgba(43, 214, 196, 0.45);
  border-radius: var(--radius);
  color: #d9fffb;
  background:
    linear-gradient(135deg, rgba(43, 214, 196, 0.24), rgba(244, 200, 94, 0.12)),
    rgba(0, 0, 0, 0.26);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  cursor: pointer;
  font-weight: 900;
}

.add-material-button:hover:not(:disabled) {
  border-color: rgba(43, 214, 196, 0.72);
  background:
    linear-gradient(135deg, rgba(43, 214, 196, 0.34), rgba(244, 200, 94, 0.18)),
    rgba(0, 0, 0, 0.2);
}

.add-material-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.candidate-section {
  display: grid;
  gap: 8px;
  width: 100%;
  min-width: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.candidate-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
  width: 100%;
  min-width: 0;
  max-height: 154px;
  overflow: auto;
  padding: 2px;
}

.candidate-list:empty {
  display: none;
}

.candidate-chip {
  position: relative;
  display: grid;
  align-items: center;
  min-width: 0;
  min-height: 42px;
  border: 1px solid rgba(43, 214, 196, 0.35);
  border-radius: var(--radius);
  color: #d9fffb;
  background:
    linear-gradient(135deg, rgba(43, 214, 196, 0.15), rgba(255, 244, 218, 0.05)),
    rgba(0, 0, 0, 0.18);
  padding: 10px 26px 8px 10px;
  line-height: 1.25;
}

.candidate-chip > span {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
  word-break: keep-all;
}

.delete-candidate {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffd7dc;
  background: rgba(215, 57, 79, 0.58);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 900;
  line-height: 1;
}

.delete-candidate:hover {
  background: rgba(215, 57, 79, 0.86);
}

.mini-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  overflow: hidden;
  justify-content: flex-end;
  min-width: 0;
}

.mini-chip {
  flex: 0 1 auto;
  max-width: 130px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid rgba(43, 214, 196, 0.35);
  border-radius: 999px;
  color: #c9fffa;
  background: rgba(43, 214, 196, 0.08);
  padding: 4px 8px;
}

.story-stage,
.db-stage,
.share-stage {
  margin-top: 28px;
}

.db-grid {
  display: grid;
  gap: 18px;
  margin-top: 16px;
}

.db-save-state {
  margin-top: 12px;
  border: 1px solid rgba(43, 214, 196, 0.28);
  border-radius: var(--radius);
  color: #c9fffa;
  background: rgba(43, 214, 196, 0.08);
  padding: 10px 12px;
  font-size: 0.86rem;
  font-weight: 800;
}

.db-group {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.db-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
}

.db-group-head span {
  font-size: 0.84rem;
  font-weight: 800;
}

.db-table-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 12px;
}

.db-table {
  display: grid;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  border: 1px solid rgba(255, 224, 141, 0.24);
  border-radius: var(--radius);
  background: rgba(21, 18, 20, 0.68);
  padding: 12px;
}

.db-table-name,
.db-row input,
.db-add-row input {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(255, 224, 141, 0.24);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.22);
  color: var(--cream);
  padding: 9px 10px;
}

.db-table-name {
  color: var(--gold-2);
  font-weight: 900;
}

.db-row-list {
  display: grid;
  gap: 7px;
  max-height: 240px;
  overflow: auto;
  padding-right: 2px;
}

.db-row {
  position: relative;
  min-width: 0;
}

.db-row input {
  padding-right: 34px;
}

.db-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 68px;
  gap: 8px;
  min-width: 0;
}

.db-add-row .ghost-action {
  min-height: 40px;
  padding: 0 10px;
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.story-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  border: 1px solid rgba(43, 214, 196, 0.28);
  border-radius: var(--radius);
  background: rgba(28, 33, 34, 0.86);
  padding: 12px;
}

.story-card h3 {
  color: #d9fffb;
}

.story-slot {
  height: 116px;
}

.story-slot .slot-line {
  top: 36px;
  font-size: 0.95rem;
}

.story-slot::before {
  top: 36px;
}

.story-slot::after {
  bottom: 36px;
}

.story-result {
  margin-top: 16px;
  border: 1px solid rgba(244, 200, 94, 0.36);
  border-radius: var(--radius);
  background: rgba(255, 244, 218, 0.08);
  padding: 16px;
  color: var(--cream);
  line-height: 1.65;
  font-weight: 750;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.db-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.file-action {
  display: inline-grid;
  place-items: center;
}

.result-preview {
  display: block;
  width: min(680px, 100%);
  margin-top: 16px;
  border: 1px solid rgba(255, 224, 141, 0.34);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.is-pulsing {
  animation: pulseGold 900ms ease-in-out infinite alternate;
}

@keyframes pulseGold {
  from {
    box-shadow: 0 0 0 rgba(244, 200, 94, 0);
  }
  to {
    box-shadow: 0 0 28px rgba(244, 200, 94, 0.36);
  }
}

@media (max-width: 1100px) {
  .machine-grid {
    grid-template-columns: 148px minmax(0, 1fr);
  }

  .reel-grid {
    grid-template-columns: repeat(2, minmax(240px, 1fr));
  }

  .story-grid {
    grid-template-columns: repeat(2, minmax(210px, 1fr));
  }
}

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

  .topbar,
  .stage-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .speed-panel {
    grid-template-columns: auto minmax(0, 1fr) 54px;
  }

  .machine-grid {
    grid-template-columns: 1fr;
  }

  .lever-panel {
    position: relative;
    top: auto;
    grid-template-columns: minmax(128px, 180px) minmax(0, 1fr);
    align-items: center;
  }

  .lever-machine {
    --lever-pull: 108px;
    min-height: 220px;
  }

  .lever-slot {
    inset: 42px 40px 32px;
  }

  .lever-arm {
    height: 94px;
  }

  .lever-knob {
    width: 62px;
    height: 62px;
  }

  .primary-action,
  .spin-state {
    grid-column: 2;
  }

  .reel-grid,
  .story-grid {
    grid-template-columns: 1fr;
  }

  .candidate-list {
    grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  }

  .share-actions {
    justify-content: stretch;
  }

  .share-actions .ghost-action,
  .db-actions .ghost-action {
    flex: 1 1 140px;
  }

  .db-actions {
    justify-content: stretch;
  }
}

@media (max-width: 480px) {
  .app-shell {
    padding: 14px;
  }

  h1 {
    font-size: 1.55rem;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .lever-panel {
    grid-template-columns: 1fr;
  }

  .primary-action,
  .spin-state {
    grid-column: auto;
  }

  .source-switch {
    grid-template-columns: 1fr;
  }

  .material-entry {
    grid-template-columns: 1fr;
  }

  .add-material-button {
    min-height: 44px;
  }

  .source-switch label + label {
    border-left: 0;
    border-top: 1px solid rgba(255, 224, 141, 0.2);
  }

  .slot-window {
    height: 172px;
  }

  .slot-line {
    top: 64px;
  }

  .slot-window::before {
    top: 64px;
  }

  .slot-window::after {
    bottom: 64px;
  }
}
