:root {
  color-scheme: dark;
  --bg: #09110f;
  --panel: #14211e;
  --panel-2: #1b2b27;
  --gold: #ffd166;
  --gold-2: #fca311;
  --mint: #61f2c2;
  --rose: #ff4d7d;
  --ink: #f7fbf8;
  --muted: #a7b8af;
  --shadow: rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
  background: #06100d;
  overflow-x: hidden;
}

.background-stage {
  position: fixed;
  inset: 0;
  z-index: -3;
  overflow: hidden;
  background: #06100d;
  pointer-events: none;
}

.background-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1200ms ease;
  will-change: opacity;
}

.background-layer.active {
  opacity: 1;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
  content: "";
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 760px);
  gap: 24px;
  width: min(760px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 0;
  align-content: center;
  justify-items: center;
}

.machine {
  position: relative;
  width: 100%;
  padding: 20px;
  border: 2px solid rgba(255, 209, 102, 0.7);
  border-radius: 26px;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.08), transparent 30%),
    linear-gradient(180deg, #233a35, #0d1714);
  box-shadow:
    0 28px 70px var(--shadow),
    inset 0 0 0 8px rgba(255, 255, 255, 0.035),
    inset 0 0 36px rgba(255, 209, 102, 0.16);
}

.machine::after {
  position: absolute;
  inset: 10px;
  z-index: -1;
  border-radius: 30px;
  background: linear-gradient(90deg, transparent, rgba(255, 209, 102, 0.32), transparent);
  filter: blur(18px);
  content: "";
}

.timer-rails {
  position: absolute;
  inset: 12px 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0.34;
  transition: opacity 120ms ease;
}

.timer-rails.active {
  opacity: 0.72;
}

.timer-rail {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.055),
    0 0 14px rgba(97, 242, 194, 0.055);
  overflow: hidden;
}

.timer-rail-left {
  left: 6px;
}

.timer-rail-right {
  right: 6px;
}

.timer-rail::before {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 18%),
    linear-gradient(180deg, rgba(97, 242, 194, 0.62), rgba(255, 209, 102, 0.48) 64%, rgba(255, 77, 125, 0.52));
  box-shadow:
    0 0 10px rgba(97, 242, 194, 0.22),
    0 0 18px rgba(255, 209, 102, 0.12);
  transform-origin: bottom center;
  content: "";
}

.timer-rails.active .timer-rail::before {
  animation: timerRailDrain var(--timer-duration, 4s) linear forwards;
}

.timer-rails.danger .timer-rail::before {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent 18%),
    linear-gradient(180deg, rgba(255, 209, 102, 0.56), rgba(255, 77, 125, 0.68));
  box-shadow:
    0 0 12px rgba(255, 77, 125, 0.28),
    0 0 20px rgba(255, 209, 102, 0.14);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.stat {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(97, 242, 194, 0.24);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.32);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 4px;
  color: var(--mint);
  font-family: Orbitron, Inter, sans-serif;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
}

.level-stat {
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.level-stat.danger {
  border-color: rgba(255, 77, 125, 0.55);
  box-shadow: inset 0 0 22px rgba(255, 77, 125, 0.08);
}

.level-stat.danger span {
  color: #ff8aa8;
}

.level-meter {
  position: relative;
  height: 16px;
  margin-top: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent calc((100% / var(--meter-segments, 9)) - 1px),
    rgba(255, 255, 255, 0.28) calc((100% / var(--meter-segments, 9)) - 1px),
    rgba(255, 255, 255, 0.28) calc(100% / var(--meter-segments, 9))
  );
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    inset 0 0 12px rgba(0, 0, 0, 0.24);
  overflow: hidden;
}

.level-meter span {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: inherit;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.28), transparent 22%),
    repeating-linear-gradient(
      90deg,
      rgba(97, 242, 194, 0.92) 0,
      rgba(97, 242, 194, 0.92) calc((100% / var(--meter-segments, 9)) - 1px),
      rgba(5, 8, 8, 0.85) calc((100% / var(--meter-segments, 9)) - 1px),
      rgba(5, 8, 8, 0.85) calc(100% / var(--meter-segments, 9))
    );
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 240ms ease, background 180ms ease;
}

.level-stat.danger .level-meter span {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.24), transparent 24%),
    repeating-linear-gradient(
      90deg,
      rgba(255, 77, 125, 0.92) 0,
      rgba(255, 77, 125, 0.92) calc((100% / var(--meter-segments, 3)) - 1px),
      rgba(5, 8, 8, 0.85) calc((100% / var(--meter-segments, 3)) - 1px),
      rgba(5, 8, 8, 0.85) calc(100% / var(--meter-segments, 3))
    );
}

.money-display {
  display: block;
}

.money-display.money-hit {
  animation: moneyHit 360ms ease both;
}

.reel-window {
  position: relative;
  padding: 18px;
  border: 8px solid #080d0c;
  border-radius: 18px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent 12%, transparent 88%, rgba(255, 255, 255, 0.08)),
    #050808;
  box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}

.reels {
  display: grid;
  gap: 10px;
  transition: grid-template-columns 180ms ease;
}

.reels-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.reel {
  position: relative;
  height: clamp(112px, 18vw, 158px);
  border: 1px solid rgba(255, 209, 102, 0.38);
  border-radius: 12px;
  background: linear-gradient(180deg, #f7fbf8, #e7ede8);
  box-shadow:
    inset 0 14px 24px rgba(255, 255, 255, 0.9),
    inset 0 -18px 28px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.reel-strip {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  transform: translateY(0);
}

.symbol {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  align-items: center;
  justify-content: center;
  color: #141414;
  font-family: Orbitron, Inter, sans-serif;
  font-size: clamp(2.1rem, 7vw, 4.4rem);
  font-weight: 800;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.9);
}

.symbol small {
  color: #253530;
  font-family: Inter, system-ui, sans-serif;
  font-size: clamp(0.78rem, 2.1vw, 1.05rem);
  font-weight: 900;
  text-transform: uppercase;
}

.symbol-emoji {
  display: block;
  line-height: 1;
}

.emoji-reel .symbol-emoji {
  font-size: clamp(3rem, 9vw, 5.5rem);
}

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

.reel::before {
  top: 0;
  background: linear-gradient(to bottom, rgba(5, 8, 8, 0.34), transparent);
}

.reel::after {
  bottom: 0;
  background: linear-gradient(to top, rgba(5, 8, 8, 0.3), transparent);
}

.result-banner {
  position: absolute;
  right: 50%;
  bottom: 18px;
  z-index: 5;
  max-width: calc(100% - 36px);
  padding: 9px 16px;
  border: 1px solid rgba(255, 209, 102, 0.42);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.78);
  color: var(--gold);
  font-weight: 900;
  transform: translateX(50%);
  white-space: nowrap;
}

.result-banner:empty {
  display: none;
}

.result-banner.win {
  animation: pop 700ms ease both;
}

.result-banner.lost {
  border-color: rgba(255, 77, 125, 0.75);
  background: rgba(70, 0, 18, 0.9);
  color: #ff8aa8;
  animation: dangerPop 760ms ease both;
}

.effect-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  overflow: hidden;
}

.try-again-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.try-again-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.try-again-panel {
  display: grid;
  gap: 18px;
  width: min(100%, 360px);
  padding: 24px;
  border: 1px solid rgba(255, 77, 125, 0.42);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    rgba(8, 14, 13, 0.94);
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.6),
    0 0 34px rgba(255, 77, 125, 0.22);
  transform: scale(0.94);
  transition: transform 180ms ease;
}

.try-again-overlay.visible .try-again-panel {
  transform: scale(1);
}

.try-again-title {
  color: #ff8aa8;
  font-family: Orbitron, Inter, sans-serif;
  font-size: clamp(1.35rem, 7vw, 2.2rem);
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.try-again-button {
  min-height: 56px;
  border: 1px solid rgba(255, 209, 102, 0.54);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 44%),
    linear-gradient(135deg, #ffd166, #fca311);
  color: #271600;
  font-family: Orbitron, Inter, sans-serif;
  font-size: 1.05rem;
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: 0 12px 30px rgba(252, 163, 17, 0.22);
}

.coin,
.bank-coin,
.confetti {
  position: absolute;
  will-change: transform, opacity;
}

.coin,
.bank-coin {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 2px solid #ffefad;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, #fff7bd, transparent 26%),
    linear-gradient(135deg, #ffd166, #e58f00);
  color: #7a3b00;
  font-family: Orbitron, Inter, sans-serif;
  font-size: 0.82rem;
  font-weight: 900;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.coin {
  animation: coinFly var(--coin-time, 900ms) cubic-bezier(.12,.78,.2,1) forwards;
}

.bank-coin {
  animation: bankCoinDrop var(--bank-time, 800ms) cubic-bezier(.16,.76,.2,1) forwards;
}

.confetti {
  width: 9px;
  height: 18px;
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.26);
  animation: confettiFly var(--confetti-time, 800ms) cubic-bezier(.12,.78,.2,1) forwards;
}

.level-confetti {
  position: fixed;
  z-index: 52;
  width: 14px;
  height: 26px;
  border-radius: 4px;
  opacity: 0;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.24);
  animation: levelConfettiFall var(--fall-time, 1600ms) linear forwards;
  pointer-events: none;
}

.level-up-text {
  position: fixed;
  top: 48%;
  left: 50%;
  z-index: 53;
  color: var(--gold);
  font-family: Orbitron, Inter, sans-serif;
  font-size: clamp(3.2rem, 13vw, 8.5rem);
  font-weight: 900;
  letter-spacing: 0;
  text-shadow:
    0 0 22px rgba(255, 209, 102, 0.8),
    0 0 58px rgba(97, 242, 194, 0.42),
    0 8px 28px rgba(0, 0, 0, 0.65);
  transform: translate(-50%, -50%);
  animation: levelUpText 1250ms cubic-bezier(.16,.84,.24,1) forwards;
  pointer-events: none;
  white-space: nowrap;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.5);
  opacity: 0.68;
}

.sentence-format {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.sentence-format span {
  display: grid;
  min-height: 38px;
  place-items: center;
  border: 1px solid rgba(97, 242, 194, 0.26);
  border-radius: 8px;
  background: rgba(97, 242, 194, 0.1);
  color: var(--mint);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.word-table-wrap {
  margin-top: 16px;
}

.word-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.word-cell {
  position: relative;
  height: clamp(58px, 8vw, 76px);
  min-width: 0;
  border: 1px solid rgba(255, 209, 102, 0.26);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent),
    rgba(8, 14, 13, 0.82);
  color: var(--ink);
  font-weight: 900;
  overflow: hidden;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .word-cell:not(:disabled):hover {
    border-color: rgba(255, 209, 102, 0.74);
    background: rgba(255, 209, 102, 0.1);
    box-shadow: 0 0 18px rgba(255, 209, 102, 0.18);
  }
}

.word-cell:disabled {
  cursor: default;
}

.word-cell.correct {
  border-color: rgba(97, 242, 194, 0.9);
  background: rgba(97, 242, 194, 0.22);
  color: var(--mint);
  box-shadow: 0 0 20px rgba(97, 242, 194, 0.35);
  animation: cellPop 420ms ease both;
}

.word-cell.wrong {
  border-color: rgba(255, 77, 125, 0.82);
  background: rgba(255, 77, 125, 0.14);
  color: #ffb6c7;
  animation: shake 260ms ease both;
}

.word-cell.column-locked {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.035);
  color: rgba(247, 251, 248, 0.42);
  box-shadow: inset 0 0 0 1px rgba(255, 77, 125, 0.12);
  filter: grayscale(0.8);
}

.word-cell.line-win {
  box-shadow:
    0 0 0 2px rgba(255, 209, 102, 0.55),
    0 0 24px rgba(255, 209, 102, 0.48);
}

.word-symbol {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 0 8px;
  font-size: clamp(0.92rem, 2.4vw, 1.18rem);
  font-weight: 900;
  text-transform: uppercase;
}

.word-symbol.lang-th {
  font-size: clamp(1.1rem, 2.88vw, 1.42rem);
  font-weight: 400;
  text-transform: none;
}

.board-line {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 6;
  width: 0;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--rose), var(--gold), var(--mint));
  box-shadow:
    0 0 12px rgba(255, 209, 102, 0.9),
    0 0 24px rgba(97, 242, 194, 0.45);
  opacity: 0;
  pointer-events: none;
  transform: rotate(var(--line-angle, 0deg)) scaleX(0);
  transform-origin: left center;
}

.board-line.draw {
  animation: drawBoardLine 620ms cubic-bezier(.16,.84,.22,1) forwards;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.paytable {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    rgba(8, 14, 13, 0.8);
  box-shadow: 0 28px 70px var(--shadow);
  backdrop-filter: blur(18px);
}

.pay-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.pay-row strong {
  color: var(--mint);
  font-family: Orbitron, Inter, sans-serif;
}

.auto-spin-control,
.language-control,
.test-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(8, 14, 13, 0.64);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.language-control {
  cursor: default;
}

.auto-spin-control input[type="checkbox"] {
  position: absolute;
  opacity: 0;
}

.language-control select,
.timed-seconds-input {
  min-height: 30px;
  border: 1px solid rgba(97, 242, 194, 0.26);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.32);
  color: var(--ink);
  font-weight: 900;
}

.timed-seconds-input {
  width: 58px;
  padding: 0 6px;
  color-scheme: dark;
}

.auto-spin-control span {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.auto-spin-control span::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  transition: transform 160ms ease, background 160ms ease;
  content: "";
}

.auto-spin-control input:checked + span {
  background: rgba(97, 242, 194, 0.7);
}

.auto-spin-control input:checked + span::after {
  background: #06201a;
  transform: translateX(18px);
}

.celebrate {
  animation: machineWin 850ms ease both;
}

.machine-blackout {
  animation: machineBlackout 720ms ease both;
  filter: saturate(0.38) brightness(0.56);
}

@keyframes pop {
  0% {
    transform: translateX(50%) scale(0.82);
  }
  60% {
    transform: translateX(50%) scale(1.08);
  }
  100% {
    transform: translateX(50%) scale(1);
  }
}

@keyframes dangerPop {
  0% {
    transform: translateX(50%) scale(0.8);
  }
  45% {
    transform: translateX(50%) scale(1.14);
  }
  100% {
    transform: translateX(50%) scale(1);
  }
}

@keyframes machineBlackout {
  0%,
  100% {
    box-shadow:
      0 28px 70px var(--shadow),
      inset 0 0 0 8px rgba(255, 255, 255, 0.035),
      inset 0 0 36px rgba(255, 209, 102, 0.16);
  }
  22% {
    box-shadow:
      0 28px 70px var(--shadow),
      inset 0 0 0 8px rgba(255, 77, 125, 0.12),
      inset 0 0 44px rgba(255, 77, 125, 0.46),
      0 0 52px rgba(255, 77, 125, 0.38);
  }
  44% {
    box-shadow:
      0 28px 70px var(--shadow),
      inset 0 0 0 8px rgba(255, 255, 255, 0.018),
      inset 0 0 22px rgba(255, 77, 125, 0.16);
  }
  66% {
    box-shadow:
      0 28px 70px var(--shadow),
      inset 0 0 0 8px rgba(255, 77, 125, 0.1),
      inset 0 0 36px rgba(255, 77, 125, 0.34),
      0 0 36px rgba(255, 77, 125, 0.24);
  }
}

@keyframes timerRailDrain {
  from {
    transform: scaleY(1);
  }
  to {
    transform: scaleY(0);
  }
}

@keyframes levelConfettiFall {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  8% {
    opacity: 1;
  }
  82% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--fall-x, 0), var(--fall-y, calc(100vh + 260px)), 0) rotate(var(--fall-rot, 620deg));
  }
}

@keyframes levelUpText {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.55);
    filter: blur(10px);
  }
  18% {
    opacity: 1;
    filter: blur(0);
  }
  58% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -54%) scale(1.22);
    filter: blur(4px);
  }
}

@keyframes machineWin {
  0%,
  100% {
    box-shadow:
      0 28px 70px var(--shadow),
      inset 0 0 0 8px rgba(255, 255, 255, 0.035),
      inset 0 0 36px rgba(255, 209, 102, 0.16);
  }
  45% {
    box-shadow:
      0 28px 70px var(--shadow),
      inset 0 0 0 8px rgba(255, 255, 255, 0.05),
      0 0 44px rgba(255, 209, 102, 0.8),
      0 0 64px rgba(97, 242, 194, 0.35);
  }
}

@keyframes cellPop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes moneyHit {
  0%,
  100% {
    transform: scale(1);
    filter: none;
  }
  45% {
    transform: scale(1.08);
    filter: drop-shadow(0 0 12px rgba(255, 209, 102, 0.85));
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  35% {
    transform: translateX(-5px);
  }
  70% {
    transform: translateX(5px);
  }
}

@keyframes drawBoardLine {
  0% {
    opacity: 1;
    transform: rotate(var(--line-angle, 0deg)) scaleX(0);
  }
  100% {
    opacity: 1;
    transform: rotate(var(--line-angle, 0deg)) scaleX(1);
  }
}

@keyframes coinFly {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35) rotate(0);
  }
  12% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform:
      translate(calc(-50% + var(--coin-x)), calc(-50% + var(--coin-y)))
      scale(1)
      rotate(var(--coin-rot));
  }
}

@keyframes bankCoinDrop {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.56) rotate(0);
  }
  82% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform:
      translate(calc(-50% + var(--bank-x)), calc(-50% + var(--bank-y)))
      scale(0.78)
      rotate(var(--bank-rot));
  }
}

@keyframes confettiFly {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4) rotate(0);
  }
  12% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform:
      translate(calc(-50% + var(--confetti-x)), calc(-50% + var(--confetti-y)))
      scale(1)
      rotate(var(--confetti-rot));
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 520px);
    padding: 10px 0 22px;
  }

  .machine {
    padding: 12px;
    border-radius: 18px;
  }

  .status-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .stat {
    padding: 8px 6px;
  }

  .stat span {
    font-size: 0.62rem;
  }

  .stat strong {
    font-size: clamp(1rem, 6vw, 1.35rem);
  }

  .paytable {
    grid-template-columns: 1fr 1fr;
    padding: 14px;
  }

  .reel-window {
    padding: 10px;
    border-width: 5px;
  }

  .reels {
    gap: 6px;
  }

  .reel {
    height: clamp(96px, 28vw, 132px);
    border-radius: 8px;
  }
}
