:root { --touch: 3rem; }
body { -webkit-text-size-adjust: 100%; }
.app-nav a.brand { font-size: 1.4rem; }
/* Large touch-friendly controls */
button, [role="button"], input[type="submit"], .btn, select, input:not([type="checkbox"]):not([type="radio"]) {
  min-height: var(--touch);
}
button, [role="button"], .btn { font-size: 1.1rem; padding: .6rem 1.2rem; touch-action: manipulation; }
.btn-lg { min-height: 3.5rem; font-size: 1.25rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.btn-row > * { flex: 1 1 8rem; margin: 0; }
input[type="checkbox"], input[type="radio"] { width: 1.6rem; height: 1.6rem; }
/* Cards / grids */
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 1rem; }
.card { border: 1px solid var(--pico-muted-border-color); border-radius: .75rem; padding: 1rem; margin-bottom: 1rem; }
/* Status colours */
.warn { color: #8a5a00; background: #fff3cd; border-left: .35rem solid #f0ad00; padding: .5rem .75rem; border-radius: .25rem; }
.danger { color: #8b1a1a; background: #fde2e2; border-left: .35rem solid #d33; padding: .5rem .75rem; border-radius: .25rem; }
.ok { color: #1b5e20; }
.muted { color: var(--pico-muted-color); }
.badge { display: inline-block; padding: .1rem .6rem; border-radius: 1rem; font-size: .85rem; background: var(--pico-muted-border-color); }
.table-wrap { overflow-x: auto; }
@media (max-width: 576px) {
  .container { padding-left: .75rem; padding-right: .75rem; }
  h1 { font-size: 1.6rem; }
}
/* Public display uses the full window */
body.display main { max-width: none; width: 100%; padding: 1rem 2vw; font-size: clamp(1.1rem, 2vw, 2.2rem); }

/* ---- Organiser dashboard ---- */
:root { --dk-team-a: #1d4ed8; --dk-team-b: #c2410c; }
.statusline { margin-bottom: .5rem; }
.controls { margin-bottom: 1rem; }
.btn-row > form { display: flex; }
.btn-row > form > button { width: 100%; margin: 0; }
.team { font-weight: 700; }
.team-a { color: var(--dk-team-a); }
.team-b { color: var(--dk-team-b); }
.vs { color: var(--pico-muted-color); font-size: .9em; padding: 0 .25rem; }
.teams { font-size: 1.25rem; margin-bottom: .5rem; }
.timer { font-size: 1.6rem; font-variant-numeric: tabular-nums; font-weight: 700; }
.court-active { border-color: var(--pico-primary); border-width: 2px; }
.reason { font-size: .95rem; color: var(--pico-muted-color); }
.badge-warn { background: #fff3cd; color: #8a5a00; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: .75rem; margin-bottom: .75rem; }
.stats > div { text-align: center; }
.stat-n { display: block; font-size: 2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-l { color: var(--pico-muted-color); font-size: .85rem; }
.upcoming { padding-left: 1.4rem; }
.upcoming li { margin-bottom: .6rem; }
/* player rows: wrap on phones */
.plist { list-style: none; padding: 0; margin: 0 0 1rem; }
.prow { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .9rem; padding: .6rem .25rem; border-bottom: 1px solid var(--pico-muted-border-color); }
.prow .pos { width: 1.6rem; color: var(--pico-muted-color); font-variant-numeric: tabular-nums; }
.prow .pname { flex: 1 1 10rem; }
.prow .pstat { white-space: nowrap; font-variant-numeric: tabular-nums; }
.prow .pbtn { margin: 0; flex: 0 0 auto; min-width: 6rem; }
.plist.compact .prow { padding: .35rem .25rem; }
/* dialogs */
dialog article { position: relative; max-height: 92vh; overflow-y: auto; width: min(100%, 36rem); }
.close-x { position: absolute; top: .4rem; right: .6rem; width: 3rem; min-height: 3rem; padding: 0; background: transparent; color: var(--pico-muted-color); border: 0; font-size: 1.8rem; }
fieldset { margin-bottom: 1rem; }
.choice { display: flex; align-items: center; gap: .6rem; min-height: var(--touch); }
.choice-row .choice { flex: 1 1 8rem; border: 1px solid var(--pico-muted-border-color); border-radius: .5rem; padding: 0 .75rem; }
.choice input[type="number"] { margin: 0; width: 6rem; }
.choice-line { display: flex; gap: .75rem; align-items: center; }
.choice-line .choice { flex: 1; }
.choice-line input[type="number"] { width: 9rem; margin: 0; }
.setup-tools { align-items: center; margin-bottom: .75rem; }
.setup-tools input { flex: 2 1 12rem; margin: 0; }
@media (max-width: 576px) { .prow .pbtn { flex: 1 1 100%; } .teams { font-size: 1.1rem; } }

/* ---- Public display (read-only, fills the window) ---- */
body.display { --pico-color: #e8efec; --pico-muted-color: #a3b2ac; --pico-background-color: #101514; background: #101514; color: #e8efec; margin: 0; overflow: hidden; }
body.display .display-main { width: 100vw; height: 100vh; max-width: none; padding: 0; margin: 0; }
#disp { --a: #7aa2ff; --b: #fb9a62; --dim: #a3b2ac; --line: #2c3a36; box-sizing: border-box; width: 100%; height: 100vh;
  display: flex; flex-direction: column; gap: .6em; padding: .8em 1.2em; font-size: 22px; color: #e8efec; }
#disp h1 { font-size: 1.6em; margin: 0; color: #e8efec; }
#disp h2 { font-size: 1.05em; margin: 0 0 .3em; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
#disp p, #disp ol { margin: 0; }
.d-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 1em; flex: 0 0 auto; }
.d-head p { font-size: 1.2em; }
.d-courts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13em), 1fr)); gap: .6em; flex: 0 0 auto; }
.d-court { border: 2px solid var(--line); border-radius: .6em; padding: .5em .8em; text-align: center; background: #1a2120; }
.d-court.is-active { border-color: #2dd4bf; }
.d-team { font-size: 1.35em; font-weight: 700; line-height: 1.2; }
.d-a { color: var(--a); } .d-b { color: var(--b); }
.d-vs, .d-label { color: var(--dim); font-size: .85em; }
.d-timer { font-size: 1.4em; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: .15em; }
.d-lower { display: grid; grid-template-columns: 1fr 1.4fr; gap: .8em; flex: 1 1 0; min-height: 0; }
.d-box { display: flex; flex-direction: column; min-height: 0; border: 2px solid var(--line); border-radius: .6em; padding: .5em .8em; }
.fit-box { flex: 1 1 0; min-height: 0; overflow-y: auto; scrollbar-width: auto; scrollbar-color: #5b736b #1a2120; }
.fit-box::-webkit-scrollbar { width: 14px; } .fit-box::-webkit-scrollbar-thumb { background: #5b736b; border-radius: 7px; }
.d-upcoming { list-style: none; padding: 0; }
.d-upcoming li { font-size: 1.1em; padding: .25em 0; border-bottom: 1px solid var(--line); }
.d-upcoming em { color: var(--dim); font-style: normal; font-size: .85em; }
.d-qlist { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(14em, 1fr)); gap: .3em .8em; align-content: start; }
.d-qlist li { font-size: 1.1em; display: flex; gap: .4em; align-items: baseline; padding: .15em 0; }
.d-qlist .d-qname { min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-n { color: var(--dim); min-width: 1.4em; font-variant-numeric: tabular-nums; }
.d-dim { color: var(--dim); font-variant-numeric: tabular-nums; margin-left: auto; }
.d-count { background: #2c3a36; border-radius: 1em; padding: 0 .6em; }
.d-break { font-size: .8em; margin-top: .3em; flex: 0 0 auto; }
@media (max-width: 700px) { .d-lower { grid-template-columns: 1fr; } }

/* Player directory search row: filter sits beside search with a gap, stacks on narrow screens */
.search-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; }
.search-row > input[type="search"] { flex: 1 1 16rem; margin-bottom: 0; }
.check-label { display: flex; align-items: flex-start; gap: .6rem; margin: 0; }
.check-label input[type="checkbox"] { margin: .15rem 0 0; flex: none; }
@media (max-width: 600px) { .search-row > input[type="search"], .check-label { flex-basis: 100%; } }

.d-head .d-clock { font-size: 1.6em; font-weight: 700; font-variant-numeric: tabular-nums; margin: 0; }
.d-complete { min-height: 3rem; width: 100%; margin: .4em 0 0; font-size: 1em; }

.d-actions { margin: .4em 0 0; }
.d-actions .d-complete { margin: 0; }
.d-actions [hidden] { display: none !important; }
.d-confirm { display: flex; gap: .4em; }
.d-confirm button { flex: 1 1 0; min-height: 3rem; margin: 0; font-size: 1em; font-weight: 700; }
.d-confirm .d-yes { background: #0F766E; border-color: #0F766E; color: #fff; }
.d-confirm .d-no { background: #3b4541; border-color: #55645E; color: #E8EFEC; }

/* Tab bar */
.tabs { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .5rem 0; border-bottom: 1px solid var(--pico-muted-border-color); }
.tabs .brand { text-decoration: none; margin-right: .5rem; }
.tab-list { display: flex; flex-wrap: wrap; gap: .25rem; list-style: none; margin: 0; padding: 0; flex: 1 1 auto; }
.tab-list li { margin: 0; padding: 0; list-style: none; }
.tab, .tab-list a { display: inline-flex; align-items: center; min-height: var(--touch); padding: 0 1rem; border-radius: 999px; text-decoration: none; color: var(--pico-muted-color); font-weight: 600; }
.tab:hover, .tab-list a:hover { background: var(--pico-muted-border-color); color: var(--pico-color); }
.tab-list a.active { background: #0f766e; color: #fff; }
.logout-form { margin: 0 0 0 auto; }
button.tab.logout { margin: 0; width: auto; min-height: var(--touch); padding: 0 1rem; font-size: 1rem; }
/* Home */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: 1rem; margin-top: 1rem; }
.stat { display: flex; flex-direction: column; margin: 0; border-left: 5px solid #0f766e; }
.stat-num { font-size: 3rem; font-weight: 800; line-height: 1.1; color: #0f766e; }
.stat-label { color: var(--pico-muted-color); }
.live-card { border-left: 5px solid #0f766e; }
.badge-live { background: #d1fae5; color: #065f46; }
.empty-card { text-align: center; padding: 1.5rem 1rem; }
.table-wrap { overflow-x: auto; }
/* Login */
.login-wrap { display: flex; justify-content: center; padding-top: 4rem; }
.login-card { width: 100%; max-width: 24rem; }
