/* ===== Game Window (modal) ===== */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 2vh 2vw;
}

.modal.active {
    display: flex;
}

.window {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.06);
    width: 90vw;
    height: 90vh;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: width 0.2s, height 0.2s;
}

/* === Window title bar === */
.window-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(180deg, #2a2a4e 0%, #1f1f3e 100%);
    padding: 0.5rem 0.8rem;
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.window-titlebar:active {
    cursor: grabbing;
}

.window-titlebar.dragging {
    opacity: 0.95;
}

.window-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.window-title-icon {
    font-size: 1.1rem;
}

.window-title-meta {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 400;
    margin-left: 0.5rem;
}

.window-title-meta a {
    color: var(--secondary);
    text-decoration: none;
}

.window-title-meta a:hover {
    text-decoration: underline;
}

.window-controls {
    display: flex;
    gap: 0.4rem;
}

.window-btn {
    width: 32px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: rgba(255,255,255,0.08);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.window-btn:hover {
    background: rgba(255,255,255,0.2);
}

.window-btn-close:hover {
    background: #e74c3c;
}

/* === Window body === */
.window-body {
    flex: 1;
    position: relative;
    background: #000;
    overflow: hidden;
}

.window-body iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    background: #000;
}

/* Attribution bar slot reserved for window.js to populate */
.window-attribution-slot {
    flex-shrink: 0;
}
.window-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.6);
    color: var(--text);
    font-size: 0.9rem;
    z-index: 1;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s;
}

.window-loading.hidden {
    opacity: 0;
}

.window-loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: var(--secondary);
    border-radius: 50%;
    margin-left: 12px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === Resize handle === */
.window-resize {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 18px;
    height: 18px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.3) 50%);
    border-bottom-right-radius: 12px;
    z-index: 2;
}

/* === Minimized state === */
.window.minimized {
    height: auto !important;
}

.window.minimized .window-body,
.window.minimized .window-resize {
    display: none;
}

/* === Fullscreen state (browser native) === */
.window:fullscreen,
.window:-webkit-full-screen {
    border-radius: 0;
    width: 100vw;
    height: 100vh;
    max-width: none;
    box-shadow: none;
}

/* === Responsive === */
@media (max-width: 768px) {
    .modal {
        padding: 0;
    }
    .window {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
    .window-title-meta {
        display: none;  /* save space on mobile */
    }
}