/* ===============================
   MOBILE RESPONSIVE — CLEAN & FINAL
   NO ROTATION LOGIC IN CSS
   =============================== */

/* ---------- Base image rules (single source of truth) ---------- */
#game-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transform: none !important;
    transform-origin: center center;
    transition: none;
}

/* ---------- Image container ---------- */
.image-container {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* ---------- Tablet + Mobile ---------- */

    @media (min-width: 769px) {
  #game-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }


    /* Header */
    .game-header {
        padding: 12px 20px !important;
        min-height: 70px !important;
    }

    .score-pill,
    .timer-pill {
        padding: 10px 20px !important;
        font-size: 18px !important;
    }

    /* Image area */
    .image-container {
        top: 70px !important;
        bottom: 100px !important;
        height: calc(100vh - 170px) !important;
        padding: 8px !important;
    }

    .fancy-frame {
        width: 90% !important;
        height: 100% !important;
    }

    /* Controls */
    .game-controls {
        height: 100px !important;
    }

    .game-btn {
        font-size: 22px !important;
    }

    .game-btn span {
        font-size: 22px !important;
    }
}

/* ---------- Small phones ---------- */
@media (max-width: 480px) {

    .game-header {
        padding: 10px 15px !important;
        min-height: 60px !important;
    }

    .score-pill,
    .timer-pill {
        font-size: 16px !important;
        padding: 8px 15px !important;
    }
}

/* ---------- FOREHEAD MODE (Landscape phones) ---------- */
/* NOTE: No rotation. Only fitting. */
@media (orientation: landscape) and (max-width: 900px) {

    .image-container {
        top: 60px !important;
        bottom: 80px !important;
        height: calc(100vh - 140px) !important;
        padding: 5px !important;
    }

    .fancy-frame {
        width: 85% !important;
        height: 100% !important;
    }

    /* Image simply fills the wider rectangle */
    #game-image {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}


    .game-header {
        padding: 8px 15px !important;
        min-height: 50px !important;
    }

    .score-pill,
    .timer-pill {
        font-size: 14px !important;
        padding: 6px 12px !important;
    }

    .game-controls {
        height: 80px !important;
    }

    .game-btn {
        font-size: 18px !important;
    }

    .game-btn span {
        font-size: 16px !important;
    }

    /* Hide decorative sparkle to save space */
    .fancy-frame::after {
        display: none;
    }
}

/* ---------- Touch safety ---------- */
@media (max-width: 768px) {
    .game-btn,
    .footer-link {
        min-height: 44px;
        min-width: 44px;
    }

    html {
        -webkit-text-size-adjust: 100%;
    }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}


/* ======================================
   MOBILE LANDSCAPE (FOREHEAD MODE) — FINAL
   THIS IS THE REAL FIX
   ====================================== */

@media (max-width: 900px) and (orientation: landscape) {

  /* 1. Reduce header height */
  .game-header {
    padding: 8px 14px;
  }

  .score-pill,
  .timer-pill {
    font-size: 14px;
    padding: 6px 12px;
  }

  /* 2. Reduce button bar height */
  .game-controls {
    height: 70px;
  }

  .game-btn {
    font-size: 16px;
  }

  /* 3. Give image more vertical space */
  .image-container {
    top: 56px;
    bottom: 64px;
    padding: 6px;
  }

  /* 4. Slightly wider frame (SAFE) */
  .fancy-frame {
    width: 98%;
    padding: 10px;
  }

  /* 5. CRITICAL IMAGE RULES */
  #game-image {
    /* NEVER stretch */
    width: auto !important;
    height: auto !important;

    /* Cap by viewport, not container */
    max-width: 88vw !important;
    max-height: 70vh !important;

    object-fit: contain !important;
  }
}


/* Gentle size boost for forehead mode — SAFE */
@media (orientation: landscape) and (max-width: 900px) {
  .image-container.landscape-fit #game-image {
    transform: scale(1.08);
  }
}

/* ===========================
   MOBILE UI RESTORE / PATCH
   Paste this into mobile.css (after your existing mobile rules)
   =========================== */

/* ---------- Glass panels / cards (mobile-friendly) ---------- */
.glass-panel {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  border: 2.5px solid var(--glass-border);
  border-radius: 28px;
  padding: 28px 22px;
  box-shadow:
    0 12px 36px rgba(127, 219, 255, 0.08),
    0 8px 20px rgba(255, 105, 180, 0.06),
    inset 0 0 18px rgba(255,255,255,0.45);
  width: min(92%, 640px);
  margin-inline: auto;
}

/* compact variant used on small screens */
@media (max-width: 480px) {
  .glass-panel {
    padding: 20px;
    border-radius: 22px;
    width: 92%;
  }
}

/* ---------- Branding / Titles ---------- */
h1.logo-title,
h2.logo-title {
  font-family: 'Pacifico', cursive;
  font-weight: 700;
  text-transform: none;
  margin-bottom: 10px;
  line-height: 1;
  letter-spacing: 0.02em;
}

/* mobile sizes for the logo */
h1.logo-title {
  font-size: clamp(32px, 7vw, 48px);
  background: linear-gradient(45deg, var(--pink-pop), var(--purple-haze), var(--blue-dream));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(1px 1px 0 rgba(255,255,255,0.6));
  text-align: center;
}

/* subtitle / taglines */
.tagline {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 18px;
  background: linear-gradient(90deg, var(--yellow-sunshine), var(--coral-kiss));
  color: var(--text-primary);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 2px;
  margin-bottom: 14px;
}

/* ---------- Instruction box (compact) ---------- */
.instruction-box {
  background: rgba(255,255,255,0.55);
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 0 8px 18px rgba(0,0,0,0.03);
}

/* keep bullets looking tidy on phones */
.instruction-box ul { padding-left: 12px; }
.instruction-box li { margin: 10px 0; }

/* ---------- Buttons: primary / secondary / mode ---------- */
button.primary-btn,
button#start-btn,
button#try-again-btn {
  background: linear-gradient(135deg, var(--pink-pop), var(--primary-btn-shadow));
  color: #fff;
  border-radius: 40px;
  padding: 14px 26px;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 8px 0 rgba(255,20,147,0.15), 0 16px 28px rgba(255,105,180,0.14);
  width: auto;
  min-width: 220px;
  display: inline-block;
  text-align: center;
}

/* secondary (light) buttons */
button.secondary-btn,
button#restart-btn {
  background: #fff;
  color: var(--secondary-btn);
  border: 3px solid var(--secondary-btn);
  padding: 10px 20px;
  border-radius: 40px;
  font-weight: 700;
  min-width: 180px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.06);
}

/* mode buttons — long pill look on mobile */
.mode-btn {
  width: min(86%, 420px);
  border-radius: 999px;
  padding: 14px;
  display: block;
  margin: 12px auto;
  text-align: center;
  font-size: 16px;
}

/* subtle focus / active states for touch */
button:active,
button:focus {
  transform: translateY(-2px) scale(0.995);
  outline: none;
}

/* ---------- Upload preview / small thumbnails ---------- */
#upload-preview {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.preview-img {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  object-fit: cover;
  border: 3px solid #fff;
  box-shadow: 0 8px 20px rgba(0,0,0,0.06);
}

/* ---------- Consent box ---------- */
.consent-box {
  background: rgba(255,255,255,0.6);
  padding: 10px;
  border-radius: 12px;
  text-align: center;
}

/* ---------- Fancy frame improvements (mobile safe) ---------- */
.fancy-frame {
  border-radius: 22px !important;
  overflow: hidden;
  position: relative;
  padding: 12px;
  box-sizing: border-box;
}

/* small decorative sparkle — hide on tiny screens */
.fancy-frame::after {
  content: '✨';
  position: absolute;
  top: -18px;
  right: -14px;
  font-size: 34px;
  opacity: 0.9;
  animation: sparkle 1.5s ease-in-out infinite;
}

@keyframes sparkle {
  0%,100% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.1); }
}

@media (max-width: 480px) {
  .fancy-frame::after { display: none; }
}

/* ---------- Game header small-screen tweaks ---------- */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px !important;
  gap: 12px;
}

/* score + timer pills smaller on phones */
.score-pill, .timer-pill {
  padding: 8px 14px !important;
  font-size: 14px !important;
  border-width: 3px !important;
}

/* ---------- Game controls (mobile pill buttons) ---------- */
.game-controls {
  display: flex !important;
  gap: 12px;
  padding: 10px;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, rgba(255,255,255,0.02), rgba(255,255,255,0.02));
  backdrop-filter: blur(4px);
  box-shadow: 0 -8px 20px rgba(0,0,0,0.06);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
}

/* pill style for PASS / YES buttons on mobile */
.game-btn {
  flex: 1;
  min-height: 56px;
  border-radius: 999px;
  margin: 0 6px;
  padding: 12px 10px;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 18px !important;
  font-weight: 900 !important;
  color: #fff !important;
  box-shadow: 0 8px 20px rgba(0,0,0,0.08) !important;
}

/* colors */
.pass-btn { background: linear-gradient(135deg, var(--danger), #FF1493) !important; }
.correct-btn { background: linear-gradient(135deg, var(--success), #4CAF50) !important; }

/* ---------- Overlay / countdown / rotate hint ---------- */
.overlay {
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.overlay.active { display: flex; }

.countdown-text {
  font-family: 'Pacifico', cursive;
  color: #fff;
  font-size: clamp(60px, 18vw, 160px);
  text-shadow: 0 6px 20px rgba(0,0,0,0.2);
  pointer-events: none;
}

/* rotate hint (small bar at top or center) */
.rotate-hint {
  position: fixed;
  left: 0;
  right: 0;
  top: 8px;
  margin-inline: auto;
  width: min(92%, 680px);
  background: rgba(255,255,255,0.92);
  color: #111;
  padding: 8px 12px;
  border-radius: 999px;
  text-align: center;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  z-index: 12000;
  display: none; /* default hidden; JS toggles it */
}

/* make rotate hint visible in the small portrait where you want to show it */
@media (max-width: 768px) {
  .rotate-hint { display: block; bottom: 16px; top: auto; }
}

/* ---------- Footer compacting on mobile ---------- */
.footer-section {
  padding: 2.2rem 1rem;
  font-size: 13px;
}

.footer-dashboard { gap: 0.8rem; }

/* ---------- Device-orientation / image container helpers ----------
   (non logic-changing: purely presentational)                       */

.image-container {
  width: 100%;
  height: 100%;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* If JS adds .landscape-fit we slightly enlarge the image but keep contain rules */
.image-container.landscape-fit #game-image {
  /* small, safe boost for forehead mode */
  transform: scale(1.06);
}

/* ensure #game-image keeps contain on all small screens */
@media (max-width: 900px) {
  #game-image {
    max-width: 92vw;
    max-height: 62vh;
    object-fit: contain;
    width: auto;
    height: auto;
    border-radius: 14px;
  }
}

/* ---------- Reduced-motion users ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .fancy-frame::after { display: none; }
}

/* ---------- Tiny layout fixes for specific edge cases ---------- */
@media (max-width: 420px) {
  .primary-btn, .mode-btn { min-width: 180px; font-size: 15px; padding: 12px 18px; }
  .game-controls { padding: 8px; }
  .game-btn { min-height: 52px; font-size: 16px !important; }
}


/* ===============================
   COUNTDOWN OVERLAY — FINAL
   Big, centered, cinematic
   =============================== */

#countdown-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;

  /* faint glassy cover */
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(6px) saturate(120%);
  -webkit-backdrop-filter: blur(6px) saturate(120%);

  z-index: 9999;
}

#countdown-overlay.active {
  display: flex;
}

/* Countdown number */
#countdown-overlay .countdown-text {
  position: relative;
  z-index: 10001;

  font-family: 'Pacifico', cursive;
  font-size: clamp(120px, 30vw, 240px);
  font-weight: 900;

  color: #111; /* BLACK number */
  text-align: center;

  /* subtle depth */
  text-shadow:
    0 6px 20px rgba(0, 0, 0, 0.25);

  animation: countdownPop 0.9s ease-in-out;
}

/* Nice pop animation */
@keyframes countdownPop {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  60% {
    transform: scale(1.15);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

/* Hide rotate hint during countdown */
#countdown-overlay.active #rotate-hint {
  display: none;
}
