:root {
    --bg: #f7efe3;
    --bg-strong: #ecd8bd;
    --surface: rgba(255, 250, 243, 0.8);
    --surface-strong: rgba(255, 255, 255, 0.72);
    --surface-muted: rgba(255, 247, 236, 0.58);
    --ink: #5d4838;
    --ink-strong: #241a12;
    --muted: #7d6756;
    --line: rgba(93, 72, 56, 0.14);
    --accent: #db5c3f;
    --accent-strong: #0f8b8d;
    --accent-soft: rgba(15, 139, 141, 0.11);
    --danger: #c3472a;
    --success: #2a8a5b;
    --timer-accent: var(--accent);
    --timer-glow: rgba(219, 92, 63, 0.2);
}

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

html {
    color-scheme: light;
}

body {
    min-height: 100vh;
    padding:
        max(20px, env(safe-area-inset-top))
        max(20px, env(safe-area-inset-right))
        max(20px, env(safe-area-inset-bottom))
        max(20px, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
    font-family: "IBM Plex Sans", sans-serif;
    color: var(--ink-strong);
    background:
        radial-gradient(circle at top left, rgba(15, 139, 141, 0.18), transparent 30%),
        radial-gradient(circle at bottom right, rgba(219, 92, 63, 0.18), transparent 34%),
        linear-gradient(145deg, #f8f1e6 0%, #f2e4d2 50%, #f8efe1 100%);
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: auto;
    border-radius: 50%;
    pointer-events: none;
    z-index: -2;
    filter: blur(10px);
    animation: drift 16s ease-in-out infinite alternate;
}

body::before {
    width: 340px;
    height: 340px;
    top: -100px;
    left: -80px;
    background: rgba(15, 139, 141, 0.18);
}

body::after {
    width: 420px;
    height: 420px;
    right: -110px;
    bottom: -140px;
    background: rgba(219, 92, 63, 0.16);
    animation-delay: -6s;
}

@keyframes drift {
    from {
        transform: translate3d(0, 0, 0) scale(1);
    }

    to {
        transform: translate3d(24px, 18px, 0) scale(1.08);
    }
}

.skip-link {
    position: absolute;
    left: 18px;
    top: 18px;
    transform: translateY(-180%);
    padding: 0.85rem 1rem;
    border-radius: 999px;
    background: var(--ink-strong);
    color: #fffaf2;
    text-decoration: none;
    z-index: 20;
    transition: transform 180ms ease;
}

.skip-link:focus-visible {
    transform: translateY(0);
}

.app-shell {
    width: min(1100px, 100%);
    position: relative;
}

.app-shell::before {
    content: "";
    position: absolute;
    inset: 18px;
    border-radius: 34px;
    background-image:
        linear-gradient(rgba(93, 72, 56, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(93, 72, 56, 0.035) 1px, transparent 1px);
    background-size: 24px 24px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.8), transparent 96%);
    pointer-events: none;
    z-index: -1;
}

.hero-card {
    position: relative;
    overflow: hidden;
    display: grid;
    gap: 1.5rem;
    padding: clamp(1.2rem, 3vw, 2.6rem);
    border-radius: 38px;
    border: 1px solid rgba(93, 72, 56, 0.12);
    background: linear-gradient(180deg, rgba(255, 252, 248, 0.82), rgba(252, 245, 235, 0.78));
    backdrop-filter: blur(22px) saturate(1.2);
    box-shadow:
        0 28px 90px rgba(81, 55, 33, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.hero-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 12% 14%, rgba(15, 139, 141, 0.11), transparent 24%),
        radial-gradient(circle at 88% 86%, rgba(219, 92, 63, 0.1), transparent 28%);
    pointer-events: none;
}

.hero-top,
.panel-head,
.controls,
.preset-row,
.stats-row {
    position: relative;
    z-index: 1;
}

.hero-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.hero-title-group {
    display: grid;
    gap: 0.5rem;
}

.eyebrow,
.panel-kicker,
.stat-label,
.target-caption,
.input-label,
.input-hint {
    letter-spacing: 0.08em;
}

.eyebrow,
.panel-kicker,
.stat-label,
.target-caption {
    text-transform: uppercase;
}

.eyebrow {
    color: var(--accent-strong);
    font-size: 0.82rem;
    font-weight: 700;
}

h1,
h2,
.timer-number,
#target-value,
.stat-value {
    font-family: "Archivo", sans-serif;
}

h1 {
    max-width: 10ch;
    font-size: clamp(3rem, 8vw, 5.6rem);
    line-height: 0.92;
    letter-spacing: -0.07em;
    text-wrap: balance;
}

.hero-copy {
    max-width: 44ch;
    color: var(--ink);
    font-size: 1.06rem;
    line-height: 1.65;
    text-wrap: pretty;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    align-self: flex-start;
    padding: 0.8rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.7);
    color: var(--ink);
    font-size: 0.92rem;
    font-weight: 700;
    box-shadow: 0 12px 24px rgba(81, 55, 33, 0.08);
}

.indicator {
    width: 0.72rem;
    height: 0.72rem;
    border-radius: 50%;
    background: rgba(36, 26, 18, 0.18);
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.42);
}

.status-chip[data-state="running"] {
    background: rgba(15, 139, 141, 0.12);
    border-color: rgba(15, 139, 141, 0.2);
    color: var(--accent-strong);
}

.status-chip[data-state="running"] .indicator {
    background: var(--accent-strong);
    box-shadow: 0 0 0 6px rgba(15, 139, 141, 0.16);
    animation: indicator-pulse 1.25s ease-in-out infinite alternate;
}

.status-chip[data-state="stopped"] {
    background: rgba(219, 92, 63, 0.1);
    border-color: rgba(219, 92, 63, 0.18);
    color: var(--accent);
}

.status-chip[data-state="stopped"] .indicator {
    background: var(--accent);
}

.status-chip[data-state="finished"] {
    background: rgba(42, 138, 91, 0.12);
    border-color: rgba(42, 138, 91, 0.2);
    color: var(--success);
}

.status-chip[data-state="finished"] .indicator {
    background: var(--success);
    box-shadow: 0 0 0 6px rgba(42, 138, 91, 0.14);
}

@keyframes indicator-pulse {
    from {
        transform: scale(1);
        opacity: 0.8;
    }

    to {
        transform: scale(1.08);
        opacity: 1;
    }
}

.workspace {
    display: grid;
    grid-template-columns: minmax(280px, 370px) minmax(320px, 1fr);
    gap: 1.2rem;
}

.panel {
    position: relative;
    overflow: hidden;
    display: grid;
    gap: 1.2rem;
    padding: 1.35rem;
    border-radius: 28px;
    border: 1px solid rgba(93, 72, 56, 0.12);
    background: linear-gradient(180deg, var(--surface-strong), var(--surface-muted));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        0 16px 34px rgba(81, 55, 33, 0.08);
}

.panel::after {
    content: "";
    position: absolute;
    inset: auto auto -40px -40px;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: rgba(219, 92, 63, 0.07);
    filter: blur(4px);
    pointer-events: none;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.panel-head h2 {
    font-size: 1.55rem;
    line-height: 1;
    letter-spacing: -0.04em;
    margin-top: 0.25rem;
    text-wrap: balance;
}

.panel-kicker {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 700;
}

.panel-note {
    max-width: 15ch;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.45;
    text-align: right;
}

.range-inputs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.input-card {
    display: grid;
    gap: 0.3rem;
    padding: 1rem;
    border-radius: 22px;
    border: 1px solid rgba(93, 72, 56, 0.12);
    background: rgba(255, 255, 255, 0.64);
    transition:
        transform 180ms ease,
        border-color 180ms ease,
        box-shadow 180ms ease,
        background-color 180ms ease;
}

.input-card:focus-within {
    transform: translateY(-2px);
    border-color: rgba(15, 139, 141, 0.32);
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 14px 30px rgba(15, 139, 141, 0.1);
}

.input-label {
    color: var(--ink-strong);
    font-size: 0.78rem;
    font-weight: 700;
}

.input-hint {
    color: var(--muted);
    font-size: 0.76rem;
}

input[type="number"] {
    width: 100%;
    margin-top: 0.6rem;
    padding: 0.75rem 0;
    border: 1px solid transparent;
    border-radius: 16px;
    background: rgba(247, 239, 227, 0.92);
    color: var(--ink-strong);
    font-family: "Archivo", sans-serif;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    font-variant-numeric: tabular-nums;
    appearance: textfield;
}

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

input[type="number"]:focus-visible {
    outline: 3px solid rgba(15, 139, 141, 0.18);
    outline-offset: 2px;
    border-color: rgba(15, 139, 141, 0.34);
}

input[type="number"][aria-invalid="true"] {
    color: var(--danger);
}

.preset-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.preset-btn {
    padding: 0.72rem 1rem;
    border: 1px solid rgba(93, 72, 56, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.68);
    color: var(--ink);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition:
        transform 180ms ease,
        border-color 180ms ease,
        background-color 180ms ease,
        color 180ms ease,
        box-shadow 180ms ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.preset-btn:hover:not(:disabled),
.preset-btn:focus-visible:not(:disabled) {
    transform: translateY(-2px);
    border-color: rgba(15, 139, 141, 0.28);
    color: var(--ink-strong);
    box-shadow: 0 12px 24px rgba(15, 139, 141, 0.08);
}

.preset-btn.active {
    background: var(--accent-soft);
    border-color: rgba(15, 139, 141, 0.24);
    color: var(--accent-strong);
    box-shadow: inset 0 0 0 1px rgba(15, 139, 141, 0.1);
}

.stage-head {
    align-items: center;
}

.target-badge {
    min-width: 132px;
    padding: 0.9rem 1rem;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(15, 139, 141, 0.13), rgba(255, 255, 255, 0.72));
    border: 1px solid rgba(15, 139, 141, 0.12);
    text-align: right;
}

.target-caption {
    display: block;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

#target-value {
    display: block;
    font-size: 1.45rem;
    line-height: 1;
    letter-spacing: -0.04em;
}

.display-area {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 350px;
}

.ring-shell {
    position: relative;
    display: grid;
    place-items: center;
    width: min(100%, 360px);
    aspect-ratio: 1;
}

.ring-shell::before,
.ring-shell::after {
    content: "";
    position: absolute;
    border-radius: 50%;
}

.ring-shell::before {
    inset: 9%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.94) 0%, rgba(255, 248, 238, 0.8) 46%, rgba(255, 248, 238, 0) 72%);
}

.ring-shell::after {
    inset: 14%;
    border: 1px dashed rgba(93, 72, 56, 0.14);
}

.progress-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    filter: drop-shadow(0 16px 26px var(--timer-glow));
}

.progress-ring__circle-bg {
    stroke: rgba(36, 26, 18, 0.08);
}

.progress-ring__circle {
    stroke: var(--timer-accent);
    stroke-dasharray: 597;
    stroke-dashoffset: 597;
    transition:
        stroke-dashoffset 220ms ease,
        stroke 220ms ease;
}

.timer-core {
    position: absolute;
    display: grid;
    place-items: center;
    gap: 0.55rem;
    text-align: center;
}

.timer-number {
    font-size: clamp(4.8rem, 13vw, 7.2rem);
    line-height: 0.86;
    letter-spacing: -0.08em;
    color: var(--timer-accent);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 12px 24px rgba(219, 92, 63, 0.16);
}

.timer-label {
    min-height: 1.5rem;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.4;
}

.pulse {
    animation: timer-pop 680ms ease-in-out infinite;
}

.finished {
    color: var(--success);
}

@keyframes timer-pop {
    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.85rem;
}

.stat-card {
    display: grid;
    gap: 0.45rem;
    padding: 0.95rem 1rem;
    border-radius: 18px;
    border: 1px solid rgba(93, 72, 56, 0.1);
    background: rgba(255, 255, 255, 0.65);
}

.stat-label {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 700;
}

.stat-value {
    font-size: 1.15rem;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
}

button {
    border: none;
    border-radius: 20px;
    font: inherit;
    font-size: 0.96rem;
    font-weight: 700;
    cursor: pointer;
    transition:
        transform 180ms ease,
        background-color 180ms ease,
        color 180ms ease,
        border-color 180ms ease,
        box-shadow 180ms ease,
        opacity 180ms ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

button svg {
    flex: none;
}

.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    min-height: 58px;
    padding: 1rem 1.25rem;
}

.btn-primary {
    flex: 1 1 260px;
    background: linear-gradient(135deg, #db5c3f, #c3472a);
    color: #fffaf3;
    box-shadow: 0 20px 34px rgba(219, 92, 63, 0.22);
}

.btn-primary:hover:not(:disabled),
.btn-primary:focus-visible:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 24px 40px rgba(219, 92, 63, 0.26);
}

.btn-secondary {
    flex: 1 1 160px;
    border: 1px solid rgba(93, 72, 56, 0.12);
    background: rgba(255, 255, 255, 0.7);
    color: var(--ink-strong);
}

.btn-secondary:hover:not(:disabled),
.btn-secondary:focus-visible:not(:disabled) {
    transform: translateY(-2px);
    border-color: rgba(15, 139, 141, 0.18);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 18px 30px rgba(81, 55, 33, 0.08);
}

button:focus-visible,
.preset-btn:focus-visible {
    outline: 3px solid rgba(15, 139, 141, 0.22);
    outline-offset: 3px;
}

button:disabled,
.preset-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#confetti-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 30;
}

@media (max-width: 960px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .panel-note {
        max-width: none;
    }
}

@media (max-width: 760px) {
    body {
        align-items: stretch;
    }

    .hero-top,
    .panel-head {
        flex-direction: column;
    }

    .status-chip {
        align-self: stretch;
        justify-content: center;
    }

    .range-inputs,
    .stats-row {
        grid-template-columns: 1fr;
    }

    .display-area {
        min-height: 290px;
    }

    .controls {
        flex-direction: column;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
    }
}

@media (max-width: 520px) {
    .app-shell::before {
        inset: 10px;
        border-radius: 24px;
    }

    .hero-card {
        border-radius: 26px;
        padding: 1rem;
    }

    .panel {
        padding: 1rem;
        border-radius: 22px;
    }

    h1 {
        font-size: clamp(2.6rem, 16vw, 4rem);
    }

    .timer-number {
        font-size: clamp(4rem, 24vw, 5.6rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    body::before,
    body::after {
        animation: none;
    }
}
