:root {
  --bg-deep: #050b16;
  --bg-mid: #0a1830;
  --panel: rgba(12, 29, 55, 0.86);
  --panel-strong: rgba(8, 20, 39, 0.96);
  --gold: #e7bd57;
  --gold-light: #fff0a2;
  --cyan: #72e8ff;
  --red: #ff4f6d;
  --green: #78f0b4;
  --text: #f7f3e8;
  --muted: #9eb0c9;
  --cell: clamp(82px, 24vw, 152px);
  --gap: clamp(6px, 1.5vw, 12px);
  --radius: 28px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 50% -10%, rgba(75, 125, 218, .36), transparent 36%),
    radial-gradient(circle at 85% 10%, rgba(229, 183, 67, .12), transparent 32%),
    linear-gradient(180deg, var(--bg-mid), var(--bg-deep) 55%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .22;
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app {
  width: min(100%, 1120px);
  margin: 0 auto;
  min-height: 100vh;
  padding: max(18px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
  display: grid;
  align-content: center;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 238, 154, .68);
  background: radial-gradient(circle, rgba(255,244,177,.3), rgba(231,189,87,.08) 55%, transparent 72%);
  box-shadow: 0 0 24px rgba(231,189,87,.2);
  overflow: hidden;
}

.brand-mark img { width: 76%; height: 76%; object-fit: contain; }
.brand-copy { min-width: 0; }

.eyebrow {
  color: var(--gold-light);
  letter-spacing: .22em;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 0;
  font-size: clamp(22px, 4vw, 38px);
  line-height: 1;
  letter-spacing: -.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.14);
  color: var(--text);
  background: rgba(9, 22, 43, .74);
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}

.icon-button:hover { background: rgba(18, 42, 76, .9); }
.icon-button:active { transform: scale(.94); }

.machine {
  position: relative;
  border: 1px solid rgba(255, 231, 152, .38);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255,255,255,.07), transparent 12%),
    linear-gradient(180deg, rgba(13, 34, 66, .94), rgba(5, 14, 29, .98));
  box-shadow:
    0 36px 70px rgba(0,0,0,.44),
    inset 0 0 0 2px rgba(255,255,255,.025),
    0 0 54px rgba(61, 123, 219, .13);
  overflow: hidden;
}

.machine::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0 6%, rgba(255,255,255,.035) 6.2%, transparent 6.4% 93.6%, rgba(255,255,255,.035) 93.8%, transparent 94%),
    radial-gradient(circle at 50% 0, rgba(231,189,87,.15), transparent 34%);
}

.marquee {
  position: relative;
  padding: 14px 18px 12px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 231, 152, .26);
  background:
    linear-gradient(180deg, rgba(233,190,87,.18), rgba(233,190,87,.04)),
    rgba(0,0,0,.15);
}

.marquee-title {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 900;
  font-size: clamp(20px, 4vw, 36px);
  letter-spacing: .12em;
  color: #fff4be;
  text-shadow: 0 0 18px rgba(231,189,87,.44), 0 2px 0 rgba(0,0,0,.6);
  text-transform: uppercase;
}

.marquee-sub {
  margin-top: 3px;
  color: rgba(255,255,255,.62);
  letter-spacing: .15em;
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
}

.status-strip {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px 14px 0;
}

.meter {
  padding: 9px 10px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 14px;
  background: rgba(4, 12, 26, .58);
  text-align: center;
  min-width: 0;
}

.meter-label {
  display: block;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 800;
}

.meter-value {
  display: block;
  margin-top: 2px;
  color: #fff;
  font-size: clamp(18px, 4vw, 28px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(114, 232, 255, .18);
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage {
  position: relative;
  padding: 16px 14px;
  display: grid;
  place-items: center;
}

.reel-frame {
  position: relative;
  width: calc(var(--cell) * 3 + var(--gap) * 2 + 22px);
  max-width: 100%;
  padding: 11px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, #f8dfa0, #9f6f1c 30%, #52340d 54%, #b98625 78%, #f6d77f),
    #b78428;
  box-shadow:
    0 20px 42px rgba(0,0,0,.45),
    inset 0 2px 2px rgba(255,255,255,.55),
    inset 0 -2px 4px rgba(39,19,0,.62),
    0 0 0 1px rgba(255,233,159,.35);
}

.reel-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, var(--cell));
  gap: var(--gap);
  border-radius: 15px;
  overflow: hidden;
  background: #020711;
  box-shadow: inset 0 0 25px rgba(0,0,0,.9);
}

.reel {
  position: relative;
  width: var(--cell);
  height: calc(var(--cell) * 3);
  overflow: hidden;
  background: linear-gradient(90deg, #eef2f4, #fff 48%, #dbe0e4);
  isolation: isolate;
}

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

.reel::before { top: 0; background: linear-gradient(#09101a99, transparent); }
.reel::after { bottom: 0; background: linear-gradient(transparent, #09101a99); }

.reel-strip {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

.symbol-cell {
  width: var(--cell);
  height: var(--cell);
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-bottom: 1px solid rgba(9, 25, 45, .14);
  background: radial-gradient(circle at 50% 35%, rgba(255,255,255,.98), rgba(234,239,243,.88) 55%, rgba(196,205,212,.86));
}

.symbol-cell img {
  width: 92%;
  height: 92%;
  object-fit: contain;
  filter: drop-shadow(0 5px 6px rgba(0,0,0,.18));
  user-select: none;
  -webkit-user-drag: none;
}

.symbol-cell.is-win::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 16px;
  border: 4px solid var(--gold-light);
  box-shadow: inset 0 0 22px rgba(255,231,107,.72), 0 0 22px rgba(255,211,72,.82);
  animation: winPulse .62s ease-in-out infinite alternate;
  z-index: 3;
}

@keyframes winPulse {
  from { opacity: .56; transform: scale(.98); }
  to { opacity: 1; transform: scale(1.02); }
}

.grid-shine {
  position: absolute;
  inset: 11px;
  border-radius: 15px;
  pointer-events: none;
  z-index: 8;
  background: linear-gradient(115deg, transparent 18%, rgba(255,255,255,.18) 35%, transparent 48%);
  transform: translateX(-120%);
}

.machine.is-spinning .grid-shine { animation: sweep 1.2s ease-in-out infinite; }

@keyframes sweep {
  0% { transform: translateX(-130%); }
  100% { transform: translateX(130%); }
}

.paylines {
  position: absolute;
  inset: 11px;
  width: calc(100% - 22px);
  height: calc(100% - 22px);
  pointer-events: none;
  z-index: 9;
  overflow: visible;
}

.payline {
  fill: none;
  stroke-width: 4.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  filter: drop-shadow(0 0 5px currentColor);
}

.payline.active {
  opacity: 1;
  animation: lineFlash .7s ease-in-out infinite alternate;
}

@keyframes lineFlash { from { opacity: .42; } to { opacity: 1; } }

.message {
  min-height: 54px;
  margin: 0 14px;
  display: grid;
  place-items: center;
  padding: 8px 14px 12px;
  text-align: center;
  color: #d8e5f8;
  font-weight: 750;
  letter-spacing: .01em;
}

.message.win {
  color: #fff0a2;
  text-shadow: 0 0 18px rgba(231,189,87,.4);
}

.controls {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,.1);
  background: rgba(3, 10, 22, .54);
}

.bet-control,
.utility-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.utility-controls { justify-content: flex-end; }

.small-button {
  min-height: 44px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 13px;
  color: #eaf2ff;
  background: rgba(18, 40, 72, .72);
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, opacity .15s ease;
}

.small-button:hover { background: rgba(31, 62, 105, .86); }
.small-button:active { transform: translateY(1px) scale(.98); }
.small-button:disabled { opacity: .42; cursor: not-allowed; }

.bet-readout {
  min-width: 74px;
  text-align: center;
  color: var(--gold-light);
  font-size: 19px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.bet-readout small {
  display: block;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.spin-button {
  position: relative;
  width: clamp(88px, 18vw, 118px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 4px solid #f8d879;
  color: #102215;
  background: radial-gradient(circle at 50% 34%, #d8ffe7, #75eab1 46%, #2a9c69 72%, #15563c);
  box-shadow:
    0 0 0 5px rgba(18, 74, 51, .85),
    0 0 0 7px rgba(246, 215, 121, .85),
    0 16px 30px rgba(0,0,0,.45),
    inset 0 5px 8px rgba(255,255,255,.45),
    inset 0 -8px 12px rgba(0,0,0,.26),
    0 0 30px rgba(96, 242, 166, .2);
  font-weight: 1000;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform .12s ease, filter .2s ease;
  z-index: 1;
}

.spin-button::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.48);
  pointer-events: none;
}

.spin-button:hover { filter: brightness(1.08); }
.spin-button:active { transform: translateY(3px) scale(.97); }
.spin-button:disabled { filter: grayscale(.4) brightness(.68); cursor: not-allowed; }

.paytable {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0 14px 14px;
}

.pay-card {
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 13px;
  background: rgba(4, 13, 28, .55);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pay-card img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex: 0 0 auto;
}

.pay-card strong {
  display: block;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pay-card span {
  display: block;
  color: var(--gold-light);
  font-size: 12px;
  font-weight: 900;
}

.footer-note {
  text-align: center;
  color: rgba(206, 220, 240, .55);
  font-size: 12px;
  padding: 0 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 16px;
  background: rgba(1, 5, 12, .78);
  backdrop-filter: blur(10px);
}

.modal-backdrop.open { display: grid; }

.modal {
  width: min(100%, 560px);
  max-height: 82vh;
  overflow: auto;
  border: 1px solid rgba(255, 229, 145, .28);
  border-radius: 22px;
  background: linear-gradient(180deg, #10284a, #071426);
  box-shadow: 0 34px 80px rgba(0,0,0,.62);
  padding: 20px;
}

.modal h2 { margin: 0 0 12px; }
.modal p, .modal li { color: #bfd0e6; line-height: 1.55; }
.modal ul { padding-left: 20px; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 18px; }

.coin-particle {
  position: fixed;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #ffe59a;
  background: radial-gradient(circle at 35% 30%, #fff8c4, #e7b93d 52%, #8f5910 78%);
  box-shadow: 0 0 12px rgba(255, 213, 84, .6);
  pointer-events: none;
  z-index: 80;
  animation: coinBurst var(--duration) cubic-bezier(.15,.76,.22,1) forwards;
}

@keyframes coinBurst {
  0% { transform: translate(0,0) rotate(0deg) scale(.4); opacity: 0; }
  12% { opacity: 1; }
  100% { transform: translate(var(--x), var(--y)) rotate(var(--r)) scale(1); opacity: 0; }
}

.screen-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 70;
  background: radial-gradient(circle, rgba(255,242,171,.34), transparent 58%);
  opacity: 0;
}

.screen-flash.active { animation: flash .65s ease-out; }
@keyframes flash { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }

@media (max-width: 720px) {
  .app { align-content: start; }
  .controls { grid-template-columns: 1fr auto 1fr; gap: 7px; }
  .small-button { padding: 0 10px; min-height: 40px; }
  .utility-controls .label { display: none; }
  .paytable { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 430px) {
  :root { --gap: 5px; --cell: min(28vw, 112px); }
  .app { padding-left: 8px; padding-right: 8px; }
  .brand-mark { width: 40px; height: 40px; }
  .stage { padding-left: 6px; padding-right: 6px; }
  .reel-frame { padding: 7px; width: calc(var(--cell) * 3 + var(--gap) * 2 + 14px); }
  .grid-shine, .paylines { inset: 7px; width: calc(100% - 14px); height: calc(100% - 14px); }
  .controls { padding: 12px 8px; }
  .bet-control, .utility-controls { gap: 4px; }
  .small-button { min-width: 40px; padding: 0 8px; }
  .spin-button { width: 86px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
