/* ===========================
   ROYAL FORTUNE — PREMIUM THEME
   =========================== */

@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@400;600;800;900&display=swap');

* {
  box-sizing: border-box;
  user-select: none;
}

:root {
  --gold: #ffd700;
  --gold-light: #ffe066;
  --gold-dark: #b8860b;
  --bg-primary: #0a0a0f;
  --bg-secondary: #111118;
  --bg-card: rgba(255, 215, 0, 0.04);
  --border-gold: rgba(255, 215, 0, 0.25);
  --text-primary: #fff;
  --text-secondary: #c9b87c;
  --accent: #ffd700;
  --glow: rgba(255, 215, 0, 0.5);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  font-family: 'Prompt', sans-serif;
  overflow-x: hidden;
}

/* =========================
   PARTICLE CANVAS (Background)
========================= */
#particleCanvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

#confettiCanvas {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

/* =========================
   APP LAYOUT
========================= */
.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  text-align: center;
  padding: 24px 12px 40px;
  margin: 0 auto;
}

/* =========================
   CROWN + TITLE
========================= */
.crown-icon {
  font-size: clamp(36px, 6vw, 52px);
  margin-bottom: 4px;
  animation: crownFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 12px rgba(255,215,0,0.6));
}

@keyframes crownFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

.title {
  font-size: clamp(24px, 5.5vw, 40px);
  margin: 0 0 4px;
  font-weight: 900;
  letter-spacing: clamp(2px, 0.5vw, 5px);
  background: linear-gradient(135deg, #ffd700, #fff6a0, #ffd700, #b8860b);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: goldShimmer 4s ease-in-out infinite;
  text-shadow: none;
  filter: drop-shadow(0 2px 8px rgba(255,215,0,0.3));
}

@keyframes goldShimmer {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.subtitle {
  font-size: clamp(13px, 2.5vw, 17px);
  color: var(--text-secondary);
  margin: 0 0 10px;
  letter-spacing: clamp(1px, 0.3vw, 3px);
  opacity: 0.8;
}

/* =========================
   WHEEL STAGE
========================= */
.wheel-stage {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: clamp(12px, 2.5vw, 24px) auto 0;
  aspect-ratio: 1 / 1;
}

.wheel-container {
  position: relative;
  overflow: visible;
  width: 100%;
  height: 100%;
  padding: 20px;
  background: var(--bg-card);
  border: 2px solid var(--border-gold);
  border-radius: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 0 60px rgba(255,215,0,0.06),
    inset 0 0 30px rgba(255,255,255,0.02);
  backdrop-filter: blur(8px);
}

/* Animated glowing ring border */
.ring-glow {
  position: absolute;
  inset: -3px;
  border-radius: 32px;
  z-index: -1;
  opacity: 0.45;
  filter: blur(8px);
  background: linear-gradient(135deg, #ffd700, #ff8c00, #ffd700, #ffec80);
  background-size: 400% 400%;
  animation: ringShift 5s ease-in-out infinite;
}

@keyframes ringShift {
  0%   { background-position: 0% 50%; opacity: 0.3; }
  50%  { background-position: 100% 50%; opacity: 0.6; }
  100% { background-position: 0% 50%; opacity: 0.3; }
}

.wheel-wrapper {
  position: relative;
  width: 88%;
  max-width: 420px;
  aspect-ratio: 1 / 1;
  z-index: 8;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.wheel-wrapper::after {
  content: "";
  position: absolute;
  inset: -40px;
  background: radial-gradient(circle, rgba(255,215,0,0.1), transparent 65%);
  z-index: -1;
}

/* =========================
   WHEEL IMAGE
========================= */
#wheel {
  width: 100%;
  height: 100%;
  transition: transform 0.6s ease, opacity 0.6s ease;
  transform-origin: center center;
  border-radius: 50%;
  z-index: 5;
  filter: drop-shadow(0 10px 30px rgba(0,0,0,0.7))
         drop-shadow(0 0 15px rgba(255,215,0,0.15));
}

/* =========================
   ARROW
========================= */
.arrow {
  position: absolute;
  /* Always ~19% of wheel width — scales perfectly on every device */
  width: 19%;
  /* Push arrow up relative to its own height so it sits above the wheel */
  top: calc(-11% * 0.85);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.6));
}

@keyframes shake {
  0%   { transform: translateX(-50%) rotate(0deg); }
  25%  { transform: translateX(-50%) rotate(-4deg); }
  50%  { transform: translateX(-50%) rotate(4deg); }
  75%  { transform: translateX(-50%) rotate(-2deg); }
  100% { transform: translateX(-50%) rotate(0deg); }
}

.arrow.spin {
  animation: shake 0.2s ease-in-out infinite;
}

/* =========================
   SPIN BUTTON (Premium Gold)
========================= */
#spinBtn {
  position: relative;
  margin-top: clamp(10px, 2vw, 20px);
  padding: clamp(11px, 2vw, 18px) clamp(28px, 6vw, 56px);
  font-size: clamp(16px, 3vw, 24px);
  font-weight: 900;
  font-family: 'Prompt', sans-serif;
  letter-spacing: 2px;
  border-radius: 50px;
  border: 2px solid var(--gold);
  cursor: pointer;
  color: #1a1a2e;
  background: linear-gradient(135deg, #ffd700, #ffec80, #ffd700);
  box-shadow:
    0 4px 25px rgba(255,215,0,0.5),
    0 0 60px rgba(255,215,0,0.15),
    inset 0 1px 0 rgba(255,255,255,0.5);
  overflow: hidden;
  transition: all 0.3s ease;
}

#spinBtn:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.03);
  box-shadow:
    0 6px 35px rgba(255,215,0,0.7),
    0 0 80px rgba(255,215,0,0.25),
    inset 0 1px 0 rgba(255,255,255,0.5);
}

#spinBtn:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}

#spinBtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(40%);
}

/* Shine sweep on button */
.btn-shine {
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255,255,255,0.4),
    transparent
  );
  animation: btnShineSweep 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes btnShineSweep {
  0%   { left: -100%; }
  50%  { left: 150%; }
  100% { left: 150%; }
}

/* =========================
   HOW TO PLAY BUTTON
========================= */
.howto-btn {
  margin-top: 6px;
  background: transparent;
  border: 2px solid rgba(255,215,0,0.3);
  color: var(--text-secondary);
  font-size: clamp(13px, 2.2vw, 17px);
  font-weight: 600;
  font-family: 'Prompt', sans-serif;
  cursor: pointer;
  padding: clamp(6px, 1.2vw, 12px) clamp(12px, 2.5vw, 22px);
  border-radius: 25px;
  transition: all 0.3s ease;
  letter-spacing: 1px;
}

.howto-btn:hover {
  background: rgba(255,215,0,0.08);
  border-color: var(--gold);
  color: var(--gold-light);
  transform: translateY(-1px);
}

/* =========================
   RESULT TEXT
========================= */
.result {
  margin-top: clamp(12px, 2vw, 20px);
  font-size: clamp(15px, 2.8vw, 22px);
  font-weight: 800;
  color: var(--gold-light);
  text-shadow: 1px 1px 6px rgba(0,0,0,0.6), 0 0 20px rgba(255,215,0,0.3);
  white-space: pre-line;
  animation: resultFadeIn 0.6s ease;
}

@keyframes resultFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hidden {
  display: none;
}

/* =========================
   JACKPOT EFFECT
========================= */
@keyframes jackpotGlow {
  0%   { box-shadow: 0 0 0 rgba(255,215,0,0); }
  50%  { box-shadow: 0 0 150px rgba(255,215,0,1); }
  100% { box-shadow: 0 0 0 rgba(255,215,0,0); }
}

.jackpot {
  animation: jackpotGlow 1.2s ease-out 3;
  color: gold;
}

/* =========================
   WHEEL TRANSITION EFFECTS
========================= */
.wheel-fade-out {
  transform: scale(1.25);
  opacity: 0;
}

.wheel-fade-in {
  transform: scale(0.9);
  opacity: 0;
}

.wheel-visible {
  transform: scale(1);
  opacity: 1;
}

.wheel-special {
  filter: drop-shadow(0 0 18px rgba(255,215,0,0.9));
  animation: specialPulse 1.4s ease-in-out infinite;
}

@keyframes specialPulse {
  0%   { filter: drop-shadow(0 0 10px rgba(255,215,0,0.6)); }
  50%  { filter: drop-shadow(0 0 30px rgba(255,215,0,1)); }
  100% { filter: drop-shadow(0 0 10px rgba(255,215,0,0.6)); }
}

.wheel-jackpot {
  filter: drop-shadow(0 0 30px rgba(255,215,0,1));
  animation: jackpotPulse 1.8s ease-in-out infinite;
}

@keyframes jackpotPulse {
  0%   { filter: drop-shadow(0 0 18px rgba(255,215,0,0.7)); }
  50%  { filter: drop-shadow(0 0 55px rgba(255,215,0,1)); }
  100% { filter: drop-shadow(0 0 18px rgba(255,215,0,0.7)); }
}

@keyframes tierPop {
  0%   { transform: scale(0.85); }
  60%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.wheel-pop {
  animation: tierPop 0.45s ease-out;
}

/* =========================
   MODAL (Premium Gold Style)
========================= */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(4px);
}

.modal.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  width: 92%;
  max-width: 420px;
  background: linear-gradient(145deg, #111118 0%, #1a1a28 50%, #111118 100%);
  border: 2px solid rgba(255,215,0,0.3);
  border-radius: 20px;
  padding: 28px 24px;
  color: #fff;
  animation: modalPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow:
    0 20px 60px rgba(0,0,0,0.5),
    0 0 40px rgba(255,215,0,0.08),
    inset 0 1px 0 rgba(255,255,255,0.05);
}

.modal-content h2 {
  margin-top: 0;
  color: var(--gold);
  font-size: clamp(16px, 3vw, 22px);
  letter-spacing: 1px;
}

.modal-content ol {
  padding-left: 20px;
  font-size: clamp(12px, 2vw, 15px);
  line-height: 1.8;
  color: #ddd;
}

.tip {
  margin-top: 14px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
}

.close-btn {
  margin-top: 18px;
  width: 100%;
  padding: clamp(10px, 1.8vw, 16px);
  border-radius: 30px;
  border: 2px solid var(--gold);
  font-weight: 800;
  font-family: 'Prompt', sans-serif;
  font-size: clamp(14px, 2.2vw, 17px);
  color: #1a1a2e;
  background: linear-gradient(135deg, #ffd700, #ffec80, #ffd700);
  cursor: pointer;
  box-shadow: 0 4px 25px rgba(255,215,0,0.4);
  transition: all 0.3s ease;
  letter-spacing: 1px;
}

.close-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 30px rgba(255,215,0,0.6);
}

@keyframes modalPop {
  from { transform: scale(0.85) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

/* =========================
   ACTION BUTTONS
========================= */
.action-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

/* ====================================
   RESPONSIVE — COMPREHENSIVE DEVICE SUPPORT
   ====================================

   Breakpoints:
   - 0–374px     : Extra-small phones (SE, Galaxy Fold)
   - 375–480px   : Standard phones (iPhone, Pixel)
   - 481–600px   : Large phones / phablets
   - 601–768px   : Small tablets (iPad Mini portrait)
   - 769–1024px  : Tablets (iPad portrait/landscape)
   - 1025–1440px : Laptops & small desktops
   - 1441px+     : Large desktops / ultrawide
   - Landscape   : Mobile landscape special handling
======================================= */

/* ------------------------------------
   EXTRA SMALL PHONES (≤ 374px)
   Galaxy Fold, iPhone SE, small Android
------------------------------------- */
@media (max-width: 374px) {
  .app {
    padding: 12px 8px 30px;
  }

  .wheel-stage {
    max-width: 98%;
  }

  .wheel-wrapper {
    width: 92%;
  }

  .wheel-container {
    padding: 12px;
    border-radius: 20px;
  }

  .ring-glow { inset: -2px; border-radius: 22px; }

  .action-buttons {
    gap: 6px;
    margin-top: 10px;
  }

  .modal-content {
    padding: 16px 14px;
    border-radius: 16px;
  }

  .tip { font-size: 11px; }
}

/* ------------------------------------
   STANDARD PHONES (375–480px)
   iPhone 8/X/11-16, Pixel, Galaxy S
------------------------------------- */
@media (min-width: 375px) and (max-width: 480px) {
  .app {
    padding: 16px 10px 34px;
  }

  .wheel-stage {
    max-width: 95%;
  }

  .wheel-wrapper {
    width: 90%;
  }

  .wheel-container {
    padding: 14px;
    border-radius: 22px;
  }

  .ring-glow { inset: -2px; border-radius: 24px; }

  .action-buttons {
    gap: 7px;
    margin-top: 12px;
  }
}

/* ------------------------------------
   LARGE PHONES / PHABLETS (481–600px)
   Galaxy Ultra, iPhone Pro Max
------------------------------------- */
@media (min-width: 481px) and (max-width: 600px) {
  .app {
    padding: 18px 14px 36px;
  }

  .wheel-stage {
    max-width: 88%;
  }

  .wheel-wrapper {
    width: 88%;
  }

  .wheel-container {
    padding: 16px;
    border-radius: 26px;
  }

  .ring-glow { inset: -3px; border-radius: 29px; }

  .action-buttons {
    gap: 8px;
    margin-top: 14px;
  }
}

/* ------------------------------------
   SMALL TABLETS (601–768px)
   iPad Mini portrait, small Android tablets
------------------------------------- */
@media (min-width: 601px) and (max-width: 768px) {
  body {
    align-items: flex-start;
    padding-top: 20px;
  }

  .app {
    max-width: 480px;
    padding: 22px 16px 40px;
  }

  .wheel-stage {
    max-width: 440px;
  }

  .wheel-wrapper {
    width: 86%;
  }

  .wheel-container {
    padding: 18px;
    border-radius: 28px;
  }

  .ring-glow { inset: -3px; border-radius: 31px; }

  .action-buttons {
    gap: 10px;
    margin-top: 16px;
  }

  .modal-content {
    max-width: 400px;
  }
}

/* ------------------------------------
   TABLETS (769–1024px)
   iPad 10th gen, iPad Air, iPad Pro 11"
   Android tablets, Surface Go
------------------------------------- */
@media (min-width: 769px) and (max-width: 1024px) {
  body {
    align-items: center;
    padding: 0;
  }

  .app {
    max-width: 520px;
    padding: 28px 20px 48px;
  }

  .wheel-stage {
    max-width: 480px;
  }

  .wheel-wrapper {
    width: 85%;
    max-width: 400px;
  }

  .wheel-container {
    padding: 22px;
    border-radius: 30px;
  }

  .ring-glow { inset: -3px; border-radius: 33px; }

  .action-buttons {
    gap: 10px;
    margin-top: 18px;
  }

  .modal-content {
    max-width: 420px;
    padding: 30px 26px;
  }
}

/* ------------------------------------
   LAPTOPS & SMALL DESKTOPS (1025–1440px)
   MacBook Air/Pro, Surface Laptop,
   13"–15" laptops, small external monitors
------------------------------------- */
@media (min-width: 1025px) and (max-width: 1440px) {
  body {
    align-items: center;
    padding: 0;
  }

  .app {
    max-width: 550px;
    padding: 30px 20px 52px;
  }

  .wheel-stage {
    max-width: 500px;
  }

  .wheel-wrapper {
    width: 84%;
    max-width: 420px;
  }

  .wheel-container {
    padding: 24px;
    border-radius: 32px;
  }

  .ring-glow { inset: -4px; border-radius: 36px; }

  .action-buttons {
    gap: 10px;
    margin-top: 20px;
  }

  .modal-content {
    max-width: 440px;
    padding: 32px 28px;
  }
}

/* ------------------------------------
   LARGE DESKTOPS & ULTRAWIDE (1441px+)
   27" iMac, external monitors, 4K screens
------------------------------------- */
@media (min-width: 1441px) {
  body {
    align-items: center;
    padding: 0;
  }

  .app {
    max-width: 600px;
    padding: 36px 24px 60px;
  }

  .wheel-stage {
    max-width: 540px;
  }

  .wheel-wrapper {
    width: 82%;
    max-width: 440px;
  }

  .wheel-container {
    padding: 28px;
    border-radius: 34px;
  }

  .ring-glow { inset: -4px; border-radius: 38px; }

  .action-buttons {
    gap: 12px;
    margin-top: 22px;
  }

  .modal-content {
    max-width: 460px;
    padding: 34px 30px;
    border-radius: 24px;
  }
}

/* ====================================
   LANDSCAPE MODE — MOBILE & TABLET
   Prevents content being cut off
   on short viewport heights
======================================= */

/* Landscape phones (short height) */
@media (max-height: 500px) and (orientation: landscape) {
  body {
    align-items: flex-start;
    padding: 0;
  }

  .app {
    max-width: 90vh;
    padding: 8px 12px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .crown-icon {
    font-size: 28px;
    margin-bottom: 2px;
  }

  .title {
    font-size: 20px !important;
    margin-bottom: 2px;
  }

  .subtitle {
    font-size: 11px;
    margin-bottom: 4px;
  }

  .wheel-stage {
    max-width: min(65vh, 380px);
    margin-top: 6px;
  }

  .wheel-container {
    padding: 8px;
    border-radius: 16px;
  }

  .ring-glow { inset: -2px; border-radius: 18px; }

  .wheel-wrapper {
    width: 92%;
  }

  /* Arrow inherits % sizing from wheel-wrapper — no override needed */

  #spinBtn {
    padding: 8px 24px;
    font-size: 14px;
    margin-top: 6px;
  }

  .howto-btn {
    padding: 4px 10px;
    font-size: 12px;
    margin-top: 4px;
  }

  .action-buttons {
    gap: 4px;
    margin-top: 6px;
  }

  .result {
    font-size: 13px;
    margin-top: 6px;
  }

  .modal-content {
    max-height: 90vh;
    overflow-y: auto;
    padding: 14px;
  }
}

/* Landscape tablets (medium height) */
@media (min-height: 501px) and (max-height: 768px) and (orientation: landscape) {
  body {
    align-items: flex-start;
    padding-top: 10px;
  }

  .app {
    max-width: 500px;
    padding: 12px 16px 30px;
  }

  .crown-icon {
    font-size: 32px;
    margin-bottom: 2px;
  }

  .wheel-stage {
    max-width: min(55vh, 420px);
    margin-top: 8px;
  }

  .wheel-container {
    padding: 12px;
    border-radius: 22px;
  }

  .ring-glow { inset: -2px; border-radius: 24px; }

  #spinBtn {
    padding: 10px 30px;
    font-size: 16px;
    margin-top: 8px;
  }

  .action-buttons {
    gap: 6px;
    margin-top: 8px;
  }

  .result {
    font-size: 15px;
    margin-top: 8px;
  }
}

/* ====================================
   iPad Pro 12.9" SPECIFIC (1024×1366)
======================================= */
@media (min-width: 1024px) and (max-width: 1100px)
       and (min-height: 1300px) {
  body {
    align-items: center;
  }

  .app {
    max-width: 560px;
    padding: 40px 24px 56px;
  }

  .wheel-stage {
    max-width: 500px;
  }

  .wheel-wrapper {
    width: 84%;
    max-width: 420px;
  }
}

/* ====================================
   HIGH DPI / RETINA DISPLAY
   Sharper shadows & effects
======================================= */
@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi) {
  .wheel-wrapper::after {
    inset: -30px;
  }
}

/* ====================================
   REDUCED MOTION — ACCESSIBILITY
======================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .crown-icon { animation: none; }
  .btn-shine { animation: none; display: none; }
  .ring-glow { animation: none; opacity: 0.4; }
}

/* ====================================
   TOUCH DEVICE OPTIMIZATIONS
======================================= */
@media (hover: none) and (pointer: coarse) {
  #spinBtn {
    min-height: 48px;
    min-width: 120px;
  }

  .howto-btn {
    min-height: 44px;
  }

  .close-btn {
    min-height: 48px;
  }

  #spinBtn:hover:not(:disabled) {
    transform: none;
    box-shadow:
      0 4px 25px rgba(255,215,0,0.5),
      0 0 60px rgba(255,215,0,0.15),
      inset 0 1px 0 rgba(255,255,255,0.5);
  }

  .howto-btn:hover {
    transform: none;
  }
}
