:root {
  --bg-deep: #041d12;
  --bg-emerald: #0a3b24;
  --gold-light: #fff0a6;
  --gold: #f5c542;
  --gold-dark: #b67b14;
  --emerald-bright: #16d178;
  --emerald-mid: #0e8a4e;
  --panel-bg: rgba(5, 32, 20, 0.92);
  --border-gold: rgba(245, 197, 66, 0.55);
  --text-main: #f7fff9;
  --text-muted: #9fd8b9;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 20%, #0f5633 0%, #052617 55%, #02120b 100%);
  color: var(--text-main);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-shell {
  width: 100%;
  max-width: 410px;
  height: 100dvh;
  max-height: 856px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #0b4a2b 0%, #062a19 42%, #041b10 100%);
  border-left: 1px solid rgba(245, 197, 66, 0.25);
  border-right: 1px solid rgba(245, 197, 66, 0.25);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 240, 166, 0.22);
  position: relative;
  overflow: hidden;
}

@media (min-width: 500px) {
  .game-shell {
    border-radius: 22px;
    border: 2px solid rgba(245, 197, 66, 0.45);
    height: min(94dvh, 844px);
  }
}

/* Header */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 4px;
  background: linear-gradient(180deg, rgba(2, 22, 13, 0.9), rgba(2, 22, 13, 0.2));
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-clover {
  font-size: 24px;
  color: #3df596;
  text-shadow: 0 0 10px rgba(61, 245, 150, 0.7);
}

.brand-text h1 {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.7px;
  background: linear-gradient(180deg, #fff8cc 0%, #f5c542 60%, #c68612 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}

.ways-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.9px;
  color: #042415;
  background: linear-gradient(90deg, #74f7b1, #f5c542);
  padding: 1px 6px;
  border-radius: 99px;
}

.top-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border-gold);
  background: rgba(6, 40, 24, 0.85);
  color: var(--gold-light);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, background 0.15s;
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn.muted {
  opacity: 0.55;
}

/* Hero Stage */
.hero-stage {
  position: relative;
  margin: 2px 8px 4px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(16, 86, 51, 0.85), rgba(5, 36, 21, 0.92));
  border: 1.5px solid rgba(245, 197, 66, 0.45);
  overflow: hidden;
  flex-shrink: 0;
}

#heroCanvas {
  display: block;
  width: 100%;
  height: 70px;
}

.fs-banner {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(18, 92, 42, 0.92), rgba(154, 96, 8, 0.92), rgba(18, 92, 42, 0.92));
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 12px;
  border-radius: 10px;
  animation: fsPulse 1.6s ease-in-out infinite;
}

@keyframes fsPulse {
  0%, 100% { box-shadow: inset 0 0 16px rgba(255, 224, 102, 0.4); }
  50% { box-shadow: inset 0 0 28px rgba(255, 224, 102, 0.85); }
}

.fs-pill, .mult-pill {
  font-size: 13px;
  font-weight: 800;
  color: #fffbe0;
  background: rgba(4, 24, 14, 0.65);
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--gold);
}

.fs-pill strong, .mult-pill strong {
  color: #ffe055;
  font-size: 16px;
}

.ticker-banner {
  background: rgba(2, 18, 10, 0.78);
  text-align: center;
  padding: 3px 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--gold-light);
  border-top: 1px solid rgba(245, 197, 66, 0.25);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main Reel Frame */
.reel-frame {
  flex: 1 1 auto;
  min-height: 0;
  margin: 4px 8px;
  border-radius: 14px;
  border: 2.5px solid var(--gold);
  box-shadow: 0 0 18px rgba(245, 197, 66, 0.22), inset 0 0 24px rgba(0, 0, 0, 0.65);
  background: linear-gradient(180deg, #062817 0%, #03190e 100%);
  position: relative;
  overflow: hidden;
}

#reelCanvas, #fxCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#fxCanvas {
  pointer-events: none;
}

/* Overlay Banner */
.overlay-banner {
  position: absolute;
  inset: 0;
  background: rgba(2, 16, 9, 0.72);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  animation: fadeIn 0.22s ease;
}

.overlay-card {
  text-align: center;
  padding: 18px 26px;
  border-radius: 18px;
  background: radial-gradient(circle at 50% 30%, #156e3f, #06301b 75%);
  border: 2.5px solid #ffd859;
  box-shadow: 0 0 40px rgba(255, 216, 89, 0.55);
  transform: scale(1);
  animation: popIn 0.35s cubic-bezier(0.22, 1.3, 0.36, 1);
}

.overlay-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(180deg, #ffffff 0%, #ffe066 50%, #e09112 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.7));
}

.overlay-amount {
  font-size: 32px;
  font-weight: 900;
  color: #fff9d6;
  text-shadow: 0 0 14px rgba(255, 216, 89, 0.85);
  margin-top: 4px;
}

.overlay-sub {
  font-size: 12px;
  font-weight: 700;
  color: #88f7be;
  margin-top: 4px;
}

.toast {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(180, 32, 32, 0.94);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 99px;
  border: 1px solid rgba(255, 180, 180, 0.6);
  z-index: 15;
  white-space: nowrap;
}

/* HUD Strip */
.hud-strip {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1.05fr;
  gap: 6px;
  padding: 6px 8px 4px;
  flex-shrink: 0;
}

.hud-box {
  background: var(--panel-bg);
  border: 1px solid rgba(245, 197, 66, 0.35);
  border-radius: 10px;
  padding: 5px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hud-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.7px;
  color: var(--text-muted);
}

.hud-val {
  font-size: 13px;
  font-weight: 900;
  color: #ffffff;
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
}

.hud-win .hud-val {
  color: #ffe055;
}

.bet-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  margin-top: 1px;
}

.step-btn {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border-gold);
  background: linear-gradient(180deg, #16653d, #0a3c23);
  color: var(--gold-light);
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.step-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Controls Dock */
.controls-dock {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 8px 14px 12px;
  background: linear-gradient(180deg, rgba(4, 24, 14, 0.3), rgba(2, 14, 8, 0.95));
  flex-shrink: 0;
  position: relative;
}

.ctrl-btn {
  width: 72px;
  height: 48px;
  border-radius: 14px;
  border: 1.5px solid var(--border-gold);
  background: linear-gradient(180deg, #105533, #072c1a);
  color: var(--gold-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s;
}

.ctrl-btn:active {
  transform: scale(0.94);
}

.ctrl-btn.active {
  background: linear-gradient(180deg, #e5a921, #9e6508);
  color: #062112;
  border-color: #fff1a8;
  box-shadow: 0 0 14px rgba(245, 197, 66, 0.6);
}

.ctrl-icon {
  font-size: 16px;
  line-height: 1;
}

.ctrl-text {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.6px;
}

.spin-btn {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 3px solid #ffe57f;
  background: radial-gradient(circle at 35% 28%, #34f595 0%, #109b54 55%, #074f29 100%);
  color: #fffef0;
  font-weight: 900;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55), 0 0 22px rgba(45, 240, 142, 0.45);
  transition: transform 0.12s, filter 0.15s;
}

.spin-btn:active {
  transform: scale(0.93);
}

.spin-btn.spinning {
  filter: saturate(0.75) brightness(0.85);
}

.spin-btn.fs-mode {
  background: radial-gradient(circle at 35% 28%, #ffe875 0%, #e09815 60%, #8a5204 100%);
  box-shadow: 0 0 26px rgba(255, 215, 70, 0.75);
}

.spin-ring {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 1.5px dashed rgba(255, 248, 200, 0.65);
  pointer-events: none;
}

.spin-label {
  font-size: 15px;
  letter-spacing: 1px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.65);
}

.auto-wrap {
  position: relative;
}

.auto-menu {
  position: absolute;
  bottom: 56px;
  right: 0;
  background: #062a19;
  border: 1.5px solid var(--gold);
  border-radius: 12px;
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 102px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.7);
  z-index: 20;
}

.auto-opt {
  background: rgba(16, 86, 51, 0.8);
  border: 1px solid rgba(245, 197, 66, 0.3);
  color: var(--gold-light);
  font-size: 12px;
  font-weight: 800;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.auto-opt:hover {
  background: #17824b;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 390px;
  max-height: 82dvh;
  background: linear-gradient(180deg, #0b4126, #041d11);
  border: 2px solid var(--gold);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(2, 18, 10, 0.75);
  border-bottom: 1px solid rgba(245, 197, 66, 0.3);
}

.modal-head h2 {
  font-size: 16px;
  color: var(--gold-light);
}

.close-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-gold);
  background: transparent;
  color: var(--gold-light);
  cursor: pointer;
  font-weight: 800;
}

.modal-body {
  padding: 12px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rule-block {
  background: rgba(3, 22, 13, 0.7);
  border: 1px solid rgba(245, 197, 66, 0.22);
  border-radius: 10px;
  padding: 9px 11px;
}

.rule-block h3 {
  font-size: 12px;
  color: var(--gold);
  margin-bottom: 4px;
}

.rule-block p {
  font-size: 11.5px;
  line-height: 1.45;
  color: #dcf7e8;
}

.paytable-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 6px;
}

.pt-item {
  background: rgba(11, 56, 33, 0.65);
  border: 1px solid rgba(245, 197, 66, 0.25);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 10.5px;
}

.pt-name {
  font-weight: 800;
  color: var(--gold-light);
  margin-bottom: 2px;
}

.pt-vals {
  color: #bcebd2;
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popIn {
  from { transform: scale(0.65); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
