/* Token Slot Machine. The cabinet alone borrows the classic Las Vegas look:
   red enamel, gold trim, chrome bezels, chasing bulbs, a payline and an amber
   readout. Everything around it keeps to the Painted Interface rules. */
.slot-page .shell {
  max-width: 1260px;
}
.slot-intro {
  padding: 40px 0 28px;
}
.slot-intro h1 {
  font-size: clamp(36px, 4.5vw, 56px);
  margin: 0 0 12px;
}
.slot-intro .lead {
  margin: 0;
  max-width: 62ch;
}
.machine-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(290px, 1fr);
  align-items: start;
  gap: 32px;
}
.machine-stage {
  position: relative;
  padding: 0 86px 0 0;
  min-width: 0;
  --chrome-light: #fbf6ec;
  --chrome: #d8cdbb;
  --chrome-dark: #9d8d76;
  --cabinet-red: #e0532f;
  --cabinet-red-light: #f47d5e;
  --cabinet-red-dark: #8f2810;
  --gold: var(--sunflower);
  --gold-dark: var(--sunflower-deep);
  --bulb-off: #9a7430;
  --bulb-on: #ffe08a;
}

/* Cabinet */
.slot-cabinet {
  position: relative;
  z-index: 1;
  padding: 22px 22px 18px;
  border: 3px solid var(--cabinet-red-dark);
  border-radius: 52px 52px 28px 28px;
  background:
    linear-gradient(
      180deg,
      var(--cabinet-red-light) 0%,
      var(--cabinet-red) 18%,
      var(--cabinet-red) 82%,
      var(--cabinet-red-dark) 100%
    ),
    var(--cabinet-red);
  box-shadow:
    inset 0 0 0 5px var(--gold),
    inset 0 0 0 7px var(--gold-dark),
    0 10px 0 var(--cabinet-red-dark),
    0 16px 24px rgba(34, 28, 23, 0.28);
}

/* Marquee: a dark top box with glowing gold lettering and chasing bulbs */
.marquee {
  margin: 0 0 18px;
  padding: 12px 14px 14px;
  border: 2px solid var(--gold-dark);
  border-radius: 30px 30px 14px 14px;
  background:
    radial-gradient(
      120% 90% at 50% 100%,
      rgba(246, 185, 43, 0.22),
      transparent 60%
    ),
    var(--ink);
  box-shadow:
    inset 0 0 0 3px var(--gold),
    inset 0 2px 14px rgba(0, 0, 0, 0.6);
  text-align: center;
  color: var(--bulb-on);
}
.marquee-lights {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
}
.marquee-lights i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--gold-dark);
  background: var(--bulb-off);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
  animation: bulb-chase 3.6s ease-in-out infinite;
}
.marquee-lights i:nth-child(11n + 2) {
  animation-delay: -0.33s;
}
.marquee-lights i:nth-child(11n + 3) {
  animation-delay: -0.66s;
}
.marquee-lights i:nth-child(11n + 4) {
  animation-delay: -0.99s;
}
.marquee-lights i:nth-child(11n + 5) {
  animation-delay: -1.32s;
}
.marquee-lights i:nth-child(11n + 6) {
  animation-delay: -1.65s;
}
.marquee-lights i:nth-child(11n + 7) {
  animation-delay: -1.98s;
}
.marquee-lights i:nth-child(11n + 8) {
  animation-delay: -2.31s;
}
.marquee-lights i:nth-child(11n + 9) {
  animation-delay: -2.64s;
}
.marquee-lights i:nth-child(11n + 10) {
  animation-delay: -2.97s;
}
.marquee-lights i:nth-child(11n + 11) {
  animation-delay: -3.3s;
}
/* One soft wave travels along each row; nothing snaps on or off. */
@keyframes bulb-chase {
  0%,
  100% {
    background: var(--bulb-off);
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
  }
  50% {
    background: var(--bulb-on);
    box-shadow: 0 0 8px rgba(255, 224, 138, 0.6);
  }
}
.marquee-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 12px;
}
.marquee-title h2 {
  font-size: clamp(22px, 2.6vw, 32px);
  line-height: 1.1;
  margin: 0;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-shadow:
    0 0 6px rgba(255, 224, 138, 0.9),
    0 0 18px rgba(246, 185, 43, 0.7),
    0 2px 0 var(--gold-dark);
}
.marquee-title svg {
  width: 20px;
  height: 20px;
  fill: var(--gold);
  filter: drop-shadow(0 0 6px rgba(246, 185, 43, 0.9));
  flex: none;
}
.marquee p {
  margin: 6px 0 12px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--chrome);
}

/* Reel window: chrome bezel, cylindrical reels, a red payline */
.reel-housing {
  position: relative;
  padding: 12px 14px 10px;
  border: 2px solid var(--chrome-dark);
  border-radius: 22px;
  background: linear-gradient(
    180deg,
    var(--chrome-light) 0%,
    var(--chrome) 40%,
    var(--chrome-dark) 52%,
    var(--chrome) 64%,
    var(--chrome-light) 100%
  );
  box-shadow:
    inset 0 1px 0 #fff,
    0 4px 0 var(--cabinet-red-dark);
}
.reel-labels,
.reel-legend {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
  text-align: center;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 10px;
}
.reel-legend {
  margin: 10px 0 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: #4a3f33;
}
.reels {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border-radius: 14px;
  background: var(--ink);
  box-shadow: inset 0 0 0 2px var(--chrome-dark);
}
.reel {
  position: relative;
  z-index: 1;
  height: 120px;
  overflow: hidden;
  border: 2px solid var(--chrome-dark);
  border-radius: 10px;
  background: linear-gradient(
    180deg,
    #b9ad9a 0%,
    #f4eee2 18%,
    #fffdf7 50%,
    #f4eee2 82%,
    #b9ad9a 100%
  );
  font-family: var(--font-display);
  font-size: clamp(20px, 2.4vw, 30px);
  font-weight: 400;
  text-align: center;
  color: var(--ink);
}
.held-reel {
  color: #5a4e42;
}
.reel-word {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  height: var(--reel-height, 116px);
}
.next-reel {
  border-color: var(--gold-dark);
  box-shadow: 0 0 0 2px var(--gold);
}
/* The payline runs behind the reels, so it shows only in the gutters and the
   words stay legible; gold markers point at it from either side. */
.payline {
  position: absolute;
  z-index: 0;
  left: 2px;
  right: 2px;
  top: 50%;
  height: 3px;
  margin-top: -1px;
  background: var(--gold);
  pointer-events: none;
}
.payline::before,
.payline::after {
  content: '';
  position: absolute;
  top: -5px;
  width: 0;
  height: 0;
  border: 6px solid transparent;
}
.payline::before {
  left: -8px;
  border-left: 8px solid var(--gold);
}
.payline::after {
  right: -8px;
  border-right: 8px solid var(--gold);
}

/* Amber readout */
.machine-readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
  padding: 8px 14px;
  border: 2px solid var(--chrome-dark);
  border-radius: 10px;
  background: var(--ink);
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.04em;
  text-shadow: 0 0 6px rgba(246, 185, 43, 0.7);
  font-variant-numeric: tabular-nums;
}
.machine-state {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

/* Control deck: brushed chrome */
.control-deck {
  position: relative;
  padding: 16px 18px 14px;
  border: 2px solid var(--chrome-dark);
  border-radius: 20px;
  background: linear-gradient(180deg, var(--chrome-light), var(--chrome));
  box-shadow:
    inset 0 1px 0 #fff,
    0 4px 0 var(--cabinet-red-dark);
}
.starter-control .control-label {
  padding-right: 48px;
}
.control-deck .toy-select {
  border-color: var(--chrome-dark);
}
.deck-actions {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}
.deck-actions .pi-btn {
  flex: 1;
  padding: 0 16px;
  border-color: var(--chrome-dark);
  background: var(--paper-raised);
}
.cabinet-details {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
}
.speaker {
  display: grid;
  gap: 4px;
  margin-right: auto;
}
.speaker i {
  width: 42px;
  height: 3px;
  border-radius: 8px;
  background: var(--chrome-dark);
}
.coin-slot {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 14px;
  border: 3px solid var(--chrome-dark);
  border-radius: 999px;
  background: var(--ink);
  box-shadow: 0 1px 0 #fff;
}
.reset-coin {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 34px;
  height: 34px;
  margin-left: -17px;
  border: 2px solid var(--gold-dark);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe8a8, var(--gold) 60%);
  box-shadow:
    inset 0 0 0 3px var(--sunflower-soft),
    0 3px 0 var(--gold-dark);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}
.reset-coin svg {
  width: 18px;
  height: 18px;
  margin: 6px;
  fill: var(--ink);
}
.coin-tray {
  height: 26px;
  margin: 16px 28px 0;
  border: 2px solid var(--chrome-dark);
  border-radius: 8px 8px 16px 16px;
  background: linear-gradient(180deg, var(--chrome-dark), var(--chrome));
  box-shadow: inset 0 6px 8px rgba(0, 0, 0, 0.45);
}
.slot-cabinet[data-display='starter'] .reel-labels span:first-child,
.slot-cabinet[data-display='starter'] .reel-legend span:first-child {
  grid-column: 1 / -1;
}
.slot-cabinet[data-display='starter'] .reel-labels span:last-child,
.slot-cabinet[data-display='starter'] .reel-legend span:last-child {
  display: none;
}

/* Lever: a chrome arm on a side bracket that swings toward you on a pivot.
   --pull runs 0 to 1; the ball comes closer and grows as the arm foreshortens. */
.slot-lever {
  position: absolute;
  top: 124px;
  right: 0;
  width: 82px;
  height: 255px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 2;
  border-radius: 18px;
}
.slot-lever:active {
  cursor: grabbing;
}
.slot-lever:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 4px;
}
.lever-mechanism {
  position: relative;
  display: block;
  height: 210px;
  width: 100%;
  perspective: 560px;
  perspective-origin: 50% 85%;
}
.lever-track {
  position: absolute;
  top: 112px;
  left: 6px;
  width: 24px;
  height: 92px;
  border: 2px solid var(--chrome-dark);
  border-radius: 10px 0 0 10px;
  background: linear-gradient(
    90deg,
    var(--chrome-dark),
    var(--chrome-light) 45%,
    var(--chrome) 100%
  );
  box-shadow: var(--edge-1);
}
.lever-pivot {
  position: absolute;
  top: 134px;
  left: 18px;
  width: 46px;
  height: 46px;
  border: 2px solid var(--chrome-dark);
  border-radius: 50%;
  background: radial-gradient(
    circle at 38% 32%,
    var(--chrome-light),
    var(--chrome) 55%,
    var(--chrome-dark) 100%
  );
  box-shadow:
    inset 0 0 0 5px var(--chrome),
    inset 0 0 0 7px var(--chrome-dark),
    0 3px 0 var(--chrome-dark);
}
.lever-arm {
  position: absolute;
  top: 34px;
  left: 34px;
  width: 14px;
  height: 126px;
  border: 2px solid var(--chrome-dark);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--chrome-dark), var(--chrome-light));
  transform-origin: 50% 100%;
  transform-style: preserve-3d;
  transform: rotateX(calc(var(--pull, 0) * -74deg));
  transition: transform 520ms var(--pi-ease-settle);
}
.lever-ball {
  position: absolute;
  top: -24px;
  left: -25px;
  width: 60px;
  height: 60px;
  border: 2px solid var(--cabinet-red-dark);
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 30%,
    #ffb39c,
    var(--cabinet-red) 45%,
    var(--cabinet-red-dark) 100%
  );
  box-shadow: 0 calc(5px * (1 - var(--pull, 0))) 0 var(--cabinet-red-dark);
  transform: translateZ(1px) rotateX(calc(var(--pull, 0) * 74deg));
  transition:
    transform 520ms var(--pi-ease-settle),
    box-shadow 520ms var(--pi-ease-settle);
}
.slot-lever.is-dragging .lever-arm,
.slot-lever.is-dragging .lever-ball {
  transition: none;
}
.slot-lever.is-thrown .lever-arm,
.slot-lever.is-thrown .lever-ball {
  transition-duration: 140ms;
  transition-timing-function: var(--pi-ease-out);
}
.slot-lever:disabled {
  cursor: not-allowed;
}
.lever-label {
  display: block;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.25;
  margin-top: 8px;
}
.lever-hint {
  margin: 20px 0 0;
  font-size: 13px;
  text-align: center;
  color: var(--ink-muted);
}
.machine-foot {
  position: absolute;
  bottom: 36px;
  left: 20px;
  right: 106px;
  height: 18px;
  border: 2px solid var(--cabinet-red-dark);
  border-radius: 0 0 12px 12px;
  background: var(--cabinet-red-dark);
}

/* Cabinet states. The bulbs keep the same slow wave in every state. */
.slot-cabinet[data-state='spinning'] .status-dot,
.slot-cabinet[data-state='resetting'] .status-dot {
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
}
.slot-cabinet[data-state='spinning'] .next-reel {
  box-shadow:
    0 0 0 2px var(--gold),
    0 0 16px var(--gold);
}
.slot-cabinet[data-state='complete'] .status-dot {
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
}
.slot-cabinet[data-state='complete'] .next-reel {
  box-shadow:
    0 0 0 2px var(--gold),
    0 0 20px var(--gold);
}

/* Odds panel, sentence tray and lesson: Painted Interface only */
.odds-panel {
  padding: 24px;
  background: var(--paper-raised);
  border: 1px solid var(--line-strong);
  border-radius: 30px;
  box-shadow: var(--edge-2);
}
.odds-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.odds-heading h2 {
  margin: 0;
}
.odds-badge {
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  background: var(--paper-sunk);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
}
.odds-panel .choice {
  grid-template-columns: minmax(70px, 1fr) 1fr 54px;
  gap: 10px;
  min-height: 60px;
  padding: 10px 12px;
}
.odds-panel .choice-word {
  font-size: 18px;
}
.odds-panel .probability-track {
  height: 10px;
}
.choice:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}
.choice:disabled {
  transform: none;
  background: var(--paper-sunk);
}
.odds-instruction,
.branch-hint {
  font-size: 15px;
  margin: 20px 0 0;
  color: var(--ink-muted);
}
.odds-panel .feedback {
  font-size: 16px;
  min-height: 104px;
  margin-top: 20px;
}
.branch-hint {
  border-top: 1px solid var(--line-strong);
  padding-top: 16px;
}
.sentence-tray {
  border: 1px solid var(--birch-edge);
  border-radius: 24px;
  padding: 22px 24px;
  margin-top: 28px;
  background: var(--birch);
  background-image: var(--pi-birch-tex);
  background-size: 512px 128px;
  box-shadow: var(--edge-2);
}
.sentence-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.sentence-heading h2 {
  margin: 0;
  font-size: 24px;
}
.sentence-heading > span {
  font-size: 14px;
  color: var(--ink-muted);
}
.sentence-tray .rail {
  min-height: 64px;
}
.slot-page .model-note {
  text-align: center;
  margin-top: 18px;
}
.slot-page .token {
  min-height: 54px;
  font-size: 20px;
}
.slot-page .token.just-added {
  animation: token-drop 450ms var(--pi-ease-settle);
}
@keyframes token-drop {
  from {
    transform: translateY(-14px) rotate(-5deg);
  }
  to {
    transform: none;
  }
}

@media (max-width: 1050px) {
  .machine-layout {
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr);
    gap: 24px;
  }
  .slot-cabinet {
    padding: 18px 16px 16px;
  }
  .marquee-title {
    gap: 8px;
  }
  .marquee-title svg {
    width: 16px;
  }
  .odds-panel {
    padding: 20px 16px;
  }
  .control-deck {
    padding: 14px;
  }
  .reel-housing {
    padding: 12px 8px 10px;
  }
  .reels {
    gap: 5px;
  }
}
@media (max-width: 850px) {
  .machine-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }
  .machine-stage {
    width: 100%;
    max-width: 620px;
    margin: auto;
  }
  .slot-intro {
    padding-top: 32px;
  }
  .marquee-title h2 {
    font-size: 30px;
  }
  .reel {
    font-size: 28px;
  }
  .odds-panel .choice-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .odds-panel .feedback {
    min-height: 0;
  }
  .branch-hint {
    margin-top: 16px;
  }
}
@media (max-width: 480px) {
  .machine-stage {
    padding-right: 0;
  }
  .slot-cabinet {
    border-radius: 36px 36px 22px 22px;
    padding: 14px 10px 12px;
    box-shadow:
      inset 0 0 0 4px var(--gold),
      inset 0 0 0 6px var(--gold-dark),
      0 8px 0 var(--cabinet-red-dark);
  }
  .marquee {
    padding: 10px 8px 10px;
  }
  .marquee-title h2 {
    font-size: 20px;
    letter-spacing: 0.04em;
  }
  .marquee-title svg {
    display: none;
  }
  .marquee p {
    font-size: 11px;
    letter-spacing: 0.1em;
  }
  .marquee-lights {
    gap: 4px;
    padding: 0 4px;
  }
  .marquee-lights i {
    width: 10px;
    height: 10px;
  }
  .reel-housing {
    padding: 10px 6px 8px;
    border-radius: 16px;
  }
  .reel-labels {
    font-size: 11px;
  }
  .reel-legend {
    font-size: 10px;
  }
  .reels {
    padding: 5px;
  }
  .reel {
    height: 100px;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 650;
  }
  .reel-word {
    padding: 0 2px;
  }
  .machine-readout {
    font-size: 12px;
    margin: 14px 60px 14px 0;
    padding: 6px 10px;
  }
  .control-deck {
    padding: 12px 8px;
    border-radius: 16px;
    margin-right: 60px;
  }
  .slot-page .control-label {
    font-size: 14px;
  }
  .slot-page .toy-select {
    padding: 12px 24px 12px 10px;
    font-size: 15px;
  }
  .deck-actions {
    gap: 8px;
  }
  .deck-actions .pi-btn {
    font-size: 14px;
    padding: 0 8px;
  }
  .cabinet-details {
    gap: 8px;
  }
  .speaker i {
    width: 22px;
  }
  .coin-slot {
    top: 14px;
    right: 10px;
    width: 26px;
  }
  .coin-tray {
    margin: 12px 16px 0 16px;
    height: 20px;
  }
  .slot-lever {
    width: 60px;
    top: 344px;
    right: 8px;
  }
  .lever-track {
    left: 0;
    width: 18px;
  }
  .lever-pivot {
    left: 7px;
    width: 42px;
    height: 42px;
  }
  .lever-arm {
    left: 22px;
  }
  .lever-ball {
    width: 52px;
    height: 52px;
    left: -21px;
  }
  .machine-foot {
    right: 16px;
    bottom: 52px;
  }
  .lever-hint {
    margin: 20px 0 0;
    padding: 0 12px;
    min-height: 36px;
  }
  .odds-panel .choice-list {
    grid-template-columns: minmax(0, 1fr);
  }
  .sentence-tray {
    padding: 18px 16px;
  }
  .sentence-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .lever-arm,
  .lever-ball,
  .token.just-added,
  .marquee-lights i {
    transition: none;
    animation: none;
  }
  .marquee-lights i:nth-child(odd) {
    background: var(--bulb-on);
  }
}
