/* =========================
   NYX PORTAL - MOBILE POLISH
   Premium Mobile UX Optimization
   ========================= */

/* ================================
   MOBILE-FIRST RESPONSIVE POLISH
   ================================ */

/* =========================
   1. GLOBAL MOBILE RESETS & VARIABLES
   ========================= */

:root {
  --mobile-spacing-safe: 20px;
  --mobile-header-height: 50px;
  --mobile-touch-target: 44px;

  /* Phase D - mobile app-like design tokens */
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;

  --radius-3: 12px;
  --radius-4: 16px;
  --radius-5: 20px;

  --tap-target-min: 44px;

  --font-mobile-xs: 0.75rem;
  --font-mobile-sm: 0.85rem;
  --font-mobile-md: 0.95rem;
  --font-mobile-lg: 1rem;

  --app-shell-min-height: 100dvh;
  --app-shell-safe-bottom: env(safe-area-inset-bottom, 0px);
}

@supports (height: 100svh) {
  :root {
    --app-shell-min-height: 100svh;
  }
}

/* Safer Global Resets */
img,
video,
iframe,
canvas,
svg {
  max-width: 100%;
  height: auto;
}

/* Prevent horizontal overflow on main containers only */
html,
body {
  overflow-x: hidden;
  width: 100%;
  -webkit-text-size-adjust: 100%;
  /* Prevent font scaling in landscape */
  -webkit-overflow-scrolling: touch;
  /* Smooth scroll */
}

/* Specific containers that might need overflow handling */
main,
section,
header,
footer {
  max-width: 100vw;
  box-sizing: border-box;
}

/* Exception for intentional overflows */
.horizontal-scroll-container,
.swiper-container,
.carousel {
  max-width: none;
  overflow-x: auto;
}

/* CRITICAL: Hide play/pause overlays on mobile Safari */
video::-webkit-media-controls-panel,
video::-webkit-media-controls-play-button,
video::-webkit-media-controls-start-playback-button {
  display: none !important;
  -webkit-appearance: none !important;
}

/* =========================
   2. TOUCH & INTERACTION STANDARDS
   ========================= */

/* Minimum touch target for all interactive elements */
a,
button,
input[type="submit"],
input[type="button"],
.btn {
  min-height: var(--mobile-touch-target);
  min-width: var(--mobile-touch-target);
  touch-action: manipulation;
  /* Optimizes tap delay */
}

/* Ensure icons inside buttons don't block clicks */
button svg,
a svg {
  pointer-events: none;
}

/* =========================
   3. VIDEO & CANVAS LAYERING FIXES
   ========================= */

/* Ensure video background stays at the very bottom */
.video-background,
#void-canvas {
  z-index: -1 !important;
  pointer-events: none !important;
}

/* Ensure content is always above video */
main,
.interface-layer,
.auth-container {
  position: relative;
  z-index: 10;
}

/* Hide ALL webkit video controls globally */
video::-webkit-media-controls {
  display: none !important;
}

video {
  pointer-events: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

/* Hamburger button only visible on mobile — hidden on desktop */
.mobile-menu-toggle {
  display: none;
}

/* =========================
   4. MOBILE TYPOGRAPHY & LAYOUT
   ========================= */

@media (max-width: 768px) {

  /* --- TYPOGRAPHY --- */

  /* Hero Title - Fluid scaling */
  .hero-title {
    font-size: clamp(2.5rem, 10vw, 3.5rem) !important;
    letter-spacing: 0.05em !important;
    line-height: 1.1 !important;
    margin: 0 var(--mobile-spacing-safe) !important;
    word-break: break-word;
    /* Prevent overflow on long words */
  }

  /* Hero Subtitle - Comfortable reading */
  .hero-subtitle {
    font-size: 1rem !important;
    line-height: 1.6 !important;
    padding: 0 var(--mobile-spacing-safe) !important;
  }

  .hero-subtitle-secondary {
    font-size: 0.95rem !important;
    line-height: 1.5 !important;
    padding: 0 var(--mobile-spacing-safe) !important;
  }

  /* Section Titles */
  .section-title {
    font-size: clamp(1.8rem, 6vw, 2.2rem) !important;
    margin-bottom: 20px !important;
  }

  /* --- LAYOUT & SPACING --- */

  /* Single column layouts */
  .features-grid,
  .portals-grid,
  .wallpaper-grid,
  .packages-grid {
    grid-template-columns: 1fr !important;
    gap: 25px !important;
    padding: 0 var(--mobile-spacing-safe) !important;
  }

  /* Generous margins */
  section {
    padding-left: var(--mobile-spacing-safe) !important;
    padding-right: var(--mobile-spacing-safe) !important;
  }

  /* Hero Section */
  #hero-main {
    min-height: 100dvh !important;
    /* Dynamic Viewport Height */
    padding-top: calc(var(--mobile-header-height) + 20px) !important;
    padding-left: var(--mobile-spacing-safe) !important;
    padding-right: var(--mobile-spacing-safe) !important;
    padding-bottom: var(--mobile-spacing-safe) !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .hero-content {
    padding: 0 !important;
    width: 100%;
  }

  .hero-avatars {
    gap: 15px !important;
    margin-bottom: 25px !important;
    justify-content: center;
  }

  .video-avatar {
    width: 80px !important;
    height: 80px !important;
    border-radius: 50%;
  }

  /* Hero CTA */
  .hero-cta-container {
    margin-top: 25px !important;
    padding: 0 var(--mobile-spacing-safe) !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 15px !important;
    width: 100% !important;
    align-items: center !important;
  }

  .hero-cta-container .hero-btn,
  .hero-cta-container a {
    padding: 16px 30px !important;
    font-size: 1rem !important;
    min-height: 48px !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    margin: 0 !important;
    /* Reset margin as we use gap */
  }

  /* ... */
  /* Button spacing */
  .dock-footer>*,
  .age-gate-buttons>* {
    margin: 8px !important;
  }

  /* --- NAVIGATION --- */

  .main-header {
    padding: 0 15px !important;
    height: 60px !important;
  }

  .logo {
    font-size: 1rem !important;
    z-index: 10002 !important;
  }

  /* --- HEADER & AUTH FIXES (CRITICAL CLEANUP) --- */
  .main-header {
    padding: 0 15px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    height: 50px !important;
  }

  .header-left,
  .header-right {
    flex: 1 !important;
  }

  .header-center {
    flex: 3 !important;
    /* Give center more space on mobile */
    display: flex !important;
    justify-content: center !important;
    padding: 0 10px !important;
  }

  /* HIDE Premium Group from Header Bar on Mobile (It's in the menu) */
  .nav-premium-group {
    display: none !important;
  }

  .nav-auth-container {
    display: flex;
    gap: 8px !important;
    align-items: center !important;
    margin-right: 0 !important;
  }

  /* REMOVED Register/Login overrides to keep centered layout clean and complete */

  /* Ensure Hamburger is clearly visible and positioned */
  .mobile-menu-toggle {
    position: relative !important;
    /* Not absolute */
    margin-left: 0 !important;
  }

  /* --- SPECIFIC PAGE FIXES (Relatos & Real) --- */

  /* Force single column for all grids on mobile to prevent 320px overflow */
  .relatos-grid,
  .container-grid,
  .blog-grid {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
    padding: 0 var(--mobile-spacing-safe) !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Filter Buttons - Touch Friendly & Wrapping */
  .category-filter {
    flex-wrap: wrap !important;
    gap: 10px !important;
    padding: 0 var(--mobile-spacing-safe) !important;
    justify-content: center !important;
  }

  .cat-btn {
    min-height: 44px !important;
    padding: 10px 20px !important;
    font-size: 0.9rem !important;
    flex: 1 1 auto !important;
    /* Allow growing but not shrinking below content */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Cards - Ensure no overflow */
  .relato-card,
  .article-card {
    max-width: 100% !important;
    margin: 0 !important;
  }

  /* Desktop nav hidden on mobile - RESTORED VIA TOGGLE CLASS */
  .nav-links {
    display: none;
  }

  .nav-links.active {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(5, 5, 12, 0.98);
    backdrop-filter: blur(20px);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding-bottom: 50px;
    animation: fadeIn 0.3s ease;
  }

  .nav-links.active a {
    font-size: 1.5rem !important;
    margin: 15px 0 !important;
    opacity: 0;
    animation: slideUp 0.4s ease forwards;
  }

  /* PREMIUM GROUP MOBILE ADJUSTMENTS */
  .nav-links.active .nav-premium-group {
    flex-direction: column;
    width: 100%;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    gap: 0;
  }

  /* Reset Premium Items to match mobile menu style */
  .nav-links.active .nav-item-premium {
    width: auto;
    justify-content: center;
    color: #fff !important;
    text-shadow: 0 0 10px rgba(255, 46, 99, 0.5);
    margin: 10px 0 !important;
  }

  .nav-links.active .nav-item-premium .premium-icon {
    display: none;
    /* Hide icon on mobile for cleaner look, or keep it */
  }

  .nav-links.active .nav-separator {
    display: none;
    /* Hide separator on mobile */
  }

  /* Adjust Animation Delays for Grouped Items */
  .nav-links.active .nav-premium-group a:nth-child(1) {
    animation-delay: 0.1s;
  }

  .nav-links.active .nav-premium-group a:nth-child(2) {
    animation-delay: 0.15s;
  }

  .nav-links.active .nav-premium-group a:nth-child(3) {
    animation-delay: 0.2s;
  }

  /* Continue delays for subsequent siblings of the group */
  .nav-links.active>a:nth-of-type(1) {
    animation-delay: 0.25s;
  }

  /* This targets first link AFTER group */
  .nav-links.active>a:nth-of-type(2) {
    animation-delay: 0.30s;
  }

  @keyframes fadeIn {
    from {
      opacity: 0;
    }

    to {
      opacity: 1;
    }
  }

  @keyframes slideUp {
    from {
      opacity: 0;
      transform: translateY(20px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .mobile-menu-toggle {
    display: flex !important;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 22px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 10001;
    /* Above Menu Overlay */
  }

  .mobile-menu-toggle span {
    width: 100%;
    height: 2px;
    background: #fff;
    transition: transform 0.3s ease, opacity 0.3s ease;
    border-radius: 2px;
    box-shadow: 0 0 5px rgba(255, 46, 99, 0.5);
  }

  /* Hamburger Animation */
  .mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 8px);
  }

  .mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
  }

  .mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -8px);
  }

  /* --- MODALS --- */



  /* === MODAL CLOSE BUTTONS - LARGER TOUCH TARGETS === */
  .modal-close,
  .age-gate-close,
  .no-essences-close,
  .gallery-modal-close,
  button[class*='close'],
  .close-btn {
    min-width: 44px !important;
    min-height: 44px !important;
    font-size: 1.5rem !important;
    padding: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Modal Positioning - Prevent Edge Clipping */
  .modal,
  .age-gate-content,
  .no-essences-content {
    margin: 10px !important;
    border-radius: 12px !important;
  }

  /* No Essences Modal (generator.html) */
  .no-essences-content {
    margin: 20px !important;
    padding: 40px 25px !important;
    max-width: calc(100vw - 40px) !important;
  }

  .no-essences-title {
    font-size: 1.5rem !important;
  }

  .no-essences-icon {
    font-size: 3rem !important;
  }

  /* Payment Modal (buy-credits.html) */
  .modal {
    margin: 20px !important;
    padding: 30px 20px !important;
    max-width: calc(100vw - 40px) !important;
    max-height: calc(100vh - 40px) !important;
    overflow-y: auto !important;
  }

  .modal h2 {
    font-size: 1.5rem !important;
  }

  /* Essences Success Modal */
  .essences-success-content {
    margin: 20px !important;
    padding: 45px 25px !important;
    max-width: calc(100vw - 40px) !important;
  }

  .success-title {
    font-size: 1.6rem !important;
  }

  .success-icon {
    font-size: 3.5rem !important;
  }

  /* --- GENERATOR PAGE --- */

  /* --- GENERATOR PAGE (Emergency 100dvh Fix) --- */

  .interface-layer {
    padding: 10px !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    overflow: hidden !important;
    /* Disable body scroll */
    justify-content: space-between !important;
  }

  .top-bar {
    flex: 0 0 auto !important;
    padding: 5px 10px !important;
    flex-direction: row !important;
    /* Keeping row for space */
    align-items: center !important;
    gap: 10px !important;
  }

  /* Hide Credits Pill text if needed, or make compact */
  .credits-pill {
    padding: 4px 10px !important;
    font-size: 0.8rem !important;
  }

  .image-stage {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    /* Crucial for flex shrinking */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 5px 0 !important;
  }

  /* Stage Placeholder Scaling */
  .stage-placeholder h2 {
    font-size: 1.2rem !important;
  }

  .stage-placeholder p {
    font-size: 0.75rem !important;
  }

  /* Generated Image Constraint */
  #generated-image {
    max-height: 40dvh !important;
    max-width: 95% !important;
    object-fit: contain !important;
  }

  .control-dock {
    flex: 0 0 auto !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 15px !important;
    background: rgba(5, 5, 8, 0.95) !important;
    /* Opaque to hide video behind */
    border-top: 1px solid rgba(255, 46, 99, 0.3) !important;
    border-radius: 20px 20px 0 0 !important;
    gap: 10px !important;
  }

  .prompt-input {
    font-size: 16px !important;
    height: 50px !important;
    /* Forced height */
    min-height: 50px !important;
    padding: 10px 15px !important;
    margin-bottom: 0 !important;
  }

  .dock-footer {
    flex-direction: row !important;
    /* Keep buttons inline if possible */
    gap: 10px !important;
    align-items: center !important;
  }

  /* Status Indicator Compact */
  .status-indicator {
    display: none !important;
    /* Hide status to save space OR make tiny */
  }

  .btn-generate {
    width: 100% !important;
    padding: 14px !important;
    font-size: 1rem !important;
    margin: 0 !important;
  }

  /* Post-Gen Block - Overlay Style for Mobile */
  .post-gen-block {
    display: none !important;
    position: absolute !important;
    bottom: 80px !important;
    /* Above control dock */
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 90% !important;
    z-index: 200 !important;
    background: rgba(10, 5, 15, 0.95) !important;
    padding: 15px !important;
  }

  .post-gen-block.visible {
    display: block !important;
    animation: slideUp 0.3s ease forwards !important;
  }

  /* --- BUY CREDITS PAGE --- */

  .container {
    margin-top: 70px !important;
    padding: 20px 15px !important;
  }

  .title {
    font-size: 2rem !important;
    letter-spacing: 0.15em !important;
  }

  .subtitle {
    font-size: 1rem !important;
    padding: 0 10px !important;
  }

  .key-concept {
    padding: 20px !important;
    margin: 25px auto 40px !important;
  }

  .package-card {
    padding: 35px 20px !important;
  }

  .package-name {
    font-size: 1.5rem !important;
  }

  .essence-amount {
    font-size: 3rem !important;
  }

  .footer-info {
    padding: 25px 20px !important;
    margin: 50px auto 30px !important;
  }

  /* --- RELATOS PAGE --- */

  .relatos-intro {
    padding: 60px 20px !important;
  }

  .relatos-intro-text {
    font-size: 1.05rem !important;
    line-height: 1.8 !important;
  }

  .relatos-grid {
    padding: 30px 15px 60px !important;
    gap: 25px !important;
  }

  .relato-cover {
    height: 200px !important;
  }

  .relato-content {
    padding: 20px !important;
  }

  .relato-title {
    font-size: 1.3rem !important;
  }

  .relato-excerpt {
    font-size: 0.9rem !important;
  }

  .relato-read-btn {
    padding: 12px 24px !important;
    font-size: 0.85rem !important;
  }

  /* Individual Story Page */
  .relato-page {
    padding: 50px 20px 80px !important;
  }

  .relato-page-title {
    font-size: clamp(1.6rem, 7vw, 2.2rem) !important;
    letter-spacing: 0.1em !important;
  }

  .relato-body {
    font-size: 1.05rem !important;
    line-height: 1.9 !important;
  }

  .relato-body p:first-of-type::first-letter {
    font-size: 3rem !important;
    margin-right: 10px !important;
  }

  /* --- CODIGO NOCHE PAGE --- */

  .codigo-container {
    padding: 90px 20px 60px !important;
  }

  .codigo-title {
    font-size: clamp(1.8rem, 8vw, 2.5rem) !important;
    letter-spacing: 0.08em !important;
  }

  .codigo-subtitle {
    font-size: 1rem !important;
  }

  .codigo-text {
    font-size: 1.05rem !important;
    line-height: 1.9 !important;
  }

  .section-label {
    font-size: 1.2rem !important;
    letter-spacing: 0.1em !important;
  }

  .codigo-list li {
    font-size: 1rem !important;
    padding: 12px 0 12px 25px !important;
  }

  .rejection-block {
    padding: 20px !important;
  }

  .closing-text {
    font-size: 1.1rem !important;
  }

  .closing-cta {
    padding: 14px 35px !important;
  }

  /* --- BLOG PREVIEW CARDS --- */

  .blog-preview-card {
    flex-direction: column !important;
    gap: 0 !important;
  }

  .blog-img-col,
  .blog-text-col {
    width: 100% !important;
  }

  .blog-img-col {
    height: 250px !important;
  }

  .blog-text-col {
    padding: 25px 20px !important;
  }

  /* --- FEATURE CARDS --- */

  .feature-card {
    height: 380px !important;
  }

  .feature-content {
    padding: 25px !important;
  }

  .feature-icon {
    font-size: 2.5rem !important;
  }

  .feature-content h3 {
    font-size: 1.5rem !important;
  }

  .feature-content p {
    font-size: 0.95rem !important;
    opacity: 1 !important;
    transform: translateY(0) !important;
  }

  /* --- PORTAL CARDS --- */

  .portal-card,
  .portal-flip-container {
    height: 500px !important;
  }

  .portal-content {
    padding: 30px 20px !important;
  }

  .portal-content h3 {
    font-size: 1.6rem !important;
  }

  .portal-content p {
    font-size: 0.9rem !important;
  }

  /* Channel List (YouTube Portal) */
  .channel-list {
    gap: 10px !important;
  }

  .channel-link-item {
    padding: 12px !important;
  }

  .channel-info h4 {
    font-size: 0.95rem !important;
  }

  .channel-info span {
    font-size: 0.8rem !important;
  }

  /* --- FLIP CARDS --- */

  .flip-card {
    height: 320px !important;
  }

  /* Disable flip on mobile - show front only */
  .flip-card:hover .flip-card-inner {
    transform: none !important;
  }

  .flip-card-back {
    display: none !important;
  }

  /* --- FOOTER --- */

  #footer-abyss {
    padding: 60px 20px 40px !important;
  }

  .footer-title {
    font-size: 1.8rem !important;
  }

  .footer-text {
    font-size: 0.95rem !important;
    line-height: 1.7 !important;
  }

  .newsletter-section {
    padding: 30px 20px !important;
  }

  .newsletter-title {
    font-size: 1.3rem !important;
  }

  .newsletter-desc {
    font-size: 0.9rem !important;
  }

  .newsletter-form {
    flex-direction: column !important;
    gap: 12px !important;
  }

  .neon-input {
    width: 100% !important;
    font-size: 16px !important;
    /* Prevents zoom on iOS */
    padding: 14px 18px !important;
  }

  .neon-button {
    width: 100% !important;
    padding: 14px 30px !important;
  }

  /* --- CHAT BUBBLE --- */

  .nyx-chat-bubble {
    width: 60px !important;
    height: 60px !important;
    bottom: 20px !important;
    right: 20px !important;
  }

  #nyx-chat-mini {
    width: calc(100vw - 20px) !important;
    max-width: none !important;
    bottom: 10px !important;
    right: 10px !important;
    max-height: calc(100vh - 100px) !important;
  }

  .nyx-chat-body {
    max-height: calc(100vh - 250px) !important;
  }

  .nyx-input {
    font-size: 16px !important;
    /* Prevents zoom on iOS */
  }

  /* --- PROPOSITION SECTION --- */

  .proposition-container {
    flex-direction: column !important;
    gap: 30px !important;
    padding: 0 20px !important;
  }

  .proposition-block {
    padding: 30px 20px !important;
  }

  .proposition-text {
    font-size: 1.05rem !important;
    line-height: 1.8 !important;
  }

  .proposition-divider {
    width: 80px !important;
    height: 2px !important;
    margin: 0 auto !important;
  }

  /* --- QUIZ SECTION --- */

  #interactive-quiz {
    padding: 56px 16px !important;
  }

  .quiz-container {
    padding: 18px 14px !important;
  }

  /* --- UTILITIES --- */

  /* Prevent text selection on interactive elements */
  .feature-card,
  .portal-card,
  .flip-card,
  .relato-card,
  .package-card {
    -webkit-tap-highlight-color: rgba(255, 46, 99, 0.1) !important;
  }

  /* Smooth scrolling */
  html {
    scroll-behavior: smooth !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Prevent horizontal overflow */
  body {
    overflow-x: hidden !important;
  }

  /* Image optimization */
  img {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Video containers */
  .hero-ambient-video,
  .video-background,
  .header-video,
  .footer-video-bg {
    /* Ensure videos fill container on mobile */
    width: 100% !important;
    height: 100% !important;
  }

  .hero-ambient-video video,
  .video-background video,
  .header-video,
  .footer-video-bg video {
    object-fit: cover !important;
    width: 100% !important;
    height: 100% !important;
  }
}

/* =========================
   3. SMALL MOBILE (≤480px)
   Extra optimizations for smaller screens
   ========================= */

@media (max-width: 480px) {

  .hero-title {
    font-size: clamp(2rem, 10vw, 3rem) !important;
    letter-spacing: 0.05em !important;
  }

  .section-title {
    font-size: 1.5rem !important;
    letter-spacing: 0.1em !important;
  }

  .video-avatar {
    width: 75px !important;
    height: 75px !important;
  }

  .feature-card,
  .portal-card,
  .portal-flip-container {
    height: 350px !important;
  }

  .package-card {
    padding: 30px 15px !important;
  }

  .essence-amount {
    font-size: 2.5rem !important;
  }

  .modal,
  .age-gate-content,
  .no-essences-content,
  .essences-success-content {
    margin: 15px !important;
    padding: 30px 20px !important;
  }
}

/* =========================
   4. LANDSCAPE MOBILE
   Optimizations for landscape orientation
   ========================= */

@media (max-width: 896px) and (max-height: 414px) and (orientation: landscape) {

  #hero-main {
    min-height: auto !important;
    padding: 40px 20px !important;
  }

  .hero-title {
    font-size: 2.5rem !important;
  }

  .video-avatar {
    width: 70px !important;
    height: 70px !important;
  }

  .modal,
  .age-gate-content {
    max-height: 90vh !important;
    overflow-y: auto !important;
  }
}

/* =========================
   5. ACCESSIBILITY ENHANCEMENTS
   ========================= */

@media (max-width: 768px) {

  /* Focus states for keyboard navigation */
  button:focus,
  a:focus,
  input:focus {
    outline: 2px solid var(--color-primary) !important;
    outline-offset: 2px !important;
  }

  /* Increase contrast for better readability */
  .hero-subtitle,
  .section-subtitle,
  .codigo-text,
  .relato-excerpt {
    color: #e0e0e0 !important;
  }

  /* Ensure sufficient spacing for readability */
  p {
    margin-bottom: 1.2em !important;
  }
}

/* =========================
   6. MOBILE UX FIXES
   ========================= */

/* --- SCROLL TO TOP FIX --- */
/* Move button to left on mobile to avoid AI Bubble overlap */
@media (max-width: 768px) {
  #back-to-top {
    left: 20px !important;
    right: auto !important;
    bottom: 20px !important;
    width: 45px !important;
    height: 45px !important;
    font-size: 1.2rem !important;
    background: rgba(0, 0, 0, 0.8) !important;
    backdrop-filter: blur(5px);
    border: 1px solid var(--color-primary);
    z-index: 9998 !important;
    /* Below Modal (9999) but high */
  }
}

/* --- MOBILE MENU --- */

/* Hamburguer Toggle */
#mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.8rem;
  cursor: pointer;
  z-index: 10001;
  padding: 5px;
}

@media (max-width: 768px) {
  #mobile-menu-toggle {
    display: block;
    position: absolute;
    top: 15px;
    right: 15px;
  }
}

/* Menu Overlay */
#mobile-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(10, 10, 10, 0.98);
  /* Deep dark background */
  backdrop-filter: blur(10px);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#mobile-menu-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Menu items */
.mobile-nav-link {
  color: #fff;
  font-family: 'Cinzel', serif;
  font-size: 1.8rem;
  margin: 15px 0;
  text-decoration: none;
  opacity: 0;
  transform: translateY(20px);
  transition: transform 0.3s ease, opacity 0.3s ease, color 0.3s ease, text-shadow 0.3s ease;
}

/* ==============================================
   PHASE I - CSS PERFORMANCE TWEAKS (MOBILE ONLY)
   ============================================== */
@media (max-width: 768px) {
  body.buy-credits-page #nyx-unified-background {
    display: none !important;
  }

  body.buy-credits-page .title {
    animation: none !important;
  }

  body.auth-page {
    background-image: url('../assets/hero_poster.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
  }

  body.auth-page .auth-bg-video {
    display: none !important;
  }

  body.auth-page .auth-card::after {
    animation: none !important;
  }

  body.auth-page .auth-card {
    contain: layout paint;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  body.buy-credits-page #nyx-unified-background {
    display: none !important;
  }
}

#mobile-menu-overlay.active .mobile-nav-link {
  opacity: 1;
  transform: translateY(0);
}

.mobile-nav-link:hover,
.mobile-nav-link.active {
  color: var(--color-primary, #ff2e63);
  text-shadow: 0 0 10px rgba(255, 46, 99, 0.5);
}

/* Close Button */
#mobile-menu-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
}

/* ==============================================
   PHASE 2 FIXES - FINAL MOBILE POLISH (320px support)
   ============================================== */
@media (max-width: 480px) {

  /* FORCE SINGLE COLUMN AND PREVENT OVERFLOW */
  .features-grid,
  .relatos-grid,
  .container-grid,
  .packages-grid,
  .portals-grid,
  .wallpaper-grid,
  .blog-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    padding: 0 15px !important;
    box-sizing: border-box !important;
    gap: 20px !important;
  }

  /* CARDS - FLUID WIDTH */
  .feature-card,
  .portal-card,
  .relato-card,
  .package-card,
  .article-card,
  .blog-preview-card,
  .auth-card {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    /* CRITICAL for grid children shrinking */
    box-sizing: border-box !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* BUY CREDITS - SPECIFIC FIXES for iPhone SE (320px) */
  .package-card {
    padding: 30px 15px !important;
    /* Reduced horizontal padding */
  }

  .package-price strong {
    font-size: 2.2rem !important;
    /* Smaller price text */
  }

  .essence-amount {
    font-size: 1.8rem !important;
  }

  .key-concept {
    padding: 20px 15px !important;
    margin: 20px auto !important;
    width: 100% !important;
  }

  /* HERO & LANDING */
  .hero-title {
    font-size: clamp(2rem, 12vw, 3rem) !important;
    line-height: 1.1 !important;
    padding: 0 10px !important;
  }

  .hero-content {
    padding: 0 10px !important;
  }

  .hero-cta-container {
    width: 100% !important;
    padding: 0 15px !important;
    flex-direction: column !important;
    gap: 15px !important;
  }

  .hero-btn {
    width: 100% !important;
    max-width: none !important;
  }

  /* AUTH PAGE */
  .auth-container {
    padding: 10px !important;
    align-items: flex-start !important;
    /* Allow scroll on small vertically */
    padding-top: 80px !important;
    /* Clear fixed header */
    min-height: 100vh !important;
  }

  .auth-card {
    padding: 25px 15px !important;
    margin: 0 !important;
  }

  .auth-oauth-btn {
    padding: 12px !important;
    font-size: 0.85rem !important;
  }

  /* PREMIUM NAV VISIBILITY */
  /* Ensure premium links are visible in the MOBILE MENU */
  .nav-links.active .nav-item-premium {
    display: flex !important;
  }

  /* REMOVE HEADER PADDING THAT CAUSES OVERFLOW */
  .main-header {
    padding: 0 15px !important;
  }

  /* MODALS */
  .modal,
  .age-gate-content {
    width: 95% !important;
    margin: 10px auto !important;
    padding: 25px 15px !important;
    max-width: none !important;
  }
}

/* EXTREME SMALL DEVICES (iPhone SE / Galaxy Fold - 320px range) */
@media (max-width: 350px) {
  .hero-title {
    font-size: 1.8rem !important;
    /* Explicitly small */
  }

  .title,
  .section-title {
    font-size: 1.6rem !important;
  }

  .package-card {
    padding: 20px 10px !important;
  }

  .package-name {
    font-size: 1.4rem !important;
  }

  .auth-logo {
    font-size: 2rem !important;
  }
}


/* ==============================================
   PHASE 3 REFINEMENTS - GENERATOR & TAGS
   ============================================== */
@media (max-width: 480px) {

  /* GENERATOR SAFER SCROLL */
  .interface-layer {
    height: 100dvh !important;
    /* Keep app feel */
    overflow-y: auto !important;
    /* BUT ALLOW SCROLL if content overflows */
    -webkit-overflow-scrolling: touch !important;
  }

  /* Fix Recommended Tag on small cards */
  .tag-recommended {
    font-size: 0.6rem !important;
    padding: 4px 30px !important;
    right: -30px !important;
    top: 15px !important;
  }

  /* Ensure Inputs are readable */
  input,
  select,
  textarea {
    font-size: 16px !important;
    /* Prevent iOS Zoom */
  }
}



/* FINAL SAFETY FIX FOR AGE GATE ON 320px */
@media (max-width: 480px) {
  .nyx-age-gate-card {
    padding: 20px 15px !important;
    width: 95% !important;
    max-width: none !important;
  }

  .nyx-age-gate-title {
    font-size: 1.2rem !important;
  }
}


/* ==============================================
   PHASE 6 FIXES - INTERACTION POLISH
   ============================================== */

/* FIX: Oracle/Rank Button Double-Tap Issue */
/* Prevents hover effects from blocking first click on touch devices */
@media (max-width: 1024px),
(hover: none) {
  .user-rank-badge:hover {
    transform: none !important;
    text-shadow: none !important;
  }

  .user-rank-badge:active {
    transform: scale(0.95) !important;
    /* Visual feedback on press instead */
  }
}


/* ==============================================
   P1 HOTFIXES - CONVERSION MOBILE (NO DESKTOP)
   ============================================== */

@media (max-width: 768px) {

  /* 1) AUTH MOBILE COMPLETABLE (320 + landscape) */
  body:has(.auth-container) {
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  body:has(.auth-container) .auth-container {
    height: calc(100dvh - 50px) !important;
    max-height: calc(100dvh - 50px) !important;
    min-height: calc(100dvh - 50px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    align-items: flex-start !important;
    padding: 70px 12px 16px !important;
  }

  body:has(.auth-container) .auth-card {
    margin: 0 auto 16px !important;
    max-width: 100% !important;
    padding: 22px 14px !important;
  }

  body:has(.auth-container) .auth-logo {
    margin-bottom: 16px !important;
    font-size: 1.9rem !important;
  }

  body:has(.auth-container) .auth-tabs {
    margin-bottom: 14px !important;
  }

  body:has(.auth-container) .auth-essence-badge {
    margin: 10px 0 !important;
    padding: 6px 12px !important;
  }

  body:has(.auth-container) .auth-oauth-btn {
    min-height: 44px !important;
    padding: 12px 14px !important;
    font-size: 0.85rem !important;
    margin-bottom: 10px !important;
  }

  body:has(.auth-container) .form-group {
    margin-bottom: 12px !important;
  }

  body:has(.auth-container) .auth-input {
    min-height: 44px !important;
    padding: 12px 14px !important;
    font-size: 16px !important;
  }

  body:has(.auth-container) #submit-btn {
    min-height: 44px !important;
    margin-top: 8px !important;
  }

  /* 2) BUY-CREDITS HEADER TAPPEABLE (NO OVERLAP) */
  .main-header:has(+ .container .packages-grid) {
    height: auto !important;
    min-height: 50px !important;
    padding: 8px 12px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    row-gap: 8px !important;
  }

  .main-header:has(+ .container .packages-grid) .logo {
    order: 1;
    flex: 0 0 auto;
  }

  .main-header:has(+ .container .packages-grid) .nav-auth-container,
  .main-header:has(+ .container .packages-grid) #nav-user-controls {
    order: 2;
    margin-left: auto !important;
    padding-left: 0 !important;
    border-left: 0 !important;
    height: auto !important;
    gap: 8px !important;
  }

  .main-header:has(+ .container .packages-grid) .nav-auth-btn {
    min-height: 44px !important;
    padding: 8px 12px !important;
    font-size: 0.75rem !important;
  }

  .main-header:has(+ .container .packages-grid) .nav-links {
    order: 3;
    flex: 1 0 100% !important;
    width: 100% !important;
    min-width: 100% !important;
    display: flex !important;
    position: static !important;
    margin: 0 !important;
    padding: 6px 0 2px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    z-index: 1 !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
  }

  .main-header:has(+ .container .packages-grid) .nav-links a {
    margin: 0 8px 0 0 !important;
    padding: 10px 12px !important;
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
  }

  .main-header:has(+ .container .packages-grid) .nav-item-premium,
  .main-header:has(+ .container .packages-grid) .nav-item-secondary {
    min-height: 44px !important;
  }

  .main-header:has(+ .container .packages-grid)+.container {
    margin-top: 130px !important;
  }

  /* 4) GENERATOR MODALS: AGE + NO-ESSENCES NO OVERFLOW */
  #nyx-targeted-gate {
    align-items: flex-start !important;
    overflow-y: auto !important;
    padding: 10px !important;
  }

  #nyx-targeted-gate .nyx-gate-card {
    max-height: calc(100dvh - 20px) !important;
    overflow-y: auto !important;
    margin: 0 auto !important;
  }

  #nyx-targeted-gate .nyx-gate-actions {
    position: sticky !important;
    bottom: 0 !important;
    background: rgba(20, 20, 25, 0.95) !important;
    padding-top: 10px !important;
  }

  #nyx-targeted-gate .nyx-gate-btn,
  .no-essences-btn-primary,
  .no-essences-btn-secondary {
    min-height: 44px !important;
  }

  .no-essences-content {
    max-height: calc(100dvh - 20px) !important;
    overflow-y: auto !important;
    margin: 10px auto !important;
  }

  .no-essences-actions {
    position: sticky !important;
    bottom: 0 !important;
    background: rgba(5, 5, 8, 0.95) !important;
    padding-top: 10px !important;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  body:has(.auth-container) {
    overflow-y: auto !important;
  }

  body:has(.auth-container) .auth-container {
    height: calc(100dvh - 50px) !important;
    max-height: calc(100dvh - 50px) !important;
    min-height: calc(100dvh - 50px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    align-items: flex-start !important;
    padding-top: 58px !important;
    padding-bottom: 12px !important;
  }

  body:has(.auth-container) .auth-card {
    padding: 16px 14px !important;
  }

  body:has(.auth-container) .auth-logo {
    margin-bottom: 10px !important;
    font-size: 1.5rem !important;
  }

  body:has(.auth-container) .auth-tabs,
  body:has(.auth-container) .auth-essence-badge,
  body:has(.auth-container) .form-group,
  body:has(.auth-container) .auth-msg {
    margin-bottom: 8px !important;
  }

  body:has(.auth-container) .auth-oauth-btn,
  body:has(.auth-container) .auth-input,
  body:has(.auth-container) #submit-btn {
    min-height: 44px !important;
  }

  .main-header:has(+ .container .packages-grid)+.container {
    margin-top: 112px !important;
  }

  #nyx-targeted-gate .nyx-gate-card,
  .no-essences-content {
    max-height: calc(100dvh - 12px) !important;
    overflow-y: auto !important;
    padding: 20px 18px !important;
  }

  #nyx-targeted-gate .nyx-gate-actions,
  .no-essences-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
    position: sticky !important;
    bottom: 0 !important;
    background: rgba(10, 10, 15, 0.95) !important;
    padding-top: 10px !important;
  }

  #nyx-targeted-gate .nyx-gate-btn,
  .no-essences-btn-primary,
  .no-essences-btn-secondary {
    min-height: 44px !important;
    width: 100% !important;
  }
}

/* ==============================================
   P2-01 QUICK WIN - MOB-015
   Mobile auth buttons tap target consistency
   ============================================== */
@media (max-width: 768px) {
  .nav-auth-btn {
    min-height: 44px !important;
    padding: 10px 14px !important;
    font-size: 0.78rem !important;
    line-height: 1.1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    touch-action: manipulation;
  }
}

/* ==============================================
   P2-02 QUICK WIN - MOB-016
   Mobile language switcher readability
   ============================================== */
@media (max-width: 768px) {
  #nyx-lang-switcher .lang-btn {
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 8px 12px !important;
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.06em !important;
  }

  #nyx-lang-switcher .lang-separator {
    font-size: 1rem !important;
    color: rgba(255, 255, 255, 0.55) !important;
  }
}

/* ==============================================
   P2-03 QUICK WIN - MOB-017
   Mobile footer non-social links tap area
   ============================================== */
@media (max-width: 768px) {
  #footer-abyss .footer-copyright a:not(.social-link) {
    display: inline-flex !important;
    align-items: center !important;
    min-height: 44px !important;
    padding: 8px 10px !important;
    line-height: 1.25 !important;
  }

  #footer-abyss .footer-copyright>div {
    row-gap: 8px !important;
  }
}

/* ==============================================
   P2-04 QUICK WIN - MOB-009
   Mobile 18+ confirmation touch comfort
   ============================================== */
@media (max-width: 768px) {
  main.container>div:has(#age-confirmation-checkbox) {
    width: min(100%, 560px) !important;
    padding: 16px !important;
  }

  main.container label:has(#age-confirmation-checkbox) {
    min-height: 44px !important;
    gap: 12px !important;
    align-items: flex-start !important;
    line-height: 1.45 !important;
    font-size: 0.95rem !important;
  }

  #age-confirmation-checkbox {
    width: 24px !important;
    height: 24px !important;
    margin-top: 2px !important;
    flex: 0 0 24px;
  }
}

/* ==============================================
   P2-05 QUICK WIN - MOB-010
   Mobile legal microcopy readability
   ============================================== */
@media (max-width: 768px) {
  .packages-grid .package-card div[style*="font-size: 0.8rem"] {
    font-size: 0.9rem !important;
    color: #c3c3c3 !important;
    line-height: 1.45 !important;
  }

  #footer-abyss .footer-copyright+div {
    font-size: 0.9rem !important;
    color: #9a9a9a !important;
    line-height: 1.5 !important;
    opacity: 0.95 !important;
  }

  #footer-abyss .footer-copyright+div a {
    color: #b3b3b3 !important;
  }
}

/* ==============================================
   P2-06 QUICK WIN - MOB-014
   Generator invocation status visible on mobile
   ============================================== */
@media (max-width: 768px) {
  body:has(#prompt-input) .dock-footer {
    flex-wrap: nowrap !important;
    align-items: center !important;
  }

  body:has(#prompt-input) .status-indicator,
  body:has(#prompt-input) #invocation-status {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    min-height: 36px !important;
    padding: 6px 10px !important;
    font-size: 0.78rem !important;
    line-height: 1.2 !important;
    max-width: 46% !important;
    flex: 0 1 46% !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  body:has(#prompt-input) .btn-generate {
    width: auto !important;
    min-width: 0 !important;
    min-height: 44px !important;
    padding: 12px 14px !important;
    flex: 1 1 54% !important;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  body:has(#prompt-input) .status-indicator,
  body:has(#prompt-input) #invocation-status {
    min-height: 34px !important;
    padding: 4px 8px !important;
    font-size: 0.72rem !important;
  }
}

/* ==============================================
   CROSS-BROWSER HARDENING
   Class-scoped fallbacks without :has()
   ============================================== */
@media (max-width: 768px) {
  body.auth-page {
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  body.auth-page .auth-container {
    height: calc(100dvh - 50px) !important;
    max-height: calc(100dvh - 50px) !important;
    min-height: calc(100dvh - 50px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    align-items: flex-start !important;
    padding: 70px 12px 16px !important;
  }

  body.auth-page .auth-card {
    margin: 0 auto 16px !important;
    max-width: 100% !important;
    padding: 22px 14px !important;
  }

  body.auth-page .auth-logo {
    margin-bottom: 16px !important;
    font-size: 1.9rem !important;
  }

  body.auth-page .auth-tabs {
    margin-bottom: 14px !important;
  }

  body.auth-page .auth-essence-badge {
    margin: 10px 0 !important;
    padding: 6px 12px !important;
  }

  body.auth-page .auth-oauth-btn {
    min-height: 44px !important;
    padding: 12px 14px !important;
    font-size: 0.85rem !important;
    margin-bottom: 10px !important;
  }

  body.auth-page .form-group {
    margin-bottom: 12px !important;
  }

  body.auth-page .auth-input {
    min-height: 44px !important;
    padding: 12px 14px !important;
    font-size: 16px !important;
  }

  body.auth-page #submit-btn {
    min-height: 44px !important;
    margin-top: 8px !important;
  }

  body.buy-credits-page .content-layer>.main-header {
    height: auto !important;
    min-height: 50px !important;
    padding: 8px 12px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    row-gap: 8px !important;
  }

  body.buy-credits-page .content-layer>.main-header .logo {
    order: 1;
    flex: 0 0 auto;
  }

  body.buy-credits-page .content-layer>.main-header .nav-auth-container,
  body.buy-credits-page .content-layer>.main-header #nav-user-controls {
    order: 2;
    margin-left: auto !important;
    padding-left: 0 !important;
    border-left: 0 !important;
    height: auto !important;
    gap: 8px !important;
  }

  body.buy-credits-page .content-layer>.main-header .nav-auth-btn {
    min-height: 44px !important;
    padding: 8px 12px !important;
    font-size: 0.75rem !important;
  }

  body.buy-credits-page .content-layer>.main-header .nav-links {
    order: 3;
    flex: 1 0 100% !important;
    width: 100% !important;
    min-width: 100% !important;
    display: flex !important;
    position: static !important;
    margin: 0 !important;
    padding: 6px 0 2px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    z-index: 1 !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
  }

  body.buy-credits-page .content-layer>.main-header .nav-links a {
    margin: 0 8px 0 0 !important;
    padding: 10px 12px !important;
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
  }

  body.buy-credits-page .content-layer>.main-header .nav-item-premium,
  body.buy-credits-page .content-layer>.main-header .nav-item-secondary {
    min-height: 44px !important;
  }

  body.buy-credits-page .content-layer>.main-header+.container {
    margin-top: 130px !important;
  }

  body.buy-credits-page .payment-method-selector {
    width: 100% !important;
    max-width: 100% !important;
    margin: 28px auto !important;
    padding: 0 10px !important;
    box-sizing: border-box !important;
  }

  body.buy-credits-page .payment-method-selector>div {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    flex-wrap: nowrap !important;
    overflow: hidden !important;
  }

  body.buy-credits-page .payment-method-selector .method-tab {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    padding: 10px 6px !important;
    font-size: 0.78rem !important;
    line-height: 1.2 !important;
    text-align: center !important;
    white-space: normal !important;
    gap: 4px !important;
  }

  body.buy-credits-page .age-confirmation {
    width: min(100%, 560px) !important;
    padding: 16px !important;
  }

  body.buy-credits-page .age-confirmation label,
  body.buy-credits-page .age-confirmation .age-confirmation-label {
    min-height: 44px !important;
    gap: 12px !important;
    align-items: flex-start !important;
    line-height: 1.45 !important;
    font-size: 0.95rem !important;
  }

  body.buy-credits-page .age-confirmation #age-confirmation-checkbox {
    width: 24px !important;
    height: 24px !important;
    margin-top: 2px !important;
    flex: 0 0 24px;
  }

  body.buy-credits-page .packages-grid .package-microcopy {
    font-size: 0.9rem !important;
    color: #c3c3c3 !important;
    line-height: 1.45 !important;
  }

  body.generator-page .dock-footer {
    flex-wrap: nowrap !important;
    align-items: center !important;
  }

  body.generator-page .status-indicator,
  body.generator-page #invocation-status {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    min-height: 36px !important;
    padding: 6px 10px !important;
    font-size: 0.78rem !important;
    line-height: 1.2 !important;
    max-width: 46% !important;
    flex: 0 1 46% !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  body.generator-page .btn-generate {
    width: auto !important;
    min-width: 0 !important;
    min-height: 44px !important;
    padding: 12px 14px !important;
    flex: 1 1 54% !important;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  body.auth-page {
    overflow-y: auto !important;
  }

  body.auth-page .auth-container {
    height: calc(100dvh - 50px) !important;
    max-height: calc(100dvh - 50px) !important;
    min-height: calc(100dvh - 50px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    align-items: flex-start !important;
    padding-top: 58px !important;
    padding-bottom: 12px !important;
  }

  body.auth-page .auth-card {
    padding: 16px 14px !important;
  }

  body.auth-page .auth-logo {
    margin-bottom: 10px !important;
    font-size: 1.5rem !important;
  }

  body.auth-page .auth-tabs,
  body.auth-page .auth-essence-badge,
  body.auth-page .form-group,
  body.auth-page .auth-msg {
    margin-bottom: 8px !important;
  }

  body.auth-page .auth-oauth-btn,
  body.auth-page .auth-input,
  body.auth-page #submit-btn {
    min-height: 44px !important;
  }

  body.buy-credits-page .content-layer>.main-header+.container {
    margin-top: 112px !important;
  }

  body.buy-credits-page .age-confirmation {
    padding: 12px 14px !important;
  }

  body.buy-credits-page .age-confirmation label,
  body.buy-credits-page .age-confirmation .age-confirmation-label {
    min-height: 44px !important;
    align-items: flex-start !important;
    gap: 10px !important;
    line-height: 1.35 !important;
    font-size: 0.9rem !important;
  }

  body.buy-credits-page .age-confirmation #age-confirmation-checkbox {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    flex: 0 0 24px;
    margin-top: 2px !important;
  }

  body.buy-credits-page .packages-grid .package-microcopy {
    font-size: 0.85rem !important;
    line-height: 1.4 !important;
    color: #bdbdbd !important;
  }

  body.generator-page .status-indicator,
  body.generator-page #invocation-status {
    min-height: 34px !important;
    padding: 4px 8px !important;
    font-size: 0.72rem !important;
  }
}

/* ==============================================
   PHASE D - COMMIT 1
   Tokens + app-shell mobile layout
   ============================================== */
@media (max-width: 768px) {
  body.nyx-dark-vibe,
  body.auth-page,
  body.buy-credits-page,
  body.generator-page {
    min-height: var(--app-shell-min-height) !important;
  }

  body.nyx-dark-vibe #hero-main,
  body.auth-page .auth-container,
  body.buy-credits-page .content-layer,
  body.generator-page .interface-layer {
    min-height: var(--app-shell-min-height) !important;
  }

  body.nyx-dark-vibe #hero-main,
  body.auth-page .auth-container,
  body.buy-credits-page .content-layer {
    padding-bottom: max(var(--space-2), var(--app-shell-safe-bottom)) !important;
  }

  body.generator-page .interface-layer {
    height: auto !important;
    padding-bottom: max(var(--space-2), var(--app-shell-safe-bottom)) !important;
  }
}

/* ==============================================
   PHASE D - COMMIT 2
   Tap targets + mobile microinteractions
   ============================================== */
@media (max-width: 768px) {
  .nav-links a,
  .nav-auth-btn,
  .hero-btn,
  .btc-buy-btn,
  .auth-btn,
  .btn-generate,
  .copy-invoice-btn,
  .success-cta,
  .no-essences-btn-primary,
  .no-essences-btn-secondary,
  #gate-enter-btn,
  #gate-exit-btn,
  #footer-abyss .footer-copyright a,
  #nyx-lang-switcher .lang-btn,
  .buy-credits-btn,
  .image-control-btn {
    min-height: var(--tap-target-min) !important;
    min-width: var(--tap-target-min) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  body.buy-credits-page .age-confirmation label,
  body.buy-credits-page .age-confirmation .age-confirmation-label {
    min-height: var(--tap-target-min) !important;
    padding: var(--space-2) 0 !important;
  }

  body.buy-credits-page .age-confirmation #age-confirmation-checkbox {
    min-width: 24px !important;
    min-height: 24px !important;
  }

  button,
  .btn,
  .nav-auth-btn,
  .btc-buy-btn,
  .btn-generate,
  .auth-btn {
    transition: transform 0.12s ease, filter 0.12s ease, opacity 0.2s ease !important;
  }

  button:active,
  .btn:active,
  .nav-auth-btn:active,
  .btc-buy-btn:active,
  .btn-generate:active,
  .auth-btn:active {
    transform: translateY(1px) scale(0.99) !important;
    filter: brightness(1.06) !important;
  }

  button:disabled,
  .btn:disabled,
  .nav-auth-btn:disabled,
  .btc-buy-btn:disabled,
  .btn-generate:disabled,
  .auth-btn:disabled,
  [aria-disabled="true"] {
    opacity: 0.52 !important;
    filter: saturate(0.65) contrast(0.92) !important;
    cursor: not-allowed !important;
  }
}

/* ==============================================
   PHASE D - COMMIT 3
   Generator dock/footer app-like polish
   ============================================== */
@media (max-width: 768px) {
  body.generator-page .control-dock {
    background: linear-gradient(180deg, rgba(11, 10, 18, 0.95), rgba(6, 6, 10, 0.98)) !important;
    border-top: 1px solid rgba(255, 46, 99, 0.28) !important;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45) !important;
    border-radius: var(--radius-5) var(--radius-5) 0 0 !important;
    padding: var(--space-3) var(--space-4) !important;
    gap: var(--space-3) !important;
  }

  body.generator-page .dock-footer {
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: var(--space-2) !important;
  }

  body.generator-page .dock-footer .invocation-info {
    display: flex !important;
    align-items: center !important;
    gap: var(--space-2) !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }

  body.generator-page .invocation-cost-badge {
    min-height: 34px !important;
    padding: 4px 8px !important;
    border-radius: var(--radius-3) !important;
  }

  body.generator-page #invocation-status,
  body.generator-page .status-indicator {
    border-radius: var(--radius-3) !important;
  }

  body.generator-page .btn-generate {
    border-radius: var(--radius-4) !important;
    min-height: 44px !important;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  body.generator-page .interface-layer {
    padding: 6px !important;
  }

  body.generator-page .top-bar {
    padding: 2px 8px !important;
    gap: 6px !important;
  }

  body.generator-page .image-stage {
    margin: 2px 0 !important;
    min-height: 80px !important;
  }

  body.generator-page .control-dock {
    padding: 8px 10px !important;
    gap: 6px !important;
    border-radius: 14px 14px 0 0 !important;
  }

  body.generator-page .prompt-input {
    height: 40px !important;
    min-height: 40px !important;
    padding: 8px 12px !important;
  }

  body.generator-page .dock-footer {
    gap: 6px !important;
    margin: 0 !important;
    align-items: center !important;
  }

  body.generator-page .dock-footer .invocation-info {
    gap: 4px !important;
  }

  body.generator-page .invocation-cost-badge {
    min-height: 30px !important;
    padding: 4px 8px !important;
  }

  body.generator-page .status-indicator,
  body.generator-page #invocation-status {
    min-height: 30px !important;
    padding: 3px 6px !important;
    font-size: 0.68rem !important;
  }

  body.generator-page .btn-generate {
    min-height: 40px !important;
    padding: 8px 10px !important;
    font-size: 0.85rem !important;
    margin: 0 !important;
  }
}

/* =========================
   11. HOMEPAGE MOBILE REFINEMENTS (NON-DESKTOP IMPACT)
   ========================= */
@media (max-width: 768px) {
  .main-header {
    padding: 8px 12px !important;
    min-height: 56px !important;
    height: auto !important;
  }

  .header-left,
  .header-right {
    flex: 0 0 auto !important;
  }

  .header-center {
    flex: 1 !important;
    min-width: 0;
  }

  .nav-auth-container {
    gap: 6px !important;
    border-left: 0 !important;
    padding-left: 0 !important;
    flex-wrap: wrap;
    justify-content: center;
  }

  .nav-auth-btn {
    min-height: 36px !important;
    padding: 8px 10px !important;
    font-size: 0.62rem !important;
    letter-spacing: 0.6px !important;
  }

  /* --- LOGGED-IN USER CONTROLS (mobile proportions) --- */
  #nav-user-controls {
    height: auto !important;
    min-height: 30px !important;
    padding: 5px 8px 5px 10px !important;
    gap: 5px !important;
    max-width: 100% !important;
    overflow: hidden !important;
    flex-shrink: 1 !important;
  }

  .user-rank-badge {
    font-size: 0.58rem !important;
    padding-right: 6px !important;
    gap: 3px !important;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-credits-display {
    font-size: 0.62rem !important;
    gap: 3px !important;
    flex-shrink: 1;
    min-width: 0;
    white-space: nowrap;
  }

  .user-credits-display span {
    font-size: 0.72rem !important;
  }

  .nav-logout-btn {
    height: 20px !important;
    padding: 0 7px !important;
    font-size: 0.46rem !important;
    flex-shrink: 0;
  }

  .hero-subtitle-main {
    font-size: clamp(1.2rem, 6vw, 1.55rem) !important;
    line-height: 1.35 !important;
    letter-spacing: 0.08em !important;
    margin-bottom: 20px !important;
  }

  .hero-free-badge {
    display: block !important;
    width: min(100%, 340px);
    margin: 18px auto !important;
    padding: 10px 16px !important;
    border-radius: 20px !important;
  }

  .hero-free-badge-label {
    justify-content: center !important;
    flex-wrap: wrap;
    text-align: center;
    line-height: 1.4;
    font-size: 0.7rem !important;
    letter-spacing: 1px !important;
  }

  .hero-free-badge-icon {
    font-size: 0.9rem !important;
  }

  .hero-subtitle-secondary {
    font-size: 0.92rem !important;
    line-height: 1.55 !important;
    margin: 0 auto 30px !important;
  }

  .hero-cta-container {
    padding: 0 !important;
    gap: 12px !important;
  }

  .hero-btn {
    width: 100% !important;
    max-width: 340px;
    min-width: 0 !important;
    padding: 13px 18px !important;
    font-size: 0.92rem !important;
    letter-spacing: 0.8px !important;
  }
}


@media (max-width: 380px) {
  .nav-auth-btn {
    padding: 7px 8px !important;
    font-size: 0.58rem !important;
  }

  /* Extra compact user controls for very small phones */
  #nav-user-controls {
    padding: 4px 6px 4px 8px !important;
    gap: 4px !important;
  }

  .user-rank-badge {
    font-size: 0.52rem !important;
    padding-right: 5px !important;
  }

  .user-credits-display {
    font-size: 0.56rem !important;
  }

  .user-credits-display span {
    font-size: 0.64rem !important;
  }

  .nav-logout-btn {
    padding: 0 5px !important;
    font-size: 0.42rem !important;
    height: 18px !important;
  }
}

/* =========================
   12. GENERATOR MODAL (RESTORED)
   ========================= */
/* NO CREDITS MODAL (Reusing/Extending aesthetics) */
.nc-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nc-modal.active {
    display: flex;
    opacity: 1;
}

.nc-content {
    background: #0f0a10;
    border: 1px solid #ff2e63; /* Replacement for --ritual-primary */
    border-radius: 12px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 0 50px rgba(255, 46, 99, 0.3);
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.nc-modal.active .nc-content {
    transform: scale(1);
}

.nc-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
    filter: drop-shadow(0 0 15px #ff2e63);
}

.nc-title {
    font-family: 'Cinzel', serif;
    color: #fff;
    font-size: 1.5rem;
    margin: 0 0 10px;
}

.nc-message {
    color: #ccc;
    font-size: 0.95rem;
    margin-bottom: 25px;
    line-height: 1.5;
}

.nc-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.nc-btn {
    padding: 12px 20px;
    border-radius: 30px;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    text-decoration: none;
}

.nc-btn.primary {
    background: #ff2e63;
    color: #fff;
    border: none;
    box-shadow: 0 4px 15px rgba(255, 46, 99, 0.3);
}

.nc-btn.primary:hover {
    background: #ff0055;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 46, 99, 0.5);
}

.nc-btn.secondary {
    background: transparent;
    color: #aaa;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.nc-btn.secondary:hover {
    color: #fff;
    border-color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.nc-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: #666;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s;
}

.nc-close:hover {
    color: #fff;
}
