/* Cream Palette & Modern Minimalist Design */
:root {
    --bg-color: #FAFAF7;
    /* Light cream/off-white background */
    --surface-color: #F1EFE7;
    /* Slightly darker cream for cards/panels */
    --surface-hover: #E8E5DA;
    --text-primary: #2C2A26;
    /* Deep brown/black for contrast */
    --text-secondary: #7A7568;
    /* Soft readable secondary color */

    /* Subtle Accent */
    --accent-color: #C1A57B;
    --accent-hover: #B09264;

    /* Timer Event Colors */
    --timer-holding: #E07A5F;
    /* Refined soft red */
    --timer-ready: #81B29A;
    /* Refined sage green */

    /* WCA Inspection Countdown Colors */
    --inspection-normal: #C1A57B;
    --inspection-7s: #E9C46A;
    /* Warning Yellow */
    --inspection-3s: #E07A5F;
    /* Danger Red */

    --border-color: #E6E2D8;

    /* Soft shadows */
    --shadow-sm: 0 4px 12px rgba(44, 42, 38, 0.03);
    --shadow-md: 0 8px 24px rgba(44, 42, 38, 0.05);

    --radius-md: 12px;
    --radius-lg: 20px;

    --transition-fast: 0.15s ease;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

/* App Layout */
.app-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 2.5rem;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.logo {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

/* Buttons */
.btn {
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    padding: 0.5rem 1.2rem;
    border: none;
    background: transparent;
}

.btn-outline {
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    background-color: transparent;
}

.btn-outline:hover {
    background-color: var(--surface-color);
    border-color: var(--accent-color);
    box-shadow: var(--shadow-sm);
}

.btn-ghost {
    color: var(--text-secondary);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background-color: var(--surface-hover);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem;
    color: var(--text-secondary);
    border-radius: 50%;
}

.btn-icon:hover {
    color: var(--text-primary);
    background-color: var(--surface-hover);
}

.hidden {
    display: none !important;
}

/* Main Workspace */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem 0;
}

/* Session Header */
.session-header {
    text-align: center;
    margin-bottom: 0.5rem;
}

.session-title-input {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
    padding: 0.25rem 1.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
    display: inline-block;
}

.session-title-input:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.session-title-input:focus {
    outline: none;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    cursor: text;
    color: var(--text-primary);
}

/* Scramble */
.scramble-container {
    text-align: center;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.scramble-text {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--text-primary);
    max-width: 900px;
    letter-spacing: 1px;
    line-height: 1.5;
}

/* Timer Display */
.timer-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    cursor: pointer;
    /* Suggests touchability */
    transition: background-color 0.4s ease;
    border-radius: var(--radius-lg);
    margin: 0 1rem;
}

.timer-container.bg-warning-7s {
    background-color: var(--inspection-7s);
}

.timer-container.bg-warning-3s {
    background-color: var(--inspection-3s);
}

.timer-text {
    font-family: 'Roboto Mono', monospace;
    font-size: 8rem;
    font-weight: 400;
    letter-spacing: -4px;
    color: var(--text-primary);
    transition: color 0.1s ease;
    user-select: none;
    font-variant-numeric: tabular-nums;
}

/* Dynamic State Classes for JS */
.timer-text.holding {
    color: var(--timer-holding);
}

.timer-text.ready {
    color: var(--timer-ready);
}

/* Countdown colors */
.timer-text.inspection-active {
    color: var(--text-primary);
    /* Keeps it dark since background changes */
}

/* Toggle Switch Setup */
.timer-controls {
    margin-top: 1.5rem;
}

.toggle-switch {
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 0.75rem;
    user-select: none;
}

.toggle-switch input {
    display: none;
}

.slider {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: var(--border-color);
    border-radius: 24px;
    transition: var(--transition-smooth);
}

.slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: var(--transition-smooth);
    box-shadow: 0 2px 4px rgba(44, 42, 38, 0.1);
}

input:checked+.slider {
    background-color: var(--accent-color);
}

input:checked+.slider::before {
    transform: translateX(20px);
}

.label-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* PLL Section */
.pll-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
    padding: 0 1rem;
}

.pll-main-btn {
    padding: 0.75rem 2.5rem;
    font-size: 1.15rem;
    font-weight: 600;
    border-radius: var(--radius-lg);
    letter-spacing: 0.5px;
}

.pll-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    max-width: 600px;
}

.pll-item-btn {
    padding: 0.5rem 0.8rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.pll-algo {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-primary);
    background-color: var(--surface-color);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    text-align: center;
    letter-spacing: 1px;
    margin-top: 0.5rem;
}

/* Stats and History Dashboard */
.dashboard {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: auto;
}

.glass-panel {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow-sm);
}

.glass-panel h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.75rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* History List */
.history-list {
    list-style: none;
    max-height: 160px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-right: 0.75rem;
}

/* Custom Scrollbar */
.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 10px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    font-family: 'Roboto Mono', monospace;
    font-size: 1.1rem;
}

.history-item:last-child {
    border-bottom: none;
}

.history-empty {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.solve-index {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.solve-time {
    font-weight: 500;
    color: var(--text-primary);
}

/* Minimalist Responsive adjustments */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }

    .timer-text {
        font-size: 5.5rem;
    }

    .scramble-text {
        font-size: 1.1rem;
    }

    .dashboard {
        grid-template-columns: 1fr;
        gap: 1rem;
        overflow-y: auto;
    }

    .glass-panel {
        padding: 1rem 1.5rem;
    }

    .main-content {
        padding: 1rem 0;
    }
}