/* Font Face Declarations */
@font-face {
  font-family: 'Trajan Pro';
  src: url('public/fonts/TrajanPro-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'Trajan Pro';
  src: url('public/fonts/TrajanPro-Bold.otf') format('opentype');
  font-weight: bold;
  font-style: normal;
}

@font-face {
  font-family: 'Goudos';
  src: url('public/fonts/GOUDOS.TTF') format('truetype');
  font-weight: normal;
  font-style: normal;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Goudos', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

:root {
  /* Safe area insets for iPhone notch */
  --safe-area-inset-top: env(safe-area-inset-top, 0px);
  --safe-area-inset-right: env(safe-area-inset-right, 0px);
  --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-inset-left: env(safe-area-inset-left, 0px);
}

html {
  height: 100%;
  height: -webkit-fill-available;
  overflow: hidden;
  position: fixed;
  width: 100%;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  /* iPhone Safari fixes */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  /* Prevent iframe-like scrolling */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  /* Fix viewport height issues */
  /* Use CSS variable for dynamic viewport height on iOS */
  --vh: 1vh;
}

body {
  background: #070012;
  color: #f7d06b;
  display: flex;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  position: fixed;
  width: 100%;
  height: 100%;
  height: -webkit-fill-available;
  /* Prevent iOS Safari bounce scrolling */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  /* iPhone Safari rendering optimizations */
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  /* Prevent iframe-like behavior */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: none;
  overscroll-behavior-x: none;
}

.game-wrapper {
  width: 100%;
  max-width: 420px;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile */
  height: -webkit-fill-available; /* iOS Safari fix */
  height: calc(var(--vh, 1vh) * 100); /* Use CSS variable for iOS Safari */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  padding-top: calc(10px + var(--safe-area-inset-top));
  padding-bottom: calc(10px + var(--safe-area-inset-bottom));
  padding-left: calc(10px + var(--safe-area-inset-left));
  padding-right: calc(10px + var(--safe-area-inset-right));
  /* iPhone Safari rendering fixes */
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.game-container {
  position: relative;
  width: 100%;
  height: 90vh;
  height: 90dvh; /* Dynamic viewport height for mobile */
  height: calc(90vh - var(--safe-area-inset-top) - var(--safe-area-inset-bottom));
  max-height: 760px;
  overflow: hidden;
  border-radius: 18px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(247, 208, 107, 0.3);
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  /* iPhone Safari optimizations */
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-perspective: 1000;
  perspective: 1000;
  /* Prevent iframe-like behavior and scrolling */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: none;
  /* Fix rendering issues */
  isolation: isolate;
  contain: layout style paint;
}

    #phaser-game {
      width: 100%;
      height: 100%;
      border-radius: 18px;
      overflow: hidden;
      position: absolute;
      top: 0;
      left: 0;
      z-index: 1;
      /* Mobile performance optimizations */
      -webkit-transform: translate3d(0, 0, 0);
      transform: translate3d(0, 0, 0);
      -webkit-backface-visibility: hidden;
      backface-visibility: hidden;
      will-change: transform;
      /* GPU acceleration */
      -webkit-perspective: 1000;
      perspective: 1000;
      /* Smooth rendering */
      image-rendering: -webkit-optimize-contrast;
      image-rendering: crisp-edges;
      -webkit-backface-visibility: hidden;
    }
    
    /* Loading screen styles */
    .loading-screen {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: #070012;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      z-index: 1000;
      border-radius: 18px;
    }

/* Memory Match Game – Match the Orchid */

.memory-game-container {
  padding: 16px;
  background: radial-gradient(circle at top, #24113a 0%, #070012 55%, #020008 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}

.memory-header {
  text-align: center;
  margin-bottom: 12px;
}

.memory-logo img {
  max-height: 40px;
  margin-bottom: 4px;
}

.memory-title {
  font-family: 'Trajan Pro', serif;
  font-size: 18px;
  letter-spacing: 1.5px;
  color: #f7d06b;
  margin-bottom: 4px;
}

.memory-subtitle {
  font-size: 11px;
  line-height: 1.4;
  color: rgba(247, 208, 107, 0.85);
  margin-bottom: 8px;
}

.memory-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.memory-stat {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(7, 0, 18, 0.8);
  border: 1px solid rgba(247, 208, 107, 0.4);
  font-size: 10px;
  display: flex;
  flex-direction: column;
  min-width: 70px;
}

.memory-stat .label {
  text-transform: uppercase;
  opacity: 0.7;
  font-size: 9px;
}

.memory-stat .value {
  font-size: 13px;
}

.memory-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 1fr;
  gap: 8px;
  padding: 4px;
}

.memory-card {
  position: relative;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  perspective: 800px;
}

.memory-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  transform-style: preserve-3d;
  transition: transform 0.35s ease;
}

.memory-card-front,
.memory-card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.memory-card-front {
  background: radial-gradient(circle at 30% 0%, #493467 0%, #17071f 45%, #070012 100%);
  border: 1px solid rgba(247, 208, 107, 0.4);
}

.memory-card-back {
  background: #070012;
  border: 1px solid rgba(247, 208, 107, 0.7);
  transform: rotateY(180deg);
}

.memory-card img {
  max-width: 70%;
  max-height: 70%;
  object-fit: contain;
}

.memory-card.flipped .memory-card-inner,
.memory-card.matched .memory-card-inner {
  transform: rotateY(180deg);
}

.memory-card.matched .memory-card-back {
  box-shadow: 0 0 10px rgba(247, 208, 107, 0.9);
}

.memory-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.memory-btn {
  flex: 1;
  font-size: 11px;
  padding: 8px 10px;
}

.memory-message {
  margin-top: 8px;
  font-size: 11px;
  text-align: center;
  color: #f7d06b;
}

/* Pick-Your-Path Quiz – Find Your Ayurvedic Mood */

.quiz-game-container {
  padding: 16px;
  background: radial-gradient(circle at top, #24113a 0%, #070012 55%, #020008 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.quiz-header {
  text-align: center;
  margin-bottom: 12px;
}

.quiz-logo img {
  max-height: 40px;
  margin-bottom: 4px;
}

.quiz-title {
  font-family: 'Trajan Pro', serif;
  font-size: 18px;
  letter-spacing: 1.5px;
  color: #f7d06b;
  margin-bottom: 4px;
}

.quiz-subtitle {
  font-size: 11px;
  line-height: 1.4;
  color: rgba(247, 208, 107, 0.85);
}

.quiz-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 4px;
}

.quiz-question {
  font-size: 14px;
  text-align: center;
  margin-bottom: 12px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-option-btn {
  font-size: 11px;
  padding: 9px 10px;
  text-align: center;
}

.quiz-progress {
  margin-top: 10px;
  font-size: 11px;
  text-align: center;
  opacity: 0.8;
}

.quiz-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.quiz-btn {
  flex: 1;
  font-size: 11px;
  padding: 8px 10px;
}

.quiz-result {
  margin-top: 10px;
  text-align: center;
  font-size: 11px;
}

.quiz-mood-title {
  font-family: 'Trajan Pro', serif;
  font-size: 15px;
  margin-bottom: 6px;
}

.quiz-mood-description {
  margin-bottom: 6px;
}

.quiz-mood-suggestion {
  font-size: 10px;
  opacity: 0.9;
}

/* Tap‑to‑Collect – Lotus Collector */

.lotus-game-container {
  padding: 16px;
  background: radial-gradient(circle at top, #24113a 0%, #070012 55%, #020008 100%);
  display: flex;
  flex-direction: column;
}

.lotus-header {
  text-align: center;
  margin-bottom: 10px;
}

.lotus-logo img {
  max-height: 40px;
  margin-bottom: 4px;
}

.lotus-title {
  font-family: 'Trajan Pro', serif;
  font-size: 18px;
  letter-spacing: 1.5px;
  color: #f7d06b;
  margin-bottom: 4px;
}

.lotus-subtitle {
  font-size: 11px;
  line-height: 1.4;
  color: rgba(247, 208, 107, 0.85);
}

.lotus-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.lotus-stat {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(7, 0, 18, 0.8);
  border: 1px solid rgba(247, 208, 107, 0.4);
  font-size: 10px;
  display: flex;
  flex-direction: column;
  min-width: 70px;
}

.lotus-stat .label {
  text-transform: uppercase;
  opacity: 0.7;
  font-size: 9px;
}

.lotus-stat .value {
  font-size: 13px;
}

.lotus-play-area {
  flex: 1;
  position: relative;
  margin-top: 10px;
  border-radius: 14px;
  border: 1px solid rgba(247, 208, 107, 0.4);
  background: radial-gradient(circle at 20% 0%, rgba(248, 215, 122, 0.2), transparent 55%), radial-gradient(circle at 80% 100%, rgba(144, 92, 255, 0.25), transparent 55%), #05000c;
  overflow: hidden;
}

.lotus-target {
  position: absolute;
  border-radius: 999px;
  border: 1px solid rgba(247, 208, 107, 0.9);
  background: radial-gradient(circle at 30% 0%, #f8d77a 0%, #c08b29 45%, #7a4a14 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 14px rgba(248, 215, 122, 0.9);
  cursor: pointer;
  padding: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.lotus-target img {
  width: 70%;
  height: 70%;
  object-fit: contain;
}

.lotus-target.lotus-hit {
  transform: scale(0.8);
  box-shadow: 0 0 6px rgba(248, 215, 122, 0.7);
}

.lotus-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.lotus-btn {
  flex: 1;
  font-size: 11px;
  padding: 8px 10px;
}

.lotus-message {
  margin-top: 8px;
  font-size: 11px;
  text-align: center;
  color: #f7d06b;
}

/* Other Games page */

.other-games-container {
  padding: 16px;
  background: radial-gradient(circle at top, #24113a 0%, #070012 55%, #020008 100%);
  display: flex;
  flex-direction: column;
}

.other-games-header {
  text-align: center;
  margin-bottom: 12px;
}

.other-games-logo img {
  max-height: 40px;
  margin-bottom: 4px;
}

.other-games-title {
  font-family: 'Trajan Pro', serif;
  font-size: clamp(20px, 5vw, 22px);
  letter-spacing: 1.5px;
  color: #f7d06b;
  margin-bottom: 6px;
  text-align: center;
}

.other-games-subtitle {
  font-size: clamp(12px, 3vw, 13px);
  line-height: 1.5;
  color: rgba(247, 208, 107, 0.9);
  text-align: center;
}

.other-games-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.other-game-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  text-align: center;
  width: 100%;
}

.other-game-link {
  font-size: clamp(13px, 3.2vw, 14px);
  text-align: center;
  width: 100%;
  max-width: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.other-game-note {
  display: block;
  font-size: clamp(12px, 3vw, 13px);
  opacity: 0.9;
  text-align: center;
  width: 100%;
  max-width: 280px;
  line-height: 1.4;
  padding: 0 8px;
}

.other-games-footer {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.other-games-back-btn {
  font-size: clamp(13px, 3.2vw, 14px);
  padding: 10px 20px;
  text-align: center;
}

/* One‑Tap Timing – Drop into the Bowl */

.bowl-game-container {
  padding: 16px;
  background: radial-gradient(circle at top, #24113a 0%, #070012 55%, #020008 100%);
  display: flex;
  flex-direction: column;
}

.bowl-header {
  text-align: center;
  margin-bottom: 10px;
}

.bowl-logo img {
  max-height: 40px;
  margin-bottom: 4px;
}

.bowl-title {
  font-family: 'Trajan Pro', serif;
  font-size: 18px;
  letter-spacing: 1.5px;
  color: #f7d06b;
  margin-bottom: 4px;
}

.bowl-subtitle {
  font-size: 11px;
  line-height: 1.4;
  color: rgba(247, 208, 107, 0.85);
}

.bowl-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.bowl-stat {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(7, 0, 18, 0.8);
  border: 1px solid rgba(247, 208, 107, 0.4);
  font-size: 10px;
  display: flex;
  flex-direction: column;
  min-width: 70px;
}

.bowl-stat .label {
  text-transform: uppercase;
  opacity: 0.7;
  font-size: 9px;
}

.bowl-stat .value {
  font-size: 13px;
}

.bowl-play-area {
  flex: 1;
  position: relative;
  margin-top: 10px;
  border-radius: 14px;
  border: 1px solid rgba(247, 208, 107, 0.4);
  background: radial-gradient(circle at 30% 0%, rgba(248, 215, 122, 0.18), transparent 55%), radial-gradient(circle at 80% 100%, rgba(144, 92, 255, 0.22), transparent 55%), #05000c;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.bowl-zone {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 50px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bowl-shape {
  width: 100%;
  height: 32px;
  border-radius: 0 0 40px 40px;
  border: 2px solid #f8d77a;
  border-top: none;
  box-shadow: 0 0 10px rgba(248, 215, 122, 0.7);
}

.bowl-drop-indicator {
  position: absolute;
  bottom: 60px;
  left: 10px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: radial-gradient(circle at 20% 0%, #f8d77a 0%, #c08b29 45%, #7a4a14 100%);
  box-shadow: 0 0 12px rgba(248, 215, 122, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateX(0);
  transition: transform 0.1s linear;
}

.bowl-drop-indicator img {
  width: 80%;
  height: 80%;
  object-fit: contain;
}

.bowl-slider-track {
  position: absolute;
  bottom: 90px;
  left: 10px;
  right: 10px;
  height: 4px;
  border-radius: 999px;
  background: rgba(247, 208, 107, 0.25);
}

.bowl-slider {
  position: absolute;
  top: -4px;
  left: 0;
  width: 40px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f8d77a, #e5af35);
  box-shadow: 0 0 8px rgba(248, 215, 122, 0.9);
  transform: translateX(0);
}

.bowl-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.bowl-btn {
  flex: 1;
  font-size: 11px;
  padding: 8px 10px;
}

.bowl-message {
  margin-top: 8px;
  font-size: 11px;
  text-align: center;
  color: #f7d06b;
}

.bowl-zone.bowl-hit .bowl-shape {
  box-shadow: 0 0 18px rgba(150, 255, 150, 0.9);
  border-color: #c6ffb6;
}

.bowl-zone.bowl-miss .bowl-shape {
  box-shadow: 0 0 14px rgba(255, 120, 120, 0.9);
  border-color: #ff9595;
}

/* Mini Hoop Shot */

.hoop-game-container {
  padding: 16px;
  background: radial-gradient(circle at top, #24113a 0%, #070012 55%, #020008 100%);
  display: flex;
  flex-direction: column;
}

.hoop-header {
  text-align: center;
  margin-bottom: 10px;
}

.hoop-logo img {
  max-height: 40px;
  margin-bottom: 4px;
}

.hoop-title {
  font-family: 'Trajan Pro', serif;
  font-size: 18px;
  letter-spacing: 1.5px;
  color: #f7d06b;
  margin-bottom: 4px;
}

.hoop-subtitle {
  font-size: 11px;
  line-height: 1.4;
  color: rgba(247, 208, 107, 0.85);
}

.hoop-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.hoop-stat {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(7, 0, 18, 0.8);
  border: 1px solid rgba(247, 208, 107, 0.4);
  font-size: 10px;
  display: flex;
  flex-direction: column;
  min-width: 70px;
}

.hoop-stat .label {
  text-transform: uppercase;
  opacity: 0.7;
  font-size: 9px;
}

.hoop-stat .value {
  font-size: 13px;
}

.hoop-play-area {
  flex: 1;
  position: relative;
  margin-top: 10px;
  border-radius: 14px;
  border: 1px solid rgba(247, 208, 107, 0.4);
  background: radial-gradient(circle at 20% 0%, rgba(248, 215, 122, 0.2), transparent 55%), radial-gradient(circle at 80% 100%, rgba(144, 92, 255, 0.22), transparent 55%), #05000c;
  overflow: hidden;
}

.hoop-rim {
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 10px;
  display: flex;
  justify-content: center;
}

.hoop-rim-bar {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f8d77a, #e5af35);
  box-shadow: 0 0 10px rgba(248, 215, 122, 0.9);
}

.hoop-ball {
  position: absolute;
  bottom: 16px;
  left: 50%;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 0%, #ffcf7a 0%, #ff8f3a 50%, #c35a19 100%);
  box-shadow: 0 0 10px rgba(255, 180, 90, 0.9);
  transform: translate(-50%, 0);
}

.hoop-floor {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 14px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.6));
}

.hoop-power-bar {
  position: absolute;
  left: 12px;
  bottom: 20px;
  right: 12px;
  height: 6px;
  border-radius: 999px;
  background: rgba(247, 208, 107, 0.2);
  overflow: hidden;
}

.hoop-power-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #f8d77a, #e5af35);
  box-shadow: 0 0 8px rgba(248, 215, 122, 0.8);
  transition: width 0.06s linear;
}

.hoop-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.hoop-btn {
  flex: 1;
  font-size: 11px;
  padding: 8px 10px;
}

.hoop-message {
  margin-top: 8px;
  font-size: 11px;
  text-align: center;
  color: #f7d06b;
}

.hoop-rim.hoop-hit .hoop-rim-bar {
  box-shadow: 0 0 16px rgba(150, 255, 150, 0.95);
}

.hoop-rim.hoop-miss .hoop-rim-bar {
  box-shadow: 0 0 14px rgba(255, 120, 120, 0.95);
}

/* Spa Hoop - Messenger-style basketball */

.spa-hoop-container {
  padding: 16px;
  background: radial-gradient(circle at top, #24113a 0%, #070012 55%, #020008 100%);
  display: flex;
  flex-direction: column;
}

.spa-hoop-header {
  text-align: center;
  margin-bottom: 10px;
}

.spa-hoop-logo img {
  max-height: 40px;
  margin-bottom: 4px;
}

.spa-hoop-title {
  font-family: 'Trajan Pro', serif;
  font-size: 18px;
  letter-spacing: 1.5px;
  color: #f7d06b;
  margin-bottom: 4px;
}

.spa-hoop-subtitle {
  font-size: 11px;
  line-height: 1.4;
  color: rgba(247, 208, 107, 0.85);
}

.spa-hoop-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.spa-hoop-stat {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(7, 0, 18, 0.8);
  border: 1px solid rgba(247, 208, 107, 0.4);
  font-size: 10px;
  display: flex;
  flex-direction: column;
  min-width: 70px;
}

.spa-hoop-stat .label {
  text-transform: uppercase;
  opacity: 0.7;
  font-size: 9px;
}

.spa-hoop-stat .value {
  font-size: 13px;
}

.spa-hoop-play-area {
  flex: 1;
  position: relative;
  margin-top: 10px;
  border-radius: 14px;
  border: 1px solid rgba(247, 208, 107, 0.4);
  background: radial-gradient(circle at 20% 0%, rgba(248, 215, 122, 0.2), transparent 55%), radial-gradient(circle at 80% 100%, rgba(144, 92, 255, 0.22), transparent 55%), #05000c;
  overflow: hidden;
  min-height: 300px;
  touch-action: none;
}

.spa-hoop-rim {
  position: absolute;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  width: 90px;
  height: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.spa-hoop-rim-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f8d77a, #e5af35);
  box-shadow: 0 0 12px rgba(248, 215, 122, 0.9);
}

.spa-hoop-ball {
  position: absolute;
  width: 50px;
  height: 50px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 0%, #ffcf7a 0%, #ff8f3a 50%, #c35a19 100%);
  box-shadow: 0 0 12px rgba(255, 180, 90, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  transition: transform 0.1s ease;
}

.spa-hoop-ball img {
  width: 70%;
  height: 70%;
  object-fit: contain;
  opacity: 0.9;
}

.spa-hoop-ball:active {
  transform: translate(-50%, -50%) scale(0.95);
}

.spa-hoop-instruction {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: rgba(247, 208, 107, 0.8);
  text-align: center;
  pointer-events: none;
}

.spa-hoop-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.spa-hoop-btn {
  flex: 1;
  font-size: 11px;
  padding: 8px 10px;
}

.spa-hoop-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  color: #f7d06b;
  background: rgba(7, 0, 18, 0.9);
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid rgba(247, 208, 107, 0.6);
  pointer-events: none;
  z-index: 100;
}

.spa-hoop-message.success {
  color: #c6ffb6;
  border-color: rgba(150, 255, 150, 0.8);
  box-shadow: 0 0 16px rgba(150, 255, 150, 0.6);
}

    
    .loading-screen.hidden {
      display: none;
    }
    
    .loading-text {
      font-family: 'Goudos', sans-serif;
      font-size: 32px;
      color: #f7d06b;
      margin-bottom: 20px;
      font-weight: bold;
    }
    
    .loading-percent {
      font-family: 'Goudos', sans-serif;
      font-size: 24px;
      color: #f7d06b;
      margin-bottom: 20px;
    }
    
    .loading-bar-container {
      width: calc(100% - 80px);
      max-width: 300px;
      height: 20px;
      background: #1a1a2e;
      border: 2px solid #f7d06b;
      border-radius: 10px;
      overflow: hidden;
      position: relative;
    }
    
    .loading-bar-fill {
      height: 100%;
      background: #f7d06b;
      width: 0%;
      transition: width 0.3s ease;
      border-radius: 8px;
      backface-visibility: hidden;
      -webkit-perspective: 1000;
      perspective: 1000;
      will-change: transform;
      /* Prevent iframe-like behavior */
      -webkit-overflow-scrolling: touch;
      overscroll-behavior: none;
    }

    #phaser-game canvas {
      border-radius: 18px;
      display: block !important;
      width: 100% !important;
      height: 100% !important;
      /* iPhone Safari rendering fixes */
      -webkit-transform: translateZ(0);
      transform: translateZ(0);
      -webkit-backface-visibility: hidden;
      backface-visibility: hidden;
      image-rendering: -webkit-optimize-contrast;
      image-rendering: crisp-edges;
      /* Prevent lag and jank */
      will-change: auto;
      /* Fix iframe-like scrolling issues */
      touch-action: none;
      -webkit-touch-callout: none;
    }

/* Sound Toggle Button - Matches Game Style */
.sound-toggle-btn {
  position: absolute;
  top: calc(100px + var(--safe-area-inset-top));
  right: calc(16px + var(--safe-area-inset-right));
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: rgba(7, 0, 18, 0.7);
  border: 1px solid rgba(247, 208, 107, 0.4);
  color: #f7d06b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.45);
  padding: 0;
  min-height: 44px;
}

.sound-icon {
  width: 22px;
  height: 22px;
  fill: #f7d06b;
  color: #f7d06b;
  transition: all 0.2s ease;
}

.sound-toggle-btn:hover {
  background: rgba(7, 0, 18, 0.85);
  border-color: rgba(247, 208, 107, 0.7);
  transform: translateY(1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6);
}

.sound-toggle-btn:hover .sound-icon {
  fill: #f8d77a;
  color: #f8d77a;
}

.sound-toggle-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.sound-toggle-btn.muted {
  opacity: 0.6;
  border-color: rgba(128, 128, 128, 0.4);
}

.sound-toggle-btn.muted .sound-icon {
  fill: #f7d06b;
  color: #f7d06b;
  opacity: 0.5;
}

.sound-toggle-btn.muted:hover {
  border-color: rgba(128, 128, 128, 0.6);
  opacity: 0.8;
}

.sound-toggle-btn.muted:hover .sound-icon {
  fill: #f7d06b;
  opacity: 0.7;
}

.sound-icon.muted-icon {
  display: none;
}

.sound-toggle-btn.muted .sound-icon:not(.muted-icon) {
  display: none;
}

.sound-toggle-btn.muted .sound-icon.muted-icon {
  display: block;
}

/* Top bar */
.hud {
  position: absolute;
  top: calc(10px + var(--safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 calc(16px + var(--safe-area-inset-left)) 0 calc(16px + var(--safe-area-inset-right));
  font-size: 14px;
  z-index: 5;
}

.hud span {
  background: rgba(7, 0, 18, 0.7);
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(247, 208, 107, 0.4);
  font-size: clamp(12px, 3vw, 14px);
}

/* Basket */
.basket {
  position: absolute;
  bottom: 20px;
  width: 90px;
  height: 40px;
  background: linear-gradient(180deg, #f8d77a, #c08b29);
  border-radius: 20px 20px 10px 10px;
  box-shadow: 0 0 12px rgba(248, 215, 122, 0.7);
  transition: left 0.1s ease-out;
}

.basket::before {
  /* handle */
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  height: 18px;
  bottom: 28px;
  border-radius: 999px;
  border: 3px solid #f8d77a;
}

/* Falling items */
.drop {
  position: absolute;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 10px rgba(200, 150, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffe8ff;
  font-size: 14px;
  pointer-events: none;
  transition: transform 0.1s linear;
}

.drop img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Start & end screens */
.overlay-screen {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top, rgba(25, 7, 52, 0.98), rgba(4, 0, 9, 0.98));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start; /* Changed from center to allow scrolling */
  text-align: center;
  padding: 24px;
  padding-bottom: 100px;
  z-index: 10;
  pointer-events: auto;
  /* Allow scrolling on mobile */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Rules screen specific styling */
#rulesScreen.overlay-screen {
  justify-content: flex-start;
  padding-top: 20px;
  padding-bottom: 120px; /* Extra space for button */
}

.logo-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
  width: 100%;
}

.welcome-logo {
  max-width: 200px;
  max-height: 80px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.flower-decoration {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 16px;
  width: 100%;
}

.welcome-flower,
.start-flower {
  max-width: 120px;
  max-height: 120px;
  width: auto;
  height: auto;
  object-fit: contain;
  opacity: 0.9;
  animation: floatFlower 3s ease-in-out infinite;
}

@keyframes floatFlower {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-10px) rotate(5deg);
  }
}

.overlay-title {
  font-family: 'Trajan Pro', serif;
  font-weight: bold;
  font-size: clamp(22px, 6vw, 28px);
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  line-height: 1.2;
}

.overlay-subtitle {
  font-size: clamp(12px, 3.5vw, 14px);
  opacity: 0.8;
  margin-bottom: 26px;
  max-width: 260px;
  line-height: 1.5;
}

/* Rules Screen */
.rules-content {
  max-width: 320px;
  max-height: 60vh;
  max-height: calc(100vh - 200px); /* Better mobile support */
  overflow-y: auto;
  overflow-x: hidden;
  margin: 20px auto;
  padding: 0 10px;
  text-align: left;
  /* Mobile scrolling fixes */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* Prevent horizontal scroll */
  width: 100%;
  box-sizing: border-box;
  /* Smooth scrolling */
  scroll-behavior: smooth;
}

.rule-section {
  margin-bottom: 20px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border-left: 3px solid #f8d77a;
  /* Prevent content from being cut off */
  min-height: fit-content;
  word-wrap: break-word;
}

.rule-title {
  font-family: 'Trajan Pro', serif;
  font-size: clamp(14px, 4vw, 16px);
  font-weight: bold;
  color: #f8d77a;
  margin-bottom: 8px;
}

.rule-text {
  font-size: clamp(12px, 3vw, 13px);
  line-height: 1.6;
  opacity: 0.9;
  color: #f7f7ff;
}

.rule-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.rule-item:last-child {
  margin-bottom: 0;
}

.rule-asset {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.rule-note {
  margin-top: 8px;
  font-size: clamp(13px, 3.2vw, 14px);
  opacity: 0.8;
  font-style: italic;
}

.rule-formula {
  margin-top: 12px;
  padding: 8px;
  background: rgba(248, 215, 122, 0.1);
  border-radius: 6px;
  text-align: center;
  font-size: clamp(13px, 3.2vw, 14px);
}

.rules-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  margin-right: 8px;
  vertical-align: middle;
  display: inline-block;
}

/* Login Options */
.login-options {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.login-option-btn {
  flex: 1;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(248, 215, 122, 0.3);
  border-radius: 6px;
  color: #f7d06b;
  font-size: clamp(12px, 3vw, 13px);
  cursor: pointer;
  transition: all 0.2s ease;
}

.login-option-btn.active {
  background: rgba(248, 215, 122, 0.2);
  border-color: #f8d77a;
  color: #f8d77a;
  font-weight: 600;
}

.login-option-btn:hover {
  background: rgba(248, 215, 122, 0.15);
}

#otpStatus, #resetOtpStatus {
  margin-top: 8px;
  font-size: clamp(13px, 3.2vw, 14px);
  min-height: 16px;
}

.btn {
  background: linear-gradient(90deg, #f8d77a, #e5af35);
  color: #2b1045;
  border: none;
  border-radius: 999px;
  padding: 12px 28px;
  font-size: clamp(13px, 3.5vw, 14px);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.45);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  touch-action: manipulation;
  min-height: 44px; /* Better touch target for mobile (iOS recommended) */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active,
.btn:hover {
  transform: translateY(1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6);
}

.small-text {
  margin-top: 12px;
  font-size: clamp(12px, 3vw, 13px);
  opacity: 0.8;
}
.attempt-info {
  opacity: 0.9;
  font-size: clamp(12px, 3vw, 13px);
}

/* User Form */
.user-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 280px;
  margin-bottom: 16px;
}

.form-input {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(247, 208, 107, 0.4);
  border-radius: 999px;
  padding: 12px 16px;
  color: #f7d06b;
  font-size: clamp(13px, 3.5vw, 14px);
  text-align: center;
  outline: none;
  transition: all 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  /* Prevent iOS zoom on input focus */
  font-size: 16px;
}

@media screen and (max-width: 480px) {
  .form-input {
    font-size: 16px !important; /* Prevent iOS zoom */
  }
}

.form-input::placeholder {
  color: rgba(247, 208, 107, 0.6);
}

.form-input:focus {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(247, 208, 107, 0.7);
  box-shadow: 0 0 8px rgba(247, 208, 107, 0.3);
}

.profile-tabs {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 280px;
  margin-bottom: 16px;
}

.tab-btn {
  flex: 1;
  border: 1px solid rgba(247, 208, 107, 0.4);
  border-radius: 999px;
  background: transparent;
  color: #f7d06b;
  padding: 10px 0;
  font-weight: 600;
  text-transform: uppercase;
  font-size: clamp(12px, 3vw, 13px);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: linear-gradient(90deg, #f8d77a, #e5af35);
  color: #2b1045;
  border-color: transparent;
}

.tab-btn:not(.active):hover {
  border-color: rgba(247, 208, 107, 0.7);
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 280px;
  margin-top: 12px;
}

.secondary-btn {
  background: transparent;
  border: 1px solid rgba(247, 208, 107, 0.7);
  color: #f7d06b;
}

.danger-btn {
  border-color: rgba(255, 99, 99, 0.7);
  color: #ff8b8b;
}

.danger-btn:hover {
  border-color: rgba(255, 99, 99, 1);
  color: #ffb3b3;
}

.more-games-link {
  display: block;
  text-align: center;
  color: #f7d06b;
  font-size: clamp(13px, 3.2vw, 14px);
  text-decoration: underline;
  opacity: 0.9;
  transition: opacity 0.2s ease;
  cursor: pointer;
}

.more-games-link:hover {
  opacity: 1;
}

.logout-link {
  display: block;
  text-align: center;
  color: #ff8b8b;
  font-size: clamp(13px, 3.2vw, 14px);
  text-decoration: underline;
  opacity: 0.9;
  transition: opacity 0.2s ease;
  cursor: pointer;
  position: absolute;
  bottom: calc(18px + var(--safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
}

.logout-link:hover {
  opacity: 1;
  color: #ffb3b3;
}

/* Dialog */
.dialog-overlay {
  position: absolute;
  inset: 0;
  background: rgba(4, 0, 9, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}

.dialog-card {
  width: 100%;
  max-width: 320px;
  background: rgba(7, 0, 18, 0.95);
  border: 1px solid rgba(247, 208, 107, 0.3);
  border-radius: 18px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.dialog-card.info {
  border-color: rgba(247, 208, 107, 0.3);
}

.dialog-card.success {
  border-color: rgba(129, 255, 188, 0.4);
}

.dialog-card.success .dialog-title {
  color: #8bffb3;
}

.dialog-card.error {
  border-color: rgba(255, 120, 120, 0.5);
}

.dialog-card.error .dialog-title {
  color: #ff8b8b;
}

.dialog-title {
  font-family: 'Trajan Pro', serif;
  font-weight: bold;
  font-size: clamp(16px, 4vw, 18px);
  color: #f8d77a;
  margin-bottom: 12px;
}

.dialog-message {
  font-size: clamp(12px, 3vw, 13px);
  color: rgba(247, 208, 107, 0.85);
  margin-bottom: 18px;
  line-height: 1.5;
}

.dialog-btn {
  width: 100%;
}

/* Leaderboard */
.leaderboard-container {
  width: 100%;
  max-width: 320px;
  max-height: 400px;
  overflow-y: auto;
  margin: 16px 0;
  padding: 0 8px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(7, 0, 18, 0.6);
  border: 1px solid rgba(247, 208, 107, 0.3);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: clamp(12px, 3vw, 14px);
}

.leaderboard-rank {
  font-weight: 700;
  color: #f8d77a;
  min-width: 30px;
  text-align: center;
}

.leaderboard-info {
  flex: 1;
  margin: 0 12px;
  text-align: left;
}

.leaderboard-name {
  font-weight: 600;
  color: #f7d06b;
  margin-bottom: 2px;
}

.leaderboard-mobile {
  font-size: clamp(12px, 3vw, 13px);
  opacity: 0.7;
  color: #f7d06b;
}

.leaderboard-score {
  font-weight: 700;
  color: #f8d77a;
  font-size: clamp(14px, 3.5vw, 16px);
  min-width: 50px;
  text-align: right;
}

.loading-text {
  text-align: center;
  opacity: 0.7;
  font-size: clamp(12px, 3vw, 14px);
}

.empty-leaderboard {
  text-align: center;
  opacity: 0.7;
  font-size: clamp(12px, 3vw, 14px);
  padding: 20px;
}

/* Mobile optimizations */
@media (max-width: 480px) {
  .game-wrapper {
    padding: 5px;
    padding-top: calc(5px + var(--safe-area-inset-top));
    padding-bottom: calc(5px + var(--safe-area-inset-bottom));
  }

  .game-container {
    height: 95vh;
    height: 95dvh;
    height: calc(95vh - var(--safe-area-inset-top) - var(--safe-area-inset-bottom));
    border-radius: 12px;
  }

  .hud {
    padding: 0 calc(12px + var(--safe-area-inset-left)) 0 calc(12px + var(--safe-area-inset-right));
    top: calc(8px + var(--safe-area-inset-top));
  }

  .basket {
    width: 80px;
    height: 35px;
    bottom: calc(15px + var(--safe-area-inset-bottom));
  }

  .drop {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
  .game-wrapper {
    height: -webkit-fill-available;
  }
  
  .game-container {
    height: -webkit-fill-available;
  }
  
  body {
    min-height: -webkit-fill-available;
  }
  
  /* Prevent iOS Safari address bar from causing layout shift */
  .overlay-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
  }
}

/* Prevent iOS Safari zoom on input focus */
input[type="text"],
input[type="tel"],
input[type="password"],
input[type="email"],
input[type="number"] {
  font-size: 16px !important;
}

@media screen and (max-width: 480px) {
  input[type="text"],
  input[type="tel"],
  input[type="password"],
  input[type="email"],
  input[type="number"] {
    font-size: 16px !important;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .game-container {
    max-height: 95vh;
    max-height: 95dvh;
  }

  .overlay-title {
    font-size: 20px;
    margin-bottom: 8px;
  }

  .overlay-subtitle {
    font-size: 12px;
    margin-bottom: 16px;
  }
}

