/* ==========================================
   GRAPH UNTANGLE STYLE SHEET
   ========================================== */

/* Theme variables (Default: Cyber) */
:root {
    --color-primary: #00f0ff;      /* Cyan */
    --color-primary-glow: rgba(0, 240, 255, 0.35);
    --color-primary-dim: rgba(0, 240, 255, 0.12);
    
    --color-secondary: #ff00a0;    /* Magenta */
    --color-secondary-glow: rgba(255, 0, 160, 0.35);
    
    --color-accent: #ffd700;       /* Gold */
    --color-accent-glow: rgba(255, 215, 0, 0.45);
    
    --color-bg-panel: rgba(10, 10, 20, 0.82);
    --color-bg-base: #030308;
    --color-text: #e0e0f0;
    --color-text-dim: #7f8c9b;
    --color-border: rgba(0, 240, 255, 0.5);
    --color-shadow: rgba(0, 240, 255, 0.08);
    
    --font-display: 'Orbitron', 'Inter', sans-serif;
    --font-sans: 'Inter', sans-serif;
}

/* Theme overrides */
body.theme-matrix {
    --color-primary: #00ff33;      /* Green */
    --color-primary-glow: rgba(0, 255, 51, 0.4);
    --color-primary-dim: rgba(0, 255, 51, 0.12);
    
    --color-secondary: #ff9d00;    /* Amber */
    --color-secondary-glow: rgba(255, 157, 0, 0.35);
    
    --color-accent: #ffffff;       /* White */
    --color-accent-glow: rgba(255, 255, 255, 0.45);
    
    --color-bg-panel: rgba(4, 12, 4, 0.85);
    --color-bg-base: #020602;
    --color-border: rgba(0, 255, 51, 0.5);
    --color-shadow: rgba(0, 255, 51, 0.08);
}

body.theme-synth {
    --color-primary: #ffd400;      /* Synth Gold */
    --color-primary-glow: rgba(255, 212, 0, 0.45);
    --color-primary-dim: rgba(255, 212, 0, 0.12);
    
    --color-secondary: #c000ff;    /* Violet */
    --color-secondary-glow: rgba(192, 0, 255, 0.35);
    
    --color-accent: #00f0ff;       /* Cyan */
    --color-accent-glow: rgba(0, 240, 255, 0.45);
    
    --color-bg-panel: rgba(14, 5, 14, 0.85);
    --color-bg-base: #060206;
    --color-border: rgba(255, 212, 0, 0.5);
    --color-shadow: rgba(255, 212, 0, 0.08);
}

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

body {
    background-color: var(--color-bg-base);
    color: var(--color-text);
    font-family: var(--font-sans);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    user-select: none;
    -webkit-user-select: none;
}

/* Fullscreen Canvas Container */
#game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* UI Overlay Container */
#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none; /* Let clicks pass to canvas */
}

/* Screen Structure */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 5;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* Re-enable pointer events for UI */
}

/* Glassmorphism Panel Base */
.glass-panel {
    background: var(--color-bg-panel);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 2px solid var(--color-border);
    border-radius: 12px;
    padding: 40px;
    width: 420px;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 0 25px var(--color-shadow);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel.panel-large {
    width: 720px;
    max-width: 95%;
}

.glass-panel.victory-panel {
    width: 500px;
}

/* Header Text Styling */
header h1, header h2 {
    font-family: var(--font-display);
    font-weight: 900;
    letter-spacing: 2px;
    margin-bottom: 24px;
}

.glow-title {
    font-size: 2.2rem;
    color: #ffffff;
    text-shadow: 0 0 10px var(--color-primary), 0 0 20px var(--color-primary-glow);
}

header h2 {
    font-size: 1.8rem;
    color: var(--color-primary);
    text-shadow: 0 0 8px var(--color-primary-glow);
}

.victory-title {
    color: var(--color-primary);
    text-shadow: 0 0 10px var(--color-primary-glow);
    font-size: 2.2rem;
}

/* Buttons System */
.btn {
    background: rgba(15, 15, 30, 0.6);
    border: 1px solid rgba(50, 140, 240, 0.3);
    border-color: var(--color-border);
    border-radius: 6px;
    color: var(--color-text);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 500;
    padding: 12px 24px;
    transition: all 0.2s ease-in-out;
    width: 100%;
    margin-bottom: 12px;
    outline: none;
}

.btn:hover:not(:disabled) {
    background: rgba(30, 40, 60, 0.75);
    border-color: var(--color-primary);
    color: #ffffff;
    box-shadow: 0 0 12px var(--color-primary-glow);
    transform: translateY(-2px);
}

.btn:active:not(:disabled) {
    background: var(--color-primary-dim);
    transform: translateY(0);
}

.btn:disabled {
    background: rgba(10, 10, 15, 0.4);
    border-color: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.15);
    cursor: not-allowed;
}

.btn-primary {
    border-width: 2px;
    border-color: var(--color-primary);
    color: var(--color-primary);
    font-weight: 700;
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 0 16px var(--color-primary);
}

/* Main Menu specific layout */
.menu-actions {
    display: flex;
    flex-direction: column;
    margin-top: 10px;
}

.menu-actions.horizontal {
    flex-direction: row;
    gap: 16px;
}

.menu-actions.horizontal .btn {
    flex: 1;
    margin-bottom: 0;
}

.score-footer {
    margin-top: 24px;
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--color-text-dim);
}

/* Badges */
.badge {
    background: var(--color-primary-dim);
    border: 1px solid var(--color-primary-glow);
    border-radius: 4px;
    color: var(--color-primary);
    font-family: var(--font-display);
    font-size: 0.8rem;
    padding: 3px 8px;
    font-weight: 700;
}

/* HUD Panel Overlay Layout */
#screen-hud {
    pointer-events: none; /* Allow play through HUD */
    display: block;
    box-sizing: border-box;
}

.hud-bar {
    position: absolute;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    z-index: 10;
    pointer-events: auto; /* UI interacts normally */
}

.hud-top {
    top: 0;
    background: linear-gradient(to bottom, rgba(3, 3, 8, 0.85), rgba(3, 3, 8, 0));
}

.hud-bottom {
    bottom: 0;
    background: linear-gradient(to top, rgba(3, 3, 8, 0.85), rgba(3, 3, 8, 0));
    justify-content: center;
    gap: 20px;
}

.hud-left, .hud-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
}

#hud-level-label {
    font-size: 1.3rem;
    color: #ffffff;
    text-shadow: 0 0 6px var(--color-primary-glow);
}

#hud-timer-label, #hud-moves-label {
    background: rgba(3, 3, 8, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 8px 14px;
}

/* Progress bar in HUD */
.hud-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 35%;
    max-width: 500px;
    gap: 6px;
}

.progress-container {
    background: rgba(10, 10, 20, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    height: 10px;
    width: 100%;
    overflow: hidden;
}

.progress-bar-fill {
    background: var(--color-primary);
    box-shadow: 0 0 10px var(--color-primary);
    height: 100%;
    width: 0%;
    border-radius: 8px;
    transition: width 0.3s cubic-bezier(0.1, 0.8, 0.3, 1);
}

#hud-progress-label {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text);
}

/* HUD Button Items */
.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: auto;
    padding: 10px 18px;
    margin-bottom: 0;
    font-size: 0.9rem;
    background: rgba(10, 10, 20, 0.75);
}

/* Level Grid Select Panel */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    padding-bottom: 14px;
    margin-bottom: 24px;
}

.panel-header h2 {
    margin-bottom: 0;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    max-height: 360px;
    overflow-y: auto;
    padding: 4px;
    margin-bottom: 24px;
}

/* Scrollbar customizations */
.level-grid::-webkit-scrollbar {
    width: 6px;
}
.level-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}
.level-grid::-webkit-scrollbar-thumb {
    background: var(--color-primary-dim);
    border-radius: 4px;
}
.level-grid::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

/* Level Button Items */
.btn-grid-lvl {
    width: 76px;
    height: 76px;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    font-family: var(--font-display);
}

.btn-grid-lvl.completed {
    border-color: #00ff66;
    color: #00ff66;
    background: rgba(0, 255, 102, 0.05);
}
.btn-grid-lvl.completed:hover {
    box-shadow: 0 0 12px rgba(0, 255, 102, 0.4);
    border-color: #00ff66;
}

.btn-grid-lvl.active-next {
    border-color: var(--color-primary);
    border-width: 2px;
    color: var(--color-primary);
    text-shadow: 0 0 6px var(--color-primary-glow);
}

.panel-actions {
    display: flex;
    justify-content: center;
}
#btn-level-select-back {
    width: auto;
    padding: 12px 30px;
}

/* Settings Form Controls */
.settings-form {
    text-align: left;
    margin-bottom: 30px;
}

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

.form-group label {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--color-text-dim);
    margin-bottom: 8px;
    font-weight: 500;
}

/* Dropdown select custom styling */
.form-group select {
    background: rgba(10, 10, 20, 0.85);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: 1rem;
    padding: 10px 14px;
    width: 100%;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.form-group select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 8px var(--color-primary-glow);
}

/* Sliders custom styling */
.form-group input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    cursor: pointer;
    outline: none;
}

.form-group input[type="range"]::-webkit-slider-runnable-track {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.05);
    height: 8px;
    border-radius: 4px;
}

.form-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    border: 2px solid var(--color-primary);
    background: #ffffff;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    margin-top: -6px;
    box-shadow: 0 0 8px var(--color-primary);
    transition: transform 0.1s;
}

.form-group input[type="range"]:active::-webkit-slider-thumb {
    transform: scale(1.25);
}

/* Modal Backdrop */
.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 2, 5, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    pointer-events: auto; /* Enable UI clicks inside the settings modal */
}

.modal-content {
    animation: zoomIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Victory styling details */
.victory-panel {
    animation: slideUp 0.35s cubic-bezier(0.1, 0.8, 0.3, 1.05);
}

.high-score-badge {
    background: linear-gradient(135deg, var(--color-accent), #ffaa00);
    border-radius: 20px;
    color: #030308;
    display: inline-block;
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 0.95rem;
    padding: 6px 20px;
    margin-bottom: 24px;
    box-shadow: 0 0 15px var(--color-accent-glow);
    animation: throb 1.5s infinite;
}

.victory-stats {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 30px;
}

.stats-group {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 16px;
    text-align: left;
}

.stats-group h3 {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--color-primary);
    letter-spacing: 1px;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.stats-group p {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Danger variant button */
.btn-danger {
    border-color: #ff0055;
    color: #ff0055;
}
.btn-danger:hover:not(:disabled) {
    border-color: #ff0055;
    background: rgba(255, 0, 85, 0.08);
    box-shadow: 0 0 10px rgba(255, 0, 85, 0.35);
}

/* Animations */
@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes throb {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 20px var(--color-accent);
    }
    100% {
        transform: scale(1);
    }
}
