:root {
    --accent-color: #0ea5e9; /* Default sky-500 */
    --scramble-color: #facc15; /* Default yellow-400 */
    --timer-font-size: 10rem; /* Default timer size */
    
    /* Dark mode colors (default) */
    --bg-primary: #111827; /* gray-900 */
    --bg-secondary: rgba(31, 41, 55, 0.5); /* gray-800/50 */
    --bg-tertiary: #374151; /* gray-700 */
    --text-primary: #f3f4f6; /* gray-100 */
    --text-secondary: #9ca3af; /* gray-400 */
    --border-color: #4b5563; /* gray-600 */
}

body.light-mode {
    /* Light mode colors */
    --bg-primary: #f9fafb; /* gray-50 */
    --bg-secondary: rgba(255, 255, 255, 0.8); /* white/80 */
    --bg-tertiary: #e5e7eb; /* gray-200 */
    --text-primary: #111827; /* gray-900 */
    --border-color: #d1d5db; /* gray-300 */
}

body {
    font-family: 'Roboto Mono', monospace;
    background-color: var(--bg-primary);
    -webkit-touch-callout: none; /* iOS Safari */
    -webkit-user-select: none; /* Safari */
    -khtml-user-select: none; /* Konqueror HTML */
    -moz-user-select: none; /* Old versions of Firefox */
    -ms-user-select: none; /* Internet Explorer/Edge */
    user-select: none; /* Non-prefixed version, currently supported by Chrome, Edge, Opera and Firefox */
}

/* --- Apple-like Card Animations --- */
.stat-card {
    position: relative;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow: hidden; /* Hide the pseudo-element when not hovered */
    opacity: 0;
    transform: translateY(20px);
    animation: cascade-in 0.5s cubic-bezier(0.3, 0.8, 0.2, 1) forwards;
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color), 0 0 20px var(--accent-color);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}

.stat-card:hover::after {
    opacity: 1;
}

/* Staggered animation delays */
.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.15s; }
.stat-card:nth-child(3) { animation-delay: 0.2s; }
.stat-card:nth-child(4) { animation-delay: 0.25s; }
.stat-card:nth-child(5) { animation-delay: 0.3s; }
.stat-card:nth-child(6) { animation-delay: 0.35s; }
.stat-card:nth-child(7) { animation-delay: 0.4s; }
.stat-card:nth-child(8) { animation-delay: 0.45s; }
.stat-card:nth-child(9) { animation-delay: 0.5s; }

@keyframes cascade-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Succession Load Animation --- */
#timer,
#scramble {
    /* Apply the animation on load */
    animation: succession-in 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

#scramble {
    animation-delay: 0.2s; /* Stagger the scramble animation slightly */
}

@keyframes succession-in {
    from {
        opacity: 0;
        transform: scale(0.95);
        filter: blur(8px);
        text-shadow: 0 0 15px var(--accent-color);
    }
    to {
        opacity: 1;
        transform: scale(1);
        filter: blur(0);
        text-shadow: none;
    }
}

/* --- Settings Icon Animation --- */
#settings-icon {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    /* Animation for mobile/load */
    animation: spin-once 1s cubic-bezier(0.4, 0, 0.2, 1) 0.5s; 
}

/* Hover effect for desktop */
@media (hover: hover) {
    #settings-btn:hover #settings-icon {
        transform: rotate(180deg);
    }
}

@keyframes spin-once {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* --- Puzzle Selection Modal --- */
.puzzle-option {
    /* Inherits background from .stat-card */
    padding: 1rem;
    border-radius: 0.5rem;
    text-align: center;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
}


.puzzle-option.active {
    background-color: var(--accent-color) !important;
    color: white;
    box-shadow: 0 0 0 2px white;
}

#puzzle-modal.visible {
    display: flex;
}

#puzzle-modal-content {
    animation-duration: 0.5s;
    animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
    animation-fill-mode: forwards;
}

#puzzle-modal.visible #puzzle-modal-content {
    animation-name: succession-in;
}

#puzzle-modal.closing #puzzle-modal-content {
    animation-name: succession-out;
}

@keyframes succession-out {
    from {
        opacity: 1;
        transform: scale(1);
        filter: blur(0);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
        filter: blur(8px);
    }
}

/* --- New Puzzle Selector Style --- */
#current-puzzle-display {
    color: var(--accent-color);
    text-shadow: 0 0 8px var(--accent-color);
    transition: text-shadow 0.3s ease;
}


.timer-ready { color: #22c55e; } /* green-500 */
.timer-holding { color: #ef4444; } /* red-500 */

/* --- Layout Styles --- */
.layout-floating body {
    position: relative;
}


.layout-floating aside {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    width: 350px;
    max-width: 90vw;
    height: auto; /* This is the key change */
    border-radius: 1.5rem;
    backdrop-filter: blur(16px);
    background-color: rgba(31, 41, 55, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 40;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    /* Remove the flex properties that cause the empty space */
    display: block;
}

.layout-floating #session-aside-spacer {
    display: none;
}

.layout-floating #solves-list {
    display: none;
}

.layout-floating main {
    width: 100%;
    z-index: 1; /* Ensure main timer area is clickable */
}

.layout-docked #session-aside-spacer {
    display: block; /* Ensure it's visible in docked mode */
}

.layout-floating #session-aside-spacer {
    display: none; /* Hide it in floating mode */
}

#solves-list-container {
    height: 200px; /* Default height */
}

.layout-floating #solves-list-container {
    position: fixed;
    top: calc(1rem + 350px); /* Position below the stats panel */
    right: 1rem;
    width: 350px;
    max-width: 90vw;
    height: calc(100vh - 2rem - 350px); /* Fill remaining height */
    border-radius: 1.5rem;
    backdrop-filter: blur(16px);
    background-color: rgba(31, 41, 55, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 40;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    padding: 1rem;
}


/* Ensure the ring color uses the accent variable */
.layout-btn.ring-sky-500 {
    --tw-ring-color: var(--accent-color);
}

/* --- Custom Backgrounds --- */
.bg-default {
    background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
}

.bg-gradient1 {
    background: linear-gradient(135deg, #581c87 0%, #1e3a8a 50%, #0f172a 100%);
}

.bg-gradient2 {
    background: linear-gradient(135deg, #064e3b 0%, #0f766e 50%, #134e4a 100%);
}

.bg-gradient3 {
    background: linear-gradient(135deg, #9a3412 0%, #dc2626 50%, #7c2d12 100%);
}

.bg-particles {
    background: linear-gradient(135deg, #312e81 0%, #581c87 100%);
    position: relative;
}

.bg-particles::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(255,255,255,0.3), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.2), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.3), transparent),
        radial-gradient(2px 2px at 160px 30px, rgba(255,255,255,0.2), transparent);
    background-repeat: repeat;
    background-size: 200px 100px;
    animation: particles 20s linear infinite;
    pointer-events: none;
}

@keyframes particles {
    0% { transform: translateY(0px); }
    100% { transform: translateY(-100px); }
}

.bg-minimal {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.bg-custom {
    /* Custom background will be applied via JavaScript */
    background-color: #111827; /* fallback */
}

/* Background button selection styles */
.background-btn.ring-sky-500 {
    --tw-ring-color: var(--accent-color);
}

/* Custom background overlay for opacity control */
.custom-bg-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: none !important;
    z-index: -1 !important;
}
.timer-inspecting { color: #f97316; } /* orange-500 */

/* Accessibility: Reduce Motion */
body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;

/* --- Beta Badge --- */
.beta-badge {
    background-color: var(--accent-color);
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px; /* pill shape */
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Custom Alerts --- */
.alert {
    display: flex;
    align-items: center;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0.75rem;
    border: 1px solid transparent;
    font-size: 0.875rem;
    opacity: 0;
    transform: translateX(100%);
    animation: slideIn 0.5s forwards;
}

.alert.fade-out {
    animation: slideOut 0.5s forwards;
}

.alert-success {
    color: #a7f3d0; /* emerald-200 */
    background-color: rgba(5, 150, 105, 0.3); /* emerald-600 with opacity */
    border-color: rgba(110, 231, 183, 0.3); /* emerald-300 with opacity */
}

.alert svg {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.75rem;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}
}

/* Accessibility: High Contrast */
body.high-contrast {
    --bg-primary: #000000;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --border-color: #666666;
}

body.high-contrast.light-mode {
    --bg-primary: #ffffff;
    --bg-secondary: #f0f0f0;
    --bg-tertiary: #e0e0e0;
    --text-primary: #000000;
    --text-secondary: #333333;
    --border-color: #999999;
}

.penalty-btn.active-plus-2 { background-color: #ca8a04; color: white; } /* yellow-600 */
.penalty-btn.active-dnf { background-color: #dc2626; color: white; } /* red-600 */
.penalty-btn:disabled {
    background-color: #bac1cb; /* gray-600 */
    opacity: 0.5;
    cursor: not-allowed;
}

#puzzle-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23ffffff%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.4-5.4-12.8z%22/%3E%3C/svg%3E');
  background-repeat: no-repeat;
  background-position: right 0.7em top 50%, 0 0;
  background-size: 0.65em auto, 100%;
}
/* Immersive Timer Mode - Sidebar Auto-Hide */
.timer-active .sidebar {
    transform: translateX(100%);
    transition: transform 0.3s ease-out;
}

.timer-active .main-timer-area {
    margin-right: 0;
    transition: margin-right 0.3s ease-out;
}

/* Mobile Touch Controls */
@media (max-width: 768px) {
    .main-timer-area {
        cursor: pointer;
    }
    
    .timer-ready .main-timer-area {
        background-color: rgba(34, 197, 94, 0.1);
        border: 2px solid rgba(34, 197, 94, 0.3);
        border-radius: 1rem;
    }
    
    .timer-holding .main-timer-area {
        background-color: rgba(239, 68, 68, 0.1);
        border: 2px solid rgba(239, 68, 68, 0.3);
        border-radius: 1rem;
    }
}
