/* The online draw (/draw): a compact web tool on top of site.css and landing.css. One panel, quiet
   surfaces, gold only where it means something. RTL throughout: logical properties, text starts on
   the right. Mobile first; every motion has a reduced form. */

.tool {
    --r: 18px;
    --r-sm: 10px;
    --h: 40px;
    --ease: cubic-bezier(.2, .8, .2, 1);
    --spring: cubic-bezier(.34, 1.56, .64, 1);
    --gold: linear-gradient(180deg, #FFC52E, #FFB300);
    --shadow-1: 0 1px 2px rgba(28, 33, 30, .05), 0 4px 16px rgba(28, 33, 30, .05);
    --danger: #B3261E;
    --danger-soft: #FDECEA;
    --ok: #1E7D4F;
}
@media (prefers-color-scheme: dark) {
    .tool {
        --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
        --danger: #F2B8B5;
        --danger-soft: #3B1714;
        --ok: #7DD3A8;
    }
}

.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.tool-main { padding: 20px 0 36px; background: radial-gradient(60% 260px at 50% -60px, var(--glow), transparent 75%), var(--bg); }
.mini { max-width: 1000px; margin: 0 auto; font-size: 14.5px; text-align: right; }
.grow { flex: 1; }

/* ------------------------------------------------ head: title and mode switch */

.mini-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.mini-title { display: flex; align-items: center; gap: 10px; }
.mini-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 11px; background: var(--gold); }
.mini-icon .ic { width: 22px; height: 22px; fill: #1C1B1F; }
.mini-title h1 { margin: 0; font-size: 21px; font-weight: 700; line-height: 1.4; }

.seg { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.seg-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s var(--ease), color .15s var(--ease);
}
.seg-item .ic { width: 18px; height: 18px; fill: currentColor; }
.seg-item:hover { color: var(--text); }
.seg-item[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-ink); }

/* ------------------------------------------------ shared controls */

.info {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: color .15s var(--ease), background .15s var(--ease);
}
.info .ic { width: 18px; height: 18px; fill: currentColor; }
.info:hover, .info[aria-expanded="true"] { color: var(--accent-ink); background: var(--accent-soft); }

.tip {
    margin: 0 0 12px;
    padding: 9px 12px;
    border-radius: var(--r-sm);
    background: var(--accent-soft);
    color: var(--text);
    font-size: 13.5px;
    line-height: 1.9;
    animation: tip-in .18s var(--ease);
}
@keyframes tip-in { from { opacity: 0; transform: translateY(-4px); } }

.tbtn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 32px;
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s var(--ease), color .15s var(--ease);
}
.tbtn .ic { width: 17px; height: 17px; fill: currentColor; }
.tbtn:hover { background: var(--surface-2); color: var(--text); }
.tbtn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.tbtn-undo { color: var(--accent-ink); }

.field {
    height: var(--h);
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 15px;
    text-align: right;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.field::placeholder { color: var(--muted); opacity: .8; }
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }

button.btn { font: inherit; font-weight: 700; cursor: pointer; }
.tool .btn-sm { min-height: 36px; padding: 0 14px; border-radius: 10px; font-size: 13.5px; }
.tool .btn-sm .ic { width: 18px; height: 18px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.tool :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------ the panel */

.panel {
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    box-shadow: var(--shadow-1);
    animation: view-in .22s var(--ease);
}
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
.pane { padding: 16px; }
.pane-side { border-top: 1px solid var(--line); }

.pane-head { display: flex; align-items: center; gap: 4px; min-height: 32px; margin-bottom: 10px; }
.pane-head h2 { margin: 0; margin-inline-end: 4px; font-size: 15px; font-weight: 700; white-space: nowrap; }
.count {
    min-width: 24px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
    transition: transform .2s var(--spring), background .2s, color .2s;
}
.count.bump { transform: scale(1.18); background: var(--accent-soft); color: var(--accent-ink); }

/* People. */
.adder { display: flex; gap: 8px; }
.adder .field { flex: 1; min-width: 0; }
.add-btn {
    display: grid;
    place-items: center;
    flex: none;
    width: var(--h);
    height: var(--h);
    border: 0;
    border-radius: var(--r-sm);
    background: var(--gold);
    color: #1C1B1F;
    cursor: pointer;
    transition: transform .12s var(--ease), box-shadow .15s var(--ease);
}
.add-btn:hover { box-shadow: 0 4px 12px rgba(255, 179, 0, .35); }
.add-btn:active { transform: scale(.94); }
.add-btn .ic { width: 22px; height: 22px; fill: currentColor; }

.bulk .field { width: 100%; height: auto; padding: 10px 12px; line-height: 1.9; resize: vertical; }
.bulk-actions { display: flex; gap: 8px; margin-top: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.chips:empty { display: none; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    height: 32px;
    padding-inline: 4px 2px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg);
    font-size: 14px;
}
.chip.fresh { animation: chip-in .22s var(--spring); }
@keyframes chip-in { from { opacity: 0; transform: scale(.85); } }
.chip.leaving { animation: chip-out .14s var(--ease) forwards; }
@keyframes chip-out { to { opacity: 0; transform: scale(.85); } }
.chip-no {
    flex: none;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
}
.chip-name { min-width: 0; padding-inline: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 26ch; }
.chip-x {
    display: grid;
    place-items: center;
    flex: none;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.chip-x .ic { width: 15px; height: 15px; fill: currentColor; }
.chip-x:hover { background: var(--danger-soft); color: var(--danger); }
.chip-level { flex: none; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; font-weight: 700; line-height: 22px; text-align: center; }
.chip-level.is-missing { background: var(--danger-soft); color: var(--danger); }
.chip.dup { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); background: var(--accent-soft); }

.empty { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 12px; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: var(--r-sm); color: var(--muted); font-size: 13.5px; }
.empty .tbtn { color: var(--accent-ink); }
.warn { margin: 10px 0 0; color: var(--accent-ink); font-size: 13px; font-weight: 600; }

/* Settings. */
.settings + .more { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 6px; min-height: var(--h); }
.row + .row, .tip + .row { margin-top: 10px; }
.settings > .tip, .more > .tip { margin: 8px 0 0; }
.row-label { display: flex; flex-direction: column; flex: 1; min-width: 0; font-weight: 600; line-height: 1.5; }
label.row-label { cursor: pointer; }
.row-label:has(+ .info) { flex: 0 1 auto; }
.row > .info + .switch, .row > .info + .field { margin-inline-start: auto; }
.shape { color: var(--text); font-weight: 600; }
.shape.is-error { color: var(--danger); }

.stepper { display: inline-flex; align-items: center; flex: none; height: var(--h); border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--bg); overflow: hidden; }
.step-btn {
    display: grid;
    place-items: center;
    width: 36px;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}
.step-btn:hover { background: var(--surface-2); }
.step-btn[disabled] { opacity: .3; cursor: not-allowed; background: transparent; }
.step-btn .ic { width: 18px; height: 18px; fill: currentColor; }
.step-value { width: 40px; height: 100%; padding: 0; border: 0; border-inline: 1px solid var(--line); background: transparent; color: var(--text); font: inherit; font-size: 15px; font-weight: 700; text-align: center; }
.step-value:focus { outline: none; background: var(--accent-soft); }

.mini-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; margin-bottom: 10px; padding: 3px; border-radius: var(--r-sm); background: var(--surface-2); }
.mini-seg button { height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.mini-seg [aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

.switch {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    flex: none;
    width: 40px;
    height: 24px;
    margin: 0;
    margin-inline-start: auto;
    border-radius: 999px;
    background: var(--line-strong);
    cursor: pointer;
    transition: background .2s var(--ease);
}
.switch::after {
    content: "";
    position: absolute;
    top: 3px;
    inset-inline-start: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
    transition: transform .22s var(--spring);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(-16px); }

.shape-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 10px; font-size: 13px; }
.shape-line > * { height: 26px; padding: 0 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-weight: 600; line-height: 26px; white-space: nowrap; }
.shape-line b { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }

.pots { display: grid; gap: 4px; margin: 10px 0 0; padding: 0; list-style: none; }
.pots li { display: flex; gap: 8px; padding: 6px 10px; border-radius: 8px; background: var(--surface-2); font-size: 13px; line-height: 1.8; }
.pots b { flex: none; color: var(--accent-ink); font-weight: 700; }
.pots span { min-width: 0; color: var(--muted); overflow-wrap: anywhere; }

.more { margin-top: 12px; border-top: 1px solid var(--line); }
.more summary { display: flex; align-items: center; gap: 6px; height: 40px; color: var(--muted); font-size: 13.5px; font-weight: 600; list-style: none; cursor: pointer; }
.more summary::-webkit-details-marker { display: none; }
.more summary .ic { width: 17px; height: 17px; fill: currentColor; }
.more summary .chev { margin-inline-start: auto; transition: transform .2s var(--ease); }
.more[open] summary .chev { transform: rotate(180deg); }
.more[open] summary { margin-bottom: 4px; }
.code-input { width: 110px; flex: none; text-align: center; font-weight: 700; letter-spacing: 3px; }
.code-input::placeholder { letter-spacing: 0; font-weight: 400; }

/* The draw button: sticky on phones. */
.cta-bar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: 14px -16px -16px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    border-radius: 0 0 var(--r) var(--r);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}
.btn-go { height: 46px; background: var(--gold); font-size: 15.5px; box-shadow: 0 6px 18px rgba(255, 179, 0, .3); }
.btn-go .ic { width: 20px; height: 20px; }
.cta-note { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; text-align: center; }
.cta-note:empty { display: none; }
.cta-note.is-error { color: var(--danger); font-weight: 600; }

/* ------------------------------------------------ result */

.result { padding: 14px 16px 16px; }
.result-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-bottom: 14px; }
.result-head .tbtn { justify-self: start; }
.result-title { margin: 0; font-size: 16px; font-weight: 700; text-align: center; }
.result-title:focus { outline: none; }
.code-chip { justify-self: end; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12.5px; font-weight: 700; letter-spacing: 2px; }
.mini[data-view="result"] .seg { display: none; }

.stage { margin-bottom: 14px; }

/* Names: a reel that rolls and lands. */
.reel {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 120px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: radial-gradient(70% 100% at 50% 0%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%), var(--bg);
    overflow: hidden;
    text-align: center;
    transition: border-color .2s var(--ease);
}
.reel-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.reel-name { max-width: 100%; overflow-wrap: anywhere; font-size: clamp(22px, 6vw, 30px); font-weight: 700; line-height: 1.4; }
.reel.rolling .reel-name { animation: roll .08s linear; }
@keyframes roll { from { opacity: .35; transform: translateY(-30%); } }
.reel.landed { border-color: var(--accent); animation: landed .45s var(--spring); }
.reel.landed .reel-name { color: var(--accent-ink); }
@keyframes landed { 35% { transform: scale(1.03); } }
.spark {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    margin: -3px;
    border-radius: 2px;
    background: var(--accent);
    pointer-events: none;
    animation: spark .75s var(--ease) forwards;
}
.spark:nth-child(3n) { background: var(--accent-ink); border-radius: 50%; }
@keyframes spark {
    from { opacity: 1; transform: translate(0, 0) rotate(0); }
    to { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); }
}

.winners { display: grid; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.winner { display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); font-size: 15px; font-weight: 600; animation: winner-in .3s var(--spring); }
@keyframes winner-in { from { opacity: 0; transform: translateY(-6px); } }
.winner-rank { flex: none; width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 700; line-height: 26px; text-align: center; }
.winner:first-child .winner-rank { background: var(--gold); color: #1C1B1F; }
.winner-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.winner .ic { flex: none; width: 18px; height: 18px; fill: var(--accent); }

/* Groups: the board fills round by round. */
.now { display: flex; align-items: center; gap: 8px; height: 40px; margin-bottom: 10px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); }
.now-label { flex: none; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; font-weight: 700; }
.now-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.now-name.pop { animation: pop .28s var(--spring); }
@keyframes pop { from { opacity: 0; transform: scale(.88); } }
.now.done .now-label { background: var(--gold); color: #1C1B1F; }

.board { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.gcard { border: 1px solid var(--line); border-radius: 12px; background: var(--bg); overflow: hidden; transition: border-color .2s var(--ease), box-shadow .2s var(--ease); }
.gcard.active { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.gcard h3 { display: flex; align-items: center; gap: 6px; margin: 0; padding: 7px 10px; border-bottom: 1px solid var(--line); font-size: 13.5px; font-weight: 700; }
.gcard h3 i { min-width: 22px; height: 22px; padding: 0 5px; border-radius: 6px; background: var(--gold); color: #1C1B1F; font-size: 12px; font-style: normal; line-height: 22px; text-align: center; }
.gcard-extra { margin-inline-start: auto; color: var(--accent-ink); font-size: 12px; font-weight: 700; white-space: nowrap; }
.gcard-extra:empty { display: none; }
.gcard ul { margin: 0; padding: 6px; list-style: none; }
.slot { display: flex; align-items: center; justify-content: space-between; gap: 6px; height: 30px; padding: 0 8px; border-radius: 7px; font-size: 13.5px; }
.slot + .slot { margin-top: 3px; }
.slot.empty-slot { border: 1px dashed var(--line); }
.slot.filled { background: var(--surface); animation: pop .3s var(--spring); }
.slot-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot.bye { justify-content: center; background: var(--surface-2); color: var(--muted); font-size: 12.5px; }
/* Knockout: one compact row per match, «number | A – B», mirrored around the dash. */
.board-knockout { grid-template-columns: 1fr; gap: 6px; }
.board-knockout .gcard { display: flex; align-items: center; }
.board-knockout .gcard h3 { flex: none; align-self: stretch; padding: 0 8px; border-bottom: 0; border-inline-end: 1px solid var(--line); }
.board-knockout .gcard h3 > span:first-child { display: none; }
.board-knockout ul { display: flex; align-items: center; flex: 1; min-width: 0; gap: 4px; padding: 5px; }
.board-knockout ul::after { content: "–"; order: 2; flex: none; color: var(--muted); font-weight: 700; }
.board-knockout .slot { flex: 1 1 0; min-width: 0; height: 32px; }
.board-knockout .slot + .slot { order: 3; margin-top: 0; flex-direction: row-reverse; }
/* A bye is always the second side; row-reverse puts its start on the outer (left) edge. */
.board-knockout .slot.bye { justify-content: flex-start; padding-inline: 8px; background: transparent; }
.pot-tag { flex: none; color: var(--muted); font-size: 11px; }
.pot-tag.is-seed { padding: 0 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; line-height: 18px; }

/* Actions: replay on the start side, the export toolbar (text, image, link, print) on the end side. */
.result-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.play-actions { display: flex; gap: 8px; }
.export { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.xbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s var(--ease), color .15s var(--ease);
}
.xbtn .ic { width: 18px; height: 18px; fill: currentColor; }
.xbtn:hover { background: var(--surface-2); }
.xbtn.done { color: var(--ok); }
.xbtn.failed { color: var(--danger); }
.xbtn[disabled] { opacity: .45; cursor: not-allowed; background: transparent; }
.export-note { margin: 10px 0 0; color: var(--muted); font-size: 12.5px; text-align: center; }
.export-note:empty { display: none; }
.print-foot { display: none; }

/* A team name is edited in place on the board. */
.gname { min-width: 2ch; padding: 0 2px; border-bottom: 1px dashed var(--line-strong); border-radius: 3px; outline: none; cursor: text; }
.gname:hover { border-bottom-color: var(--accent); }
.gname:focus { background: var(--accent-soft); border-bottom-color: var(--accent); }

.tool-text a { color: var(--accent-ink); font-weight: 600; }

/* ------------------------------------------------ dropdown (tool-kit.js enhanceSelect) */

.dd { position: relative; flex: none; }
.dd-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 168px;
    max-width: 220px;
    height: 36px;
    padding-inline: 12px 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.dd-btn:hover:not([disabled]) { border-color: var(--accent); }
.dd-btn[disabled] { opacity: .55; cursor: not-allowed; }
.dd-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.dd-label.is-placeholder { color: var(--muted); font-weight: 400; }
.dd-chev { flex: none; width: 18px; height: 18px; fill: var(--muted); transition: transform .2s var(--ease); }
.dd.open .dd-chev { transform: rotate(180deg); }
.dd.open .dd-btn { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.dd-menu {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-start: 0;
    z-index: 30;
    min-width: 100%;
    max-height: 280px;
    margin: 0;
    padding: 4px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .16);
    list-style: none;
    animation: dd-in .14s var(--ease);
}
.dd-menu.up { top: auto; bottom: calc(100% + 6px); }
.dd-menu:focus { outline: none; }
@keyframes dd-in { from { opacity: 0; transform: translateY(-4px); } }
.dd-item { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 10px; border-radius: 8px; font-size: 14px; white-space: nowrap; cursor: pointer; }
.dd-item:hover, .dd-item:focus { outline: none; background: var(--surface-2); }
.dd-item[aria-selected="true"] { color: var(--accent-ink); font-weight: 700; }
.dd-text { flex: 1; }
.dd-check { flex: none; width: 16px; height: 16px; fill: currentColor; }

/* ------------------------------------------------ text under the tool */

.tool-text { margin-top: 40px; padding: 36px 0 48px; border-top: 1px solid var(--line); background: var(--surface); }
.tool-text h2 { margin: 0 0 10px; font-size: 19px; font-weight: 700; line-height: 1.5; }
.tool-text p { margin: 0 0 12px; color: var(--muted); font-size: 14.5px; line-height: 2; }
.tool-text h2:not(:first-child) { margin-top: 30px; }
.tool-text .faq { margin-top: 14px; }
.tool-text .faq summary h3 { font-size: 15px; }

/* ------------------------------------------------ phones */

@media (max-width: 599px) {
    .mini-head { gap: 10px; }
    .seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
    /* Four modes on a phone: icon over label, like an app's segmented bar. */
    .seg-item { flex-direction: column; justify-content: center; gap: 1px; min-width: 0; height: 48px; padding: 0 2px; font-size: 12px; }
    .tbtn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .tbtn { width: 32px; padding: 0; justify-content: center; }
    /* Two columns of groups: an odd last group takes the whole row, so the board stays even. */
    .board > .gcard:last-child:nth-child(odd) { grid-column: 1 / -1; }
    /* The export toolbar on top as four equal cells, replay below it. */
    .result-actions { flex-direction: column-reverse; align-items: stretch; }
    .export { display: grid; grid-template-columns: repeat(4, 1fr); }
    .xbtn { flex-direction: column; gap: 1px; height: 48px; padding: 0 2px; font-size: 12px; }
    .play-actions .btn { flex: 1; }
}

/* ------------------------------------------------ wider screens */

@media (min-width: 760px) {
    .tool-main { padding-top: 28px; }
    .tool-text { margin-top: 56px; }
    .pane { padding: 20px; }
    .result { padding: 16px 20px 20px; }
    .cta-bar { position: static; margin: 16px 0 0; padding: 0; border: 0; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
    /* The two halves of the bracket side by side. */
    .board-knockout { grid-template-columns: 1fr 1fr; grid-auto-flow: column; grid-template-rows: repeat(var(--half, 1), auto); }
}

@media (min-width: 900px) {
    #view-setup:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
    .pane-side { border-top: 0; border-inline-start: 1px solid var(--line); }
    #view-result { max-width: 760px; margin: 0 auto; }
}

/* ------------------------------------------------ print: the result only, black on white */

@media print {
    /* Paper is white whatever the screen theme: black text, grey lines. */
    :root:root, :root:root[data-theme] {
        --bg: #fff; --surface: #fff; --surface-2: #fff; --text: #000; --muted: #333;
        --line: #999; --line-strong: #666; --accent-ink: #000; --accent-soft: #fff;
    }
    body { background: #fff; color: #000; }
    .lp-head, .lp-foot, .foot, .skip, .tool-text, .mini-head .seg, .mini-head .info, .tip, #view-setup,
    .result-head .tbtn, .result-actions, .export-note, .now, .spark { display: none !important; }
    .tool-main { padding: 0; background: none; }
    .mini, .tool { color: #000; }
    .mini-icon { background: none; border: 1px solid #000; }
    .panel, .gcard, .reel, .winner { box-shadow: none; border-color: #999; background: #fff; animation: none; }
    #view-result { max-width: none; padding: 0; border: 0; }
    .slot.filled, .slot.bye { background: none; animation: none; }
    .gcard, .winner, .board-knockout .gcard { break-inside: avoid; }
    .gcard h3 i, .winner-rank, .pot-tag.is-seed, .code-chip { background: none; border: 1px solid #000; color: #000; }
    .gcard-extra, .reel.landed .reel-name { color: #000; }
    .gname { border: 0; }
    .print-foot { display: block; margin: 16px 0 0; color: #000; font-size: 12px; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
    .panel, .tip, .chip.fresh, .winner, .slot.filled, .now-name.pop, .reel.landed, .reel.rolling .reel-name { animation: none; }
    .spark { display: none; }
    .dd-menu { animation: none; }
}
