:root {
    --nicolas: #548dce;
    --julio: #292929;
    --muted: #a3a3a3;
    --text: #202020;
    --secondary-text: #737373;
    --border: #e5e5e5;
    --background: #fafaf8;
    --content-width: 420px;
    --ease-premium: cubic-bezier(0.16, 1, 0.3, 1);
}


* {
    box-sizing: border-box;
}


html {
    min-height: 100%;
    background: var(--background);
}


body {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;

    color: var(--text);
    background: var(--background);

    font-family:
        "Space Grotesk",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}


main {
    width: min(100%, var(--content-width));
    margin: 0 auto;
    padding-inline: clamp(14px, 4vw, 18px);
}


button,
input {
    font: inherit;
}


button {
    cursor: pointer;
}


img {
    max-width: 100%;
}


[hidden] {
    display: none !important;
}


.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}


/* -------------------------------------------------------------------------- */
/* Home shell                                                                  */
/* -------------------------------------------------------------------------- */

.home-view {
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: clamp(8px, 1.4dvh, 14px);
    padding-bottom: 16px;
}


/* -------------------------------------------------------------------------- */
/* Crossed paddle hero                                                         */
/* -------------------------------------------------------------------------- */

.paddle-hero {
    position: relative;
    width: 100%;
    height: clamp(238px, 30dvh, 258px);
    margin: 0 auto;
    overflow: visible;
    isolation: isolate;
}


.hero-paddle {
    position: absolute;
    top: clamp(2px, 0.7dvh, 6px);
    left: 50%;

    width: clamp(136px, 37vw, 148px);
    max-width: none;
    height: auto;

    object-fit: contain;
    transform-origin: 50% 77%;
    user-select: none;
    pointer-events: none;
    will-change: transform, opacity;
}


.hero-paddle--black {
    z-index: 1;

    transform:
        translateX(calc(-50% - 18px))
        rotate(-34deg);

    animation:
        blackPaddleEnter
        660ms
        var(--ease-premium)
        both;
}


.hero-paddle--blue {
    z-index: 2;

    transform:
        translateX(calc(-50% + 18px))
        rotate(34deg);

    animation:
        bluePaddleEnter
        660ms
        var(--ease-premium)
        both;
}


@keyframes blackPaddleEnter {
    from {
        opacity: 0;
        transform:
            translateX(calc(-50% + 132px))
            translateY(8px)
            rotate(-8deg);
    }

    to {
        opacity: 1;
        transform:
            translateX(calc(-50% - 18px))
            translateY(0)
            rotate(-34deg);
    }
}


@keyframes bluePaddleEnter {
    from {
        opacity: 0;
        transform:
            translateX(calc(-50% - 132px))
            translateY(8px)
            rotate(8deg);
    }

    to {
        opacity: 1;
        transform:
            translateX(calc(-50% + 18px))
            translateY(0)
            rotate(34deg);
    }
}


/* -------------------------------------------------------------------------- */
/* Home branding                                                               */
/* -------------------------------------------------------------------------- */

.home-brand {
    display: flex;
    justify-content: center;
    margin-top: -2px;
}


.pro-spin-logo {
    display: block;
    width: clamp(232px, 67vw, 268px);
    height: auto;
    margin: 0 auto;
    object-fit: contain;
    user-select: none;
}


.home-subtitle {
    margin: 5px 0 0;

    color: var(--text);

    font-size: clamp(13px, 3.6vw, 15px);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0.4em;
    text-align: center;
    text-indent: 0.4em;
}


/* -------------------------------------------------------------------------- */
/* Head-to-head scoreboard                                                     */
/* -------------------------------------------------------------------------- */

.home-scoreboard {
    margin-top: clamp(15px, 2.3dvh, 20px);
}


.scoreboard-names,
.scoreboard-score {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}


.scoreboard-names {
    grid-template-columns: 1fr 1fr;
    margin-bottom: 0;
}


.scoreboard-name {
    font-size: clamp(13px, 3.5vw, 15px);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}


.scoreboard-name--nicolas {
    color: var(--nicolas);
    text-align: left;
}


.scoreboard-name--julio {
    color: var(--julio);
    text-align: right;
}


.scoreboard-number {
    font-size: clamp(48px, 13.5vw, 56px);
    font-weight: 700;
    line-height: 0.95;
    font-variant-numeric: tabular-nums;
}


.scoreboard-number--nicolas {
    color: var(--nicolas);
    text-align: left;
}


.scoreboard-number--julio {
    color: var(--julio);
    text-align: right;
}


.scoreboard-separator {
    padding-inline: 12px;

    color: #c7c7c7;

    font-size: 25px;
    font-weight: 400;
    line-height: 1;
}


/* -------------------------------------------------------------------------- */
/* Win ratio                                                                   */
/* -------------------------------------------------------------------------- */

.win-ratio {
    margin-top: clamp(10px, 1.8dvh, 15px);
}


.ratio-percentages {
    display: flex;
    align-items: center;
    justify-content: space-between;
}


.ratio-percentage {
    font-size: clamp(15px, 4vw, 17px);
    font-weight: 600;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}


.ratio-percentage--nicolas {
    color: var(--nicolas);
}


.ratio-percentage--julio {
    color: var(--julio);
}


.ratio-bar {
    --nicolas-ratio: 0%;
    --julio-ratio: 0%;

    display: flex;
    width: 100%;
    height: 4px;
    margin-top: 7px;
    overflow: hidden;

    border-radius: 999px;
    background: var(--border);
}


.ratio-segment {
    display: block;
    height: 100%;
    transition: flex-basis 240ms var(--ease-premium);
}


.ratio-segment--nicolas {
    flex: 0 0 var(--nicolas-ratio);
    background: var(--nicolas);
}


.ratio-segment--julio {
    flex: 0 0 var(--julio-ratio);
    background: var(--julio);
}


/* -------------------------------------------------------------------------- */
/* Last match                                                                  */
/* -------------------------------------------------------------------------- */

.last-match-section {
    margin-top: clamp(17px, 2.4dvh, 21px);
    padding-top: clamp(14px, 2dvh, 17px);

    border-top: 1px solid var(--border);
}


.section-label {
    margin: 0 0 8px;

    color: var(--secondary-text);

    font-size: clamp(12px, 3.2vw, 13px);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0.15em;
    text-align: center;
    text-transform: uppercase;
}


.last-match-result {
    display: grid;
    grid-template-columns:
        minmax(0, 1fr)
        auto
        auto
        auto
        minmax(0, 1fr);
    align-items: baseline;
    column-gap: clamp(6px, 2vw, 9px);

    min-height: 34px;

    font-variant-numeric: tabular-nums;
}


.last-match-result--empty {
    display: block;

    color: var(--muted);

    font-size: 14px;
    text-align: center;
}


.last-match-player {
    min-width: 0;

    font-size: clamp(13px, 3.5vw, 15px);
    line-height: 1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}


.last-match-player--nicolas {
    text-align: right;
}


.last-match-player--julio {
    text-align: left;
}


.last-match-score {
    font-size: clamp(27px, 7.7vw, 32px);
    line-height: 1;
}


.last-match-separator {
    color: #bcbcbc;

    font-size: 23px;
    font-weight: 400;
    line-height: 1;
}


.last-match-player.is-nicolas,
.last-match-score.is-nicolas {
    color: var(--nicolas);
}


.last-match-player.is-julio,
.last-match-score.is-julio {
    color: var(--julio);
}


.last-match-player.is-loser,
.last-match-score.is-loser {
    color: var(--muted);
}


.last-match-player.is-winner,
.last-match-score.is-winner {
    font-weight: 700;
}


.last-match-player.is-loser {
    font-weight: 500;
}


.last-match-score.is-loser {
    font-weight: 600;
}


/* -------------------------------------------------------------------------- */
/* Home actions                                                                */
/* -------------------------------------------------------------------------- */

.home-actions {
    display: grid;
    gap: 3px;

    margin-top: clamp(23px, 3.2dvh, 29px);
}


.home-action {
    width: 100%;
    min-height: 44px;
    margin: 0;

    border: 0;
    border-radius: 9px;

    font-size: clamp(14px, 3.8vw, 16px);
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.055em;
    text-transform: uppercase;

    -webkit-tap-highlight-color: transparent;
    transition:
        transform 120ms ease,
        opacity 120ms ease,
        background-color 120ms ease;
}


.home-action:active {
    transform: scale(0.988);
}


.home-action--primary {
    min-height: 50px;

    color: #fff;
    background: var(--nicolas);
}


.home-action--primary:hover {
    background: #4a83c3;
}


.home-action--secondary {
    color: var(--text);
    background: transparent;
}


.home-action--secondary:hover {
    background: rgba(32, 32, 32, 0.035);
}


.home-action:focus-visible {
    outline: 3px solid rgba(84, 141, 206, 0.32);
    outline-offset: 2px;
}


/* -------------------------------------------------------------------------- */
/* Home reveal sequence                                                        */
/* -------------------------------------------------------------------------- */

.home-reveal {
    opacity: 0;
    transform: translateY(-7px);

    animation:
        homeReveal
        430ms
        var(--ease-premium)
        both;
}


.home-reveal--logo {
    animation-delay: 470ms;
}


.home-reveal--subtitle {
    animation-delay: 540ms;
}


.home-reveal--scoreboard {
    animation-delay: 610ms;
}


.home-reveal--ratio {
    animation-delay: 680ms;
}


.home-reveal--last-match {
    animation-delay: 750ms;
}


.home-reveal--actions {
    animation-delay: 820ms;
}


@keyframes homeReveal {
    from {
        opacity: 0;
        transform: translateY(-7px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* -------------------------------------------------------------------------- */
/* Temporary/basic styling for secondary screens                               */
/* -------------------------------------------------------------------------- */

.secondary-view {
    padding: 24px 0 42px;
}


.secondary-view > button {
    min-height: 44px;
    padding: 10px 14px;

    border: 1px solid var(--border);
    border-radius: 8px;

    color: var(--text);
    background: transparent;
}


.secondary-view h1 {
    margin: 20px 0;
}


.score-input-group {
    display: flex;
    align-items: center;
    justify-content: space-between;

    max-width: 240px;
    margin: 16px 0;
}


input[type="number"] {
    width: 90px;
    padding: 10px;
}


fieldset {
    margin: 24px 0;
    padding: 16px;
}


fieldset label {
    display: inline-block;
    margin-right: 16px;
}


.form-error {
    min-height: 1.5em;
    margin: 16px 0;

    color: #b00020;

    font-size: 14px;
}


.stats-total {
    margin: 24px 0 16px;
    text-align: center;
}


#total-matches {
    font-weight: 700;
}


.player-stats-grid {
    display: grid;
    grid-template-columns:
        minmax(0, 1fr)
        minmax(0, 1fr);

    margin-top: 24px;

    border-top: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
}


.player-stat-column {
    min-width: 0;
    padding: 24px 12px;
    text-align: center;
}


.player-stat-column:first-child {
    border-right: 1px solid #ccc;
}


.player-stat-column h2 {
    margin-top: 0;
}


.stat-block {
    margin: 32px 0;
}


.stat-score {
    margin: 6px 0;

    font-size: 18px;
    font-weight: 700;
}


.stat-detail {
    min-height: 1.2em;

    color: #666;

    font-size: 13px;
}


.shared-stats {
    margin-top: 40px;
    text-align: center;
}


.shared-stats .stat-block {
    padding: 24px 0;
    border-bottom: 1px solid #ccc;
}


#history-list {
    margin-top: 24px;
}


.history-entry {
    padding: 18px 0;
    border-bottom: 1px solid #ccc;
}


.history-date {
    color: #666;
    font-size: 13px;
}


.history-score {
    display: block;
    margin: 6px 0;
}


.history-winner {
    font-size: 14px;
}


/* -------------------------------------------------------------------------- */
/* Short-screen tuning                                                         */
/* -------------------------------------------------------------------------- */

@media (max-height: 760px) {
    .home-view {
        padding-top: 5px;
        padding-bottom: 10px;
    }

    .paddle-hero {
        height: 218px;
    }

    .hero-paddle {
        width: clamp(124px, 34vw, 136px);
        top: 0;
    }

    .pro-spin-logo {
        width: clamp(220px, 62vw, 242px);
    }

    .home-subtitle {
        margin-top: 2px;
    }

    .home-scoreboard {
        margin-top: 12px;
    }

    .scoreboard-number {
        font-size: clamp(44px, 12vw, 50px);
    }

    .win-ratio {
        margin-top: 8px;
    }

    .last-match-section {
        margin-top: 14px;
        padding-top: 12px;
    }

    .section-label {
        margin-bottom: 6px;
    }

    .home-actions {
        margin-top: 19px;
    }
}


/* -------------------------------------------------------------------------- */
/* Narrow-screen tuning                                                        */
/* -------------------------------------------------------------------------- */

@media (max-width: 340px) {
    main {
        padding-inline: 12px;
    }

    .paddle-hero {
        height: 224px;
    }

    .hero-paddle {
        width: 128px;
    }

    .pro-spin-logo {
        width: 220px;
    }

    .scoreboard-name {
        font-size: 12px;
    }

    .scoreboard-number {
        font-size: 46px;
    }

    .last-match-player {
        font-size: 12px;
    }

    .last-match-score {
        font-size: 26px;
    }

    .last-match-result {
        column-gap: 5px;
    }

    .player-stat-column {
        padding-right: 8px;
        padding-left: 8px;
    }

    .stat-score {
        font-size: 16px;
    }
}


/* -------------------------------------------------------------------------- */
/* Reduced motion                                                              */
/* -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
    }

    .hero-paddle,
    .home-reveal {
        animation: none !important;
        transition: none !important;
    }

    .home-reveal {
        opacity: 1;
        transform: none;
    }
}


/* ========================================================================== */
/* Secondary screens                                                          */
/* ========================================================================== */

.secondary-view {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 12px 0 24px;
}

.secondary-view--history {
    min-height: 100dvh;
    padding-bottom: 36px;
}

.back-button {
    position: relative;
    z-index: 2;

    display: grid;
    place-items: center;

    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;

    border: 0;
    border-radius: 50%;

    color: var(--text);
    background: transparent;

    font-size: 24px;
    font-weight: 400;
    line-height: 1;

    -webkit-tap-highlight-color: transparent;
    transition:
        transform 120ms ease,
        background-color 120ms ease;
}

.back-button:hover {
    background: rgba(32, 32, 32, 0.04);
}

.back-button:active {
    transform: scale(0.985);
}

.back-button:focus-visible,
.winner-option:focus-within,
.score-input:focus-visible,
.save-match-button:focus-visible {
    outline: 3px solid rgba(84, 141, 206, 0.3);
    outline-offset: 2px;
}

.secondary-header {
    margin-top: -28px;
    text-align: center;
    pointer-events: none;
}

.secondary-title {
    margin: 0;

    color: var(--text);

    font-size: clamp(17px, 4.8vw, 20px);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.23em;
    text-indent: 0.23em;
    text-transform: uppercase;
}

.secondary-label {
    margin: 0;

    color: var(--secondary-text);

    font-size: clamp(11px, 3vw, 13px);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0.15em;
    text-align: center;
    text-transform: uppercase;
}


/* -------------------------------------------------------------------------- */
/* Add Match                                                                   */
/* -------------------------------------------------------------------------- */

.secondary-view--add .secondary-header {
    margin-bottom: clamp(46px, 7dvh, 62px);
}

.add-match-form {
    margin: 0;
}

.winner-fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;

    border: 0;
}

.winner-fieldset > .secondary-label {
    display: block;
    width: 100%;
    margin-bottom: 14px;
}

.winner-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.winner-option {
    position: relative;

    display: grid;
    place-items: center;

    min-height: 64px;
    padding: 0 12px;

    border: 1.5px solid var(--border);
    border-radius: 9px;

    background: transparent;

    font-size: clamp(15px, 4.1vw, 17px);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;

    cursor: pointer;
    user-select: none;

    transition:
        color 160ms ease,
        border-color 160ms ease,
        background-color 160ms ease,
        transform 120ms ease;
}

.winner-option--nicolas {
    color: var(--nicolas);
    border-color: rgba(84, 141, 206, 0.62);
}

.winner-option--julio {
    color: var(--julio);
    border-color: rgba(41, 41, 41, 0.38);
}

.winner-option:active {
    transform: scale(0.985);
}

.winner-input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.winner-selector:has(.winner-input:checked) .winner-option:not(:has(.winner-input:checked)) {
    color: var(--muted);
    border-color: var(--border);
    background: rgba(163, 163, 163, 0.055);
}

.winner-option--nicolas:has(.winner-input:checked) {
    color: #fff;
    border-color: var(--nicolas);
    background: var(--nicolas);
}

.winner-option--julio:has(.winner-input:checked) {
    color: #fff;
    border-color: var(--julio);
    background: var(--julio);
}

.score-entry {
    margin-top: clamp(54px, 8dvh, 70px);
}

.score-entry > .secondary-label {
    margin-bottom: 18px;
}

.score-entry-names {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-bottom: 8px;
}

.score-entry-name {
    font-size: clamp(12px, 3.2vw, 14px);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.score-entry-name--nicolas {
    color: var(--nicolas);
    text-align: left;
}

.score-entry-name--julio {
    color: var(--julio);
    text-align: right;
}

.score-entry-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: end;
    gap: 14px;
}

.score-field {
    min-width: 0;
}

.score-input {
    display: block;
    width: 100%;
    min-width: 0;
    height: 72px;
    padding: 0 6px 4px;

    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;

    background: transparent;

    font-size: clamp(48px, 14.5vw, 60px);
    font-weight: 700;
    line-height: 1;
    text-align: center;
    font-variant-numeric: tabular-nums;

    appearance: textfield;
    -moz-appearance: textfield;
}

.score-input::-webkit-inner-spin-button,
.score-input::-webkit-outer-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

.score-input::placeholder {
    color: #d2d2d2;
    opacity: 1;
}

.score-input--nicolas {
    color: var(--nicolas);
    caret-color: var(--nicolas);
}

.score-input--julio {
    color: var(--julio);
    caret-color: var(--julio);
}

.score-entry-separator {
    align-self: center;
    padding-bottom: 6px;

    color: #bdbdbd;

    font-size: 28px;
    font-weight: 400;
    line-height: 1;
}

.form-error {
    min-height: 42px;
    margin: 16px 4px 8px;

    color: #a33d3d;

    font-size: 12px;
    font-weight: 500;
    line-height: 1.45;
    text-align: center;
}

.save-match-button {
    width: 100%;
    min-height: 54px;
    margin: 8px 0 0;
    padding: 0 18px;

    border: 0;
    border-radius: 9px;

    color: #fff;
    background: var(--nicolas);

    font-size: clamp(14px, 3.8vw, 16px);
    font-weight: 600;
    letter-spacing: 0.055em;
    text-transform: uppercase;

    -webkit-tap-highlight-color: transparent;
    transition:
        transform 120ms ease,
        background-color 120ms ease;
}

.save-match-button:hover {
    background: #4a83c3;
}

.save-match-button:active {
    transform: scale(0.985);
}


/* -------------------------------------------------------------------------- */
/* Stats                                                                       */
/* -------------------------------------------------------------------------- */

.secondary-view--stats .secondary-header {
    margin-bottom: 20px;
}

.stats-total {
    margin: 7px 0 0;

    color: var(--secondary-text);

    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0.1em;
    text-align: center;
    text-transform: uppercase;
}

#total-matches {
    color: var(--text);
    font-weight: 700;
}

.stats-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;

    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.player-stat-column {
    min-width: 0;
    padding: 16px 14px 14px;
    text-align: center;
}

.player-stat-column--nicolas {
    border-right: 1px solid var(--border);
}

.stats-player-name {
    margin: 0 0 18px;

    font-size: clamp(13px, 3.5vw, 15px);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.player-stat-column--nicolas .stats-player-name,
.player-stat-column--nicolas .player-stat-value {
    color: var(--nicolas);
}

.player-stat-column--julio .stats-player-name,
.player-stat-column--julio .player-stat-value {
    color: var(--julio);
}

.player-stat-row {
    margin: 0;
    padding: 12px 0 14px;
}

.player-stat-row + .player-stat-row {
    border-top: 1px solid rgba(229, 229, 229, 0.72);
}

.player-stat-row h3 {
    margin: 0 0 7px;

    color: var(--secondary-text);

    font-size: clamp(10px, 2.8vw, 11px);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.player-stat-value {
    margin: 0;

    font-size: clamp(26px, 7.7vw, 32px);
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.player-stat-value--score {
    font-size: clamp(23px, 6.5vw, 28px);
}

.player-stat-detail {
    min-height: 1em;
    margin: 5px 0 0;

    color: var(--secondary-text);

    font-size: 10px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.shared-stats {
    margin: 0;
    text-align: center;
}

.shared-stat {
    padding: clamp(15px, 2.3dvh, 19px) 0;
}

.shared-stat + .shared-stat {
    border-top: 1px solid var(--border);
}

.shared-stat .secondary-label {
    margin-bottom: 7px;
}

.shared-stat-player {
    margin: 0;

    font-size: clamp(20px, 5.4vw, 24px);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.shared-stat-player.is-nicolas {
    color: var(--nicolas);
}

.shared-stat-player.is-julio {
    color: var(--julio);
}

.shared-stat-detail {
    min-height: 1em;
    margin: 4px 0 0;

    color: var(--secondary-text);

    font-size: 11px;
    font-weight: 500;
    line-height: 1.25;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.shared-match-result {
    display: grid;
    grid-template-columns:
        minmax(0, 1fr)
        auto
        auto
        auto
        minmax(0, 1fr);
    align-items: baseline;
    column-gap: clamp(5px, 1.8vw, 8px);

    max-width: 330px;
    margin: 0 auto;

    font-variant-numeric: tabular-nums;
}

.shared-match-result--empty {
    display: block;
    color: var(--muted);
    text-align: center;
}

.shared-match-player {
    min-width: 0;

    font-size: clamp(12px, 3.2vw, 14px);
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}

.shared-match-player--nicolas {
    text-align: right;
}

.shared-match-player--julio {
    text-align: left;
}

.shared-match-score {
    font-size: clamp(22px, 6.4vw, 27px);
    font-weight: 700;
    line-height: 1;
}

.shared-match-separator {
    color: #bdbdbd;
    font-size: 20px;
    line-height: 1;
}

.shared-match-player.is-nicolas,
.shared-match-score.is-nicolas {
    color: var(--nicolas);
}

.shared-match-player.is-julio,
.shared-match-score.is-julio {
    color: var(--julio);
}

.shared-match-player.is-loser,
.shared-match-score.is-loser {
    color: var(--muted);
}


/* -------------------------------------------------------------------------- */
/* History                                                                     */
/* -------------------------------------------------------------------------- */

.secondary-view--history .secondary-header {
    margin-bottom: 18px;
}

.history-list {
    margin: 0;
}

.history-empty {
    padding: 72px 0;

    color: var(--muted);

    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.13em;
    text-align: center;
    text-transform: uppercase;
}

.history-entry {
    padding: 17px 0 18px;
    border-bottom: 1px solid var(--border);
}

.history-entry:first-child {
    padding-top: 4px;
}

.history-date {
    margin: 0 0 11px;

    color: var(--secondary-text);

    font-size: 11px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.09em;
    text-align: center;
    text-transform: uppercase;
}

.history-match {
    display: grid;
    grid-template-columns:
        minmax(0, 1fr)
        auto
        auto
        auto
        minmax(0, 1fr);
    align-items: baseline;
    column-gap: clamp(7px, 2.2vw, 11px);

    font-variant-numeric: tabular-nums;
}

.history-player {
    min-width: 0;

    font-size: clamp(12px, 3.3vw, 14px);
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.history-player--nicolas {
    text-align: right;
}

.history-player--julio {
    text-align: left;
}

.history-match-score {
    font-size: clamp(25px, 7.1vw, 30px);
    font-weight: 700;
    line-height: 1;
}

.history-match-separator {
    color: #bdbdbd;
    font-size: 22px;
    font-weight: 400;
    line-height: 1;
}

.history-player.is-nicolas,
.history-match-score.is-nicolas {
    color: var(--nicolas);
}

.history-player.is-julio,
.history-match-score.is-julio {
    color: var(--julio);
}

.history-player.is-loser,
.history-match-score.is-loser {
    color: var(--muted);
}


/* -------------------------------------------------------------------------- */
/* Secondary entrance motion                                                   */
/* -------------------------------------------------------------------------- */

.secondary-view.is-entering .secondary-animate {
    animation:
        secondaryReveal
        340ms
        var(--ease-premium)
        both;
}

.secondary-view.is-entering .secondary-animate--header {
    animation-delay: 0ms;
}

.secondary-view.is-entering .secondary-animate--content {
    animation-delay: 65ms;
}

.secondary-view.is-entering .secondary-animate--shared,
.secondary-view.is-entering .secondary-animate--action {
    animation-delay: 130ms;
}

@keyframes secondaryReveal {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* -------------------------------------------------------------------------- */
/* Secondary short-screen tuning                                               */
/* -------------------------------------------------------------------------- */

@media (max-height: 760px) {
    .secondary-view {
        padding-top: 7px;
        padding-bottom: 16px;
    }

    .secondary-view--add .secondary-header {
        margin-bottom: 34px;
    }

    .winner-option {
        min-height: 58px;
    }

    .score-entry {
        margin-top: 38px;
    }

    .score-input {
        height: 64px;
        font-size: clamp(44px, 13.2vw, 54px);
    }

    .form-error {
        min-height: 34px;
        margin-top: 11px;
        margin-bottom: 5px;
    }

    .save-match-button {
        min-height: 50px;
    }

    .secondary-view--stats .secondary-header {
        margin-bottom: 13px;
    }

    .player-stat-column {
        padding-top: 12px;
        padding-bottom: 10px;
    }

    .stats-player-name {
        margin-bottom: 11px;
    }

    .player-stat-row {
        padding: 9px 0 10px;
    }

    .shared-stat {
        padding: 11px 0;
    }
}


@media (max-width: 340px) {
    .winner-selector {
        gap: 8px;
    }

    .winner-option {
        min-height: 58px;
        padding-inline: 8px;
        font-size: 14px;
    }

    .score-entry-controls {
        gap: 9px;
    }

    .player-stat-column {
        padding-inline: 9px;
    }

    .player-stat-value {
        font-size: 25px;
    }

    .player-stat-value--score {
        font-size: 22px;
    }

    .history-match,
    .shared-match-result {
        column-gap: 5px;
    }

    .history-player,
    .shared-match-player {
        font-size: 11px;
    }
}


@media (prefers-reduced-motion: reduce) {
    .secondary-view.is-entering .secondary-animate {
        animation: none !important;
        opacity: 1;
        transform: none;
    }

    .back-button,
    .winner-option,
    .save-match-button {
        transition: none !important;
    }
}

/* -------------------------------------------------------------------------- */
/* Secondary specificity safeguards                                            */
/* -------------------------------------------------------------------------- */

.secondary-view > .back-button {
    width: 44px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;

    border: 0;
    border-radius: 50%;

    color: var(--text);
    background: transparent;
}

.secondary-view .secondary-title {
    margin: 0;
}

.secondary-view .score-input {
    width: 100%;
    padding: 0 6px 4px;
}


/* -------------------------------------------------------------------------- */
/* Authentication                                                              */
/* -------------------------------------------------------------------------- */

.auth-view {
    display: flex;
    align-items: center;
    justify-content: center;

    min-height: 100vh;
    min-height: 100dvh;

    padding: 24px 18px;

    background: var(--background);
}


.auth-content {
    width: min(100%, 360px);

    text-align: center;
}


.auth-logo {
    display: block;

    width: min(260px, 72vw);
    height: auto;

    margin: 0 auto;
}


.auth-brand-subtitle {
    margin: 8px 0 42px;

    color: var(--text);

    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;

    letter-spacing: 0.4em;
    text-indent: 0.4em;
}


.auth-title {
    margin: 0 0 28px;

    color: var(--text);

    font-size: 18px;
    font-weight: 600;
    line-height: 1.2;

    letter-spacing: 0.14em;

    text-transform: uppercase;
}


.login-form {
    display: grid;

    gap: 18px;

    text-align: left;
}


.login-field {
    display: grid;

    gap: 7px;

    color: var(--secondary-text);

    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;

    letter-spacing: 0.08em;

    text-transform: uppercase;
}


.login-field input {
    width: 100%;
    height: 48px;

    padding: 0 14px;

    border: 1px solid var(--border);
    border-radius: 8px;

    outline: none;

    color: var(--text);
    background: transparent;

    font-family: inherit;
    font-size: 16px;

    text-transform: none;

    transition:
        border-color 140ms ease,
        box-shadow 140ms ease;
}


.login-field input:focus {
    border-color: var(--nicolas);

    box-shadow:
        0 0 0 3px
        rgba(84, 141, 206, 0.12);
}


.login-error {
    min-height: 18px;

    margin: -2px 0 0;

    color: #b94a48;

    font-size: 13px;
    line-height: 1.4;

    text-align: center;
}


.login-button {
    width: 100%;
    height: 52px;

    margin-top: 2px;

    border: 0;
    border-radius: 9px;

    color: #fff;
    background: var(--nicolas);

    font-family: inherit;
    font-size: 15px;
    font-weight: 600;

    letter-spacing: 0.07em;

    text-transform: uppercase;

    transition:
        transform 120ms ease,
        opacity 120ms ease,
        background-color 120ms ease;
}


.login-button:hover {
    background: #4a83c3;
}


.login-button:active {
    transform: scale(0.985);
}


.login-button:focus-visible {
    outline: 3px solid rgba(84, 141, 206, 0.32);
    outline-offset: 2px;
}


.login-button:disabled {
    cursor: wait;
    opacity: 0.65;
}


@media (prefers-reduced-motion: reduce) {
    .login-field input,
    .login-button {
        transition: none !important;
    }
}


/* -------------------------------------------------------------------------- */
/* History delete mode                                                         */
/* -------------------------------------------------------------------------- */

.secondary-view--history {
    position: relative;
}


.history-delete-toggle {
    position: absolute;
    top: 18px;
    right: 0;

    display: inline-grid;
    place-items: center;

    width: 44px;
    height: 44px;
    padding: 0;

    border: 0;
    border-radius: 50%;

    color: var(--secondary-text);
    background: transparent;

    transition:
        color 120ms ease,
        background-color 120ms ease,
        transform 120ms ease;
}


.history-delete-icon {
    display: block;

    width: 20px;
    height: 20px;

    background-color: currentColor;

    -webkit-mask:
        url("assets/trash-2.svg")
        center / contain
        no-repeat;

    mask:
        url("assets/trash-2.svg")
        center / contain
        no-repeat;
}


.history-delete-toggle:hover {
    color: #a64444;
    background: rgba(166, 68, 68, 0.06);
}


.history-delete-toggle:active {
    transform: scale(0.94);
}


.history-delete-toggle[aria-pressed="true"] {
    color: #a64444;
    background: rgba(166, 68, 68, 0.08);
}


.history-delete-toggle:focus-visible {
    outline: 3px solid rgba(84, 141, 206, 0.28);
    outline-offset: 2px;
}


.history-delete-instruction {
    margin: 7px 0 0;

    color: var(--secondary-text);

    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-align: center;
    text-transform: uppercase;
}


.history-entry {
    position: relative;
    display: grid;
    grid-template-columns: 0 minmax(0, 1fr);
    align-items: center;
    column-gap: 0;

    transition:
        grid-template-columns 180ms var(--ease-premium),
        column-gap 180ms var(--ease-premium),
        background-color 120ms ease;
}


.history-entry-content {
    min-width: 0;
}


.is-delete-mode .history-entry {
    grid-template-columns: 30px minmax(0, 1fr);
    column-gap: 9px;
    cursor: pointer;
}


.history-entry.is-selected {
    background: rgba(166, 68, 68, 0.045);
}


.history-select-button {
    display: grid;
    place-items: center;

    width: 24px;
    height: 24px;
    padding: 0;

    overflow: hidden;

    border: 1px solid var(--border);
    border-radius: 50%;

    color: #fff;
    background: transparent;

    font-size: 13px;
    font-weight: 700;

    opacity: 0;
    pointer-events: none;

    transform: scale(0.8);

    transition:
        opacity 140ms ease,
        transform 180ms var(--ease-premium),
        border-color 120ms ease,
        background-color 120ms ease;
}


.is-delete-mode .history-select-button {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}


.history-select-button[aria-pressed="true"] {
    border-color: #a64444;
    background: #a64444;
}


.history-select-button:focus-visible {
    outline: 3px solid rgba(84, 141, 206, 0.24);
    outline-offset: 2px;
}


.history-delete-actions {
    position: sticky;
    bottom: 0;

    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 8px;

    margin-top: 14px;
    padding: 12px 0 max(12px, env(safe-area-inset-bottom));

    background:
        linear-gradient(
            to bottom,
            rgba(250, 250, 248, 0),
            var(--background) 18px
        );
}


.history-delete-actions[hidden] {
    display: none !important;
}


.history-delete-cancel,
.history-delete-confirm {
    min-height: 46px;
    padding: 0 12px;

    border-radius: 8px;

    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;

    transition:
        transform 120ms ease,
        opacity 120ms ease,
        background-color 120ms ease;
}


.history-delete-cancel {
    border: 1px solid var(--border);

    color: var(--text);
    background: var(--background);
}


.history-delete-confirm {
    border: 1px solid #a64444;

    color: #fff;
    background: #a64444;
}


.history-delete-confirm:disabled {
    cursor: default;
    opacity: 0.38;
}


.history-delete-cancel:active,
.history-delete-confirm:not(:disabled):active {
    transform: scale(0.985);
}


@media (prefers-reduced-motion: reduce) {
    .history-delete-toggle,
    .history-entry,
    .history-select-button,
    .history-delete-cancel,
    .history-delete-confirm {
        transition: none !important;
    }
}

