* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 24px 12px;
    background: #eef2f8;
    color: #202020;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 17px;
}

.site-nav {
    display: flex;
    justify-content: center;
    gap: 8px;
    max-width: 760px;
    margin: 0 auto 14px;
}

.site-nav a {
    padding: 9px 14px;
    border: 1px solid #b7c9ee;
    border-radius: 999px;
    background: #fff;
    color: #123b94;
    font-size: 15px;
    font-weight: bold;
    text-decoration: none;
}

.site-nav a:hover,
.site-nav a.active {
    border-color: #0845ba;
    background: #0955db;
    color: #fff;
}

.closest-game {
    max-width: 760px;
    margin: 0 auto;
    overflow: hidden;
    border: 1px solid #dce2ef;
    border-radius: 12px;
    background: #fafbff;
    box-shadow: 0 5px 20px #153c7712;
}

.game-header {
    padding: 12px 16px;
    background: #083eaa;
    color: #fff;
    text-align: center;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 6px;
    font-size: 24px;
}

.game-header p {
    margin-bottom: 0;
}

.game-header h1 {
    margin: 0;
}

.game-content {
    padding: 16px;
}

.panel {
    margin-bottom: 14px;
    padding: 20px;
    border: 2px solid #e4e9f5;
    border-radius: 10px;
    background: #f5f7ff;
}

.panel:last-child {
    margin-bottom: 0;
}

h2 {
    margin-bottom: 16px;
    color: #123b94;
    font-size: 20px;
    text-align: center;
}

.setup-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.setup-intro {
    max-width: 590px;
    margin: -4px auto 20px;
    color: #536076;
    line-height: 1.45;
    text-align: center;
}

.range-control,
.player-control {
    padding: 16px;
    border: 1px solid #dce4f2;
    border-radius: 9px;
    background: #fff;
}

.control-label {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    color: #123b94;
    font-weight: bold;
}

.control-label output {
    min-width: 58px;
    padding: 4px 8px;
    border-radius: 5px;
    background: #dce8ff;
    text-align: center;
}

.range-control input[type="range"] {
    min-height: auto;
    padding: 0;
    border: 0;
    accent-color: #0955db;
}

.range-ends {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    color: #69758a;
    font-size: 13px;
}

.player-stepper {
    display: grid;
    grid-template-columns: 46px 1fr 46px;
    gap: 8px;
    align-items: center;
}

.player-stepper button {
    min-height: 42px;
    margin: 0;
    padding: 0;
    font-size: 24px;
    line-height: 1;
}

.player-stepper span {
    padding: 10px;
    border: 2px solid #d9deea;
    border-radius: 7px;
    color: #123b94;
    font-weight: bold;
    text-align: center;
}

.player-control small {
    display: block;
    margin-top: 10px;
}

label {
    display: grid;
    gap: 7px;
    color: #123b94;
    font-weight: bold;
}

input,
button {
    width: 100%;
    min-height: 44px;
    border-radius: 7px;
    font: inherit;
}

input {
    padding: 8px 10px;
    border: 2px solid #d9deea;
    background: #fff;
    color: #202020;
}

small {
    color: #5c687d;
    font-size: 13px;
    font-weight: normal;
    line-height: 1.3;
}

button {
    margin-top: 20px;
    padding: 10px;
    border: 1px solid #0845ba;
    background: #0955db;
    color: #fff;
    font-weight: bold;
    cursor: pointer;
}

button:hover {
    background: #0843b0;
}

input:focus-visible,
button:focus-visible,
.site-nav a:focus-visible {
    outline: 3px solid #638fff;
    outline-offset: 3px;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 14px;
}

.section-heading h2 {
    margin-bottom: 4px;
    text-align: left;
}

.section-heading p {
    margin-bottom: 16px;
    color: #52617b;
}

.player-total {
    flex: 0 0 auto;
    padding: 7px 10px;
    border-radius: 999px;
    background: #dce8ff;
    color: #123b94;
    font-size: 14px;
    font-weight: bold;
}

.player-entries {
    display: grid;
    gap: 10px;
}

.player-row {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) minmax(130px, 0.75fr);
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid #dce4f2;
    border-radius: 8px;
    background: #fff;
}

.player-row span {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #dce8ff;
    color: #123b94;
    font-size: 14px;
    font-weight: bold;
}

.player-row input {
    min-height: 40px;
}

#result-message {
    margin-bottom: 16px;
    color: #123b94;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
}

.result-modal {
    position: fixed;
    z-index: 10;
    inset: 0;
    display: none;
    place-items: center;
    padding: 20px;
    background: #07162acc;
}

.result-modal.is-visible {
    display: grid;
}

.result-card {
    width: min(100%, 650px);
    max-height: min(90vh, 760px);
    overflow-y: auto;
    padding: 28px;
    border: 3px solid #6d97ff;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 18px 50px #0007;
    text-align: center;
}

.result-label {
    margin-bottom: 7px;
    color: #0955db;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.result-card h2 {
    margin-bottom: 10px;
    font-size: 28px;
}

.result-card h3 {
    margin: 22px 0 10px;
    color: #123b94;
    font-size: 16px;
}

.podium {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    align-items: end;
    margin-top: 20px;
}

.podium-place {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    justify-content: end;
}

.podium-place.first {
    grid-column: 2;
    grid-row: 1;
}

.podium-place.second {
    grid-column: 1;
    grid-row: 1;
}

.podium-place.third {
    grid-column: 3;
    grid-row: 1;
}

.place-label {
    color: #59657a;
    font-size: 13px;
    font-weight: bold;
}

.podium-name {
    width: 100%;
    margin: 5px 0 3px;
    overflow-wrap: anywhere;
    color: #123b94;
}

.podium-guess {
    color: #536076;
    font-size: 12px;
}

.podium-tier {
    display: grid;
    width: 100%;
    place-items: center;
    margin-top: 8px;
    border-radius: 8px 8px 0 0;
    background: #9fbaf3;
    color: #fff;
    font-size: 25px;
    font-weight: bold;
}

.podium-place.first .podium-tier {
    height: 146px;
    background: #f0b83d;
}

.podium-place.second .podium-tier {
    height: 103px;
    background: #9ca8b7;
}

.podium-place.third .podium-tier {
    height: 72px;
    background: #c9824d;
}

.podium-place.winner .podium-name {
    color: #176537;
}

.results-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
    max-height: 210px;
    overflow-y: auto;
}

.results-list li {
    display: grid;
    grid-template-columns: 34px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 12px;
    border: 1px solid #dce4f2;
    border-radius: 8px;
    background: #fff;
}

.results-list .rank {
    color: #59657a;
    font-weight: bold;
    text-align: center;
}

.results-list .result-details {
    color: #536076;
    font-size: 14px;
}

.results-list li.winner {
    border-color: #3fba75;
    background: #e9f9ef;
}

.results-list li.winner .name {
    color: #176537;
    font-weight: bold;
}

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

    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .player-total {
        align-self: start;
    }
}

@media (max-width: 440px) {
    body {
        padding: 14px 8px;
    }

    .game-content,
    .panel {
        padding: 14px;
    }

    .player-row {
        grid-template-columns: 36px 1fr;
    }

    .player-row input:last-child {
        grid-column: 2;
    }

    .results-list li {
        grid-template-columns: 28px 1fr;
    }

    .results-list .result-details {
        grid-column: 2;
    }

    .result-card {
        padding: 20px 14px;
    }

    .podium-tier {
        font-size: 20px;
    }

    .podium-place.first .podium-tier {
        height: 120px;
    }

    .podium-place.second .podium-tier {
        height: 88px;
    }

    .podium-place.third .podium-tier {
        height: 62px;
    }
}
