:root {
    color-scheme: light;
    --bg: #f3ede2;
    --panel: #fffaf0;
    --panel-strong: #fff4df;
    --text: #1a1714;
    --muted: #5f554c;
    --line: #2f2a25;
    --accent: #126b5c;
    --ink: #8c2f39;
    --warm: #d3982b;
    --danger: #a2411a;
    --shadow: 10px 10px 0 rgba(47, 42, 37, 0.08);
    --game-shell-min-width: 1615px;
    --scrollbar-size: 8px;
    --scrollbar-thumb: rgba(47, 42, 37, 0.4);
    --scrollbar-thumb-hover: rgba(47, 42, 37, 0.56);
    font-family: Aptos, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    font-size: 18px;
    line-height: 1.45;
    background: var(--bg);
    color: var(--text);
    position: relative;
}

body::before {
    content: none;
}

.app-shell {
    margin: 0 auto;
    padding: 32px 0 48px;
    position: relative;
    z-index: 1;
    width: min(1740px, calc(100vw - 32px));
}

.hero {
    margin: 0 0 22px;
    padding: 6px 4px 18px;
    /* background: #fffdf9; */
    display: grid;
    justify-items: center;
    gap: 18px;
}

.hero h1 {
    margin: 0;
    padding: 14px 22px 18px;
    width: min(862px, 100%);
    background: #fff;
    border: 2px solid var(--line);
    border-radius: 10px 24px 10px 24px;
    box-shadow: 8px 8px 0 rgba(47, 42, 37, 0.14);
    font-family: Cambria, Georgia, serif;
    font-size: clamp(2.6rem, 4vw, 4.4rem);
    letter-spacing: -0.03em;
    color: #000;
    text-shadow: none;
}

.hero-word {
    display: inline-block;
}

.hero-word-cooperate {
    color: #000;
}

.hero-word-defect {
    color: #000;
}

.hero::after {
    content: "";
    width: min(862px, 100%);
    height: 4px;
    background: var(--line);
}

body.game-active .hero {
    display: none;
}

body.game-active .app-shell {
    padding-top: 4px;
    padding-bottom: 0;
    width: max(100%, var(--game-shell-min-width));
    max-width: none;
    padding-left: 10px;
    padding-right: 6px;
}

.players-textarea,
.round-column-panel,
.featured-pair-grid,
.leaderboard,
.compact-stat-grid,
.payoff-grid,
.history-list,
.bonus-pair-grid {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

.players-textarea::-webkit-scrollbar,
.round-column-panel::-webkit-scrollbar,
.featured-pair-grid::-webkit-scrollbar,
.leaderboard::-webkit-scrollbar,
.compact-stat-grid::-webkit-scrollbar,
.payoff-grid::-webkit-scrollbar,
.history-list::-webkit-scrollbar,
.bonus-pair-grid::-webkit-scrollbar {
    width: var(--scrollbar-size);
    height: var(--scrollbar-size);
}

.players-textarea::-webkit-scrollbar-track,
.round-column-panel::-webkit-scrollbar-track,
.featured-pair-grid::-webkit-scrollbar-track,
.leaderboard::-webkit-scrollbar-track,
.compact-stat-grid::-webkit-scrollbar-track,
.payoff-grid::-webkit-scrollbar-track,
.history-list::-webkit-scrollbar-track,
.bonus-pair-grid::-webkit-scrollbar-track {
    background: transparent;
}

.players-textarea::-webkit-scrollbar-thumb,
.round-column-panel::-webkit-scrollbar-thumb,
.featured-pair-grid::-webkit-scrollbar-thumb,
.leaderboard::-webkit-scrollbar-thumb,
.compact-stat-grid::-webkit-scrollbar-thumb,
.payoff-grid::-webkit-scrollbar-thumb,
.history-list::-webkit-scrollbar-thumb,
.bonus-pair-grid::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border: 2px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}

.players-textarea::-webkit-scrollbar-thumb:hover,
.round-column-panel::-webkit-scrollbar-thumb:hover,
.featured-pair-grid::-webkit-scrollbar-thumb:hover,
.leaderboard::-webkit-scrollbar-thumb:hover,
.compact-stat-grid::-webkit-scrollbar-thumb:hover,
.payoff-grid::-webkit-scrollbar-thumb:hover,
.history-list::-webkit-scrollbar-thumb:hover,
.bonus-pair-grid::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
    background-clip: padding-box;
}

.players-textarea::-webkit-scrollbar-button,
.round-column-panel::-webkit-scrollbar-button,
.featured-pair-grid::-webkit-scrollbar-button,
.leaderboard::-webkit-scrollbar-button,
.compact-stat-grid::-webkit-scrollbar-button,
.payoff-grid::-webkit-scrollbar-button,
.history-list::-webkit-scrollbar-button,
.bonus-pair-grid::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

.players-textarea::-webkit-scrollbar-corner,
.round-column-panel::-webkit-scrollbar-corner,
.featured-pair-grid::-webkit-scrollbar-corner,
.leaderboard::-webkit-scrollbar-corner,
.compact-stat-grid::-webkit-scrollbar-corner,
.payoff-grid::-webkit-scrollbar-corner,
.history-list::-webkit-scrollbar-corner,
.bonus-pair-grid::-webkit-scrollbar-corner {
    background: transparent;
}

.layout {
    display: grid;
    gap: 22px;
    transform: translateY(0);
}

.setup-layout {
    grid-template-columns: 1fr;
    align-items: start;
}

.game-layout {
    grid-template-columns: 1fr;
    align-items: start;
}

.game-stage {
    display: grid;
    width: 100%;
    min-width: 0;
    min-height: calc(100vh - 18px);
    justify-items: stretch;
    align-items: stretch;
}

.game-stage-fill {
    justify-items: stretch;
    align-items: stretch;
}

.game-stage-align-top-left {
    justify-items: start;
    align-items: start;
}

.game-stage-align-top-middle {
    justify-items: center;
    align-items: start;
}

.game-stage-align-middle-left {
    justify-items: start;
    align-items: center;
}

.game-stage-align-middle-middle {
    justify-items: center;
    align-items: center;
}

@media (min-width: 961px) {
    html.game-active,
    body.game-active {
        min-width: var(--game-shell-min-width);
        overflow-x: auto;
        overflow-y: hidden;
    }

    html.game-active.fixed-width-layout,
    body.game-active.fixed-width-layout {
        overflow-x: auto;
    }

    html.game-active.fixed-height-layout,
    body.game-active.fixed-height-layout {
        overflow-y: auto;
    }

    body.game-active .game-main-grid {
        margin-right: 6px;
    }
}

.custom-scroll-host {
    scrollbar-width: none;
}

.custom-scroll-shell {
    position: relative;
}

.custom-scroll-host::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.custom-scrollbar-track {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: var(--scrollbar-size);
    z-index: 2;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.custom-scrollbar-track[hidden] {
    display: none;
}

.custom-scroll-shell:hover .custom-scrollbar-track,
.custom-scroll-shell:focus-within .custom-scrollbar-track,
.custom-scroll-shell-active .custom-scrollbar-track,
.custom-scrollbar-track:hover,
.custom-scrollbar-track.dragging {
    opacity: 1;
    pointer-events: auto;
}

.custom-scroll-shell-active .custom-scrollbar-track {
    transition: none;
}

.custom-scrollbar-thumb {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    min-height: 28px;
    background: var(--scrollbar-thumb);
    border: 2px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}

.custom-scrollbar-track:hover .custom-scrollbar-thumb,
.custom-scrollbar-track.dragging .custom-scrollbar-thumb {
    background: var(--scrollbar-thumb-hover);
    background-clip: padding-box;
}

.panel {
    position: relative;
    background: var(--panel);
    border: 2px solid var(--line);
    border-radius: 12px 32px 12px 32px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.panel::before {
    content: "";
    position: absolute;
    top: -2px;
    left: 24px;
    width: 88px;
    height: 10px;
    background: var(--warm);
    border-radius: 0 0 8px 8px;
}

.panel-wide {
    grid-column: 1 / -1;
}

.panel h2,
.panel h3,
.panel p {
    margin-top: 0;
}

.panel h2,
.panel h3 {
    font-family: Cambria, Georgia, serif;
}

.panel h2 {
    font-size: clamp(1.75rem, 2.2vw, 2.4rem);
}

.panel h3 {
    font-size: 1.35rem;
}

.panel-copy,
.muted,
small,
label span {
    color: var(--muted);
}

.panel-kicker {
    margin: 0 0 6px;
    color: var(--ink);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.72rem;
    font-weight: 700;
}

.inset {
    background: var(--panel-strong);
    box-shadow: none;
    border-radius: 8px 28px 8px 28px;
}

.rule-list {
    margin: 0;
    padding-left: 18px;
}

.grid {
    display: grid;
    gap: 16px;
}

.two-up {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-grid {
    gap: 12px;
}

label {
    display: grid;
    gap: 8px;
    font-weight: 600;
}

.field-stack {
    display: grid;
    gap: 8px;
    font-weight: 600;
}

.field-stack > span {
    color: var(--muted);
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 2px solid rgba(47, 42, 37, 0.5);
    border-radius: 14px;
    padding: 14px 16px;
    background: #fffdf9;
    color: var(--text);
}

textarea {
    resize: none;
}

.players-textarea {
    height: 190px;
    min-height: 190px;
    max-height: 190px;
    overflow: auto;
    background: #fffdf9;
}

.input-suffix-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
}

.input-suffix {
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}

.toggle-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.number-stepper {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 52px 52px;
    gap: 10px;
    align-items: baseline;
    isolation: isolate;
}

.stepper-button {
    display: grid;
    place-items: center;
    padding: 0;
    min-height: 52px;
    font-size: 1.6rem;
    line-height: 1;
    text-align: center;
    transform: translate(0, 0);
}

.stepper-button:hover {
    transform: none;
    box-shadow: 6px 6px 0 rgba(47, 42, 37, 0.14);
}

.stepper-button:active {
    transform: translate(1px, 1px);
    box-shadow: 2px 2px 0 rgba(47, 42, 37, 0.12);
    background: #f5ecdd;
}

.stepper-button:focus-visible {
    outline: 3px solid rgba(18, 107, 92, 0.2);
    outline-offset: 2px;
}

.stepper-symbol {
    display: block;
    line-height: 1;
}

.stepper-symbol-minus {
    transform: translateX(-2px) translateY(-3px);
}

.stepper-symbol-plus {
    transform: translateX(-6px) translateY(-2px);
}

.stepper-input {
    appearance: textfield;
    text-align: center;
    background: #fffdf9;
    border: 2px solid rgba(47, 42, 37, 0.5);
    border-radius: 14px;
    padding: 14px 16px;
    color: var(--text);
}

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

.choice-option {
    position: relative;
    display: grid;
    min-height: 74px;
    align-items: stretch;
    border: 2px solid var(--line);
    border-radius: 12px 22px 12px 22px;
    background: #fffdf9;
    cursor: pointer;
    overflow: hidden;
}

.choice-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.choice-option span {
    display: grid;
    place-items: center;
    min-height: 100%;
    padding: 14px 16px;
    text-align: center;
    font-weight: 700;
    color: var(--text);
}

.choice-option.active {
    border-color: #8f4a24;
    background: #f4b183;
    box-shadow: 6px 6px 0 rgba(143, 74, 36, 0.18);
}

.choice-option.active span {
    color: #402013;
}

.choice-option:not(.active) {
    background: #fffdf9;
}

.choice-option:hover {
    transform: translate(-1px, -1px);
}

.choice-option:focus-within {
    outline: 3px solid rgba(143, 74, 36, 0.18);
    outline-offset: 2px;
}

.checkbox-row {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 2px solid rgba(47, 42, 37, 0.2);
    border-radius: 10px 20px 10px 20px;
    background: #fffaf2;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.checkbox-row input {
    appearance: none;
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    margin: 0;
    flex: 0 0 24px;
    border: 2px solid var(--line);
    border-radius: 7px;
    background: #fffdf9;
    display: grid;
    place-items: center;
    box-shadow: inset 0 0 0 0 var(--accent);
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.checkbox-row input::after {
    content: "";
    width: 7px;
    height: 11px;
    border-right: 3px solid white;
    border-bottom: 3px solid white;
    transform: translate(-4px, -7px) rotate(45deg) scale(0.72);
    transform-origin: center;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.checkbox-row input:checked {
    background: var(--accent);
    border-color: var(--accent-strong);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.checkbox-row input:checked::after {
    opacity: 1;
}

.checkbox-row:hover {
    transform: translate(-1px, -1px);
    border-color: rgba(18, 107, 92, 0.36);
    box-shadow: 6px 6px 0 rgba(47, 42, 37, 0.08);
}

.checkbox-row:focus-within {
    border-color: var(--accent-strong);
    box-shadow: 0 0 0 3px rgba(18, 107, 92, 0.14);
}

.checkbox-row:has(input:checked) {
    background: #edf6f3;
    border-color: rgba(18, 107, 92, 0.45);
}

.button {
    border: 2px solid var(--line);
    border-radius: 12px 22px 12px 22px;
    padding: 14px 22px;
    min-height: 54px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 5px 5px 0 rgba(47, 42, 37, 0.12);
    transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

.button:hover {
    transform: translate(-1px, -1px);
    box-shadow: 7px 7px 0 rgba(47, 42, 37, 0.14);
}

.button:active {
    transform: translate(1px, 1px);
    box-shadow: 3px 3px 0 rgba(47, 42, 37, 0.12);
}

.button.primary {
    background: var(--accent);
    color: white;
}

.button.secondary {
    background: #f7efe4;
    color: var(--ink);
}

.button.danger {
    background: #f6d8c8;
    color: var(--danger);
}

.button.action-sky {
    background: #d9ebf8;
    color: #2d6c9f;
}

.button.action-gold {
    background: #f7ebc6;
    color: #8a6200;
}

.button.action-rose {
    background: #f7dfe2;
    color: #8a3550;
}

.button.action-mint {
    background: #efe3c3;
    color: #6b5430;
}

.button.action-plum {
    background: #eedff0;
    color: #6f3f74;
}

.button.action-amber {
    background: #fde7bd;
    color: #8c5e00;
}

.stage-panel::before,
.round-desk::before {
    background: var(--accent);
}

.launch-panel::before {
    background: var(--ink);
}

.section-heading,
.control-strip,
.leaderboard-row,
.pair-header,
.payoff-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.control-strip {
    flex-wrap: wrap;
    /* margin-top: 18px; */
}

.modal-actions-right {
    justify-content: flex-end;
}

.control-strip.vertical {
    flex-direction: column;
    align-items: stretch;
}

.wide-button {
    width: 100%;
    justify-content: center;
}

.stage-panel,
.round-desk {
    overflow: hidden;
}

.stage-header {
    display: flex;
    align-items: start;
    justify-content: flex-start;
    gap: 18px;
    margin-bottom: 10px;
}
.compact-stage-header {
    margin-bottom: 12px;
}

.setup-main-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 420px));
    gap: 22px;
    align-items: start;
    justify-content: center;
}

.feature-panel {
    padding: 18px 18px 20px;
}

.setup-layout {
    position: relative;
    padding: 18px 20px 22px;
    border-radius: 26px 38px 26px 38px;
    /* background: #eadcc6; */
}

.setup-panel-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
}

.setup-panel-header h2 {
    margin-bottom: 0;
}

.setup-play-button {
    width: 100%;
    min-width: 0;
}

.setup-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    align-items: start;
}

.setup-player-section {
    display: grid;
    gap: 22px;
    align-content: start;
    margin-top: 10px;
}

.setup-player-section h3 {
    margin-bottom: 0;
}

.setup-options-panel {
    display: grid;
    gap: 14px;
    align-content: start;
}

.players-panel,
.launch-panel {
    display: grid;
    gap: 14px;
    align-content: start;
    padding: 18px 18px 20px;
    min-height: 412px;
}

.players-panel {
    background: #f8dab6;
}

.players-panel::before {
    background: #d46f3b;
}

.launch-panel {
    background: #dfe9f7;
}

.launch-panel::before {
    background: #466a9c;
}

.setup-layout .details-block {
    background: #fff8ee;
    box-shadow: 6px 6px 0 rgba(70, 106, 156, 0.08);
}

.setup-layout .details-block summary {
    background: #fff7ef;
    color: #7a3527;
    border-left-color: #d89a32;
}

.setup-layout .setup-panel-header h2 {
    color: #2c2c2c;
}

.setup-layout .field-stack > span,
.setup-layout label span,
.setup-layout .panel-copy,
.setup-layout .muted {
    color: #7a3527;
}

.players-count-field {
    width: 100%;
    max-width: none;
    min-height: 222px;
    display: grid;
    grid-template-rows: auto minmax(190px, auto);
    align-content: start;
}

.players-textarea-wrap {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.launch-card {
    padding: 0;
}

.details-block {
    border: 2px solid var(--line);
    border-radius: 10px 24px 10px 24px;
    background: var(--panel-strong);
    overflow: hidden;
}

.details-block summary {
    list-style: none;
    cursor: pointer;
    padding: 14px 16px;
    font-weight: 700;
    color: var(--ink);
    border-left: 10px solid var(--warm);
}

.details-block summary::-webkit-details-marker {
    display: none;
}

.details-block summary::after {
    content: "+";
    float: right;
    color: var(--muted);
}

.details-block[open] summary::after {
    content: "−";
}

.details-content {
    padding: 0 16px 16px;
    display: grid;
    gap: 12px;
}

.details-block:not([open]) > :not(summary) {
    display: none;
}

.inline-details {
    margin-top: 14px;
}

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

.game-main-grid {
    display: grid;
    grid-template-columns: minmax(900px, 1fr) 687px;
    gap: 12px;
    width: var(--game-stage-width, 100%);
    align-items: stretch;
    height: var(--game-stage-height, calc(100vh - 18px));
    min-height: 0;
    min-width: 0;
}

.game-side-grid {
    display: grid;
    grid-template-columns: 300px 375px;
    gap: 12px;
    width: 100%;
    align-items: stretch;
    min-height: 0;
    min-width: 687px;
}

.game-side-rail {
    display: grid;
    gap: 12px;
    align-content: stretch;
    grid-template-rows: repeat(2, minmax(0, 1fr));
    width: 100%;
    min-height: 0;
    min-width: 0;
}

.timer-card {
    min-width: 180px;
    margin-left: auto;
    text-align: right;
    padding: 18px 20px;
    border-radius: 10px 24px 10px 24px;
    background: #fff2c9;
    border: 2px solid var(--line);
    box-shadow: none;
}

.timer-card strong {
    display: block;
    font-size: 3rem;
}

.timer-label,
.stat-label {
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.75rem;
    color: var(--muted);
}

.timer-setting {
    margin-top: 8px;
    text-align: right;
}

.timer-input-wrap {
    justify-content: end;
}

.timer-input-wrap input {
    max-width: 110px;
}

.embedded-timer-card {
    min-width: 160px;
    margin-left: 0;
}

.pairings-main-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    background: #fff1c4;
    overflow: hidden;
}

.pairings-main-panel::before {
    background: #d3982b;
}

.round-column-panel {
    padding-right: 10px;
    max-width: none;
    width: 100%;
    min-width: 900px;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.final-standings-panel {
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at top left, rgba(255, 223, 135, 0.32), transparent 34%),
        radial-gradient(circle at bottom right, rgba(45, 108, 159, 0.14), transparent 38%),
        #fff8ef;
}

.final-celebration-card {
    display: grid;
    justify-items: center;
    gap: 16px;
    width: min(720px, 100%);
    max-height: 100%;
    padding: 32px 28px 28px;
    border: 2px solid rgba(47, 42, 37, 0.14);
    border-radius: 24px 44px 24px 44px;
    background: rgba(255, 253, 248, 0.92);
    box-shadow: 16px 16px 0 rgba(45, 108, 159, 0.12);
    text-align: center;
    overflow: auto;
}

.final-celebration-copy {
    display: grid;
    gap: 8px;
    max-width: 580px;
    width: 100%;
}

.final-celebration-copy h2 {
    margin: 0;
    font-size: clamp(1.6rem, 2vw, 2.4rem);
}

.final-kicker {
    margin: 0;
    color: #8a6200;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.round-card-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
    /* margin-bottom: 18px; */
}

.round-card-copy {
    display: grid;
    gap: 10px;
}

.round-card-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    justify-content: flex-end;
    align-items: stretch;
}

.round-timer-card {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    min-width: 86px;
    padding: 8px 14px;
    border: 2px solid var(--line);
    border-radius: 999px;
    background: #fff2c9;
    color: var(--line);
    font-family: Cambria, Georgia, serif;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
}

.pairings-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: start;
    margin-bottom: 18px;
}

.pairings-timer {
    justify-self: center;
    align-self: start;
    font-family: Cambria, Georgia, serif;
    font-size: clamp(2rem, 3vw, 3rem);
    font-weight: 700;
    line-height: 1;
    color: var(--line);
}

.pairings-heading-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    align-self: start;
    align-items: start;
}

.more-actions-details {
    min-width: 152px;
    width: fit-content;
    position: relative;
    background: transparent;
    border: 0;
    box-shadow: none;
    overflow: visible;
}

.more-actions-details::before {
    display: none;
}

.more-actions-label-desktop {
    display: inline;
}

.more-actions-label-mobile {
    display: none;
}

.more-actions-item-label-desktop {
    display: inline;
}

.more-actions-item-label-mobile {
    display: none;
}

.more-actions-details.compact-more-actions-label {
    min-width: 0;
}

.more-actions-details.compact-more-actions-label .more-actions-label-desktop {
    display: none;
}

.more-actions-details.compact-more-actions-label .more-actions-label-mobile {
    display: inline;
}

.more-actions-details.compact-more-actions-label .more-actions-item-label-desktop {
    display: none;
}

.more-actions-details.compact-more-actions-label .more-actions-item-label-mobile {
    display: inline;
}

.more-actions-details summary {
    padding: 12px 14px;
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-left-width: 0;
    border: 2px solid var(--line);
    border-radius: 10px 18px 10px 18px;
    background: #fffdf9;
    color: var(--text);
}

.more-actions-details summary::after {
    margin-left: 12px;
    float: none;
}

.more-actions-details[open] summary {
    margin-bottom: 0;
}

.more-actions-content {
    position: absolute;
    left: 0;
    top: calc(100% + 4px);
    z-index: 5;
     min-width: 0;
     width: max-content;
    padding: 0;
}

.more-actions-grid {
    display: grid;
    gap: 10px;
    padding: 14px;
    background: #fffaf0;
    border: 2px solid var(--line);
    border-radius: 10px 18px 10px 18px;
    box-shadow: 8px 8px 0 rgba(47, 42, 37, 0.1);
     justify-items: center;
}

.more-actions-grid .button {
     width: auto;
     min-width: 214px;
    transform: none;
    transition: box-shadow 0.15s ease, opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.more-actions-details.compact-more-actions-label .more-actions-grid .button {
    min-width: 0;
}

.more-actions-details.compact-more-actions-label .more-actions-grid {
    justify-items: stretch;
}

.more-actions-details.compact-more-actions-label .more-actions-grid .button {
    width: 100%;
}

.more-actions-grid .button:hover,
.more-actions-grid .button:active {
    transform: none;
}

.more-actions-grid .button:hover {
    box-shadow: 5px 5px 0 rgba(47, 42, 37, 0.12);
}

.more-actions-grid .button:active {
    box-shadow: inset 0 0 0 2px rgba(47, 42, 37, 0.12);
}

.pair-grid,
.stat-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.featured-pair-grid {
    gap: 14px;
    grid-template-columns: repeat(2, minmax(340px, 1fr));
    min-height: 0;
    align-content: start;
    overflow: auto;
    padding-right: 10px;
    scrollbar-gutter: stable;
}

.pair-card {
    padding: 16px;
    min-width: 266px;
    border-radius: 10px 24px 10px 24px;
    background: var(--panel-strong);
    border: 2px solid rgba(47, 42, 37, 0.2);
}

.stat-card,
.history-entry {
    padding: 16px;
    min-width: 280px;
    border-radius: 10px 24px 10px 24px;
    background: var(--panel-strong);
    border: 2px solid rgba(47, 42, 37, 0.2);
}

.featured-pair-grid .pair-card {
    background: #fffdf7;
    border-color: var(--accent);
    box-shadow: 8px 8px 0 rgba(18, 107, 92, 0.12);
}

.winner-message {
    font-size: clamp(1.9rem, 3vw, 3.1rem);
    font-weight: 800;
    color: var(--accent-strong);
    letter-spacing: -0.03em;
    line-height: 1.04;
    margin: 0;
}

.winner-score {
    margin: 0;
    font-family: Cambria, Georgia, serif;
    font-size: clamp(1.55rem, 2.4vw, 2.5rem);
    font-weight: 700;
    color: #8a6200;
    line-height: 1;
}

.winner-detail {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.bye-card {
    background: rgba(217, 119, 6, 0.08);
}

.pair-separator {
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.pair-choice-row {
    display: grid;
    gap: 14px;
    align-items: start;
}

.pair-card-layout {
    display: grid;
    gap: 10px;
    align-items: start;
}

.pair-card-rows {
    grid-template-columns: 1fr;
}

.pair-player-row {
    display: grid;
    grid-template-columns: minmax(118px, 146px) minmax(0, 1fr);
    gap: 4px;
    align-items: center;
}

.pair-column {
    display: grid;
    gap: 14px;
    justify-items: start;
    text-align: left;
    padding-right: 10px;
    scrollbar-gutter: stable;
}

.pair-column-left {
    grid-column: 1;
}

.pair-column-right {
    grid-column: 1;
}

.choice-button-stack {
    display: grid;
    gap: 8px;
    width: 100%;
}

.choice-button-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
    max-width: 100%;
}

.choice-button-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.choice-button {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    align-items: center;
    justify-content: start;
    gap: 5px;
    min-height: 44px;
    padding: 8px 11px;
    min-width: 0;
    width: 100%;
    border-radius: 10px 18px 10px 18px;
    background: #fffdf9;
    color: var(--text);
    box-shadow: none;
    text-align: left;
    overflow: hidden;
}

.choice-button.no-choice-icons {
    grid-template-columns: minmax(0, 1fr) auto;
}

.choice-symbol {
    width: 24px;
    height: 24px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(47, 42, 37, 0.08);
    font-size: 0.86rem;
    font-weight: 800;
    flex: 0 0 24px;
}

.choice-symbol svg {
    width: 16px;
    height: 16px;
    display: block;
}

.choice-text {
    display: block;
    font-size: 0.9rem;
    white-space: nowrap;
}

.choice-points {
    justify-self: end;
    font-weight: 800;
    font-size: 0.94rem;
    white-space: nowrap;
    padding-left: 2px;
}

.choice-button.cooperate.active {
    background: #dff2eb;
    border-color: var(--accent);
    color: var(--accent-strong);
    box-shadow: 6px 6px 0 rgba(18, 107, 92, 0.12);
}

.choice-button.defect.active {
    background: #f8e0d4;
    border-color: var(--danger);
    color: var(--danger);
    box-shadow: 6px 6px 0 rgba(162, 65, 26, 0.12);
}

.choice-button.random.active {
    background: #f7ebc6;
    border-color: var(--warm);
    color: #7b5700;
    box-shadow: 6px 6px 0 rgba(211, 152, 43, 0.14);
}

.pair-player-block {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.player-icon {
    --icon-primary: var(--accent);
    --icon-secondary: #dff2eb;
    --icon-pattern: radial-gradient(circle at 50% 50%, var(--icon-primary) 0 18%, transparent 19%);
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border: 2px solid var(--icon-primary);
    border-radius: 50%;
    background: var(--icon-pattern), var(--icon-secondary);
}

.player-icon.tone-mint {
    --icon-primary: #126b5c;
    --icon-secondary: #dff2eb;
}

.player-icon.tone-coral {
    --icon-primary: #b54f34;
    --icon-secondary: #f8e0d4;
}

.player-icon.tone-gold {
    --icon-primary: #a46a00;
    --icon-secondary: #f7ebc6;
}

.player-icon.tone-sky {
    --icon-primary: #2d6c9f;
    --icon-secondary: #d9ebf8;
}

.player-icon.tone-plum {
    --icon-primary: #7a4b7f;
    --icon-secondary: #eedff0;
}

.player-icon.tone-slate {
    --icon-primary: #4a5d69;
    --icon-secondary: #dfe6ea;
}

.player-icon.shape-circle {
    border-radius: 50%;
}

.player-icon.shape-rounded {
    border-radius: 10px;
}

.player-icon.shape-diamond {
    border-radius: 8px;
    transform: scale(0.78) rotate(45deg);
}

.player-icon.shape-pill {
    border-radius: 999px;
}

.player-icon.shape-diamond::before {
    content: "";
    position: absolute;
}

.player-icon.pattern-rings {
    --icon-pattern:
        radial-gradient(circle at 50% 50%, var(--icon-primary) 0 16%, transparent 17% 30%, var(--icon-primary) 31% 38%, transparent 39%);
}

.player-icon.pattern-stripes {
    --icon-pattern:
        repeating-linear-gradient(135deg, var(--icon-primary) 0 5px, transparent 5px 10px);
}

.player-icon.pattern-grid {
    --icon-pattern:
        linear-gradient(var(--icon-primary), var(--icon-primary)),
        linear-gradient(90deg, var(--icon-primary), var(--icon-primary));
    background-size: 100% 5px, 5px 100%;
    background-position: center;
    background-repeat: no-repeat;
    background-color: var(--icon-secondary);
}

.player-icon.pattern-burst {
    --icon-pattern:
        conic-gradient(from 0deg, var(--icon-primary) 0 20deg, transparent 20deg 40deg, var(--icon-primary) 40deg 60deg, transparent 60deg 80deg, var(--icon-primary) 80deg 100deg, transparent 100deg 120deg, var(--icon-primary) 120deg 140deg, transparent 140deg 160deg, var(--icon-primary) 160deg 180deg, transparent 180deg 200deg, var(--icon-primary) 200deg 220deg, transparent 220deg 240deg, var(--icon-primary) 240deg 260deg, transparent 260deg 280deg, var(--icon-primary) 280deg 300deg, transparent 300deg 320deg, var(--icon-primary) 320deg 340deg, transparent 340deg 360deg);
}

.player-icon.pattern-split {
    --icon-pattern:
        linear-gradient(135deg, var(--icon-primary) 0 50%, transparent 50% 100%);
}

.pair-player-name {
    font-weight: 700;
    font-size: clamp(0.88rem, 0.82rem + 0.22vw, 1.06rem);
    line-height: 1;
    letter-spacing: -0.02em;
    min-width: 0;
    white-space: nowrap;
}

.leaderboard {
    display: grid;
    gap: 10px;
    min-height: 0;
    overflow: auto;
    padding-right: 8px;
    scrollbar-gutter: stable;
}

.compact-stat-grid {
    grid-template-columns: repeat(2, minmax(156px, 1fr));
    align-items: stretch;
     align-content: start;
    min-height: 0;
    overflow: auto;
    padding-right: 8px;
    gap: 8px;
    scrollbar-gutter: stable;
}

.pie-stat-card {
    grid-column: 1 / -1;
     padding: 8px 12px 8px;
    align-content: start;
}

.decision-pie-wrap {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.decision-pie {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: conic-gradient(var(--accent) 0deg var(--cooperate-angle), var(--danger) var(--cooperate-angle) 360deg);
    border: 2px solid rgba(47, 42, 37, 0.18);
    box-shadow: inset 0 0 0 9px #fffaf0;
}

.decision-pie-legend {
    display: grid;
    gap: 6px;
    align-content: center;
}

.stat-callout-card {
    padding: 10px 14px;
    min-width: 0;
}

.stat-callout-card .stat-label {
    white-space: nowrap;
}

.stat-callout {
    display: grid;
    gap: 6px;
    width: 100%;
}

.stat-callout.has-tooltip {
    width: 100%;
    cursor: default;
}

.stat-callout-names,
.stat-callout-detail,
.stat-callout-hint {
    display: block;
}

.stat-callout-detail,
.stat-callout-hint {
    color: var(--muted);
    font-size: 0.96rem;
    font-weight: 600;
}

.stat-callout-hint {
    font-size: 0.88rem;
}

.floating-tooltip {
    position: fixed;
    left: 0;
    top: 0;
    width: max-content;
    min-width: 0;
    max-width: min(360px, calc(100vw - 24px));
    padding: 8px 10px;
    border: 2px solid var(--line);
    border-radius: 10px 18px 10px 18px;
    background: var(--panel);
    box-shadow: 8px 8px 0 rgba(47, 42, 37, 0.12);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.35;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
    transform: translateY(4px);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.floating-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.decision-legend {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.96rem;
}

.decision-legend::before {
    content: "";
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: currentColor;
}

.decision-legend.cooperate {
    color: var(--accent);
}

.decision-legend.defect {
    color: var(--danger);
}

.leaderboard-row {
    padding: 14px 16px;
    background: var(--panel-strong);
    border-radius: 10px 18px 10px 18px;
    border: 2px solid rgba(47, 42, 37, 0.15);
}

.leader-player {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.leaderboard-player-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
}

.leader-rank {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    background: #d8efe9;
    font-weight: 700;
}

.leader-name {
    flex: 1;
    font-weight: 600;
    font-size: clamp(0.92rem, 0.84rem + 0.24vw, 1.1rem);
    line-height: 1.18;
    letter-spacing: -0.02em;
    min-width: 0;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
}

.leader-score {
    font-size: 1.45rem;
    font-weight: 700;
}

.payoff-grid,
.history-list {
    display: grid;
    gap: 8px;
}

.payoff-grid {
    min-height: 0;
    overflow: auto;
    padding-right: 10px;
    scrollbar-gutter: stable;
}

.leaderboard-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    height: 100%;
    width: 100%;
    min-width: 300px;
    padding-right: 10px;
    background: #dcefe9;
}

.leaderboard-panel::before {
    background: #126b5c;
}

.stats-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    height: 100%;
    overflow: hidden;
    width: 100%;
    min-width: 375px;
    padding-right: 10px;
    background: #f7ddd0;
}

.stats-panel::before {
    background: #b54f34;
}

.payoff-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    height: 100%;
    overflow: hidden;
    width: 100%;
    min-width: 375px;
    padding-right: 10px;
    background: #dfe7f8;
}

.payoff-panel::before {
    background: #2d6c9f;
}

.payoff-matrix-header {
    display: grid;
    grid-template-columns: 38px repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0 4px 2px 0;
    align-items: end;
}

.payoff-matrix-spacer {
    display: block;
}

.payoff-column-heading {
    color: var(--muted);
    font-weight: 700;
    text-align: center;
}

.payoff-row {
    display: grid;
    grid-template-columns: 38px repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0;
    background: transparent;
    border-radius: 0;
    align-items: center;
    border: 0;
}

.payoff-label {
    min-width: 38px;
    font-weight: 700;
}

.notice {
    color: var(--accent-strong);
    font-weight: 600;
}

.settings-stack {
    display: grid;
    gap: 14px;
}

.compact-settings-grid {
    gap: 16px;
}

.settings-row {
    display: grid;
    gap: 14px;
}

.settings-row-two-up {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.settings-row-layout-detail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.modal-panel-body {
    display: grid;
    gap: 16px;
}

.modal-card-wide {
    --modal-card-width: 1120px;
}

.modal-card-payoff-twist {
    --modal-card-width: 560px;
}

.modal-card-layout-settings {
    --modal-card-width: 560px;
}

.modal-card-aside {
    width: min(780px, calc(100vw - 440px));
    max-height: calc(100vh - 48px);
    overflow: auto;
}

.payoff-preview-grid {
    display: grid;
    gap: 10px;
}

.payoff-preview-header,
.payoff-preview-row {
    display: grid;
    grid-template-columns: minmax(64px, 82px) repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: center;
}

.payoff-preview-header {
    color: var(--muted);
    font-weight: 700;
    text-align: center;
}

.payoff-preview-label {
    font-weight: 700;
    text-align: center;
}

.payoff-preview-value {
    display: grid;
    place-items: center;
    min-height: 54px;
    padding: 10px 12px;
    border: 2px solid rgba(47, 42, 37, 0.18);
    border-radius: 12px;
    background: #fffdf7;
    font-weight: 700;
}

.bonus-round-shell {
    display: grid;
    gap: 18px;
}

.bonus-round-header {
    align-items: start;
}

.bonus-round-actions {
    margin-top: 0;
    justify-content: flex-end;
}

.bonus-pair-grid {
    max-height: min(56vh, 640px);
    overflow: auto;
    padding-right: 4px;
}

.payoff-panel .payoff-grid {
    margin-top: 8px;
    align-content: start;
}

.game-settings-details .details-content {
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 0;
}

.compact-payoff-grid .payoff-row {
    padding: 0;
}

.compact-payoff-grid .payoff-row label span {
    font-size: 0.84rem;
}

.compact-payoff-grid {
    gap: 6px;
}

.compact-payoff-grid .payoff-matrix-header {
    gap: 8px;
    padding: 0 4px 2px 0;
}

.compact-payoff-grid .payoff-row {
    grid-template-columns: 28px repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.compact-payoff-grid input {
    min-height: 36px;
    padding: 6px 8px;
}

.history-points {
    margin: 8px 0 0;
    padding-left: 18px;
}

.history-details {
    background: transparent;
    border: 0;
    box-shadow: none;
}

.history-details summary {
    border-left: 0;
}

.history-details .details-content {
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 0;
}

.history-details .history-list {
    margin-top: 4px;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.94rem;
}

.history-table th,
.history-table td {
    padding: 8px 10px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid rgba(47, 42, 37, 0.12);
}

.history-table th {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.74rem;
    color: var(--muted);
}

.history-list {
    overflow: auto;
    padding-right: 10px;
    scrollbar-gutter: stable;
}

.history-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.modal-title-row {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.modal-title-row h2 {
    margin-bottom: 0;
}

.modal-title-actions {
    margin-top: 0;
    justify-content: flex-end;
    flex-wrap: nowrap;
    align-items: stretch;
}

.modal-close-button {
    min-height: 48px;
    padding: 10px 16px;
}

.export-history-button {
    background: #f7ebc6;
    color: #8a6200;
    min-height: 48px;
}

.stat-card strong {
    display: block;
    font-size: 1.45rem;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(26, 23, 20, 0.32);
    z-index: 20;
}

.modal-backdrop-aside {
    place-items: start;
    padding: 24px clamp(18px, 3vw, 34px);
    background: linear-gradient(90deg, rgba(26, 23, 20, 0.24) 0%, rgba(26, 23, 20, 0.14) 56%, rgba(26, 23, 20, 0.04) 100%);
}

.modal-card {
    width: min(var(--modal-card-width, 460px), 100%);
    padding: 24px;
    background: #fffaf0;
    border: 2px solid var(--line);
    border-radius: 12px 28px 12px 28px;
    box-shadow: 12px 12px 0 rgba(47, 42, 37, 0.12);
}

html.game-active.mobile-layout-mode,
body.game-active.mobile-layout-mode {
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

body.game-active.mobile-layout-mode .app-shell {
    width: 100%;
    min-width: 375px;
    padding-left: 10px;
    padding-right: 10px;
}

body.game-active.mobile-layout-mode .game-stage {
    min-height: 0;
}

body.game-active.mobile-layout-mode .game-main-grid {
    grid-template-columns: 1fr;
    width: 100%;
    height: auto;
    min-width: 375px;
}

body.game-active.mobile-layout-mode .game-side-grid {
    grid-template-columns: 1fr;
    min-width: 375px;
}

body.game-active.mobile-layout-mode .game-side-rail,
body.game-active.mobile-layout-mode .leaderboard-panel,
body.game-active.mobile-layout-mode .stats-panel,
body.game-active.mobile-layout-mode .payoff-panel,
body.game-active.mobile-layout-mode .round-column-panel {
    width: 100%;
    min-width: 375px;
    height: auto;
    min-height: 0;
}

body.game-active.mobile-layout-mode .leaderboard,
body.game-active.mobile-layout-mode .compact-stat-grid,
body.game-active.mobile-layout-mode .payoff-grid,
body.game-active.mobile-layout-mode .featured-pair-grid,
body.game-active.mobile-layout-mode .round-column-panel {
    overflow: visible;
    max-height: none;
}

body.game-active.mobile-layout-mode .section-heading,
body.game-active.mobile-layout-mode .pair-header,
body.game-active.mobile-layout-mode .payoff-row,
body.game-active.mobile-layout-mode .stage-header {
    flex-direction: column;
    align-items: flex-start;
}

body.game-active.mobile-layout-mode .game-dual-grid,
body.game-active.mobile-layout-mode .compact-stat-grid,
body.game-active.mobile-layout-mode .choice-button-group,
body.game-active.mobile-layout-mode .featured-pair-grid,
body.game-active.mobile-layout-mode .pair-card-layout,
body.game-active.mobile-layout-mode .pair-player-row,
body.game-active.mobile-layout-mode .settings-row-two-up {
    grid-template-columns: 1fr;
}

body.game-active.mobile-layout-mode .round-card-header {
    flex-direction: row;
    align-items: start;
}

body.game-active.mobile-layout-mode .round-card-actions {
    width: auto;
    margin-left: auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
    align-items: stretch;
}

body.game-active.mobile-layout-mode .more-actions-content {
    position: absolute;
    left: 0;
    top: calc(100% + 4px);
    min-width: 0;
    width: max-content;
    max-width: calc(100vw - 40px);
}

body.game-active.mobile-layout-mode .more-actions-grid {
    justify-items: center;
}

body.game-active.mobile-layout-mode .more-actions-grid .button {
    width: auto;
    min-width: 214px;
}

body.game-active.mobile-layout-mode .more-actions-details.compact-more-actions-label .more-actions-grid {
    justify-items: stretch;
}

body.game-active.mobile-layout-mode .more-actions-details.compact-more-actions-label .more-actions-grid .button {
    width: 100%;
    min-width: 0;
}

body.game-active.mobile-layout-mode .timer-input-wrap {
    justify-content: start;
}

@media (max-width: 960px) {
    .setup-layout,
    .game-layout {
        grid-template-columns: 1fr;
    }

    body.game-active .app-shell {
        width: 100%;
        min-width: 375px;
    }

    .setup-main-grid {
        grid-template-columns: 1fr;
        justify-content: stretch;
    }

    .hero h1 {
        width: 100%;
    }
    .setup-form-grid {
        grid-template-columns: 1fr;
    }

    .hero::after {
        content: "";
        width: min(862px, 100%);
        height: 4px;
        margin-top: 18px;
        background: var(--line);
    }

    .players-panel,
    .players-count-field,
    .launch-panel,
    .round-column-panel {
        max-width: none;
    }

    .game-main-grid {
        grid-template-columns: 1fr;
        height: auto;
        min-width: 375px;
    }

    .game-side-grid {
        grid-template-columns: 1fr;
        min-width: 375px;
    }

    .game-side-rail,
    .leaderboard-panel,
    .stats-panel,
    .payoff-panel,
    .round-column-panel {
        width: 100%;
        min-width: 375px;
        height: auto;
        min-height: 0;
    }

        .leaderboard,
        .compact-stat-grid,
        .payoff-grid,
        .featured-pair-grid,
        .round-column-panel {
            overflow: visible;
            max-height: none;
        }

    .section-heading,
    .pair-header,
    .payoff-row,
    .stage-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .timer-card {
        width: 100%;
        text-align: left;
        margin-left: 0;
    }

    .timer-setting {
        text-align: left;
    }

    .game-dual-grid,
    .compact-stat-grid,
    .choice-button-group {
        grid-template-columns: 1fr;
    }

    .pairings-heading {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .pairings-timer,
    .pairings-heading-actions {
        justify-self: start;
    }

    .modal-backdrop-aside {
        place-items: center;
        padding: 20px;
        background: rgba(26, 23, 20, 0.32);
    }

    .modal-card-aside {
        width: min(920px, 100%);
        max-height: calc(100vh - 40px);
    }

    .pairings-heading-actions {
        flex-direction: column;
    }

    .round-card-header {
        flex-direction: column;
    }

    .modal-title-row,
    .modal-title-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .round-card-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .more-actions-content {
        position: absolute;
        left: 0;
        top: calc(100% + 4px);
        min-width: 0;
        width: min(290px, calc(100vw - 40px));
        max-width: calc(100vw - 40px);
    }

    .more-actions-grid {
        justify-items: stretch;
    }

    .more-actions-grid .button {
        width: 100%;
        min-width: 0;
    }

    .setup-main-grid,
    .featured-pair-grid {
        grid-template-columns: 1fr;
    }

    .decision-pie-wrap {
        grid-template-columns: 64px minmax(0, 1fr);
        align-items: center;
    }

    .pair-card-layout,
    .pair-player-row,
    .settings-row-two-up {
        grid-template-columns: 1fr;
    }

    .decision-pie {
        margin: 0;
    }

    .payoff-matrix-header,
    .payoff-row {
        grid-template-columns: 38px repeat(2, minmax(0, 1fr));
    }

    .payoff-matrix-spacer {
        display: block;
    }

    .payoff-column-heading,
    .payoff-label {
        text-align: center;
    }

    .payoff-label {
        text-align: left;
    }

    .timer-input-wrap {
        justify-content: start;
    }
}

@media (max-width: 960px) {
    html.game-active.desktop-layout-mode,
    body.game-active.desktop-layout-mode {
        min-width: var(--game-shell-min-width);
        overflow-x: auto;
        overflow-y: hidden;
    }

    html.game-active.desktop-layout-mode.fixed-width-layout,
    body.game-active.desktop-layout-mode.fixed-width-layout {
        overflow-x: auto;
    }

    html.game-active.desktop-layout-mode.fixed-height-layout,
    body.game-active.desktop-layout-mode.fixed-height-layout {
        overflow-y: auto;
    }

    body.game-active.desktop-layout-mode .app-shell {
        width: max(100%, var(--game-shell-min-width));
        min-width: 0;
        padding-left: 10px;
        padding-right: 6px;
    }

    body.game-active.desktop-layout-mode .game-stage {
        min-height: calc(100vh - 18px);
    }

    body.game-active.desktop-layout-mode .game-main-grid {
        grid-template-columns: minmax(900px, 1fr) 687px;
        width: var(--game-stage-width, 100%);
        height: var(--game-stage-height, calc(100vh - 18px));
        min-width: 0;
    }

    body.game-active.desktop-layout-mode .game-side-grid {
        grid-template-columns: 300px 375px;
        min-width: 687px;
    }

    body.game-active.desktop-layout-mode .game-side-rail {
        width: 100%;
        min-width: 0;
        height: 100%;
        min-height: 0;
    }

    body.game-active.desktop-layout-mode .leaderboard-panel {
        width: 100%;
        min-width: 300px;
        height: 100%;
        min-height: 0;
    }

    body.game-active.desktop-layout-mode .stats-panel,
    body.game-active.desktop-layout-mode .payoff-panel {
        width: 100%;
        min-width: 375px;
        height: 100%;
        min-height: 0;
    }

    body.game-active.desktop-layout-mode .round-column-panel {
        width: 100%;
        min-width: 900px;
        height: 100%;
        min-height: 0;
        overflow: hidden;
    }

    body.game-active.desktop-layout-mode .leaderboard,
    body.game-active.desktop-layout-mode .compact-stat-grid,
    body.game-active.desktop-layout-mode .payoff-grid,
    body.game-active.desktop-layout-mode .featured-pair-grid {
        overflow: auto;
        max-height: none;
    }

    body.game-active.desktop-layout-mode .section-heading,
    body.game-active.desktop-layout-mode .pair-header,
    body.game-active.desktop-layout-mode .payoff-row,
    body.game-active.desktop-layout-mode .stage-header {
        flex-direction: row;
        align-items: center;
    }

    body.game-active.desktop-layout-mode .stage-header {
        align-items: start;
        justify-content: flex-start;
    }

    body.game-active.desktop-layout-mode .game-dual-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body.game-active.desktop-layout-mode .compact-stat-grid {
        grid-template-columns: repeat(2, minmax(156px, 1fr));
    }

    body.game-active.desktop-layout-mode .round-card-header {
        flex-direction: row;
    }

    body.game-active.desktop-layout-mode .round-card-actions {
        width: auto;
        justify-content: flex-end;
        flex-wrap: nowrap;
        align-items: stretch;
    }

    body.game-active.desktop-layout-mode .more-actions-content {
        position: absolute;
        left: 0;
        top: calc(100% + 4px);
        min-width: 0;
        width: max-content;
        max-width: none;
    }

    body.game-active.desktop-layout-mode .more-actions-grid {
        justify-items: center;
    }

    body.game-active.desktop-layout-mode .more-actions-grid .button {
        width: auto;
        min-width: 214px;
    }

    body.game-active.desktop-layout-mode .featured-pair-grid {
        grid-template-columns: repeat(2, minmax(340px, 1fr));
    }

    body.game-active.desktop-layout-mode .pair-player-row {
        grid-template-columns: minmax(118px, 146px) minmax(0, 1fr);
    }

    body.game-active.desktop-layout-mode .settings-row-two-up {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .toggle-row {
        grid-template-columns: 1fr;
    }

    .app-shell {
        width: min(100% - 12px, 1180px);
        padding-top: 20px;
    }

        body.game-active .app-shell {
            padding-left: 10px;
            padding-right: 10px;
        }

    .hero h1 {
        width: 100%;
    }

    .two-up {
        grid-template-columns: 1fr;
    }

    .pair-choice-row {
        grid-template-columns: 1fr;
    }

    .round-timer-card {
        min-width: 0;
    }

}