/* --- CSS VARIABLES & BASE STYLES --- */
:root {
    --bg-color: #f4f7f6;
    --primary: #007bff;
    --success: #28a745;
    --dark: #333;
    --card-bg: #fff;
}

* { 
    box-sizing: border-box; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
}

body { 
    margin: 0; 
    padding: 0; 
    background: var(--bg-color); 
    color: var(--dark); 
}

/* --- SCREEN MANAGEMENT --- */
.screen { display: none; padding: 20px; }
.screen.active { display: block; }

/* --- LOBBY STYLES --- */
#lobby-screen { display: flex; justify-content: center; align-items: center; min-height: 100vh; }
.card { background: var(--card-bg); padding: 30px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); width: 100%; max-width: 400px; text-align: center; }
.divider { margin: 20px 0; color: #888; font-size: 14px; font-weight: bold; }
.error { color: #dc3545; margin-top: 10px; font-weight: bold; }

/* --- INPUTS & GLOBAL BUTTONS --- */
input { width: 100%; padding: 15px; border: 2px solid #ddd; border-radius: 8px; font-size: 18px; margin-bottom: 10px; text-align: center; }
button { width: 100%; padding: 15px; border: none; border-radius: 8px; font-size: 18px; font-weight: bold; cursor: pointer; color: white; transition: 0.2s; }
button:hover { opacity: 0.9; }

.primary-btn { background: var(--primary); }
.secondary-btn { background: #6c757d; }
.success-btn { background: var(--success); }
.danger-btn { background: #dc3545; color: white; border: none; cursor: pointer; border-radius: 5px; }
.badge { background: #e9ecef; padding: 5px 10px; border-radius: 20px; font-size: 14px; }

/* --- RESPONSIVE HEADER & CONTROLS --- */
.header { 
    background: var(--card-bg); 
    padding: 15px 20px; 
    position: sticky; 
    top: 0; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.1); 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    z-index: 100; 
    flex-wrap: wrap; 
    gap: 10px;
}

#global-timer { font-size: 32px; font-family: monospace; font-weight: bold; }

.header-controls { display: flex; gap: 8px; }
.header-controls button { padding: 8px 15px; font-size: 16px; width: auto; }

@media (max-width: 500px) {
    .header {
        flex-direction: column; 
        align-items: stretch;
        text-align: center;
        padding: 10px;
    }
    #global-timer {
        font-size: 40px; 
        margin: 5px 0;
    }
    .header-controls {
        justify-content: center;
    }
    .header-controls button {
        flex: 1; 
        padding: 12px 10px;
    }
}

/* --- 2-TAP DELETE VISUAL CUE --- */
.confirming {
    background-color: #8b0000 !important; /* Dark Red */
    transform: scale(1.05);
    transition: all 0.2s;
    font-weight: bold;
    color: white !important;
}

/* --- COMPACT & STICKY TABLE STYLES --- */
.table-wrapper {
    background: white; 
    padding: 10px; 
    border-radius: 8px; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); 
    margin-bottom: 15px;
}

.table-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.table-header-row h2 { margin: 0; font-size: 16px; color: var(--primary); }

.interval-input { width: 45px !important; padding: 2px; font-size: 12px; display: inline-block !important; text-align: center; }

.table-container { overflow-x: auto; max-width: 100vw; position: relative; }
.swim-table { width: auto; min-width: 100%; border-collapse: collapse; text-align: center; }
.swim-table th, .swim-table td { border: 1px solid #ddd; padding: 4px; vertical-align: middle; font-size: 12px; }
.swim-table th { background-color: #f4f7f6; color: #333; }

/* STICKY COLUMN MAGIC */
.sticky-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background-color: #fff;
    box-shadow: 2px 0 4px rgba(0,0,0,0.1);
}
.swim-table th.sticky-col {
    background-color: #f4f7f6;
    z-index: 3; 
}

.name-input { width: 85px !important; padding: 4px; border: 1px solid transparent; background: transparent; font-size: 12px; font-weight: bold; }
.name-input:focus { border: 1px solid var(--primary); background: white; }

.lap-cell { min-width: 50px; }
.true-time { font-size: 13px; font-weight: bold; margin-bottom: 4px; color: #007bff; }
.record-lap-btn { background:#ffc107; color:black; border:none; padding:6px 0; border-radius:4px; cursor:pointer; width:100%; font-weight: bold; font-size: 12px; }

/* Hide the manual override input by default to save space on mobile */
.lap-time { display: none !important; }
.disabled-btn {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
    pointer-events: none !important; /* This physically prevents the click */
}
