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

:root {
    --color-primary: #2b6cb0;
    --color-primary-dark: #1e4e8c;
    --color-bg: #f7f8fa;
    --color-text: #1a202c;
    --color-text-light: #4a5568;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-accent: #38a169;
    --color-accent-light: #c6f6d5;
    --color-active: #ebf4ff;
    --color-active-border: #2b6cb0;
    --color-progress: #2b6cb0;
    --color-progress-bg: #e2e8f0;
    --color-warning: #e53e3e;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

/* Screens */
.screen {
    display: none;
    height: 100dvh;
    width: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.screen.active {
    display: flex;
}

/* Setup Screen */
#setup-screen {
    justify-content: flex-start;
    padding-top: 2rem;
    overflow-y: auto;
}

#setup-screen h1 {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    line-height: 1.3;
    margin-bottom: 1.5rem;
    color: var(--color-primary);
}

.setup-form {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.setup-form label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
    margin-top: 0.25rem;
}

.button-group {
    display: flex;
    gap: 0.5rem;
}

.button-group button {
    flex: 1;
    padding: 0.75rem 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: 2px solid var(--color-border);
    border-radius: 0.75rem;
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.15s ease;
}

.button-group button:active {
    transform: scale(0.95);
}

.button-group button.selected {
    border-color: var(--color-active-border);
    background: var(--color-active);
    color: var(--color-primary);
}

input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: 2px solid var(--color-border);
    border-radius: 0.75rem;
    background: var(--color-surface);
    color: var(--color-text);
    text-align: center;
    appearance: textfield;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--color-active-border);
}

.calculation-preview {
    background: var(--color-active);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    color: var(--color-primary);
    text-align: center;
    font-weight: 600;
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.primary-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1.15rem;
    font-weight: 700;
    border: none;
    border-radius: 0.75rem;
    background: var(--color-primary);
    color: white;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-top: 0.5rem;
}

.primary-btn:active {
    transform: scale(0.97);
    background: var(--color-primary-dark);
}

.primary-btn:disabled {
    background: var(--color-border);
    color: var(--color-text-light);
    cursor: not-allowed;
    transform: none;
}

/* Timer Screen */
#timer-screen {
    justify-content: space-between;
    padding: 1rem 1rem 1.5rem;
    position: relative;
}

.timer-nav {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#round-tabs,
#person-tabs {
    display: flex;
    gap: 0.35rem;
    justify-content: center;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: 2px solid var(--color-border);
    border-radius: 2rem;
    background: var(--color-surface);
    color: var(--color-text-light);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.tab-btn:active {
    transform: scale(0.95);
}

.tab-btn.active {
    border-color: var(--color-active-border);
    background: var(--color-primary);
    color: white;
}

.tab-btn.done {
    border-color: var(--color-accent);
    background: var(--color-accent-light);
    color: var(--color-accent);
}

.timer-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    flex: 1;
    justify-content: center;
    width: 100%;
}

.circle-container {
    position: relative;
    width: min(65vw, 65vh, 280px);
    height: min(65vw, 65vh, 280px);
}

.progress-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: var(--color-progress-bg);
    stroke-width: 8;
}

.progress-ring-fill {
    fill: none;
    stroke: var(--color-progress);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 565.48;
    stroke-dashoffset: 565.48;
    transition: stroke-dashoffset 0.5s ease;
}

.progress-ring-fill.warning {
    stroke: var(--color-warning);
}

.timer-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: min(15vw, 15vh, 4rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

.timer-display.warning {
    color: var(--color-warning);
}

.timer-label {
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    color: var(--color-text);
    line-height: 1.3;
}

#timer-screen .primary-btn {
    max-width: 280px;
}

#timer-screen .primary-btn.running {
    background: var(--color-warning);
}

.settings-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    border-radius: 50%;
    background: var(--color-surface);
    color: var(--color-text-light);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: all 0.15s ease;
}

.settings-btn:active {
    transform: scale(0.9);
}

/* End Screen */
#end-screen {
    background: var(--color-bg);
}

.end-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    text-align: center;
}

.end-icon {
    width: 5rem;
    height: 5rem;
    border-radius: 50%;
    background: var(--color-accent);
    color: white;
    font-size: 2.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

#end-screen h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
}

#end-screen .primary-btn {
    max-width: 280px;
}

/* Animations */
@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.03); }
}

.timer-display.running {
    animation: pulse 2s ease-in-out infinite;
}
