:root { color-scheme: dark; font-family: Arial, Helvetica, sans-serif; background: #080808; }
* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; overflow-x: hidden; }
body {
  min-height: 100vh;
  min-height: 100svh;
  color: #fff;
  background:
    radial-gradient(circle at 50% 34%, rgba(205,27,12,.66), transparent 35%),
    radial-gradient(circle at 50% 65%, rgba(236,167,36,.3), transparent 35%),
    linear-gradient(145deg, #050505, #241109 54%, #050505);
}
button, a { -webkit-tap-highlight-color: transparent; }

.background-video {
  position: fixed;
  z-index: -2;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .72;
}

.page {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(12px, env(safe-area-inset-top)) 6px max(20px, env(safe-area-inset-bottom));
  overflow: hidden;
}

.page::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  background: radial-gradient(circle at 50% 47%, transparent 20%, rgba(0,0,0,.42) 90%);
  pointer-events: none;
}

.logo {
  position: relative;
  z-index: 3;
  display: block;
  width: min(500px, 78vw);
  height: auto;
  margin: 0 auto 3px;
  filter: drop-shadow(0 7px 8px rgba(0,0,0,.72));
}

.game { position: relative; z-index: 2; width: min(1000px, 100%); display: flex; flex-direction: column; align-items: center; }
.game h1 {
  margin: 0;
  color: #fff5c7;
  font-size: clamp(25px, 4vw, 43px);
  line-height: 1;
  text-align: center;
  text-shadow: 0 3px 2px #571000, 0 0 10px #ffbe2f;
}

.stage { position: relative; width: min(760px, 98vw); aspect-ratio: 1; margin-top: 2px; }
.wheel-wrap { position: absolute; width: 86%; aspect-ratio: 1; top: 2%; left: 7%; }
.rotor {
  position: absolute;
  inset: 11.55%;
  z-index: 1;
  overflow: hidden;
  border-radius: 50%;
  transform: rotate(0deg);
  will-change: transform;
}
.rotor img, .wheel-frame { display: block; width: 100%; height: 100%; }
.rotor img { position: absolute; inset: 0; object-fit: contain; }
.rotor .wheel-base { z-index: 0; }
.rotor .wheel-labels { z-index: 1; }
.wheel-frame { position: absolute; inset: 0; z-index: 2; object-fit: contain; pointer-events: none; }
.pointer { position: absolute; z-index: 5; width: 14%; height: auto; top: -.4%; left: 43%; filter: drop-shadow(0 4px 5px rgba(0,0,0,.72)); }

.spin {
  position: absolute;
  z-index: 6;
  width: 22%;
  aspect-ratio: 1;
  top: 39%;
  left: 39%;
  border: 0;
  border-radius: 50%;
  color: #fff8d7;
  background: transparent url("assets/megaFortune/img/wheel-btn.webp") center / contain no-repeat;
  font: 900 clamp(17px, 3vw, 30px)/1 Arial, sans-serif;
  text-shadow: 0 3px 2px #641100, 0 0 6px #fff;
  cursor: pointer;
  filter: drop-shadow(0 5px 6px rgba(0,0,0,.62));
  animation: pulse 1.4s ease-in-out infinite;
}
.spin:disabled { cursor: default; animation: none; opacity: .95; }
.spin:focus-visible, .claim:focus-visible, .close:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }

.decor { position: absolute; z-index: 4; width: 18%; height: auto; pointer-events: none; filter: drop-shadow(0 8px 6px rgba(0,0,0,.6)); }
.decor-money { left: 0; bottom: 5%; transform: rotate(-12deg); }
.decor-car { right: -1%; bottom: 7%; transform: rotate(10deg); }
.decor-watch { right: 3%; top: 12%; width: 13%; transform: rotate(14deg); }

.status { position: relative; z-index: 7; min-height: 28px; margin: -6% 0 0; text-align: center; color: #fff2bb; font-size: clamp(17px, 2.4vw, 24px); font-weight: 900; text-shadow: 0 3px 2px #571000; }

.modal[hidden] { display: none; }
.modal { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 14px; background: rgba(0,0,0,.86); backdrop-filter: blur(5px); }
.modal-card {
  position: relative;
  width: min(500px, 94vw);
  max-height: calc(100vh - 28px);
  max-height: calc(100svh - 28px);
  padding: 32px 24px 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
  text-align: center;
  border: 4px solid #f4c75e;
  border-radius: 26px;
  color: #fff;
  background: #240b05 url("assets/megaFortune/img/modal-bg.webp") center / cover no-repeat;
  box-shadow: 0 0 0 6px #7b290b, 0 18px 70px rgba(0,0,0,.78), inset 0 0 30px rgba(255,210,91,.2);
}
.modal-card::before { content: ""; position: absolute; inset: 0; background: rgba(31,4,0,.28); pointer-events: none; }
.modal-card > * { position: relative; }
.win-art { display: block; width: min(82vw, 380px); max-width: 100%; max-height: min(22vh, 190px); max-height: min(22svh, 190px); height: auto; object-fit: contain; margin: 0 auto 8px; }
.modal h2 { margin: 2px 0 8px; color: #fff1b1; font-size: clamp(24px, 7vw, 38px); text-shadow: 0 3px 2px #641100; }
.modal p { margin: 0; font-size: 20px; font-weight: 800; }
.result { display: block; margin: 5px 0 19px; color: #ffd951; font-size: clamp(31px, 9vw, 47px); text-shadow: 0 3px 2px #7d1900; }
.claim { display: inline-flex; justify-content: center; align-items: center; min-width: 230px; min-height: 60px; padding: 13px 30px; border: 3px solid #fff0a3; border-radius: 999px; color: #3b1000; background: linear-gradient(#fff37d, #f2a817 58%, #c9570b); box-shadow: 0 5px 0 #732000, 0 8px 22px rgba(0,0,0,.5); text-decoration: none; font-size: 25px; font-weight: 900; }
.close { position: absolute; z-index: 3; top: 7px; right: 11px; border: 0; color: #fff; background: transparent; font: 700 38px/1 Arial, sans-serif; cursor: pointer; }

@keyframes pulse { 50% { transform: scale(1.06); filter: drop-shadow(0 5px 13px rgba(255,186,42,.84)); } }

@media (max-width: 640px) {
  .background-video { opacity: .58; }
  .page { padding-left: 3px; padding-right: 3px; }
  .logo { width: min(460px, 88vw); }
  .stage { width: min(640px, 100vw); }
  .wheel-wrap { width: 92%; left: 4%; top: 2%; }
  .decor-money { left: 1%; bottom: 7%; width: 17%; }
  .decor-car { right: 0; bottom: 8%; width: 17%; }
  .decor-watch { right: 4%; top: 12%; width: 12%; }
  .status { margin-top: -8%; }
  .modal { padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); }
  .modal-card { width: calc(100vw - 20px); max-width: 430px; max-height: calc(100vh - 20px); max-height: calc(100svh - 20px); padding: 27px 17px 23px; }
  .win-art { width: min(78vw, 340px); max-height: min(19vh, 150px); max-height: min(19svh, 150px); }
}

@media (max-width: 360px), (max-height: 620px) {
  .modal-card { padding: 22px 13px 17px; }
  .win-art { width: min(73vw, 280px); max-height: 14vh; max-height: 14svh; }
  .modal h2 { margin-top: 0; font-size: clamp(22px, 7vw, 30px); }
  .result { margin-bottom: 13px; font-size: clamp(28px, 9vw, 37px); }
  .claim { min-height: 53px; padding-block: 9px; }
}

@media (max-height: 720px) and (orientation: landscape) {
  .logo { width: 280px; }
  .game h1 { font-size: 22px; }
  .stage { width: min(500px, 72vh); }
  .status { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) { .spin { animation: none; } .background-video { display: none; } }
