/* ============ XOSO66 Vòng Quay May Mắn — styles ============ */

:root {
  --wheel-size: min(90vw, 90vh, 600px);
  --gold: #FFD700;
  --gold-light: #FFE873;
  --gold-dark: #B8860B;
  --red: #E60026;
  --red-deep: #8B0000;
  --bg-deep: #1a0010;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
  scrollbar-gutter: stable;
  /* tránh layout-shift khi scrollbar pop in/out */
}

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  background:
    radial-gradient(ellipse at top, rgba(230, 0, 38, 0.35) 0%, transparent 60%),
    radial-gradient(ellipse at bottom, rgba(255, 215, 0, 0.15) 0%, transparent 55%),
    url('assets/background.jpg') center/cover no-repeat fixed,
    var(--bg-deep);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #fff;
  overflow: hidden;
  /* trang full-viewport, không cần scroll → diệt scrollbar flicker do halo pulse */
}

/* ============ Layout ============ */

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 16px;
  gap: 16px;
}

.page-title {
  margin: 0;
  font-size: clamp(26px, 5.5vw, 46px);
  font-weight: 900;
  letter-spacing: 3px;
  text-align: center;
  background: linear-gradient(90deg, var(--gold-light) 0%, var(--gold) 35%, #fff 50%, var(--gold) 65%, var(--gold-light) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
  filter: drop-shadow(0 0 16px rgba(255, 215, 0, 0.55)) drop-shadow(0 0 6px rgba(230, 0, 38, 0.4));
  animation: titleShimmer 4s linear infinite;
}

@keyframes titleShimmer {
  0% {
    background-position: 200% 50%;
  }

  100% {
    background-position: -200% 50%;
  }
}

.hint {
  margin: 0;
  font-size: clamp(14px, 2.5vw, 18px);
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  animation: hintPulse 2s ease-in-out infinite;
}

@keyframes hintPulse {

  0%,
  100% {
    opacity: 0.7;
  }

  50% {
    opacity: 1;
  }
}

/* ============ Wheel ============ */

.wheel-area {
  position: relative;
  width: var(--wheel-size);
  aspect-ratio: 1;
  filter:
    drop-shadow(0 0 32px rgba(255, 215, 0, 0.55)) drop-shadow(0 0 60px rgba(230, 0, 38, 0.35));
  animation: wheelHalo 3s ease-in-out infinite;
}

@keyframes wheelHalo {

  0%,
  100% {
    filter: drop-shadow(0 0 28px rgba(255, 215, 0, 0.45)) drop-shadow(0 0 50px rgba(230, 0, 38, 0.3));
  }

  50% {
    filter: drop-shadow(0 0 40px rgba(255, 215, 0, 0.7)) drop-shadow(0 0 75px rgba(230, 0, 38, 0.45));
  }
}

.pointer {
  position: absolute;
  top: -3%;
  left: 50%;
  transform: translateX(-50%);
  width: 10%;
  aspect-ratio: 100/120;
  background: url('assets/pointer.png') center/contain no-repeat;
  z-index: 10;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6));
}

.wheel-wrap {
  position: relative;
  width: 100%;
  height: 100%;
}

.wheel {
  width: 100%;
  height: 100%;
  background: url('assets/wheel.png') center/contain no-repeat;
  transition: transform 5s cubic-bezier(0.17, 0.67, 0.12, 0.99);
  will-change: transform;
}

.center-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 28%;
  height: 28%;
  background: url('assets/center-button1.png') center/contain no-repeat;
  border: 0;
  cursor: pointer;
  border-radius: 50%;
  padding: 0;
  transition: transform 0.15s ease, filter 0.15s ease;
  z-index: 5;
}

.center-btn:hover:not(:disabled) {
  filter: brightness(1.15) drop-shadow(0 0 14px var(--gold)) drop-shadow(0 0 20px rgba(230, 0, 38, 0.6));
  transform: translate(-50%, -50%) scale(1.06);
}

.center-btn:active:not(:disabled) {
  transform: translate(-50%, -50%) scale(0.95);
}

.center-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

/* ============ Mute Button ============ */

.mute-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border: 2px solid rgba(255, 215, 0, 0.55);
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(230, 0, 38, 0.4), rgba(0, 0, 0, 0.55));
  color: white;
  font-size: 20px;
  cursor: pointer;
  z-index: 50;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.3);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.mute-btn:hover {
  transform: scale(1.1) rotate(-6deg);
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

/* ============ Modal ============ */

.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  z-index: 100;
  padding: 16px;
}

.modal[aria-hidden="false"] {
  display: grid;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  cursor: pointer;
}

.modal-box {
  position: relative;
  background:
    radial-gradient(ellipse at top, rgba(230, 0, 38, 0.35) 0%, transparent 70%),
    linear-gradient(135deg, #2a0814 0%, #1a0010 100%);
  border: 2px solid var(--gold);
  border-radius: 20px;
  padding: 36px 28px 28px;
  max-width: 90vw;
  width: 440px;
  text-align: center;
  box-shadow:
    0 0 0 1px rgba(255, 215, 0, 0.25) inset,
    0 0 50px rgba(255, 215, 0, 0.45),
    0 0 100px rgba(230, 0, 38, 0.35),
    0 20px 60px rgba(0, 0, 0, 0.75);
  animation: modalIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  /* Force own GPU layer để confetti repaint không kéo theo modal */
  transform: translateZ(0);
  will-change: transform;
  contain: layout paint;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.7) translateY(20px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-title {
  margin: 0 0 12px;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--gold);
  text-shadow: 0 0 14px rgba(255, 215, 0, 0.7), 0 0 28px rgba(230, 0, 38, 0.45);
}

.modal-prize-img {
  display: block;
  max-width: 200px;
  max-height: 160px;
  margin: 16px auto;
  object-fit: contain;
}

.modal-message {
  margin: 16px 0 0;
  font-size: 18px;
  line-height: 1.5;
}

.modal-message strong {
  color: var(--gold);
  font-size: 24px;
  display: block;
  margin-top: 4px;
}

.modal-insurance {
  margin: 8px 0 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #4CAF50;
  text-transform: uppercase;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}

.btn {
  padding: 12px 24px;
  border: 0;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  min-width: 120px;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 45%, #FFA000 100%);
  color: #2a0008;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.4) inset,
    0 4px 14px rgba(255, 215, 0, 0.5),
    0 0 24px rgba(230, 0, 38, 0.25);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 215, 0, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ============ Responsive ============ */

@media (max-width: 480px) {
  .modal-box {
    padding: 24px 16px;
  }

  .modal-prize-img {
    max-width: 150px;
  }

  .modal-actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .mute-btn {
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --wheel-size: min(80vh, 500px);
  }

  .page-title {
    font-size: 20px;
  }

  .stage {
    gap: 8px;
  }
}