:root {
    --bg-color: #000000;
    --text-color: #ffffff;
    --accent: #ff3b30;
    --active: #34c759;
    --border: #333333;
    --inactive: #555555;
    --modal-bg: rgba(0, 0, 0, 0.85);
    --card-bg: #1c1c1e;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
    user-select: none;
}

/* Orientation Warning */
#orientation-warning {
    display: none;
}

#warning-text {
    display: none;
}

#warning-subtext {
    display: none;
}

/* Main Dashboard */
#dashboard {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    background-color: var(--border);
}

.metric {
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 6px;
}

.label {
    font-size: 4.5vh;
    color: #aaaaaa;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
    transition: color 0.3s;
    font-weight: 600;
}

.label.rest-mode { color: var(--active); }

.value {
    font-size: 18vh;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.unit {
    font-size: 5.5vh;
    color: #888888;
    margin-left: 5px;
    font-weight: 600;
}

/* Bottom Controls */
#controls {
    height: 56px;
    display: flex;
    background-color: #111;
    border-top: 2px solid var(--border);
    align-items: center;
    padding: 0 12px;
    gap: 12px;
}

#btn-settings {
    background: transparent;
    border: none;
    font-size: 28px;
    cursor: pointer;
    padding: 0 10px 0 0;
    color: white;
    transition: opacity 0.2s;
}

#btn-settings:disabled { opacity: 0.3; cursor: not-allowed; }

#lap-info {
    flex: 1;
    font-size: 24px;
    color: #aaa;
    font-weight: bold;
}

.status-mode-work { color: var(--accent) !important; }
.status-mode-rest { color: var(--active) !important; }

/* Status Icons */
.status-container { display: flex; gap: 15px; margin-right: 15px; }
.status-icon { width: 28px; height: 28px; fill: var(--inactive); transition: fill 0.3s ease; }
.status-icon.active { fill: var(--active); }
.status-icon.error { fill: var(--accent); }

button {
    padding: 12px 35px;
    font-size: 22px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
}

#btn-lap { background-color: #444; color: white; }
#btn-start { background-color: var(--active); color: white; min-width: 120px; }
#btn-start.running { background-color: var(--accent); }

/* Setup Modal */
#modal-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--modal-bg); backdrop-filter: blur(5px);
    display: flex; justify-content: center; align-items: center; z-index: 1000;
}

.hidden { display: none !important; }

#setup-card {
    background: var(--card-bg); padding: 25px; border-radius: 16px;
    width: 80%; max-width: 400px; border: 1px solid var(--border);
}
#setup-card h2 { margin-top: 0; text-align: center; }
.form-group { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.form-group label { color: #aaa; font-weight: bold; font-size: 16px; }
.form-group select, .form-group input {
    padding: 12px; font-size: 18px; border-radius: 8px; border: 1px solid var(--border);
    background: #000; color: white; outline: none;
}
#btn-save-settings { width: 100%; background: var(--active); padding: 15px; font-size: 20px; }

/* BIG Interval Notification Overlay */
#interval-alert {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex; justify-content: center; align-items: center;
    z-index: 2000;
    pointer-events: none; /* Let clicks pass through to Stop button if needed */
    opacity: 0;
    transition: opacity 0.2s;
}
#interval-alert.show { opacity: 1; }
#alert-text { font-size: 12vw; font-weight: 900; color: var(--active); letter-spacing: 5px; }

@media (orientation: portrait) {
    #dashboard { grid-template-columns: 1fr; grid-template-rows: repeat(4, 1fr); }
    .label { font-size: 3.5vh; margin-bottom: 1px; font-weight: 700; }
    .value { font-size: 10dvh; }
    .unit { font-size: 4vh; }
    #controls { height: 56px; padding: 0 10px; gap: 10px; }
    #btn-settings { font-size: 24px; }
    button { padding: 10px 30px; font-size: 18px; }
    #lap-info { font-size: 18px; }
    .status-icon { width: 22px; height: 22px; }
    #alert-text { font-size: 12vw; }
}

@media (orientation: landscape) {
    .label { font-size: 6.5vh; margin-bottom: 1px; font-weight: 700; }
    .value { font-size: 18dvh; }
    .unit { font-size: 7vh; }
    #controls { height: 60px; padding: 0 10px; gap: 10px; }
    #btn-settings { font-size: 36px; }
    button { padding: 14px 40px; font-size: 24px; }
    #lap-info { font-size: 26px; }
    .status-icon { width: 28px; height: 28px; }
    #alert-text { font-size: 16vw; }
}
