/* ── Loading Screen ───────────────────────────────────────────────────────── */
#loading-screen {
    position: fixed;
    inset: 0;
    background: #0a0a15;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    transition: opacity 0.4s ease;
}
#loading-screen.loading-fade-out {
    opacity: 0;
    pointer-events: none;
}
.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: min(80%, 320px);
}
.loading-title {
    font-family: 'Courier New', monospace;
    font-size: clamp(28px, 8vw, 42px);
    letter-spacing: 6px;
    color: #4ecdc4;
    text-shadow: 0 0 20px rgba(78, 205, 196, 0.6);
    animation: loading-pulse 1.8s ease-in-out infinite;
}
@keyframes loading-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}
.loading-bar-track {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
}
.loading-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4ecdc4, #ffe66d);
    border-radius: 3px;
    transition: width 0.15s ease;
}
.loading-label {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #666;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.loading-start-btn {
    border: 2px solid rgba(78, 205, 196, 0.65);
    background: rgba(78, 205, 196, 0.08);
    color: #e8fffb;
    font: inherit;
    font-size: 14px;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 12px 20px;
    min-width: 180px;
    cursor: pointer;
}

.loading-start-btn:disabled {
    opacity: 0.65;
    cursor: default;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    background-color: #0f0f1e;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    color: #ffffff;
    touch-action: pan-y;
}

.extension-warning {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 32px));
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid rgba(255, 200, 120, 0.38);
    background: rgba(33, 22, 8, 0.96);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    color: #ffd694;
    z-index: 10001;
}

.extension-warning p {
    margin: 0;
    line-height: 1.5;
    font-size: 13px;
}

.extension-warning button {
    flex: 0 0 auto;
    border: 1px solid rgba(255, 214, 148, 0.45);
    background: transparent;
    color: #ffd694;
    font: inherit;
    padding: 6px 10px;
    cursor: pointer;
}

.extension-warning button:hover {
    background: rgba(255, 214, 148, 0.1);
}

.site-shell {
    min-height: 100vh;
    padding: 32px 20px 140px;
    background:
        radial-gradient(circle at top, rgba(78, 205, 196, 0.18), transparent 32%),
        linear-gradient(180deg, #121329 0%, #0b0d18 58%, #070910 100%);
}

.site-header,
.page-main,
.site-footer {
    width: min(1200px, 100%);
    margin: 0 auto;
}

.site-header {
    margin-bottom: 28px;
}

.site-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    padding: 24px 28px;
    border: 1px solid rgba(78, 205, 196, 0.2);
    background: rgba(8, 12, 25, 0.78);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
}

.site-kicker {
    color: #7eb8ff;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 12px;
    margin-bottom: 10px;
}

.site-title {
    font-size: clamp(34px, 6vw, 64px);
    letter-spacing: 3px;
    line-height: 0.95;
    margin-bottom: 12px;
}

.site-lede {
    max-width: 680px;
    color: #b6bdd6;
    font-size: 16px;
    line-height: 1.6;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
}

.site-nav a,
.site-footer-links a,
.content-links a {
    color: #4ecdc4;
    text-decoration: none;
}

.site-nav a {
    padding: 10px 14px;
    border: 1px solid rgba(78, 205, 196, 0.28);
    background: rgba(255, 255, 255, 0.03);
}

.site-nav a:hover,
.site-footer-links a:hover,
.content-links a:hover {
    text-decoration: underline;
}

.page-main {
    display: grid;
    gap: 28px;
}

.inline-ad-section {
    display: grid;
    gap: 14px;
    padding: 20px 24px;
    border: 1px solid rgba(78, 205, 196, 0.16);
    background: rgba(8, 12, 25, 0.82);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.22);
}

.inline-ad-label {
    color: #7eb8ff;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 12px;
    margin-bottom: 6px;
}

.inline-ad-text {
    color: #a6aec8;
    line-height: 1.6;
    font-size: 14px;
}

.game-stage {
    display: flex;
    justify-content: center;
    padding: 28px;
    border: 1px solid rgba(126, 184, 255, 0.16);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02)),
        rgba(10, 13, 26, 0.86);
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.28);
}

#game-container {
    position: relative;
    max-width: 600px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none;
}

#gameCanvas {
    display: block;
    background-color: #1a1a2e;
    border: 3px solid #333;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    touch-action: none;
    cursor: crosshair;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.compact-content {
    align-items: start;
}

.content-card-wide {
    grid-column: span 1;
}

.content-card,
.editorial-card {
    padding: 24px;
    border: 1px solid rgba(78, 205, 196, 0.16);
    background: rgba(7, 10, 22, 0.82);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.content-card h2,
.editorial-card h2 {
    color: #e6ecff;
    font-size: 20px;
    margin-bottom: 14px;
    letter-spacing: 1px;
}

.content-card p,
.content-card li,
.editorial-card p,
.site-footer p {
    color: #a6aec8;
    line-height: 1.7;
    font-size: 14px;
}

.content-card p + p,
.editorial-card p + p {
    margin-top: 12px;
}

.content-list,
.content-links {
    padding-left: 20px;
}

.content-list li + li,
.content-links li + li {
    margin-top: 8px;
}

.mini-notes {
    padding: 16px 20px;
    border: 1px solid rgba(78, 205, 196, 0.14);
    background: rgba(7, 10, 22, 0.72);
}

.mini-notes p {
    color: #9da7c5;
    line-height: 1.6;
    font-size: 13px;
}

.publisher-note {
    padding: 18px 20px;
    border: 1px solid rgba(126, 184, 255, 0.14);
    background: rgba(9, 13, 26, 0.76);
}

.publisher-note h2 {
    color: #e6ecff;
    font-size: 18px;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.publisher-note p {
    color: #a6aec8;
    line-height: 1.65;
    font-size: 14px;
}

.editorial-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.site-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 28px;
    padding: 24px 4px 0;
}

.site-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

/* UI Overlay */
#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Allow clicks to pass through to canvas */
}

/* Note: Individual UI elements set their own pointer-events as needed */

/* Debug Info */
.debug-info {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px;
    font-size: 12px;
    border-radius: 5px;
    font-family: monospace;
    color: #4ecdc4;
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    body {
        min-height: 100vh;
        min-height: -webkit-fill-available; /* Fix for iOS Safari */
        min-height: 100dvh; /* Modern: adapts as browser chrome slides away */
    }

    .extension-warning {
        top: 8px;
        width: calc(100% - 16px);
    }

    .site-shell {
        padding: 16px 0 120px;
    }

    .site-header,
    .page-main,
    .site-footer {
        width: 100%;
    }

    .site-header-inner,
    .content-card,
    .editorial-card {
        border-left: none;
        border-right: none;
    }

    .site-header-inner,
    .site-footer {
        padding-left: 16px;
        padding-right: 16px;
    }

    .site-header-inner,
    .site-footer,
    .content-grid,
    .editorial-strip {
        display: block;
    }

    .site-nav {
        justify-content: flex-start;
        margin-top: 16px;
    }

    .game-stage {
        padding: 0;
        border-left: none;
        border-right: none;
    }

    .inline-ad-section {
        padding: 18px 16px;
        border-left: none;
        border-right: none;
    }

    .mini-notes {
        border-left: none;
        border-right: none;
        padding: 16px;
    }

    .publisher-note {
        border-left: none;
        border-right: none;
        padding: 16px;
    }

    #game-container {
        width: 100vw;
        height: 100vh;
        height: -webkit-fill-available; /* Fix for iOS Safari */
        height: 100dvh;
        max-width: 100vw;
        max-height: 100vh;
        max-height: -webkit-fill-available;
        max-height: 100dvh;
        display: flex;
        justify-content: center;
        align-items: center;
        overflow: hidden;
    }

    #gameCanvas {
        border: none;
        /* Scale canvas to fit viewport while maintaining aspect ratio */
        max-width: min(100vw, 66.67vh); /* 600:900 = 2:3 ratio */
        max-height: min(100vh, 150vw);
        max-height: min(-webkit-fill-available, 150vw); /* Fix for iOS Safari */
        max-height: min(100dvh, 150vw); /* Modern: dynamic viewport */
        width: auto;
        height: auto;
    }

    .content-card + .content-card,
    .editorial-card + .editorial-card {
        margin-top: 16px;
    }

    .site-footer {
        margin-top: 20px;
        padding-top: 20px;
    }
}

/* ── BANNER AD ───────────────────────────────────── */
.ad-banner-container {
    display: none; /* shown by AdManager.showBanner() */
    width: 100%;
    min-height: 72px;
    padding: 12px 14px;
    border: 1px dashed rgba(78, 205, 196, 0.28);
    background: rgba(0, 0, 0, 0.28);
    justify-content: center;
    align-items: center;
}

.ad-blocker-msg {
    display: none;
    margin: 0;
    color: #aaa;
    font-size: 13px;
    text-align: center;
    padding: 0 12px;
}

.ad-banner-container.ad-blocked .ad-blocker-msg {
    display: block;
}

/* Portrait orientation enforcement for mobile */
@media (orientation: landscape) and (max-width: 900px) {
    body::before {
        content: "Please rotate your device to portrait mode";
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: rgba(0, 0, 0, 0.95);
        padding: 20px;
        border-radius: 10px;
        z-index: 10000;
        text-align: center;
    }

    #game-container {
        opacity: 0.2;
    }
}
