* {
    box-sizing: border-box;
}

:root {
    --bg: #111827;
    --panel: #1f2937;
    --panel-soft: #273449;
    --panel-deep: #182235;
    --text: #f8fafc;
    --muted: #94a3b8;
    --accent: #f59e0b;
    --accent-hover: #fbbf24;
    --accent-soft: rgba(245, 158, 11, 0.12);
    --surface: #ffffff;
    --line: rgba(255,255,255,0.08);
    --shadow: 0 24px 70px rgba(0,0,0,0.35);
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 36px 20px 60px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(245, 158, 11, 0.10), transparent 30%),
        radial-gradient(circle at top right, rgba(59, 130, 246, 0.10), transparent 28%),
        linear-gradient(180deg, #0f172a 0%, #111827 100%);
    color: var(--text);
}

.yahtzee {
    width: min(1120px, 100%);
    border: 1px solid var(--line);
    border-radius: 24px;
    background: rgba(31, 41, 55, 0.96);
    padding: 0 22px 30px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.yahtzee-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 0 -22px 24px;
    padding: 22px 28px;
    background: linear-gradient(135deg, #182235, #25334b);
    border-bottom: 1px solid var(--line);
}

.game-kicker,
.section-kicker {
    display: block;
    margin-bottom: 7px;
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.yahtzee-title h1 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: clamp(2rem, 5vw, 3.25rem);
    line-height: 1;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text);
    background: none;
}

.yahtzee-title h1 i {
    color: var(--accent);
    filter: drop-shadow(0 5px 10px rgba(245, 158, 11, 0.25));
}

.game-badge {
    flex: 0 0 auto;
    padding: 10px 14px;
    border: 1px solid rgba(245, 158, 11, 0.32);
    border-radius: 999px;
    background: var(--accent-soft);
    color: #fde68a;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hide {
    visibility: hidden;
}

.scorecard-shell {
    margin-top: 8px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

.scorecard-heading-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
}

.scorecard-heading-row h2 {
    margin: 0;
    font-size: 1.65rem;
    letter-spacing: -0.03em;
}

.reset-card {
    min-height: 42px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    background: rgba(255,255,255,0.06);
    color: var(--muted);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s ease;
}

.reset-card:hover {
    color: var(--text);
    background: rgba(255,255,255,0.10);
    transform: translateY(-1px);
}

.scorecard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.score-panel {
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.42);
    box-shadow: 0 12px 28px rgba(0,0,0,0.16);
}

.score-panel-header {
    min-height: 78px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: linear-gradient(135deg, rgba(255,255,255,0.055), rgba(255,255,255,0.018));
    border-bottom: 1px solid var(--line);
}

.score-panel-header > div {
    display: flex;
    align-items: center;
    gap: 11px;
}

.section-number {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent-hover);
    font-size: 0.72rem;
    font-weight: 900;
}

.score-panel-header h3 {
    margin: 0;
    font-size: 1.08rem;
}

.section-note {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 600;
    text-align: right;
}

.score-list {
    display: flex;
    flex-direction: column;
}

.score-row {
    min-height: 61px;
    padding: 10px 14px;
    display: grid;
    grid-template-columns: minmax(120px, 1.05fr) minmax(120px, 1fr) 76px;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.055);
    transition: background 0.16s ease;
}

.score-row:hover {
    background: rgba(255,255,255,0.035);
}

.score-name {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 800;
}

.score-name i {
    color: #cbd5e1;
}

.score-rule {
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.3;
}

.score-input,
.summary-value,
.totals-bar input {
    width: 100%;
    height: 38px;
    padding: 0 7px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    outline: none;
    background: rgba(255,255,255,0.96);
    color: #111827;
    font: inherit;
    font-size: 1rem;
    font-weight: 800;
    text-align: center;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.score-input:hover {
    transform: translateY(-1px);
}

.score-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

.score-input::-webkit-inner-spin-button,
.score-input::-webkit-outer-spin-button {
    opacity: 0.55;
}

.upper-summary {
    padding: 12px 14px 14px;
    display: grid;
    gap: 9px;
    background: rgba(255,255,255,0.025);
}

.summary-row,
.bonus-row {
    min-height: 51px;
    padding: 8px 10px;
    display: grid;
    grid-template-columns: 1fr 76px;
    align-items: center;
    gap: 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
}

.summary-row > span,
.bonus-row strong {
    font-size: 0.84rem;
    font-weight: 800;
}

.bonus-row {
    border: 1px solid rgba(245, 158, 11, 0.18);
    background: rgba(245, 158, 11, 0.065);
}

.bonus-row > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.bonus-row span {
    color: var(--muted);
    font-size: 0.7rem;
}

.grand-summary-row {
    background: rgba(255,255,255,0.075);
}

.summary-value[readonly],
.totals-bar input[readonly] {
    cursor: default;
}

.yahtzee-score-row {
    background: linear-gradient(90deg, rgba(245,158,11,0.08), transparent 70%);
}

.yahtzee-score-row .score-name,
.yahtzee-score-row .score-name i {
    color: #fbbf24;
}

.yahtzee-bonus-card {
    margin: 12px 14px 14px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border: 1px solid rgba(245,158,11,0.18);
    border-radius: 14px;
    background: rgba(245,158,11,0.065);
}

.bonus-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bonus-copy strong {
    font-size: 0.88rem;
}

.bonus-copy span {
    color: var(--muted);
    font-size: 0.7rem;
}

.bonus-control-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bonus-control-area .summary-value {
    width: 72px;
}

.bonus-div-container {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bonus-div {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(245,158,11,0.40);
    border-radius: 9px;
    background: rgba(245,158,11,0.09);
    color: #fbbf24;
    cursor: pointer;
    transition: 0.16s ease;
}

.bonus-div:hover {
    background: rgba(245,158,11,0.16);
    transform: translateY(-1px);
}

.totals-bar {
    margin-top: 18px;
    display: grid;
    grid-template-columns: 1fr 1fr 1.35fr;
    gap: 12px;
}

.total-stat {
    min-height: 78px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 16px;
    background: rgba(15,23,42,0.42);
}

.total-stat span {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.total-stat input {
    width: 86px;
    height: 44px;
    font-size: 1.08rem;
}

.grand-total-stat {
    border-color: rgba(245,158,11,0.28);
    background: linear-gradient(135deg, rgba(245,158,11,0.15), rgba(245,158,11,0.06));
}

.grand-total-stat span {
    color: #fde68a;
}

.grand-total-stat input {
    border-color: rgba(245,158,11,0.45);
}

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

    .totals-bar {
        grid-template-columns: 1fr 1fr;
    }

    .grand-total-stat {
        grid-column: 1 / -1;
    }
}

@media (max-width: 620px) {
    body {
        padding: 18px 10px 40px;
    }

    .yahtzee {
        padding-left: 12px;
        padding-right: 12px;
        border-radius: 18px;
    }

    .yahtzee-title {
        margin-left: -12px;
        margin-right: -12px;
        padding: 18px;
    }

    .game-badge {
        display: none;
    }

    .scorecard-heading-row {
        align-items: center;
    }

    .reset-card span {
        display: none;
    }

    .score-row {
        grid-template-columns: 1fr 72px;
        gap: 8px;
    }

    .score-rule {
        grid-column: 1;
        grid-row: 2;
    }

    .score-input {
        grid-column: 2;
        grid-row: 1 / span 2;
    }

    .section-note {
        display: none;
    }

    .yahtzee-bonus-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .bonus-control-area {
        width: 100%;
        justify-content: space-between;
    }

    .totals-bar {
        grid-template-columns: 1fr;
    }

    .grand-total-stat {
        grid-column: auto;
    }
}

/* --------------------------------------------------
   Gameplay polish: score selection and turn completion
   -------------------------------------------------- */

.scorecard-shell {
    position: relative;
    border-radius: 18px;
    transition: background 0.25s ease, box-shadow 0.25s ease;
}

.scorecard-shell.scorecard-ready {
    background: rgba(255,255,255,0.012);
}

.scorecard-shell.scorecard-choose-score {
    background: linear-gradient(180deg, rgba(245,158,11,0.05), transparent 34%);
    box-shadow: inset 0 1px 0 rgba(251,191,36,0.18);
}

.scorecard-shell.scorecard-choose-score .section-kicker {
    color: #fbbf24;
}

.score-row {
    position: relative;
}

.score-input:disabled {
    cursor: not-allowed;
    opacity: 0.40;
    background: rgba(15,23,42,0.58);
}

.scorecard-ready .score-row:not(.scored-row),
.scorecard-choose-score .score-row:not(.scored-row) {
    cursor: pointer;
}

.scorecard-ready .score-row:not(.scored-row):hover,
.scorecard-choose-score .score-row:not(.scored-row):hover {
    background: rgba(245,158,11,0.065);
}

.scorecard-ready .score-row:not(.scored-row):hover .score-input,
.scorecard-choose-score .score-row:not(.scored-row):hover .score-input {
    border-color: rgba(251,191,36,0.56);
}

.scorecard-choose-score .score-row:not(.scored-row) .score-input:not(:focus) {
    box-shadow: 0 0 0 1px rgba(245,158,11,0.10);
}

.score-row.scored-row {
    background: rgba(34,197,94,0.055);
}

.score-row.scored-row:hover {
    background: rgba(34,197,94,0.055);
}

.score-row.scored-row::after {
    content: "✓";
    position: absolute;
    right: 4px;
    top: 4px;
    width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(34,197,94,0.16);
    color: #86efac;
    font-size: 0.66rem;
    font-weight: 1000;
}

.score-row.scored-row .score-name {
    color: #bbf7d0;
}

.score-row.scored-row .score-rule {
    opacity: 0.58;
}

.score-row.scored-row .score-input {
    border-color: rgba(34,197,94,0.24);
    background: rgba(34,197,94,0.08);
    color: #bbf7d0;
    cursor: default;
}

.score-row.score-just-committed {
    animation: scoreCommitted 0.8s ease-out;
}

@keyframes scoreCommitted {
    0% {
        transform: scale(1);
        box-shadow: inset 0 0 0 rgba(34,197,94,0);
    }
    35% {
        transform: scale(1.012);
        box-shadow: inset 0 0 0 1px rgba(34,197,94,0.35), 0 0 22px rgba(34,197,94,0.10);
    }
    100% {
        transform: scale(1);
        box-shadow: inset 0 0 0 rgba(34,197,94,0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .score-row.score-just-committed {
        animation: none;
    }
}

/* =====================================================
   LEADERBOARD
   ===================================================== */

.leaderboard-panel {
    position: fixed;

    top: 24px;
    right: 24px;

    width: 290px;

    padding: 18px;

    z-index: 100;

    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 18px;

    background:
        linear-gradient(
            145deg,
            rgba(30, 41, 59, 0.98),
            rgba(15, 23, 42, 0.98)
        );

    box-shadow:
        0 18px 45px rgba(0, 0, 0, 0.35);
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    gap: 12px;
    margin-bottom: 14px;
}

.leaderboard-header h2 {
    margin: 0;

    font-size: 1.25rem;
    color: #ffffff;
}

.leaderboard-kicker {
    display: block;

    margin-bottom: 3px;

    font-size: 0.65rem;
    font-weight: 800;

    letter-spacing: 0.12em;

    color: #f59e0b;
}

.high-score-display {
    min-width: 90px;

    padding: 8px 10px;

    text-align: center;

    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 11px;

    background: rgba(245, 158, 11, 0.1);
}

.high-score-display span {
    display: block;

    font-size: 0.6rem;
    font-weight: 700;

    text-transform: uppercase;

    color: #cbd5e1;
}

.high-score-display strong {
    display: block;

    font-size: 1.3rem;

    color: #fbbf24;
}

.leaderboard-list {
    display: grid;
    gap: 6px;
}

.leaderboard-row {
    display: grid;

    grid-template-columns: 30px 1fr 60px;

    align-items: center;

    min-height: 38px;

    padding: 5px 9px;

    border-radius: 9px;

    background: rgba(255, 255, 255, 0.045);

    color: #e2e8f0;
}

.leaderboard-first {
    border: 1px solid rgba(245, 158, 11, 0.35);

    background: rgba(245, 158, 11, 0.1);
}

.leaderboard-rank {
    font-size: 0.85rem;
    font-weight: 900;

    color: #94a3b8;
}

.leaderboard-first .leaderboard-rank {
    color: #fbbf24;
}

.leaderboard-name {
    overflow: hidden;

    font-size: 0.88rem;
    font-weight: 700;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-score {
    text-align: right;

    font-size: 0.95rem;
    font-weight: 900;

    color: #ffffff;
}

.leaderboard-kicker {
    display: block;
    margin-bottom: 4px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    color: #f59e0b;
}

.leaderboard-header h2 {
    margin: 0;
    color: #ffffff;
    font-size: 1.65rem;
}

.high-score-display {
    min-width: 115px;
    padding: 10px 16px;
    text-align: center;
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 14px;
    background: rgba(245, 158, 11, 0.1);
}

.high-score-display span {
    display: block;
    margin-bottom: 2px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #cbd5e1;
}

.high-score-display strong {
    display: block;
    font-size: 1.55rem;
    color: #fbbf24;
}

.leaderboard-list {
    display: grid;
    gap: 8px;
}

.leaderboard-row {
    display: grid;
    grid-template-columns: 50px 1fr 90px;
    align-items: center;
    min-height: 52px;
    padding: 8px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.045);
    color: #e2e8f0;
}

.leaderboard-row:hover {
    background: rgba(255, 255, 255, 0.075);
}

.leaderboard-first {
    border: 1px solid rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.10);
}

.leaderboard-rank {
    font-weight: 900;
    color: #94a3b8;
}

.leaderboard-first .leaderboard-rank {
    color: #fbbf24;
}

.leaderboard-name {
    font-weight: 700;
}

.leaderboard-score {
    text-align: right;
    font-size: 1.1rem;
    font-weight: 900;
    color: #ffffff;
}

.leaderboard-loading,
.leaderboard-empty,
.leaderboard-error {
    padding: 24px;
    text-align: center;
    border-radius: 12px;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.035);
}

/* =====================================================
   HIGH SCORE CELEBRATION
   ===================================================== */

.high-score-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;

    background: rgba(2, 6, 23, 0.82);
    backdrop-filter: blur(8px);

    opacity: 0;
    visibility: hidden;

    transition:
        opacity 0.25s ease,
        visibility 0.25s ease;
}

.high-score-overlay.show {
    opacity: 1;
    visibility: visible;
}

.high-score-celebration {
    width: min(460px, 100%);
    padding: 42px 30px;
    text-align: center;

    border: 1px solid rgba(245, 158, 11, 0.45);
    border-radius: 26px;

    background:
        radial-gradient(
            circle at top,
            rgba(245, 158, 11, 0.22),
            transparent 46%
        ),
        #0f172a;

    box-shadow:
        0 0 80px rgba(245, 158, 11, 0.25),
        0 30px 80px rgba(0, 0, 0, 0.55);

    transform: scale(0.85);

    transition:
        transform 0.3s ease;
}

.high-score-overlay.show
.high-score-celebration {
    transform: scale(1);
}

.trophy {
    margin-bottom: 14px;
    font-size: 4.5rem;

    animation:
        trophyBounce 0.8s ease;
}

.celebration-kicker {
    font-size: 0.85rem;
    font-weight: 900;
    letter-spacing: 0.16em;
    color: #fbbf24;
}

.celebration-score {
    margin: 6px 0;
    font-size: 4.5rem;
    line-height: 1;
    font-weight: 1000;
    color: #ffffff;
}

.celebration-player {
    margin-bottom: 26px;
    color: #cbd5e1;
}

.celebration-button {
    min-width: 150px;
    padding: 12px 22px;

    border: 0;
    border-radius: 12px;

    background: #f59e0b;
    color: #111827;

    font-weight: 900;
    cursor: pointer;
}

.celebration-button:hover {
    transform: translateY(-1px);
    background: #fbbf24;
}

.game-complete-message {
    color: #fbbf24;
    font-weight: 800;
}

@keyframes trophyBounce {

    0% {
        transform:
            scale(0.2)
            rotate(-15deg);
    }

    60% {
        transform:
            scale(1.2)
            rotate(8deg);
    }

    100% {
        transform:
            scale(1)
            rotate(0deg);
    }

}

@media (max-width: 620px) {

    .leaderboard-panel {
        padding: 18px;
    }

    .leaderboard-header {
        align-items: flex-start;
    }

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

    .celebration-score {
        font-size: 3.8rem;
    }
}

@media (max-width: 1450px) {

    .leaderboard-panel {
        position: relative;

        top: auto;
        right: auto;

        width: min(600px, calc(100% - 30px));

        margin: 20px auto;
    }
}

/* =====================================================
   COMPACT LAYOUT + HEADER ACTIONS
   ===================================================== */

body {
    padding: 18px 20px 32px;
}

body.modal-open {
    overflow: hidden;
}

.yahtzee {
    padding: 0 18px 20px;
}

.yahtzee-title {
    margin: 0 -18px 14px;
    padding: 14px 20px;
}

.game-kicker {
    margin-bottom: 4px;
    font-size: 0.64rem;
}

.yahtzee-title h1 {
    gap: 9px;
    font-size: clamp(1.8rem, 4vw, 2.7rem);
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.header-action-button {
    min-height: 38px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 11px;
    background: rgba(255,255,255,0.055);
    color: #cbd5e1;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.header-action-button:hover {
    transform: translateY(-1px);
    border-color: rgba(255,255,255,0.20);
    background: rgba(255,255,255,0.10);
    color: #ffffff;
}

.header-action-button i {
    color: #fbbf24;
}

.new-game-button {
    border-color: rgba(245,158,11,0.30);
    background: rgba(245,158,11,0.10);
    color: #fde68a;
}

.scorecard-shell {
    margin-top: 0;
    padding-top: 10px;
}

.scorecard-grid {
    gap: 14px;
}

.score-panel-header {
    min-height: 58px;
    padding: 10px 14px;
}

.section-number {
    width: 30px;
    height: 30px;
    border-radius: 9px;
}

.score-panel-header h3 {
    font-size: 1rem;
}

.score-row {
    min-height: 48px;
    padding: 6px 12px;
    gap: 10px;
}

.score-name {
    font-size: 0.86rem;
}

.score-rule {
    font-size: 0.71rem;
}

.score-input,
.summary-value,
.totals-bar input {
    height: 34px;
    border-radius: 9px;
    font-size: 0.94rem;
}

.upper-summary {
    padding: 8px 12px 10px;
    gap: 6px;
}

.summary-row,
.bonus-row {
    min-height: 42px;
    padding: 5px 8px;
}

.yahtzee-bonus-card {
    margin: 8px 12px 10px;
    padding: 8px 10px;
}

.bonus-div {
    width: 30px;
    height: 30px;
}

.lower-summary {
    padding: 0 12px 10px;
    gap: 6px;
}

.lower-summary .grand-summary-row {
    min-height: 42px;
    padding: 5px 8px;
}

.totals-bar {
    margin-top: 12px;
    gap: 10px;
}

.total-stat {
    min-height: 60px;
    padding: 8px 12px;
}

.total-stat input {
    height: 38px;
}

/* Keep the leaderboard from competing with modal content. */
body.modal-open .leaderboard-panel {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.how-to-play-rules-heading {
    margin-top: 4px;
    padding: 4px 2px 0;
}

.how-to-play-rules-heading span {
    display: block;
    margin-bottom: 3px;
    color: #fbbf24;
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.how-to-play-rules-heading p {
    margin: 0;
    color: #94a3b8;
    font-size: 0.78rem;
    line-height: 1.45;
}

.detailed-score-grid > .score-help-card {
    min-height: 108px;
    display: block;
}

.score-help-card strong,
.score-help-card span,
.score-help-card em {
    display: block;
    text-align: left;
}

.score-help-card strong {
    margin-bottom: 5px;
    color: #f8fafc;
    font-size: 0.84rem;
}

.score-help-card span {
    color: #cbd5e1;
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.4;
}

.score-help-card em {
    margin-top: 6px;
    color: #fbbf24;
    font-size: 0.71rem;
    font-style: normal;
    font-weight: 700;
    line-height: 1.35;
}

/* =====================================================
   HOW TO PLAY MODAL
   ===================================================== */

.how-to-play-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    padding: 18px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.how-to-play-modal.show {
    opacity: 1;
    visibility: visible;
}

.how-to-play-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.82);
    backdrop-filter: blur(7px);
}

.how-to-play-dialog {
    position: relative;
    z-index: 1;
    width: min(760px, 100%);
    max-height: min(820px, calc(100vh - 36px));
    overflow-y: auto;
    padding: 26px;
    border: 1px solid rgba(245,158,11,0.34);
    border-radius: 22px;
    background:
        radial-gradient(circle at top right, rgba(245,158,11,0.12), transparent 32%),
        #111827;
    box-shadow: 0 28px 80px rgba(0,0,0,0.56);
    transform: translateY(8px) scale(0.98);
    transition: transform 0.22s ease;
}

.how-to-play-modal.show .how-to-play-dialog {
    transform: translateY(0) scale(1);
}

.how-to-play-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 10px;
    background: rgba(255,255,255,0.055);
    color: #cbd5e1;
    cursor: pointer;
}

.how-to-play-close:hover {
    background: rgba(255,255,255,0.10);
    color: #ffffff;
}

.how-to-play-kicker {
    display: block;
    margin-bottom: 5px;
    color: #f59e0b;
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.how-to-play-dialog h2 {
    margin: 0 46px 20px 0;
    font-size: clamp(1.6rem, 4vw, 2.15rem);
}

.how-to-play-content {
    display: grid;
    gap: 12px;
}

.how-to-play-step {
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 12px;
    align-items: start;
    padding: 11px 12px;
    border: 1px solid rgba(255,255,255,0.075);
    border-radius: 13px;
    background: rgba(255,255,255,0.035);
}

.how-to-play-step-number {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(245,158,11,0.14);
    color: #fbbf24;
    font-size: 0.78rem;
    font-weight: 1000;
}

.how-to-play-step strong {
    display: block;
    margin-bottom: 2px;
    color: #ffffff;
    font-size: 0.92rem;
}

.how-to-play-step p {
    margin: 0;
    color: #94a3b8;
    font-size: 0.8rem;
    line-height: 1.45;
}

.how-to-play-score-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-top: 2px;
}

.how-to-play-score-grid > div {
    min-height: 52px;
    padding: 9px 11px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-radius: 11px;
    background: rgba(15,23,42,0.72);
    border: 1px solid rgba(255,255,255,0.07);
}

.how-to-play-score-grid strong {
    color: #e2e8f0;
    font-size: 0.79rem;
}

.how-to-play-score-grid span {
    color: #fbbf24;
    font-size: 0.74rem;
    font-weight: 800;
    text-align: right;
}

.how-to-play-tip {
    margin: 2px 0 0;
    padding: 10px 12px;
    border-radius: 11px;
    background: rgba(59,130,246,0.08);
    color: #bfdbfe;
    font-size: 0.78rem;
    line-height: 1.45;
}

.how-to-play-tip i {
    margin-right: 7px;
    color: #fbbf24;
}

.how-to-play-got-it {
    width: 100%;
    min-height: 44px;
    margin-top: 16px;
    border: 0;
    border-radius: 11px;
    background: linear-gradient(180deg, #fbbf24, #f59e0b);
    color: #111827;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 900;
    cursor: pointer;
}

.how-to-play-got-it:hover {
    filter: brightness(1.05);
}

@media (max-width: 620px) {
    body {
        padding: 10px 8px 28px;
    }

    .yahtzee {
        padding-left: 10px;
        padding-right: 10px;
    }

    .yahtzee-title {
        align-items: flex-start;
        margin-left: -10px;
        margin-right: -10px;
        padding: 12px 14px;
    }

    .header-actions {
        gap: 6px;
    }

    .header-action-button {
        width: 38px;
        min-height: 38px;
        padding: 0;
    }

    .header-action-button span {
        display: none;
    }

    .scorecard-shell {
        padding-top: 6px;
    }

    .how-to-play-dialog {
        padding: 22px 16px 16px;
    }

    .how-to-play-score-grid {
        grid-template-columns: 1fr;
    }
}

/* =====================================================
   HALL OF FAME DRAWER
   ===================================================== */

.header-actions {
    justify-content: flex-start;
}

.hall-of-fame-button {
    border-color: rgba(245, 158, 11, 0.24);
}

.header-high-score {
    min-width: 34px;
    margin-left: 2px;
    padding-left: 8px;
    padding-right: 5px;
    border-left: 1px solid rgba(255,255,255,0.12);
    color: #fbbf24;
    font-size: 0.82rem;
}

.leaderboard-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1998;
    background: rgba(2, 6, 23, 0.46);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.leaderboard-backdrop.show {
    opacity: 1;
    visibility: visible;
}

.leaderboard-panel {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    width: min(360px, 92vw) !important;
    height: 100vh;
    margin: 0 !important;
    padding: 22px 18px !important;
    z-index: 1999;
    border-radius: 20px 0 0 20px !important;
    border-right: 0;
    overflow-y: auto;
    transform: translateX(105%);
    transition: transform 0.25s ease;
    box-shadow: -24px 0 60px rgba(0,0,0,0.42);
}

.leaderboard-panel.show {
    transform: translateX(0);
}

.leaderboard-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 10px;
    background: rgba(255,255,255,0.06);
    color: #cbd5e1;
    cursor: pointer;
}

.leaderboard-close:hover {
    background: rgba(255,255,255,0.11);
    color: #fff;
}

.leaderboard-panel .leaderboard-header {
    padding-right: 42px;
    margin-bottom: 12px;
}

.leaderboard-panel .leaderboard-header h2 {
    font-size: 1.35rem;
}

.leaderboard-panel .high-score-display {
    min-width: 90px;
    padding: 7px 10px;
}

.leaderboard-panel .high-score-display strong {
    font-size: 1.25rem;
}

.leaderboard-panel .leaderboard-list {
    gap: 6px;
}

.leaderboard-panel .leaderboard-row {
    grid-template-columns: 32px 1fr 64px;
    min-height: 40px;
    padding: 6px 10px;
}

@media (max-width: 620px) {
    .header-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .header-action-button {
        flex: 1 1 auto;
    }

    .leaderboard-panel {
        width: min(340px, 94vw) !important;
        padding: 18px 14px !important;
    }
}

/* =====================================================
   PHONE HEADER POLISH
   ===================================================== */
@media (max-width: 700px) {
    .hall-of-fame-button {
        font-size: 0.68rem;
        gap: 4px;
        padding-left: 8px;
        padding-right: 8px;
    }

    .header-high-score {
        min-width: 24px;
        padding-left: 5px;
        font-size: 0.68rem;
    }
}

@media (max-width: 620px) {

    #howToPlayBtn {
        width: 46px;
        min-width: 46px;
        padding: 0;
        flex: 0 0 46px;
    }

    #hallOfFameBtn {
        padding-left: 9px;
        padding-right: 11px;
        gap: 6px;
    }

     #hallOfFameBtn > i {
        transform: translateX(3px);
    }

    .header-high-score {
        min-width: 36px;
        padding-left: 8px;
        padding-right: 5px;
        margin-left: 0;
    }
}

.yahtzee-celebration-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;

    display: flex;
    align-items: center;
    justify-content: center;

    background: rgba(2, 6, 23, 0.72);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition:
        opacity 0.2s ease,
        visibility 0.2s ease;
}

.yahtzee-celebration-overlay.show {
    opacity: 1;
    visibility: visible;
}

.yahtzee-celebration-card {
    text-align: center;

    padding: 38px 32px;

    border: 2px solid #f59e0b;
    border-radius: 24px;

    background:
        radial-gradient(
            circle at top,
            rgba(245, 158, 11, 0.22),
            transparent 55%
        ),
        #0f172a;

    box-shadow:
        0 0 70px rgba(245, 158, 11, 0.35),
        0 30px 70px rgba(0, 0, 0, 0.5);

    transform: scale(0.75);
}

.yahtzee-celebration-overlay.show
.yahtzee-celebration-card {
    animation:
        yahtzeeCelebrationPop
        0.45s
        ease-out
        forwards;
}

.yahtzee-celebration-dice {
    margin-bottom: 12px;
    font-size: 2rem;
}

.yahtzee-celebration-title {
    font-size: clamp(
        3rem,
        12vw,
        5.5rem
    );

    font-weight: 1000;
    letter-spacing: 0.05em;

    color: #fbbf24;

    text-shadow:
        0 0 18px
        rgba(245, 158, 11, 0.55);
}

.yahtzee-celebration-subtitle {
    margin-top: 8px;

    font-size: 1.2rem;
    font-weight: 800;

    color: #ffffff;
}

@keyframes yahtzeeCelebrationPop {
    0% {
        transform:
            scale(0.65)
            rotate(-3deg);
    }

    65% {
        transform:
            scale(1.08)
            rotate(1deg);
    }

    100% {
        transform:
            scale(1)
            rotate(0deg);
    }
}

/* Hide number input spinner arrows */
.score-input::-webkit-inner-spin-button,
.score-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.score-input {
    appearance: textfield;
    -moz-appearance: textfield;
}
