.timer-main {
    --timer-pro: #5551ff;
    --timer-con: #c84f72;
    --timer-neutral: #4a9b7a;
    --timer-warn: #bd7a1e;
    --timer-speech: #7957c8;
    --timer-control-size: 0.72rem;
    --timer-control-height: 38px;
    min-height: calc(100vh - 104px);
    min-width: 0;
    padding-block: 70px 100px;
}

.timer-page-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.45fr);
    align-items: end;
    gap: 48px;
    padding-bottom: 46px;
    border-bottom: 1px solid var(--line);
    min-width: 0;
}

.timer-page-heading h1 {
    max-width: 760px;
    margin: 0;
    font-size: clamp(2.5rem, 5vw, 4.6rem);
    font-weight: 500;
    letter-spacing: -0.06em;
    line-height: 1;
}

.timer-page-heading > p {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.timer-app-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(290px, 330px);
    gap: 18px;
    min-width: 0;
    padding-top: 34px;
}

.timer-main button {
    border: 0;
    cursor: pointer;
}

.timer-main button:focus-visible,
.timer-main input:focus-visible {
    outline: 3px solid rgba(85, 81, 255, 0.2);
    outline-offset: 2px;
}

.timer-main button:disabled {
    cursor: not-allowed;
    opacity: 0.38;
}

.timer-main .is-hidden,
.bell-panel.is-hidden {
    display: none !important;
}

.round-panel,
.side-panel {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 18px 44px rgba(23, 24, 34, 0.08);
    backdrop-filter: blur(18px);
}

.round-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: clamp(18px, 2.4vw, 26px);
}

.side-panel {
    align-self: start;
    padding: 22px;
}

.topbar {
    display: grid;
    gap: 18px;
}

.title-stack {
    display: grid;
    gap: 8px;
}

.title-stack .eyebrow {
    margin: 0;
}

.title-stack h2 {
    margin: 0;
    font-size: clamp(1.65rem, 2.7vw, 2.35rem);
    font-weight: 500;
    letter-spacing: -0.045em;
    line-height: 1.08;
}

.site-byline {
    display: inline-flex;
    width: fit-content;
    flex-wrap: wrap;
    gap: 0.35em;
    margin: 0;
    color: var(--muted);
    font-size: 0.7rem;
}

.site-byline strong {
    color: var(--ink);
    font-weight: 600;
}

.mode-switch {
    display: grid;
    gap: 6px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(233, 233, 226, 0.64);
}

.mode-group {
    display: grid;
    grid-template-columns: 82px repeat(3, minmax(0, 1fr));
    align-items: center;
    gap: 4px;
}

.mode-group:last-child {
    grid-template-columns: 82px repeat(2, minmax(0, 1fr));
}

.mode-group-label {
    padding-left: 8px;
    color: var(--muted);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.mode-button,
.order-button,
.oo-button {
    min-height: 36px;
    padding: 7px 9px;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: var(--timer-control-size);
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    transition: background-color 180ms ease, color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.mode-button:hover,
.order-button:hover,
.oo-button:hover {
    color: var(--ink);
}

.mode-button.active,
.order-button.active,
.oo-button.active {
    background: var(--surface);
    box-shadow: 0 8px 20px rgba(23, 24, 34, 0.08);
    color: var(--ink);
}

.coin-strip,
.order-panel,
.event-panel,
.bp-status,
.poi-card,
.controls,
.prep-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.62);
}

.coin-strip,
.order-panel,
.event-panel {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px;
}

.coin {
    position: relative;
    display: grid;
    width: 50px;
    height: 50px;
    flex: 0 0 auto;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface-soft);
    color: var(--ink);
    font-size: 1rem;
    font-weight: 600;
}

.coin-face {
    position: absolute;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 160ms ease, transform 180ms ease;
}

.coin[data-result="unknown"] .coin-face-unknown,
.coin[data-result="spinning"] .coin-face-spinning,
.coin[data-result="heads"] .coin-face-heads,
.coin[data-result="tails"] .coin-face-tails {
    opacity: 1;
    transform: scale(1);
}

.coin[data-result="heads"],
.coin[data-result="tails"] {
    border-color: rgba(85, 81, 255, 0.3);
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.coin.flipping {
    animation: timer-coin-flip 650ms cubic-bezier(0.22, 1, 0.36, 1);
}

.coin.revealed {
    animation: timer-pop 240ms ease;
}

.coin-copy,
.order-copy,
.poi-copy,
.bp-status,
.prep-copy,
.bell-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.coin-copy {
    flex: 1;
}

.coin-copy span,
.order-copy span,
.poi-copy span,
.bp-status span,
.prep-copy span,
.bell-copy span {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.coin-copy strong,
.order-copy strong,
.poi-copy strong,
.bp-status strong {
    font-size: 0.85rem;
    font-weight: 600;
}

.order-panel,
.event-panel {
    justify-content: space-between;
}

.order-switch {
    display: flex;
    padding: 3px;
    border-radius: 11px;
    background: var(--surface-soft);
}

.order-button,
.oo-button {
    min-width: 88px;
}

.bp-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.bp-status,
.poi-card {
    min-height: 82px;
    padding: 14px;
}

.bp-status {
    align-content: center;
}

.poi-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.bp-panel[data-poi="pois-open"] .bp-status strong {
    color: var(--timer-neutral);
}

.bp-panel[data-poi*="protected"] .bp-status strong {
    color: var(--timer-warn);
}

.stage {
    --phase-color: var(--timer-neutral);
    position: relative;
    display: flex;
    min-height: 350px;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    padding: clamp(24px, 4vw, 36px);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background:
        radial-gradient(circle at 88% 10%, color-mix(in srgb, var(--phase-color) 12%, transparent), transparent 32%),
        rgba(255, 255, 255, 0.84);
}

.stage::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: var(--phase-color);
    content: "";
}

.stage[data-side="pro"] {
    --phase-color: var(--timer-pro);
}

.stage[data-side="con"] {
    --phase-color: var(--timer-con);
}

.stage[data-side="speech"] {
    --phase-color: var(--timer-speech);
}

.stage[data-type="prep"],
.stage[data-type="crossfire"],
.stage[data-type="cross-examination"] {
    --phase-color: var(--timer-warn);
}

.stage.phase-pop {
    animation: timer-pop 280ms ease;
}

.stage-meta {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stage h2 {
    max-width: 780px;
    margin: 0;
    font-size: clamp(1.8rem, 3.7vw, 3.2rem);
    font-weight: 500;
    letter-spacing: -0.05em;
    line-height: 1.02;
}

.stage p {
    max-width: 680px;
    margin: 11px 0 0;
    color: var(--muted);
    font-size: 0.84rem;
}

.timer {
    margin-top: 24px;
    color: var(--ink);
    font-size: clamp(4.25rem, 10vw, 7.5rem);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    letter-spacing: -0.065em;
    line-height: 0.92;
}

.progress-shell,
.bell-progress-shell {
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface-soft);
}

.progress-shell {
    height: 7px;
    margin-top: 24px;
}

.progress-bar,
.bell-progress-bar {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: var(--phase-color);
    transition: width 250ms linear, background-color 180ms ease;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 8px;
}

.primary,
.secondary,
.icon-button,
.text-button,
.prep-toggle,
.prep-reset,
.evidence-toggle,
.evidence-reset,
.poi-toggle,
.poi-reset,
.bell-stop {
    min-height: var(--timer-control-height);
    border-radius: 11px;
    font-size: var(--timer-control-size);
    font-weight: 600;
    line-height: 1.2;
    transition: background-color 180ms ease, color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.primary,
.secondary {
    padding: 8px 13px;
}

.primary {
    min-width: 104px;
    background: var(--accent);
    box-shadow: 0 12px 24px rgba(85, 81, 255, 0.2);
    color: #fff;
}

.primary:hover {
    background: var(--accent-dark);
    transform: translateY(-2px);
}

.secondary,
.icon-button {
    background: var(--surface-soft);
    color: var(--ink);
}

.secondary:hover,
.icon-button:hover {
    background: #deded5;
}

.icon-button {
    width: 40px;
    padding: 0;
    font-size: 1.1rem;
}

.prep-grid,
.evidence-grid {
    display: grid;
    gap: 12px;
}

.prep-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.prep-card {
    --team-color: var(--timer-neutral);
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    min-height: 96px;
    overflow: hidden;
    padding: 15px;
}

.prep-card::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--team-color);
    content: "";
}

.prep-card.pro {
    --team-color: var(--timer-pro);
}

.prep-card.con {
    --team-color: var(--timer-con);
}

.prep-card.active {
    border-color: color-mix(in srgb, var(--team-color) 34%, var(--line));
    background: color-mix(in srgb, var(--team-color) 7%, #fff);
}

.prep-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
}

.team-dot {
    width: 8px;
    height: 32px;
    border-radius: 999px;
    background: var(--team-color);
}

.prep-copy strong {
    font-size: clamp(1.55rem, 3vw, 2.2rem);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    letter-spacing: -0.05em;
    line-height: 1;
}

.prep-actions {
    display: flex;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface);
}

.prep-toggle,
.evidence-toggle,
.poi-toggle {
    display: inline-flex;
    min-width: 72px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 12px;
    border-radius: 10px 0 0 10px;
    background: transparent;
    color: var(--team-color);
}

.prep-toggle[aria-pressed="true"],
.evidence-toggle[aria-pressed="true"],
.poi-toggle[aria-pressed="true"] {
    background: var(--team-color);
    color: #fff;
}

.prep-reset,
.evidence-reset,
.poi-reset {
    width: 36px;
    padding: 0;
    border-left: 1px solid var(--line) !important;
    border-radius: 0 10px 10px 0;
    background: transparent;
    color: var(--muted);
}

.prep-reset:hover,
.evidence-reset:hover,
.poi-reset:hover {
    background: var(--surface-soft);
    color: var(--ink);
}

.section-heading,
.settings-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.section-heading {
    margin-bottom: 14px;
}

.section-heading h2,
.settings h2 {
    margin: 0;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.text-button {
    min-height: 32px;
    padding: 6px 9px;
    background: transparent;
    color: var(--accent-dark);
    font-size: 0.68rem;
}

.flow-list {
    display: grid;
    gap: 7px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.flow-item {
    --flow-color: var(--timer-neutral);
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 9px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: border-color 180ms ease, background-color 180ms ease, opacity 180ms ease, transform 180ms ease;
}

.flow-item.pro {
    --flow-color: var(--timer-pro);
}

.flow-item.con {
    --flow-color: var(--timer-con);
}

.flow-item.speech {
    --flow-color: var(--timer-speech);
}

.flow-item.active {
    border-color: color-mix(in srgb, var(--flow-color) 34%, var(--line));
    background: color-mix(in srgb, var(--flow-color) 7%, #fff);
    transform: translateX(2px);
}

.flow-item.done {
    opacity: 0.48;
}

.flow-index {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 50%;
    background: var(--flow-color);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
}

.flow-title {
    min-width: 0;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.3;
}

.flow-time {
    color: var(--muted);
    font-size: 0.74rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.settings {
    display: grid;
    gap: 14px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.sound-test {
    border: 1px solid rgba(85, 81, 255, 0.2) !important;
    background: rgba(85, 81, 255, 0.07);
}

.sound-test.playing {
    border-color: rgba(200, 79, 114, 0.24) !important;
    background: rgba(200, 79, 114, 0.08);
    color: var(--timer-con);
}

.settings-group {
    display: grid;
    gap: 10px;
}

.settings label {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 78px;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 500;
}

.settings input {
    width: 78px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.84);
    color: var(--ink);
    font-weight: 600;
}

.wide {
    width: 100%;
}

.bell-panel {
    position: fixed;
    z-index: 1200;
    bottom: max(18px, env(safe-area-inset-bottom));
    left: 50%;
    display: grid;
    width: min(560px, calc(100vw - 28px));
    grid-template-columns: auto minmax(120px, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow);
    transform: translateX(-50%);
}

.bell-progress-shell {
    height: 7px;
}

.bell-progress-bar {
    width: 0;
    background: var(--accent);
}

.bell-stop {
    padding: 7px 12px;
    background: rgba(200, 79, 114, 0.09);
    color: var(--timer-con);
}

.ending .timer-main .progress-bar {
    background: var(--timer-warn);
    animation: timer-pulse 1s ease-in-out infinite;
}

.expired .timer-main .progress-bar,
.expired .timer-main .primary {
    background: var(--timer-con);
}

@media (max-width: 1020px) {
    .timer-app-shell {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 760px) {
    .timer-main {
        padding-block: 60px 86px;
    }

    .timer-page-heading {
        grid-template-columns: minmax(0, 1fr);
        gap: 22px;
        padding-bottom: 38px;
    }

    .timer-page-heading h1,
    .title-stack h2 {
        overflow-wrap: anywhere;
    }

    .timer-app-shell {
        padding-top: 24px;
    }

    .round-panel,
    .side-panel {
        border-radius: var(--radius-md);
    }

    .mode-group,
    .mode-group:last-child {
        grid-template-columns: 1fr;
    }

    .mode-group-label {
        padding: 7px 8px 0;
    }

    .coin-strip,
    .order-panel,
    .event-panel {
        align-items: stretch;
        flex-direction: column;
    }

    .coin-strip .secondary,
    .order-switch {
        width: 100%;
    }

    .order-switch {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .order-button,
    .oo-button {
        min-width: 0;
    }

    .bp-panel,
    .prep-grid {
        grid-template-columns: 1fr;
    }

    .stage {
        min-height: 310px;
        padding: 22px;
    }

    .stage h2 {
        font-size: clamp(1.75rem, 8vw, 2.6rem);
    }

    .timer {
        font-size: clamp(4rem, 20vw, 6rem);
    }

    .controls {
        display: grid;
        grid-template-columns: 40px minmax(82px, 1fr) 74px 40px;
    }

    #resetRound {
        grid-column: 1 / -1;
    }

    .primary,
    .secondary {
        min-width: 0;
        padding-inline: 12px;
    }

    .coin-strip .secondary {
        width: fit-content;
        align-self: flex-start;
    }

    .prep-card {
        grid-template-columns: 1fr;
    }

    .prep-actions {
        width: 100%;
    }

    .prep-toggle,
    .evidence-toggle,
    .poi-toggle {
        flex: 1;
    }
}

@media (max-width: 430px) {
    .order-switch {
        grid-template-columns: 1fr;
    }

    .controls {
        grid-template-columns: 38px minmax(76px, 1fr) 68px 38px;
        padding: 7px;
    }

    .round-panel,
    .side-panel {
        padding: 16px;
    }
}

@keyframes timer-coin-flip {
    0% { transform: rotate(0deg) scale(1); }
    45% { transform: rotate(180deg) scale(1.08); }
    100% { transform: rotate(360deg) scale(1); }
}

@keyframes timer-pop {
    0% { opacity: 0.7; transform: translateY(7px) scale(0.99); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes timer-pulse {
    50% { filter: brightness(1.25); }
}

@media (prefers-reduced-motion: reduce) {
    .timer-main *,
    .timer-main *::before,
    .timer-main *::after,
    .bell-panel {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
