/*
 Theme Name:    PuzzleHabits
 Theme URI:     https://puzzlehabits.com
 Description:   Premium Scalable Game Portal Child Theme
 Author:        Areeba
 Author URI:    https://yourportfolio.com
 Template:      hello-elementor
 Version:       1.2.0
*/

:root {
  --bg-body: #FAFAF8;
  --bg-white: #FFFFFF;
  --bg-warm: #F5F3EF;
  --bg-tint: #F0EDFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #FDFCFB;
  --accent-primary: #6D28D9;
  --accent-secondary: #8B5CF6;
  --accent-light: #EDE9FE;
  --accent-ultra-light: #F5F3FF;
  --accent-warm: #F59E0B;
  --accent-orange: #F97316;
  --accent-teal: #0D9488;
  --accent-pink: #DB2777;
  --accent-green: #059669;
  --accent-red: #DC2626;
  --accent-blue: #2563EB;
  --text-primary: #1A1A2E;
  --text-secondary: #4B5563;
  --text-muted: #9CA3AF;
  --text-on-accent: #FFFFFF;
  --border-light: #E5E7EB;
  --border-card: rgba(0,0,0,0.06);
  --border-focus: rgba(109, 40, 217, 0.4);
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.05), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-card-hover: 0 8px 30px rgba(109, 40, 217, 0.1), 0 2px 8px rgba(0,0,0,0.06);
  --shadow-purple: 0 4px 20px rgba(109, 40, 217, 0.2);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;
  --font-display: 'Bricolage Grotesque', serif;
  --font-body: 'DM Sans', sans-serif;
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ===== BASE & CONTAINER ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1260px;
  margin: 0 auto;
  padding: 0 28px;
}

.section { padding: 80px 0; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}
.section-title .highlight { color: var(--accent-primary); }

/* ===== NAVIGATION ===== */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: rgba(250, 250, 248, 0.85);
  backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--border-light);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1260px;
  margin: 0 auto;
  padding: 14px 28px;
  gap: 20px;
}

.nav-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.nav-logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; box-shadow: var(--shadow-purple);
  transform: rotate(-3deg);
}
.nav-logo-text { font-family: var(--font-display); font-weight: 800; font-size: 23px; color: var(--text-primary); letter-spacing: -0.5px; }
.nav-logo-text span { color: var(--accent-primary); }

.nav-links {
  display: flex;
  justify-content: center;
  list-style: none;
  gap: 10px;
  flex-grow: 1;
  overflow-x: auto;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  white-space: nowrap;
}
.nav-links a:hover { color: var(--accent-primary); background: var(--accent-ultra-light); }
.nav-links a.active { color: var(--accent-primary); background: var(--accent-light); font-weight: 600; }

/* ===== SEARCH BOX ===== */
/* ===== SEARCH BOX (RESTORING ORIGINAL STYLING) ===== */
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-white);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-full);
  padding: 8px 18px; /* Slightly more horizontal padding */
  transition: var(--transition-fast);
  box-shadow: var(--shadow-xs);
  min-width: 260px;
  position: relative;
}

.search-box:focus-within {
  border-color: var(--accent-secondary);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1); /* Softer focus ring */
}

/* Fix for the SVG color and size */
.search-box svg {
  color: #94a3b8; /* Matches your text-muted */
  flex-shrink: 0;
  stroke: #94a3b8;
}

.search-box:focus-within svg {
  stroke: var(--accent-primary);
}

/* THE CRITICAL FIX FOR THE INPUT FIELD */
.search-box input {
  background: transparent !important;
  border: none !important; /* Removes that box you see in the screenshot */
  outline: none !important; /* Removes the blue/black highlight on click */
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-body);
  width: 100%;
  padding: 4px 0; /* Vertical breathing room */
  margin: 0;
  box-shadow: none !important; /* Extra safety against browser defaults */
}

.search-box input::placeholder {
  color: #94a3b8;
  opacity: 1;
}
/* ===== MOBILE NAVIGATION & SEARCH FIX ===== */
@media (max-width: 768px) {
  .nav-inner {
    padding: 10px 16px;
    gap: 10px; /* Tighter gap for mobile */
    display: flex;
    justify-content: space-between;
  }

  .nav-logo-text {
    font-size: 18px; /* Slightly smaller logo text */
  }

  .nav-logo-icon {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  /* Make the search box shrinkable */
  .search-box {
    min-width: 140px; /* Allow it to get smaller */
    max-width: 180px;
    padding: 6px 12px;
  }

  .search-box input {
    font-size: 12px; /* Smaller text to fit */
  }

  /* If you have the nav-links showing, they will break mobile. 
     This ensures they stay hidden unless you build a toggle. */
  .nav-links {
    display: none !important;
  }
}

/* Extra small screens (iPhone SE etc) */
@media (max-width: 400px) {
  .nav-logo-text {
    display: none; /* Only show the Icon to save space */
  }
  
  .search-box {
    min-width: 120px;
    flex-grow: 1; /* Let search take the remaining space */
  }
}
/* ===== HERO SECTION ===== */
.hero {
  padding: 140px 0 60px;
  position: relative;
  overflow: hidden;
}

.hero-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 50px;
  align-items: center;
}

.hero-text h1 {
  font-family: var(--font-display);
  font-size: 54px;
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -1.5px;
  margin-bottom: 18px;
}
.gradient-text {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-pink), var(--accent-orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-games {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 10px;
}

.hero-game-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  aspect-ratio: 1;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: var(--shadow-sm);
}
.hero-game-card:nth-child(1) { grid-column: 1 / 3; grid-row: 1 / 3; }
.hero-game-card img { width: 100%; height: 100%; object-fit: cover; }

.hero-card-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 18px;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.hero-card-overlay h3 { font-size: 18px; color: white; font-weight: 700; }

/* ===== CATEGORIES ===== */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}

.category-card {
  background: var(--bg-white);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px 16px;
  text-align: center;
  transition: var(--transition-smooth);
  text-decoration: none;
}
.category-card:hover { transform: translateY(-5px); border-color: var(--accent-secondary); box-shadow: var(--shadow-card-hover); }
.category-icon { font-size: 34px; display: block; margin-bottom: 10px; }
.category-name { font-weight: 700; color: var(--text-primary); font-size: 14px; }
.category-count { font-size: 12px; color: var(--text-muted); }

/* ===== GAME CARDS ===== */
.games-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.game-card {
  background: var(--bg-white);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition-smooth);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-xs);
  display: block;
}
.game-card:hover { transform: translateY(-6px); border-color: var(--accent-secondary); box-shadow: var(--shadow-card-hover); }

.game-card-thumb { position: relative; aspect-ratio: 16/10; overflow: hidden; background: var(--bg-warm); }
.game-card-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ===== BADGES ===== */
.game-card-badge {
    position: absolute; top: 12px; left: 12px;
    padding: 6px 14px !important; border-radius: 50px !important;
    font-size: 11px !important; font-weight: 800 !important;
    color: #ffffff !important; text-transform: uppercase;
    z-index: 10; display: flex; align-items: center; line-height: 1;
}
.badge-Hot, .badge-hot { background: #ff5722 !important; box-shadow: 0 4px 10px rgba(255, 87, 34, 0.3) !important; }
.badge-Featured, .badge-featured { background: #7C3AED !important; box-shadow: 0 4px 10px rgba(124, 58, 237, 0.3) !important; }
.badge-New, .badge-new { background: #009688 !important; box-shadow: 0 4px 10px rgba(0, 150, 136, 0.3) !important; }

/* ===== BUTTONS ===== */
.btn-primary {
  display: inline-flex;
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  border-radius: var(--radius-full);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-purple);
  transition: var(--transition-smooth);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(109, 40, 217, 0.3); color: white !important; }

/* ===== STEPS ===== */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.step-card {
  background: var(--bg-white);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 32px 26px;
}
.step-number {
  width: 44px; height: 44px;
  background: var(--accent-primary);
  color: white;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; margin-bottom: 18px;
}

/* ===== FEATURED BANNER ===== */
.featured-banner {
  background: linear-gradient(135deg, var(--accent-primary), #4338CA, var(--accent-pink));
  border-radius: var(--radius-xl);
  padding: 56px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  color: white;
  margin: 40px 0;
}
.featured-stat-card {
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(10px);
  padding: 22px;
  border-radius: var(--radius-md);
  text-align: center;
}
.stat-num { font-size: 30px; font-weight: 800; display: block; }

/* ===== FOOTER ===== */
.footer {
  background: #ffffff;
  padding: 80px 0 40px 0;
  border-top: 1px solid var(--border-light);
  margin-top: 80px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr 1fr;
  gap: 30px;
}
.footer-col h4 { font-size: 16px; font-weight: 800; margin-bottom: 25px; color: var(--text-primary); }
.footer-col a { display: block; color: var(--text-muted); text-decoration: none; margin-bottom: 12px; font-size: 14px; }
.footer-col a:hover { color: var(--accent-primary); }

.footer-bottom {
  margin-top: 60px;
  padding-top: 30px;
  border-top: 1px solid var(--border-light);
  display: flex; justify-content: space-between;
  color: var(--text-muted); font-size: 14px;
}

/* ===== SEARCH OVERLAY ===== */
#search-results-overlay {
    background: var(--bg-body);
    width: 100%;
    min-height: 80vh;
    padding-top: 100px;
    display: block !important;
    position: relative;
    z-index: 99;
}
#archive-page[style*="display: none"], #page-home[style*="display: none"] {
    display: none !important;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeUp 0.5s ease-out forwards; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .hero-content { grid-template-columns: 1fr; gap: 40px; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 40px; }
  .categories-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .hero-text h1 { font-size: 38px; }
  .games-grid { grid-template-columns: repeat(2, 1fr); }
  .nav-links { display: none; }
  .featured-banner { grid-template-columns: 1fr; padding: 30px; }
}

/* ===== ARCHIVE PAGE SPECIFICS ===== */
#archive-page {
    padding-top: 100px; /* Space for fixed nav */
}

.archive-header {
    padding: 40px 0 20px 0;
    margin-bottom: 30px;
}

.archive-header h1 {
    font-family: var(--font-display);
    font-size: 42px;
    font-weight: 800;
    color: #1e293b;
}

.archive-header h1 .highlight {
    color: var(--accent-primary);
}

.archive-count {
    color: #94a3b8;
    font-size: 16px;
    margin-top: 5px;
}

/* ===== FILTER BAR PILLS ===== */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

/* This targets the specific buttons in your archive */
.filter-pill {
    appearance: none;
    background: #ffffff !important;
    border: 1.5px solid #e2e8f0 !important;
    padding: 10px 24px !important;
    border-radius: 50px !important;
    color: #64748b !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-pill:hover {
    border-color: var(--accent-primary) !important;
    color: var(--accent-primary) !important;
}

.filter-pill.active {
    background: var(--accent-primary) !important;
    color: #ffffff !important;
    border-color: var(--accent-primary) !important;
    box-shadow: var(--shadow-purple);
}

/* ===== GAME CARD INFO (TEXT STYLING) ===== */
.game-card-info {
    padding: 18px;
}

.game-card-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #1e293b;
}

.game-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
}

.game-card-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Re-fixing the rating gold color */
.game-card-meta span:first-child {
    color: #f59e0b;
    font-weight: 700;
}

/* ===== RESPONSIVE GRID & CARD FIX ===== */

/* Tablets and Large Phones */
@media (max-width: 1024px) {
    .games-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
}

/* Standard Mobile Phones */
@media (max-width: 768px) {
    .games-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 cards side-by-side */
        gap: 12px;
        padding: 0 10px;
    }

    .game-card-info {
        padding: 12px; /* Tighter padding for mobile */
    }

    .game-card-title {
        font-size: 15px; /* Slightly smaller title to prevent wrapping */
        margin-bottom: 6px;
    }

    /* Fix the meta icons (Star/Players) to stay in one line */
    .game-card-meta {
        display: flex;
        flex-wrap: wrap; 
        gap: 8px;
        font-size: 11px;
    }

    .game-card-meta span {
        white-space: nowrap; /* Prevents 4.4 and Star from breaking */
    }
}

/* Very Small Phones (iPhone SE size) */
@media (max-width: 480px) {
    .games-grid {
        grid-template-columns: repeat(2, 1fr); /* Stay 2-column but reduce font */
        gap: 8px;
    }
    
    .game-card-title {
        font-size: 14px;
    }
    
    /* Hide 'Medium/Easy' on tiny screens to save space if needed */
    .game-card-meta span:last-child {
        display: none; 
    }
/* Add spacing above the Play button */
.btn-primary, 
.btn-play-now,
.play-external-btn {
    margin-top: 24px !important;
    display: inline-flex; /* Ensures margin works correctly on <a> tags */
}

/* Specific fix for the Detail Page sidebar button */
.sidebar-info-card .btn-play-now {
    margin-top: 15px;
    margin-bottom: 20px;
}

}
/* ===== BREADCRUMB FIXES ===== */

/* 1. Add space so they aren't hidden under the Nav */
.detail-header, 
.breadcrumb-container,
.archive-header {
    margin-top: 100px !important; /* Forces content below the fixed header */
    padding-left: 20px;
    padding-right: 20px;
}

/* 2. Styling the Breadcrumbs */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
}

/* 3. Theme Color for Links (Purple) */
.breadcrumb a {
    color: var(--accent-primary); /* Uses your #6D28D9 purple */
    text-decoration: none;
    transition: var(--transition-fast);
}

.breadcrumb a:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

/* 4. Current Page (The last item) */
.breadcrumb span:last-child {
    color: var(--text-muted);
    font-weight: 400;
}

/* 5. Mobile Specific Fix */
@media (max-width: 768px) {
    .detail-header, 
    .breadcrumb-container {
        margin-top: 85px !important; /* Slightly tighter for mobile */
        font-size: 12px; /* Smaller text for narrow screens */
    }
    
    .breadcrumb {
        gap: 5px;
    }
	.single-game-layout{
 margin-top: 85px !important; }
}


/* ===== GLOBAL MOBILE RESPONSIVE OVERRIDES ===== */
@media (max-width: 768px) {
    
    /* 1. Fix General Spacing & Overlaps */
    .section {
        padding: 40px 0; /* Reduce huge desktop padding */
    }

    .container {
        padding: 0 20px; /* Ensure content doesn't touch screen edges */
    }

    /* 2. Fix Categories (image_a159bc) */
    .categories-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr) !important; /* 2 columns instead of 6 */
        gap: 12px;
    }

    .category-card {
        padding: 20px 10px;
    }

    /* 3. Fix Section Titles (Trending/New Arrivals) */
    .section-title {
        font-size: 24px;
        line-height: 1.2;
        margin-bottom: 20px;
    }

    /* 4. Fix Featured Banner (image_a159c5 / image_a159e3) */
    .featured-banner {
        grid-template-columns: 1fr !important; /* Stack text on top of stats */
        padding: 30px 20px;
        text-align: center;
        gap: 30px;
    }

    .featured-stats {
        grid-template-columns: 1fr 1fr; /* Side by side stats on mobile */
        gap: 10px;
    }

    .featured-stat-card {
        padding: 15px;
    }

    .featured-stat-card .stat-num {
        font-size: 24px;
    }

    /* 5. Fix How It Works (image_a15a1e / image_a15a3a) */
    .steps-grid {
        display: flex;
        flex-direction: column; /* Stack cards vertically */
        gap: 15px;
    }

    .step-card {
        padding: 20px;
        text-align: left;
    }

    /* 6. Fix Footer (image_a15ce3) */
    .footer-grid {
        grid-template-columns: 1fr !important; /* Full width columns */
        gap: 30px;
        text-align: left;
    }

    .footer-col h4 {
        margin-bottom: 15px;
    }

    .footer-bottom {
        flex-direction: column; /* Stack copyright and links */
        gap: 10px;
        text-align: center;
        padding-bottom: 20px;
    }
}

/* 7. Extra small screen fix (Phones under 400px wide) */
@media (max-width: 400px) {
    .categories-grid {
        grid-template-columns: 1fr !important; /* 1 card per row for tiny screens */
    }
    
    .hero-text h1 {
        font-size: 32px;
    }
}

/* ===== TIGHTENING SPACING (DESKTOP & MOBILE) ===== */

/* 1. Reduce Global Section Spacing */
.section {
    padding: 40px 0 !important; /* Was 80px, now much tighter */
}

/* 2. Fix Header Spacing (Space below Nav) */
.archive-header, 
.detail-header, 
#archive-page,
.hero {
    padding-top: 100px !important; /* Reduced to sit closer to the nav bar */
    margin-top: 0 !important;
}

/* 3. Reduce space between Page Title and Filters/Content */
.archive-header {
    padding-bottom: 0 !important;
    margin-bottom: 20px !important;
}

/* 4. Tighten the Footer */
.footer {
    padding: 40px 0 20px 0 !important; /* Reduced top padding */
    margin-top: 40px !important;
}

/* 5. Mobile Specific Tightening */
@media (max-width: 768px) {
    .section {
        padding: 25px 0 !important; /* Even tighter for mobile screens */
    }

    .archive-header, 
    .detail-header, 
    .hero {
        padding-top: 80px !important; /* Nav is shorter on mobile */
    }

    .archive-header h1 {
        font-size: 28px !important; /* Smaller text takes up less vertical space */
    }
    
    .footer-grid {
        gap: 20px !important;
    }
}

/* ===== GAME DETAIL PAGE LAYOUT FIX ===== */

/* 1. Create the 2-Column Sidebar Layout */
.detail-layout, 
.game-main-grid {
    display: grid;
    grid-template-columns: 1fr 360px; /* Left for Content, Right for Sidebar */
    gap: 40px;
    align-items: start;
    margin-top: 40px;
}

/* 2. Fix the Game Viewport (The big image/player) */
.detail-thumb, 
.game-viewport-container {
    grid-column: 1 / -1; /* Make the player take the FULL width at the top */
    margin-bottom: 40px;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}
/* FORCE HEIGHT ON MOBILE TO REMOVE ROTATE MESSAGE */
@media (max-width: 768px) {
    /* This makes the game take up most of the mobile screen height */
    .game-viewport-container {
        aspect-ratio: auto !important;
        height: 75vh !important; /* Uses 75% of the total screen height */
        max-height: 600px;
        border-radius: 12px !important;
        margin-bottom: 20px !important;
    }
}
    
    /* Optional: Pull the About section slightly higher */
    .game-description-area {
        margin-top: 20px !important;
    }
}

/* 3. Ensure the Sidebar stays on the right */
.detail-sidebar, 
.game-sidebar {
    position: sticky;
    top: 100px; /* Sticks to the top when scrolling */
}

/* 4. Fix Related Games Row (image overlap fix) */
.related-games {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid var(--border-light);
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* 5. Space out the "Play Now" Button */
.play-now-container {
    margin: 30px 0;
    display: block;
}

/* Mobile Reset: Stack them back to 1 column on phones */
@media (max-width: 992px) {
    .detail-layout, 
    .game-main-grid {
        grid-template-columns: 1fr;
    }
    
    .detail-sidebar {
        order: -1; /* Moves stats above the "About" text on mobile */
    }
}

/* TIGHTENING TOP SPACE ON ARCHIVE & DETAIL PAGES */

/* 1. Reduce the main container padding */
#archive-page, 
.archive-header, 
.detail-header, 
#page-home {
    padding-top: 60px !important; /* Reduced from 100px */
    margin-top: 0 !important;
}

/* 2. Remove the top padding from the internal header box */
.archive-header {
    padding-top: 20px !important; /* Tiny gap for breathing room */
}

/* 3. Pull the "Explore All Games" title closer to the nav */
.archive-header h1 {
    margin-top: 0 !important;
    margin-bottom: 5px !important;
}

/* 4. Pull the games count (11 games) closer to the title */
.archive-count {
    margin-top: 0 !important;
    margin-bottom: 20px !important;
}

/* MOBILE SPECIFIC TIGHTENING */
@media (max-width: 768px) {
    #archive-page, 
    .archive-header, 
    .detail-header {
        padding-top: 20px !important; /* Even tighter on mobile */
    }
}







<?php
/**
 * ============================================================================
 * PUZZLEHABITS — MOBILE GAME FIX
 * ============================================================================
 * 
 * THE PROBLEM:
 * On mobile, your .game-viewport-container has aspect-ratio: 16/9.
 * On a 375px wide phone, that means the iframe height = ~210px.
 * CrazyGames' embed wrapper needs minimum ~480px height to:
 *   1. Show and dismiss their preroll ad
 *   2. Initialize their SDK
 *   3. Render the game canvas
 * At 210px, their ad gets stuck on the purple loading screen.
 * 
 * THE FIX:
 * On mobile (<768px), override aspect-ratio to auto and force
 * a minimum height of 480px with 70vh as the target height.
 * This gives CrazyGames enough room to load properly.
 * 
 * ALSO:
 * On mobile, the iframe wrapper (#game-embed-wrapper) was set to
 * height: 0 initially. When ph_load_game() sets height: 100%,
 * 100% of 0 is still 0 in some mobile browsers because the
 * wrapper uses position: static (not absolute). Fixed by making
 * the wrapper position: absolute with inset: 0.
 * 
 * HOW TO USE:
 * Option A: Add this to your theme's functions.php
 * Option B: Use a "Code Snippets" plugin and paste this
 * Option C: Copy ONLY the CSS between <style> tags into your
 *           theme's custom CSS area
 * ============================================================================
 */

add_action('wp_head', 'ph_mobile_game_fix', 99);
function ph_mobile_game_fix() {
    if (!is_singular('games')) return;
    ?>
    <style id="ph-mobile-game-fix">
        /* ===== MOBILE: Fix game viewport height ===== */
        @media (max-width: 768px) {
            .game-viewport-container {
                aspect-ratio: auto !important;
                min-height: 480px !important;
                height: 70vh !important;
                max-height: 700px !important;
            }
        }

        @media (max-width: 480px) {
            .game-viewport-container {
                min-height: 420px !important;
                height: 65vh !important;
                border-radius: 14px !important;
            }
        }

        /* ===== Fix: iframe wrapper must fill the container ===== */
        #game-embed-wrapper {
            position: absolute !important;
            top: 0 !important;
            left: 0 !important;
            right: 0 !important;
            bottom: 0 !important;
            width: 100% !important;
        }

        /* When active, fill fully */
        #game-embed-wrapper[style*="opacity: 1"],
        #game-embed-wrapper[style*="height: 100%"] {
            height: 100% !important;
        }
    </style>
    <?php
}