:root {
    --font-stack: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Helvetica Neue', system-ui, sans-serif;
    --transition-speed: 0.3s;
    --button-radius: 12px;
}

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

body {
    font-family: var(--font-stack);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #90ccf4;
    transition: background var(--transition-speed) ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    margin: 0;
    overflow: hidden;
}

/* Theme Classes */
body.biscay {
    background: linear-gradient(135deg, #2e3c56 0%, #364564 100%);
}

body.sky-blue {
    background: linear-gradient(135deg, #90ccf4 0%, #a8d5f7 100%);
}

body.tangerine {
    background: linear-gradient(135deg, #f4976c 0%, #f7a882 100%);
}

body.gin {
    background: #d7e8ba;
}

body.slate {
    background: #64748b;
}

body.charcoal {
    background: #1e293b;
}

body.frost {
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
}

.container {
    text-align: center;
    color: white;
    width: 100%;
    padding-top: 30vh;
    min-height: 100vh;
}

body.gin .container,
body.frost .container {
    color: #1e293b;
}

.stopwatch-display {
    margin-bottom: 80px;
}

.lap-time-container {
    display: inline-flex;
    align-items: baseline;
    margin-bottom: 20px;
}

.lap-time {
    font-size: 12rem;
    font-weight: 200;
    line-height: 1;
    letter-spacing: -0.02em;
    padding-left: 10px;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    transform: translateZ(0);
    backface-visibility: hidden;
}

.lap-ms {
    font-size: 6rem;
    font-weight: 200;
    opacity: 0.6;
    margin-left: 8px;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    transform: translateZ(0);
    backface-visibility: hidden;
}

.total-time {
    font-size: 1.8rem;
    font-weight: 200;
    opacity: 0.7;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    transform: translateZ(0);
    backface-visibility: hidden;
}

.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 80px;
}

button {
    font-family: var(--font-stack);
    font-weight: 500;
    font-size: 1rem;
    padding: 14px 24px;
    border: none;
    border-radius: var(--button-radius);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    backdrop-filter: blur(10px);
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    outline: none;
    position: relative;
    box-shadow: 
        0 4px 6px rgba(0, 0, 0, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transform: translateY(0) scale(1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 110px;
    justify-content: center;
}

button .icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

button:focus-visible {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

body.gin button,
body.frost button {
    background: rgba(0, 0, 0, 0.1);
    color: #1e293b;
    box-shadow: 
        0 4px 6px rgba(0, 0, 0, 0.08),
        0 2px 4px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

body.gin button:focus-visible,
body.frost button:focus-visible {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.2);
}

button:hover {
    background: rgba(255, 255, 255, 0.3);
    box-shadow: 
        0 6px 10px rgba(0, 0, 0, 0.12),
        0 3px 5px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

body.gin button:hover,
body.frost button:hover {
    background: rgba(0, 0, 0, 0.15);
    box-shadow: 
        0 6px 10px rgba(0, 0, 0, 0.1),
        0 3px 5px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

button:active,
button.pressed {
    transform: translateY(1px) scale(0.98) !important;
    background: rgba(255, 255, 255, 0.4) !important;
    box-shadow: 
        0 1px 2px rgba(0, 0, 0, 0.1),
        inset 0 2px 4px rgba(0, 0, 0, 0.1),
        inset 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

body.gin button.pressed,
body.frost button.pressed,
body.gin button:active,
body.frost button:active {
    background: rgba(0, 0, 0, 0.2) !important;
    box-shadow: 
        0 1px 2px rgba(0, 0, 0, 0.08),
        inset 0 2px 4px rgba(0, 0, 0, 0.08),
        inset 0 1px 2px rgba(0, 0, 0, 0.04) !important;
}


.splits-section {
    display: none;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
    max-height: 30vh;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
    width: 100%;
    justify-content: center;
}

.splits-section::-webkit-scrollbar {
    width: 6px;
}

.splits-section::-webkit-scrollbar-track {
    background: transparent;
}

.splits-section::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

body.gin .splits-section::-webkit-scrollbar-thumb,
body.frost .splits-section::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
}

.splits-section.visible {
    display: flex;
    opacity: 1;
}

.splits-table {
    width: 750px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 300;
}

body.gin .splits-table,
body.frost .splits-table {
    color: rgba(0, 0, 0, 0.6);
}

.splits-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
    text-align: center;
}

body.gin .splits-header,
body.frost .splits-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.split-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    text-align: center;
}

body.gin .split-row,
body.frost .split-row {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.help-icon {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    font-size: 1.2rem;
    color: white;
    will-change: transform;
}

body.gin .help-icon,
body.frost .help-icon {
    background: rgba(0, 0, 0, 0.1);
    color: #1e293b;
}

.help-icon:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

body.gin .help-icon:hover,
body.frost .help-icon:hover {
    background: rgba(0, 0, 0, 0.15);
}

.theme-pill {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 20px;
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.gin .theme-pill,
body.frost .theme-pill {
    background: rgba(0, 0, 0, 0.1);
    color: #1e293b;
}

.theme-pill.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-speed) ease, visibility var(--transition-speed) ease;
    z-index: 1000;
}

.modal-backdrop.visible {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: fixed;
    top: 0;
    right: -320px;
    height: 100%;
    width: 380px;
    max-width: 90vw;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
    transition: right var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    padding: 40px 50px;
    overflow-y: auto;
    z-index: 1001;
    border-radius: 20px 0 0 20px;
}

body.gin .modal,
body.frost .modal {
    background: rgba(255, 255, 255, 0.95);
}

body.biscay .modal,
body.charcoal .modal {
    background: rgba(30, 30, 30, 0.85);
}

body.slate .modal {
    background: rgba(50, 50, 60, 0.85);
}

.modal-backdrop.visible .modal {
    right: 0;
}

.modal h2 {
    color: rgba(0, 0, 0, 0.8);
    margin-bottom: 45px;
    font-weight: 500;
    font-size: 1.3rem;
    letter-spacing: 0.02em;
}

body.biscay .modal h2,
body.charcoal .modal h2,
body.slate .modal h2 {
    color: rgba(255, 255, 255, 0.9);
}

.shortcuts {
    text-align: left;
}

.shortcut {
    display: grid;
    grid-template-columns: 90px auto;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    font-size: 0.95rem;
    color: rgba(0, 0, 0, 0.6);
}

.key-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.key-wrapper.key-group {
    gap: 4px;
}

.key-wrapper.key-wide-wrapper {
    justify-content: center;
}

body.biscay .shortcut,
body.charcoal .shortcut,
body.slate .shortcut {
    color: rgba(255, 255, 255, 0.7);
}

.key {
    background: rgba(0, 0, 0, 0.08);
    padding: 8px 0;
    border-radius: 8px;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.8);
    font-size: 0.85rem;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.06),
        0 1px 2px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.key.wide {
    width: 76px;
}

.key-group .key {
    width: 36px;
}

body.biscay .key,
body.charcoal .key,
body.slate .key {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.1),
        0 1px 2px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body.biscay .key-group .key,
body.charcoal .key-group .key,
body.slate .key-group .key {
    background: rgba(255, 255, 255, 0.1);
}

.close-modal {
    position: absolute !important;
    top: 37px;
    right: 40px;
    background: none;
    border: none;
    color: rgba(0, 0, 0, 0.4);
    cursor: pointer;
    padding: 0;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    max-width: 32px !important;
    max-height: 32px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

body.biscay .close-modal,
body.charcoal .close-modal,
body.slate .close-modal {
    color: rgba(255, 255, 255, 0.5);
}

.close-modal:hover {
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.05);
}

body.biscay .close-modal:hover,
body.charcoal .close-modal:hover,
body.slate .close-modal:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Responsive scaling */
@media (min-width: 1920px) {
    .lap-time {
        font-size: 14rem;
    }
    .lap-ms {
        font-size: 7rem;
    }
    .total-time {
        font-size: 2rem;
    }
}

@media (min-width: 2560px) {
    .lap-time {
        font-size: 16rem;
    }
    .lap-ms {
        font-size: 8rem;
    }
    .total-time {
        font-size: 2.2rem;
    }
}

@media (min-width: 3440px) {
    .lap-time {
        font-size: 18rem;
    }
    .lap-ms {
        font-size: 9rem;
    }
    .total-time {
        font-size: 2.4rem;
    }
}

@media (max-width: 768px) {
    .lap-time {
        font-size: 7rem;
    }
    .lap-ms {
        font-size: 3.5rem;
    }
    .total-time {
        font-size: 1.4rem;
    }
}

@media (max-width: 480px) {
    .lap-time {
        font-size: 5rem;
    }
    .lap-ms {
        font-size: 2.5rem;
    }
    .total-time {
        font-size: 1.2rem;
    }

    button {
        padding: 12px 20px;
        font-size: 0.9rem;
    }

    .controls {
        flex-wrap: wrap;
    }
}