/* Fischietto · Match simulation page (builds on the components in app.css) */

.sim-body {
    background: var(--bg);
    min-height: 100vh;
    min-height: 100dvh;
}

.sim-root {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ---------- Top bar ---------- */
.sim-top {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    padding-top: max(8px, env(safe-area-inset-top));
    background: var(--hero);
    color: var(--on-hero);
    flex-shrink: 0;
    position: relative;
    z-index: 5;
}

.sim-back {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: inherit;
}

.sim-back:hover {
    background: rgba(255, 255, 255, .1);
}

.sim-title {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
}

.sim-title strong {
    font-size: .98rem;
}

.sim-title span {
    font-size: .72rem;
    opacity: .7;
}

.sim-top-right {
    margin-left: auto;
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    justify-content: flex-end;
    flex-shrink: 0;
}

.sim-title strong {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sim-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    border-radius: var(--r-pill);
    border: 1px solid rgba(255, 255, 255, .22);
    background: rgba(255, 255, 255, .08);
    color: inherit;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
}

.sim-chip:hover {
    background: rgba(255, 255, 255, .16);
}

.sim-chip.active {
    background: var(--on-hero);
    color: var(--hero);
}

/* ---------- Setup ---------- */
.sim-setup {
    width: 100%;
    max-width: 920px;
    margin: 0 auto;
    padding: 22px 16px 40px;
    display: grid;
    gap: 16px;
}

.sim-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 24px;
    box-shadow: var(--shadow-1);
}

.sim-card h1 {
    font-size: 1.5rem;
    letter-spacing: -.02em;
    margin-bottom: 6px;
}

.sim-lead {
    color: var(--text-2);
    max-width: 64ch;
    line-height: 1.55;
}

.sim-h2 {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
    font-weight: 700;
    margin: 22px 0 10px;
}

.role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
    gap: 10px;
}

.role-card {
    text-align: left;
    padding: 14px 16px;
    border-radius: var(--r-md);
    border: 1.5px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.role-card strong {
    font-size: 1rem;
}

.role-card span {
    font-size: .84rem;
    color: var(--text-2);
    line-height: 1.45;
}

.role-card.active {
    border-color: var(--blue);
    background: var(--blue-soft);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent);
}

.sim-options {
    display: grid;
    gap: 14px;
    margin-top: 20px;
}

.sim-opt {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
}

.sim-opt-label {
    font-weight: 600;
    min-width: 190px;
}

.sim-start-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 18px;
    margin-top: 24px;
}

kbd {
    font-family: var(--font);
    font-size: .75rem;
    padding: 1px 6px;
    border-radius: 5px;
    border: 1px solid var(--line);
    background: var(--surface-2);
}

/* Stats */
.ss-totals {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.ss-tile {
    flex: 1 1 120px;
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-md);
    padding: 12px 14px;
}

.ss-tile b {
    display: block;
    font-family: var(--font-score);
    font-size: 1.9rem;
    line-height: 1.05;
}

.ss-tile span {
    font-size: .8rem;
    color: var(--text-3);
}

.ss-row {
    display: grid;
    grid-template-columns: minmax(120px, 1.2fr) minmax(0, 2fr) 56px;
    gap: 10px;
    align-items: center;
    padding: 6px 0;
    font-size: .88rem;
}

.ss-bar {
    height: 8px;
    border-radius: 4px;
    background: var(--inset);
    overflow: hidden;
}

.ss-bar span {
    display: block;
    height: 100%;
    background: var(--green);
    border-radius: 4px;
}

.ss-row .ss-num {
    text-align: right;
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
}

/* ---------- Game ---------- */
.sim-game {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: #0f1728;
}

#sim-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

.scoreboard {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: stretch;
    background: rgba(10, 18, 34, .82);
    color: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
    font-family: var(--font-score);
    backdrop-filter: blur(4px);
}

.sb-team {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
}

.sb-a {
    background: rgba(47, 111, 208, .35);
}

.sb-b {
    background: rgba(226, 85, 43, .35);
}

.sb-name {
    font-weight: 700;
    font-size: 1rem;
    opacity: .9;
}

.sb-score {
    font-weight: 700;
    font-size: 1.9rem;
    min-width: 1.4em;
    text-align: center;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.sb-serve {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.sb-serve.on {
    background: #ffd54f;
    box-shadow: 0 0 0 3px rgba(255, 213, 79, .25);
}

.sb-mid {
    display: grid;
    place-items: center;
    padding: 0 10px;
    font-family: var(--font);
    font-size: .7rem;
    opacity: .75;
}

.sim-badges {
    position: absolute;
    top: 14px;
    left: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
}

.sim-badge {
    background: rgba(10, 18, 34, .75);
    color: #fff;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .04em;
    padding: 5px 10px;
    border-radius: var(--r-pill);
}

.sim-badge.slow {
    background: #ffd54f;
    color: #14264a;
    text-transform: uppercase;
}

.sim-banner {
    position: absolute;
    top: 74px;
    left: 50%;
    transform: translateX(-50%);
    max-width: min(560px, calc(100% - 24px));
    background: rgba(255, 255, 255, .96);
    color: #14264a;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: .9rem;
    line-height: 1.45;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
    text-align: center;
}

.sim-banner strong {
    display: block;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #7a879e;
    margin-bottom: 2px;
}

.sim-controls {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px 16px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: linear-gradient(to top, rgba(10, 18, 34, .85), rgba(10, 18, 34, 0));
}

.sim-hint {
    color: #e6ecf7;
    font-size: .86rem;
    text-align: center;
    min-height: 1.2em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}

.sim-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.sim-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 54px;
    padding: 0 26px;
    border-radius: var(--r-pill);
    border: 0;
    font-size: 1.02rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}

.sim-btn.whistle {
    background: #ffffff;
    color: #14264a;
    min-width: 170px;
    justify-content: center;
}

.sim-btn.whistle:active {
    transform: scale(.97);
}

.sim-btn.whistle.pulse {
    animation: pulse-w 1s ease-in-out infinite;
}

.sim-btn.authorize {
    background: var(--blue);
    color: #fff;
}

.sim-btn.authorize.pulse {
    animation: pulse-a 1.1s ease-in-out infinite;
}

.sim-btn:disabled {
    opacity: .45;
    cursor: default;
}

@keyframes pulse-w {
    50% {
        box-shadow: 0 0 0 10px rgba(255, 255, 255, .18), 0 6px 18px rgba(0, 0, 0, .35);
    }
}

@keyframes pulse-a {
    50% {
        box-shadow: 0 0 0 10px rgba(47, 111, 208, .3), 0 6px 18px rgba(0, 0, 0, .35);
    }
}

@media (prefers-reduced-motion: reduce) {
    .sim-btn.pulse {
        animation: none;
    }
}

/* On-screen movement controller: phones and tablets (on desktop: arrow keys) */
.move-pad {
    position: absolute;
    left: 14px;
    bottom: max(20px, env(safe-area-inset-bottom));
    display: none;
    gap: 8px;
    z-index: 2;
}

.move-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .35);
    background: rgba(10, 18, 34, .6);
    color: #fff;
    display: grid;
    place-items: center;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.move-btn.active {
    background: rgba(255, 255, 255, .9);
    color: #14264a;
}

@media (pointer: coarse), (max-width: 820px) {
    .move-pad {
        display: flex;
    }
}

@media (max-width: 520px) {
    .move-pad {
        left: 10px;
        bottom: max(16px, env(safe-area-inset-bottom));
    }

    .move-btn {
        width: 50px;
        height: 50px;
    }

    /* Controller on the left, the two big buttons stacked on the right */
    .sim-controls {
        align-items: flex-end;
        padding-left: 128px;
    }

    .sim-buttons {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        max-width: 230px;
    }

    .sim-btn {
        justify-content: center;
        padding: 0 14px;
    }

    .sim-btn.whistle {
        min-width: 0;
    }

    .sim-hint {
        text-align: right;
    }
}

/* Score sheet drawer */
.sheet {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(380px, 100%);
    background: var(--surface);
    color: var(--text);
    box-shadow: -10px 0 30px rgba(0, 0, 0, .3);
    display: flex;
    flex-direction: column;
    z-index: 4;
}

.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.sheet-body {
    overflow: auto;
    padding: 12px 16px 24px;
    font-size: .86rem;
}

.sh-team {
    margin-bottom: 18px;
}

.sh-team h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .95rem;
    margin-bottom: 8px;
}

.sh-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.sh-pos {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.sh-pos div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 4px 6px;
    text-align: center;
    font-family: var(--font-score);
    font-size: 1.05rem;
    font-weight: 700;
}

.sh-pos div small {
    display: block;
    font-family: var(--font);
    font-size: .64rem;
    font-weight: 600;
    color: var(--text-3);
}

.sh-pos .lib {
    background: var(--amber-soft);
}

.sh-line {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 0;
    border-top: 1px solid var(--line-soft);
}

.sh-line span:first-child {
    color: var(--text-3);
}

.sh-line span:last-child {
    text-align: right;
}

/* ---------- Decision, feedback ---------- */
.sim-modal {
    z-index: 60;
}

.sim-decision {
    max-width: 640px;
}

.dec-group {
    margin-top: 12px;
}

.dec-group h5 {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
    margin-bottom: 6px;
}

.dec-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.dec-btn {
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
}

.dec-btn:hover {
    border-color: var(--blue);
}

.dec-btn.team-a {
    background: #2f6fd0;
    color: #fff;
    border-color: #2f6fd0;
    min-width: 130px;
    justify-content: center;
    text-align: center;
}

.dec-btn.team-b {
    background: #e2552b;
    color: #fff;
    border-color: #e2552b;
    min-width: 130px;
    text-align: center;
}

.dec-back {
    margin-top: 14px;
}

.dec-event {
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    padding: 12px 14px;
    margin: 6px 0 4px;
    line-height: 1.5;
}

.sim-feedback {
    max-width: 640px;
    max-height: calc(100dvh - 40px);
    overflow: auto;
}

.fb-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fb-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 800;
    flex-shrink: 0;
}

.fb-head.ok .fb-icon {
    background: var(--green);
}

.fb-head.ko .fb-icon {
    background: var(--red);
}

.fb-head.info .fb-icon {
    background: var(--blue);
}

.fb-section {
    margin-top: 12px;
}

.fb-section h5 {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
    margin-bottom: 4px;
}

.fb-section p {
    line-height: 1.5;
}

.fb-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

.fb-compare div {
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    font-size: .9rem;
}

.fb-compare small {
    display: block;
    color: var(--text-3);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 2px;
}

.fb-note {
    margin-top: 10px;
    font-size: .86rem;
    color: var(--amber-strong);
    background: var(--amber-soft);
    border-radius: 10px;
    padding: 8px 12px;
}

.fb-refs {
    display: grid;
    gap: 6px;
}

.fb-ref {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 12px;
}

.fb-ref summary {
    cursor: pointer;
    font-weight: 600;
    font-size: .9rem;
    list-style: none;
    display: flex;
    gap: 8px;
    align-items: baseline;
}

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

.fb-ref summary .code {
    font-family: var(--font-score);
    color: var(--blue-strong);
    flex-shrink: 0;
}

.fb-ref p {
    margin-top: 6px;
    font-size: .86rem;
    color: var(--text-2);
    line-height: 1.5;
    white-space: pre-line;
}

@media (max-width: 520px) {
    .fb-compare {
        grid-template-columns: 1fr;
    }
}

/* ---------- Point assignment: tappable half courts ---------- */
.pick-layer {
    position: absolute;
    inset: 0;
    z-index: 5;
}

.pick-layer[hidden] {
    display: none;
}

.pick-layer svg {
    position: absolute;
    inset: 0;
}

.pick-half {
    cursor: pointer;
    outline: none;
}

.pick-half polygon {
    fill: rgba(255, 255, 255, .06);
    stroke: rgba(255, 255, 255, .55);
    stroke-width: 2;
    stroke-dasharray: 6 6;
    transition: fill .15s;
}

.pick-a:hover polygon, .pick-a:focus-visible polygon {
    fill: rgba(47, 111, 208, .30);
    stroke: #fff;
    stroke-dasharray: none;
}

.pick-b:hover polygon, .pick-b:focus-visible polygon {
    fill: rgba(226, 85, 43, .30);
    stroke: #fff;
    stroke-dasharray: none;
}

.pick-label rect {
    fill: rgba(10, 18, 34, .72);
}

.pick-a .pick-label rect {
    fill: rgba(47, 111, 208, .92);
}

.pick-b .pick-label rect {
    fill: rgba(226, 85, 43, .92);
}

.pick-label text {
    fill: #fff;
    font: 700 17px Inter, sans-serif;
}

.pick-half:hover .pick-label rect {
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .35));
}

.pick-head {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: min(520px, calc(100% - 24px));
    background: rgba(255, 255, 255, .96);
    color: #14264a;
    border-radius: 14px;
    padding: 10px 14px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
}

.pick-head span {
    font-size: .86rem;
    color: #4b5b78;
}

.pick-head .btn {
    margin-top: 4px;
}

/* ---------- Official signals ---------- */
.fb-gesture {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 14px;
    align-items: center;
    margin-top: 12px;
    padding: 12px;
    border-radius: 14px;
    background: var(--blue-soft);
}

.fb-gesture.nofig {
    grid-template-columns: 1fr;
}

.fg-fig {
    width: 180px;
    height: 173px;
    background: linear-gradient(#dfe7f5, #c9d5ea);
    border-radius: 12px;
    overflow: hidden;
    flex: none;
}

.fg-text h5 {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--blue-strong);
    margin-bottom: 4px;
}

.fg-cap {
    font-weight: 700;
    min-height: 2.6em;
    line-height: 1.3;
}

.fg-list {
    margin: 6px 0 8px 18px;
    font-size: .84rem;
    color: var(--text-2);
    line-height: 1.45;
}

.fg-list li.on {
    color: var(--text);
    font-weight: 600;
}

.fg-note {
    font-size: .82rem;
    color: var(--text-2);
    margin-bottom: 6px;
}

.gesture-mini {
    position: absolute;
    right: 14px;
    bottom: 96px;
    width: 156px;
    background: rgba(255, 255, 255, .95);
    border-radius: 14px;
    padding: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 3;
}

.gesture-mini[hidden] {
    display: none;
}

.gm-fig {
    width: 140px;
    height: 135px;
    background: linear-gradient(#dfe7f5, #c9d5ea);
    border-radius: 10px;
    overflow: hidden;
}

.gesture-mini span {
    font-size: .72rem;
    font-weight: 600;
    color: #14264a;
    line-height: 1.3;
    min-height: 2.6em;
}

@media (max-width: 520px) {
    .fb-gesture {
        grid-template-columns: 140px 1fr;
        align-items: start;
    }

    .fg-fig {
        width: 140px;
        height: 135px;
    }

    .gesture-mini {
        top: 64px;
        bottom: auto;
        right: 10px;
        width: 122px;
    }

    .gm-fig {
        width: 106px;
        height: 102px;
    }
}

/* ---------- Narrow screens ---------- */
@media (max-width: 640px) {
    .sim-title span {
        display: none;
    }

    .sim-chip span {
        display: none;
    }

    .sim-chip {
        padding: 0 9px;
        height: 32px;
    }

    .sim-top {
        gap: 8px;
        padding-left: 8px;
        padding-right: 10px;
    }

    .sim-top > img {
        display: none;
    }

    .sb-mid {
        display: none;
    }

    .sim-card {
        padding: 18px;
    }

    .sb-holder {
        top: 8px;
    }

    .sb-slip span {
        display: none;
    }

    .sb-slip {
        padding: 6px;
    }

    .sb-score {
        font-size: 1.5rem;
    }

    .sim-banner {
        top: 60px;
        font-size: .84rem;
    }

    .sim-btn {
        min-height: 50px;
        padding: 0 20px;
    }

    .sim-badges {
        top: 64px;
    }
}

/* End of set: official signals to review */
.end-signals {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.end-sig {
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface);
}

.end-sig.ko {
    border-color: color-mix(in srgb, #e5484d 40%, var(--line));
}

.end-sig-head {
    all: unset;
    box-sizing: border-box;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
}

.end-sig-head:hover, .end-sig-head:focus-visible {
    background: color-mix(in srgb, var(--text) 5%, transparent);
}

.end-sig-head > span:nth-child(2) {
    flex: 1;
    font-weight: 600;
}

.end-sig-head small {
    display: block;
    font-weight: 400;
    color: var(--text-2);
    font-size: .82rem;
}

.end-sig-mark {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: .8rem;
    color: #fff;
    background: #2f9e6b;
    flex: none;
}

.end-sig.ko .end-sig-mark {
    background: #e5484d;
}

.end-sig-go {
    color: var(--accent, #2f6fd0);
    font-size: .85rem;
    white-space: nowrap;
}

.end-sig-body {
    display: flex;
    gap: 14px;
    padding: 4px 12px 12px;
    align-items: flex-start;
}

@media (max-width: 640px) {
    .end-sig-body {
        flex-direction: column;
    }
}

/* Compact card after a decision: the user's own signal, with "Mostra dettagli" */
.dcard {
    position: absolute;
    left: 50%;
    bottom: 96px;
    transform: translateX(-50%);
    width: min(520px, calc(100% - 24px));
    background: var(--surface);
    color: var(--text);
    border-radius: 16px;
    padding: 14px;
    z-index: 6;
    box-shadow: 0 14px 40px rgba(0, 0, 0, .35);
}

.dcard[hidden] {
    display: none;
}

.dc-head {
    display: flex;
    gap: 10px;
    align-items: center;
}

.dc-head h4 {
    font-size: 1rem;
    margin: 0;
}

.dc-head p {
    margin: 2px 0 0;
    font-size: .84rem;
    color: var(--text-2);
}

.dc-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    flex: none;
    background: var(--green, #2f9e6b);
}

.dcard.ko .dc-icon {
    background: var(--red);
}

.dc-sig {
    position: relative;
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 12px;
    align-items: center;
    margin-top: 10px;
    padding: 8px;
    border-radius: 12px;
    background: var(--blue-soft);
}

.dc-sig.nofig {
    grid-template-columns: 1fr;
}

.dc-text small {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 700;
    color: var(--text-2);
}

.dc-sig .fg-fig {
    width: 140px;
    height: 135px;
}

.dc-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

/* Wrong signal: light red background and an "error" mark at the bottom */
.dc-sig.ko, .fb-gesture.fb-yours {
    background: var(--red-soft);
}

.sig-mark {
    display: none;
    grid-column: 1 / -1;
    align-items: center;
    gap: 6px;
    font-size: .8rem;
    font-weight: 700;
    color: var(--red);
}

.sig-mark span {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--red);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: .7rem;
}

.dc-sig.ko .sig-mark, .fb-yours .sig-mark {
    display: flex;
}

.fb-gesture.fb-yours {
    margin-top: 8px;
}

@media (max-width: 520px) {
    .dcard {
        bottom: 84px;
        padding: 12px;
    }

    .dc-sig {
        grid-template-columns: 106px 1fr;
    }

    .dc-sig .fg-fig {
        width: 106px;
        height: 102px;
    }

    .fb-yours {
        grid-template-columns: 140px 1fr;
    }
}

/* Game log ("Cronologia") */
.log-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lg-item {
    border: 1px solid var(--line);
    border-left: 4px solid var(--text-3);
    border-radius: 10px;
    padding: 8px 10px;
    background: var(--surface);
}

.lg-item.ok {
    border-left-color: var(--green, #2f9e6b);
}

.lg-item.ko {
    border-left-color: var(--red);
    background: color-mix(in srgb, var(--red-soft) 55%, var(--surface));
}

.lg-top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-3);
    font-weight: 700;
}

.lg-score {
    font-variant-numeric: tabular-nums;
    color: var(--text-2);
}

.lg-what {
    font-weight: 600;
    margin-top: 2px;
}

.lg-hap {
    font-size: .82rem;
    color: var(--text-2);
    margin-top: 2px;
}

.lg-by {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: .76rem;
}

.lg-badge {
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--inset);
    color: var(--text-2);
    font-weight: 600;
}

.lg-item.ok .lg-badge, .lg-item.ko .lg-badge {
    background: var(--blue-soft);
    color: var(--text);
}

.lg-res.ok {
    color: var(--green, #2f9e6b);
    font-weight: 700;
}

.lg-res.ko {
    color: var(--red);
    font-weight: 700;
}

.end-log {
    margin-top: 18px;
}

.end-log summary {
    cursor: pointer;
    font-weight: 700;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-2);
    padding: 6px 0;
}

.end-log .log-list {
    margin-top: 8px;
    max-height: 480px;
    overflow: auto;
}

/* Score bug extras: time-outs, substitutions and sanctions of each team */
.scoreboard {
    display: grid;
    grid-template-columns: auto auto auto;
}

.sb-a {
    grid-column: 1;
    grid-row: 1;
    justify-content: space-between;
}

.sb-mid {
    grid-column: 2;
    grid-row: 1;
}

.sb-b {
    grid-column: 3;
    grid-row: 1;
    justify-content: space-between;
}

.sbx {
    grid-row: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, .18);
    font-family: var(--font);
    font-size: .68rem;
    border-top: 1px solid rgba(255, 255, 255, .12);
}

.sbx-a {
    grid-column: 1;
}

.sbx-mid {
    grid-column: 2;
}

.sbx-b {
    grid-column: 3;
}

.sbx-b {
    justify-content: flex-end;
}

.sbx-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    opacity: .9;
    white-space: nowrap;
}

.sbx-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, .75);
}

.sbx-dot.used {
    background: #ffd54f;
    border-color: #ffd54f;
}

.sbx-card {
    width: 7px;
    height: 10px;
    border-radius: 1.5px;
    display: inline-block;
}

.sbx-card.y {
    background: #ffd400;
}

.sbx-card.r {
    background: #e53935;
}

.sbx-card.yr {
    background: linear-gradient(90deg, #ffd400 50%, #e53935 50%);
    width: 10px;
}

.sbx-card.v {
    background: transparent;
    border: 1.5px solid rgba(255, 255, 255, .7);
}

.sbx-card.delay {
    box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .55);
    border-radius: 50%;
    width: 9px;
    height: 9px;
}

@media (max-width: 640px) {
    .scoreboard {
        grid-template-columns: auto auto;
    }

    .sb-b, .sbx-b {
        grid-column: 2;
    }

    .sbx-mid {
        display: none;
    }

    .sbx {
        font-size: .6rem;
        gap: 5px;
        padding: 3px 6px;
    }
}

/* History inside the decision windows */
.dec-log {
    margin-top: 10px;
    max-height: 280px;
    overflow: auto;
    padding: 2px;
}

.dec-back .btn.active {
    background: var(--blue-soft);
}

/* Replay window */
.sim-replay {
    width: min(860px, calc(100vw - 24px));
    max-width: none;
}

.rp-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.rp-stage {
    position: relative;
    margin-top: 8px;
    border-radius: 12px;
    overflow: hidden;
    background: #0f1728;
    aspect-ratio: 16 / 9;
}

#rp-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.rp-badge {
    position: absolute;
    left: 50%;
    top: 12px;
    transform: translateX(-50%);
    background: #ffd54f;
    color: #14264a;
    font-weight: 700;
    font-size: .8rem;
    padding: 4px 10px;
    border-radius: 999px;
}

.rp-rec {
    position: absolute;
    right: 10px;
    top: 10px;
    color: #ff6b6b;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
}

.rp-bar {
    position: relative;
    margin-top: 10px;
}

.rp-bar input {
    width: 100%;
}

.rp-mark {
    position: absolute;
    top: -5px;
    width: 3px;
    height: 24px;
    background: rgba(229, 57, 53, .32);
    border-left: 3px solid #e53935;
    border-radius: 3px;
    pointer-events: none;
    box-sizing: border-box;
}

.rp-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
}

.rp-controls .active {
    background: var(--blue-soft);
}

@media (max-width: 520px) {
    .rp-stage {
        aspect-ratio: 4 / 5;
    }
}

/* Drawers (score sheet, game log) stay above the decision windows, so they can be read while deciding */
.sheet {
    z-index: 66;
}

/* Looking at the court while a decision is pending */
.peek-bar {
    position: absolute;
    left: 50%;
    bottom: 96px;
    transform: translateX(-50%);
    z-index: 6;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    background: var(--surface);
    color: var(--text);
    border-radius: 14px;
    padding: 10px 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
    width: max-content;
    max-width: calc(100% - 24px);
}

.peek-bar[hidden] {
    display: none;
}

.peek-bar span {
    font-size: .84rem;
    color: var(--text-2);
    font-weight: 600;
}

/* Replay from the log: above the drawers */
#replay-modal {
    z-index: 75;
}

.lg-replay {
    margin-left: auto;
    border: 0;
    background: var(--blue-soft);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    font-size: .74rem;
    padding: 3px 9px;
    border-radius: 999px;
    cursor: pointer;
}

.lg-replay:hover, .lg-replay:focus-visible {
    background: color-mix(in srgb, var(--blue-soft) 70%, var(--text) 12%);
}

/* Sanctions: chosen sanction, team and member */
.dec-btn.on {
    background: var(--blue-soft);
    border-color: var(--focus);
    color: var(--text);
    box-shadow: inset 0 0 0 1px var(--focus);
}

.dec-btn .sh-dot {
    display: inline-block;
    vertical-align: middle;
    margin-right: 4px;
}

.ask-cap {
    border: 1px dashed var(--line);
}

.mem-h {
    margin: 10px 0 4px;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
    font-weight: 700;
}

.mem-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.mem-wide {
    margin-top: 8px;
    margin-bottom: 8px;
}

.mem-btn {
    min-width: 46px;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.mem-btn b {
    font-family: var(--font-score, inherit);
    font-size: 1.05rem;
}

.mem-btn i {
    font-style: normal;
    font-size: .64rem;
    color: var(--text-2);
}

.mem-btn.cap b {
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 2px;
}

.mem-btn.lib {
    background: color-mix(in srgb, #ffd54f 25%, var(--surface-2));
}

.mem-btn.on {
    background: var(--blue-soft);
    border-color: var(--focus);
    box-shadow: inset 0 0 0 1px var(--focus);
}

.mem-btn:hover {
    border-color: var(--text-3);
}

.dec-confirm {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.sh-cap {
    padding: 2px 8px;
    min-height: 0;
}

.sim-opt-hint {
    flex-basis: 100%;
    font-size: .8rem;
    color: var(--text-3);
    line-height: 1.4;
}

#opt-fouls {
    flex-wrap: wrap;
}

/* Picking who gets a sanction on the court */
.person-bar {
    position: absolute;
    left: 50%;
    bottom: 92px;
    transform: translateX(-50%);
    z-index: 6;
    width: min(560px, calc(100% - 24px));
    background: var(--surface);
    color: var(--text);
    border-radius: 14px;
    padding: 10px 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
    display: flex;
    align-items: center;
    gap: 10px;
}

.person-bar[hidden] {
    display: none;
}

.person-bar p {
    flex: 1;
}

.person-bar p {
    margin: 0;
    font-size: .86rem;
    color: var(--text-2);
}

.person-bar strong {
    color: var(--text);
}

.pb-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pick-target {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--blue-soft);
    font-weight: 600;
}

.rp-mark.w {
    background: rgba(30, 136, 229, .32);
    border-left-color: #1e88e5;
}

.rp-mark[hidden] {
    display: none;
}

.rp-legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
    font-size: .78rem;
    color: var(--text-2);
}

.rp-legend > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.rp-legend > span[hidden] {
    display: none;
}

.rp-legend i {
    width: 3px;
    height: 14px;
    border-radius: 2px;
    display: inline-block;
}

.rp-legend i.f {
    background: #e53935;
}

.rp-legend i.w {
    background: #1e88e5;
}

.rp-badge.w {
    background: #1e88e5;
    color: #fff;
}

.gm-who {
    font-size: .64rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 700;
    color: #4b5b78;
}

/* Game clock, seconds since the service authorisation, time-out countdown */
.sim-badge.serve {
    background: rgba(30, 136, 229, .9);
    font-variant-numeric: tabular-nums;
}

.sim-badge.serve.late {
    background: #e53935;
}

#badge-clock {
    font-variant-numeric: tabular-nums;
}

.to-wait {
    position: absolute;
    left: 50%;
    top: 96px;
    transform: translateX(-50%);
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    color: var(--text);
    border-radius: 14px;
    padding: 10px 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

.to-wait[hidden] {
    display: none;
}

.to-wait span {
    color: var(--text-2);
    font-size: .86rem;
}

.to-wait b {
    font-family: var(--font-score, inherit);
    font-size: 1.6rem;
    min-width: 2ch;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Collaboration signals of the 2nd referee (you) to the 1st */
.sim-btn.collab {
    background: rgba(255, 255, 255, .92);
    color: #14264a;
}

.collab-panel {
    position: absolute;
    left: 50%;
    bottom: 92px;
    transform: translateX(-50%);
    z-index: 6;
    width: min(520px, calc(100% - 24px));
    background: var(--surface);
    color: var(--text);
    border-radius: 14px;
    padding: 10px 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

.collab-panel[hidden] {
    display: none;
}

.collab-panel p {
    margin: 0 0 8px;
    font-size: .82rem;
    color: var(--text-2);
}

.cp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.cp-btn {
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
    border-radius: 10px;
    padding: 8px 10px;
    font: inherit;
    font-weight: 600;
    font-size: .86rem;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cp-btn:hover {
    border-color: var(--focus);
}

/* "Attenzione": right point, but a different (earlier) fault ended the rally */
.dcard.warn .dc-icon, .fb-head.warn .fb-icon, .end-sig.warn .end-sig-mark {
    background: var(--amber, #e0a100);
    color: #3A2A05;
}

.dc-sig.warn {
    background: var(--amber-soft);
}

.end-sig.warn {
    border-color: color-mix(in srgb, var(--amber, #e0a100) 50%, var(--line));
}

.lg-item.warn {
    border-left-color: var(--amber, #e0a100);
    background: color-mix(in srgb, var(--amber-soft) 55%, var(--surface));
}

.lg-item.warn .lg-badge {
    background: var(--blue-soft);
    color: var(--text);
}

.lg-res.warn {
    color: var(--amber-strong);
    font-weight: 700;
}

.fb-gesture.fb-yours.warn {
    background: var(--amber-soft);
}

.fb-yours.warn .sig-mark {
    color: var(--amber-strong);
}

.fb-yours.warn .sig-mark span {
    background: var(--amber, #e0a100);
    color: #3A2A05;
}

/* Credit, on the right of the top bar (setup screen and end of the set; hidden during the match) */
.sim-credit {
    margin-left: auto;
    font-size: .74rem;
    opacity: .65;
    white-space: nowrap;
    padding-left: 12px;
}

.sim-top-right:not([hidden]) + .sim-credit {
    display: none;
}

/* hidden during the match */
@media (max-width: 520px) {
    .sim-credit {
        font-size: .66rem;
        padding-left: 6px;
        white-space: normal;
        text-align: right;
        max-width: 120px;
        line-height: 1.2;
    }
}

/* Settings window during the match */
.opts-box {
    width: min(680px, calc(100vw - 24px));
    max-width: none;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

.opts-box .sim-options {
    margin-top: 8px;
}

.segmented button:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.sim-stats-link p {
    margin: 0;
    font-size: .92rem;
}

.opts-box {
    box-sizing: border-box;
    overflow-x: hidden;
    padding-bottom: 0;
}

.opts-box .segmented {
    flex-wrap: wrap;
    max-width: 100%;
}

.opts-box .modal-actions {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    padding: 12px 0 16px;
    margin-top: 10px;
    border-top: 1px solid var(--line-soft);
}

/* Scoreboard with the starting line-up slips on its sides */
.sb-holder {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: flex-start;
    gap: 8px;
    z-index: 3;
}

/* The line-up slip opens above the decision window (from its «Formazione A/B» buttons) */
.sb-holder .scoreboard {
    position: static;
    transform: none;
}

.sb-slip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 7px 9px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: rgba(10, 18, 34, .82);
    color: #fff;
    font: 700 .78rem var(--font);
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.sb-slip[hidden] {
    display: none;
}

.sb-slip:hover {
    background: rgba(30, 44, 70, .92);
}

.slip-card {
    position: absolute;
    left: 50%;
    bottom: 96px;
    transform: translateX(-50%);
    width: min(420px, calc(100% - 24px));
    z-index: 67;
    background: #fffdf6;
    color: #1b2433;
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, .35);
    border-top: 6px solid var(--team, #2f6fd0);
}

.slip-card[hidden] {
    display: none;
}

.slip-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.slip-head small, .slip-court-wrap small {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6b7385;
}

.slip-head h4 {
    margin: 2px 0 0;
    font-size: 1rem;
}

.slip-head .btn {
    color: #1b2433;
}

.slip-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    margin-top: 10px;
}

.slip-box, .slip-pos {
    border: 1.5px solid #c9ced8;
    border-radius: 6px;
    text-align: center;
    padding: 4px 0 6px;
    background: #fff;
}

.slip-box small, .slip-pos small {
    display: block;
    font-size: .66rem;
    color: #6b7385;
    font-weight: 700;
}

.slip-box b, .slip-pos b {
    font-family: var(--font-score);
    font-size: 1.35rem;
    line-height: 1.1;
}

.slip-court-wrap {
    margin-top: 10px;
}

.slip-court {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 3px solid #1b2433;
}

.slip-pos {
    background: #fdf3e6;
}

/* Replay: the referee's signal, in sync with the recording */
.rp-mark.s {
    background: rgba(46, 158, 91, .3);
    border-left-color: #2e9e5b;
}

.rp-legend i.s {
    background: #2e9e5b;
}

.rp-sigs {
    position: absolute;
    right: 10px;
    bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
    max-width: min(340px, 70%);
}

.rp-sig {
    display: flex;
    gap: 10px;
    align-items: center;
    background: rgba(255, 255, 255, .94);
    color: #1b2433;
    border-radius: 12px;
    padding: 6px 10px 6px 6px;
    max-width: min(340px, 70%);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
    max-width: 100%;
}

.rp-sig[hidden] {
    display: none;
}

.rp-sig-fig {
    width: 96px;
    height: 92px;
    flex: none;
}

.rp-sig-fig svg {
    width: 100%;
    height: 100%;
}

.rp-sig-text small {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #2e9e5b;
    font-weight: 700;
}

.rp-sig-text p {
    margin: 2px 0 0;
    font-size: .8rem;
    line-height: 1.3;
}

@media (max-width: 520px) {
    .rp-sig-fig {
        width: 70px;
        height: 68px;
    }

    .rp-sig-text p {
        font-size: .72rem;
    }
}

/* ================= Phones ================= */
/* Portrait: the replay buttons wrap; a tip suggests turning the phone (the court is much bigger in landscape) */
@media (max-width: 640px) {
    .rp-controls {
        flex-wrap: wrap;
    }

    .rp-controls .btn {
        padding-left: 10px;
        padding-right: 10px;
    }

    .sim-badges {
        top: 60px;
        left: 8px;
    }

    .sim-banner {
        top: 108px;
        max-width: calc(100% - 24px);
    }
}

@media (max-width: 420px) {
    .sim-top:has(.sim-top-right:not([hidden])) .sim-title {
        display: none;
    }

    /* during the match the chips need the room */
}

.rotate-tip {
    position: absolute;
    left: 50%;
    bottom: calc(96px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 4;
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 14px;
    width: max-content;
    max-width: calc(100% - 32px);
    background: rgba(10, 18, 34, .88);
    color: #fff;
    font-size: .86rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}

.rotate-tip svg {
    flex: none;
    animation: rot-tip 2.4s ease-in-out infinite;
}

.rotate-tip button {
    margin-left: 4px;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 6px 10px;
    font-weight: 700;
    cursor: pointer;
}

@keyframes rot-tip {
    0%, 30% {
        transform: rotate(0);
    }
    60%, 100% {
        transform: rotate(-90deg);
    }
}

@media (orientation: portrait) and (max-width: 640px) {
    body:not(.rot-dismissed) .sim-game .rotate-tip {
        display: flex;
    }
}

/* Landscape phones (little height): slimmer bar, icon-only chips, compact cards and windows */
@media (max-height: 500px) and (orientation: landscape) {
    .sim-top {
        padding: 4px 10px;
        padding-top: max(4px, env(safe-area-inset-top));
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
        gap: 8px;
    }

    .sim-top > img {
        width: 22px;
        height: 22px;
    }

    .sim-title span {
        display: none;
    }

    .sim-chip span {
        display: none;
    }

    .sim-chip {
        height: 30px;
        padding: 0 9px;
    }

    .sim-back {
        width: 30px;
        height: 30px;
    }

    .sb-holder {
        top: 6px;
    }

    .sb-score {
        font-size: 1.35rem;
    }

    .sb-team {
        padding: 3px 9px;
    }

    .sbx {
        font-size: .6rem;
        padding: 2px 8px;
    }

    .sb-slip span {
        display: none;
    }

    .sb-slip {
        padding: 5px;
    }

    .sim-badges {
        top: 8px;
        left: max(8px, env(safe-area-inset-left));
    }

    .sim-banner {
        top: 64px;
        font-size: .78rem;
        padding: 6px 12px;
        max-width: 56%;
    }

    .sim-controls {
        padding: 6px 12px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        gap: 4px;
    }

    .sim-hint {
        font-size: .76rem;
    }

    .sim-btn {
        min-height: 42px;
        padding: 0 18px;
        font-size: .94rem;
    }

    .sim-btn.whistle {
        min-width: 140px;
    }

    .gesture-mini {
        transform: scale(.82);
        transform-origin: bottom right;
    }

    /* Decision card: compact, never taller than the screen */
    .dcard {
        bottom: 58px;
        padding: 10px 12px;
        max-height: calc(100% - 70px);
        overflow-y: auto;
        width: min(560px, calc(100% - 24px));
    }

    .dc-head h4 {
        font-size: .92rem;
    }

    .dc-head p {
        font-size: .78rem;
    }

    .dc-sig {
        grid-template-columns: 84px 1fr;
        margin-top: 6px;
        padding: 6px;
    }

    .dc-sig .fg-fig {
        width: 84px;
        height: 80px;
    }

    .dc-actions {
        margin-top: 6px;
    }

    .slip-card {
        bottom: 58px;
        max-height: calc(100% - 70px);
        overflow-y: auto;
    }

    .slip-court-wrap {
        display: none;
    }

    /* Windows: use the whole height, scroll inside */
    .sim-modal .modal-box {
        max-height: calc(100dvh - 12px);
        overflow-y: auto;
        padding: 14px 16px;
    }

    #replay-modal .modal-box {
        width: min(760px, calc(100vw - 16px));
    }

    .rp-stage {
        aspect-ratio: auto;
        height: 52dvh;
    }

    .rp-head h3 {
        font-size: .95rem;
    }

    #rp-note {
        display: none;
    }

    .rp-controls {
        flex-wrap: wrap;
        margin-top: 4px;
    }

    .rp-legend {
        margin-top: 4px;
    }
}
