/* Action-Mix 6: shared visual tokens and component refinements. */
:root {
    font-family:
        ui-sans-serif,
        system-ui,
        -apple-system,
        "Segoe UI",
        sans-serif;
    --ink: #22233d;
    --purple: #433a80;
    --purple2: #6953c1;
    --muted: #62647a;
    --category-color: #6953c1;
    --surface: #fff;
    --radius: 22px;
    --shadow: 0 10px 35px #2826460b;
    color: var(--ink);
}
body {
    background: #f5f3ee;
    background-image: radial-gradient(ellipse at 50% -15%, #e7e0fa 0, transparent 65%);
}
body[data-mode="malen"] {
    --category-color: #3267cd;
}
body[data-mode="erklaeren"] {
    --category-color: #7952b3;
}
body[data-mode="pantomime"] {
    --category-color: #b96919;
}
body[data-mode="geraeusch"] {
    --category-color: #147969;
}
button,
input,
select {
    font-family: inherit;
}
button {
    font-weight: 700 !important;
}
button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid #2865c9;
    outline-offset: 4px;
}
.switch:has(input:focus-visible),
.output-mode-card:has(input:focus-visible) {
    outline: 3px solid #2865c9;
    outline-offset: 4px;
}
.action-topbar {
    height: 64px;
    background: #f9f7f0e8;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #dedbe9;
}
.action-logo {
    letter-spacing: -0.7px;
    font-size: 21px;
}
.action-logo span {
    font-size: 24px;
}
.connection-bar {
    max-width: 1180px;
    margin: 8px auto 0;
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 26px;
    font-size: 12px;
    color: #53675d;
}
.connection-bar > span:before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #278660;
    margin-right: 7px;
}
.connection-bar > span.offline {
    color: #9b541f;
}
.connection-bar > span.offline:before {
    background: #be772c;
}
.panel {
    box-shadow: var(--shadow);
    border: 1px solid #e5e1ec;
    border-radius: var(--radius);
    padding: clamp(22px, 3vw, 38px);
}
.setup-panel {
    max-width: 900px;
    margin-top: 14px;
}
.brand-mark {
    font-size: 76px;
    line-height: 1;
    width: 90px;
    height: 90px;
    margin: 0 auto 16px;
    display: grid;
    place-content: center;
}
.setup-panel h1 {
    font-size: clamp(38px, 6vw, 62px);
    font-weight: 750;
    letter-spacing: -2px;
    line-height: 1.04;
    margin: 14px 0 18px;
}
.section-kicker {
    letter-spacing: 0.13em;
    font-size: 11px;
    font-weight: 700;
}
.lead {
    font-size: 17px;
    line-height: 1.5;
    max-width: 570px;
}
.team-number {
    background: var(--team-color, #6953c1);
    border-radius: 50%;
    font-size: 17px;
}
.team-row input {
    font-weight: 600;
    font-size: 18px;
    border: 1px solid #d7d3df;
}
.team-row input:focus {
    border-color: var(--purple2);
}
.option-toggle-card {
    box-shadow: none;
    border-width: 1px !important;
    padding: 14px;
    gap: 10px;
}
.adult-toggle-copy strong {
    font-size: 15px;
}
.adult-toggle-copy small {
    font-size: 12px;
}
.adult-badge,
.open-badge,
.sound-badge {
    width: 34px;
    height: 34px;
    font-size: 13px;
}
.switch {
    width: 46px;
    height: 28px;
}
.switch-track::after {
    width: 20px;
    height: 20px;
    top: 4px;
    left: 4px;
}
.switch input:checked + .switch-track::after {
    transform: translateX(18px);
}
.output-mode-card {
    border-width: 1px;
    padding: 15px;
}
.output-mode-card strong {
    font-size: 15px;
}
.output-mode-card small {
    font-size: 12px;
}
.team-add-action {
    max-width: 760px;
    margin: 12px auto 22px;
    text-align: left;
}
.button {
    border-radius: 12px;
    transition:
        transform 0.12s ease,
        background-color 0.15s ease;
    box-shadow: none;
}
.button.primary {
    background: #433a80;
}
.button.secondary {
    background: #f0edf5;
}
.start-button,
.success-button {
    background: #147969;
}
.difficulty {
    border-width: 1px;
    box-shadow: var(--shadow);
    border-radius: 18px;
}
.difficulty strong {
    font-size: 22px;
    font-weight: 700;
}
.difficulty-points {
    font-weight: 750;
}
.scoreboard {
    gap: 10px;
}
.score-team {
    position: relative;
    min-width: 165px;
    border: 1px solid #e0dce7;
    box-shadow: none;
    padding: 13px 15px;
    border-radius: 16px;
    transition:
        border-color 0.2s,
        background-color 0.2s;
}
.score-team.current {
    border-color: var(--team-color);
    box-shadow: inset 0 3px 0 var(--team-color);
    background: #fff;
}
.score-team-name {
    font-size: 14px;
    font-weight: 650;
    color: var(--team-color);
}
.score-team-points strong {
    font-size: 28px;
    color: var(--ink);
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}
.joker-count {
    margin-left: auto;
    font-size: 11px;
    color: var(--muted);
}
.score-track {
    height: 4px;
    background: #eeecf2;
    border-radius: 9px;
    overflow: hidden;
    margin-top: 10px;
}
.score-track i {
    display: block;
    height: 100%;
    background: var(--team-color);
    transition: width 0.5s ease;
    border-radius: 9px;
}
.score-delta {
    position: absolute;
    right: 16px;
    top: 20px;
    opacity: 0;
    color: var(--team-color);
    font-size: 27px;
    font-weight: 800;
}
.turn-panel {
    min-height: 0;
    border-top: 4px solid var(--category-color);
    margin-top: 8px;
}
.turn-panel h1 {
    font-weight: 750;
    font-size: clamp(32px, 5vw, 50px);
    letter-spacing: -1.3px;
}
.current-team-label {
    font-weight: 650;
    font-size: 11px;
    margin-top: 15px;
    color: var(--muted);
}
.turn-meta {
    font-size: 12px;
    gap: 12px;
}
.stage {
    margin-top: 20px;
}
.mode-card {
    background: #f5f3f8;
    border: 1px solid #e5e0ee;
    border-radius: 18px;
}
.mode-card strong {
    color: var(--category-color);
    font-weight: 700;
}
.category-icon {
    display: inline-block;
    width: 1.15em;
    height: 1.15em;
    vertical-align: middle;
}
.mode-icon .category-icon {
    width: 52px;
    height: 52px;
    color: var(--category-color);
}
.mode-badge {
    color: var(--category-color);
    background: #f1eff7;
}
.timer-ring {
    width: min(52vw, 280px);
}
.timer-number {
    font-size: clamp(74px, 12vw, 112px);
    font-weight: 750;
    color: var(--ink);
}
.timer-progress {
    transition: stroke 0.2s;
    stroke: var(--category-color);
}
.timer-track {
    stroke: #eeebf4;
}
.timer-mode {
    font-size: 12px;
    color: var(--category-color);
    letter-spacing: 0.1em;
}
.timer-rule {
    font-size: 14px;
    font-weight: 500;
}
.early-success-note {
    font-size: 12px;
    color: var(--muted);
}
.timer-actions-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    max-width: 700px;
    margin: 18px auto 0;
}
.timer-actions-main .button {
    font-size: 17px;
    min-height: 58px;
}
.timer-actions-main .extend-button {
    font-size: 14px;
    background: #fbefd9;
    color: #8b5616;
}
.timer-actions-main .drawing-open-button {
    font-size: 14px;
    border-width: 1px;
}
.timer-actions-main [data-reprint-label] {
    grid-column: 1/-1;
    font-size: 12px;
    min-height: 32px;
    background: transparent;
}
.last-result-tools {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 20px;
}
.last-result-tools button {
    font-size: 12px;
    min-height: 38px;
}
.last-result-tools summary {
    font-size: 12px;
    cursor: pointer;
    color: var(--muted);
}
body:not([data-stage="difficulty-stage"]) .last-result-tools {
    display: none;
}
.playback-settings {
    width: min(calc(100% - 28px), 980px);
    margin: 20px auto;
    color: var(--muted);
    font-size: 12px;
}
.playback-settings summary {
    cursor: pointer;
    text-align: center;
    padding: 10px;
}
.playback-settings > div {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 14px;
}
.playback-settings label {
    display: flex;
    align-items: center;
    gap: 7px;
}
.playback-settings input[type="range"] {
    width: 85px;
}
.live-status {
    background: #eaf4ee;
    border-radius: 10px;
    padding: 10px;
    color: #236948 !important;
    font-size: 13px !important;
}
.ai-help-panel {
    box-shadow: none;
    background: #faf9fd;
}
.ai-help-head strong {
    font-size: 17px;
}
.ai-help-note {
    font-size: 12px;
}
.modal-card {
    border-radius: 22px;
}
.modal-card h2 {
    font-weight: 750;
    letter-spacing: -1px;
}
.rules-list strong {
    font-weight: 650;
}
.rules-list p {
    font-size: 14px;
}
.rules-list li {
    padding: 12px;
}
.winner-modal .trophy {
    animation: none;
}
.winner-modal .winner-card {
    box-shadow: 0 24px 80px #221b3930;
}
.recap {
    text-align: left;
    margin: 20px auto;
    max-width: 650px;
}
.recap summary {
    cursor: pointer;
    font-size: 15px;
    font-weight: 650;
}
.recap ul {
    list-style: none;
    padding: 0;
}
.recap li {
    border-top: 1px solid #e6e0ed;
    padding: 12px 0;
    font-size: 13px;
    color: var(--muted);
}
.recap img {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 10px auto;
    background: #fff;
    border-radius: 10px;
}
.drawing-canvas-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.drawing-canvas-wrap canvas {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 3/2;
    object-fit: contain;
    border-radius: 6px;
    align-self: center;
}
.drawing-toolbar {
    gap: 8px;
}
.drawing-topbar {
    box-shadow: none;
}
.dialog-open {
    overflow: hidden;
}
.drawing-workspace {
    height: 100dvh;
}
.modal-card {
    max-height: calc(100dvh - 44px);
}
@media (min-width: 900px) and (max-height: 850px) {
    body[data-stage="timer-stage"] .timer-stage {
        display: grid;
        grid-template-columns: 1fr 1fr;
        align-items: center;
        gap: 6px 26px;
    }
    .timer-stage .timer-mode,
    .timer-stage .timer-rule,
    .timer-stage .early-success-note {
        grid-column: 1;
    }
    .timer-stage .timer-ring {
        grid-column: 1;
        grid-row: 2/6;
        width: 230px;
    }
    .timer-stage .timer-actions-main {
        grid-column: 2;
        grid-row: 3/6;
        margin: 0;
    }
    .timer-stage .timer-rule {
        grid-row: 6;
    }
    .timer-stage .early-success-note {
        grid-row: 7;
    }
    .turn-panel {
        padding-top: 18px;
        padding-bottom: 20px;
    }
    .turn-panel h1 {
        font-size: 36px;
    }
    .lead {
        margin-bottom: 12px;
    }
}
@media (max-width: 600px) {
    .action-topbar {
        padding: 0 10px;
    }
    .setup-panel h1 {
        letter-spacing: -1.4px;
    }
    .panel {
        padding: 22px 17px;
    }
    .score-team {
        min-width: 145px;
    }
    .timer-actions-main .button {
        font-size: 15px;
    }
    .turn-panel h1 {
        font-size: 32px;
    }
    .option-toggle-grid {
        gap: 8px;
    }
    .option-toggle-card {
        margin: 6px 0;
    }
    .drawing-topbar {
        gap: 6px;
    }
    .drawing-canvas-wrap {
        padding: 8px;
    }
    .drawing-prestart-overlay {
        inset: 8px;
    }
    .drawing-toolbar button {
        min-height: 40px;
    }
    .drawing-color {
        width: 34px !important;
        min-width: 34px;
    }
    .drawing-topbar > div:first-child strong {
        font-size: 14px;
    }
}
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
    .winner-confetti {
        display: none;
    }
}
html[data-motion="off"] *,
html[data-motion="off"] *::before,
html[data-motion="off"] *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}
html[data-motion="off"] .winner-confetti {
    display: none;
}
.option-toggle-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto 1fr;
    align-items: start;
    min-height: 116px;
    border: 1px solid #dfd9e8;
    border-radius: 16px;
    background: #faf8fd;
    margin: 0;
}
.option-toggle-card .adult-toggle-copy {
    grid-column: 1;
    grid-row: 1/3;
}
.option-toggle-card .switch {
    grid-column: 2;
    grid-row: 1;
}
.option-toggle-card .adult-badge,
.option-toggle-card .open-badge,
.option-toggle-card .sound-badge {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
    margin-top: 5px;
}
.option-toggle-grid {
    gap: 12px;
    margin: 18px 0;
}
.setup-panel h1 {
    font-size: clamp(36px, 5vw, 52px);
}
.score-team-points span {
    font-size: 12px;
}
@media (min-width: 900px) and (max-height: 850px) {
    body[data-stage="timer-stage"] .game-view {
        margin-top: 10px;
    }
    body[data-stage="timer-stage"] .score-team {
        padding: 9px 14px;
    }
    body[data-stage="timer-stage"] .score-team-points strong {
        font-size: 24px;
    }
    body[data-stage="timer-stage"] .turn-panel {
        padding: 14px 26px;
    }
    body[data-stage="timer-stage"] .turn-panel h1 {
        font-size: 32px;
        margin: 6px 0;
    }
    body[data-stage="timer-stage"] .current-team-label {
        margin-top: 10px;
    }
    body[data-stage="timer-stage"] .stage {
        margin-top: 10px;
    }
    .timer-stage .timer-ring {
        width: 210px;
    }
    .timer-stage .early-success-note {
        display: none;
    }
    .timer-stage .timer-rule {
        margin-top: 6px;
    }
    .timer-stage .timer-actions-main .button {
        min-height: 54px;
    }
    .timer-stage .timer-number {
        font-size: 94px;
    }
}
@media (max-width: 900px) {
    .option-toggle-card {
        min-height: 0;
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
    }
    .option-toggle-card .switch {
        grid-column: 1;
        grid-row: 1;
    }
    .option-toggle-card .adult-toggle-copy {
        grid-column: 2;
        grid-row: 1;
    }
    .option-toggle-card .adult-badge,
    .option-toggle-card .open-badge,
    .option-toggle-card .sound-badge {
        grid-column: 3;
        grid-row: 1;
        margin: 0;
    }
    .option-toggle-grid {
        gap: 8px;
    }
}

/* Touch layouts: safe screen edges, readable inputs and reachable controls. */
select {
    background: #fff;
    border: 1px solid #d4cede;
    border-radius: 11px;
    padding: 10px;
    color: var(--ink);
    font-size: 16px;
    min-height: 44px;
}
@media (max-width: 600px) {
    body[data-stage="timer-stage"] .score-team {
        padding: 8px 12px;
    }
    body[data-stage="timer-stage"] .turn-panel {
        padding: 14px 16px;
    }
    body[data-stage="timer-stage"] .turn-meta {
        gap: 6px;
    }
    body[data-stage="timer-stage"] .current-team-label {
        margin-top: 8px;
    }
    body[data-stage="timer-stage"] #current-team {
        font-size: 26px;
        margin: 4px 0;
    }
    body[data-stage="timer-stage"] #turn-instruction {
        display: none;
    }
    body[data-stage="timer-stage"] .stage {
        margin-top: 10px;
    }
    body[data-stage="timer-stage"] .timer-ring {
        width: 150px;
        margin: 8px auto;
    }
    body[data-stage="timer-stage"] .timer-number {
        font-size: 62px;
    }
    body[data-stage="timer-stage"] .timer-rule {
        font-size: 12px;
        margin: 6px 0;
    }
    body[data-stage="timer-stage"] .early-success-note {
        padding: 8px;
        margin: 8px 0;
    }
    body[data-stage="timer-stage"] .timer-actions-main {
        margin-top: 10px;
        gap: 8px;
    }
}
.action-shell {
    min-height: 100dvh;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}
.action-topbar {
    height: auto;
    min-height: 64px;
    padding-top: env(safe-area-inset-top);
}
.team-row {
    min-width: 0;
}
.team-row input {
    min-width: 0;
}
.score-team-name,
.turn-panel h1,
.mobile-live-status {
    overflow-wrap: anywhere;
}
.modal-card {
    overscroll-behavior: contain;
}
@media (pointer: coarse) {
    button,
    .text-button,
    .playback-settings summary {
        min-height: 44px;
        touch-action: manipulation;
    }
    .option-toggle-card,
    .output-mode-card {
        touch-action: manipulation;
    }
    .drawing-toolbar button {
        min-height: 44px;
    }
    .drawing-color {
        width: 44px !important;
        min-width: 44px;
    }
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    select {
        font-size: 16px;
    }
}
@media (max-width: 600px) {
    .action-topbar {
        min-height: 52px;
        grid-template-columns: auto 1fr auto;
        gap: 4px;
    }
    .action-logo {
        justify-self: center;
    }
    .action-topbar .text-button {
        font-size: 13px;
        padding: 8px;
    }
    .setup-panel {
        margin-top: 12px;
        padding: 20px 16px;
    }
    .setup-panel h1 {
        font-size: 32px;
        margin: 10px 0;
    }
    .setup-panel .brand-mark {
        width: 68px;
        height: 68px;
        font-size: 60px;
        margin-bottom: 12px;
    }
    .setup-panel .lead {
        font-size: 15px;
        margin-bottom: 20px;
    }
    .section-kicker {
        font-size: 10px;
        letter-spacing: 1px;
    }
    .team-row {
        grid-template-columns: 36px minmax(0, 1fr) 44px;
        gap: 8px;
    }
    .team-number {
        width: 36px;
        height: 36px;
    }
    .team-row input {
        font-size: 16px;
        padding: 12px;
    }
    .team-add-action .button,
    .setup-actions .button {
        width: 100%;
    }
    .timer-ring {
        max-width: min(70vw, 260px);
    }
    .drawing-colors {
        flex-wrap: wrap;
    }
    .playback-settings > div {
        gap: 12px;
    }
    .modal {
        padding: 10px;
    }
    .modal-card {
        max-height: calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    }
}
@media (orientation: landscape) and (max-height: 500px) {
    .action-topbar {
        position: relative;
    }
    .timer-ring {
        width: 180px;
        margin: 10px auto;
    }
    .timer-number {
        font-size: 70px;
    }
    .drawing-colors {
        order: initial;
        width: auto;
    }
    .drawing-size {
        order: initial;
    }
    .drawing-toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        touch-action: pan-x;
    }
    .drawing-toolbar > * {
        flex-shrink: 0;
    }
    .drawing-topbar {
        padding-top: max(5px, env(safe-area-inset-top));
        padding-bottom: 5px;
    }
}

.action-logo span {
    font-size: 32px;
}
@media (max-width: 760px) {
    .action-logo strong {
        display: inline;
        font-size: 15px;
        letter-spacing: -0.4px;
    }
    .action-logo {
        gap: 5px;
    }
    .action-logo span {
        font-size: 26px;
    }
}
@media (max-width: 350px) {
    .action-logo strong {
        font-size: 13px;
    }
    .action-topbar > a {
        padding: 6px;
        font-size: 13px;
    }
}

#previous-term-feedback {
    max-width: 100%;
}
#previous-term-feedback p {
    max-width: 42rem;
    overflow-wrap: anywhere;
    font-size: 14px;
    line-height: 1.5;
}
#feedback-term {
    font-weight: 650;
}
.feedback-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 6px;
}
.feedback-controls select {
    width: 100%;
    min-width: 0;
}
.feedback-controls .button {
    min-height: 44px;
    margin: 0;
}
#previous-term-feedback[open] {
    flex-basis: 100%;
    padding: 12px;
    background: #f7f5fa;
    border-radius: 12px;
    text-align: left;
}
#previous-term-feedback summary {
    padding: 8px;
    user-select: none;
    -webkit-user-select: none;
}
#previous-term-feedback select:focus:not(:focus-visible),
#previous-term-feedback button:focus:not(:focus-visible),
#previous-term-feedback summary:focus:not(:focus-visible) {
    outline: none;
}
@media (max-width: 450px) {
    .feedback-controls {
        grid-template-columns: minmax(0, 1fr);
    }
    .feedback-controls .button {
        width: 100%;
    }
}

.rules-card {
    position: relative;
}
.rules-close {
    position: sticky;
    top: 0;
    z-index: 2;
    display: block;
    margin: -12px -12px -32px auto;
    width: 44px;
    height: 44px;
    border: 1px solid #ded9e9;
    border-radius: 50%;
    background: #fff;
    color: #433a80;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}
.rules-card h2 {
    padding: 0 26px;
}

.recap-result {
    display: block;
    width: fit-content;
    margin: 6px 0;
    padding: 5px 9px;
    border-radius: 8px;
    font-size: 13px;
}
.recap-success {
    background: #e3f3e9;
    color: #185c38;
}
.recap-failed {
    background: #fce7eb;
    color: #92233b;
}
body.drawing-active,
.drawing-workspace,
.drawing-workspace * {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
.drawing-workspace,
.drawing-canvas-wrap,
#drawing-canvas {
    touch-action: none;
}
.drawing-workspace *::selection {
    background: transparent;
}

.brand-status {
    justify-self: center;
    min-width: 0;
}
.brand-status .action-logo {
    justify-content: center;
}
.brand-status .connection-bar {
    margin: 0;
    padding: 0;
    min-height: 16px;
    justify-content: center;
    gap: 6px;
    font-size: 10px;
}
.brand-status .connection-bar .text-button {
    font-size: 11px;
    padding: 2px 4px;
    min-height: 24px;
}
.brand-status .connection-bar > span:before {
    width: 5px;
    height: 5px;
}
@media (max-width: 600px) {
    .brand-status .connection-bar {
        max-width: 155px;
        font-size: 9px;
        flex-wrap: wrap;
    }
    .brand-status .connection-bar > span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}
@media (min-width: 700px) {
    .game-view {
        margin-top: 10px;
    }
    .game-view > .turn-panel {
        width: 100%;
        min-width: 0;
        margin: 0;
        padding: 18px;
    }
    .ai-help-text {
        max-height: 45dvh;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    .game-view .current-team-label {
        margin-top: 8px;
    }
    .game-view #current-team {
        font-size: 30px;
        margin: 4px 0;
    }
    .game-view .lead {
        font-size: 14px;
        margin: 6px 0;
    }
    .game-view .stage {
        margin-top: 12px;
    }
    .game-view .score-team {
        padding: 9px 12px;
    }
    .game-view .mode-card {
        padding: 12px;
        gap: 5px;
    }
    .game-view .mode-card .category-icon {
        width: 32px;
        height: 32px;
    }
    .game-view .mode-card strong {
        font-size: 24px;
    }
    .game-view .control-note {
        font-size: 12px;
        margin: 10px 0;
        padding: 10px;
    }
    .game-view .ready-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .game-view .ready-actions .button {
        min-height: 48px;
        font-size: 14px;
    }
    .game-view .reroll-hint {
        font-size: 11px;
        margin: 8px 0 0;
    }
}

/* The help stays below the game, as a compact horizontal panel. */
.game-view > .ai-help-panel {
    position: static;
    width: 100%;
    margin: 8px auto 0;
    padding: 10px 14px;
    border-radius: 14px;
}
.ai-help-head {
    flex-direction: row;
    align-items: center;
    gap: 12px;
}
.ai-help-kicker {
    display: none;
}
.ai-help-head strong {
    font-size: 15px;
}
.ai-help-head .ai-help-button {
    width: auto;
    min-height: 44px;
    padding: 8px 14px;
}
.ai-help-note {
    font-size: 11px;
    margin-top: 5px;
    line-height: 1.35;
}
.ai-help-text {
    margin-top: 8px;
    padding: 10px 12px;
    max-height: 30dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    font-size: 15px;
}
.ai-help-confirm {
    margin-top: 8px;
    min-height: 44px;
    padding: 8px 12px;
}
@media (min-width: 700px) and (max-height: 850px) {
    body[data-stage="timer-stage"] #turn-instruction {
        display: none;
    }
    body[data-stage="timer-stage"] .timer-stage .timer-ring {
        width: 195px;
    }
    body[data-stage="timer-stage"] .timer-stage .timer-number {
        font-size: 86px;
    }
    body[data-stage="timer-stage"] .timer-rule {
        margin: 6px 0;
        font-size: 12px;
    }
    .game-view .turn-panel {
        padding: 14px 18px;
    }
}
@media (max-width: 400px) {
    .ai-help-head strong {
        font-size: 13px;
    }
    .ai-help-head .ai-help-button {
        font-size: 13px;
        padding: 8px 10px;
    }
}

/* Optional setup features stay collapsed; gameplay keeps its compact layout. */
.team-generator,
.preflight,
.gallery {
    margin: 16px 0;
    padding: 14px;
    border: 1px solid var(--line, #ded8eb);
    border-radius: 14px;
    text-align: left;
}
.team-generator summary,
.preflight summary,
.gallery summary,
.team-players summary {
    cursor: pointer;
    font-weight: 700;
}
.team-generator label {
    display: block;
    margin: 12px 0 6px;
}
.team-generator textarea,
.team-players textarea {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    padding: 10px;
    border: 1px solid #cfc6dc;
    border-radius: 10px;
    font: inherit;
    resize: vertical;
}
.team-players {
    grid-column: 2 / -1;
    min-width: 0;
    font-size: 13px;
    text-align: left;
}
.team-players textarea {
    margin-top: 8px;
}
.generator-actions {
    display: flex;
    gap: 12px;
    align-items: end;
    flex-wrap: wrap;
}
.generator-actions input {
    width: 72px;
    padding: 9px;
    font: inherit;
}
.team-generator p,
.preflight p {
    font-size: 13px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}
.current-player {
    margin: 4px 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--purple);
}
.drawing-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
    gap: 16px;
    margin-top: 12px;
}
.drawing-gallery figure {
    margin: 0;
    min-width: 0;
    border: 1px solid #ded8eb;
    border-radius: 12px;
    overflow: hidden;
    padding: 10px;
    background: #fff;
}
.drawing-gallery img {
    width: 100%;
    aspect-ratio: 3/2;
    object-fit: contain;
    background: #fff;
}
.drawing-gallery figcaption {
    margin: 8px 0;
    overflow-wrap: anywhere;
}
.drawing-gallery a {
    font-size: 13px;
}
#recap-list li {
    display: block;
    padding: 14px 0;
    overflow-wrap: anywhere;
}
#recap-list .recap-result {
    display: block;
    margin: 6px 0;
}
#recap-list p {
    margin: 4px 0;
    font-size: 13px;
    line-height: 1.45;
}
.recap-rerolled {
    color: #72500a;
}
/* Team setup: one integrated draw panel and compact, editable team cards. */
.setup-panel .hero-icon {
    font-size: 64px;
    margin-bottom: 8px;
}
.setup-panel h1 {
    font-size: clamp(32px, 5vw, 46px);
    line-height: 1.08;
    margin: 10px 0;
}
.setup-panel > .lead {
    margin: 12px auto 24px;
    max-width: 580px;
    font-size: 16px;
}
.team-generator {
    padding: 0;
    margin: 0 0 28px;
    border: 1px solid #ded8ed;
    border-radius: 20px;
    background: linear-gradient(125deg, #f4f0ff, #faf9fd);
    overflow: hidden;
}
.team-generator > summary {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px;
    list-style: none;
}
.team-generator > summary::-webkit-details-marker {
    display: none;
}
.generator-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    background: #fff;
    border-radius: 15px;
    font-size: 25px;
    box-shadow: 0 3px 12px #433a8009;
}
.team-generator summary strong {
    display: block;
    font-size: 20px;
    color: #433a80;
}
.team-generator summary small {
    display: block;
    margin-top: 4px;
    font-weight: 400;
    font-size: 13px;
    color: #736786;
}
.generator-chevron {
    margin-left: auto;
    font-size: 22px;
    transition: transform 0.15s;
}
.team-generator[open] .generator-chevron {
    transform: rotate(180deg);
}
.generator-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 210px;
    gap: 14px 22px;
    padding: 0 20px 18px;
}
.generator-entry,
.generator-controls {
    min-width: 0;
}
.generator-label {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}
.team-generator label {
    font-size: 13px;
    font-weight: 700;
    margin: 0;
    color: #55476c;
}
#generator-people {
    font-size: 12px;
    border-radius: 20px;
    padding: 4px 9px;
    background: #e9e2f6;
    color: #574477;
    white-space: nowrap;
}
.team-generator textarea {
    display: block;
    min-height: 150px;
    background: #fff;
    border-color: #dbd3e9;
    font-size: 16px;
    line-height: 1.65;
    border-radius: 12px;
    padding: 12px 14px;
}
.team-generator textarea:focus,
.team-players textarea:focus,
#generator-count:focus {
    outline: 3px solid #bca9df66;
    outline-offset: 2px;
    border-color: #8f75b8;
}
.generator-entry p {
    font-size: 12px;
    color: #7b7088;
    margin: 8px 0 0;
}
.generator-controls {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    border-left: 1px solid #ded6eb;
    padding-left: 22px;
}
#generator-count {
    width: 100%;
    margin: 8px 0 0;
    padding: 12px 14px;
    border: 1px solid #dbd3e9;
    border-radius: 12px;
    background: #fff;
    font: 700 23px system-ui;
    color: #433a80;
}
.generator-controls p {
    color: #746487;
    line-height: 1.6;
    margin: 10px 0;
}
.generator-controls .button {
    margin-top: auto;
    width: 100%;
    padding: 13px 8px;
    min-height: 48px;
    font-size: 14px;
}
#generator-status {
    grid-column: 1/-1;
    margin: 0;
    padding-top: 12px;
    border-top: 1px solid #e2dceb;
    color: #655775;
    font-size: 12px;
    line-height: 1.5;
}
.team-section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    text-align: left;
    margin: 0 0 12px;
}
.team-section-heading h2 {
    margin: 0;
    font-size: 20px;
    color: #433a80;
}
.team-section-heading > span {
    font-size: 12px;
    color: #867a94;
}
.setup-panel .team-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    max-width: none;
    margin: 0;
}
.setup-panel .team-row {
    position: relative;
    grid-template-columns: 34px minmax(0, 1fr) 30px;
    align-content: start;
    gap: 9px;
    padding: 15px;
    border: 1px solid #e3ddec;
    border-top: 3px solid var(--team-color);
    border-radius: 15px;
    background: #fff;
    box-shadow: 0 4px 15px #433a8005;
}
.setup-panel .team-number {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--team-color);
    font-size: 14px;
}
.setup-panel .team-row > input {
    font-size: 16px;
    padding: 8px 5px;
    border: 0;
    border-bottom: 1px solid #e5deee;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    width: 100%;
}
.setup-panel .remove-team {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    font-size: 19px;
}
.player-chips {
    grid-column: 1/-1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
    padding: 6px 0;
    align-content: start;
}
.player-chips > span {
    border-radius: 8px;
    background: #f3f0f8;
    padding: 6px 9px;
    font-size: 13px;
    color: #504361;
    overflow-wrap: anywhere;
    max-width: 100%;
}
.player-chips small {
    font-size: 12px;
    color: #9a8da5;
    line-height: 1.5;
}
.setup-panel .team-players {
    grid-column: 1/-1;
    border-top: 1px solid #eee8f3;
    padding-top: 9px;
    font-size: 12px;
    color: #82738e;
}
.team-players summary {
    font-weight: 500;
}
.team-players textarea {
    font-size: 16px;
    line-height: 1.5;
}
.team-add-action {
    margin: 14px 0 24px;
}
@media (max-width: 600px) {
    .generator-body {
        grid-template-columns: 1fr;
        padding: 0 14px 14px;
        gap: 14px;
    }
    .team-generator > summary {
        padding: 16px 14px;
        gap: 10px;
    }
    .team-generator summary strong {
        font-size: 18px;
    }
    .generator-controls {
        border-left: 0;
        padding-left: 0;
        display: grid;
        grid-template-columns: 80px minmax(0, 1fr);
        gap: 8px 12px;
        align-items: center;
    }
    .generator-controls label {
        grid-column: 1/-1;
    }
    #generator-count {
        margin: 0;
    }
    .generator-controls p {
        display: none;
    }
    .generator-controls .button {
        margin: 0;
        height: 100%;
        font-size: 14px;
    }
    .setup-panel .team-list {
        grid-template-columns: 1fr;
    }
    .team-section-heading {
        align-items: start;
        flex-direction: column;
        gap: 3px;
    }
    .setup-panel .hero-icon {
        font-size: 52px;
    }
}
/* Optional generator lives outside the setup form, in its own dialog. */
.generator-card.team-generator {
    width: min(620px, 100%);
    margin: auto;
    padding: 22px;
    overflow: auto;
    max-height: calc(100dvh - 32px);
    text-align: left;
    background: #faf8ff;
}
.generator-card h2 {
    margin: 0 32px 8px 0;
    font-size: 24px;
    color: #433a80;
}
.generator-card .generator-intro {
    font-size: 14px;
    line-height: 1.5;
    color: #7b6e8c;
    margin: 0 0 20px;
}
.generator-card .generator-body {
    padding: 0;
    grid-template-columns: minmax(0, 1fr) 180px;
}
.generator-card .rules-close {
    position: absolute;
    top: 12px;
    right: 12px;
}
.generator-card {
    position: relative;
}
.team-section-heading #open-generator {
    font-size: 13px;
    font-weight: 600;
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid #e3ddec;
    border-radius: 10px;
    background: #faf8fd;
    white-space: nowrap;
}
@media (min-width: 650px) {
    .setup-panel {
        padding: 20px 26px;
    }
    .setup-panel .hero-icon {
        font-size: 38px;
        line-height: 1;
        margin: 0 auto 6px;
    }
    .setup-panel h1 {
        font-size: 32px;
        margin: 8px 0;
        line-height: 1.15;
    }
    .setup-panel h1 br {
        display: none;
    }
    .setup-panel > .lead {
        font-size: 14px;
        line-height: 1.4;
        margin: 8px auto 16px;
        max-width: none;
    }
    .setup-panel .team-row {
        padding: 11px;
        gap: 6px;
    }
    .setup-panel .team-section-heading {
        margin-bottom: 8px;
        align-items: center;
    }
    .setup-panel .team-add-action {
        margin: 8px 0 14px;
    }
    .setup-panel .team-add-action .button {
        padding: 9px 14px;
        min-height: 38px;
    }
    .setup-panel .option-toggle-grid {
        margin: 10px 0;
        gap: 10px;
    }
    .setup-panel .option-toggle-card {
        min-height: 82px;
        padding: 12px;
    }
    .setup-panel .output-mode-picker {
        margin: 14px 0;
    }
    .setup-panel .output-mode-card {
        min-height: 66px;
        padding: 12px;
    }
    .setup-panel .setup-actions {
        margin-top: 12px;
    }
    .setup-panel .setup-actions .button {
        min-height: 46px;
        padding: 12px 22px;
    }
    .setup-panel .setup-note {
        margin: 10px 0 0;
    }
}
@media (max-width: 649px) {
    .generator-card.team-generator {
        padding: 18px;
        max-height: calc(100dvh - 24px);
    }
    .generator-card .generator-body {
        grid-template-columns: 1fr;
    }
    .team-section-heading {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 8px;
    }
}
@media (min-width: 650px) {
    .setup-panel .hero-icon.brand-mark {
        width: 42px;
        height: 42px;
    }
    .setup-panel > .fine-print {
        margin: 10px 0 0;
    }
}
@media (min-width: 900px) and (max-height: 850px) {
    .setup-panel .hero-icon.brand-mark {
        display: none;
    }
    .setup-panel > .lead {
        display: none;
    }
    .setup-panel h1 {
        margin: 6px 0 16px;
    }
    .setup-panel {
        margin-top: 8px;
        padding-top: 16px;
        padding-bottom: 16px;
    }
}
/* Keep constrained setup controls and notices centered inside their panels. */
.setup-panel .output-mode-picker {
    width: min(760px, 100%);
    min-inline-size: 0;
    margin-inline: auto;
}
.output-mode-card {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-width: 0;
}
.output-mode-card span:last-child {
    min-width: 0;
    overflow-wrap: anywhere;
}
.game-view .control-note {
    width: min(760px, 100%);
    margin-inline: auto;
    text-align: center;
}
.game-view .lead {
    margin-inline: auto;
    text-align: center;
}
.endgame-note,
.adult-rule-warning,
.open-rule-warning,
.early-success-note {
    margin-inline: auto;
    text-align: center;
    max-width: 100%;
    overflow-wrap: anywhere;
}
