:root {
  --bg-0: #07060a;
  --bg-1: #110b14;
  --gold-0: #fff3c4;
  --gold-1: #f4c64a;
  --gold-2: #b3812a;
  --gold-3: #6e4a16;
  --silver-0: #f2f4f8;
  --silver-1: #b8bdc9;
  --silver-2: #6b7080;
  --ink: #efe7d2;
  --crimson: #d8324b;
  --reel-gap: 6px;
  --cols: 5;
  --rows: 4;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vw, 40px);
  font-family: "Cormorant Garamond", Georgia, serif;
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 50% -10%, #1b1320 0%, var(--bg-1) 38%, var(--bg-0) 100%),
    var(--bg-0);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.cabinet {
  width: min(760px, 100%);
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2.4vw, 26px);
}

/* ---------- masthead ---------- */
.masthead { text-align: center; }
.title-rule {
  width: 120px; height: 2px; margin: 0 auto 14px;
  background: linear-gradient(90deg, transparent, var(--gold-1), transparent);
}
.masthead h1 {
  font-family: "Cinzel", serif;
  font-weight: 900;
  font-size: clamp(34px, 7vw, 58px);
  letter-spacing: 0.14em;
  line-height: 1;
  background: linear-gradient(180deg, var(--gold-0) 8%, var(--gold-1) 42%, var(--gold-2) 70%, var(--gold-0) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6));
}
.subtitle {
  margin-top: 8px;
  font-style: italic;
  letter-spacing: 0.18em;
  font-size: clamp(12px, 2.2vw, 15px);
  color: var(--silver-2);
}

/* ---------- machine / frame ---------- */
.machine { perspective: 1400px; }
.frame {
  position: relative;
  padding: clamp(10px, 2vw, 18px);
  border-radius: 18px;
  background:
    linear-gradient(160deg, #1a1410, #0b0a0d 60%),
    var(--bg-1);
  box-shadow:
    0 0 0 2px var(--gold-3),
    0 0 0 4px #120d08,
    0 0 0 6px var(--gold-2),
    0 26px 60px -18px rgba(0,0,0,0.85),
    inset 0 0 60px rgba(0,0,0,0.7);
}
.frame::before {
  content: "";
  position: absolute; inset: 6px;
  border-radius: 12px;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(255,243,196,0.10), transparent 30%, transparent 70%, rgba(255,243,196,0.06));
  mix-blend-mode: screen;
}

.reels {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: var(--reel-gap);
  border-radius: 10px;
  background: #050407;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.9), inset 0 0 0 1px rgba(255,243,196,0.08);
  overflow: hidden;
}

.reel {
  position: relative;
  aspect-ratio: 1 / var(--rows);
  overflow: hidden;
}
.reel .strip {
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.cell {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
  background: #050407;
}
.cell img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}
.cell::after {
  content: "";
  position: absolute; inset: 0;
  box-shadow: inset 0 0 22px rgba(0,0,0,0.65);
  pointer-events: none;
}

/* winning cell highlight */
.cell.win::after {
  box-shadow: inset 0 0 0 3px var(--gold-1), inset 0 0 24px rgba(244,198,74,0.55);
  animation: winPulse 0.9s ease-in-out infinite alternate;
}
@keyframes winPulse {
  from { box-shadow: inset 0 0 0 3px rgba(244,198,74,0.55), inset 0 0 18px rgba(244,198,74,0.35); }
  to   { box-shadow: inset 0 0 0 3px var(--gold-0), inset 0 0 34px rgba(255,243,196,0.8); }
}
.cell.dim img { filter: brightness(0.4) saturate(0.7); transition: filter 0.3s; }

/* glass + vignette over reels */
.reels::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.55), transparent 18%, transparent 82%, rgba(0,0,0,0.6)),
    radial-gradient(140% 100% at 50% 50%, transparent 55%, rgba(0,0,0,0.55));
}

.win-banner {
  position: absolute;
  left: 50%; bottom: clamp(16px, 4vw, 30px);
  transform: translate(-50%, 20px);
  padding: 8px 26px;
  font-family: "Cinzel", serif;
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: clamp(16px, 3.4vw, 24px);
  color: #1a1206;
  background: linear-gradient(180deg, var(--gold-0), var(--gold-1) 55%, var(--gold-2));
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6), inset 0 0 0 1px rgba(255,255,255,0.5);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
.win-banner.show {
  animation: bannerIn 0.5s cubic-bezier(0.2,1.4,0.4,1) forwards;
}
@keyframes bannerIn {
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- console ---------- */
.console {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(10px, 2.5vw, 24px);
  padding: clamp(12px, 2vw, 18px) clamp(14px, 3vw, 26px);
  border-radius: 14px;
  background: linear-gradient(180deg, #15100c, #0a0709);
  box-shadow: inset 0 0 0 1px rgba(255,243,196,0.12), 0 18px 40px -20px rgba(0,0,0,0.8);
}
.meter { text-align: center; display: flex; flex-direction: column; gap: 4px; }
.meter-label {
  font-size: 11px; letter-spacing: 0.25em; text-transform: uppercase;
  color: var(--silver-2);
}
.meter-value {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: clamp(20px, 4.5vw, 30px);
  color: var(--gold-0);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 rgba(0,0,0,0.6);
}
.win-meter .meter-value { color: var(--silver-0); }

.bet-control { display: flex; align-items: center; gap: 10px; }
.bet-readout { display: flex; flex-direction: column; gap: 2px; min-width: 54px; text-align: center; }
.bet-readout .meter-value { font-size: clamp(16px, 3.6vw, 22px); }
.bet-btn {
  width: 38px; height: 38px;
  border: none; border-radius: 50%;
  font-size: 22px; font-weight: 700; line-height: 1;
  color: var(--gold-0);
  background: radial-gradient(circle at 35% 30%, #3a2c15, #1a130a);
  box-shadow: inset 0 0 0 1px var(--gold-3), 0 2px 6px rgba(0,0,0,0.6);
  cursor: pointer; transition: transform 0.08s, filter 0.15s;
}
.bet-btn:hover { filter: brightness(1.3); }
.bet-btn:active { transform: scale(0.92); }

.spin {
  position: relative;
  width: clamp(96px, 22vw, 128px);
  height: clamp(96px, 22vw, 128px);
  border: none; border-radius: 50%;
  cursor: pointer;
  background:
    radial-gradient(circle at 38% 32%, var(--crimson), #7c1322 62%, #45070f 100%);
  box-shadow:
    0 0 0 3px var(--gold-2),
    0 0 0 6px #160d06,
    0 0 0 8px var(--gold-3),
    0 14px 30px -8px rgba(0,0,0,0.8),
    inset 0 6px 14px rgba(255,255,255,0.25),
    inset 0 -10px 18px rgba(0,0,0,0.5);
  transition: transform 0.1s, filter 0.15s;
}
.spin-face {
  font-family: "Cinzel", serif; font-weight: 900;
  font-size: clamp(16px, 3.6vw, 22px);
  letter-spacing: 0.1em;
  color: var(--gold-0);
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
}
.spin:hover { filter: brightness(1.08); }
.spin:active { transform: scale(0.95); }
.spin:disabled { cursor: default; filter: grayscale(0.5) brightness(0.7); }
.spin.spinning .spin-face { animation: faceFade 0.6s ease-in-out infinite alternate; }
@keyframes faceFade { to { opacity: 0.45; } }

/* ---------- ticker ---------- */
.ticker {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 6px;
  font-size: 13px; color: var(--silver-2);
}
.hint { letter-spacing: 0.08em; }
kbd {
  font-family: inherit;
  padding: 1px 7px; border-radius: 5px;
  background: #1c1620; color: var(--gold-0);
  box-shadow: inset 0 0 0 1px rgba(255,243,196,0.2);
}
.ghost-btn {
  background: none; border: none; cursor: pointer;
  font-family: "Cormorant Garamond", serif; font-size: 14px;
  letter-spacing: 0.1em; color: var(--gold-1);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s, color 0.2s;
}
.ghost-btn:hover { color: var(--gold-0); border-color: var(--gold-2); }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(4,3,7,0.78);
  backdrop-filter: blur(6px);
}
.modal[hidden] { display: none; }
.modal-card {
  position: relative;
  width: min(540px, 100%);
  max-height: 86vh; overflow-y: auto;
  padding: 28px clamp(20px, 4vw, 36px);
  border-radius: 16px;
  background: linear-gradient(180deg, #15100c, #0a0709);
  box-shadow: 0 0 0 2px var(--gold-2), 0 0 0 4px #120d08, 0 30px 70px rgba(0,0,0,0.8);
}
.modal-card h2 {
  font-family: "Cinzel", serif; font-weight: 700;
  letter-spacing: 0.1em; color: var(--gold-0);
  margin-bottom: 6px;
}
.modal-note { color: var(--silver-2); margin-bottom: 18px; font-style: italic; }
.modal-close {
  position: absolute; top: 12px; right: 16px;
  background: none; border: none; cursor: pointer;
  font-size: 28px; line-height: 1; color: var(--silver-2);
}
.modal-close:hover { color: var(--gold-0); }

.paytable-grid { display: flex; flex-direction: column; gap: 10px; }
.pt-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,243,196,0.03);
  box-shadow: inset 0 0 0 1px rgba(255,243,196,0.07);
}
.pt-row img {
  width: 56px; height: 56px; border-radius: 8px; object-fit: cover;
  box-shadow: inset 0 0 0 1px rgba(255,243,196,0.2);
}
.pt-name { font-size: 18px; color: var(--ink); }
.pt-name small { display: block; color: var(--silver-2); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; }
.pt-pays { display: flex; gap: 14px; font-variant-numeric: tabular-nums; }
.pt-pays span { text-align: center; color: var(--silver-1); font-size: 13px; }
.pt-pays b { display: block; color: var(--gold-0); font-size: 17px; font-family: "Cinzel", serif; }

@media (max-width: 460px) {
  .console { grid-template-columns: 1fr 1fr; grid-template-areas: "credits win" "bet spin"; gap: 14px; }
  .meter:first-child { grid-area: credits; }
  .win-meter { grid-area: win; }
  .bet-control { grid-area: bet; justify-content: center; }
  .spin { grid-area: spin; justify-self: center; }
  .pt-pays { gap: 8px; }
}
