/**
 * Royal Stack
 * @version 1.0.0
 * @author codavax
 * @license Commercial License — CodeCanyon / Envato Market
 * @copyright (c) 2026 codavax. All rights reserved.
 * @see https://codecanyon.net/user/codavax
 *
 * @description
 * Global stylesheet — normalize, BEM conventions, Royal Neon & Glassmorphism theme.
 * Uses CSS custom properties for full theme customizability.
 * This file follows ES6+ standards for clean, modular, and professional code.
 */

/* ==============================
   LOCAL FONTS
   ============================== */
@font-face {
  font-family: "Montserrat";
  src: url("../assets/fonts/Montserrat-Regular.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: "Montserrat";
  src: url("../assets/fonts/Montserrat-Bold.ttf") format("truetype");
  font-weight: bold;
  font-style: normal;
}

@font-face {
  font-family: "Playfair Display";
  src: url("../assets/fonts/PlayfairDisplay-Bold.ttf") format("truetype");
  font-weight: bold;
  font-style: normal;
}

/* ==============================
   CSS RESET / NORMALIZE
   ============================== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
  line-height: 1.15;
}

body {
  overflow: hidden;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--color-bg);
  font-family: var(--font-body);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ==============================
   DESIGN TOKENS (CUSTOM PROPERTIES)
   ============================== */
:root {
  /* ---- Colors: Royal Neon Theme ---- */
  --color-bg: #120e1f;
  --color-bg-dark: #0a0714;
  --color-surface: rgba(255, 255, 255, 0.06);
  --color-surface-hover: rgba(255, 255, 255, 0.1);
  --color-border: rgba(255, 255, 255, 0.12);
  --color-text: #f0edf6;
  --color-text-muted: rgba(240, 237, 246, 0.55);

  /* ---- Accents ---- */
  --color-gold: #ffd700;
  --color-gold-glow: rgba(255, 215, 0, 0.35);
  --color-cyan: #00f3ff;
  --color-cyan-glow: rgba(0, 243, 255, 0.3);
  --color-green: #00e676;
  --color-red: #ff1744;
  --color-magenta: #e040fb;
  --color-purple: #7e57c2;

  /* ---- Card Grade Colors ---- */
  --card-low-1: #4fc3f7;
  --card-low-2: #66bb6a;
  --card-mid-1: #ff7043;
  --card-mid-2: #ab47bc;
  --card-mid-3: #7e57c2;
  --card-high-1: #ffd700;
  --card-high-2: #e53935;

  /* ---- Typography ---- */
  --font-heading: "Playfair Display", Georgia, serif;
  --font-body: "Montserrat", "Segoe UI", sans-serif;

  /* ---- Spacing Scale ---- */
  --space-xs: clamp(0.25rem, 0.2rem + 0.25vw, 0.5rem);
  --space-sm: clamp(0.5rem, 0.4rem + 0.5vw, 0.75rem);
  --space-md: clamp(1rem, 0.8rem + 1vw, 1.5rem);
  --space-lg: clamp(1.5rem, 1.2rem + 1.5vw, 2.5rem);
  --space-xl: clamp(2rem, 1.5rem + 2.5vw, 4rem);

  /* ---- Borders & Radius ---- */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* ---- Shadows & Glow ---- */
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-neon-gold:
    0 0 16px var(--color-gold-glow), 0 0 40px var(--color-gold-glow);
  --shadow-neon-cyan:
    0 0 16px var(--color-cyan-glow), 0 0 40px var(--color-cyan-glow);

  /* ---- Glassmorphism ---- */
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: 1px solid rgba(255, 255, 255, 0.1);
  --glass-blur: blur(14px);

  /* ---- Transitions ---- */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 150ms var(--ease-out-expo);
  --transition-base: 300ms var(--ease-out-expo);
  --transition-slow: 500ms var(--ease-out-expo);
}

/* ==============================
   GAME CONTAINER
   ============================== */
.game {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-bg);
}

.game__canvas {
  display: block;
}

/* ==============================
   GLASSMORPHISM UTILITY
   ============================== */
.glass {
  background: var(--glass-bg);
  border: var(--glass-border);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-radius: var(--radius-md);
}

/* ==============================
   NEON GLOW UTILITIES
   ============================== */
.glow--gold {
  box-shadow: var(--shadow-neon-gold);
}

.glow--cyan {
  box-shadow: var(--shadow-neon-cyan);
}

/* ==============================
   PLAY NOW OVERLAY (Stage 1)
   ============================== */
.rs-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-bg);
  opacity: 1;
  -webkit-transition: opacity 0.5s var(--ease-out-expo);
  transition: opacity 0.5s var(--ease-out-expo);
}

.rs-overlay--hidden {
  opacity: 0;
  pointer-events: none;
}

.rs-overlay__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 2.5vh, 2rem);
  padding: var(--space-lg);
  text-align: center;
  width: 100%;
  max-width: 420px;
}

/* ---- Crown Icon ---- */
.rs-overlay__crown {
  width: clamp(48px, 12vw, 80px);
  height: auto;
  -webkit-animation: rsCrownPulse 2.4s ease-in-out infinite;
  animation: rsCrownPulse 2.4s ease-in-out infinite;
}

.rs-overlay__crown-svg {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 0 8px var(--color-gold-glow));
}

/* ---- Title ---- */
.rs-overlay__title {
  font-family: var(--font-heading);
  font-size: clamp(1.75rem, 6vw, 2.75rem);
  font-weight: bold;
  color: var(--color-gold);
  letter-spacing: 0.08em;
  text-shadow:
    0 0 12px var(--color-gold-glow),
    0 2px 4px rgba(0, 0, 0, 0.5);
  line-height: 1.1;
}

/* ---- Subtitle ---- */
.rs-overlay__subtitle {
  font-family: var(--font-body);
  font-size: clamp(0.75rem, 2.2vw, 1rem);
  color: var(--color-text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* ---- Play Now Button ---- */
.rs-overlay__btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: clamp(160px, 45vw, 220px);
  padding: clamp(0.75rem, 2vh, 1.1rem) clamp(1.5rem, 5vw, 2.5rem);
  border: 2px solid var(--color-gold);
  border-radius: var(--radius-pill);
  background: linear-gradient(
    135deg,
    rgba(255, 215, 0, 0.15) 0%,
    rgba(126, 87, 194, 0.2) 100%
  );
  cursor: pointer;
  overflow: hidden;
  -webkit-transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.rs-overlay__btn:hover {
  -webkit-transform: scale(1.06);
  transform: scale(1.06);
  box-shadow:
    0 0 20px var(--color-gold-glow),
    0 0 50px rgba(255, 215, 0, 0.15);
}

.rs-overlay__btn:active {
  -webkit-transform: scale(0.95);
  transform: scale(0.95);
}

/* Button glow layer (behind text) */
.rs-overlay__btn-glow {
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  background: radial-gradient(
    ellipse at center,
    var(--color-gold-glow) 0%,
    transparent 70%
  );
  opacity: 0.5;
  -webkit-animation: rsGlowPulse 2s ease-in-out infinite;
  animation: rsGlowPulse 2s ease-in-out infinite;
  pointer-events: none;
}

.rs-overlay__btn-text {
  position: relative;
  z-index: 1;
  font-family: var(--font-body);
  font-weight: bold;
  font-size: clamp(0.875rem, 2.8vw, 1.15rem);
  color: var(--color-gold);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* ---- Footer ---- */
.rs-overlay__footer {
  font-family: var(--font-body);
  font-size: clamp(0.55rem, 1.5vw, 0.7rem);
  color: rgba(240, 237, 246, 0.2);
  margin-top: clamp(1rem, 3vh, 2.5rem);
}

/* ---- Overlay Keyframes ---- */
@-webkit-keyframes rsCrownPulse {
  0%,
  100% {
    -webkit-transform: scale(1);
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    -webkit-transform: scale(1.08);
    transform: scale(1.08);
    opacity: 1;
  }
}
@keyframes rsCrownPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

@-webkit-keyframes rsGlowPulse {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 0.7;
  }
}
@keyframes rsGlowPulse {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 0.7;
  }
}

/* ==============================
   LOADING / PRELOADER (CSS fallback)
   ============================== */
#royal-stack-game {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: 100vw;
  background-color: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Force-center the Phaser canvas on all devices */
#royal-stack-game canvas {
  display: block !important;
  margin: 0 auto !important;
  position: relative !important;
  left: auto !important;
  right: auto !important;
}

/* ==============================
   ANIMATIONS
   ============================== */
@-webkit-keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@-webkit-keyframes pulseGlow {
  0%,
  100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

@keyframes pulseGlow {
  0%,
  100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

@-webkit-keyframes shakeError {
  0%,
  100% {
    -webkit-transform: translateX(0);
    transform: translateX(0);
  }
  20% {
    -webkit-transform: translateX(-6px);
    transform: translateX(-6px);
  }
  40% {
    -webkit-transform: translateX(6px);
    transform: translateX(6px);
  }
  60% {
    -webkit-transform: translateX(-4px);
    transform: translateX(-4px);
  }
  80% {
    -webkit-transform: translateX(4px);
    transform: translateX(4px);
  }
}

@keyframes shakeError {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

@-webkit-keyframes scaleIn {
  from {
    -webkit-transform: scale(0);
    transform: scale(0);
    opacity: 0;
  }
  to {
    -webkit-transform: scale(1);
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@-webkit-keyframes floatUp {
  from {
    -webkit-transform: translateY(0);
    transform: translateY(0);
    opacity: 1;
  }
  to {
    -webkit-transform: translateY(-40px);
    transform: translateY(-40px);
    opacity: 0;
  }
}

@keyframes floatUp {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-40px);
    opacity: 0;
  }
}
