/* --- Premium Re-design Design Tokens & Variables for Stopwatch --- */
:root {
    --font-display: 'Outfit', Arial, sans-serif;
    --font-sans: 'Outfit', Arial, sans-serif;
    --font-mono: 'Inconsolata', monospace;
    
    /* Curated harmonious color palettes (Tailored HSL) */
    --brand-primary: hsl(340, 71%, 54%); /* vibrant pink */
    --brand-accent: hsl(190, 90%, 45%); /* glowing cyan */
    --brand-info: hsl(210, 90%, 50%); /* bright blue */
    --brand-success: hsl(150, 70%, 45%); /* emerald green */
    --brand-danger: hsl(350, 80%, 50%); /* red-pink */
    
    --bg-color: #f8fafc;
    --text-color: hsl(222, 47%, 11%);
    --text-muted: hsl(218, 11%, 47%);
    --panel-bg: #ffffff;
    --border-color: #e2e8f0;
    --glass-border: 1px solid rgba(255, 255, 255, 0.4);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
    --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Base resets & Fonts overrides */
body, p, span, a, h1, h2, h3, h4, h5, h6, input, button, select, textarea, label {
    font-family: var(--font-sans) !important;
}

#fh5co-stopwatch {
    background-color: var(--bg-color);
    padding: 60px 0;
}

/* --- Hero Section Redesign --- */
.hero-section {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    position: relative;
    padding: 60px 0;
    text-align: center;
    color: var(--text-color);
    overflow: hidden;
    border-bottom: 1px solid #e2e8f0;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: radial-gradient(hsla(220, 20%, 80%, 0.4) 1px, transparent 1px);
    background-size: 24px 24px;
    pointer-events: none;
}

.hero-section__container {
    position: relative;
    z-index: 2;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

.hero-section h1 {
    font-size: 42px;
    font-weight: 800;
    margin: 0 0 12px 0;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, hsl(222, 47%, 11%) 40%, var(--brand-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-section p {
    font-size: 16px;
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0;
    font-weight: 400;
}

/* --- Mode Switch --- */
.mode-switch-container {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
}

.mode-switch {
    display: inline-flex;
    background: #ffffff;
    padding: 6px;
    border-radius: 30px;
    border: 1px solid #cbd5e1;
    box-shadow: var(--shadow-sm);
    align-items: center;
    gap: 4px;
}

.mode-btn {
    padding: 8px 24px;
    border-radius: 20px;
    border: none;
    background: transparent;
    color: var(--text-color);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    opacity: 0.65;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mode-btn:hover {
    opacity: 1;
    color: var(--brand-primary);
}

.mode-btn.active {
    background: var(--brand-primary);
    color: white !important;
    opacity: 1;
    box-shadow: 0 4px 12px hsla(340, 71%, 54%, 0.2);
}

/* --- Main Grid Layout --- */
.main-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    max-width: 1100px;
    margin: 0 auto 50px auto;
    align-items: start;
}

/* Left Column: Timer & Controls */
.timer-section {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 40px 30px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Event Title Input */
.event-section {
    margin-bottom: 25px;
    width: 100%;
    max-width: 320px;
    text-align: center;
}

.event-input {
    background: transparent;
    border: none;
    border-bottom: 2px solid #cbd5e1;
    color: var(--text-color);
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    width: 100%;
    padding: 6px;
    transition: var(--transition-smooth);
}

.event-input:focus {
    outline: none;
    border-bottom-color: var(--brand-primary);
}

.event-input::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

/* Focus Presets */
.focus-presets {
    display: none;
    gap: 8px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    justify-content: center;
}

body.focus-mode .focus-presets {
    display: flex;
}

.preset-btn {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: var(--text-color);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.preset-btn:hover {
    background: var(--brand-accent);
    color: #ffffff;
    border-color: var(--brand-accent);
    box-shadow: 0 4px 10px hsla(190, 90%, 45%, 0.2);
}

/* Timer Wrapper & Clock */
.timer-wrapper {
    position: relative;
    margin: 10px 0 35px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 280px;
    max-height: 280px;
}

.display {
    font-family: var(--font-mono) !important;
    font-size: 3.4rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    color: hsl(222, 47%, 11%);
    z-index: 2;
    text-align: center;
}

.milliseconds {
    font-family: var(--font-mono) !important;
    font-size: 0.5em;
    opacity: 0.7;
    color: var(--brand-primary);
    display: inline-block;
    width: 2ch;
    margin-left: 2px;
}

/* Progress Ring */
.progress-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s;
}

body.focus-mode .progress-ring {
    opacity: 1;
}

.progress-ring circle {
    fill: transparent;
    stroke-width: 6;
    stroke-linecap: round;
    transform-origin: center;
}

.progress-ring-bg { 
    stroke: #f1f5f9; 
}
.progress-ring-fill {
    stroke: var(--brand-accent);
    transition: stroke-dashoffset 0.1s linear;
}

/* Controls buttons */
.controls {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    align-items: center;
    justify-content: center;
}

.btn-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-circle:active { 
    transform: scale(0.95); 
}
.btn-circle:disabled { 
    opacity: 0.4; 
    cursor: not-allowed; 
    transform: none !important; 
    box-shadow: none !important;
}

.btn-main {
    width: 76px;
    height: 76px;
}

.btn-start { 
    background: var(--brand-success); 
    color: white !important; 
    box-shadow: 0 4px 14px hsla(150, 70%, 45%, 0.25);
}
.btn-start:hover:not(:disabled) {
    background: hsl(150, 75%, 38%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px hsla(150, 70%, 45%, 0.4);
}

.btn-stop { 
    background: var(--brand-danger); 
    color: white !important; 
    box-shadow: 0 4px 14px hsla(350, 80%, 50%, 0.25);
}
.btn-stop:hover:not(:disabled) {
    background: hsl(350, 85%, 44%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px hsla(350, 80%, 50%, 0.4);
}

.btn-reset, .btn-lap { 
    background: #ffffff; 
    color: var(--text-color); 
    border: 1px solid #cbd5e1; 
}
.btn-reset:hover:not(:disabled), .btn-lap:hover:not(:disabled) {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    background: hsla(340, 71%, 54%, 0.03);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Utility bar */
.utility-bar {
    margin-top: 10px;
    display: flex;
    gap: 15px;
    justify-content: center;
    width: 100%;
    border-top: 1px solid #f1f5f9;
    padding-top: 20px;
}

.util-btn {
    background: transparent;
    border: none;
    color: var(--text-color);
    opacity: 0.6;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-smooth);
    padding: 8px 12px;
    border-radius: 8px;
}

.util-btn:hover { 
    opacity: 1; 
    background: #f1f5f9;
    color: var(--brand-primary);
}

/* Right Column: Lap Table */
.laps-section {
    width: 100%;
}

body.focus-mode .laps-section {
    display: none;
}
body.focus-mode .main-container {
    grid-template-columns: 1fr;
    max-width: 550px;
}

.lap-container {
    width: 100%;
    background: #ffffff;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 480px;
}

.lap-header {
    display: grid;
    grid-template-columns: 0.8fr 1.5fr 1.5fr;
    padding: 16px 24px;
    background: #f8fafc;
    font-weight: 700;
    font-size: 14px;
    color: hsl(222, 47%, 15%);
    border-bottom: 2px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 5;
}

.lap-list {
    overflow-y: auto;
    flex: 1;
}

.lap-row {
    display: grid;
    grid-template-columns: 0.8fr 1.5fr 1.5fr;
    padding: 14px 24px;
    border-bottom: 1px solid #f1f5f9;
    font-family: var(--font-mono) !important;
    font-size: 14px;
    color: var(--text-color);
    align-items: center;
    transition: var(--transition-smooth);
    animation: slideIn 0.2s ease-out;
}

.lap-row:hover {
    background-color: #f8fafc;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.lap-row.fastest { 
    color: var(--brand-success); 
    background: hsla(150, 70%, 45%, 0.05); 
    font-weight: 700;
}
.lap-row.slowest { 
    color: var(--brand-danger); 
    background: hsla(350, 80%, 50%, 0.05); 
    font-weight: 700;
}

/* Toast Messages */
.toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: hsl(222, 47%, 11%);
    color: white;
    padding: 12px 28px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

.toast.show { 
    transform: translateX(-50%) translateY(0); 
    opacity: 1; 
}

/* --- Bottom Info Section --- */
.info-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

.description-section, .shortcuts-section {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 35px;
    box-shadow: var(--shadow-sm);
    height: 100%;
}

.description-section h3, .shortcuts-section h3 {
    font-size: 22px;
    font-weight: 700;
    color: hsl(222, 47%, 11%);
    margin-top: 0;
    margin-bottom: 18px;
    border-bottom: 2px solid hsl(210, 40%, 96%);
    padding-bottom: 8px;
}

.description-section p {
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-color);
    margin-bottom: 14px;
}
.description-section p:last-child {
    margin-bottom: 0;
}

.shortcuts-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.shortcuts-list li {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    color: var(--text-color);
}

kbd {
    background-color: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
    color: hsl(222, 47%, 11%);
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    padding: 4px 8px;
    white-space: nowrap;
    font-family: var(--font-mono) !important;
}

/* --- Detailed Human SEO Block --- */
.seo-section-card {
    margin-top: 50px;
    padding: 40px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
}

.seo-section-card h2 {
    font-size: 24px;
    font-weight: 800;
    color: hsl(222, 47%, 11%);
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid hsl(210, 40%, 96%);
    padding-bottom: 10px;
}

.seo-section-card h3 {
    font-size: 18px;
    font-weight: 700;
    color: hsl(222, 47%, 11%);
    margin-top: 28px;
    margin-bottom: 12px;
}

.seo-section-card p {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-color);
    margin-bottom: 16px;
}

.seo-section-card p:last-child {
    margin-bottom: 0;
}

/* --- Fullscreen Mode Styles --- */
body.fullscreen .site-header,
body.fullscreen .breadcrumbs-wrapper,
body.fullscreen .hero-section,
body.fullscreen .mode-switch-container,
body.fullscreen .event-section,
body.fullscreen .focus-presets,
body.fullscreen .laps-section,
body.fullscreen .utility-bar,
body.fullscreen .info-container,
body.fullscreen .seo-section-card,
body.fullscreen footer {
    display: none !important;
}

body.fullscreen {
    background-color: #0f172a; /* Sleek dark space background in fullscreen */
}

body.fullscreen #fh5co-stopwatch {
    padding: 0;
    background: transparent;
}

body.fullscreen .main-container {
    grid-template-columns: 1fr;
    height: 100vh;
    padding: 0;
    max-width: none;
    align-items: center;
    justify-content: center;
    margin: 0;
}

body.fullscreen .timer-section {
    height: 100vh;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    justify-content: center;
}

body.fullscreen .timer-wrapper {
    max-width: 450px;
    max-height: 450px;
    width: 80vw;
    height: 80vw;
}

body.fullscreen .display {
    font-size: 18vw;
    color: #ffffff;
    text-shadow: 0 0 30px rgba(6, 182, 212, 0.4);
}

body.fullscreen .milliseconds {
    color: var(--brand-accent);
}

body.fullscreen .controls {
    position: fixed;
    bottom: 50px;
    z-index: 10;
    transition: opacity 0.5s ease;
}

body.fullscreen.inactive .controls {
    opacity: 0;
    pointer-events: none;
}

/* --- Responsive Adjustments --- */
@media (max-width: 900px) {
    .main-container {
        grid-template-columns: 1fr;
        padding: 0 20px;
        gap: 30px;
    }
    .info-container {
        grid-template-columns: 1fr;
        padding: 0 20px;
        gap: 30px;
    }
    .lap-container {
        height: 380px;
    }
}

@media (max-width: 500px) {
    .display {
        font-size: 2.8rem;
    }
    .hero-section h1 {
        font-size: 32px;
    }
    .seo-section-card {
        padding: 25px;
    }
}
