:root {
  --gold-1: #fff6c4;
  --gold-2: #facc15;
  --gold-3: #d97706;
  --gold-4: #78350f;
  --ocean-top: #06314f;
  --ocean-mid: #041d35;
  --ocean-bot: #020e1c;
  --glass: rgba(4, 24, 44, 0.72);
  --glass-border: rgba(250, 204, 21, 0.42);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ocean-bot);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #fff;
  touch-action: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

#oceanCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

/* Top HUD */
#topHud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding: max(6px, env(safe-area-inset-top)) 8px 4px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.jackpot-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.jp-pill {
  background: linear-gradient(180deg, rgba(15, 35, 60, 0.92), rgba(5, 16, 32, 0.94));
  border: 1.5px solid rgba(250, 204, 21, 0.55);
  border-radius: 10px;
  padding: 3px 6px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 246, 196, 0.35);
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.jp-pill.jp-mini  { border-color: #38bdf8; }
.jp-pill.jp-minor { border-color: #c084fc; }
.jp-pill.jp-major { border-color: #fb923c; }
.jp-pill.jp-grand {
  border-color: #facc15;
  background: linear-gradient(180deg, rgba(120, 53, 15, 0.92), rgba(45, 18, 4, 0.95));
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.45), inset 0 1px 0 rgba(255, 246, 196, 0.6);
}

.jp-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.8px;
  opacity: 0.9;
}
.jp-mini  .jp-label { color: #7dd3fc; }
.jp-minor .jp-label { color: #e9d5ff; }
.jp-major .jp-label { color: #fed7aa; }
.jp-grand .jp-label { color: #fef08a; }

.jp-val {
  font-size: clamp(11px, 2.7vw, 15px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff9db, #facc15);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hud-subrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 4px 10px;
  backdrop-filter: blur(6px);
}
.brand-title {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.7px;
  background: linear-gradient(180deg, #fff6c4, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.crown-icon { font-size: 13px; }

.wallet-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(180deg, rgba(16, 40, 68, 0.9), rgba(6, 20, 38, 0.94));
  border: 1.5px solid rgba(250, 204, 21, 0.65);
  border-radius: 999px;
  padding: 4px 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s ease;
}
.wallet-pill.pulse {
  transform: scale(1.08);
  border-color: #fef08a;
  box-shadow: 0 0 18px rgba(250, 204, 21, 0.7);
}
.coin-dot { font-size: 14px; }
.currency-code {
  font-size: 10px;
  font-weight: 800;
  color: #fde68a;
  opacity: 0.85;
}
.balance-val {
  font-size: 14px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.hud-actions {
  display: flex;
  gap: 5px;
  pointer-events: auto;
}
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: #fff;
  font-size: 15px;
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.icon-btn:active { transform: scale(0.92); }

/* Boss Alert Banner */
.boss-banner {
  position: absolute;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  pointer-events: none;
  animation: bossSlide 0.4s ease-out;
}
.boss-banner-inner {
  background: linear-gradient(90deg, rgba(120, 15, 15, 0.92), rgba(180, 83, 9, 0.95), rgba(120, 15, 15, 0.92));
  border: 2px solid #fde047;
  border-radius: 14px;
  padding: 8px 20px;
  text-align: center;
  box-shadow: 0 0 28px rgba(250, 204, 21, 0.65);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.boss-tag {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #fef08a;
}
.boss-name {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.8px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}
@keyframes bossSlide {
  from { opacity: 0; transform: translate(-50%, -18px) scale(0.92); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* Big Win Banner */
.win-banner {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  pointer-events: none;
  text-align: center;
  background: radial-gradient(circle, rgba(146, 64, 14, 0.94), rgba(69, 26, 3, 0.9));
  border: 2.5px solid #fde047;
  border-radius: 20px;
  padding: 14px 28px;
  box-shadow: 0 0 40px rgba(250, 204, 21, 0.8);
  animation: popIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.win-banner-title {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #fef08a;
}
.win-banner-amount {
  font-size: 30px;
  font-weight: 900;
  background: linear-gradient(180deg, #ffffff, #fde047, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
}
@keyframes popIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Toast */
.toast {
  position: absolute;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  background: rgba(153, 27, 27, 0.94);
  border: 1.5px solid #fca5a5;
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

/* Bottom Controls Dock */
#bottomDock {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding: 6px 10px max(8px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(2, 14, 28, 0) 0%, rgba(2, 14, 28, 0.88) 45%, rgba(2, 12, 24, 0.98) 100%);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.dock-left, .dock-center, .dock-right {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 48px;
  border-radius: 12px;
  border: 1.5px solid rgba(148, 163, 184, 0.4);
  background: linear-gradient(180deg, rgba(15, 38, 66, 0.92), rgba(7, 20, 38, 0.95));
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ctrl-btn .ctrl-icon { font-size: 16px; line-height: 1; }
.ctrl-btn .ctrl-text { font-size: 9px; font-weight: 800; letter-spacing: 0.6px; margin-top: 2px; }
.ctrl-btn.active {
  border-color: #facc15;
  background: linear-gradient(180deg, #b45309, #78350f);
  color: #fef9c3;
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.65);
}
.ctrl-btn:active { transform: scale(0.93); }

.dock-center {
  background: linear-gradient(180deg, rgba(18, 42, 72, 0.92), rgba(6, 20, 38, 0.96));
  border: 1.5px solid rgba(250, 204, 21, 0.65);
  border-radius: 999px;
  padding: 4px 6px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
}

.bet-step-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid #fde047;
  background: linear-gradient(180deg, #f59e0b, #b45309);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.bet-step-btn:active { transform: scale(0.9); }

.bet-display {
  min-width: 64px;
  text-align: center;
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  padding: 0 4px;
}
.bet-label {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fde68a;
}
.bet-value {
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.stat-mini {
  background: var(--glass);
  border: 1px solid rgba(250, 204, 21, 0.35);
  border-radius: 12px;
  padding: 6px 10px;
  min-width: 82px;
  text-align: right;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.stat-label {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.7px;
  color: #93c5fd;
}
.stat-value {
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #fde047;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 10, 20, 0.82);
  backdrop-filter: blur(5px);
}

.wheel-card {
  position: relative;
  z-index: 1;
  width: min(370px, 94vw);
  background: radial-gradient(circle at top, #1e3a5f, #06182c);
  border: 2.5px solid #facc15;
  border-radius: 22px;
  padding: 18px 16px;
  text-align: center;
  box-shadow: 0 0 45px rgba(250, 204, 21, 0.55);
}
.wheel-crown {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.8px;
  color: #fde047;
}
.wheel-sub {
  font-size: 11px;
  color: #bfdbfe;
  margin-top: 2px;
  margin-bottom: 10px;
}
.wheel-stage {
  position: relative;
  width: 280px;
  height: 280px;
  margin: 0 auto;
}
#wheelCanvas {
  width: 100%;
  height: 100%;
  display: block;
}
.wheel-pointer {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 26px;
  color: #fde047;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.85));
}
.wheel-result {
  margin-top: 12px;
  animation: popIn 0.25s ease-out;
}
.wheel-tier {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fde047;
}
.wheel-prize {
  font-size: 28px;
  font-weight: 900;
  color: #fff;
  margin: 4px 0 10px;
}
.gold-btn {
  border: 1.5px solid #fef08a;
  background: linear-gradient(180deg, #facc15, #d97706);
  color: #422006;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 0.8px;
  padding: 10px 26px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(250, 204, 21, 0.45);
}
.gold-btn:active { transform: scale(0.95); }

.paytable-card {
  position: relative;
  z-index: 1;
  width: min(520px, 95vw);
  max-height: 84dvh;
  overflow-y: auto;
  background: linear-gradient(180deg, #0b2440, #041222);
  border: 2px solid #facc15;
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
}
.paytable-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.paytable-header h2 {
  font-size: 17px;
  color: #fde047;
}
.close-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
}
.paytable-note {
  font-size: 12px;
  color: #cbd5e1;
  line-height: 1.4;
  margin-bottom: 12px;
}
.paytable-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.pt-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(250, 204, 21, 0.25);
  border-radius: 12px;
  padding: 8px;
  text-align: center;
}
.pt-item.boss {
  border-color: #facc15;
  background: rgba(180, 83, 9, 0.22);
}
.pt-name {
  font-size: 11px;
  font-weight: 700;
  color: #e2e8f0;
}
.pt-mult {
  font-size: 16px;
  font-weight: 900;
  color: #fde047;
  margin-top: 2px;
}
.pt-jp {
  font-size: 9px;
  font-weight: 800;
  color: #7dd3fc;
  margin-top: 2px;
}
.paytable-jp {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.jp-info {
  border-radius: 10px;
  padding: 6px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.07);
}
.jp-info.mini  { border: 1px solid #38bdf8; color: #7dd3fc; }
.jp-info.minor { border: 1px solid #c084fc; color: #e9d5ff; }
.jp-info.major { border: 1px solid #fb923c; color: #fed7aa; }
.jp-info.grand { border: 1px solid #facc15; color: #fef08a; }

.hidden { display: none !important; }

@media (max-width: 420px) {
  .brand-badge { display: none; }
  .ctrl-btn { width: 46px; height: 44px; }
  .stat-mini { min-width: 70px; padding: 5px 8px; }
}
