:root {
    --ink: #171717;
    --muted: #6a6259;
    --line: #ded6ca;
    --paper: #f6f1e9;
    --panel: #fffaf3;
    --green: #1f7a55;
    --red: #b04335;
    --gold: #c99332;
    --blue: #254c77;
    --shadow: 0 18px 45px rgba(35, 27, 18, .12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--paper);
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

input,
select,
button {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

.entry-shell,
.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.brand-panel {
    padding: 36px 0 24px;
    max-width: 760px;
}

.brand-panel h1,
.topbar h1,
.display-header h1 {
    margin: 0;
    line-height: 1;
}

.brand-panel h1 {
    font-size: clamp(44px, 8vw, 84px);
    max-width: 720px;
}

.brand-panel p:not(.eyebrow) {
    color: var(--muted);
    font-size: 20px;
    line-height: 1.45;
    max-width: 680px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--blue);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.entry-grid,
.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    gap: 20px;
    align-items: start;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 22px;
}

.panel h2 {
    margin: 0 0 18px;
    font-size: 24px;
}

.round-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

label {
    display: grid;
    gap: 7px;
    margin-bottom: 15px;
    color: var(--muted);
    font-weight: 700;
}

label span {
    font-size: 13px;
}

input,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    padding: 12px 13px;
}

.button,
.icon-button {
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 800;
}

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    padding: 0 16px;
    background: var(--ink);
    color: #fff;
}

.button.secondary {
    background: var(--green);
}

.button.ghost {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
}

.button.danger {
    background: var(--red);
}

.button.warning {
    background: var(--gold);
    color: var(--ink);
}

.button.compact {
    min-height: 38px;
    padding: 0 12px;
}

.flash {
    margin: 0 0 16px;
    padding: 12px;
    border: 1px solid #e5b6a9;
    border-radius: 6px;
    color: #71291f;
    background: #fff1ed;
}

.topbar,
.panel-header,
.display-header,
.display-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar {
    padding-bottom: 22px;
}

.topbar h1 {
    font-size: clamp(34px, 5vw, 58px);
}

.top-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.controls-panel {
    min-width: 0;
}

.inline-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
    margin: 22px 0;
}

.inline-form label {
    margin: 0;
}

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

.player-row {
    display: grid;
    grid-template-columns: 44px 36px minmax(130px, 1fr) auto minmax(260px, 1.7fr) 40px;
    gap: 10px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.seat-actions {
    display: grid;
    gap: 4px;
}

.seat-button {
    display: grid;
    place-items: center;
    width: 30px;
    height: 26px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--blue);
    cursor: pointer;
    font-weight: 900;
}

.rank {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    color: #fff;
    background: var(--blue);
    font-weight: 900;
}

.player-meta {
    min-width: 0;
}

.player-meta strong,
.player-meta span {
    display: block;
    overflow-wrap: anywhere;
}

.player-meta span {
    color: var(--muted);
    font-weight: 800;
}

.player-meta span + span {
    font-size: 12px;
    font-weight: 700;
}

.quick-score-actions {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.quick-score-button {
    display: grid;
    place-items: center;
    min-width: 42px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f7eee4;
    color: var(--red);
    cursor: pointer;
    font-weight: 900;
}

.quick-score-button.add {
    background: #e8f3ed;
    color: var(--green);
}

.score-form {
    display: grid;
    grid-template-columns: 90px minmax(0, 1fr) auto;
    gap: 8px;
}

.icon-button {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    background: #f2e8dd;
    color: var(--red);
    font-size: 24px;
    line-height: 1;
}

.copy-link {
    margin: 6px 0 12px;
}

.starter-picker {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--line);
}

.starter-picker h2 {
    min-height: 34px;
    overflow-wrap: anywhere;
}

.starter-picker .button {
    width: 100%;
    margin: 4px 0 10px;
}

.saved-player-actions {
    display: grid;
    gap: 8px;
}

.saved-player-button {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    padding: 10px 12px;
    text-align: left;
}

.saved-player-button span {
    min-width: 0;
    overflow-wrap: anywhere;
    font-weight: 850;
}

.saved-player-button small {
    flex: 0 0 auto;
    color: var(--muted);
    font-weight: 800;
}

.static-person-row {
    cursor: default;
}

.muted,
.empty-state {
    color: var(--muted);
}

.danger-zone {
    display: grid;
    gap: 10px;
    padding-top: 24px;
}

.danger-zone .button {
    width: 100%;
}

.activity-panel {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.slim-header {
    margin-bottom: 12px;
}

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

.activity-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.activity-row strong,
.activity-row span {
    display: block;
    overflow-wrap: anywhere;
}

.activity-row span {
    color: var(--muted);
    font-weight: 700;
}

.saved-game-list,
.history-panel {
    display: grid;
    gap: 12px;
}

.saved-game-row,
.history-row {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.saved-game-row {
    grid-template-columns: minmax(0, 1fr) auto;
}

.saved-game-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.history-row {
    grid-template-columns: minmax(180px, 1fr) auto auto auto;
}

.compact-history-row {
    grid-template-columns: minmax(180px, 1fr) auto;
}

.saved-game-row strong,
.saved-game-row span,
.history-row strong,
.history-row span {
    display: block;
    overflow-wrap: anywhere;
}

.saved-game-row span,
.history-row span {
    color: var(--muted);
    font-weight: 700;
}

.compact-link {
    grid-column: 1 / -1;
    margin: 0;
    min-width: 0;
}

.display-screen {
    min-height: 100vh;
    padding: clamp(24px, 5vw, 54px);
    color: #fff;
    background:
        linear-gradient(135deg, rgba(20, 20, 20, .92), rgba(30, 45, 38, .9)),
        radial-gradient(circle at 20% 20%, rgba(201, 147, 50, .28), transparent 30%),
        #151515;
}

.display-header {
    padding-bottom: 28px;
    border-bottom: 1px solid rgba(255, 255, 255, .18);
}

.display-header .eyebrow {
    color: #f2c56c;
}

.display-header h1 {
    font-size: clamp(42px, 8vw, 96px);
}

.display-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.display-meta span,
.table-order-label,
.table-order-pill {
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 999px;
    background: rgba(255, 255, 255, .08);
    color: rgba(255, 255, 255, .78);
    padding: 8px 12px;
    font-weight: 850;
}

.round-badge {
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 8px;
    padding: 14px 18px;
    color: #f2c56c;
    font-size: clamp(20px, 3vw, 34px);
    font-weight: 900;
    white-space: nowrap;
}

.table-order-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 18px 0 0;
}

.table-order-label {
    color: #f2c56c;
}

.standings {
    display: grid;
    gap: 14px;
    padding: 32px 0;
}

.standing-row {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    min-height: 92px;
    padding: 16px 22px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 8px;
    background: rgba(255, 255, 255, .08);
}

.standing-row:first-child {
    border-color: rgba(242, 197, 108, .8);
    background: rgba(201, 147, 50, .16);
}

.standing-rank {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    border-radius: 999px;
    color: #151515;
    background: #f2c56c;
    font-size: 28px;
    font-weight: 950;
}

.standing-name {
    overflow-wrap: anywhere;
    font-size: clamp(26px, 4.5vw, 58px);
    font-weight: 900;
}

.standing-delta {
    margin-top: 5px;
    color: rgba(255, 255, 255, .66);
    font-size: clamp(15px, 1.8vw, 24px);
    font-weight: 850;
}

.standing-score {
    color: #f2c56c;
    font-size: clamp(32px, 6vw, 72px);
    font-weight: 950;
}

.display-activity {
    margin: 0 0 26px;
}

.display-activity h2 {
    margin: 0 0 12px;
    color: rgba(255, 255, 255, .72);
    font-size: 18px;
}

.display-activity-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 8px;
}

.display-activity-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 8px;
    background: rgba(255, 255, 255, .07);
    padding: 10px 12px;
}

.display-activity-row strong,
.display-activity-row span {
    overflow-wrap: anywhere;
}

.display-activity-row span {
    color: #f2c56c;
    font-weight: 850;
}

.display-footer {
    color: rgba(255, 255, 255, .65);
    font-weight: 700;
}

@media (max-width: 880px) {
    .entry-grid,
    .dashboard-grid,
    .score-form,
    .saved-game-row,
    .history-row,
    .compact-history-row {
        grid-template-columns: 1fr;
    }

    .topbar,
    .panel-header,
    .display-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .inline-form {
        grid-template-columns: 1fr;
    }

    .rank {
        width: 32px;
        height: 32px;
    }

    .standing-row {
        grid-template-columns: 52px minmax(0, 1fr);
    }

    .standing-score {
        grid-column: 2;
    }
}

@media (max-width: 720px) {
    .entry-shell,
    .app-shell {
        width: min(100% - 20px, 1180px);
        padding: 16px 0;
    }

    .panel {
        padding: 16px;
    }

    .topbar h1 {
        font-size: 38px;
    }

    .top-actions,
    .round-actions {
        width: 100%;
    }

    .top-actions .button,
    .round-actions .button,
    .inline-form .button {
        width: 100%;
    }

    .player-row {
        grid-template-columns: 42px minmax(0, 1fr) 42px;
        grid-template-areas:
            "rank meta remove"
            "seat quick quick"
            "score score score";
        align-items: start;
        gap: 12px;
        padding: 14px;
    }

    .rank {
        grid-area: rank;
        width: 36px;
        height: 36px;
    }

    .seat-actions {
        grid-area: seat;
        display: flex;
        gap: 6px;
    }

    .seat-button {
        width: 42px;
        height: 40px;
    }

    .player-meta {
        grid-area: meta;
        align-self: center;
    }

    .quick-score-actions {
        grid-area: quick;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }

    .quick-score-button {
        width: 100%;
        height: 44px;
    }

    .score-form {
        grid-area: score;
        grid-template-columns: 82px minmax(0, 1fr) auto;
        width: 100%;
    }

    .player-row > form:last-child {
        grid-area: remove;
        justify-self: end;
    }

    .icon-button {
        width: 42px;
        height: 40px;
    }

    .activity-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }
}

@media (max-width: 480px) {
    .brand-panel h1,
    .topbar h1 {
        font-size: 34px;
    }

    .score-form,
    .activity-row {
        grid-template-columns: 1fr;
    }

    .score-form .button,
    .activity-row .button {
        width: 100%;
    }

    .display-screen {
        padding: 18px;
    }
}
