/* modern.css - Premium Choclate Gaming UI */
:root {
    --bg-base: #1a0f0d;
    --bg-glass: rgba(45, 27, 20, 0.7);
    --bg-glass-hover: rgba(55, 33, 24, 0.85);
    --border-glass: rgba(255, 245, 230, 0.1);

    --text-primary: #fff5e6;
    --text-secondary: #d1a586;

    --accent-gradient: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
    --accent-color: #f59e0b;

    --danger-color: #ef4444;
    --success-color: #10b981;

    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --shadow-soft: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 25px rgba(251, 191, 36, 0.4);
}

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

body {
    background-color: var(--bg-base);
    background-image:
        radial-gradient(circle at 15% 50%, rgba(217, 119, 6, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(251, 191, 36, 0.08) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
}

/* App Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    border-radius: 0;
    border-top: none;
    border-bottom: none;
    border-left: none;
    z-index: 100;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.sidebar.collapsed {
    width: 80px;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-title,
.sidebar.collapsed .username,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .genre-count-badge,
.sidebar.collapsed .logout-btn span,
.sidebar.collapsed .auth-section .btn {
    display: none;
}

.sidebar.collapsed .logo {
    padding: 0 0 32px;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
}

.sidebar.collapsed .nav-section {
    padding: 0 10px;
    padding-top: 20px;
}

.sidebar-toggle {
    position: absolute;
    top: 90px;
    right: 20px;
    /* Slightly more offset */
    width: 40px;
    /* Bigger medallion */
    height: 40px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    /* Gold/Amber Medallion */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 110;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.4);
    border: 3px solid var(--bg-base);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: #fff;
}

.sidebar-toggle svg {
    width: 22px;
    height: 22px;
    stroke-width: 3;
    /* Bolder arrow icon */
    transition: transform 0.3s ease;
}

.sidebar.collapsed .sidebar-toggle {
    transform: rotate(180deg);
}

.logo {
    padding: 0px 24px;
    /* More vertical space */
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 5px;
    /* More gap between image and text */
}

.logo-img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.3));
    transition: var(--transition);
}

.logo:hover .logo-img {
    transform: scale(1.1) rotate(5deg);
    filter: drop-shadow(0 0 12px rgba(251, 191, 36, 0.5));
}

.logo-text {
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.accent {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    margin-bottom: 24px;
}

.ad-label {
    display: none;
    /* Hide ad labels as per user request */
}

.nav-title {
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 12px;
    padding-left: 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    border-radius: 12px;
    transition: var(--transition);
    gap: 12px;
    margin: 0 auto 4px auto;
    width: 90%;
}

.genre-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.genre-icon svg {
    width: 100%;
    height: 100%;
}

.nav-item svg {
    opacity: 0.7;
    transition: var(--transition);
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: #fff;
    background: var(--accent-gradient);
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
}

.nav-item.active svg {
    opacity: 1;
}

.auth-section {
    margin-top: auto;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
}

.username {
    font-weight: 500;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    border: none;
}

.primary-btn {
    background: var(--accent-gradient);
    color: #fff;
}

.primary-btn:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.outline-btn {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
}

.outline-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.logout-btn {
    width: 100%;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

.full-width {
    width: 100%;
}

/* Main Content Area */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.top-bar {
    height: 60px;
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 0;
    background: rgba(15, 17, 26, 0.8);
    backdrop-filter: blur(12px);
    z-index: 50;
}

.mobile-menu-toggle {
    display: none;
    cursor: pointer;
    color: var(--text-primary);
}

.search-form {
    flex: 1;
    max-width: 400px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-secondary);
}

.search-input-wrapper input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    padding: 12px 12px 12px 42px;
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition);
}

.search-input-wrapper input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.08);
}

.page-content {
    padding: 40px;
    flex: 1;
}

/* Headers */
.header-section {
    margin-bottom: 20px;
}

.header-section h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 16px;
}

/* History Section */
.history-section {
    animation: fadeIn 0.8s ease-out;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title::before {
    content: '';
    width: 4px;
    height: 20px;
    background: var(--accent-gradient);
    border-radius: 2px;
}

.history-grid {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding: 10px 5px 10px 5px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-glass) transparent;
}

.history-grid::-webkit-scrollbar {
    height: 6px;
}

.history-grid::-webkit-scrollbar-track {
    background: transparent;
}

.history-grid::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 10px;
}

.history-card-link {
    text-decoration: none;
    flex-shrink: 0;
}

.history-card {
    width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 0;
    transition: var(--transition);
}

.history-card:hover {
    transform: translateY(-5px);
}

.history-thumb-wrapper {
    width: 100px;
    height: 100px;
    border-radius: 22px;
    /* iOS style icon radius */
    overflow: hidden;
    transition: var(--transition);
    border: 1px solid var(--border-glass);
    background: var(--bg-glass);
}

.history-card:hover .history-thumb-wrapper {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), var(--shadow-glow);
    border-color: var(--accent-color);
}

.history-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.history-card:hover .history-icon {
    transform: scale(1.1);
}

.history-info {
    width: 100%;
    padding: 8px 0 0 0;
    text-align: center;
}

.history-game-title {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.no-thumb-small {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.2);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* Game Grid */
.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
}

.game-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.game-card {
    border-radius: 20px;
    overflow: hidden;
    padding: 16px;
    transition: var(--transition);
}

.game-card:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: rgba(251, 191, 36, 0.4);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), var(--shadow-glow);
}

.thumb-wrapper {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    margin-bottom: 16px;
    background: rgba(0, 0, 0, 0.5);
}

.game-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.no-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.game-card:hover .game-thumbnail {
    transform: scale(1.1);
}

.play-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
    color: #fff;
}

.game-card:hover .play-overlay {
    opacity: 1;
}

.play-overlay svg {
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.game-card:hover .play-overlay svg {
    transform: scale(1);
}

.game-info h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
}

.genre-tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    font-size: 12px;
    font-weight: 500;
}

.game-icon-mobile {
    display: none;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Game View Details - Refined */
.game-view-container {
    max-width: 1400px;
    margin: 0 auto;
}

.game-header {
    display: none;
    /* Removed as per user request */
}

.game-title {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 12px;
}

.game-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

.badge {
    background: var(--accent-gradient);
    padding: 6px 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
}

.date {
    color: var(--text-secondary);
    font-size: 14px;
}

.game-actions {
    display: flex;
    gap: 16px;
}

.fav-btn.active {
    color: #ff4757;
    background: rgba(255, 71, 87, 0.1);
    border-color: rgba(255, 71, 87, 0.3);
}

.iframe-wrapper {
    aspect-ratio: 16 / 9;
    width: 100%;
    margin-bottom: 32px;
    overflow: clip;
    position: relative;
    padding: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #000;
}

@media (min-width: 1101px) {
    .iframe-wrapper.is-premium {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100vh;
        z-index: 10000;
        aspect-ratio: auto;
        border-radius: 0;
        border: none;
        margin: 0;
        display: grid;
        grid-template-columns: 1fr 15vw;
        grid-template-rows: 1fr auto;
    }

    .iframe-wrapper.is-premium.no-ad {
        grid-template-columns: 1fr;
    }

    .iframe-wrapper.is-premium .pf-controls-overlay {
        display: flex;
        grid-column: 1 / -1;
        grid-row: 2;
        height: 60px;
        background: rgba(0, 0, 0, 0.85);
        backdrop-filter: blur(15px);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        align-items: center;
        justify-content: space-between;
        padding: 0 30px;
    }

    .iframe-wrapper.is-premium .pf-side-overlay {
        display: flex;
        grid-column: 2;
        grid-row: 1;
        background: rgba(15, 15, 15, 0.95);
        border-left: 1px solid rgba(255, 255, 255, 0.1);
        padding: 0;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        overflow-y: auto;
    }

    /* When ad is in the fullscreen side panel, override its normal styles */
    .pf-side-overlay .in-canvas-ad-container {
        width: 100% !important;
        min-width: 100% !important;
        height: 100% !important;
        border-left: none !important;
        border-top: none !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
}

.iframe-wrapper.is-premium.no-ad .pf-side-overlay {
    display: none;
}

/* Interaction Bar - Consolidated */
.interaction-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 30px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    border: 1px solid var(--border-glass);
    margin-bottom: 32px;
    box-shadow: var(--shadow-soft);
}

.interaction-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.interaction-title-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.interaction-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.interaction-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
    font-size: 13px;
}

.interaction-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.pf-game-title {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

/* Reusing these for the overlay internal elements */
.pf-controls-overlay,
.pf-side-overlay {
    display: none;
}

.pf-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.pf-side {
    width: 320px;
    background: transparent;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
}

.sticky-ad {
    position: sticky;
    top: 100px;
    min-height: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

.pf-exit-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.pf-exit-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger-color);
}

.empty-state {
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
}

.game-description {
    padding: 32px;
}

.game-description h3 {
    margin-bottom: 16px;
    font-size: 20px;
}

.game-description p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Auth Pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 160px);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 40px;
}

.auth-card h2 {
    font-size: 28px;
    margin-bottom: 8px;
}

.auth-card p {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.08);
}

.form-error {
    color: var(--danger-color);
    font-size: 13px;
    margin-top: 6px;
}

.form-text {
    display: block;
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 6px;
}

.auth-form {
    margin-bottom: 24px;
}

.auth-links {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-links a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

.auth-links a:hover {
    text-decoration: underline;
}

/* Tooltip */
.tooltip {
    position: relative;
    display: inline-flex;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: var(--bg-glass);
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Mobile Responsive */
@media (max-width: 900px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: -260px;
        transition: left 0.3s ease;
        background: rgba(15, 17, 26, 0.95);
        backdrop-filter: blur(20px);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }

    .sidebar.active {
        left: 0;
    }

    .mobile-menu-toggle {
        display: block;
        margin-right: 20px;
    }

    .page-content {
        padding: 24px;
    }

    .game-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    .game-actions {
        width: 100%;
    }

    .game-actions .btn {
        flex: 1;
    }
}

/* Pagination */
.pagination-section {
    margin-top: 50px;
    display: flex;
    justify-content: center;
    padding-bottom: 20px;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    border-radius: 20px;
}

.page-number {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.pagination-btn {
    padding: 8px 16px;
    font-size: 13px;
}

.pagination-btn svg {
    margin: 0;
}

/* Mobile Pagination */
@media (max-width: 600px) {
    .pagination-controls {
        gap: 12px;
        padding: 10px 16px;
    }

    .page-number {
        font-size: 12px;
    }
}

.game-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.play-count-tag {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.play-count-tag svg {
    opacity: 0.6;
}

.header-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 20px;
    flex-wrap: wrap;
}

.sort-filters {
    display: flex;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    padding: 6px;
    border-radius: 12px;
    border: 1px solid var(--border-glass);
}

.sort-btn {
    padding: 6px 16px;
    font-size: 13px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
}

.sort-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.sort-btn.active {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Mobile Adjustments for Search/Header */
@media (max-width: 768px) {
    .header-title-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .sort-filters {
        width: 100%;
        justify-content: space-between;
    }

    .sort-btn {
        flex: 1;
        text-align: center;
    }
}

/* Authentication Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.4s ease;
}

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

.modal-content {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

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

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

.modal-header {
    text-align: center;
    margin-bottom: 30px;
}

.modal-header h2 {
    font-size: 26px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.modal-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.modal-form .form-group {
    margin-bottom: 20px;
}

.modal-form .form-control {
    width: 100%;
    padding: 14px 16px;
}

.modal-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

.modal-footer a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
}

/* Toast Container upgrade */
.toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    padding: 12px 24px;
    border-radius: 12px;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    color: #fff;
    box-shadow: var(--shadow-soft);
    animation: toast-slide-in 0.4s ease forwards;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

@keyframes toast-slide-in {
    from {
        transform: translateX(120%);
        opacity: 0;
    }

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

@keyframes modal-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-8px);
    }

    75% {
        transform: translateX(8px);
    }
}

.modal-content.error {
    animation: modal-shake 0.3s ease;
    border-color: var(--danger-color);
}

/* Similar Games Section */
.similar-games-section {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid var(--border-glass);
}

.section-title {
    font-size: 20px;
    margin-bottom: 4px;
    font-weight: 600;
}

.similar-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.small-card {
    padding: 12px;
    border-radius: 16px;
}

.small-card .thumb-wrapper {
    margin-bottom: 12px;
}

.small-card h4 {
    font-size: 14px;
    margin-bottom: 4px;
    font-weight: 600;
}

}

/* Top Bar Logo */
.top-bar-logo {
    display: none;
    /* Hide on desktop by default as sidebar has logo */
    height: 36px;
    align-items: center;
    justify-content: flex-end;
    margin-left: auto;
}

.top-bar-logo img {
    height: 32px;
    max-width: 120px;
    object-fit: contain;
}

.top-bar-logo a {
    display: flex;
    align-items: center;
}

@media (max-width: 768px) {
    .top-bar-logo {
        display: flex;
    }
}

/* --- Mobile Game View Additions --- */
.mobile-game-header {
    display: none;
}

.sheet-drag-handle {
    display: none;
    /* Hide on desktop */
}

@media (max-width: 1100px) {

    /* Hide sidebar and topbar natively by placing game view absolute over everything */
    .game-view-container {
        position: fixed;
        inset: 0;
        z-index: 2100;
        /* above sidebar overlay */
        background: var(--bg-base);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .mobile-game-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 16px;
        background: rgba(15, 15, 15, 0.95);
        border-bottom: 1px solid var(--border-glass);
        z-index: 1010;
        backdrop-filter: blur(10px);
        height: 60px;
    }

    .mgh-info {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        flex: 1;
        cursor: pointer;
    }

    .mgh-back-btn,
    .mgh-fs-btn {
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        color: rgba(255, 255, 255, 0.8);
        width: 36px;
        height: 36px;
        padding: 0;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
    }

    .mgh-back-btn:active,
    .mgh-fs-btn:active {
        background: rgba(255, 255, 255, 0.1);
        transform: scale(0.95);
    }

    .mgh-back-btn svg,
    .mgh-fs-btn svg {
        width: 18px;
        height: 18px;
        stroke-width: 2;
    }

    .mgh-icon-wrapper {
        width: 36px;
        height: 36px;
        border-radius: 8px;
        overflow: hidden;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .mgh-icon {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .mgh-title {
        font-weight: 600;
        font-size: 16px;
        color: var(--text-primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 150px;
    }

    .mgh-chevron {
        transition: transform 0.3s ease;
        opacity: 0.7;
    }

    .mgh-chevron.active {
        transform: rotate(180deg);
        opacity: 1;
    }

    .mgh-fs-btn {
        background: rgba(255, 255, 255, 0.1);
        padding: 8px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Layout Logic for Portrait/Landscape */
    .game-main-layout {
        display: flex !important;
        /* override grid */
        flex-direction: column !important;
        flex: 1;
        width: 100%;
        height: 100%;
        overflow: hidden;
        gap: 0 !important;
    }

    @media (orientation: landscape) {
        .game-main-layout {
            flex-direction: row !important;
        }

        .game-column-right {
            display: none !important; /* Hide sidebar completely in mobile landscape */
        }

        .game-column-left {
            flex: 1;
            display: flex;
            flex-direction: column;
            position: relative;
        }

        .iframe-wrapper {
            flex: 1;
            flex-direction: row !important; /* Game on left, ad on right */
            border-radius: 0 !important;
            margin: 0 !important;
            aspect-ratio: auto !important;
        }

        .iframe-wrapper .in-canvas-ad-container {
            width: 15vw !important; /* Fixed width for right ad */
            min-width: 120px !important;
            max-width: 200px !important;
            height: 100% !important;
            max-height: 100% !important;
            border-left: 1px solid var(--border-glass) !important;
            border-top: none !important;
            flex-shrink: 0;
            display: flex !important;
        }
    }

    @media (orientation: portrait) {
        .game-main-layout {
            flex-direction: column !important;
        }

        .game-column-left {
            flex: 1;
            display: flex;
            flex-direction: column;
            position: relative;
        }

        .iframe-wrapper {
            flex: 1;
            flex-direction: column !important;
            border-radius: 0 !important;
            margin: 0 !important;
            aspect-ratio: auto !important;
        }

        .iframe-wrapper .in-canvas-ad-container {
            width: 100% !important;
            min-width: 100% !important;
            max-width: 100% !important;
            height: 15vh !important;
            max-height: 15vh !important;
            min-height: 50px;
            border-left: none !important;
            border-top: 1px solid var(--border-glass);
            flex-shrink: 0;
        }
    }

    /* Bottom Sheet Logic */
    .game-info-wrapper {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(20, 20, 20, 0.95);
        backdrop-filter: blur(15px);
        border-top: 1px solid var(--border-glass);
        border-radius: 20px 20px 0 0;
        transform: translateY(110%);
        transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
        z-index: 1005;
        max-height: 80vh;
        overflow-y: auto;
        padding-top: 20px;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    }

    .game-info-wrapper.active {
        transform: translateY(0);
    }

    .sheet-drag-handle {
        display: block;
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 2px;
        margin: -10px auto 16px auto;
        cursor: pointer;
    }

    .interaction-bar {
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-glass) !important;
        background: transparent !important;
        padding: 16px 20px !important;
    }

    .game-column-right {
        background: rgba(0, 0, 0, 0.5);
        display: flex !important;
        /* Ensure unified ad space is visible */
        justify-content: center;
        align-items: center;
        border-top: 1px solid var(--border-glass);
        width: 100%;
        padding: 10px 0;
    }

    .game-side-ad {
        min-height: 50px !important;
        border: none !important;
        backdrop-filter: none !important;
        background: transparent !important;
        padding: 0 !important;
        box-shadow: none !important;
        width: 100%;
        display: flex;
        justify-content: center;
    }
}

/* --- End Mobile Game View Additions --- */

/* Toast System */
.toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    padding: 14px 24px;
    border-radius: 12px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastSlide 0.4s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

@keyframes toastSlide {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

.toast.removing {
    animation: toastFade 0.3s ease forwards;
}

@keyframes toastFade {
    to {
        transform: translateY(-10px);
        opacity: 0;
    }
}

/* Rating Stars */
.rating-display {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
}

.stars-outer {
    position: relative;
    display: inline-block;
    font-size: 22px;
    line-height: 1;
    height: 1em;
    cursor: default;
    user-select: none;
}

.stars-outer::before {
    content: "\2605 \2605 \2605 \2605 \2605";
    color: rgba(255, 255, 255, 0.15);
}

.stars-inner {
    position: absolute;
    top: 0;
    left: 0;
    white-space: nowrap;
    overflow: hidden;
    width: 0;
    line-height: 1;
    transition: width 0.2s ease;
    pointer-events: none;
    /* pass clicks through to stars-outer */
}

.stars-inner::before {
    content: "\2605 \2605 \2605 \2605 \2605";
    color: #f59e0b;
}

.rating-value {
    font-weight: 700;
    color: var(--accent-color);
}

.rating-count {
    font-size: 12px;
    color: var(--text-secondary);
}


/* Game Cover Banner */
.game-cover-banner {
    position: relative;
    width: 100%;
    height: 280px;
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 28px;
}

.game-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.game-cover-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 30%, rgba(26, 15, 13, 0.95) 100%);
}

/* Sidebar genre links with count badge */
.genre-count-badge {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 11px;
    color: var(--text-secondary);
}

.nav-item.active .genre-count-badge {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Media Queries for Mobile Adaptation */
@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }

    /* Sidebar as Drawer */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        width: 280px;
        height: 100vh;
        z-index: 2000;
        border-radius: 0 20px 20px 0;
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Override collapsed desktop state on mobile drawer */
    .sidebar.collapsed {
        width: 280px !important;
    }

    .sidebar.collapsed .logo-text,
    .sidebar.collapsed .nav-title,
    .sidebar.collapsed .username,
    .sidebar.collapsed .nav-item span,
    .sidebar.collapsed .genre-count-badge,
    .sidebar.collapsed .logout-btn span,
    .sidebar.collapsed .auth-section .btn {
        display: block !important;
    }

    .sidebar.collapsed .nav-item {
        justify-content: flex-start !important;
        padding: 12px !important;
    }

    .sidebar-toggle {
        display: none !important;
    }

    /* Overlay for mobile sidebar */
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        z-index: 1999;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    /* Top Bar adjustments */
    .top-bar {
        height: 60px;
        padding: 0 16px;
        gap: 12px;
    }

    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        color: var(--text-primary);
    }

    .search-form {
        max-width: none;
        flex: 1;
    }

    .search-input-wrapper input {
        padding: 10px 10px 10px 38px;
        font-size: 13px;
    }

    .search-icon {
        left: 10px;
        width: 18px;
        height: 18px;
    }

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

    .header-section h1 {
        font-size: 24px !important;
    }

    /* Game Catalog Adaptation */
    .game-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)) !important;
        gap: 12px !important;
    }

    /* Small screens (most phones): 3 columns */
    @media (max-width: 480px) {
        .game-grid {
            grid-template-columns: repeat(3, 1fr) !important;
        }
    }

    .game-card {
        padding: 8px !important;
        border-radius: 16px !important;
    }

    .thumb-wrapper {
        aspect-ratio: 1 / 1 !important;
        margin-bottom: 8px !important;
        border-radius: 12px !important;
    }

    .game-thumbnail {
        display: none !important;
    }

    .game-icon-mobile {
        display: block !important;
    }

    .game-info h3 {
        font-size: 11px !important;
        line-height: 1.2;
        margin-bottom: 4px !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-align: center;
        height: 26px;
    }

    .game-card-meta {
        display: none !important;
        /* Hide tags on mobile grid to save space */
    }

    .play-overlay {
        display: none !important;
        /* Touch doesn't support hover overlays well */
    }

    .admin-card-actions {
        padding: 0 8px 8px 8px !important;
        flex-direction: column !important;
        gap: 4px !important;
    }

    .admin-card-actions .btn {
        padding: 4px !important;
        font-size: 9px !important;
    }

    /* Pagination */
    .pagination-controls {
        flex-direction: column;
        gap: 12px;
        padding: 16px !important;
    }

    .pagination-btn {
        width: 100%;
        height: 48px;
        /* Better touch target */
    }

    /* Auth Modal Adaptation */
    .modal-content {
        width: 95% !important;
        max-width: 400px;
        padding: 24px !important;
        margin: 10px;
    }

    .modal-header h2 {
        font-size: 20px;
    }

    .form-control {
        height: 48px !important;
        /* Better touch target */
    }

    .btn {
        min-height: 44px;
        /* Ensure mobile friendly button height */
    }
}


/* Toast responsiveness */
@media (max-width: 480px) {
    .toast-container {
        left: 20px;
        right: 20px;
        bottom: 20px;
    }

    .toast {
        width: 100%;
        justify-content: center;
    }
}