* {
    box-sizing: border-box;
}

:root {
    --ink: #241a35;
    --ink-deep: #150f22;
    --paper: #f3e9d8;
    --amber: #eba83c;
}

html {
    height: 100vh;
    height: 100dvh;
    touch-action: manipulation;
}

body {
    margin: 0;
    height: 100vh;
    height: 100dvh;
    background-image: url('background.png');
    background-size: cover;
    background-position: center;
}

#content {
    height: 100%;
    width: 100%;
    padding: clamp(24px, 4dvh, 32px) clamp(12px, 4vw, 32px);
    display: flex;
    justify-content: center;
    align-items: center;
}

#scorecard {
    aspect-ratio: 607 / 371;
    /* Bounded by whichever is tighter: available width, or available height minus
       #content's own padding, then capped at 900px on large desktop screens. */
    width: max(300px, min(94vw, calc((100dvh - 48px) * 1.6361), 900px));
    container-type: inline-size;
    font-size: clamp(11px, 2.636cqw, 24px);
    margin: 0;
    overflow: hidden;
    border: 1px solid rgba(235, 168, 60, 0.25);
    border-radius: clamp(8px, 1.4cqw, 14px);
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--ink);
    box-shadow: rgba(0, 0, 0, 0.35) 1.95px 1.95px 2.6px, 0 0 clamp(20px, 4cqw, 60px) rgba(0, 0, 0, 0.35);
}

#card-header {
    width: 100%;
    height: clamp(28px, 4.89cqw, 46px);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 clamp(10px, 2.4cqw, 18px);
}

#rows {
    height: 62%;
    width: 99%;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
}

.row {
    width: 100%;
    height: 24%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.row.red {
    background-color: #c92424;
}

.numbers.red,.link.red {
    background-color: #872828;
}

.cell.red,.lock.red {
    background-color: #fdf4f6;
    color: #c92424;
    border-color: #872828;
}
.st0.red {
    fill: #872828
}

.st1.red {
    stroke: #872828;
}

.selected.red {
    background-color: #872828 !important;
}

.row.yellow {
    background-color: #dbdb43;
}

.numbers.yellow,.link.yellow {
    background-color: #8e8e02;
}

.cell.yellow,.lock.yellow {
    background-color: #fdfdf4;
    color: #dbdb43;
    border-color: #8e8e02;
}

.st0.yellow {
    fill: #8e8e02;
}

.st1.yellow {
    stroke: #8e8e02;
}

.selected.yellow {
    background-color: #8e8e02 !important;
}

.row.green {
    background-color: #439b51;
}

.numbers.green,.link.green {
    background-color: #408728;
}

.cell.green,.lock.green {
    background-color: #f4fdf5;
    color: #439b51;
    border-color: #408728;
}

.st0.green {
    fill: #408728;
}

.st1.green {
    stroke: #408728;
}

.selected.green {
    background-color: #408728 !important;
}

.row.blue {
    background-color: #4b438d;
}

.numbers.blue,.link.blue {
    background-color: #282887;
}

.cell.blue,.lock.blue {
    background-color: #f4f5fd;
    color: #4b438d;
    border-color: #282887;
}

.st0.blue {
    fill: #282887;
}

.st1.blue {
    stroke: #282887;
}

.selected.blue {
    background-color: #282887 !important;
}

.arrow {
    width: 0;
    height: 0;
    border-top: clamp(4px, 1.153cqw, 10px) solid transparent;
    border-bottom: clamp(4px, 1.153cqw, 10px) solid transparent;
    border-left: clamp(7px, 2.471cqw, 22px) solid black;
}

.numbers {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 80%;
    padding: 2px;
    border-radius: 10px;
}

.cell {
    font-family: 'Lato', sans-serif;
    font-weight: 800;
    width: clamp(24px, 7.414cqw, 67px);
    height: 100%;
    margin: 1px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: row;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
}

.link {
    height: 10%;
    width: 0.5%;
}

.lock {
    border: clamp(2px, 0.494cqw, 4px) solid;
    border-radius: 30px;
    width: clamp(16px, 4.942cqw, 44px);
    height: clamp(16px, 4.942cqw, 44px);
    text-align: center;
    transform: rotate(20deg);
    cursor: pointer;
}


.st1 {
    fill: none;
    stroke-width: 50;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-miterlimit: 10
}

#points {
    width: 100%;
    height: 13%;
    display: flex;
}

#points-header {
    height: 100%;
    width: 5%;
    background-color: var(--ink-deep);
}

#points-helper {
    height: 100%;
    width: 75%;
    background-color: var(--ink-deep);
}

#minus-points {
    height: 100%;
    width: 20%;
    padding: 0 2px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#minus-points-help {
    font-family: lato;
    height: 50%;
    text-align: center;
    color: var(--paper);
    font-size: 3.0cqw;
}

#minus-points-tracker {
    display: flex;
    justify-content: space-around;
    height: 50%;
}

#minus-points-tracker > div {
    width: 15%;
    height: 80%;
    background-color: white;
    border: 2px solid darkgray;
    border-radius: 6px;
    cursor: pointer;
}

#minus-points-tracker > div.selected {
    background-color: black;
}

#totals {
    width: 100%;
    flex: 1 1 auto;
    background-color: var(--paper);
    color: var(--ink);
    display: flex;
    justify-content: space-around;
    align-items: center;
}

#totals > span:first-child {
    font-family: lato;
}

.total {
    width: 5%;
    height: 50%;
    background-color: white;
    border: 3px solid ;
    border-radius: 6px;
    font-family: lato;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
}

.total.red {
    border-color: #c92424;
    cursor: pointer;
}

.total.yellow {
    border-color: #dbdb43;
    cursor: pointer;
}

.total.green {
    border-color: #439b51;
    cursor: pointer;
}

.total.blue {
    border-color: #4b438d;
    cursor: pointer;
}

.total.wide {
    cursor: pointer;
    width: 15%;
}

.operation {
    color: darkgray;
    font-size: 1.5em;
    margin: 0 5px
}

.ineligible {
    opacity: 0.2;
}

#reset {
    background-color: var(--amber);
    color: var(--ink);
    width: auto;
    flex-shrink: 0;
    border: 1.5px solid var(--ink);
    border-radius: clamp(5px, 1cqw, 9px);
    font-family: 'Lato', sans-serif;
    font-weight: 400;
    font-size: clamp(11px, 1.6cqw, 14px);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(4px, 1cqw, 7px);
    padding: clamp(6px, 1.3cqw, 10px) clamp(10px, 2.2cqw, 16px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
    transition: filter 0.15s ease;
}

#reset:hover,
#reset:focus-visible {
    filter: brightness(1.08);
}

#reset svg {
    width: clamp(13px, 1.9cqw, 17px);
    height: auto;
    flex-shrink: 0;
}

#rotate-prompt {
    display: none;
}

@media (orientation: portrait) and (max-width: 600px) and (hover: none) and (pointer: coarse) {
    #content {
        display: none;
    }

    #rotate-prompt {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 100dvh;
        margin: 0;
        gap: 12px;
        font-family: 'Lato', sans-serif;
        font-weight: 400;
        color: var(--ink);
        text-align: center;
        background-color: var(--paper);
    }

    #rotate-prompt p {
        margin: 0;
    }

    #rotate-prompt p:first-of-type {
        font-size: 1.3em;
        font-weight: 800;
    }

    #rotate-prompt .sub {
        color: rgba(36, 26, 53, 0.6);
        font-size: 0.95em;
    }

    #rotate-prompt .phone-icon {
        width: 46px;
        height: 76px;
        border: 4px solid var(--ink);
        border-radius: 10px;
        position: relative;
        animation: rotate-phone 2.4s ease-in-out infinite;
    }

    #rotate-prompt .phone-icon::after {
        content: "";
        position: absolute;
        bottom: 8px;
        left: 50%;
        width: 14px;
        height: 3px;
        border-radius: 2px;
        background: var(--ink);
        transform: translateX(-50%);
    }
}

@keyframes rotate-phone {
    0%, 20% {
        transform: rotate(0deg);
    }
    50%, 80% {
        transform: rotate(90deg);
    }
    100% {
        transform: rotate(90deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    #rotate-prompt .phone-icon {
        animation: none;
        transform: rotate(90deg);
    }
}
