@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;800&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
    --primary-gradient: linear-gradient(135deg, #10b981 0%, #3b82f6 100%);
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --card-bg: rgba(30, 41, 59, 0.7);
    --panel-bg: rgba(22, 32, 50, 0.7);
    --border-color: rgba(255, 255, 255, 0.06);
    --glass-blur: 20px;
    --accent: #10b981;
    --primary-color: #3b82f6;
    --cyan: #06b6d4;
    --input-bg: rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
}

.bg-blobs {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    top: 0;
    left: 0;
}

.blob {
    position: absolute;
    width: 600px;
    height: 600px;
    background: var(--primary-gradient);
    filter: blur(80px);
    border-radius: 50%;
    opacity: 0.12;
}

.blob-1 {
    top: -10%;
    right: -10%;
}

.blob-2 {
    bottom: -10%;
    left: -10%;
}

.calculator-card {
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 900px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 30px;
}

header {
    text-align: center;
}

header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--cyan);
    margin-bottom: 5px;
}

header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.panel-row {
    display: flex;
    gap: 40px;
    align-items: flex-start;
}

.panel-left {
    flex: 1.2;
    display: flex;
    flex-direction: column;
    gap: 30px;
    align-items: center;
}

/* Stopwatch Display */
.stopwatch-display-container {
    background: var(--panel-bg);
    padding: 40px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
}

.timer-main {
    font-family: 'JetBrains Mono', monospace;
    font-size: 4.5rem;
    font-weight: 700;
    color: white;
    line-height: 1;
    letter-spacing: -2px;
}

.timer-ms {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2rem;
    color: var(--accent);
    font-weight: 500;
    margin-top: 5px;
}

.main-controls {
    display: flex;
    gap: 20px;
    width: 100%;
    justify-content: center;
}

.control-btn,
.primary-btn,
.secondary-btn {
    border: none;
    border-radius: 14px;
    padding: 16px 24px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.primary-btn {
    background: var(--primary-gradient);
    color: white;
    width: 150px;
    box-shadow: 0 10px 20px rgba(16, 185, 129, 0.2);
}

.primary-btn.pulse {
    animation: startPulse 2s infinite;
}

.primary-btn.running {
    background: linear-gradient(135deg, #f43f5e 0%, #fb7185 100%);
    box-shadow: 0 10px 20px rgba(244, 63, 94, 0.2);
}

.control-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 110px;
}

.control-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.control-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.status-indicator {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 700;
}

/* Laps History Panel */
.output-panel {
    flex: 1;
    position: sticky;
    top: 30px;
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-self: flex-start;
    min-width: 320px;
}

.preview-header {
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.preview-header i {
    color: var(--accent);
}

.laps-container {
    max-height: 400px;
    overflow-y: auto;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
}

.laps-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.laps-table th {
    text-align: left;
    padding: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
}

.laps-table td {
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-family: 'JetBrains Mono', monospace;
}

.laps-table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.01);
}

.laps-table tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

.no-laps-msg {
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

.secondary-btn {
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid var(--cyan);
    color: var(--cyan);
}

@keyframes startPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@media (max-width: 900px) {
    .panel-row {
        flex-direction: column;
    }

    .output-panel {
        width: 100%;
        min-width: unset;
        position: static;
    }

    .timer-main {
        font-size: 3.5rem;
    }
}

@media (max-width: 480px) {
    .timer-main {
        font-size: 2.8rem;
    }

    .main-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .primary-btn {
        width: 100%;
    }

    .control-btn {
        width: 100%;
    }
}