:root {
    color-scheme: light;
    --bg: #eef3ef;
    --panel: #ffffff;
    --ink: #142015;
    --muted: #637066;
    --line: #d9e3dc;
    --accent: #0f7c45;
    --accent-dark: #095f34;
    --danger: #b42318;
    --attacker: #c82424;
    --defender: #1f5fd1;
    --criterion-bg: #141719;
    --gold: #f7c948;
}

html,
body {
    min-height: 100%;
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #2a2d2f;
    color: var(--ink);
}

button,
input {
    font: inherit;
}

.game-shell {
    width: min(1180px, calc(100vw - 24px));
    margin: 0 auto;
    padding: 24px 0 48px;
}

.game-shell.theme-dark {
    --bg: #2a2d2f;
    --panel: #1d2023;
    --ink: #f4f7f5;
    --muted: #bac3bd;
    --line: #3a4044;
    --criterion-bg: #090a0b;
    color-scheme: dark;
}

.game-shell.theme-light {
    --bg: #eef3ef;
    --panel: #ffffff;
    --ink: #142015;
    --muted: #637066;
    --line: #d9e3dc;
    --criterion-bg: #232729;
    color-scheme: light;
}

body:has(.theme-light) {
    background: radial-gradient(circle at top left, #d6f5df 0, transparent 32rem), var(--bg);
}

body:has(.theme-dark) {
    background: radial-gradient(circle at top left, rgba(15, 124, 69, .2) 0, transparent 30rem), var(--bg);
}

.hero-card,
.turn-banner,
.loading-card,
.error-card,
.debug-panel,
.menu-card,
.settings-card,
.pregame-card,
.ready-card,
.end-actions,
.board-wrap {
    background: color-mix(in srgb, var(--panel) 92%, transparent);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.16);
}

.menu-card,
.settings-card,
.pregame-card,
.solo-live-actions,
.ready-card,
.end-actions {
    margin-top: 16px;
    padding: 24px;
    display: grid;
    gap: 16px;
}

.mode-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.mode-tab {
    border: 2px solid var(--line);
    border-radius: 18px;
    padding: 16px;
    background: color-mix(in srgb, var(--panel) 80%, var(--line));
    color: var(--ink);
    font-weight: 950;
    cursor: pointer;
}

.mode-tab.active {
    border-color: var(--accent);
    outline: 3px solid color-mix(in srgb, var(--accent) 34%, transparent);
    outline-offset: 2px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent), 0 14px 34px rgba(15, 124, 69, .24);
}

.mode-tab.disabled {
    opacity: .55;
    cursor: not-allowed;
}

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

.setting-column {
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 18px;
    background: color-mix(in srgb, var(--panel) 88%, transparent);
}

.radio-list,
.nested-options {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.option-line {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-weight: 800;
    color: var(--ink);
}

.checkbox-line {
    margin-top: 12px;
}

.selected-time {
    display: inline-block;
    margin: 4px 0 8px;
    font-size: clamp(1.8rem, 5vw, 3rem);
    letter-spacing: .04em;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    gap: 10px;
}

.color-grid.compact {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    align-items: stretch;
}

.color-choice {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 46px;
    box-sizing: border-box;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px;
    background: color-mix(in srgb, var(--panel) 86%, var(--line));
    color: var(--ink);
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
}

.color-choice.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent);
}

.color-choice input {
    margin: 0;
    flex: 0 0 auto;
}

.color-swatch {
    inline-size: 22px;
    block-size: 22px;
    flex: 0 0 22px;
    border-radius: 50%;
    border: 2px solid color-mix(in srgb, var(--ink) 72%, #fff);
    box-shadow: 0 2px 8px rgba(0,0,0,.26), inset 0 0 0 1px rgba(255,255,255,.35);
}

.color-choice.disabled,
.countdown-setting-card.disabled {
    opacity: .42;
    cursor: not-allowed;
}

.color-choice.disabled input,
.countdown-setting-card.disabled input {
    cursor: not-allowed;
}

.countdown-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
    align-items: start;
}

.countdown-setting-card {
    min-width: 0;
}

.countdown-setting-card .checkbox-line {
    min-height: 42px;
    margin-top: 0;
    align-items: flex-start;
    line-height: 1.15;
}

.transition-duration {
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--panel) 88%, var(--line));
}

.transition-duration .option-line {
    min-height: 32px;
    padding: 4px 0;
    line-height: 1.2;
}

.color-subhead {
    margin-top: 18px;
}

.mode-button {
    border: 2px solid var(--line);
    border-radius: 20px;
    padding: 18px 20px;
    background: color-mix(in srgb, var(--panel) 82%, var(--line));
    color: var(--ink);
    font-size: clamp(1.1rem, 3vw, 1.6rem);
    font-weight: 900;
    cursor: pointer;
    text-align: left;
}

.mode-button:hover:not(:disabled) {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.mode-button.disabled {
    opacity: .55;
    cursor: not-allowed;
}

.mode-button span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: .95rem;
}

.settings-section {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
}

.option-grid {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.option-pill {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 10px 14px;
    background: color-mix(in srgb, var(--panel) 84%, var(--line));
    font-weight: 800;
}

.preset-settings {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
    background: color-mix(in srgb, var(--panel) 88%, transparent);
}

.preset-settings h3 {
    margin: 0 0 12px;
    font-size: 1rem;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

.preset-option {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px 12px;
    background: var(--panel);
    font-weight: 800;
    cursor: pointer;
    min-block-size: 58px;
}

.preset-option span {
    line-height: 1.15;
}

.preset-option.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent);
}

.preset-option input[type="radio"] {
    accent-color: var(--accent);
}

.preset-description,
.preset-locked-note {
    margin: 10px 0 0;
    color: var(--muted);
    font-weight: 700;
}

.preset-locked-note {
    border: 1px dashed var(--line);
    border-radius: 14px;
    padding: 12px;
    background: color-mix(in srgb, var(--panel) 80%, transparent);
}

.category-settings {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
}

.category-table {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.category-row {
    display: grid;
    grid-template-columns: minmax(110px, 1.5fr) .8fr .8fr .8fr;
    gap: 8px;
    align-items: center;
}

.category-head {
    color: var(--muted);
    font-weight: 900;
}

.category-row input[type="number"] {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px;
    background: var(--panel);
    color: var(--ink);
}

.category-toggle {
    inline-size: 100%;
    min-block-size: 38px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    cursor: pointer;
    position: relative;
}

.category-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    inline-size: 1px;
    block-size: 1px;
}

.category-toggle-box {
    inline-size: 22px;
    block-size: 22px;
    display: grid;
    place-items: center;
    border: 2px solid var(--line);
    border-radius: 7px;
    background: color-mix(in srgb, var(--panel) 70%, #fff);
    color: #fff;
    font-size: 15px;
    font-weight: 1000;
}

.category-toggle input[type="checkbox"]:checked + .category-toggle-box {
    border-color: var(--accent);
    background: var(--accent);
}

.category-toggle input[type="checkbox"]:checked + .category-toggle-box::after {
    content: "✓";
}

.category-toggle input[type="checkbox"]:focus-visible + .category-toggle-box {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.invalid-input {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--danger) 22%, transparent);
}

.timer-display,
.modal-timer {
    font-size: clamp(1.6rem, 5vw, 3rem);
    font-weight: 950;
    letter-spacing: .04em;
}

.timer-warning {
    color: #ffe58a;
}

.hero-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 24px;
    flex-wrap: wrap;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    line-height: 1.05;
}

h1 {
    font-size: clamp(2rem, 6vw, 4.2rem);
    letter-spacing: -0.06em;
}

h2 {
    font-size: clamp(1.25rem, 3vw, 2rem);
}

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

.primary-action,
.ghost-button,
.board-cell,
.result-row {
    border: 0;
    cursor: pointer;
}

.primary-action,
.ghost-button {
    flex: 0 0 auto;
    padding: 12px 18px;
    border-radius: 999px;
    font-weight: 900;
}

.primary-action {
    background: var(--accent);
    color: #fff;
}

.ghost-button {
    background: color-mix(in srgb, var(--panel) 84%, var(--line));
    color: var(--ink);
}

.primary-action:hover,
.result-row:hover {
    background: var(--accent-dark);
    color: #fff;
}

.primary-action:disabled,
.board-cell:disabled {
    cursor: not-allowed;
}

.turn-banner,
.loading-card,
.error-card {
    margin-top: 16px;
    padding: 18px 22px;
}

.turn-banner {
    display: grid;
    gap: 10px;
    color: #fff;
    border-width: 2px;
}

.turn-banner.status-actions {
    grid-template-columns: minmax(0, 1fr) minmax(180px, 240px);
    align-items: start;
    column-gap: 20px;
}

.banner-start-action {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    order: 3;
}

.banner-start-button {
    min-width: min(260px, 100%);
    padding: 13px 22px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,.34);
    background: #111827;
    color: #fff;
    font-weight: 950;
    letter-spacing: .04em;
    text-transform: uppercase;
    box-shadow: 0 12px 28px rgba(0,0,0,.22), inset 0 0 0 1px rgba(255,255,255,.1);
}

.banner-start-button:hover {
    transform: translateY(-1px);
    background: #0b1220;
}

.banner-copy {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.turn-banner strong {
    font-size: clamp(1.5rem, 5vw, 3.2rem);
    line-height: 1;
    letter-spacing: .02em;
}

.stat-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.stat-badge {
    min-width: 126px;
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,.32);
    border-radius: 16px;
    background: rgba(0,0,0,.2);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}

.stat-badge small,
.stat-badge strong {
    display: block;
}

.stat-badge small {
    color: rgba(255,255,255,.78);
    font-size: .82rem;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.stat-badge strong {
    margin-top: 3px;
    color: #fff;
    font-size: clamp(1.35rem, 4vw, 2.2rem);
    line-height: 1;
    letter-spacing: .02em;
}

.banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 2px;
}

.final-actions-column {
    justify-self: end;
    align-self: stretch;
    display: grid;
    grid-template-columns: 1fr;
    align-content: start;
    width: min(240px, 100%);
}

.final-actions-column .ghost-button {
    width: 100%;
}

.banner-actions .primary-action,
.banner-actions .ghost-button {
    padding: 10px 15px;
    min-width: 0;
}

.turn-banner .ghost-button {
    background: #111827;
    color: #fff;
    border: 1px solid rgba(255,255,255,.28);
}

.turn-banner.color-yellow .ghost-button,
.turn-banner.draw .ghost-button {
    background: #111827;
    color: #fff;
    border-color: rgba(255,255,255,.28);
}

.turn-banner .ghost-button:disabled,
.turn-banner .banner-start-button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.turn-banner.attacker {
    background: linear-gradient(135deg, #8f1515, var(--attacker));
    border-color: #ff7a7a;
}

.turn-banner.defender {
    background: linear-gradient(135deg, #173e91, var(--defender));
    border-color: #84aaff;
}

.turn-banner.color-red,
.board-cell.occupied.color-red,
.color-swatch.color-red {
    background: linear-gradient(135deg, #8f1515, #c82424);
    border-color: #ff7a7a;
    color: #fff;
}

.turn-banner.color-blue,
.board-cell.occupied.color-blue,
.color-swatch.color-blue {
    background: linear-gradient(135deg, #173e91, #1f5fd1);
    border-color: #84aaff;
    color: #fff;
}

.turn-banner.color-green,
.board-cell.occupied.color-green,
.color-swatch.color-green {
    background: linear-gradient(135deg, #09613a, #0f9f5a);
    border-color: #7ee0a5;
    color: #fff;
}

.turn-banner.color-yellow,
.board-cell.occupied.color-yellow,
.color-swatch.color-yellow {
    background: linear-gradient(135deg, #c69205, #f7c948);
    border-color: #ffe58a;
    color: #211700;
}

.hidden-criterion-card {
    aspect-ratio: 1;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: repeating-linear-gradient(135deg, #22282c 0 10px, #171b1f 10px 20px);
    border: 3px solid color-mix(in srgb, #fff 18%, #171b1f);
    color: rgba(255,255,255,.74);
    font-weight: 950;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.board-blocked .board-cell:not(.occupied) {
    opacity: .62;
}

.countdown-overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(3px);
}

.countdown-card {
    width: min(420px, calc(100vw - 32px));
    padding: 34px;
    border-radius: 28px;
    border: 2px solid var(--gold);
    background: color-mix(in srgb, var(--panel) 96%, transparent);
    color: var(--ink);
    text-align: center;
    box-shadow: 0 30px 90px rgba(0,0,0,.42);
}

.countdown-card strong {
    display: block;
    font-size: clamp(4rem, 18vw, 8rem);
    line-height: .9;
    color: var(--accent);
}

.turn-banner.draw {
    background: linear-gradient(135deg, #f2b705, var(--gold));
    border-color: #ffe58a;
    color: #211700;
}

.status-final {
    border-color: var(--gold);
}

.error-card {
    color: var(--danger);
}

.board-wrap {
    margin-top: 16px;
    padding: 14px;
    overflow-x: auto;
}

.criteria-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(112px, 1fr));
    gap: 8px;
    width: min(760px, 100%);
    margin: 0 auto;
}

.corner-cell,
.criterion-card,
.board-cell {
    aspect-ratio: 1;
    border-radius: 18px;
    overflow: hidden;
}

.corner-cell {
    background: var(--criterion-bg);
    border: 3px solid color-mix(in srgb, #fff 22%, var(--criterion-bg));
}

.logo-cell {
    display: grid;
    place-items: center;
    padding: 10px;
    background: radial-gradient(circle at 50% 35%, #3d4449 0, var(--criterion-bg) 66%);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.06), 0 10px 26px rgba(0,0,0,.2);
}

.logo-cell img {
    width: 86%;
    height: 86%;
    object-fit: contain;
    display: block;
}

.criterion-card {
    padding: 4px;
    background: var(--criterion-bg);
    border: 3px solid color-mix(in srgb, #fff 22%, var(--criterion-bg));
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.06), 0 10px 26px rgba(0,0,0,.2);
}

.criterion-card .node-square-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    background-color: #171a1d;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    border-radius: 14px;
    padding: 0;
    overflow: hidden;
}

.criterion-card.no-image .node-square-content {
    justify-content: space-between;
    background: radial-gradient(circle at 50% 35%, #3d4449 0, #191d20 62%);
}

.criterion-fallback {
    display: grid;
    place-items: center;
    width: 42%;
    aspect-ratio: 1;
    margin-top: 14%;
    border-radius: 50%;
    background: rgba(255,255,255,.12);
    color: rgba(255,255,255,.78);
    font-size: clamp(1.4rem, 5vw, 3rem);
    font-weight: 950;
    text-shadow: 0 2px 8px rgba(0,0,0,.5);
}

.node-text,
.chosen-player {
    padding: 0 5px 7px;
    color: white;
    line-height: 1.05;
    font-size: clamp(.78rem, 2vw, 1.15rem);
    letter-spacing: .01rem;
    text-align: center;
    overflow-wrap: anywhere;
    text-shadow:
        0.05em 0 black,
        0 0.05em black,
        -0.05em 0 black,
        0 -0.05em black,
        -0.05em -0.05em black,
        -0.05em 0.05em black,
        0.05em -0.05em black,
        0.05em 0.05em black;
}

.board-cell {
    display: grid;
    place-items: center;
    padding: 8px;
    background: color-mix(in srgb, var(--panel) 76%, var(--line));
    border: 2px solid var(--line);
    color: var(--ink);
    transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.board-cell:not(:disabled):hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: 0 16px 32px rgba(15, 124, 69, 0.18);
}

.board-cell.occupied {
    border-width: 4px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}

.board-cell.occupied.attacker {
    background: linear-gradient(135deg, #8f1515, var(--attacker));
    border-color: #ff8b8b;
}

.board-cell.occupied.defender {
    background: linear-gradient(135deg, #173e91, var(--defender));
    border-color: #91b4ff;
}

.board-cell .chosen-player {
    font-size: clamp(.82rem, 2.2vw, 1.2rem);
    font-weight: 900;
    padding: 0;
}

.debug-panel {
    margin-top: 16px;
    padding: 16px 18px;
    color: var(--ink);
}

.debug-panel summary {
    cursor: pointer;
    font-weight: 900;
}

.debug-grid,
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.settings-grid input[type="number"] {
    width: 64px;
    margin-left: 6px;
}

.difficulty-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.settings-error {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #ffe8e8;
    color: #8f1515;
    font-weight: 800;
}

.theme-dark,
.theme-dark .pregame-card,
.theme-dark .setting-column,
.theme-dark .category-settings,
.theme-dark .ready-card,
.theme-dark .end-actions,
.theme-dark .solo-live-actions,
.theme-dark .loading-card,
.theme-dark .error-card,
.theme-dark .modal-head,
.theme-dark .option-line,
.theme-dark .color-choice,
.theme-dark .category-row,
.theme-dark .selected-time {
    color: var(--ink);
}

.theme-dark .subtitle,
.theme-dark .muted,
.theme-dark .category-head {
    color: var(--muted);
}

.theme-dark .setting-column,
.theme-dark .category-settings,
.theme-dark .transition-duration,
.theme-dark .color-choice,
.theme-dark .ghost-button,
.theme-dark .mode-tab,
.theme-dark .result-row,
.theme-dark .search-input,
.theme-dark .category-row input[type="number"] {
    background: color-mix(in srgb, var(--panel) 86%, var(--line));
    color: var(--ink);
    border-color: var(--line);
}

.theme-dark .primary-action {
    color: #fff;
}

.theme-dark .countdown-card,
.theme-dark .picker-modal {
    background: var(--panel);
    color: var(--ink);
}

.theme-dark .settings-error {
    background: #3a1717;
    color: #ffb4b4;
}

.debug-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px 14px;
    margin-top: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--panel) 82%, var(--line));
}

.debug-summary strong,
.debug-summary span,
.debug-cell strong,
.debug-cell span,
.debug-cell em {
    display: block;
}

.debug-summary strong,
.debug-cell span {
    color: var(--accent);
    font-weight: 800;
}

.debug-cell {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--panel) 90%, var(--line));
}

.debug-cell em {
    margin-top: 6px;
    color: #c17a00;
    font-size: 0.86rem;
    font-style: normal;
    font-weight: 800;
}

.debug-cell .debug-warning {
    color: var(--danger);
}

.debug-cell p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.theme-dark .debug-panel {
    background: #15191c;
    border-color: #56616a;
    color: #f5f8f6;
}

.theme-dark .debug-panel summary,
.theme-dark .debug-cell strong,
.theme-dark .debug-summary strong {
    color: #ffffff;
}

.theme-dark .debug-summary,
.theme-dark .debug-cell {
    background: #20262a;
    border-color: #56616a;
    color: #edf3ef;
}

.theme-dark .debug-summary span,
.theme-dark .debug-cell p {
    color: #d7e2dc;
}

.theme-dark .debug-cell span {
    color: #7ee0a7;
}

.theme-dark .debug-cell em {
    color: #ffd36b;
}

.theme-dark .debug-cell .debug-warning {
    color: #ff9a9a;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(7, 18, 10, 0.62);
    z-index: 10;
}

.picker-modal {
    width: min(680px, 100%);
    max-height: min(760px, calc(100vh - 36px));
    overflow: auto;
    padding: 24px;
    border-radius: 28px;
    background: var(--panel);
    color: var(--ink);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
}

.search-input {
    width: 100%;
    margin: 20px 0 14px;
    padding: 15px 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    outline: none;
    color: var(--ink);
    background: color-mix(in srgb, var(--panel) 96%, var(--line));
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(15, 124, 69, 0.12);
}

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

.result-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 16px;
    background: color-mix(in srgb, var(--panel) 88%, var(--line));
    color: var(--ink);
    text-align: left;
}

.result-row:disabled {
    cursor: wait;
    opacity: .72;
}

.answer-result {
    display: grid;
    place-items: center;
    gap: 8px;
    min-height: 220px;
    padding: 30px;
    border-radius: 24px;
    color: #fff;
    text-align: center;
}

.answer-result strong {
    font-size: clamp(2.4rem, 8vw, 5rem);
    line-height: 1;
}

.answer-result span {
    font-size: 1.2rem;
    font-weight: 800;
}

.answer-result-success {
    background: linear-gradient(135deg, #0f7c45, #19a460);
}

.answer-result-error {
    background: linear-gradient(135deg, #8f1515, #d12c2c);
}

.toast-stack {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 50;
    display: grid;
    gap: 10px;
    width: min(380px, calc(100vw - 36px));
    pointer-events: none;
}

.toast-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    border-radius: 16px;
    color: #fff;
    box-shadow: 0 18px 50px rgba(20, 32, 21, 0.18);
    pointer-events: auto;
}

.toast-success { background: #14804a; }
.toast-warning { background: #b85c00; }
.toast-error { background: #b42318; }
.toast-info { background: #28516f; }

.toast-close {
    border: 0;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: 1.2rem;
}

.entity-image,
.entity-placeholder {
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
    border-radius: 14px;
    object-fit: contain;
    background: #fff;
}

.entity-placeholder {
    display: inline-grid;
    place-items: center;
    color: var(--accent);
    font-weight: 900;
}

@media (max-width: 720px) {
    .game-shell {
        width: min(100vw - 12px, 100%);
        padding-top: 8px;
    }

    .mode-tabs,
    .pregame-grid {
        grid-template-columns: 1fr;
    }

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

    .turn-banner.status-actions {
        grid-template-columns: 1fr;
    }

    .final-actions-column {
        justify-self: stretch;
        width: 100%;
    }

    .countdown-settings-grid {
        grid-template-columns: 1fr;
    }

    .banner-start-action {
        order: 0;
    }

    .color-grid,
    .color-grid.compact {
        grid-template-columns: repeat(2, minmax(132px, 1fr));
    }

    .category-row {
        grid-template-columns: 1fr 64px 64px 64px;
    }

    .hero-card {
        padding: 16px;
    }

    .board-wrap {
        padding: 8px;
    }

    .criteria-grid {
        grid-template-columns: repeat(4, 22vw);
        gap: 5px;
        width: max-content;
    }

    .corner-cell,
    .criterion-card,
    .board-cell {
        border-radius: 12px;
    }

    .criterion-card {
        padding: 3px;
        border-width: 2px;
    }

    .criterion-card .node-square-content {
        border-radius: 9px;
    }

    .node-text,
    .chosen-player,
    .board-cell .chosen-player {
        font-size: 2.6vw;
    }
}

@media (max-width: 360px) {
    .preset-grid,
    .color-grid,
    .color-grid.compact {
        grid-template-columns: 1fr;
    }
}
