:root {
  --cabinet: #2b1a08;
  --sand: #e8c27a;
  --turquoise: #2ee6c8;
}

body {
  background-image:
    radial-gradient(ellipse 50% 30% at 50% 0%, rgba(232, 194, 122, 0.1), transparent 70%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='800' height='500' viewBox='0 0 800 500'><defs><linearGradient id='sky' x1='0' y1='0' x2='0' y2='1'><stop offset='0%25' stop-color='%233a1a1a'/><stop offset='55%25' stop-color='%235c3018'/><stop offset='100%25' stop-color='%231a0f04'/></linearGradient></defs><rect width='800' height='500' fill='url(%23sky)'/><circle cx='420' cy='140' r='75' fill='%23e8c27a' opacity='0.4'/><polygon points='120,420 240,200 360,420' fill='%23140b04' opacity='0.6'/><polygon points='300,420 430,160 560,420' fill='%230d0702' opacity='0.75'/><polygon points='500,420 600,250 700,420' fill='%23140b04' opacity='0.55'/><rect y='405' width='800' height='95' fill='%231a0f04'/></svg>");
  background-color: var(--bg-dark);
  background-repeat: no-repeat, no-repeat;
  background-position: top, bottom center;
  background-size: cover, cover;
  background-attachment: fixed, fixed;
}

.cabinet {
  background: linear-gradient(160deg, var(--cabinet), #1a0f04);
  border: 4px solid var(--sand);
  border-radius: 24px;
  padding: 24px 28px 30px;
  width: 620px;
  max-width: 95vw;
  box-shadow: 0 0 40px rgba(232, 194, 122, 0.25), inset 0 0 30px rgba(46, 230, 200, 0.12);
  text-align: center;
  position: relative;
}

.title {
  margin: 0 0 12px;
  font-size: 1.5rem;
  letter-spacing: 2px;
  color: var(--sand);
  text-shadow: 0 0 8px var(--sand), 0 0 20px var(--turquoise);
  animation: title-pulse 2.4s ease-in-out infinite;
}

.bonus-banner {
  background: linear-gradient(90deg, var(--turquoise), var(--sand));
  color: #1a0f04;
  font-weight: bold;
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 12px;
  animation: pulse 1s infinite alternate;
}
.bonus-banner.hidden { display: none; }

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.02); }
}

.screen {
  position: relative;
  background: #0d0702;
  border: 3px solid #6b4a1f;
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
}

.cell {
  background: linear-gradient(145deg, #3a2410, #1a0f04);
  border: 2px solid #6b4a1f;
  border-radius: 10px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.cell.win {
  animation: cell-win-glow 0.8s ease-in-out infinite alternate;
  z-index: 1;
}
@keyframes cell-win-glow {
  from { border-color: var(--turquoise); box-shadow: 0 0 10px var(--turquoise), inset 0 0 8px var(--turquoise); }
  to   { border-color: #baffef; box-shadow: 0 0 22px var(--turquoise), inset 0 0 16px var(--turquoise); }
}

.cell.win .symbol {
  animation: symbol-win-pop 0.5s ease-in-out infinite alternate;
}
@keyframes symbol-win-pop {
  from { transform: scale(1); }
  to   { transform: scale(1.12); }
}

.cell.expanded {
  animation: cell-expand-flash 0.5s ease-out;
  border-color: var(--sand);
  box-shadow: 0 0 16px var(--sand), inset 0 0 12px var(--sand);
}
@keyframes cell-expand-flash {
  0%   { transform: scale(0.85); filter: brightness(1.8); }
  100% { transform: scale(1); filter: brightness(1); }
}

.symbol {
  font-size: 2.1rem;
  display: inline-block;
  will-change: transform;
}

.symbol.card-rank {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: bold;
  font-size: 1.7rem;
  color: var(--sand);
  background: rgba(232, 194, 122, 0.12);
  border: 1px solid var(--sand);
  border-radius: 8px;
  padding: 4px 10px;
}

.cell.spinning .symbol {
  animation: spin-blur 0.12s linear infinite;
}

@keyframes spin-blur {
  0%   { transform: translateY(-40%); filter: blur(2px); opacity: 0.6; }
  50%  { transform: translateY(0%); filter: blur(0.5px); opacity: 1; }
  100% { transform: translateY(40%); filter: blur(2px); opacity: 0.6; }
}

.payline-overlay {
  position: absolute;
  inset: 10px;
  width: calc(100% - 20px);
  height: calc(100% - 20px);
  pointer-events: none;
}

.payline-overlay polyline {
  stroke: var(--turquoise);
  fill: none;
  stroke-width: 4;
  opacity: 0;
  filter: drop-shadow(0 0 4px var(--turquoise));
}

.payline-overlay polyline.show {
  opacity: 0.95;
  animation: dash-move 0.5s linear infinite, line-glow-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes dash-move {
  from { stroke-dashoffset: 20; }
  to { stroke-dashoffset: 0; }
}

@keyframes line-glow-pulse {
  from { filter: drop-shadow(0 0 4px var(--turquoise)); }
  to   { filter: drop-shadow(0 0 12px var(--turquoise)); }
}

.message {
  min-height: 22px;
  font-size: 0.95rem;
  color: var(--turquoise);
  margin-bottom: 10px;
}

.hud {
  display: flex;
  justify-content: space-between;
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 14px;
}

.stat { display: flex; flex-direction: column; font-size: 0.85rem; }
.stat label { color: #c9a877; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px; }
.stat span { font-size: 1.1rem; font-weight: bold; color: var(--sand); }

.controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.btn {
  font-family: inherit;
  font-weight: bold;
  border: none;
  border-radius: 10px;
  padding: 10px 8px;
  cursor: pointer;
  background: linear-gradient(160deg, #4a3318, #241608);
  color: var(--text);
  transition: transform 0.08s, box-shadow 0.15s;
}
.btn:hover { box-shadow: 0 0 10px var(--turquoise); }
.btn:active { transform: scale(0.95); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.btn.spin {
  grid-column: span 4;
  background: linear-gradient(160deg, var(--sand), #a97e2f);
  color: #241608;
  font-size: 1.2rem;
  letter-spacing: 2px;
  padding: 14px;
  order: -1;
}

.btn.small { font-size: 0.85rem; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.modal.hidden { display: none; }

.modal-content {
  background: var(--cabinet);
  border: 3px solid var(--sand);
  border-radius: 16px;
  padding: 20px 24px;
  width: 340px;
  max-width: 90vw;
}
.modal-content h2 { color: var(--sand); margin-top: 0; }
.modal-content .hint { font-size: 0.8rem; color: #d8c19a; }

.paytable-list { list-style: none; padding: 0; margin: 12px 0; }
.paytable-list li {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dashed #6b4a1f;
  font-size: 0.95rem;
}
.paytable-list li span:last-child { color: var(--sand); font-weight: bold; }

.gamble-content { text-align: center; }
.card-reveal {
  width: 90px;
  height: 120px;
  margin: 14px auto;
  border: 3px solid var(--sand);
  border-radius: 12px;
  background: linear-gradient(160deg, #3a2410, #1a0f04);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: bold;
}
.card-reveal.red { color: #ff4d6d; }
.card-reveal.black { color: #cfc4ef; }

.gamble-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.gamble-btn { flex: 1; padding: 14px; font-size: 1rem; }
.gamble-btn.red { background: linear-gradient(160deg, #ff4d6d, #a0192f); }
.gamble-btn.black { background: linear-gradient(160deg, #3a2a4a, #14101c); }

.collect-btn { width: 100%; }

@keyframes flash {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.6); }
}
.win-flash { animation: flash 0.3s ease-in-out 3; }
