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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 20%, #2a1019 0%, #12060b 65%, #070204 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #fff6e5;
  display: flex;
  justify-content: center;
  align-items: center;
}

#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  max-height: 920px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #3c121e 0%, #682119 35%, #2b0f14 75%, #120609 100%);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 196, 86, 0.25);
  overflow: hidden;
  transition: background 0.6s ease;
}

#app.free-mode {
  background: linear-gradient(180deg, #130b2e 0%, #2b134d 35%, #1b0c2e 75%, #090414 100%);
}

/* Top Bar */
.top-bar {
  flex: 0 0 auto;
  height: 48px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(20, 6, 10, 0.92), rgba(45, 14, 16, 0.72));
  border-bottom: 1.5px solid rgba(255, 198, 88, 0.4);
  z-index: 10;
}

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

.jili-tag {
  background: linear-gradient(135deg, #ffdd6e, #e88612);
  color: #2b0b00;
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.8px;
  padding: 2px 7px;
  border-radius: 5px;
  box-shadow: 0 2px 6px rgba(255, 150, 20, 0.45);
}

.game-title {
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 1px;
  background: linear-gradient(180deg, #fff5c4 0%, #ffbe3b 55%, #d65a0b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.9));
}

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

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 203, 98, 0.45);
  background: rgba(25, 8, 12, 0.75);
  color: #ffe299;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, background 0.15s;
}

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

/* Free Spins HUD */
.fs-hud {
  position: absolute;
  top: 54px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  z-index: 12;
  pointer-events: none;
}

.fs-hud.hidden {
  display: none;
}

.fs-hud-pill {
  flex: 1;
  background: linear-gradient(180deg, rgba(44, 15, 82, 0.95), rgba(20, 6, 40, 0.95));
  border: 1.5px solid #c084fc;
  border-radius: 10px;
  padding: 4px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.45);
}

.fs-hud-pill.gold {
  border-color: #fbbf24;
  box-shadow: 0 4px 16px rgba(251, 191, 36, 0.4);
}

.fs-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #e9d5ff;
}

.fs-hud-pill.gold .fs-label {
  color: #fde68a;
}

.fs-value {
  font-size: 17px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 10px rgba(255, 215, 80, 0.8);
}

/* Main Stage */
.stage-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.win-ticker {
  position: absolute;
  bottom: 8px;
  left: 12px;
  right: 12px;
  height: 28px;
  background: linear-gradient(90deg, rgba(20, 6, 10, 0.85), rgba(66, 22, 16, 0.92), rgba(20, 6, 10, 0.85));
  border: 1px solid rgba(255, 196, 86, 0.45);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  pointer-events: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

#ticker-text {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #ffe39b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Big Win / Feature Overlay */
.overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(20, 4, 8, 0.82) 0%, rgba(5, 1, 4, 0.9) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  animation: fadeIn 0.25s ease;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  text-align: center;
  padding: 24px 28px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(96, 26, 16, 0.96), rgba(34, 8, 12, 0.98));
  border: 2.5px solid #ffcb47;
  box-shadow: 0 0 40px rgba(255, 174, 30, 0.65), inset 0 0 25px rgba(255, 210, 90, 0.2);
  max-width: 88%;
  animation: popIn 0.35s cubic-bezier(0.2, 1.3, 0.4, 1);
}

.overlay-kicker {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #ffd980;
  margin-bottom: 4px;
}

.overlay-title {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 1.5px;
  background: linear-gradient(180deg, #fff9d2 0%, #ffcc33 45%, #ff6a00 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.85));
}

.overlay-amount {
  font-size: 38px;
  font-weight: 900;
  color: #fff;
  margin-top: 8px;
  text-shadow: 0 0 18px rgba(255, 198, 46, 0.9), 0 3px 0 #7a2c00;
}

.overlay-sub {
  font-size: 13px;
  font-weight: 700;
  color: #ffe8b3;
  margin-top: 6px;
}

/* Toast */
.toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(185, 28, 28, 0.95);
  border: 1px solid #fca5a5;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 20px;
  z-index: 30;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}

.toast.hidden {
  display: none;
}

/* Bottom Control Deck */
.control-deck {
  flex: 0 0 auto;
  background: linear-gradient(180deg, rgba(28, 9, 12, 0.96), rgba(14, 4, 7, 0.99));
  border-top: 2px solid rgba(255, 196, 86, 0.45);
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1.1fr 0.9fr;
  gap: 6px;
}

.stat-box {
  background: rgba(10, 3, 5, 0.78);
  border: 1px solid rgba(255, 196, 86, 0.28);
  border-radius: 10px;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-box.win-box {
  border-color: rgba(255, 206, 70, 0.65);
  background: linear-gradient(180deg, rgba(64, 24, 8, 0.8), rgba(22, 7, 5, 0.9));
}

.stat-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.9px;
  color: #c9a27e;
}

.stat-value {
  font-size: 15px;
  font-weight: 900;
  color: #fff8e7;
  font-variant-numeric: tabular-nums;
}

.stat-value.gold {
  color: #ffd046;
  text-shadow: 0 0 8px rgba(255, 190, 40, 0.55);
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bet-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.round-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 201, 92, 0.6);
  background: linear-gradient(180deg, #521d14, #260b09);
  color: #ffde8a;
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
}

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

.bet-chip {
  min-width: 48px;
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 196, 86, 0.35);
  border-radius: 8px;
  padding: 3px 6px;
  display: flex;
  flex-direction: column;
}

.chip-lbl {
  font-size: 8px;
  font-weight: 800;
  color: #d6aa7e;
}

.chip-num {
  font-size: 14px;
  font-weight: 900;
  color: #fff;
}

/* Central Spin Button */
.spin-btn {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 3px solid #ffe285;
  background: radial-gradient(circle at 35% 30%, #ffdf5d 0%, #f58b0a 48%, #9c2e04 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 22px rgba(255, 152, 20, 0.7), 0 6px 14px rgba(0, 0, 0, 0.7), inset 0 2px 6px rgba(255, 255, 255, 0.55);
  transition: transform 0.12s, filter 0.15s;
}

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

.spin-btn.spinning {
  background: radial-gradient(circle at 35% 30%, #fb7185 0%, #dc2626 55%, #7f1d1d 100%);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.65), 0 6px 14px rgba(0, 0, 0, 0.7);
}

.spin-btn.spinning .spin-icon {
  animation: spinAnim 0.75s linear infinite;
}

.spin-icon {
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.65);
}

.spin-lbl {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.aux-controls {
  display: flex;
  gap: 6px;
}

.pill-btn {
  width: 52px;
  height: 46px;
  border-radius: 12px;
  border: 1.5px solid rgba(255, 198, 92, 0.45);
  background: linear-gradient(180deg, #3c1412, #1c0708);
  color: #ffe3a3;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  transition: all 0.15s;
}

.pill-btn span {
  font-size: 9px;
  letter-spacing: 0.6px;
}

.pill-btn.active {
  background: linear-gradient(180deg, #f59e0b, #b45309);
  border-color: #fef08a;
  color: #1f0a00;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.65);
}

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

.modal.hidden {
  display: none;
}

.modal-sheet {
  width: 100%;
  max-width: 440px;
  max-height: 86dvh;
  background: linear-gradient(180deg, #2d0e14, #16060a);
  border: 2px solid #f5b942;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 45px rgba(0, 0, 0, 0.85);
}

.modal-head {
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.45);
  border-bottom: 1px solid rgba(255, 196, 86, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h2 {
  font-size: 15px;
  font-weight: 900;
  color: #ffd369;
  letter-spacing: 0.8px;
}

.close-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255, 200, 90, 0.5);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}

.modal-body {
  padding: 14px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.5;
}

.modal-body h3 {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fbbf24;
  margin: 12px 0 6px;
}

.rule-banner {
  background: rgba(255, 185, 50, 0.12);
  border: 1px solid rgba(255, 196, 86, 0.4);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  color: #ffefc2;
}

.special-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.special-card {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 200, 90, 0.3);
  border-radius: 10px;
  padding: 10px;
}

.sp-title {
  font-weight: 900;
  color: #ffd369;
  margin-bottom: 4px;
}

.paytable-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.pt-item {
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 196, 86, 0.22);
  border-radius: 8px;
  padding: 7px 9px;
}

.pt-name {
  font-weight: 900;
  color: #ffe399;
  margin-bottom: 3px;
  font-size: 12px;
}

.pt-rows {
  font-size: 11px;
  color: #e7d4be;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

@keyframes spinAnim {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

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

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