:root {
    color-scheme: dark;
    --ink: #f4efe3;
    --muted: #aeb8ae;
    --line: rgba(238, 232, 214, .14);
    --panel: #18201a;
    --accent: #d8c382;
    --green: #8fbf80;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
html, body { min-height: 100%; max-width: 100%; margin: 0; background: #0e1410; }
html { overflow-x: clip; }
body { min-width: 0; overflow-x: clip; color: var(--ink); }
img, svg, canvas { max-width: 100%; }
button, input, textarea, select { font: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid #e5ca75; outline-offset: 3px; }
[hidden] { display: none !important; }

.setup-view {
    min-height: 100vh;
    min-height: 100dvh;
    padding: 0 max(18px, env(safe-area-inset-right)) 60px max(18px, env(safe-area-inset-left));
    background:
        radial-gradient(circle at 85% 8%, rgba(133, 172, 108, .16), transparent 30rem),
        linear-gradient(180deg, #111914 0, #0d120f 100%);
}

.setup-header {
    width: min(1060px, 100%);
    min-height: 68px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
}

.back-link { color: var(--ink); font-weight: 750; text-decoration: none; }
.back-link:hover { color: #f4d987; }
.public-badge { padding: 7px 11px; color: #cfe1c9; border: 1px solid rgba(143, 191, 128, .3); border-radius: 999px; background: rgba(143, 191, 128, .08); font-size: .76rem; font-weight: 700; }
.tool-tabs { width: min(1060px, 100%); margin: 18px auto 0; padding: 5px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; border: 1px solid var(--line); border-radius: 14px; background: #0b100d; }
.tool-tab { min-height: 45px; padding: 9px 14px; display: grid; place-items: center; color: var(--muted); border: 0; border-radius: 9px; background: transparent; font-size: .82rem; font-weight: 800; text-align: center; text-decoration: none; cursor: pointer; }
.tool-tab:hover { color: var(--ink); background: rgba(255, 255, 255, .045); }
.tool-tab.is-active { color: #151910; background: #dfca87; }

.setup-intro {
    width: min(1060px, 100%);
    margin: 50px auto 30px;
}
.eyebrow { margin: 0 0 8px; color: #b9cdac; font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.setup-intro h1 { max-width: 780px; margin: 0; font: 800 clamp(2.6rem, 8vw, 5.8rem)/.96 Georgia, serif; letter-spacing: -.05em; }
.setup-intro > p:last-child { max-width: 620px; margin: 18px 0 0; color: var(--muted); font-size: clamp(1rem, 2vw, 1.2rem); line-height: 1.55; }
#clock-tool .setup-intro { margin: 36px auto 24px; }
#clock-tool .setup-intro h1 { font-size: clamp(2.5rem, 6vw, 4.5rem); }
.quick-launch-panel { width: min(1060px, 100%); margin: -6px auto 16px; padding: 14px; display: grid; grid-template-columns: minmax(210px, 1fr) minmax(300px, 1.15fr) auto; align-items: center; gap: 14px; border: 1px solid rgba(224,201,120,.28); border-radius: 18px; background: linear-gradient(135deg, rgba(224,201,120,.1), rgba(143,191,128,.055)); box-shadow: 0 14px 36px rgba(0,0,0,.16); }
.quick-launch-copy { display: grid; gap: 3px; }
.quick-launch-copy > span { color: #b7cba8; font-size: .61rem; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.quick-launch-copy strong { font-size: .9rem; }
.quick-launch-copy small { color: var(--muted); font-size: .65rem; }
.quick-start-button { min-height: 62px; padding: 10px 16px; display: flex; align-items: center; gap: 13px; color: #151910; border: 0; border-radius: 13px; background: #e0ca83; cursor: pointer; box-shadow: 0 9px 24px rgba(0,0,0,.2); }
.quick-start-button > span:first-child { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: rgba(17,23,19,.12); font-size: .84rem; }
.quick-start-button > span:last-child { min-width: 0; display: grid; gap: 3px; text-align: left; }
.quick-start-button small { font-size: .61rem; font-weight: 800; }
.quick-start-button strong { overflow: hidden; font: 800 1rem/1.15 Georgia, serif; white-space: nowrap; text-overflow: ellipsis; }
.quick-start-button:hover { background: #ecd78f; transform: translateY(-1px); }
.quick-tune-link { color: #c9d3c6; font-size: .7rem; font-weight: 800; text-decoration: none; white-space: nowrap; }
.quick-tune-link:hover { color: #ecd78f; }

.clock-settings { width: min(1060px, 100%); margin: 0 auto; display: grid; gap: 16px; }
.settings-section { padding: clamp(20px, 4vw, 34px); border: 1px solid var(--line); border-radius: 22px; background: rgba(24, 32, 26, .84); box-shadow: 0 18px 45px rgba(0, 0, 0, .16); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.section-heading > div { display: flex; align-items: center; gap: 12px; }
.section-heading h2 { margin: 0; font-size: clamp(1.15rem, 3vw, 1.55rem); }
.step { width: 30px; height: 30px; margin: 0; display: grid; place-items: center; flex: 0 0 auto; color: #111713; border-radius: 50%; background: var(--accent); font-weight: 900; }
.control-preview { color: #eadcae; font: 800 clamp(1.4rem, 4vw, 2rem)/1 Georgia, serif; }

.preset-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.preset-group h3 { margin: 0 0 9px; color: var(--muted); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; }
.preset-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.preset {
    min-height: 74px;
    padding: 10px 8px;
    display: grid;
    place-content: center;
    gap: 4px;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #111813;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.preset strong { font: 800 1.25rem/1 Georgia, serif; }
.preset span { color: var(--muted); font-size: .67rem; }
.preset:hover { transform: translateY(-1px); border-color: rgba(229, 202, 117, .5); }
.preset.is-selected { color: #151910; border-color: #e1ca82; background: #e1ca82; }
.preset.is-selected span { color: rgba(21, 25, 16, .7); }
.preset-group--tournament { grid-column: 1 / -1; }
.tournament-preset-grid { grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); }
.tournament-preset-grid .preset { min-height: 86px; }
.tournament-preset-grid .preset strong { font-size: clamp(.9rem, 2vw, 1.12rem); }
.favorite-controls { margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line); }
.favorite-controls > header { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.favorite-controls > header > div { display: grid; gap: 3px; }
.favorite-controls > header strong { font-size: .82rem; }
.favorite-controls > header small { color: var(--muted); font-size: .63rem; }
.favorite-control-toggle { min-height: 38px; padding: 7px 11px; color: #dce5da; border: 1px solid rgba(224,201,120,.3); border-radius: 9px; background: #111813; font-size: .68rem; font-weight: 800; cursor: pointer; }
.favorite-control-toggle span { color: #e3ca75; font-size: .9rem; }
.favorite-control-toggle[aria-pressed="true"] { color: #171a13; border-color: #e0c978; background: #e0c978; }
.favorite-control-toggle[aria-pressed="true"] span { color: #171a13; }
.favorite-control-list { min-height: 42px; margin-top: 11px; display: flex; flex-wrap: wrap; gap: 7px; }
.favorite-control-item { display: inline-grid; grid-template-columns: auto 32px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #0e1510; }
.favorite-control-launch { min-height: 42px; padding: 7px 11px; display: grid; align-content: center; gap: 2px; color: #e8ecdf; border: 0; background: transparent; text-align: left; cursor: pointer; }
.favorite-control-launch strong { font: 800 .82rem/1 Georgia, serif; }
.favorite-control-launch small { color: #89968c; font-size: .55rem; }
.favorite-control-launch:hover { background: rgba(224,201,120,.09); }
.favorite-control-remove { color: #9da99f; border: 0; border-left: 1px solid var(--line); background: transparent; font-size: .9rem; cursor: pointer; }
.favorite-control-remove:hover { color: #f0a493; background: rgba(184,83,70,.1); }
.favorite-control-empty { align-self: center; color: #78857b; font-size: .66rem; }

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset legend { width: 100%; margin-bottom: 10px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.mode-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.mode-picker label { position: relative; cursor: pointer; }
.mode-picker input { position: absolute; opacity: 0; pointer-events: none; }
.mode-picker span { min-height: 78px; padding: 15px; display: grid; align-content: center; gap: 5px; border: 1px solid var(--line); border-radius: 12px; background: #111813; }
.mode-picker strong { font-size: .9rem; }
.mode-picker small { color: var(--muted); font-size: .7rem; line-height: 1.35; }
.mode-picker input:checked + span { border-color: #d9c47f; background: rgba(217, 196, 127, .12); box-shadow: inset 0 0 0 1px #d9c47f; }
.mode-picker input:focus-visible + span { outline: 3px solid #e5ca75; outline-offset: 3px; }

.number-settings { margin-top: 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.number-field { display: grid; gap: 8px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.number-field input, .number-field select { width: 100%; min-height: 54px; padding: 10px 14px; color: var(--ink); border: 1px solid var(--line); border-radius: 11px; background: #0f1511; font-size: 1.15rem; font-weight: 800; }
.number-field input:disabled { opacity: .45; }
.mode-note { min-height: 20px; margin: 12px 0 0; color: #b7c5b3; font-size: .78rem; }
.stage-builder { margin-top: 17px; }
.stage-builder-heading { margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.stage-builder-heading > div { display: grid; gap: 3px; }
.stage-builder-heading strong { font-size: .83rem; }
.stage-builder-heading small { color: var(--muted); font-size: .67rem; }
.stage-list { display: grid; gap: 8px; }
.stage-row { padding: 11px; display: grid; grid-template-columns: 34px repeat(3, minmax(0, 1fr)) auto; align-items: end; gap: 9px; border: 1px solid var(--line); border-radius: 12px; background: #101612; }
.stage-number { width: 32px; height: 32px; align-self: center; display: grid; place-items: center; color: #151910; border-radius: 8px; background: #d9c680; font-size: .75rem; }
.stage-row .number-field input { min-height: 48px; font-size: 1rem; }
.remove-stage { width: 42px; min-height: 48px; padding: 5px; color: #e7aaa3; border-color: rgba(231, 170, 163, .25); font-size: 1.15rem; }

.table-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.compact-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.compact-picker legend { grid-column: 1 / -1; }
.compact-picker label { position: relative; cursor: pointer; }
.compact-picker input { position: absolute; opacity: 0; pointer-events: none; }
.compact-picker span { min-height: 46px; display: grid; place-items: center; border: 1px solid var(--line); background: #111813; font-size: .8rem; font-weight: 750; }
.compact-picker label:first-of-type span { border-radius: 10px 0 0 10px; }
.compact-picker label:last-of-type span { margin-left: -1px; border-radius: 0 10px 10px 0; }
.compact-picker input:checked + span { position: relative; z-index: 1; color: #171a13; border-color: #dfcb89; background: #dfcb89; }
.compact-picker input:focus-visible + span { outline: 3px solid #e5ca75; outline-offset: 3px; }

.switches { margin-top: 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.switch-row { min-height: 64px; padding: 11px 13px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid var(--line); border-radius: 11px; background: #111813; cursor: pointer; }
.switch-row > span { display: grid; gap: 3px; }
.switch-row strong { font-size: .8rem; }
.switch-row small { color: var(--muted); font-size: .68rem; }
.switch-row input { width: 42px; height: 24px; flex: 0 0 auto; accent-color: #9cc78d; }
.feedback-settings { margin-top: 20px; padding: 15px; border: 1px solid rgba(217,196,127,.22); border-radius: 14px; background: rgba(217,196,127,.045); }
.feedback-settings > header > div { display: grid; gap: 4px; }
.feedback-settings > header strong { color: #e7eadf; font-size: .88rem; }
.feedback-settings > header small { color: var(--muted); font-size: .68rem; line-height: 1.4; }
.silent-mode-row { margin-top: 12px; border-color: rgba(224,201,120,.34); background: rgba(224,201,120,.09); }
#feedback-controls { margin-top: 10px; transition: opacity .16s ease; }
#feedback-controls.is-disabled { opacity: .43; }
.feedback-switches { margin-top: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.feedback-tuning { margin-top: 10px; display: grid; grid-template-columns: minmax(180px, 1fr) minmax(190px, 1fr) minmax(180px, .8fr); align-items: end; gap: 10px; }
.feedback-tuning .number-field select { min-height: 48px; font-size: .84rem; }
.volume-field, .sound-preview-actions { min-height: 72px; padding: 10px 12px; display: grid; align-content: center; gap: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 11px; background: #111813; font-size: .72rem; font-weight: 750; }
.volume-field > span { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.volume-field output { color: #ead38a; font-variant-numeric: tabular-nums; }
.volume-field input { width: 100%; accent-color: #d9c47f; cursor: pointer; }
.sound-preview-actions > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.sound-preview-actions .secondary-button { min-height: 38px; padding: 7px 10px; }
.secondary-button:disabled { opacity: .42; cursor: not-allowed; }
.warning-signals { margin-top: 10px; padding: 10px 12px; display: flex; align-items: center; flex-wrap: wrap; gap: 7px; border: 1px solid rgba(143,191,128,.18); border-radius: 11px; background: rgba(143,191,128,.045); }
.warning-signals > span { min-width: 58px; padding: 6px 9px; color: #b9c8b5; border-radius: 8px; background: #0e1510; font-size: .66rem; text-align: center; }
.warning-signals strong { color: #e7d48f; font-size: .8rem; }
.warning-signals small { margin-left: auto; color: #8f9c91; font-size: .62rem; }
.tap-guard-row { margin-top: 12px; }
.arbiter-access-settings { margin-top: 12px; padding: 14px; display: grid; grid-template-columns: minmax(160px, 1fr) minmax(230px, 1.1fr) minmax(150px, .7fr); align-items: end; gap: 12px; border: 1px solid rgba(215,194,125,.24); border-radius: 13px; background: rgba(215,194,125,.045); }
.arbiter-access-settings > div { align-self: center; display: grid; gap: 4px; }
.arbiter-access-settings > div strong { color: #e4e9df; font-size: .8rem; }
.arbiter-access-settings > div small { color: var(--muted); font-size: .66rem; }
.arbiter-protection-picker legend { font-size: .68rem; }
.arbiter-pin-setting input { min-height: 46px; font-size: 1rem; letter-spacing: .14em; }
.handicap-toggle { margin-top: 20px; }
.asymmetric-settings { margin-top: 10px; padding: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; border: 1px solid rgba(217, 196, 127, .22); border-radius: 12px; background: rgba(217, 196, 127, .055); }

.variant-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.variant-picker label { position: relative; cursor: pointer; }
.variant-picker input { position: absolute; opacity: 0; pointer-events: none; }
.variant-picker span { min-height: 66px; padding: 13px 15px; display: grid; align-content: center; gap: 4px; border: 1px solid var(--line); border-radius: 12px; background: #111813; }
.variant-picker strong { font-size: .88rem; }
.variant-picker small { color: var(--muted); font-size: .69rem; }
.variant-picker input:checked + span { border-color: #d9c47f; background: rgba(217, 196, 127, .12); box-shadow: inset 0 0 0 1px #d9c47f; }
.variant-picker input:focus-visible + span { outline: 3px solid #e5ca75; outline-offset: 3px; }
.chess960-settings { margin-top: 18px; display: grid; gap: 14px; }
.position-controls { display: grid; grid-template-columns: minmax(140px, 1fr) auto minmax(110px, auto) auto; align-items: end; gap: 8px; }
.position-number-field input { min-height: 48px; }
.secondary-button { min-height: 43px; padding: 9px 13px; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; background: #111813; font-size: .76rem; font-weight: 800; cursor: pointer; }
.secondary-button:hover { border-color: rgba(229, 202, 117, .55); }
.position-controls .secondary-button { min-height: 48px; }
.chess960-preview-card { padding: clamp(14px, 2.4vw, 22px); border: 1px solid var(--line); border-radius: 16px; background: #0f1511; }
.position-heading { margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.position-heading > div { display: grid; gap: 3px; }
.position-heading span { color: var(--muted); font-size: .68rem; }
.position-heading strong { font-size: .9rem; }
.position-heading small { color: #b8c5b4; font: 700 .65rem/1.3 ui-monospace, monospace; letter-spacing: .04em; }
.fen-copy { padding: 7px 10px; color: #d9e2d7; border: 1px solid var(--line); border-radius: 8px; background: transparent; font-size: .67rem; cursor: pointer; }
.favorite-position { min-height: 40px; padding: 8px 12px; color: #d9e2d7; border: 1px solid var(--line); border-radius: 10px; background: #141b16; font-size: .69rem; font-weight: 800; cursor: pointer; }
.favorite-position span { color: #e2ca78; font-size: 1rem; }
.favorite-position[aria-pressed="true"] { color: #151910; border-color: #e2ca78; background: #e2ca78; }
.favorite-position[aria-pressed="true"] span { color: #151910; }
.chess960-main-grid { display: grid; grid-template-columns: minmax(420px, 1.45fr) minmax(270px, .65fr); align-items: start; gap: clamp(14px, 2.5vw, 24px); }
.position-board-column { min-width: 0; }
.position-board { width: min(100%, 680px); margin: 0 auto; display: grid; grid-template-columns: repeat(8, 1fr); overflow: hidden; border: clamp(4px, .7vw, 7px) solid #5c4932; border-radius: 10px; aspect-ratio: 1; background: #c7a978; box-shadow: 0 18px 38px rgba(0,0,0,.25); }
.position-square { position: relative; display: grid; place-items: center; color: #10140f; background: #e5d4ac; font: 400 clamp(1.45rem, 5.5vw, 4.15rem)/1 Georgia, serif; text-shadow: 0 1px 0 rgba(255,255,255,.35); }
.position-square.is-dark { background: #82956c; }
.position-square.is-black-piece { color: #101510; text-shadow: 0 1px 0 rgba(255,255,255,.2), 0 0 1px #fff; }
.position-square.is-white-piece { color: #fff9e9; text-shadow: 0 1px 1px #1d251e, 0 0 2px #152016; }
.position-square .square-coordinate { position: absolute; z-index: 2; left: 4px; top: 3px; color: rgba(20,28,21,.7); font: 800 clamp(.42rem, .9vw, .65rem)/1 system-ui, sans-serif; text-shadow: none; }
.position-square.is-dark .square-coordinate { color: rgba(244,239,218,.74); }
.position-square::after { content: ""; position: absolute; inset: 7%; z-index: 1; border: 0 solid transparent; border-radius: 8px; pointer-events: none; }
.position-square.is-king-start::after { border: 3px solid #2e78c8; box-shadow: inset 0 0 0 2px rgba(255,255,255,.4); }
.position-square.is-rook-start::after { border: 3px solid #d48f2f; }
.position-square.is-king-target::after { background: radial-gradient(circle, rgba(47,126,210,.52) 0 22%, transparent 24%); }
.position-square.is-rook-target::after { box-shadow: inset 0 0 0 5px rgba(222,157,58,.36); }
.position-square.is-king-start.is-king-target::after { border-color: #2e78c8; background: radial-gradient(circle, rgba(47,126,210,.52) 0 22%, transparent 24%); }
.position-square.is-rook-start.is-rook-target::after { border-color: #d48f2f; box-shadow: inset 0 0 0 5px rgba(222,157,58,.36); }
.position-coordinate-note { width: min(100%, 680px); margin: 5px auto 0; padding: 0 6px; display: grid; grid-template-columns: repeat(8, 1fr); color: #77837a; text-align: center; font: 700 .58rem/1 ui-monospace, monospace; }
.position-notation { min-height: 1.3em; margin: 9px 0 0; color: #abb8aa; text-align: center; font: 700 .68rem/1.45 ui-monospace, monospace; }
.castling-legend { margin-top: 9px; display: flex; justify-content: center; flex-wrap: wrap; gap: 7px 13px; color: #859087; font-size: .58rem; }
.castling-legend span { display: inline-flex; align-items: center; gap: 5px; }
.castling-legend i { width: 12px; height: 12px; border-radius: 3px; }
.castling-legend .king-start { border: 2px solid #2e78c8; }
.castling-legend .rook-start { border: 2px solid #d48f2f; }
.castling-legend .king-target { background: #3f86d1; }
.castling-legend .rook-target { background: rgba(222,157,58,.7); }
.chess960-details { display: grid; gap: 12px; }
.castling-card, .position-share-card { padding: 14px; display: grid; gap: 11px; border: 1px solid var(--line); border-radius: 13px; background: #141b16; }
.castling-heading { display: grid; gap: 3px; }
.castling-heading span, .position-share-card > div:first-child span, .position-code-grid section > div span { color: #89958b; font-size: .59rem; letter-spacing: .05em; text-transform: uppercase; }
.castling-heading strong, .position-share-card > div:first-child strong { color: #e5eae2; font-size: .82rem; }
.castling-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.castling-picker button { min-height: 39px; color: #b9c3b9; border: 1px solid var(--line); background: #0e1410; font-size: .66rem; font-weight: 800; cursor: pointer; }
.castling-picker button:first-child { border-radius: 9px 0 0 9px; }
.castling-picker button:last-child { margin-left: -1px; border-radius: 0 9px 9px 0; }
.castling-picker button.is-selected { position: relative; color: #151910; border-color: #dec77c; background: #dec77c; }
.castling-card p { margin: 0; color: #aeb9ae; font-size: .68rem; line-height: 1.5; }
.castling-destinations { display: grid; gap: 5px; color: #c7d1c5; font: 700 .64rem/1.35 ui-monospace, monospace; }
.position-share-card > div:first-child { display: grid; gap: 3px; }
.position-qr { width: min(190px, 82%); margin: 0 auto; padding: 8px; border-radius: 10px; background: white; aspect-ratio: 1; }
.position-qr svg { width: 100%; height: 100%; display: block; }
.position-link { overflow-wrap: anywhere; color: #8d998f; font: 600 .56rem/1.4 ui-monospace, monospace; }
.position-share-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.position-code-grid { margin-top: 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.position-code-grid section { min-width: 0; padding: 11px; border: 1px solid var(--line); border-radius: 11px; background: #111813; }
.position-code-grid section > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.position-code-grid .position-fen { white-space: pre-wrap; }
.position-fen { margin-top: 10px; display: block; overflow-wrap: anywhere; color: #849086; font: 600 .62rem/1.45 ui-monospace, monospace; }
.position-pgn { white-space: pre-wrap; }
.position-library { margin-top: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.position-library section { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: #111813; }
.position-library header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.position-library header strong { font-size: .72rem; }
.position-library header small { color: #7f8b82; font-size: .56rem; }
.position-chip-list { min-height: 37px; margin-top: 9px; display: flex; flex-wrap: wrap; gap: 6px; }
.position-chip { min-height: 32px; padding: 6px 9px; color: #cbd5c9; border: 1px solid var(--line); border-radius: 999px; background: #0d130f; font: 750 .62rem/1 ui-monospace, monospace; cursor: pointer; }
.position-chip:hover { border-color: #cdb873; }
.position-chip-empty { align-self: center; color: #748077; font-size: .61rem; }

/* Swiss tournament manager */
.tournament-page .setup-view {
    background:
        radial-gradient(circle at 10% 8%, rgba(216, 195, 130, .12), transparent 28rem),
        radial-gradient(circle at 92% 30%, rgba(118, 173, 105, .14), transparent 30rem),
        linear-gradient(180deg, #111914 0, #0b110d 100%);
}
.tournament-page-tool { padding: 0 0 60px; }
.tournament-intro { position: relative; margin: 34px 0 18px; padding: clamp(24px, 4vw, 40px); overflow: hidden; border: 1px solid rgba(216, 195, 130, .26); border-radius: 22px; background: linear-gradient(135deg, rgba(216, 195, 130, .085), rgba(143, 191, 128, .045)); }
.tournament-intro::after { content: "♟"; position: absolute; right: clamp(18px, 5vw, 55px); bottom: -34px; color: rgba(225, 211, 164, .07); font: 400 clamp(8rem, 20vw, 15rem)/1 Georgia, serif; pointer-events: none; }
.tournament-intro h1 { position: relative; z-index: 1; max-width: 720px; font-size: clamp(2.55rem, 7vw, 5.35rem); }
.tournament-intro > p:nth-of-type(2) { position: relative; z-index: 1; max-width: 680px; margin: 17px 0 0; color: var(--muted); font-size: clamp(.94rem, 1.8vw, 1.12rem); line-height: 1.55; }
.tournament-feature-list { position: relative; z-index: 1; margin-top: 20px; display: flex; flex-wrap: wrap; gap: 7px; }
.tournament-feature-list span { padding: 7px 10px; color: #dbe5d6; border: 1px solid rgba(143, 191, 128, .25); border-radius: 999px; background: rgba(143, 191, 128, .065); font-size: .67rem; font-weight: 750; }
.swiss-tool { width: min(1060px, 100%); margin: 0 auto; }
.swiss-intro { width: 100%; }
.swiss-setup { width: 100%; }
.swiss-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(150px, .3fr); gap: 10px; }
.text-field { display: grid; gap: 8px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.text-field input, .text-field textarea { width: 100%; padding: 13px 14px; color: var(--ink); border: 1px solid var(--line); border-radius: 11px; background: #0f1511; resize: vertical; }
.text-field input { min-height: 54px; }
.participant-field { margin-top: 14px; }
.field-hint { margin-top: -3px; color: #7f8b82; font-size: .64rem; font-weight: 600; line-height: 1.4; }
.participant-field textarea { min-height: 190px; line-height: 1.5; }
.swiss-setup-footer { margin-top: 14px; display: grid; grid-template-columns: auto minmax(260px, .55fr); align-items: center; justify-content: space-between; gap: 16px; }
.swiss-setup-footer p { color: var(--muted); font-size: .78rem; }
.swiss-create { min-height: 62px; }
.form-error { min-height: 18px; margin: 10px 0 0; color: #f19a91; font-size: .76rem; }
.form-error.is-info { color: #a9caa1; }
.tournament-tiebreak-settings { margin-top: 14px; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: #111713; }
.tournament-tiebreak-settings > summary { min-height: 52px; padding: 11px 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; color: #c9d3c7; cursor: pointer; font-size: .75rem; font-weight: 780; }
.tournament-tiebreak-settings > summary strong { color: #dfca87; font-size: .68rem; }
.tournament-tiebreak-settings[open] > summary { border-bottom: 1px solid var(--line); background: rgba(224,202,131,.035); }
.tournament-tiebreak-settings > fieldset { margin: 0; padding: 14px; border: 0; }
.tournament-tiebreak-presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tournament-tiebreak-presets label { position: relative; min-width: 0; cursor: pointer; }
.tournament-tiebreak-presets input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.tournament-tiebreak-presets label > span { min-height: 61px; padding: 10px 12px; display: grid; align-content: center; gap: 4px; border: 1px solid var(--line); border-radius: 10px; background: #0d130f; }
.tournament-tiebreak-presets strong { font-size: .74rem; }
.tournament-tiebreak-presets small { color: var(--muted); font-size: .59rem; line-height: 1.35; }
.tournament-tiebreak-presets input:checked + span { color: #151910; border-color: #d9c680; background: #d9c680; }
.tournament-tiebreak-presets input:checked + span small { color: rgba(21,25,16,.68); }
.tournament-tiebreak-presets input:focus-visible + span { outline: 3px solid #e5ca75; outline-offset: 3px; }
.tournament-tiebreak-order { margin-top: 9px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.tournament-tiebreak-order label { min-width: 0; display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: #0d130f; }
.tournament-tiebreak-order label > span { height: 100%; display: grid; place-items: center; color: #171a13; background: #d8c57f; font-size: .65rem; font-weight: 900; }
.tournament-tiebreak-order select { min-width: 0; min-height: 46px; padding: 7px 9px; color: var(--ink); border: 0; outline-offset: -3px; background: transparent; font-size: .67rem; font-weight: 720; }
.tournament-tiebreak-footer { margin-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.tournament-tiebreak-footer p { max-width: 650px; margin: 0; color: #c9b98d; font-size: .64rem; line-height: 1.45; }
.tournament-tiebreak-footer .secondary-button { flex: 0 0 auto; }
.swiss-workspace { display: grid; gap: 16px; }
.tournament-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.tournament-header h2 { margin: 3px 0 6px; font: 800 clamp(1.55rem, 4vw, 2.25rem)/1 Georgia, serif; }
.tournament-header p:last-child { margin: 0; color: var(--muted); font-size: .78rem; }
.tournament-state-line { display: flex; align-items: center; gap: 9px; }
.tournament-state-line .eyebrow { margin-bottom: 0; }
.tournament-publication-status { min-height: 25px; padding: 5px 8px; display: inline-grid; place-items: center; border: 1px solid rgba(222,157,58,.32); border-radius: 999px; color: #eccb91; background: rgba(121,77,26,.18); font-size: .56rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.tournament-publication-status.is-published,
.tournament-publication-status[data-status="published"] { color: #b8deb0; border-color: rgba(128,189,112,.33); background: rgba(66,116,55,.17); }
.tournament-publication-status.is-completed,
.tournament-publication-status[data-status="completed"] { color: #e6dbb9; border-color: rgba(224,202,131,.35); background: rgba(116,96,42,.18); }
.swiss-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); align-items: start; gap: 16px; }
.round-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.round-heading > div { display: flex; align-items: center; gap: 12px; }
.round-heading h2 { margin: 0; }
.round-heading > span { color: var(--muted); font-size: .7rem; }
.pairing-list { display: grid; gap: 9px; }
.pairing-card { padding: 11px; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 8px 11px; border: 1px solid var(--line); border-radius: 12px; background: #111813; }
.board-number { grid-row: 1 / 3; width: 32px; height: 32px; display: grid; place-items: center; color: #151910; border-radius: 8px; background: #d9c680; font-size: .72rem; font-weight: 900; }
.pairing-players { display: grid; gap: 5px; }
.pairing-player { min-width: 0; display: flex; align-items: center; gap: 7px; font-size: .8rem; font-weight: 800; }
.pairing-player i { width: 10px; height: 10px; flex: 0 0 auto; border: 1px solid #d5dece; border-radius: 50%; }
.pairing-player--white i { background: #f5ecd6; }
.pairing-player--black i { background: #202921; }
.result-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.result-button { min-height: 34px; padding: 5px; color: #c8d1c6; border: 1px solid var(--line); border-radius: 7px; background: #0d130f; font-size: .68rem; font-weight: 800; cursor: pointer; }
.result-button.is-selected { color: #111510; border-color: #dfca87; background: #dfca87; }
.bye-label { color: #b8c5b3; font-size: .72rem; }
.next-round { min-height: 62px; margin-top: 13px; }
.next-round:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.standings-scroll { overflow-x: auto; }
.standings-table { width: 100%; border-collapse: collapse; font-size: .76rem; }
.standings-table th, .standings-table td { padding: 10px 7px; border-bottom: 1px solid var(--line); text-align: left; }
.standings-table th { color: var(--muted); font-size: .62rem; letter-spacing: .05em; text-transform: uppercase; }
.standings-table th:nth-child(n+3), .standings-table td:nth-child(n+3) { text-align: right; }
.standings-table td:nth-child(2) { min-width: 130px; font-weight: 800; }
.tournament-standings-state { padding: 5px 8px; color: #d7c88f; border: 1px solid rgba(216,197,127,.28); border-radius: 999px; background: rgba(216,197,127,.07); font-size: .58rem; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.tournament-standings-state.is-final { color: #bce3c3; border-color: rgba(120,190,136,.35); background: rgba(83,149,98,.12); }
.tournament-standings-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 7px; }
.tournament-standings-actions .secondary-button { min-height: 32px; padding: 6px 9px; font-size: .59rem; }
.tournament-tiebreak-legend { margin-top: 10px; border-top: 1px solid var(--line); }
.tournament-tiebreak-legend > summary { padding: 11px 0 5px; color: #d8c57f; cursor: pointer; font-size: .65rem; font-weight: 800; }
.tournament-tiebreak-legend dl { margin: 7px 0; display: grid; grid-template-columns: minmax(56px, auto) minmax(0, 1fr); gap: 6px 10px; }
.tournament-tiebreak-legend dt { color: #dfca87; font-size: .62rem; font-weight: 900; }
.tournament-tiebreak-legend dd { margin: 0; color: #b9c2b8; font-size: .61rem; line-height: 1.45; }
.tournament-tiebreak-legend > p { margin: 7px 0 0; color: var(--muted); font-size: .59rem; line-height: 1.45; }
.tournament-note { margin: 0; color: #b5c4b1; text-align: center; font-size: .76rem; }

/* Tournament director console */
.tournament-page .tournament-intro { margin: 24px 0 14px; padding: clamp(21px, 3vw, 30px); }
.tournament-page .tournament-intro h1 { font-size: clamp(2.15rem, 5.6vw, 4.25rem); }
.tournament-page .tournament-intro > p:nth-of-type(2) { margin-top: 12px; font-size: clamp(.86rem, 1.5vw, 1rem); }
.tournament-page .tournament-feature-list { margin-top: 14px; }
.tournament-page.has-active-tournament .tournament-intro,
.tournament-page:has(#swiss-workspace:not([hidden])) .tournament-intro {
    min-height: 0;
    margin: 12px 0 8px;
    padding: 15px 20px;
}
.tournament-page.has-active-tournament .tournament-intro h1,
.tournament-page:has(#swiss-workspace:not([hidden])) .tournament-intro h1 {
    font: 800 clamp(1.35rem, 3vw, 1.8rem)/1.1 Georgia, serif;
    letter-spacing: -.025em;
}
.tournament-page.has-active-tournament .tournament-intro > p:nth-of-type(2),
.tournament-page.has-active-tournament .tournament-feature-list,
.tournament-page:has(#swiss-workspace:not([hidden])) .tournament-intro > p:nth-of-type(2),
.tournament-page:has(#swiss-workspace:not([hidden])) .tournament-feature-list { display: none; }
.tournament-page.has-active-tournament .tournament-intro::after,
.tournament-page:has(#swiss-workspace:not([hidden])) .tournament-intro::after { right: 18px; bottom: -18px; font-size: 6rem; }
.tournament-page.has-active-tournament .tournament-intro .eyebrow,
.tournament-page:has(#swiss-workspace:not([hidden])) .tournament-intro .eyebrow { margin-bottom: 4px; font-size: .62rem; }
.tournament-page.has-active-tournament .tournament-library,
.tournament-page:has(#swiss-workspace:not([hidden])) .tournament-library { display: none; }

.tournament-library { margin-bottom: 16px; }
.tournament-library__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.tournament-library__header h2 { margin: 0; font-size: clamp(1.2rem, 3vw, 1.55rem); }
.tournament-library__header p:last-child { margin: 7px 0 0; color: var(--muted); font-size: .74rem; line-height: 1.45; }
.tournament-library__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.secondary-button--accent { color: #151910; border-color: #e0ca83; background: #e0ca83; }
.secondary-button--accent:hover { background: #ecd78f; }
.tournament-library__grid { margin-top: 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tournament-library__group { min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: #111713; }
.tournament-library__group > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tournament-library__group h3 { margin: 0; font-size: .8rem; }
.tournament-library__group > header span { min-width: 24px; min-height: 24px; display: grid; place-items: center; color: #151910; border-radius: 999px; background: #d9c680; font-size: .65rem; font-weight: 900; }
.tournament-library__list { min-height: 54px; margin-top: 9px; display: grid; gap: 7px; }
.tournament-library-card { min-width: 0; padding: 11px; display: flex; align-items: stretch; flex-direction: column; justify-content: space-between; gap: 10px; color: var(--ink); border: 1px solid rgba(255,255,255,.08); border-radius: 10px; background: #0d130f; text-align: left; }
.tournament-library-card.is-current { border-color: rgba(224,202,131,.55); box-shadow: inset 0 0 0 1px rgba(224,202,131,.12); }
.tournament-library-card > div { min-width: 0; display: grid; gap: 3px; }
.tournament-library-card h3 { margin: 0; overflow: hidden; font-size: .78rem; white-space: nowrap; text-overflow: ellipsis; }
.tournament-library-card p { margin: 0; color: var(--muted); font-size: .62rem; line-height: 1.4; }
.tournament-library-card__status { width: max-content; margin-bottom: 2px; color: #e1c978; font-size: .55rem; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.tournament-library-card__status.is-complete { color: #99cc8c; }
.tournament-library-card > .tournament-library-card__actions { display: flex; flex-wrap: wrap; gap: 5px; }
.tournament-card-button { min-height: 38px; padding: 6px 9px; color: #bdc8be; border: 1px solid var(--line); border-radius: 8px; background: #151d17; font-size: .6rem; font-weight: 820; cursor: pointer; }
.tournament-card-button:hover { color: #eef2e9; border-color: rgba(224,202,131,.35); }
.tournament-card-button.is-primary { color: #151910; border-color: #d9c680; background: #d9c680; }
.tournament-card-button.is-danger { color: #e8aaa2; border-color: rgba(213,105,94,.25); background: rgba(112,45,39,.17); }
.tournament-empty-state { margin: 0; align-self: center; color: #7f8a82; font-size: .68rem; line-height: 1.4; }

.tournament-toolbar {
    position: sticky;
    z-index: 25;
    top: 8px;
    padding: 9px 10px 9px 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid rgba(224,201,120,.24);
    border-radius: 14px;
    background: rgba(13,19,15,.95);
    box-shadow: 0 12px 32px rgba(0,0,0,.28);
    backdrop-filter: blur(14px);
}
.tournament-save-state { min-width: 0; display: flex; align-items: center; gap: 8px; color: #aeb9ae; font-size: .66rem; font-weight: 750; }
.tournament-save-state i { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: #80bd70; box-shadow: 0 0 0 3px rgba(128,189,112,.12); }
.tournament-save-state.is-saving i { background: #d9bc67; }
.tournament-save-state.is-error { color: #efaaa1; }
.tournament-save-state.is-error i { background: #d86e63; }
.tournament-toolbar__actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.tournament-toolbar__button { min-height: 44px; padding: 8px 11px; color: #dce4da; border: 1px solid var(--line); border-radius: 9px; background: #172019; font-size: .66rem; font-weight: 820; cursor: pointer; }
.tournament-toolbar__button:hover { border-color: rgba(224,201,120,.42); background: #202a22; }
.tournament-toolbar__button:disabled { opacity: .42; cursor: not-allowed; }
.tournament-toolbar__button--danger { color: #e7b0aa; border-color: rgba(213,105,94,.24); background: rgba(112,45,39,.16); }
.tournament-toolbar__actions { flex-wrap: wrap; }
.tournament-toolbar__button--publish { color: #152016; border-color: #9ac68d; background: #9ac68d; }
.tournament-toolbar__button--publish:hover { color: #101710; border-color: #afd4a5; background: #afd4a5; }
.tournament-toolbar__button--finish { color: #eadba9; border-color: rgba(224,202,131,.35); }

.tournament-mobile-tabs { display: none; }
.tournament-round-tabs { margin: -6px 0 13px; padding-bottom: 3px; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; }
.tournament-round-tabs button { min-width: 66px; min-height: 42px; padding: 7px 10px; flex: 0 0 auto; color: #aab6ac; border: 1px solid var(--line); border-radius: 9px; background: #0d130f; font-size: .66rem; font-weight: 800; cursor: pointer; }
.tournament-round-tabs button.is-active,
.tournament-round-tabs button[aria-current="page"] { color: #151910; border-color: #dfca87; background: #dfca87; }
.tournament-pairing-diagnostics { margin: 0 0 13px; overflow: hidden; border: 1px solid rgba(143,191,128,.2); border-radius: 12px; background: #0d130f; }
.tournament-pairing-diagnostics > summary { min-height: 48px; padding: 9px 12px; display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; }
.tournament-pairing-diagnostics > summary::-webkit-details-marker { display: none; }
.tournament-pairing-diagnostics > summary::after { content: "⌄"; margin-left: auto; color: #8f9a91; font-size: .9rem; transition: transform .16s ease; }
.tournament-pairing-diagnostics[open] > summary::after { transform: rotate(180deg); }
.tournament-pairing-diagnostics > summary strong { min-width: 0; overflow-wrap: anywhere; font-size: .69rem; }
.tournament-pairing-health { min-width: 72px; padding: 5px 8px; display: inline-grid; place-items: center; border: 1px solid rgba(128,189,112,.3); border-radius: 999px; color: #bce1b4; background: rgba(73,121,61,.15); font-size: .56rem; font-weight: 900; text-transform: uppercase; }
.tournament-pairing-health.is-warning { color: #ebce8b; border-color: rgba(222,169,73,.35); background: rgba(126,84,27,.17); }
.tournament-pairing-health.is-error { color: #efaaa2; border-color: rgba(210,92,81,.38); background: rgba(118,43,36,.18); }
.tournament-pairing-diagnostics__body { padding: 0 12px 12px; display: grid; gap: 10px; border-top: 1px solid var(--line); }
.tournament-pairing-diagnostics__stats { padding-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.tournament-pairing-diagnostics__stats span { padding: 5px 7px; color: #c7d0c8; border: 1px solid var(--line); border-radius: 7px; background: #131b15; font-size: .59rem; font-weight: 800; }
.tournament-pairing-diagnostics__list { margin: 0; padding-left: 18px; display: grid; gap: 5px; color: #b5c0b6; font-size: .64rem; line-height: 1.45; }
.tournament-pairing-diagnostics__list li.is-warning { color: #e1c783; }
.tournament-pairing-diagnostics__list li.is-error { color: #eca39b; }
.tournament-float-history { padding: 10px 11px; display: grid; gap: 9px; border: 1px solid rgba(116,164,104,.18); border-radius: 10px; background: rgba(116,164,104,.045); }
.tournament-float-history > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tournament-float-history > header strong { font-size: .67rem; }
.tournament-float-history > header span { color: #8f9c91; font-size: .56rem; font-weight: 780; }
.tournament-scoregroups { display: flex; flex-wrap: wrap; gap: 5px; }
.tournament-scoregroups span { padding: 4px 6px; color: #c8d7c5; border: 1px solid rgba(143,191,128,.2); border-radius: 999px; background: #0c120e; font-size: .54rem; font-weight: 800; }
.tournament-float-history ul { max-height: 150px; margin: 0; padding: 0; display: grid; gap: 5px; overflow: auto; list-style: none; }
.tournament-float-history li { padding: 6px 7px; color: #aebbb0; border-radius: 7px; background: rgba(255,255,255,.035); font-size: .59rem; line-height: 1.4; }
.tournament-float-history li strong { color: #e2cd84; }
.tournament-float-history li.is-potential { color: #c7b785; border: 1px dashed rgba(222,169,73,.24); background: rgba(105,72,26,.1); }
.tournament-pairing-diagnostics__body > .secondary-button { justify-self: start; min-height: 42px; }
.tournament-mobile-alert-count { min-width: 18px; height: 18px; margin-left: 3px; display: inline-grid; place-items: center; border-radius: 999px; color: #17140c; background: #dfb657; font-size: .55rem; font-weight: 950; }
.tournament-result-progress { margin-bottom: 13px; padding: 11px 12px; display: grid; gap: 8px; border: 1px solid rgba(143,191,128,.16); border-radius: 11px; background: rgba(143,191,128,.045); }
.tournament-result-progress > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: .69rem; }
.tournament-result-progress span { color: #a7b4a8; font-variant-numeric: tabular-nums; }
.tournament-result-progress progress { width: 100%; height: 7px; overflow: hidden; border: 0; border-radius: 999px; background: #222b24; }
.tournament-result-progress progress::-webkit-progress-bar { border-radius: 999px; background: #222b24; }
.tournament-result-progress progress::-webkit-progress-value { border-radius: 999px; background: linear-gradient(90deg, #86bd76, #d9c77e); }
.tournament-result-progress progress::-moz-progress-bar { border-radius: 999px; background: linear-gradient(90deg, #86bd76, #d9c77e); }
.tournament-pairing-tools { margin-bottom: 13px; display: grid; grid-template-columns: auto minmax(160px, 1fr); gap: 8px; }
.tournament-pairing-filters { padding: 3px; display: grid; grid-template-columns: repeat(3, auto); gap: 3px; border: 1px solid var(--line); border-radius: 10px; background: #0d130f; }
.tournament-pairing-filters button { min-height: 40px; padding: 6px 9px; color: #98a49b; border: 0; border-radius: 7px; background: transparent; font-size: .62rem; font-weight: 800; cursor: pointer; }
.tournament-pairing-filters button.is-active,
.tournament-pairing-filters button[aria-pressed="true"] { color: #151910; background: #d9c680; }
.tournament-pairing-search input { width: 100%; min-height: 48px; padding: 9px 12px 9px 36px; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; background: #0d130f; font-size: .73rem; }
.tournament-pairing-search { position: relative; min-width: 0; }
.tournament-pairing-search::before { content: "⌕"; position: absolute; z-index: 1; left: 12px; top: 50%; color: #849087; transform: translateY(-50%); pointer-events: none; }
.tournament-page .pairing-player { overflow-wrap: anywhere; line-height: 1.25; }
.tournament-page .result-button { min-height: 46px; padding: 7px 8px; display: flex; align-items: center; justify-content: center; gap: 5px; border-radius: 9px; touch-action: manipulation; }
.tournament-page .result-button.is-selected::after,
.tournament-page .result-button[aria-pressed="true"]::after { content: "✓"; font-size: .75rem; font-weight: 950; }
.tournament-page .result-button:disabled { cursor: default; }
.tournament-page .pairing-card.is-readonly .result-button:not(.is-selected) { opacity: .42; }
.tournament-page .pairing-card.is-complete { border-color: rgba(143,191,128,.28); }
.tournament-page .pairing-card.is-pending { border-color: rgba(222,157,58,.28); }
.tournament-page .pairing-card[hidden] { display: none; }
.pairing-card__meta { grid-column: 2; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.pairing-diagnostic-badge { padding: 4px 6px; color: #aeb9b0; border: 1px solid var(--line); border-radius: 999px; background: #0c120e; font-size: .55rem; font-weight: 800; }
.pairing-diagnostic-badge.is-warning { color: #e3c77d; border-color: rgba(222,169,73,.3); }
.pairing-explain-button, .pairing-board-move { min-height: 36px; padding: 5px 8px; color: #c8d3c9; border: 1px solid var(--line); border-radius: 8px; background: #151d17; font-size: .58rem; font-weight: 850; cursor: pointer; }
.pairing-board-move { width: 38px; padding: 4px; font-size: .82rem; }
.pairing-explain-button:hover, .pairing-board-move:hover { color: #161a12; border-color: #dac77f; background: #dac77f; }
.pairing-board-move:disabled { opacity: .35; cursor: default; }
.special-result-trigger { min-height: 40px; padding: 6px 9px; color: #aeb9b0; border: 1px dashed rgba(255,255,255,.17); border-radius: 8px; background: transparent; font-size: .61rem; font-weight: 800; cursor: pointer; }
.special-result-trigger:hover { color: #ead99d; border-color: rgba(224,202,131,.42); background: rgba(224,202,131,.045); }
.result-picker .special-result-trigger { grid-column: 1 / -1; }
.special-result-trigger.is-selected { color: #e8d68e; border-style: solid; border-color: rgba(224,202,131,.42); background: rgba(224,202,131,.08); }
.tournament-correction-note { padding: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid rgba(224,169,79,.28); border-radius: 11px; background: rgba(101,68,25,.13); }
.tournament-correction-note p { margin: 0; color: #c9b88f; font-size: .68rem; line-height: 1.45; }
.tournament-correction-note .secondary-button { flex: 0 0 auto; }
.tournament-pairings-empty { padding: 18px; text-align: center; }
.standings-table tr.is-withdrawn { opacity: .52; }

.tournament-secondary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.tournament-secondary-grid .section-heading { margin-bottom: 14px; }
.tournament-secondary-grid .section-heading > span { color: var(--muted); font-size: .7rem; }
.tournament-participants-list, .tournament-history-list { min-height: 62px; margin: 0; padding: 0; display: grid; gap: 7px; list-style: none; }
.tournament-participant-row, .tournament-history-item { min-width: 0; padding: 10px 11px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; background: #111813; font-size: .7rem; }
.tournament-participant-row { grid-template-columns: 30px minmax(0, 1fr) auto auto; }
.tournament-participant-row strong, .tournament-history-item strong { min-width: 0; overflow-wrap: anywhere; }
.tournament-participant-row small, .tournament-history-item small { color: var(--muted); }
.tournament-participant__seed { width: 28px; height: 28px; display: grid; place-items: center; color: #171a13; border-radius: 8px; background: #d8c57f; font-size: .62rem; font-weight: 900; }
.tournament-participant__info, .tournament-history-item > div { min-width: 0; display: grid; gap: 3px; }
.tournament-participant__status { min-height: 38px; padding: 6px 9px; color: #b9dcb0; border: 1px solid rgba(131,183,116,.28); border-radius: 8px; background: rgba(76,119,65,.12); font-size: .59rem; font-weight: 850; cursor: pointer; }
.tournament-participant__status:disabled { opacity: .55; cursor: not-allowed; }
.tournament-participant-row.is-withdrawn { opacity: .6; }
.tournament-participant-row.is-withdrawn .tournament-participant__status { color: #e2aaa2; border-color: rgba(207,98,86,.25); background: rgba(113,48,40,.15); }
.tournament-participant-round-action { min-height: 40px; padding: 6px 9px; color: #d8c984; border: 1px solid rgba(224,202,131,.25); border-radius: 8px; background: rgba(224,202,131,.06); font-size: .59rem; font-weight: 850; cursor: pointer; }
.tournament-history-item.is-complete { border-color: rgba(128,189,112,.2); }
.tournament-history-item.is-pending { border-color: rgba(222,157,58,.25); }
.tournament-audit-protocol { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.tournament-audit-protocol > header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.tournament-audit-protocol > header > div:first-child { display: grid; gap: 3px; }
.tournament-audit-protocol h3 { margin: 0; font-size: .82rem; }
.tournament-audit-protocol > header span { color: var(--muted); font-size: .59rem; }
.tournament-audit-protocol > header > div:last-child { display: flex; gap: 6px; }
.tournament-audit-protocol select { min-height: 42px; padding: 7px 9px; color: var(--ink); border: 1px solid var(--line); border-radius: 9px; background: #0d130f; font-size: .63rem; }
.tournament-protocol-list { max-height: 280px; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; overflow: auto; list-style: none; }
.tournament-protocol-item { padding: 9px 10px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 8px; border: 1px solid var(--line); border-radius: 9px; background: #0d130f; font-size: .63rem; }
.tournament-protocol-item time { color: #869188; font-variant-numeric: tabular-nums; }
.tournament-protocol-item p { min-width: 0; margin: 0; overflow-wrap: anywhere; line-height: 1.4; }
.tournament-protocol-item span { color: #d8c77f; font-size: .57rem; font-weight: 800; }
.tournament-mobile-action { display: none; }

.tournament-dialog { width: min(620px, calc(100% - 24px)); max-height: min(820px, calc(100dvh - 24px)); margin: auto; padding: 0; overflow: auto; color: var(--ink); border: 1px solid rgba(224,202,131,.34); border-radius: 18px; background: #111713; box-shadow: 0 26px 80px rgba(0,0,0,.62); }
.tournament-dialog::backdrop { background: rgba(4,8,5,.84); backdrop-filter: blur(5px); }
.tournament-dialog > form { padding: clamp(17px, 4vw, 27px); display: grid; gap: 14px; }
.tournament-dialog__panel { padding: clamp(17px, 4vw, 27px); display: grid; gap: 14px; }
.tournament-dialog > form > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.tournament-dialog__panel > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.tournament-dialog h2 { margin: 0; font: 800 clamp(1.35rem, 4vw, 1.9rem)/1.08 Georgia, serif; }
.tournament-dialog > form > p:not(.form-error) { margin: 0; color: var(--muted); font-size: .72rem; line-height: 1.5; }
.tournament-dialog .tournament-dialog__context { padding: 10px 12px; color: #e7eadf; border: 1px solid var(--line); border-radius: 10px; background: #0d130f; font-weight: 800; }
.tournament-dialog__close { width: 44px; height: 44px; flex: 0 0 auto; color: #dce5da; border: 1px solid var(--line); border-radius: 50%; background: #1a221c; font-size: 1.45rem; cursor: pointer; }
.tournament-dialog fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.tournament-dialog fieldset legend { margin-bottom: 8px; }
.tournament-special-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.tournament-special-results label { position: relative; min-width: 0; cursor: pointer; }
.tournament-special-results input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.tournament-special-results label > span { min-height: 66px; padding: 10px; display: grid; place-content: center; gap: 4px; color: #dbe3d8; border: 1px solid var(--line); border-radius: 10px; background: #0d130f; text-align: center; }
.tournament-special-results strong { font-size: .78rem; }
.tournament-special-results small { color: var(--muted); font-size: .59rem; }
.tournament-special-results input:checked + span { color: #151910; border-color: #dfca87; background: #dfca87; }
.tournament-special-results input:checked + span small { color: rgba(21,25,16,.68); }
.tournament-special-results input:focus-visible + span { outline: 3px solid #e5ca75; outline-offset: 3px; }
.tournament-dialog .tournament-dialog__hint { color: #ccb98c; }
.tournament-dialog menu { margin: 0; padding: 3px 0 0; display: grid; grid-template-columns: minmax(110px,.35fr) minmax(190px,.65fr); gap: 8px; }
.tournament-dialog menu .secondary-button, .tournament-dialog menu .start-button { width: 100%; min-height: 50px; padding: 10px 13px; border-radius: 10px; font-size: .72rem; }
.tournament-dialog__panel > p { margin: 0; color: var(--muted); font-size: .72rem; line-height: 1.5; }
.tournament-pairing-edit-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.tournament-pairing-edit-preview { padding: 11px 12px; color: #b7c3b8; border: 1px solid var(--line); border-radius: 10px; background: #0d130f; font-size: .68rem; line-height: 1.45; }
.tournament-pairing-edit-preview.is-valid { color: #b8ddb0; border-color: rgba(128,189,112,.3); }
.tournament-pairing-edit-preview.is-warning { color: #e4c77f; border-color: rgba(222,169,73,.34); }
.tournament-explanation-block { padding: 11px 12px; display: grid; gap: 5px; border: 1px solid var(--line); border-radius: 10px; background: #0d130f; }
.tournament-explanation-block strong { color: #e6d491; font-size: .64rem; }
.tournament-explanation-block p { margin: 0; color: #bcc6bd; font-size: .68rem; line-height: 1.5; }
.tournament-pairing-explanation-issues, .tournament-pairing-publish-warnings { margin: 0; padding: 11px 12px 11px 28px; display: grid; gap: 6px; color: #e2c47d; border: 1px solid rgba(222,169,73,.25); border-radius: 10px; background: rgba(94,64,24,.13); font-size: .66rem; line-height: 1.45; }
.tournament-pairing-explanation-issues:empty { display: none; }
.tournament-player-skip, .tournament-organizer-bye { position: relative; cursor: pointer; }
.tournament-player-skip > input, .tournament-organizer-bye > input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.tournament-player-skip > span, .tournament-organizer-bye > span { min-height: 62px; padding: 11px 12px 11px 46px; position: relative; display: grid; align-content: center; gap: 3px; border: 1px solid var(--line); border-radius: 10px; background: #0d130f; }
.tournament-player-skip > span::before, .tournament-organizer-bye > span::before { content: ""; position: absolute; left: 14px; top: 50%; width: 20px; height: 20px; border: 1px solid #657168; border-radius: 6px; transform: translateY(-50%); }
.tournament-player-skip input:checked + span, .tournament-organizer-bye input:checked + span { border-color: rgba(224,202,131,.52); background: rgba(224,202,131,.08); }
.tournament-player-skip input:checked + span::before, .tournament-organizer-bye input:checked + span::before { content: "✓"; display: grid; place-items: center; color: #151910; border-color: #dfca87; background: #dfca87; font-size: .72rem; font-weight: 950; }
.tournament-player-skip input:focus-visible + span, .tournament-organizer-bye input:focus-visible + span { outline: 3px solid #e5ca75; outline-offset: 3px; }
.tournament-player-skip strong, .tournament-organizer-bye strong { font-size: .73rem; }
.tournament-player-skip small, .tournament-organizer-bye small { color: var(--muted); font-size: .6rem; }
.tournament-requested-bye { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.tournament-requested-bye legend { grid-column: 1 / -1; }
.tournament-requested-bye label { position: relative; cursor: pointer; }
.tournament-requested-bye input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.tournament-requested-bye span { min-height: 46px; display: grid; place-items: center; color: #c7d1c7; border: 1px solid var(--line); border-radius: 9px; background: #0d130f; font-size: .67rem; font-weight: 800; }
.tournament-requested-bye input:checked + span { color: #151910; border-color: #dfca87; background: #dfca87; }
.tournament-requested-bye input:focus-visible + span { outline: 3px solid #e5ca75; outline-offset: 3px; }

.start-button { width: 100%; min-height: 76px; padding: 16px clamp(18px, 4vw, 32px); display: flex; align-items: center; justify-content: space-between; gap: 18px; color: #111510; border: 0; border-radius: 17px; background: #e0ca83; box-shadow: 0 15px 35px rgba(0, 0, 0, .2); cursor: pointer; }
.start-button span { font-size: 1rem; font-weight: 900; }
.start-button strong { font: 800 1.25rem/1 Georgia, serif; }
.start-button:hover { background: #ecd78f; transform: translateY(-1px); }
.setup-tip { margin: -4px 0 0; color: #7f8c82; text-align: center; font-size: .72rem; }

/* Synchronized clocks on two phones */
.clock-launch-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.clock-launch-options .start-button { min-width: 0; height: 100%; flex-direction: column; align-items: flex-start; justify-content: center; gap: 7px; text-align: left; }
.clock-launch-options .start-button strong { max-width: 100%; line-height: 1.15; }
.start-button--online { color: #e8eddf; border: 1px solid rgba(224,201,120,.5); background: linear-gradient(135deg, #1e2d22, #172019); box-shadow: inset 0 0 0 1px rgba(255,255,255,.03), 0 15px 35px rgba(0,0,0,.2); }
.start-button--online:hover { background: linear-gradient(135deg, #283a2d, #1a251d); }
.start-button--online span { color: #d8c77f; }
.sync-join-card { margin-top: -8px; padding: 12px 14px; display: grid; grid-template-columns: minmax(180px, 1fr) minmax(130px, .35fr) auto; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 13px; background: #101612; }
.sync-join-card > div { display: grid; gap: 3px; }
.sync-join-card strong { font-size: .76rem; }
.sync-join-card small { color: var(--muted); font-size: .62rem; }
.sync-join-card input { width: 100%; min-height: 44px; padding: 9px 12px; color: #f1e9ce; border: 1px solid rgba(224,201,120,.28); border-radius: 9px; outline: 0; background: #0a100c; font: 900 1.05rem/1 ui-monospace, monospace; letter-spacing: .16em; text-transform: uppercase; }
.sync-join-card input:focus { border-color: #dfc975; box-shadow: 0 0 0 3px rgba(223,201,117,.12); }
.sync-join-card .secondary-button { min-height: 44px; }
.sync-join-card > p { grid-column: 2 / -1; min-height: 0; margin: -5px 0 0; color: #ef9d8d; font-size: .62rem; }
.clock-portability { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); gap: 12px; }
.clock-settings-share, .clock-install-card { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: #101612; }
.clock-settings-share > header > div, .clock-install-card > div:nth-child(2) { display: grid; gap: 4px; }
.clock-settings-share > header span, .clock-install-card > div:nth-child(2) > span { color: #9dc58f; font-size: .59rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.clock-settings-share > header strong, .clock-install-card > div:nth-child(2) > strong { font-size: .84rem; }
.clock-settings-share-body { margin-top: 12px; display: grid; grid-template-columns: 132px minmax(0, 1fr); align-items: center; gap: 13px; }
.clock-settings-qr { width: 132px; height: 132px; padding: 7px; border-radius: 10px; background: white; }
.clock-settings-qr svg { width: 100%; height: 100%; display: block; }
.clock-settings-link-panel { min-width: 0; display: grid; gap: 9px; }
.clock-settings-link-panel p { margin: 0; color: #a4b0a6; font-size: .65rem; line-height: 1.45; }
.clock-settings-link { max-height: 3.2em; overflow: hidden; overflow-wrap: anywhere; color: #849087; font: 600 .56rem/1.45 ui-monospace, monospace; }
.clock-settings-link-panel > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.clock-settings-link-panel .secondary-button { min-height: 38px; padding: 7px 9px; font-size: .65rem; }
.clock-install-card { display: grid; grid-template-columns: 60px minmax(0, 1fr); align-content: center; align-items: center; gap: 11px 13px; border-color: rgba(143,191,128,.22); background: linear-gradient(145deg, #121b15, #0e1510); }
.clock-app-icon { position: relative; width: 58px; height: 58px; display: grid; place-items: center; overflow: hidden; color: #e5d083; border-radius: 15px; background: #1b2b20; box-shadow: inset 0 0 0 1px rgba(224,201,120,.25); }
.clock-app-icon span { position: relative; z-index: 1; font: 700 2rem/1 Georgia, serif; }
.clock-app-icon i { position: absolute; width: 35px; height: 35px; border: 3px solid rgba(143,191,128,.48); border-radius: 50%; }
.clock-install-card p { margin: 2px 0 0; color: #9eaaa0; font-size: .64rem; line-height: 1.4; }
.install-clock-button { grid-column: 1 / -1; min-height: 43px; color: #141913; border: 0; border-radius: 10px; background: #9fc891; font-size: .75rem; font-weight: 850; cursor: pointer; }
.install-clock-button:hover { background: #b1d5a5; }
.install-clock-button:disabled { opacity: .58; cursor: default; }
.clock-install-card > small { grid-column: 1 / -1; color: #819085; font-size: .59rem; line-height: 1.4; }

.sync-lobby { position: fixed; z-index: 120; inset: 0; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); overflow: auto; color: var(--ink); background: rgba(4,7,5,.9); }
.sync-lobby-card { width: min(820px, 100%); margin: 0 auto; padding: clamp(17px, 3.5vw, 30px); display: grid; gap: 18px; border: 1px solid rgba(224,201,120,.35); border-radius: 20px; background: #111713; box-shadow: 0 24px 80px rgba(0,0,0,.58); }
.sync-lobby-card > header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.sync-lobby-card > header > div { display: grid; gap: 4px; }
.sync-lobby-card > header span { color: #dbc878; font-size: .64rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.sync-lobby-card h2 { margin: 0; font: 800 clamp(1.4rem, 4vw, 2.1rem)/1.05 Georgia, serif; }
#sync-cancel { width: 44px; height: 44px; flex: 0 0 auto; color: #dce5da; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; background: #1a221c; font-size: 1.5rem; cursor: pointer; }
.sync-room-status { padding: 14px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; border: 1px solid var(--line); border-radius: 13px; background: #0d130f; }
.sync-room-status span { color: #b7c2b7; font-size: .7rem; font-weight: 750; }
.sync-room-status strong { grid-row: 1 / 3; grid-column: 2; color: #f0d985; font: 900 clamp(1.55rem, 5vw, 2.3rem)/1 ui-monospace, monospace; letter-spacing: .11em; }
.sync-room-status small { color: #849087; font-size: .65rem; }
.sync-share { display: grid; grid-template-columns: minmax(210px, .65fr) minmax(260px, 1.35fr); align-items: center; gap: clamp(16px, 4vw, 32px); }
.sync-qr { width: min(250px, 100%); margin: 0 auto; padding: 10px; border-radius: 14px; background: white; aspect-ratio: 1; }
.sync-qr svg { width: 100%; height: 100%; display: block; }
.sync-share-copy { display: grid; gap: 10px; }
.sync-share-copy > strong { font: 800 1.15rem/1 Georgia, serif; }
.sync-share-copy p { margin: 0; color: #a8b4a9; font-size: .74rem; line-height: 1.55; }
.sync-share-copy output { padding: 10px 12px; overflow-wrap: anywhere; color: #aeb9ae; border: 1px solid var(--line); border-radius: 9px; background: #0b100d; font: 650 .63rem/1.45 ui-monospace, monospace; }
.sync-share-copy > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sync-player-presence { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.sync-player-presence span { min-height: 48px; padding: 10px 13px; display: flex; align-items: center; gap: 9px; color: #9aa69d; border: 1px solid var(--line); border-radius: 11px; background: #111813; font-size: .7rem; font-weight: 800; }
.sync-player-presence i { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: #6f7971; box-shadow: 0 0 0 3px rgba(111,121,113,.13); }
.sync-player-presence span.is-connected { color: #c9e4c2; border-color: rgba(121,179,104,.38); }
.sync-player-presence span.is-connected i { background: #7fc16d; box-shadow: 0 0 0 3px rgba(127,193,109,.16); }
.sync-start { min-height: 66px; }
.sync-start:disabled { opacity: .48; cursor: wait; transform: none; }
.sync-accuracy-note { margin: -5px 0 0; color: #7f8b82; text-align: center; font-size: .65rem; line-height: 1.45; }
.clock-health #sync-game-status.is-warning { color: #ffd287; }

/* Full-height over-the-board clock */
.game-view { position: fixed; inset: 0; z-index: 50; height: 100vh; height: 100dvh; display: grid; grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr); overflow: hidden; background: #0b0f0c; user-select: none; }
.player-clock { position: relative; min-width: 0; min-height: 0; width: 100%; padding: 14px max(14px, env(safe-area-inset-right)) 14px max(14px, env(safe-area-inset-left)); border: 0; overflow: hidden; cursor: pointer; touch-action: manipulation; transition: filter .12s ease, box-shadow .12s ease; }
.player-clock--top { padding-top: max(14px, env(safe-area-inset-top)); }
.player-clock--bottom { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.player-clock[data-color="white"] { color: #151a15; background: #e8dfcb; }
.player-clock[data-color="black"] { color: #f1ead9; background: #243128; }
.player-clock:not(.is-active):not(.is-timeout) { filter: saturate(.72) brightness(.82); }
.player-clock.is-active { z-index: 1; box-shadow: inset 0 0 0 clamp(5px, 1.3vmin, 12px) #9bc783; }
.player-clock.is-pressed { filter: brightness(1.12); }
.player-clock.is-rejected { animation: rejectedTap .24s ease-out; }
.player-clock.is-low .time-display { color: #d13b35; }
.player-clock.is-timeout { color: white; background: #a82e2b; animation: timeoutPulse .85s ease-in-out 3; }
.player-clock.is-winner { color: #10200e; background: #9bc783; }
.player-clock.is-loser { filter: saturate(.55) brightness(.68); }
.clock-face { height: 100%; display: grid; grid-template-rows: auto 1fr auto; align-items: center; justify-items: center; gap: 4px; }
.player-clock--top .clock-face { transform: rotate(180deg); }
.is-remote-clock .player-clock--top .clock-face { transform: none; }
.player-label { display: inline-flex; align-items: center; gap: 8px; font-size: clamp(.75rem, 2.4vmin, 1.05rem); letter-spacing: .08em; text-transform: uppercase; }
.player-label i { width: .72em; height: .72em; border: 2px solid currentColor; border-radius: 50%; background: currentColor; }
.time-display { align-self: center; font: 800 clamp(4.2rem, 20vmin, 11rem)/.9 "Arial Narrow", "Roboto Condensed", sans-serif; font-variant-numeric: tabular-nums; letter-spacing: -.055em; white-space: nowrap; }
.player-meta { width: min(520px, 88%); display: flex; justify-content: space-between; gap: 12px; font-size: clamp(.68rem, 2vmin, .9rem); font-weight: 750; opacity: .68; }

.clock-controls { position: relative; z-index: 5; min-height: 72px; padding: 7px max(8px, env(safe-area-inset-right)) 7px max(8px, env(safe-area-inset-left)); display: grid; grid-template-columns: auto auto minmax(145px, auto) auto minmax(92px, 1fr) auto; align-items: center; gap: 6px; border-top: 1px solid rgba(255,255,255,.1); border-bottom: 1px solid rgba(255,255,255,.1); background: #0b0f0c; }
.control-button, .main-control { min-height: 48px; color: #dce4da; border: 1px solid rgba(255,255,255,.13); border-radius: 10px; background: #171e18; cursor: pointer; touch-action: manipulation; }
.control-button { min-width: 62px; padding: 5px 8px; display: grid; place-content: center; gap: 2px; }
.control-button:disabled { opacity: .38; cursor: not-allowed; filter: saturate(.3); }
.control-button span { font-size: 1.1rem; }
.control-button small { font-size: .58rem; }
.main-control { min-width: 145px; min-height: 58px; padding: 7px 18px; display: flex; align-items: center; justify-content: center; gap: 10px; color: #121710; border-color: #e0c978; background: #e0c978; box-shadow: 0 4px 16px rgba(224,201,120,.18); font-size: .94rem; }
.main-control span { font-size: 1.18rem; }
.game-status { min-width: 0; padding: 0 5px; display: grid; justify-items: center; gap: 1px; text-align: center; }
.game-status strong, .game-status small { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.game-status strong { font: 800 .85rem/1 Georgia, serif; }
.game-status small { color: #8f9c91; font-size: .58rem; }
.clock-health { max-width: 100%; display: flex; justify-content: center; flex-wrap: wrap; gap: 3px; }
.clock-health i { max-width: 100%; padding: 2px 5px; overflow: hidden; color: #94a198; border-radius: 999px; background: rgba(255,255,255,.055); font: 700 .48rem/1.15 system-ui, sans-serif; font-style: normal; white-space: nowrap; text-overflow: ellipsis; }
.clock-health i.is-ok { color: #a9d79b; background: rgba(120,178,104,.13); }
.clock-health i.is-warning { color: #ffd287; background: rgba(209,139,50,.16); }
.clock-notice { position: absolute; z-index: 20; left: 50%; top: 50%; width: min(520px, calc(100% - 28px)); padding: 11px 15px; color: #e5ece4; border: 1px solid rgba(255,255,255,.16); border-radius: 12px; background: rgba(18,27,20,.96); box-shadow: 0 14px 42px rgba(0,0,0,.35); transform: translate(-50%, -50%); text-align: center; font-size: clamp(.72rem, 2.4vmin, .88rem); font-weight: 750; pointer-events: none; }
.clock-notice[data-kind="warning"] { color: #ffdfa2; border-color: rgba(224,169,79,.55); background: rgba(54,40,20,.97); }
.clock-notice[data-kind="success"] { color: #c8e9bf; border-color: rgba(142,193,126,.5); }

.arbiter-open, .analysis-open { position: relative; overflow: hidden; border-color: rgba(224,201,120,.38); }
.analysis-open { color: #cbe6c3; border-color: rgba(132,185,116,.42); }
.arbiter-open.is-holding::after { content: ""; position: absolute; inset: auto 0 0; height: 4px; background: #e0c978; transform-origin: left; animation: arbiterHold .85s linear forwards; }
.arbiter-panel { position: fixed; z-index: 80; inset: 0; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); overflow: auto; color: #e6ece4; background: rgba(5,8,6,.88); user-select: text; }
.arbiter-card { width: min(820px, 100%); min-height: min(680px, calc(100dvh - 24px)); margin: 0 auto; padding: clamp(16px, 3vw, 28px); display: grid; align-content: start; gap: 18px; border: 1px solid rgba(224,201,120,.3); border-radius: 18px; background: #111713; box-shadow: 0 22px 70px rgba(0,0,0,.55); }
.arbiter-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.arbiter-header > div { display: grid; gap: 3px; }
.arbiter-header span { color: #d9c77f; font-size: .65rem; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.arbiter-header h2 { margin: 0; font: 800 clamp(1.35rem, 4vw, 2rem)/1 Georgia, serif; }
.arbiter-close { width: 44px; height: 44px; color: #dce5da; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; background: #1a221c; font-size: 1.55rem; cursor: pointer; }
.arbiter-pin-gate { width: min(390px, 100%); margin: clamp(30px, 10vh, 90px) auto 0; display: grid; gap: 14px; text-align: center; }
.arbiter-pin-gate p { margin: 0; color: #a7b2a9; font-size: .78rem; }
.arbiter-pin-gate .arbiter-error { min-height: 1.2em; color: #ffae91; }
.arbiter-tools { display: grid; gap: 16px; }
.arbiter-player-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.arbiter-player { padding: 14px; display: grid; gap: 11px; border: 1px solid rgba(255,255,255,.1); border-radius: 14px; background: #171e18; }
.arbiter-player[data-arbiter-color="white"] { border-color: rgba(232,223,203,.3); }
.arbiter-player[data-arbiter-color="black"] { border-color: rgba(126,164,137,.28); }
.arbiter-player header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.arbiter-player header strong { font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; }
.arbiter-player header output { color: #e4cf83; font: 800 1.65rem/1 "Arial Narrow", sans-serif; font-variant-numeric: tabular-nums; }
.arbiter-time-actions, .arbiter-results > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.arbiter-time-actions button, .arbiter-results button, .arbiter-secondary, .arbiter-primary { min-height: 44px; padding: 9px 12px; color: #e3e9e1; border: 1px solid rgba(255,255,255,.13); border-radius: 10px; background: #202921; font-size: .74rem; font-weight: 850; cursor: pointer; }
.arbiter-time-actions button:hover, .arbiter-results button:hover, .arbiter-secondary:hover { border-color: rgba(224,201,120,.55); }
.arbiter-secondary:disabled { opacity: .4; cursor: not-allowed; }
.arbiter-primary { color: #171a13; border-color: #e0c978; background: #e0c978; }
.arbiter-player .number-field { gap: 5px; font-size: .68rem; }
.arbiter-player .number-field input { min-height: 44px; font-size: .95rem; }
.arbiter-state-grid { display: grid; grid-template-columns: minmax(230px, 1fr) repeat(2, minmax(180px, .8fr)); align-items: end; gap: 10px; }
.arbiter-reason { padding: 14px; display: grid; grid-template-columns: 1fr 1.2fr auto; align-items: end; gap: 10px; border: 1px solid rgba(255,255,255,.09); border-radius: 14px; }
.arbiter-reason .number-field { gap: 5px; font-size: .68rem; }
.arbiter-reason .number-field input, .arbiter-reason .number-field select { min-height: 44px; font-size: .82rem; }
.arbiter-log { grid-column: 1 / -1; display: grid; gap: 4px; color: #9eaaa1; font-size: .68rem; }
.arbiter-log p { margin: 0; }
.arbiter-results { padding: 13px 14px; display: grid; grid-template-columns: auto minmax(300px, 1fr); align-items: center; gap: 16px; border: 1px solid rgba(184,83,70,.25); border-radius: 14px; }
.arbiter-results > span { color: #d5bbb5; font-size: .72rem; font-weight: 800; }
.arbiter-results > div { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.arbiter-results button { color: #f0cdc5; border-color: rgba(184,83,70,.3); background: rgba(113,48,40,.2); }
.arbiter-continue { width: 100%; min-height: 56px; font-size: .9rem; }

.analysis-panel { position: fixed; z-index: 82; inset: 0; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); overflow: auto; color: #e6ece4; background: rgba(5,8,6,.91); user-select: text; }
.analysis-card { width: min(980px, 100%); margin: 0 auto; padding: clamp(16px, 3vw, 28px); display: grid; gap: 18px; border: 1px solid rgba(145,192,129,.3); border-radius: 18px; background: #111713; box-shadow: 0 22px 70px rgba(0,0,0,.58); }
.analysis-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.analysis-header > div { display: grid; gap: 4px; }
.analysis-header span, .analysis-chart-card header span, .analysis-journal-card header span { color: #9dc58f; font-size: .63rem; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.analysis-header h2 { margin: 0; font: 800 clamp(1.4rem, 4vw, 2.15rem)/1 Georgia, serif; }
.analysis-header p { margin: 3px 0 0; color: #aab6ac; font-size: .75rem; }
.analysis-comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.analysis-side { padding: 15px; display: grid; gap: 12px; border: 1px solid rgba(255,255,255,.1); border-radius: 14px; background: #171e18; }
.analysis-side.is-white { border-color: rgba(232,223,203,.32); }
.analysis-side.is-black { border-color: rgba(126,164,137,.3); }
.analysis-side header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.analysis-side header strong { font-size: .84rem; letter-spacing: .07em; text-transform: uppercase; }
.analysis-side header span { color: #e3ce82; font: 800 1.35rem/1 Georgia, serif; }
.analysis-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.analysis-metric { min-width: 0; padding: 9px; display: grid; gap: 4px; border-radius: 9px; background: rgba(255,255,255,.045); }
.analysis-metric small { color: #8f9b91; font-size: .58rem; }
.analysis-metric strong { overflow: hidden; color: #e4eae2; font-size: .8rem; white-space: nowrap; text-overflow: ellipsis; }
.analysis-chart-card, .analysis-journal-card { padding: 15px; display: grid; gap: 13px; border: 1px solid rgba(255,255,255,.09); border-radius: 14px; background: #151c17; }
.analysis-chart-card > header, .analysis-journal-card > header { display: flex; align-items: end; justify-content: space-between; gap: 14px; }
.analysis-chart-card h3, .analysis-journal-card h3 { margin: 2px 0 0; font: 800 1.05rem/1.1 Georgia, serif; }
.analysis-legend { display: flex; align-items: center; gap: 6px; color: #97a39a; font-size: .62rem; }
.analysis-legend i { width: 18px; height: 3px; border-radius: 99px; }
.analysis-legend i.is-white { background: #e8dfcb; }
.analysis-legend i.is-black { margin-left: 5px; background: #83b279; }
.analysis-chart { min-height: 230px; overflow: hidden; border-radius: 10px; background: #0c120e; }
.analysis-chart svg { width: 100%; height: 230px; display: block; }
.analysis-chart .grid { stroke: rgba(255,255,255,.09); stroke-width: 1; }
.analysis-chart .axis-label { fill: #7f8b82; font: 10px system-ui, sans-serif; }
.analysis-chart .white-line { fill: none; stroke: #e8dfcb; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.analysis-chart .black-line { fill: none; stroke: #83b279; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.analysis-chart .point-white { fill: #e8dfcb; }
.analysis-chart .point-black { fill: #83b279; }
.analysis-empty { min-height: 180px; display: grid; place-items: center; color: #849086; text-align: center; font-size: .74rem; }
.analysis-journal-card > header small { color: #879289; font-size: .62rem; text-align: right; }
.analysis-table-scroll { overflow-x: auto; }
.analysis-table { width: 100%; border-collapse: collapse; font-size: .7rem; font-variant-numeric: tabular-nums; }
.analysis-table th, .analysis-table td { padding: 9px 8px; border-bottom: 1px solid rgba(255,255,255,.07); text-align: left; white-space: nowrap; }
.analysis-table th { color: #859087; font-size: .58rem; letter-spacing: .05em; text-transform: uppercase; }
.analysis-table td { color: #d6ded5; }
.analysis-table td:nth-child(2) { font-weight: 800; }
.analysis-table tr:last-child td { border-bottom: 0; }
.analysis-export { padding: 14px; display: grid; grid-template-columns: minmax(220px, 1fr) auto auto; align-items: center; gap: 9px; border: 1px solid rgba(224,201,120,.17); border-radius: 13px; }
.analysis-export > div { display: grid; gap: 3px; }
.analysis-export strong { font-size: .78rem; }
.analysis-export small { color: #8d998f; font-size: .62rem; }

@keyframes timeoutPulse { 50% { filter: brightness(1.35); } }
@keyframes rejectedTap { 35% { filter: brightness(1.24); transform: translateX(-4px); } 70% { transform: translateX(4px); } }
@keyframes arbiterHold { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (max-width: 700px) {
    .setup-intro { margin-top: 34px; }
    #clock-tool .setup-intro { margin-top: 28px; }
    .tournament-intro { margin-top: 24px; padding: 24px 20px; }
    .tournament-intro::after { right: -10px; }
    .tournament-feature-list { gap: 5px; }
    .tournament-feature-list span { padding: 6px 8px; font-size: .61rem; }
    .preset-groups { grid-template-columns: 1fr; gap: 17px; }
    .quick-launch-panel { grid-template-columns: 1fr; }
    .quick-tune-link { text-align: center; }
    .preset-group--tournament { grid-column: auto; }
    .tournament-preset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mode-picker { grid-template-columns: 1fr; }
    .mode-picker span { min-height: 60px; }
    .table-settings, .switches { grid-template-columns: 1fr; }
    .feedback-tuning { grid-template-columns: 1fr; }
    .warning-signals small { width: 100%; margin-left: 0; }
    .arbiter-access-settings { grid-template-columns: 1fr; align-items: stretch; }
    .chess960-main-grid { grid-template-columns: 1fr; }
    .chess960-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stage-row { grid-template-columns: 32px repeat(3, minmax(0, 1fr)) auto; gap: 6px; padding: 9px; }
    .stage-row .number-field span { font-size: .62rem; }
    .swiss-grid, .swiss-form-grid { grid-template-columns: 1fr; }
    .swiss-setup-footer { grid-template-columns: 1fr; }
    .swiss-create { width: 100%; }
    .tournament-page-tool { padding-bottom: 18px; }
    .tournament-page .tournament-intro { margin-top: 18px; padding: 20px 18px; }
    .tournament-page .tournament-intro h1 { font-size: clamp(2rem, 11vw, 3.15rem); }
    .tournament-page.has-active-tournament .tournament-intro,
    .tournament-page:has(#swiss-workspace:not([hidden])) .tournament-intro { margin-top: 8px; padding: 12px 14px; }
    .tournament-library__header { flex-direction: column; gap: 15px; }
    .tournament-library__actions { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tournament-library__actions .secondary-button { width: 100%; }
    .tournament-library__grid { grid-template-columns: 1fr; }
    .tournament-toolbar { position: relative; top: auto; padding: 10px; align-items: stretch; flex-direction: column; }
    .tournament-toolbar__actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .tournament-toolbar__button { padding-inline: 7px; }
    .tournament-tiebreak-order { grid-template-columns: 1fr; }
    .tournament-tiebreak-footer { align-items: stretch; flex-direction: column; }
    .tournament-tiebreak-footer .secondary-button { width: 100%; }
    .tournament-audit-protocol > header { align-items: stretch; flex-direction: column; }
    .tournament-audit-protocol > header > div:last-child { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
    .tournament-audit-protocol select { width: 100%; }
    .tournament-dialog { width: min(620px, calc(100% - 16px)); max-height: calc(100dvh - 16px); border-radius: 15px; }
    .tournament-pairing-dialog { width: 100%; max-height: 85dvh; margin: auto 0 0; border-width: 1px 0 0; border-radius: 18px 18px 0 0; }
    .tournament-pairing-dialog > form, .tournament-pairing-dialog > .tournament-dialog__panel { padding-bottom: max(17px, env(safe-area-inset-bottom)); }
    .tournament-pairing-dialog menu { position: sticky; bottom: 0; padding-top: 8px; background: linear-gradient(180deg, rgba(17,23,19,0), #111713 22%); }
    .tournament-mobile-tabs {
        position: sticky;
        z-index: 24;
        top: 0;
        padding: 5px;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 3px;
        border: 1px solid rgba(255,255,255,.13);
        border-radius: 12px;
        background: rgba(11,16,13,.96);
        box-shadow: 0 9px 24px rgba(0,0,0,.25);
        backdrop-filter: blur(14px);
    }
    .tournament-mobile-tabs button { min-width: 0; min-height: 44px; padding: 6px 3px; color: #9ca8a0; border: 0; border-radius: 8px; background: transparent; font-size: .62rem; font-weight: 820; cursor: pointer; }
    .tournament-mobile-tabs button.is-active,
    .tournament-mobile-tabs button[aria-pressed="true"] { color: #151910; background: #dfca87; }
    .tournament-page [data-tournament-panel] { display: none; }
    .tournament-page [data-tournament-panel].is-active,
    .tournament-page [data-tournament-panel].is-mobile-active { display: block; }
    .tournament-page [data-tournament-panel][hidden] { display: none; }
    .tournament-pairing-tools { grid-template-columns: 1fr; }
    .tournament-pairing-edit-grid { grid-template-columns: 1fr; }
    .pairing-explain-button, .pairing-board-move { min-height: 44px; }
    .pairing-board-move { width: 44px; }
    .tournament-pairing-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .tournament-pairing-filters button { min-height: 44px; padding-inline: 5px; }
    .tournament-secondary-grid { display: contents; }
    .tournament-page .next-round { display: none; }
    .tournament-mobile-action {
        position: sticky;
        z-index: 26;
        bottom: max(6px, env(safe-area-inset-bottom));
        margin-top: 3px;
        padding: 8px 8px 8px 12px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 9px;
        border: 1px solid rgba(224,201,120,.38);
        border-radius: 13px;
        background: rgba(12,18,14,.97);
        box-shadow: 0 13px 36px rgba(0,0,0,.42);
        backdrop-filter: blur(16px);
    }
    .tournament-mobile-action > div { min-width: 0; display: grid; gap: 2px; }
    .tournament-mobile-action span { color: #98a59b; font-size: .58rem; }
    .tournament-mobile-action strong { overflow: hidden; font-size: .69rem; white-space: nowrap; text-overflow: ellipsis; }
    .tournament-mobile-action button { min-height: 48px; padding: 8px 12px; flex: 0 0 auto; color: #151910; border: 0; border-radius: 9px; background: #dfca87; font-size: .67rem; font-weight: 900; cursor: pointer; }
    .tournament-mobile-action button:disabled { color: #7e887f; background: #252e27; cursor: not-allowed; }
    #tournament-pairings-panel, #tournament-standings-panel, #tournament-players-panel, #tournament-history-panel { scroll-margin-top: 64px; }
    .clock-controls { grid-template-columns: auto auto minmax(126px, 1fr) auto minmax(68px, .75fr); }
    .game-status { min-width: 62px; padding: 0 2px; }
    #fullscreen-game { display: none; }
    .arbiter-state-grid { grid-template-columns: 1fr 1fr; }
    .arbiter-state-grid .compact-picker { grid-column: 1 / -1; }
    .arbiter-reason { grid-template-columns: 1fr 1fr; }
    .arbiter-reason .arbiter-secondary { grid-column: 1 / -1; }
    .arbiter-results { grid-template-columns: 1fr; }
    .analysis-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .clock-launch-options { grid-template-columns: 1fr; }
    .clock-launch-options .start-button { min-height: 72px; }
    .sync-join-card { grid-template-columns: 1fr auto; }
    .sync-join-card > div { grid-column: 1 / -1; }
    .sync-join-card > p { grid-column: 1 / -1; }
    .sync-share { grid-template-columns: 1fr; }
    .sync-qr { width: min(230px, 76vw); }
    .clock-portability { grid-template-columns: 1fr; }
}

@media (max-width: 430px) {
    .preset-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .quick-launch-panel { padding: 12px; border-radius: 15px; }
    .quick-start-button { width: 100%; }
    .favorite-controls > header { align-items: stretch; flex-direction: column; }
    .favorite-control-toggle { width: 100%; }
    .settings-section { padding: 18px 14px; border-radius: 17px; }
    .number-settings { grid-template-columns: 1fr; }
    .stage-builder-heading { align-items: flex-start; flex-direction: column; }
    .stage-builder-heading .secondary-button { width: 100%; }
    .stage-row { grid-template-columns: 30px repeat(2, minmax(0, 1fr)) auto; }
    .stage-row .number-field:nth-of-type(3) { grid-column: 2 / 4; }
    .stage-number { width: 30px; height: 30px; }
    .asymmetric-settings { grid-template-columns: 1fr; }
    .tool-tabs { grid-template-columns: .72fr 1.28fr; }
    .tool-tab { padding: 8px 6px; font-size: .69rem; }
    .variant-picker { grid-template-columns: 1fr; }
    .position-controls { grid-template-columns: 1fr auto auto; }
    .position-number-field { grid-column: 1 / -1; }
    .random-position { min-width: 110px; }
    .position-board { border-width: 3px; }
    .chess960-details, .position-code-grid, .position-library { grid-template-columns: 1fr; }
    .position-heading { align-items: flex-start; }
    .favorite-position { min-width: 44px; }
    .position-library header { align-items: flex-start; flex-direction: column; }
    .tournament-header { align-items: flex-start; flex-direction: column; }
    .tournament-header .secondary-button { width: 100%; }
    .tournament-page .setup-view { padding-right: max(11px, env(safe-area-inset-right)); padding-left: max(11px, env(safe-area-inset-left)); }
    .tournament-library__actions { grid-template-columns: 1fr; }
    .tournament-library-card > .tournament-library-card__actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tournament-card-button { min-height: 42px; }
    .tournament-toolbar__actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tournament-toolbar__button--danger { grid-column: 1 / -1; }
    .tournament-tiebreak-presets { grid-template-columns: 1fr; }
    .tournament-tiebreak-settings > summary { align-items: flex-start; flex-direction: column; gap: 3px; }
    .tournament-state-line { align-items: flex-start; flex-direction: column; }
    .tournament-special-results { grid-template-columns: 1fr; }
    .tournament-dialog > form { padding: 17px 13px; }
    .tournament-dialog__panel { padding: 17px 13px; }
    .tournament-dialog menu { grid-template-columns: 1fr; }
    .tournament-requested-bye { grid-template-columns: 1fr; }
    .tournament-protocol-item { grid-template-columns: auto minmax(0, 1fr); }
    .tournament-protocol-item span { grid-column: 2; }
    .tournament-mobile-tabs button { font-size: .58rem; }
    .tournament-page .round-panel { padding-right: 11px; padding-left: 11px; }
    .tournament-page .pairing-card { grid-template-columns: 32px minmax(0, 1fr); padding: 10px 9px; }
    .tournament-page .pairing-player { font-size: .75rem; }
    .tournament-page .result-button { min-height: 48px; }
    .tournament-correction-note { align-items: stretch; flex-direction: column; }
    .tournament-correction-note .secondary-button { width: 100%; }
    .tournament-participant-row { grid-template-columns: 28px minmax(0, 1fr); }
    .tournament-participant__status { grid-column: 2; width: 100%; }
    .tournament-participant-round-action { grid-column: 2; width: 100%; }
    .tournament-mobile-action button { padding-inline: 10px; }
    .clock-controls { min-height: 68px; padding-top: 5px; padding-bottom: 5px; }
    .control-button { min-width: 49px; min-height: 44px; padding: 4px 6px; }
    .control-button small { display: none; }
    .main-control { min-width: 118px; min-height: 56px; padding: 6px 10px; }
    .clock-health i { font-size: .44rem; }
    .arbiter-card { padding: 15px 12px; border-radius: 14px; }
    .arbiter-player-grid { grid-template-columns: 1fr; }
    .arbiter-state-grid, .arbiter-reason { grid-template-columns: 1fr; }
    .arbiter-state-grid .compact-picker, .arbiter-reason .arbiter-secondary { grid-column: auto; }
    .arbiter-results > div { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .analysis-card { padding: 15px 12px; border-radius: 14px; }
    .analysis-comparison { grid-template-columns: 1fr; }
    .analysis-chart-card > header, .analysis-journal-card > header { align-items: flex-start; flex-direction: column; }
    .analysis-journal-card > header small { text-align: left; }
    .analysis-export { grid-template-columns: 1fr 1fr; }
    .analysis-export > div { grid-column: 1 / -1; }
    .sync-lobby-card { padding: 16px 13px; border-radius: 15px; }
    .sync-room-status { grid-template-columns: 1fr; text-align: center; }
    .sync-room-status strong { grid-row: auto; grid-column: auto; order: -1; }
    .sync-player-presence { grid-template-columns: 1fr; }
    .sync-share-copy > div { grid-template-columns: 1fr; }
    .clock-settings-share-body { grid-template-columns: 1fr; }
    .clock-settings-qr { width: min(180px, 58vw); height: auto; margin: 0 auto; aspect-ratio: 1; }
    .clock-settings-link-panel > div { grid-template-columns: 1fr; }
}

/* Mobile working layout: readable controls, safe areas and local overflow. */
@media (max-width: 700px) {
    .setup-view {
        width: 100%;
        min-width: 0;
        padding-right: max(12px, env(safe-area-inset-right));
        padding-bottom: max(40px, calc(env(safe-area-inset-bottom) + 24px));
        padding-left: max(12px, env(safe-area-inset-left));
    }
    .setup-header { min-height: 60px; gap: 10px; }
    .back-link { min-height: 44px; display: inline-flex; align-items: center; font-size: .875rem; }
    .public-badge { padding: 7px 9px; font-size: .75rem; text-align: center; }
    .tool-tabs { margin-top: 12px; }
    .tool-tab { min-height: 48px; font-size: .8125rem; line-height: 1.25; }
    .setup-intro { min-width: 0; margin: 28px auto 20px; }
    #clock-tool .setup-intro { margin-top: 24px; }
    .setup-intro h1 { overflow-wrap: anywhere; font-size: clamp(2.2rem, 12vw, 3.7rem); }
    #clock-tool .setup-intro h1 { font-size: clamp(2.15rem, 11vw, 3.45rem); }
    .setup-intro > p:last-child { margin-top: 12px; line-height: 1.45; }

    .clock-settings,
    .settings-section,
    .quick-launch-panel,
    .clock-portability,
    .clock-settings-share,
    .clock-install-card,
    .chess960-preview-card,
    .chess960-main-grid,
    .chess960-details,
    .swiss-tool,
    .swiss-setup,
    .swiss-workspace,
    .swiss-grid,
    .tournament-secondary-grid,
    [data-tournament-panel] { min-width: 0; max-width: 100%; }
    .settings-section { padding: 20px 16px; border-radius: 18px; }
    .section-heading { min-width: 0; margin-bottom: 18px; gap: 10px; }
    .section-heading > div { min-width: 0; }
    .section-heading h2 { overflow-wrap: anywhere; }

    #clock-app button:not(.player-clock),
    body.tournament-page button { min-height: 44px; font-size: .8125rem; }
    #clock-app small,
    body.tournament-page small { font-size: .75rem; line-height: 1.4; }
    #clock-app input,
    #clock-app select,
    #clock-app textarea,
    body.tournament-page input,
    body.tournament-page select,
    body.tournament-page textarea { font-size: 1rem; }
    .number-field,
    .text-field,
    fieldset legend { font-size: .875rem; line-height: 1.35; }
    .field-hint,
    .mode-note,
    .setup-tip { font-size: .75rem; }
    .secondary-button { min-height: 44px; padding: 9px 12px; font-size: .8125rem; }

    .quick-launch-copy > span,
    .preset-group h3,
    .clock-settings-share > header span,
    .clock-install-card > div:nth-child(2) > span { font-size: .75rem; }
    .quick-launch-copy strong { font-size: .9375rem; }
    .quick-start-button { min-height: 68px; }
    .quick-start-button small,
    .preset span,
    .favorite-controls > header small,
    .favorite-control-launch small,
    .favorite-control-empty,
    .mode-picker small,
    .switch-row small,
    .feedback-settings > header small,
    .arbiter-access-settings > div small,
    .variant-picker small,
    .position-heading span,
    .position-heading small,
    .castling-card p,
    .castling-destinations,
    .position-link,
    .position-fen,
    .position-library header small,
    .position-chip-empty,
    .clock-settings-link-panel p,
    .clock-settings-link,
    .clock-install-card p,
    .clock-install-card > small,
    .sync-room-status small,
    .sync-share-copy p,
    .sync-share-copy output,
    .sync-accuracy-note { font-size: .75rem; }
    .quick-tune-link,
    .favorite-control-toggle,
    .favorite-control-launch strong,
    .mode-picker strong,
    .switch-row strong,
    .feedback-settings > header strong,
    .arbiter-access-settings > div strong,
    .variant-picker strong,
    .position-heading strong,
    .castling-heading strong,
    .position-share-card > div:first-child strong,
    .position-library header strong,
    .clock-settings-share > header strong,
    .clock-install-card > div:nth-child(2) > strong,
    .sync-join-card strong,
    .sync-share-copy > strong { font-size: .875rem; }
    .quick-tune-link { min-height: 44px; display: grid; place-items: center; }
    .favorite-control-toggle { min-height: 44px; }
    .favorite-control-item { grid-template-columns: auto 44px; }
    .favorite-control-launch { min-height: 44px; }
    .favorite-control-remove { width: 44px; min-height: 44px; }
    .favorite-control-empty { min-height: 44px; display: flex; align-items: center; }
    .mode-picker span,
    .variant-picker span { min-height: 68px; }
    .feedback-tuning .number-field select { min-height: 48px; font-size: 1rem; }
    .sound-preview-actions .secondary-button { min-height: 44px; }
    .warning-signals > span,
    .warning-signals small { font-size: .75rem; }
    .warning-signals strong { font-size: .875rem; }
    .volume-field,
    .sound-preview-actions { font-size: .75rem; }
    .volume-field input { min-height: 44px; }
    .arbiter-protection-picker legend { font-size: .75rem; }
    .stage-row { min-width: 0; }
    .stage-row .number-field span { font-size: .75rem; overflow-wrap: anywhere; }
    .stage-row .number-field input { min-width: 0; padding-inline: 8px; }
    .remove-stage { width: 44px; min-width: 44px; }
    .position-controls > *,
    .position-share-actions > *,
    .clock-settings-link-panel > div > *,
    .sync-share-copy > div > * { min-width: 0; }
    .fen-copy,
    .favorite-position,
    .castling-picker button,
    .position-chip,
    .install-clock-button { min-height: 44px; font-size: .75rem; }
    .position-share-actions .fen-copy,
    .clock-settings-link-panel .secondary-button { font-size: .75rem; white-space: normal; }
    .position-chip { padding-inline: 11px; }
    .castling-heading span,
    .position-share-card > div:first-child span,
    .position-code-grid section > div span { font-size: .75rem; }
    .position-notation,
    .castling-legend { font-size: .75rem; }
    .sync-join-card input,
    .sync-join-card .secondary-button { min-height: 48px; }
    .sync-join-card > p { font-size: .75rem; }
    .sync-player-presence span { min-height: 48px; font-size: .8125rem; }

    /* The central clock bar stays operable at 360 px even when arbiter tools appear. */
    .clock-controls {
        min-height: 0;
        padding: 6px max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
        grid-template-columns: 44px 44px minmax(112px, 1fr) 44px 44px;
        grid-template-rows: auto auto;
        gap: 4px;
    }
    .control-button { width: 100%; min-width: 0; min-height: 48px; padding: 4px; }
    .control-button small { display: none; }
    .control-button span { font-size: 1.2rem; }
    .main-control { width: 100%; min-width: 0; min-height: 52px; padding: 6px 10px; }
    .game-status { grid-column: 1 / -1; min-width: 0; min-height: 32px; padding: 2px 4px; }
    .game-status strong { font-size: .875rem; }
    .game-status small,
    .clock-health i { font-size: .75rem; }
    .clock-health i { padding: 3px 6px; }
    #fullscreen-game { display: none; }
    .player-label,
    .player-meta { font-size: clamp(.75rem, 3.2vmin, .95rem); }
    .time-display { font-size: clamp(4rem, 22vmin, 8.5rem); }
    .clock-notice { font-size: .8125rem; }
    .arbiter-panel,
    .analysis-panel,
    .sync-lobby { overscroll-behavior: contain; }
    .arbiter-card { min-height: 0; }
    .arbiter-header span,
    .analysis-header span,
    .analysis-chart-card header span,
    .analysis-journal-card header span { font-size: .75rem; }
    .arbiter-player .number-field,
    .arbiter-reason .number-field,
    .arbiter-log,
    .arbiter-results > span,
    .analysis-header p,
    .analysis-metric small,
    .analysis-legend,
    .analysis-journal-card > header small,
    .analysis-export small { font-size: .75rem; }
    .arbiter-time-actions button,
    .arbiter-results button,
    .arbiter-secondary,
    .arbiter-primary { font-size: .8125rem; }
    .analysis-table { min-width: 560px; font-size: .75rem; }
    .analysis-table th { font-size: .75rem; }
    .analysis-table-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch; }

    /* Tournament console keeps its navigation fixed while data tables scroll locally. */
    body.tournament-page p,
    body.tournament-page li,
    body.tournament-page dd,
    body.tournament-page dt { font-size: .75rem; }
    .tournament-page .tournament-intro { padding: 18px 16px; }
    .tournament-page .tournament-intro h1 { overflow-wrap: anywhere; }
    body.tournament-page .eyebrow { font-size: .75rem; }
    body.tournament-page.has-active-tournament .tournament-intro .eyebrow,
    body.tournament-page:has(#swiss-workspace:not([hidden])) .tournament-intro .eyebrow { font-size: .75rem; }
    .tournament-feature-list span { font-size: .75rem; }
    .tournament-library__header p:last-child,
    .tournament-library-card p,
    .tournament-empty-state,
    .tournament-save-state,
    .tournament-pairing-diagnostics > summary strong,
    .tournament-pairing-health,
    .tournament-pairing-diagnostics__stats span,
    .tournament-pairing-diagnostics__list,
    .tournament-float-history > header strong,
    .tournament-float-history > header span,
    .tournament-scoregroups span,
    .tournament-float-history li,
    .tournament-result-progress > div,
    .pairing-diagnostic-badge,
    .tournament-correction-note p,
    .tournament-secondary-grid .section-heading > span,
    .tournament-participant-row,
    .tournament-history-item,
    .tournament-audit-protocol > header span,
    .tournament-protocol-item,
    .tournament-dialog > form > p:not(.form-error),
    .tournament-dialog__panel > p,
    .tournament-pairing-edit-preview,
    .tournament-explanation-block strong,
    .tournament-explanation-block p,
    .tournament-pairing-explanation-issues,
    .tournament-pairing-publish-warnings,
    .tournament-player-skip strong,
    .tournament-organizer-bye strong,
    .tournament-player-skip small,
    .tournament-organizer-bye small { font-size: .75rem; }
    .tournament-library-card h3,
    .tournament-library__group h3,
    .tournament-audit-protocol h3 { font-size: .875rem; }
    .tournament-library-card__status,
    .tournament-publication-status,
    .tournament-standings-state { font-size: .75rem; }
    .tournament-library__group > header span { font-size: .75rem; }
    .tournament-card-button,
    .tournament-toolbar__button,
    .tournament-round-tabs button,
    .tournament-pairing-filters button,
    .pairing-explain-button,
    .pairing-board-move,
    .special-result-trigger,
    .tournament-participant__status,
    .tournament-participant-round-action,
    .tournament-audit-protocol select,
    .tournament-requested-bye span,
    .tournament-dialog menu .secondary-button,
    .tournament-dialog menu .start-button { min-height: 44px; font-size: .75rem; }
    .tournament-card-button { min-height: 44px; }
    .tournament-library-card > .tournament-library-card__actions { gap: 7px; }
    .tournament-toolbar__actions { gap: 7px; }
    .tournament-toolbar__button { min-width: 0; padding: 8px; overflow-wrap: anywhere; line-height: 1.2; }
    .tournament-mobile-tabs {
        top: max(0px, env(safe-area-inset-top));
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    .tournament-mobile-tabs button { min-height: 48px; font-size: .75rem; line-height: 1.15; }
    .tournament-mobile-alert-count { font-size: .75rem; }
    .tournament-round-tabs { max-width: 100%; overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch; }
    .tournament-round-tabs button { min-width: 72px; }
    .tournament-pairing-search input { min-height: 48px; font-size: 1rem; }
    .tournament-page .pairing-player,
    .tournament-page .result-button { font-size: .8125rem; }
    .round-heading > span,
    .board-number { font-size: .75rem; }
    .tournament-pairing-diagnostics__body > .secondary-button { min-height: 44px; }
    .pairing-board-move { width: 44px; }
    .tournament-participant__seed { width: 32px; height: 32px; font-size: .75rem; }
    .tournament-participant__status,
    .tournament-participant-round-action { min-height: 44px; }
    .tournament-audit-protocol select { min-height: 48px; font-size: 1rem; }

    .tournament-tiebreak-settings > summary { min-height: 56px; font-size: .875rem; }
    .tournament-tiebreak-settings > summary strong,
    .tournament-tiebreak-presets strong,
    .tournament-tiebreak-presets small,
    .tournament-tiebreak-footer p,
    .tournament-tiebreak-legend > summary,
    .tournament-tiebreak-legend dt,
    .tournament-tiebreak-legend dd,
    .tournament-tiebreak-legend > p { font-size: .75rem; }
    .tournament-tiebreak-legend > summary { min-height: 44px; display: flex; align-items: center; }
    .tournament-tiebreak-presets label > span { min-height: 68px; }
    .tournament-tiebreak-order label { grid-template-columns: 38px minmax(0, 1fr); }
    .tournament-tiebreak-order label > span { font-size: .75rem; }
    .tournament-tiebreak-order select { min-height: 50px; padding: 8px 10px; font-size: 1rem; }

    .standings-panel .section-heading { align-items: stretch; flex-direction: column; }
    .tournament-standings-actions { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; justify-content: stretch; }
    .tournament-standings-actions .secondary-button { min-height: 44px; font-size: .75rem; }
    .tournament-standings-state { min-height: 44px; padding: 7px 10px; place-items: center; text-align: center; }
    .standings-scroll {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    .standings-table { width: max-content; min-width: 100%; font-size: .75rem; }
    .standings-table th,
    .standings-table td { padding: 11px 9px; font-size: .75rem; white-space: nowrap; }
    .standings-table td:nth-child(2) { min-width: 150px; white-space: normal; }

    .tournament-mobile-action {
        bottom: max(6px, env(safe-area-inset-bottom));
        min-width: 0;
        padding: 9px 9px 9px 12px;
    }
    .tournament-mobile-action span { font-size: .75rem; }
    .tournament-mobile-action strong { font-size: .8125rem; }
    .tournament-mobile-action button { min-height: 50px; font-size: .8125rem; white-space: normal; }

    .tournament-dialog {
        max-width: calc(100% - 16px);
        max-height: calc(100dvh - 16px);
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }
    .tournament-dialog > form,
    .tournament-dialog__panel { min-width: 0; }
    .tournament-dialog menu {
        position: sticky;
        z-index: 2;
        bottom: 0;
        padding-top: 10px;
        padding-bottom: max(2px, env(safe-area-inset-bottom));
        background: linear-gradient(180deg, rgba(17,23,19,0), #111713 22%);
    }
    .tournament-dialog .tournament-dialog__context { overflow-wrap: anywhere; font-size: .8125rem; }
    .tournament-special-results strong { font-size: .8125rem; }
    .tournament-special-results small { font-size: .75rem; }
}

@media (max-height: 540px) {
    .clock-controls { min-height: 56px; }
    .control-button { min-height: 40px; }
    .main-control { min-height: 48px; }
    .game-status { display: none; }
    .clock-controls { grid-template-rows: auto; }
    .player-label, .player-meta { font-size: .6rem; }
    .time-display { font-size: clamp(3rem, 17vmin, 6rem); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Shared wayfinding and concise instructions for the chess workspace. */
.tool-links { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tool-links .tool-tab { min-height: 48px; }
.tool-links .tool-tab.is-active:hover,
.tool-links .tool-tab.is-active:focus-visible { color: #151910; background: #ecd78f; }
.clock-howto {
    width: min(1060px, 100%); margin: 0 auto 22px; padding: 17px 20px;
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 20px;
    border: 1px solid var(--line); border-radius: 16px; background: rgba(24, 32, 26, .58);
}
.clock-howto p { margin: 0; display: flex; align-items: flex-start; gap: 9px; color: #dce4d8; font-size: .8125rem; line-height: 1.5; }
.clock-howto p > span { width: 23px; height: 23px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: #2c3a2c; color: #e0d09b; font-size: .75rem; font-weight: 800; }
.clock-howto > small { grid-column: 1 / -1; padding-top: 10px; border-top: 1px solid var(--line); color: #b9c5b8; font-size: .75rem; line-height: 1.7; }
.clock-howto kbd { padding: 1px 5px; border: 1px solid #62715c; border-radius: 4px; color: #f3eedc; font: inherit; }
.tournament-draft-status { margin: 14px 0 0; color: #bacbb1; font-size: .8125rem; line-height: 1.5; }
#swiss-player-count { line-height: 1.5; }
select:focus-visible, summary:focus-visible { outline: 3px solid #e5ca75; outline-offset: 3px; }
@media (min-width: 701px) {
    .quick-launch-copy > span, .quick-start-button small { font-size: .75rem; }
    .quick-launch-copy small, .quick-tune-link, .preset span { font-size: .75rem; line-height: 1.4; }
}
@media (max-width: 700px) {
    .tool-links .tool-tab { padding: 9px 5px; font-size: .75rem; line-height: 1.3; }
    .clock-howto { grid-template-columns: 1fr; padding: 16px; gap: 10px; }
    .clock-howto > small { line-height: 1.65; }
    .tournament-draft-status { overflow-wrap: anywhere; }
}
