:root {
  --bg1: #1a0b2e;
  --bg2: #07040f;
  --gold: #ffcc33;
  --gold-d: #b47b00;
  --text: #fff8e6;
  --muted: #c9bfdc;
  --win: #1fae5b;
  --loss: #e0313f;
  --draw: #6b7a90;
  --jack: #ffcc33;
  --card: #1c1230e6;
  --wheel: min(86vw, 74vh, 620px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(ellipse at 50% 35%, #3b1660 0%, var(--bg1) 45%, var(--bg2) 100%) fixed;
  background-color: var(--bg2);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
body.shake { animation: shake .6s cubic-bezier(.36,.07,.19,.97) both; }
body.shake-hard { animation: shake 1.1s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 1px, 0); }
  30%, 50%, 70% { transform: translate3d(-8px, -2px, 0); }
  40%, 60% { transform: translate3d(8px, 2px, 0); }
}

.disclaimer-bar {
  background: linear-gradient(90deg, #ffcc33, #ffa62b);
  color: #2a1600;
  text-align: center;
  font-size: 14px;
  padding: 8px 16px;
  line-height: 1.4;
}

.top {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; padding: 12px 64px 0; position: relative;
}
.top h1 {
  margin: 0; font-weight: 900; letter-spacing: .5px;
  font-size: clamp(22px, 4.5vw, 40px);
  background: linear-gradient(180deg, #fff6c8, #ffcc33 55%, #d48c00);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 2px 18px #ffb30033;
  text-align: center;
}
.brand { padding-right: 4px; }
.icon-btn {
  position: absolute; right: 16px; top: 12px;
  width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid #ffcc3388; background: #ffffff10; color: var(--text);
  font-size: 20px; cursor: pointer;
}

.stage {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  gap: clamp(16px, 4vw, 56px);
  padding: 12px 16px 16px;
  flex-wrap: wrap;
}

/* ---------- Wheel ---------- */
.wheel-area { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.wheel-wrap {
  position: relative;
  width: var(--wheel); height: var(--wheel);
  border-radius: 50%;
  padding: calc(var(--wheel) * .045);
  background: conic-gradient(from 0deg, #ffdf6b, #b47b00, #ffe9a0, #9a6400, #ffdf6b, #b47b00, #ffe9a0, #9a6400, #ffdf6b);
  box-shadow: 0 0 0 4px #4a2a00, 0 0 60px #ffb3004d, 0 25px 60px #000a, inset 0 0 18px #0008;
}
#wheel {
  width: 100%; height: 100%;
  border-radius: 50%;
  display: block;
  will-change: transform;
  box-shadow: 0 0 0 3px #3a2200, inset 0 0 30px #000;
}
.bulbs { position: absolute; inset: 0; pointer-events: none; }
.bulb {
  position: absolute; width: calc(var(--wheel) * .022); height: calc(var(--wheel) * .022);
  border-radius: 50%; transform: translate(-50%, -50%);
  background: #fff4c2; box-shadow: 0 0 6px 2px #ffd54a;
  animation: blink 1.2s infinite;
}
.bulb:nth-child(even) { animation-delay: .6s; }
.spinning .bulb { animation-duration: .25s; }
.party .bulb { animation: party .18s infinite; }
.sad .bulb { animation: none; background: #5a2a2a; box-shadow: none; }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .25; } }
@keyframes party { 0% { background: #fff4c2; } 33% { background: #5dffa0; box-shadow: 0 0 10px 3px #5dffa0; } 66% { background: #ffcc33; box-shadow: 0 0 10px 3px #ffcc33; } }

.pointer {
  position: absolute; left: 50%; top: calc(var(--wheel) * -.045);
  width: calc(var(--wheel) * .085); z-index: 3;
  transform: translateX(-50%); transform-origin: 50% 20%;
  filter: drop-shadow(0 4px 6px #000b);
}
.pointer svg { width: 100%; display: block; }
.pointer.flap { animation: flap .09s ease-out; }
@keyframes flap { 0% { transform: translateX(-50%) rotate(0); } 40% { transform: translateX(-50%) rotate(-14deg); } 100% { transform: translateX(-50%) rotate(0); } }

.hub {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 19%; height: 19%; border-radius: 50%;
  border: 4px solid #7a4a00;
  background: radial-gradient(circle at 35% 30%, #fff6c8, #ffcc33 45%, #b47b00 100%);
  color: #5a1200; font: 900 clamp(13px, 2.6vw, 22px) "Be Vietnam Pro", sans-serif;
  box-shadow: 0 6px 18px #000b, inset 0 -4px 8px #0004;
  cursor: pointer; z-index: 2;
}
.hub:disabled { cursor: default; filter: saturate(.7); }

.live {
  min-height: 40px; font-size: clamp(18px, 3vw, 26px); font-weight: 900;
  padding: 4px 18px; border-radius: 999px; background: #ffffff10;
  border: 1px solid #ffffff22; text-align: center;
}
.live.win { color: #5dffa0; } .live.loss { color: #ff6b77; }
.live.draw { color: #c9d4e4; } .live.jack { color: var(--gold); }

/* ---------- Side ---------- */
.side { display: flex; flex-direction: column; gap: 16px; width: min(360px, 100%); }
.spin-btn {
  width: 100%; padding: 22px 16px; border-radius: 22px; cursor: pointer;
  border: 0; color: #fff;
  background: linear-gradient(180deg, #ff4d5e, #d0102a 60%, #8e0618);
  box-shadow: 0 8px 0 #5c0010, 0 14px 30px #000a, inset 0 2px 0 #ffffff55;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: transform .08s, box-shadow .08s, filter .2s;
  animation: pulse 1.6s infinite;
}
.spin-btn:hover { filter: brightness(1.08); }
.spin-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 #5c0010, 0 6px 14px #000a, inset 0 2px 0 #ffffff55; }
.spin-btn:disabled { filter: grayscale(.7) brightness(.7); cursor: not-allowed; animation: none; }
.spin-main { font-size: clamp(26px, 5vw, 38px); font-weight: 900; letter-spacing: 1px; text-shadow: 0 3px 0 #0005; }
.spin-sub { font-size: 13px; opacity: .85; }
@keyframes pulse { 0%, 100% { box-shadow: 0 8px 0 #5c0010, 0 14px 30px #000a, 0 0 0 0 #ff4d5e88; } 50% { box-shadow: 0 8px 0 #5c0010, 0 14px 30px #000a, 0 0 0 14px #ff4d5e00; } }

.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; font-size: 15px; color: var(--muted); }
.legend div { display: flex; align-items: center; gap: 8px; }
.sw { width: 18px; height: 18px; border-radius: 5px; display: inline-block; border: 2px solid #fff3; }
.sw.win { background: var(--win); } .sw.loss { background: var(--loss); }
.sw.draw { background: var(--draw); } .sw.jack { background: var(--jack); }

.history-box { background: #ffffff0d; border: 1px solid #ffffff1f; border-radius: 16px; padding: 12px 14px; }
.history-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: 6px; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; font-size: 13px; }
.stats { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; max-height: 120px; overflow: auto; }
.history li { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; color: #fff; }
.history li.win { background: #13804299; } .history li.loss { background: #b0202c99; }
.history li.draw { background: #4c5a6e99; } .history li.jack { background: #c9930099; color: #fff; }

/* ---------- Result ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: #000a; backdrop-filter: blur(3px);
  animation: fadein .25s ease-out;
}
.overlay[hidden] { display: none; }
.overlay.loss { background: radial-gradient(circle, #3a000899, #000d); }
.overlay.win, .overlay.jack { background: radial-gradient(circle, #0c3a2299, #000c); }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.result-card {
  width: min(560px, 100%); text-align: center; padding: 28px 20px 22px;
  border-radius: 28px; background: var(--card);
  border: 3px solid #ffffff33; box-shadow: 0 30px 80px #000c;
  animation: pop .55s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes pop { from { transform: scale(.3) rotate(-6deg); opacity: 0; } to { transform: none; opacity: 1; } }
.result-card.win { border-color: #3dff8f; box-shadow: 0 0 60px #1fae5b88, 0 30px 80px #000c; }
.result-card.loss { border-color: #ff4d5e; box-shadow: 0 0 60px #e0313f88, 0 30px 80px #000c; }
.result-card.draw { border-color: #9fb0c8; }
.result-card.jack { border-color: var(--gold); box-shadow: 0 0 90px #ffcc33cc, 0 30px 80px #000c; animation: pop .55s cubic-bezier(.2, 1.6, .4, 1), glow 1s .6s infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 140px #ffcc33, 0 30px 80px #000c; } }
.r-icon { font-size: clamp(56px, 12vw, 92px); line-height: 1; }
.r-label { font-size: clamp(42px, 11vw, 84px); font-weight: 900; line-height: 1.05; margin: 8px 0 4px; }
.win .r-label { color: #5dffa0; text-shadow: 0 0 24px #1fae5b; }
.loss .r-label { color: #ff6b77; text-shadow: 0 0 24px #e0313f; }
.draw .r-label { color: #dfe7f2; }
.jack .r-label { background: linear-gradient(180deg, #fff6c8, #ffcc33 50%, #e08a00); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 16px #ffcc33aa); }
.r-mult { font-size: clamp(22px, 5vw, 32px); font-weight: 700; color: var(--muted); }
.r-msg { font-size: clamp(18px, 4vw, 24px); margin: 10px 0 18px; }
.again-btn {
  font: 900 20px "Be Vietnam Pro", sans-serif; color: #2a1600; cursor: pointer;
  padding: 14px 28px; border-radius: 16px; border: 0;
  background: linear-gradient(180deg, #fff1a8, #ffcc33 60%, #d48c00);
  box-shadow: 0 6px 0 #7a4a00;
}
.again-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #7a4a00; }
.r-note { font-size: 12px; color: var(--muted); margin-top: 14px; }

.fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

.foot { text-align: center; font-size: 13px; color: var(--muted); padding: 12px 16px 18px; line-height: 1.5; }

@media (max-width: 760px) {
  :root { --wheel: min(88vw, 60vh, 520px); }
  .stage { flex-direction: column; gap: 14px; }
  .side { width: 100%; max-width: 520px; }
}
@media (prefers-reduced-motion: reduce) {
  .bulb, .spin-btn { animation: none !important; }
}
