@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@400;700;900&display=swap");

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: "Nunito", "Segoe UI", sans-serif;
  color: white;
  cursor: pointer;
}

/* ========== DESKTOP PREVIEW ========== */
.preview-body {
  background: linear-gradient(135deg, #0d1117 0%, #161b22 50%, #1a2332 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.preview-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  padding: 20px;
}

.mobile-frame {
  height: min(85vh, 700px);
  width: calc(min(85vh, 700px) / 2.17);
  border: 8px solid #111;
  border-radius: 45px;
  background: #87CEEB;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 0 0 2px #333,
    0 25px 60px rgba(0, 0, 0, 0.6),
    0 0 80px rgba(74, 163, 223, 0.15);
}

.notch {
  width: 90px; height: 25px;
  background-color: #000;
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  border-radius: 20px;
  z-index: 1000;
}

.iframe-wrapper {
  width: 100%; height: 100%;
  overflow: hidden;
  position: relative;
  border-radius: 37px;
}

.home-indicator {
  position: absolute;
  bottom: 8px; left: 50%;
  transform: translateX(-50%);
  width: 100px; height: 4px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  z-index: 1000;
}

.iframe-wrapper canvas,
body > canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100% !important;
  height: 100% !important;
  z-index: 0;
}

#cloud-overlay, #score-container, #perfect-indicator,
#layer-name, #tutorial-hand, #instructions, #results, #victory, #game-logo {
  position: absolute;
}

/* Responsive frame sizing */
@media (max-height: 700px) {
  .mobile-frame {
    height: min(80vh, 550px);
    width: calc(min(80vh, 550px) / 2.17);
    border-width: 6px;
    border-radius: 38px;
  }
  .iframe-wrapper { border-radius: 32px; }
  .notch { width: 75px; height: 22px; top: 10px; }
}

@media (min-height: 900px) {
  .mobile-frame {
    height: min(85vh, 800px);
    width: calc(min(85vh, 800px) / 2.17);
    border-width: 10px;
    border-radius: 50px;
  }
  .iframe-wrapper { border-radius: 40px; }
  .notch { width: 100px; height: 28px; top: 14px; }
}

/* ========== MOBILE FULLSCREEN ========== */
@media (max-width: 768px) {
  .preview-body { background: #4aa3df; }
  .preview-container { padding: 0; width: 100%; height: 100%; }
  .mobile-frame {
    width: 100%; height: 100%;
    border: none; border-radius: 0;
    box-shadow: none; background: transparent;
  }
  .notch, .home-indicator { display: none; }
  .iframe-wrapper { border-radius: 0; }
  .iframe-wrapper canvas,
  body > canvas { position: fixed; z-index: 0; }

  #cloud-overlay, #score-container, #perfect-indicator,
  #layer-name, #tutorial-hand, #instructions, #results, #victory, #game-logo {
    position: fixed;
  }
}

/* ========== GAME UI ========== */

/* Subtle cloud wisps */
#cloud-overlay {
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(ellipse 120px 60px at 8% 12%, rgba(255,255,255,0.12) 0%, transparent 70%),
    radial-gradient(ellipse 150px 70px at 88% 8%, rgba(255,255,255,0.1) 0%, transparent 70%),
    radial-gradient(ellipse 100px 50px at 50% 6%, rgba(255,255,255,0.08) 0%, transparent 70%);
}

/* Score */
#score-container {
  top: 16px; right: 16px;
  z-index: 100;
  text-align: center;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 14px;
  padding: 10px 20px;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
}

#score-label {
  font-size: 0.65em;
  font-weight: 700;
  letter-spacing: 2px;
  opacity: 0.8;
  margin-bottom: 2px;
}

#score {
  font-size: 2.6em;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* Perfect indicator */
#perfect-indicator {
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  z-index: 150;
  font-size: 2em;
  font-weight: 900;
  color: #FFD700;
  text-shadow:
    0 0 20px rgba(255, 215, 0, 0.6),
    0 0 40px rgba(255, 215, 0, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              opacity 0.25s ease-out;
}

#perfect-indicator.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

/* Layer name */
#layer-name {
  top: 28%;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  z-index: 150;
  font-size: 1.1em;
  font-weight: 800;
  color: white;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  opacity: 0;
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 18px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

#layer-name.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ========== MODAL SCREENS ========== */
#instructions, #results, #victory {
  display: none;
  align-items: center;
  justify-content: center;
  height: 100%; width: 100%;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#instructions {
  background: linear-gradient(180deg,
    rgba(15, 30, 50, 0.92) 0%,
    rgba(20, 45, 70, 0.88) 50%,
    rgba(25, 60, 95, 0.85) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#results {
  background: linear-gradient(180deg,
    rgba(30, 15, 10, 0.92) 0%,
    rgba(50, 25, 15, 0.88) 50%,
    rgba(60, 30, 20, 0.85) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: default;
}

#victory {
  background: linear-gradient(180deg,
    rgba(40, 30, 5, 0.92) 0%,
    rgba(55, 40, 10, 0.88) 50%,
    rgba(70, 50, 15, 0.85) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: default;
}

/* Smooth fade in */
#instructions.visible,
#results.visible,
#victory.visible {
  opacity: 1;
}


.content {
  max-width: 260px;
  padding: 28px 24px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  text-align: center;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transform: translateY(10px);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.visible .content {
  transform: translateY(0);
}

/* In-game logo at top - hidden by default, shown during gameplay */
#game-logo {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 500;
  pointer-events: none;
  background: none;
  padding: 0;
  display: none;
}

#game-logo img {
  height: 100px;
  width: auto;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.25));
}

/* Logo */
.logo { margin-bottom: 16px; }

.logo-img {
  display: block;
  margin: 0 auto 12px;
  height: 72px;
  width: auto;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
  animation: float 3s ease-in-out infinite;
}

.logo h1 {
  font-size: 1.5em;
  font-weight: 900;
  letter-spacing: 2px;
  margin: 0;
  background: linear-gradient(180deg, #FFD700 0%, #F0A500 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.logo h2 {
  font-size: 0.85em;
  font-weight: 700;
  letter-spacing: 3px;
  margin: 4px 0 0;
  opacity: 0.85;
}

/* Text */
.tagline {
  font-size: 0.95em;
  font-weight: 700;
  margin-bottom: 10px;
  color: #FFD700;
}

.hint {
  font-size: 0.78em;
  opacity: 0.7;
  margin-bottom: 14px;
  line-height: 1.4;
}

.cta {
  font-size: 0.9em;
  font-weight: 700;
  margin-top: 16px;
  opacity: 0.9;
}

.key {
  display: inline-block;
  background: rgba(255, 255, 255, 0.15);
  padding: 3px 8px;
  border-radius: 5px;
  font-weight: 900;
  font-size: 0.85em;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Game over & Victory */
.game-over-icon, .victory-icon {
  font-size: 2.6em;
  margin-bottom: 10px;
}

#results h2 {
  font-size: 1.4em;
  font-weight: 900;
  margin-bottom: 12px;
  letter-spacing: 2px;
  color: #FF8A80;
}

#victory h2 {
  font-size: 1.3em;
  font-weight: 900;
  margin-bottom: 12px;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #FFD700 0%, #FFA000 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.final-score-label {
  font-size: 0.82em;
  opacity: 0.7;
  margin-bottom: 4px;
}

.final-score {
  font-size: 1.8em;
  font-weight: 900;
  color: #FFD700;
  margin-bottom: 18px;
}

.victory-text {
  font-size: 0.85em;
  margin-bottom: 18px;
  line-height: 1.4;
  opacity: 0.9;
}

/* CTA Section */
.cta-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.cta-logo {
  height: 50px;
  width: auto;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}

/* Buy Now CTA Button */
#buy-now-btn, #buy-now-victory-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(180deg, #FFD700 0%, #F0A500 100%);
  color: #3D2314;
  text-decoration: none;
  border: none;
  border-radius: 50px;
  padding: 13px 36px;
  font-size: 1em;
  font-weight: 900;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 16px rgba(255, 215, 0, 0.25);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

#buy-now-btn:hover, #buy-now-victory-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(255, 215, 0, 0.35);
}

#buy-now-btn:active, #buy-now-victory-btn:active {
  transform: scale(0.97);
}

/* Play Again - secondary link */
.replay-link {
  display: inline-block;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.8em;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 6px 12px;
  transition: color 0.2s ease;
  letter-spacing: 0.5px;
}

.replay-link:hover {
  color: rgba(255, 255, 255, 1);
}

/* Victory card */
#victory .content {
  background: linear-gradient(180deg,
    rgba(255, 215, 0, 0.12) 0%,
    rgba(255, 165, 0, 0.06) 100%);
  border-color: rgba(255, 215, 0, 0.3);
}

/* Tutorial hand */
#tutorial-hand {
  bottom: 32%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 250;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

#tutorial-hand.show { opacity: 1; }

.hand-icon {
  font-size: 2.6em;
  animation: tap-bounce 1s ease-in-out infinite;
}

.tap-text {
  font-size: 0.85em;
  font-weight: 900;
  color: #FFD700;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  letter-spacing: 3px;
  animation: tap-fade 1s ease-in-out infinite;
}

/* Animations */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes tap-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

@keyframes tap-fade {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Mobile responsive */
@media (max-width: 768px) {
  .content { max-width: 300px; padding: 32px 28px; }
  .logo-icon { font-size: 3em; }
  .logo h1 { font-size: 1.8em; }
  #score-container { top: 12px; right: 12px; padding: 8px 16px; }
  #score { font-size: 2.2em; }
  #buy-now-btn, #buy-now-victory-btn { padding: 14px 32px; font-size: 1.05em; }
  .cta-logo { height: 45px; }
  #game-logo { top: 12px; left: 12px; }
  #game-logo img { height: 80px; }
}

/* Prevent selection */
body {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

canvas { touch-action: none; z-index: 0; }

html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}
