/*
© 2026 Logic Duel Puzzles. All rights reserved. Unauthorized duplication, modification, or redistribution of this source code is strictly prohibited.
// --- Start: ConnectDuel CSS ---
*/

/* --- THEME VARIABLES & GLOW MATRICES --- */
:root {
    /* Theme A: Water (Default - Deep blues and tranquil cyans) */
    --bg-color: #0f172a;
    --overlay-bg: rgba(15, 23, 42, 0.85);
    --neutral-bg: rgba(255, 255, 255, 0.06);
    --text-color: #f8fafc;
    --accent-color: #38bdf8;
    
    /* ConnectDuel Specific State Colors */
    --empty-color: #334155;
    --powered-color: #0ea5e9;
    --error-color: #ef4444;
}

[data-theme="electric"] {
    /* Theme B: Electric (High contrast industrial greys and amber) */
    --bg-color: #1a1a1a;
    --overlay-bg: rgba(26, 26, 26, 0.90);
    --neutral-bg: rgba(255, 255, 255, 0.08);
    --text-color: #f5f5f5;
    --accent-color: #fbbf24;

    --empty-color: #404040; /* Solid dim grey */
    --powered-color: #fbbf24;
    --error-color: #f87171;
}

[data-theme="data"] {
    /* Theme C: Network (Hacker/Matrix greens and deep blacks) */
    --bg-color: #051c0b;
    --overlay-bg: rgba(5, 28, 11, 0.90);
    --neutral-bg: rgba(16, 185, 129, 0.05);
    --text-color: #d1fae5;
    --accent-color: #10b981;

    --empty-color: #064e3b; /* Solid dim forest green */
    --powered-color: #34d399;
    --error-color: #f43f5e;
}

/* --- GLOBAL RESETS & FOUNDATION --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* ADD THIS to ensure the root document fills exactly 100% of the visible window */
html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    position: relative;
}

#app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 850px; 
    margin: 0 auto;
    padding: 12px;
    
    /* THE FIX: Absolute pinning instead of height */
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    
    z-index: 1;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom, 12px);
}

/* --- Ambient Background Vectors --- */
.ambient-vectors {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* --- Unified Row Components --- */
.ui-row {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    padding: 6px 0;
    gap: 10px;
}

.level-controls, .system-controls, .action-group, .timer-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- Global Button Styling --- */
.btn {
    background: var(--neutral-bg);
    color: var(--text-color);
    border: 1px solid var(--text-color);
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.2);
}

.donate-btn { border-color: #ff9800; }

/* --- Modern Sliding Tab Pill --- */
.sliding-tab-container {
    position: relative;
    display: flex;
    background: var(--neutral-bg);
    border: 1px solid var(--accent-color);
    border-radius: 20px;
    padding: 2px;
    overflow: hidden;
    isolation: isolate;
}

.diff-tab-container { min-width: 240px; }
.zen-tab-container { min-width: 90px; border-radius: 16px; }
.bounds-tab-container { min-width: 110px; border-radius: 16px; }

/* Constrain theme tab to prevent stretching */
.theme-tab-container { min-width: 260px; max-width: 320px; flex: 0 1 auto; }

.tab-btn {
    background: transparent;
    color: var(--text-color);
    border: none;
    padding: 6px 0;
    flex: 1;
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    border-radius: 18px;
    z-index: 2;
    transition: color 0.2s ease;
    text-align: center;
}

.tab-btn.active { color: var(--bg-color) !important; }
.zen-btn, .bounds-btn { padding: 4px 0; border-radius: 14px; }

/* The physical animated background elements */
.sliding-pill {
    position: absolute;
    top: 2px; left: 2px; bottom: 2px;
    background: var(--accent-color);
    border-radius: 18px;
    z-index: 1;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Adjust pill widths based on tab counts */
.diff-pill { width: calc(25% - 2px); }
.zen-pill, .bounds-pill { width: calc(50% - 2px); border-radius: 14px; }
.theme-pill { width: calc(33.333% - 2px); }

/* --- Seed Input & Clock --- */
.control-label { font-size: 0.8rem; font-weight: bold; color: var(--text-color); }

#seed-input {
    background: transparent; border: none; outline: none; padding: 0;
    color: var(--text-color); font-family: monospace; font-size: 1.05rem;
    font-weight: bold; width: 48px; text-align: center; transition: color 0.2s;
}
#seed-input:focus { color: var(--accent-color) !important; }
#seed-input.history-solved { color: #4caf50; }
#seed-input.history-gave-up { color: #f44336; }
#seed-input.history-zen { color: rgba(255, 255, 255, 0.35); }

#game-clock {
    font-family: monospace; font-size: 1.35rem; font-weight: bold;
    background: var(--neutral-bg); padding: 4px 12px; border-radius: 6px;
    transition: opacity 0.2s ease, color 0.2s ease; cursor: pointer;
}
#game-clock:hover { color: var(--accent-color); }
#game-clock.zen-active { opacity: 0.25; color: rgba(255, 255, 255, 0.5); }

/* --- ConnectDuel SVG Engine & Tile Aesthetics --- */
#game-board-area {
    flex: 1;
    display: flex;
    flex-direction: column; 
    gap: 10px; 
    width: 100%;
    justify-content: center; 
    align-items: center;
    position: relative;
    padding: 5px 0;
    min-height: 0;
}

.grid-container {
    flex: 1;
    display: flex;
    width: 100%;
    max-width: 100%; 
    justify-content: center;
    align-items: center;
    min-height: 0; 
}

#connect-svg {
    width: 100%;
    height: 100%;
    max-height: 100%; 
    display: block;
    touch-action: none; /* Crucial for native SVG touch matrix interactions on mobile */
}

/* Ultra-Glassy Background Grid Slot for contrast */
.grid-slot {
    fill: rgba(255, 255, 255, 0.02);
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 1;
}
/* Ensure the grid respects themes */
[data-theme="data"] .grid-slot { fill: rgba(16, 185, 129, 0.02); stroke: rgba(16, 185, 129, 0.08); }
[data-theme="electric"] .grid-slot { fill: rgba(255, 255, 255, 0.03); stroke: rgba(255, 255, 255, 0.06); }

/* Interactive Connection Group */
.connection-tile {
    cursor: pointer;
    color: var(--empty-color); /* Default state is empty */
    transition: color 0.3s ease, filter 0.3s ease, opacity 0.3s ease;
}

/* Locking Mechanic visual dimming */
.connection-tile.locked {
    opacity: 0.45;
    filter: grayscale(0.5);
}

/* The underlying base that physically rotates */
.connection-base {
    transform-origin: 50px 50px; /* Absolute SVG coordinates, not 'center center' */
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Snappy, slightly bouncy rotation */
}

/* The magical CSS glow! */
.connection-tile.powered {
    color: var(--powered-color);
    filter: drop-shadow(0 0 8px var(--powered-color));
}

.connection-tile.error-loop {
    color: var(--error-color);
    filter: drop-shadow(0 0 8px var(--error-color));
    animation: pulse-error 1s infinite alternate;
}

/* Decoupled Static Icon Layer (Sits perfectly upright above the rotating base) */
.static-icon {
    pointer-events: none; /* Let the clicks pass through to the rotating base */
    transform-origin: center center;
    color: inherit; /* Inherits the powered/empty color from the parent connection-tile */
}

@keyframes pulse-error {
    from { opacity: 0.8; }
    to { opacity: 1; filter: drop-shadow(0 0 12px var(--error-color)); }
}

/* --- Responsive Extreme Difficulty Hiding --- */
@media (max-width: 600px) {
    .diff-extreme {
        display: none !important; 
    }
    .diff-pill {
        width: calc(33.333% - 2px); 
    }
}

/* --- Dual Overlay System (Identical to Hub/Platform standard) --- */
.overlay-hidden { opacity: 0; pointer-events: none; }

#board-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--overlay-bg);
    backdrop-filter: blur(5px);
    display: flex; justify-content: center; align-items: center;
    z-index: 10; transition: opacity 0.2s ease; border-radius: 8px;
}
#board-overlay-content { text-align: center; color: var(--text-color); }

#info-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100dvh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex; justify-content: center; align-items: center;
    z-index: 999; transition: opacity 0.2s ease;
}
#info-overlay-content {
    display: flex; flex-direction: column; width: 92%; max-width: 500px; max-height: 85dvh;
    background: var(--bg-color); border-radius: 12px; padding: 20px;
    text-align: center; color: var(--text-color); border: 2px solid var(--accent-color);
    box-shadow: 0px 10px 40px rgba(0,0,0,0.9);
}

.overlay-scroll-area {
    overflow-y: auto; text-align: left; margin-bottom: 15px; padding: 15px;
    font-size: 0.95rem; line-height: 1.6; background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05); border-radius: 8px;
}

/* The 3D Tactile Close Button */
.overlay-sticky-close {
    background: var(--accent-color) !important; color: #000000 !important;
    font-weight: 900; padding: 16px; border-radius: 8px; border: none;
    text-transform: uppercase; letter-spacing: 1px; cursor: pointer;
    box-shadow: 0px 5px 0px rgba(0, 0, 0, 0.4), 0px 10px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s ease, box-shadow 0.1s ease; flex-shrink: 0;
}
.overlay-sticky-close:active {
    transform: translateY(5px); box-shadow: 0px 0px 0px rgba(0, 0, 0, 0.4), 0px 2px 5px rgba(0, 0, 0, 0.3);
}

.overlay-icon-btn {
    font-size: 5rem; cursor: pointer; background: none; border: none;
    color: var(--text-color); transition: transform 0.2s ease, color 0.2s ease;
    text-shadow: 0px 4px 15px rgba(0,0,0,0.5);
}
.overlay-icon-btn:hover { transform: scale(1.1); color: var(--accent-color); }

.overlay-text { font-size: 1.6rem; font-weight: bold; margin-bottom: 25px; text-shadow: 0px 3px 6px rgba(0,0,0,0.9); padding: 0 15px; }
.overlay-actions { display: flex; gap: 35px; justify-content: center; }
.overlay-actions .btn { font-size: 1.2rem; padding: 10px 30px; border-radius: 6px; font-weight: bold; }

/* Custom Scrollbars */
.overlay-scroll-area::-webkit-scrollbar { width: 6px; }
.overlay-scroll-area::-webkit-scrollbar-track { background: transparent; }
.overlay-scroll-area::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 10px; transition: background 0.2s ease; }
.overlay-scroll-area::-webkit-scrollbar-thumb:hover { background: var(--accent-color); }
.overlay-scroll-area { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.15) transparent; }


/* --- Mobile Viewport UI Condensation --- */
@media (max-width: 480px) {
    /* Tighten global row gaps */
    .ui-row { gap: 6px; padding: 4px 0; }
    .btn { font-size: 0.75rem; padding: 6px 10px; }
    .tab-btn { font-size: 0.7rem; padding: 4px 0; }
    
    /* Shrink Tab Containers to prevent wrapping */
    .diff-tab-container { min-width: 190px; }
    .theme-tab-container { min-width: 210px; }
    .bounds-tab-container { min-width: 90px; }
    .zen-tab-container { min-width: 80px; }
    
    /* Keep clock legible but compact */
    #game-clock { font-size: 1.1rem; padding: 4px 8px; }
}

/*
// --- End: ConnectDuel CSS ---
*/