/*
© 2026 Logic Duel Puzzles. All rights reserved. 
Unauthorized duplication, modification, or redistribution of this source code is strictly prohibited.
*/

/* ==========================================
   1. CORE VARIABLES & THEMES
   ========================================== */
:root {
    /* GLOBAL PLATFORM COLORS (Constant across all themes) */
    --page-bg: #0f172a;               /* Deep celestial slate blue */
    --ui-text: #f8fafc;               /* Crisp white */
    --ui-accent: #fbbf24;             /* Signature Amber */
    --neutral-bg: rgba(255, 255, 255, 0.06);
    --overlay-bg: rgba(15, 23, 42, 0.92);

    /* THEME A: VOID (Grid specific colors) */
    --grid-bg: rgba(0, 0, 0, 0.35);   /* Translucent dark glass */
    --grid-line: rgba(255, 255, 255, 0.15);
    --grid-block-line: rgba(255, 255, 255, 0.5);
    --grid-given: #f8fafc;            /* White */
    --grid-user: #fbbf24;             /* Amber */
    --grid-candidate: #94a3b8;        /* Muted slate */
    --cell-select: rgba(251, 191, 36, 0.2);
    --cell-select: rgba(251, 191, 36, 0.2);
    --cell-highlight: rgba(255, 255, 255, 0.12); /* Subtle glow for matching numbers */
}

[data-theme="light"] {
    /* THEME B: LIGHT (Grid specific colors) */
    --grid-bg: #f8fafc;               /* Solid crisp paper white */
    --grid-line: rgba(0, 0, 0, 0.15);
    --grid-block-line: rgba(0, 0, 0, 0.6);
    --grid-given: #0f172a;            /* Deep slate ink */
    --grid-user: #2563eb;             /* Blue ink */
    --grid-candidate: #64748b;        /* Dark slate */
    --cell-select: rgba(37, 99, 235, 0.15);
    --cell-select: rgba(37, 99, 235, 0.15);
    --cell-highlight: rgba(0, 0, 0, 0.08); /* Subtle dark tint for matching numbers */
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; user-select: none; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--page-bg);
    color: var(--ui-text);
    height: 100dvh;
    overflow: hidden;
}

/* THE CANVAS CONSTRAINT */
.ambient-vectors {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 0; pointer-events: none;
}

/* ==========================================
   2. GLOBAL APP LAYOUT & UI ROWS
   ========================================== */
#app-container {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 650px;
    margin: 0 auto;
    padding: 10px;
    position: relative;
    z-index: 1;
}

.ui-row {
    flex: 0 0 auto; /* CRITICAL FIX: Never shrink or grow the UI rows */
    width: 100%;
    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; }

.btn {
    background: var(--neutral-bg); color: var(--ui-text); border: 1px solid var(--ui-text);
    padding: 6px 12px; cursor: pointer; border-radius: 4px; font-size: 0.85rem; transition: all 0.2s ease;
}
.btn:hover { border-color: var(--ui-accent); color: var(--ui-accent); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; border-color: rgba(255, 255, 255, 0.2); }
.donate-btn { border-color: #ff9800; }

.sliding-tab-container {
    position: relative; display: flex; background: var(--neutral-bg); border: 1px solid var(--ui-accent);
    border-radius: 20px; padding: 2px; overflow: hidden; isolation: isolate;
}

.diff-tab-container { min-width: 240px; }
.zen-tab-container { min-width: 90px; border-radius: 16px; }
.theme-tab-container { width: 100%; max-width: 200px; } 


.tab-btn {
    background: transparent; color: var(--ui-text); 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(--page-bg) !important; }
.zen-btn { padding: 4px 0; border-radius: 14px; }

.sliding-pill {
    position: absolute; top: 2px; left: 2px; bottom: 2px; background: var(--ui-accent); 
    border-radius: 18px; z-index: 1; transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.diff-pill { width: calc(25% - 2px); }
.zen-pill { width: calc(50% - 2px); border-radius: 14px; }
.theme-pill { width: calc(50% - 2px); } 
.visibility-pill { width: calc(50% - 2px); border-radius: 14px; }
.mode-pill { width: calc(50% - 2px); }

.control-label { font-size: 0.8rem; font-weight: bold; color: var(--ui-text); }

#seed-input {
    background: transparent; border: none; outline: none; padding: 0; color: var(--ui-text); 
    font-family: monospace; font-size: 1.05rem; font-weight: bold; width: 48px; text-align: center; transition: color 0.2s;
}
#seed-input:focus { color: var(--ui-accent) !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;
}

/* ==========================================
   3. BOARD AREA & SVG MATRIX
   ========================================== */
#game-board-area {
    flex: 1 1 0; 
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 5px 0;
    overflow: hidden; 
    position: relative; /* Forces the overlay to stay inside this box */
}

.grid-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

#matrix-svg {
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1 / 1;
    background: var(--grid-bg);
    border: 3px solid var(--grid-block-line);
    border-radius: 4px;
    display: block;
    margin: 0 auto;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.cell-bg { fill: transparent; transition: fill 0.1s ease; cursor: pointer; }
.cell-bg.selected { fill: var(--cell-select); }
.cell-highlight { fill: var(--cell-highlight) !important; transition: fill 0.2s ease; } /* NEW */

/* Internal Grid Lines */
.grid-line-thin { stroke: var(--grid-line); stroke-width: 2; pointer-events: none; transition: stroke 0.3s ease; }
.grid-line-thick { stroke: var(--grid-block-line); stroke-width: 4; pointer-events: none; transition: stroke 0.3s ease; }

/* Matrix Typography */
.val-given { font-weight: 800; font-size: 65px; fill: var(--grid-given); font-family: monospace; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.val-user { font-weight: 800; font-size: 65px; fill: var(--grid-user); font-family: monospace; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.val-candidate { font-weight: 600; font-size: 22px; fill: var(--grid-candidate); font-family: monospace; text-anchor: middle; dominant-baseline: central; pointer-events: none; }

/* ==========================================
   4. THE INPUT COMMAND CENTER
   ========================================== */
#input-zone {
    flex: 0 0 auto; /* CRITICAL FIX: Never shrink */
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding-bottom: 5px;
}

.input-control-bar { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    width: 100%; 
    padding: 0 2px; /* Aligns visually with the numpad edges */
}
.visibility-group, .mode-group { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}

.mode-tab-container { 
    min-width: 200px; /* Gives the emojis room to breathe */
}

.visibility-tab-container { 
    min-width: 90px; 
    border-radius: 16px; 
}

.vis-btn { 
    padding: 4px 0; 
    font-size: 0.7rem; 
    border-radius: 14px; 
}

/* The Numpad */
.numpad-row { display: flex; justify-content: space-between; gap: 4px; width: 100%; }
.numpad-btn {
    flex: 1; aspect-ratio: 1 / 1; max-height: 50px; background: var(--neutral-bg); border: 1px solid var(--grid-line);
    border-radius: 6px; font-size: 1.4rem; font-weight: 800; font-family: monospace; 
    color: var(--grid-user); /* Matches User input color */
    cursor: pointer; transition: all 0.1s ease;
}
.numpad-btn:active { transform: scale(0.95); background: var(--cell-select); }
.action-erase { color: #ef4444 !important; }


/* The Sticky Brush Active State */
.numpad-btn.active-brush {
    background: var(--grid-user);
    color: var(--bg-color) !important; /* Force dark text for contrast */
    border-color: var(--grid-user);
    transform: scale(0.95);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

/* Ensure Erase brush looks distinctly dangerous when active */
.action-erase.active-brush {
    background: #ef4444;
    border-color: #ef4444;
}



/* Color-Sync UX: Dynamically fade to candidate color */
#input-zone[data-input-mode="candidate"] .numpad-btn:not(.action-erase) {
    color: var(--grid-candidate);
    font-weight: 600;
}
#input-zone[data-input-mode="candidate"] .action-erase { opacity: 0.3; cursor: not-allowed; }

/* ==========================================
   5. OVERLAY MODALS & SCROLLBARS
   ========================================== */
.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(7px); 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(--ui-text); }
#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(--page-bg); border-radius: 12px; padding: 20px; text-align: center; color: var(--ui-text);
    border: 2px solid var(--ui-accent); 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;
}
.overlay-sticky-close {
    background: var(--ui-accent) !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(--ui-text); 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(--ui-accent); }
.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; }

.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(--ui-accent); }
.overlay-scroll-area { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.15) transparent; }
