* {
  box-sizing: border-box;
}

:root {
  --bg: #0a0e1a;
  --bg-soft: #0f1419;
  --bg-card: #12161f;
  --text: #f8fafc;
  --text-gold: #ffd700;
  --text-silver: #c0c0c0;
  --muted: rgba(248, 250, 252, 0.65);
  --accent: #6366f1;
  --accent-strong: #4f46e5;
  --gold: #ffd700;
  --gold-dark: #b8860b;
  --radius-lg: 20px;
  --shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 0 20px rgba(255, 215, 0, 0.3);
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 215, 0, 0.15), transparent 50%),
    radial-gradient(circle at 80% 10%, rgba(99, 102, 241, 0.2), transparent 55%),
    radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0.8), transparent 70%),
    linear-gradient(135deg, var(--bg) 0%, #060a14 50%, var(--bg) 100%);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
  /* Ensure full coverage on iPhone */
  background-attachment: fixed;
}

.wrap {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  padding: max(env(safe-area-inset-top), 20px) 12px max(env(safe-area-inset-bottom), 8px);
  box-sizing: border-box;
  overflow: visible;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: max(env(safe-area-inset-top), 40px);
}

.content {
  width: min(400px, 92vw);
  padding: clamp(20px, 4vw, 30px) clamp(10px, 2.5vw, 18px);
  display: grid;
  gap: clamp(15px, 3vw, 20px);
  text-align: center;
  position: relative;
  margin-top: 20px;
}


.tag {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-gold);
  font-weight: 700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
  position: relative;
}

.tag::after {
  content: '♦';
  margin-left: 8px;
  color: var(--gold);
}

.headline {
  margin: 0 0 16px 0;
  font-size: clamp(2rem, 5.5vw, 2.6rem);
  line-height: 1.1;
  word-break: break-word;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text-gold) 0%, var(--text-silver) 50%, var(--text-gold) 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
  position: relative;
  padding-bottom: 8px;
}

.headline::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  box-shadow: var(--shadow-gold);
  z-index: 10;
}

.subhead,
.hint {
  margin: 0 auto;
  color: var(--muted);
  max-width: 32ch;
  font-size: 0.98rem;
  line-height: 1.45;
}

.wheel-zone {
  display: grid;
  gap: 20px;
  justify-items: center;
  margin-top: clamp(48px, 9vw, 72px);
  width: 100%;
  position: relative;
  overflow: visible;
  z-index: 1;
}

.wheel-shell {
  position: relative;
  width: min(360px, 85vw);
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 18px);
  margin: 0 auto;
}

canvas#wheel {
  width: 100%;
  height: auto;
  border-radius: 50%;
  box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.45);
  touch-action: none;
  user-select: none;
  transition: transform 0.1s ease;
}

.wheel-pointer {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3), 0 0 0 3px rgba(255, 215, 0, 0.2);
  border: 2px solid rgba(0, 0, 0, 0.2);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wheel-pointer::after {
  content: '';
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 6px solid rgba(0, 0, 0, 0.7);
  margin-top: 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-weight: 700;
  border-radius: 50px;
  border: 2px solid var(--gold);
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.btn.primary {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 50%, var(--gold) 100%);
  color: #000;
  box-shadow: 
    0 8px 32px rgba(255, 215, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.btn.primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.btn.primary:hover::before {
  left: 100%;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.hint {
  font-size: 0.92rem;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}

.modal-card {
  position: relative;
  width: min(360px, 90vw);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  text-align: center;
  box-shadow: var(--shadow);
  display: grid;
  gap: 20px;
  border: 2px solid var(--gold);
  overflow: hidden;
}

.modal-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.8;
}

.modal-card h2 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-gold);
  text-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
  letter-spacing: 0.1em;
}

.modal-card p {
  margin: 0;
  color: var(--muted);
}

.legal-modal {
  max-width: min(480px, 95vw);
  max-height: 80vh;
  overflow-y: auto;
}

.legal-content {
  text-align: left;
  max-height: 60vh;
  overflow-y: auto;
  padding: 16px 0;
  border-top: 1px solid rgba(255, 215, 0, 0.2);
  border-bottom: 1px solid rgba(255, 215, 0, 0.2);
  margin: 16px 0;
}

.legal-content p {
  margin-bottom: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.legal-content ul {
  margin: 12px 0;
  padding-left: 20px;
}

.legal-content li {
  margin-bottom: 8px;
  line-height: 1.4;
  color: var(--muted);
}

.legal-content h3 {
  color: var(--text-gold);
  font-size: 1.1rem;
  margin: 0 0 16px 0;
  text-align: center;
  font-weight: 700;
}

.legal-content h4 {
  color: var(--text);
  font-size: 0.95rem;
  margin: 20px 0 12px 0;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 215, 0, 0.2);
  padding-bottom: 4px;
}

.legal-content a {
  color: var(--text-gold);
  text-decoration: underline;
  transition: color 0.2s ease;
}

.legal-content a:hover {
  color: var(--gold);
}

.btn.secondary {
  background: transparent;
  color: var(--text);
  border: 2px solid rgba(248, 250, 252, 0.3);
  box-shadow: none;
}

.btn.secondary:hover {
  border-color: var(--gold);
  color: var(--text-gold);
}


.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 30;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 14px;
  background: #fff;
  opacity: 0;
  animation: confettiFall linear forwards;
}

/* Casino chip confetti */
.confetti-chip {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  opacity: 0;
  animation: confettiFall linear forwards;
  border: 2px solid #fff;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
}

.confetti-chip::before {
  content: '$';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

/* Gold coin confetti */
.confetti-coin {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  opacity: 0;
  animation: confettiFall linear forwards;
  background: radial-gradient(circle at 30% 30%, #ffd700, #b8860b);
  border: 1px solid #8b7355;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
}

.confetti-coin::before {
  content: '♦';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #8b7355;
  font-size: 8px;
  font-weight: bold;
}

/* Star confetti */
.confetti-star {
  position: absolute;
  width: 12px;
  height: 12px;
  opacity: 0;
  animation: confettiFall linear forwards;
  background: transparent;
}

.confetti-star::before {
  content: '★';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  color: #ffd700;
  text-shadow: 0 0 4px rgba(255, 215, 0, 0.8);
}

/* Diamond confetti */
.confetti-diamond {
  position: absolute;
  width: 10px;
  height: 10px;
  opacity: 0;
  animation: confettiFall linear forwards;
  background: transparent;
}

.confetti-diamond::before {
  content: '♦';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  color: #ff4757;
  text-shadow: 0 0 3px rgba(255, 71, 87, 0.8);
}

/* Spade confetti */
.confetti-spade {
  position: absolute;
  width: 10px;
  height: 10px;
  opacity: 0;
  animation: confettiFall linear forwards;
  background: transparent;
}

.confetti-spade::before {
  content: '♠';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  color: #2f3542;
  text-shadow: 0 0 3px rgba(47, 53, 66, 0.8);
}

@keyframes confettiFall {
  0% {
    transform: translateY(-20vh) rotate(0deg) scale(1);
    opacity: 0;
  }
  5% {
    opacity: 1;
  }
  15% {
    transform: translateY(-15vh) rotate(180deg) scale(1.2);
  }
  100% {
    transform: translateY(110vh) rotate(720deg) scale(0.8);
    opacity: 0;
  }
}

@keyframes chipSpin {
  0% {
    transform: translateY(-20vh) rotate(0deg) rotateY(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  50% {
    transform: translateY(40vh) rotate(360deg) rotateY(180deg);
  }
  100% {
    transform: translateY(110vh) rotate(720deg) rotateY(360deg);
    opacity: 0;
  }
}

@keyframes particleBurst {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--endX, 50%), var(--endY, 100%)) scale(0);
    opacity: 0;
  }
}

.footnote {
  padding: 2px 0 4px;
  color: rgba(248, 250, 252, 0.4);
  font-size: 0.55rem;
  text-align: center;
  position: relative;
  margin-top: auto;
  flex-shrink: 0;
}

.footer-links {
  margin-bottom: 4px;
  font-size: 0.6rem;
}

.footer-links a {
  color: rgba(248, 250, 252, 0.6);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-links a:hover {
  color: var(--text-gold);
  text-decoration: underline;
}

.footer-links span {
  margin: 0 6px;
  color: rgba(248, 250, 252, 0.3);
}

.footnote::before {
  content: '♠ ♥ ♦ ♣';
  display: block;
  margin-bottom: 4px;
  color: var(--gold);
  opacity: 0.6;
  letter-spacing: 6px;
  font-size: 0.8rem;
}

/* Minimal Tutorial Hints */

.button-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  margin-top: 8px;
  opacity: 1;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.button-hint.hidden {
  opacity: 0;
}

[hidden] {
  display: none !important;
}

@media (min-width: 640px) {
  .content {
    width: min(480px, 85vw);
    padding: 28px 26px;
    gap: 18px;
  }

  .wheel-shell {
    width: min(400px, 70vw);
  }
}

@media (max-width: 520px) {
  .content {
    width: min(350px, 95vw);
    padding: 30px 10px 20px;
    gap: 15px;
    margin-top: 30px;
  }

  .wheel-shell {
    width: min(330px, 82vw);
    margin: 0;
    padding: 8px;
  }

  .btn.primary,
  #spin {
    width: 90%;
    font-size: 0.95rem;
    padding: 10px 18px;
  }

  .headline {
    font-size: clamp(1.9rem, 5.2vw, 2.3rem);
    line-height: 1.1;
    margin-bottom: 15px;
    padding-bottom: 8px;
  }

  .tag {
    font-size: 0.75rem;
    margin-bottom: 8px;
  }

  .wheel-zone {
    gap: 18px;
    margin-top: clamp(36px, 12vw, 56px);
  }

  .wrap {
    padding-top: max(env(safe-area-inset-top), 50px);
    padding-bottom: max(env(safe-area-inset-bottom), 10px);
    padding-left: 8px;
    padding-right: 8px;
  }
}

@media (min-width: 920px) {
  body {
    background-size: cover;
  }

  .wrap {
    padding: 20px;
  }

  .content {
    width: 520px;
    padding: 32px 28px;
    gap: 20px;
  }

  .wheel-shell {
    width: 420px;
  }
}

@media (max-width: 375px) {
  .content {
    width: min(340px, 97vw);
    padding: 25px 6px 15px;
    gap: 12px;
    margin-top: 25px;
  }

  .wheel-shell {
    width: min(310px, 78vw);
    padding: 6px;
  }

  .headline {
    font-size: clamp(1.7rem, 4.8vw, 2.1rem);
    line-height: 1.05;
    margin-bottom: 12px;
    padding-bottom: 6px;
  }

  .btn.primary,
  #spin {
    font-size: 0.85rem;
    padding: 8px 16px;
    width: 92%;
  }

  .wheel-zone {
    gap: 15px;
    margin-top: clamp(32px, 14vw, 52px);
  }

  .wrap {
    padding-top: max(env(safe-area-inset-top), 45px);
    padding-bottom: max(env(safe-area-inset-bottom), 8px);
    padding-left: 4px;
    padding-right: 4px;
  }
}

@media (max-width: 320px) {
  .wheel-shell {
    width: min(290px, 75vw);
    padding: 4px;
  }

  .headline {
    font-size: clamp(1.5rem, 4.2vw, 1.9rem);
    line-height: 1.0;
    margin-bottom: 6px;
    padding-bottom: 3px;
  }

  .content {
    gap: 3px;
    padding: 3px 4px;
  }

  .wheel-zone {
    gap: 8px;
    margin-top: clamp(24px, 18vw, 40px);
  }

  .wrap {
    padding: 6px 3px 2px;
  }

  .tag {
    font-size: 0.68rem;
    margin-bottom: 2px;
  }

  .btn.primary,
  #spin {
    font-size: 0.8rem;
    padding: 7px 14px;
  }
}

/* iPhone 15 Pro and similar devices with notch */
@media screen and (device-width: 393px) and (device-height: 852px) and (-webkit-device-pixel-ratio: 3) {
  body {
    padding: 0;
    margin: 0;
    background-attachment: fixed;
  }

  .wrap {
    padding-top: max(env(safe-area-inset-top), 60px);
    padding-bottom: max(env(safe-area-inset-bottom), 10px);
    padding-left: 6px;
    padding-right: 6px;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .content {
    width: min(360px, 95vw);
    padding: 35px 8px 20px;
    gap: 15px;
    margin-top: 20px;
  }

  .wheel-shell {
    width: min(340px, 82vw);
    padding: 8px;
  }

  .wheel-zone {
    gap: 18px;
    margin-top: clamp(36px, 12vw, 56px);
  }

  .headline {
    margin-bottom: 15px;
    padding-bottom: 8px;
  }

  .tag {
    margin-bottom: 8px;
  }

  .footnote {
    padding: 3px 0 5px;
    font-size: 0.55rem;
  }
}

/* General iOS safe area support */
@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .wrap {
    padding-left: max(env(safe-area-inset-left), 8px);
    padding-right: max(env(safe-area-inset-right), 8px);
  }
}

/* Ensure full coverage on all mobile devices */
@media (max-height: 667px) {
  .wrap {
    padding: 4px 6px 2px;
  }

  .content {
    gap: 3px;
    padding: 3px 4px;
  }

  .wheel-zone {
    margin-top: clamp(20px, 8vh, 32px);
    gap: 10px;
  }

  .headline {
    margin-bottom: 4px;
    padding-bottom: 2px;
  }

  .tag {
    margin-bottom: 2px;
  }

  .wheel-shell {
    width: min(300px, 78vw);
  }
}

/* Force full screen coverage on all iOS devices */
@media only screen and (device-width: 393px) and (device-height: 852px),
       only screen and (device-width: 414px) and (device-height: 896px),
       only screen and (device-width: 375px) and (device-height: 812px) {
  html, body {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
  }

  body {
    background-size: 100vw 100vh;
    background-size: 100vw 100dvh;
    background-repeat: no-repeat;
    background-attachment: fixed;
  }
}

/* Remove any potential white space on mobile browsers */
@media (max-width: 768px) {
  html {
    margin: 0;
    padding: 0;
    width: 100vw;
    overflow-x: hidden;
  }

  body {
    margin: 0;
    padding: 0;
    width: 100vw;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }

  .wrap {
    width: 100vw;
    box-sizing: border-box;
  }
}
