*{box-sizing:border-box}
body{margin:0;font:400 16px/1.5 system-ui,-apple-system,'Segoe UI',Roboto,Arial,sans-serif;min-height:100vh}
button,input,select,textarea{font:inherit}
button{cursor:pointer}
[hidden]{display:none!important}
.matches-header{display:flex;align-items:center;gap:1.2rem;padding:.7rem clamp(1rem,2vw,2rem);background:#8d1730;color:white}
.matches-header .brand{font-size:1.25rem;font-weight:600}
.matches-header a{color:white;text-decoration:none}
.matches-header nav{display:flex;gap:1rem;flex-wrap:wrap}
.matches-header a:hover{text-decoration:underline}
main{width:100%;margin:0;padding:1.5rem clamp(1rem,2vw,2rem) 4rem}
.page-title{display:flex;justify-content:space-between;align-items:end;gap:1rem;flex-wrap:wrap}
h1{font-size:clamp(2rem,4vw,3.5rem);margin:0;font-weight:600}
#status{margin:.35rem 0;color:#586577}
#status:empty{display:none}
#status.error,#dialogStatus.error{color:#a32018}
.org-choices,.tools{display:flex;gap:.5rem;flex-wrap:wrap;margin:.75rem 0}
.resources{display:flex;gap:.5rem 1rem;flex-wrap:wrap;align-items:center;margin:.5rem 0 1rem}
.resource-group{display:flex;gap:.35rem .75rem;flex-wrap:wrap;align-items:center}
.resource-group+.resource-group{border-left:1px solid #d9dee8;padding-left:1rem}
.resource-name{font-weight:600}
.resources a{font-weight:500}
.pill,.button{display:inline-block;border:1px solid #8d1730;background:#fff;color:#8d1730;border-radius:.45rem;padding:.35rem .65rem;text-decoration:none;font-weight:500}
.pill.active,.button.primary{background:#8d1730;color:#fff}
.button.secondary{border-color:#65717d;color:#334252}
.button.danger{border-color:#b82736;color:#a32018}
.button:disabled{opacity:.5;cursor:not-allowed}
.action-bar{display:flex;align-items:center;gap:.5rem 1rem;flex-wrap:wrap;margin:1.25rem 0 .7rem}
.action-bar .tools{margin:0}
.action-bar .tools:empty{display:none}
.filter-bar{display:flex;align-items:center;justify-content:flex-end;gap:.5rem 1rem;flex:1 1 18rem;min-width:min(100%,18rem);flex-wrap:wrap;margin:0}
.list-controls{display:flex;align-items:center;gap:.5rem;flex:1 1 15rem;min-width:min(100%,15rem);max-width:22rem}
.list-controls label{white-space:nowrap}
.list-controls input{min-width:0;flex:1}
.mobile-zone{display:none}
.heading-zone{display:block;width:100%;min-width:0;margin-top:.35rem;padding:.25rem .35rem;font-size:.8rem;font-weight:400}
.heading-filters{display:flex;align-items:center;flex-wrap:wrap;gap:.2rem .35rem;margin-top:.25rem}
.heading-filter{font-size:1rem;line-height:1.5;text-align:left;white-space:normal}
.heading-filter.button:hover{border-color:var(--matches-link,#8d1730);background:var(--matches-soft,#edf0f5);color:var(--matches-link,#8d1730)}
.heading-filter.button:focus-visible{outline:2px solid var(--matches-link,#8d1730);outline-offset:2px}
.heading-filter.button[aria-pressed=true]{border-color:var(--org-color,#8d1730);background:var(--org-color,#8d1730);color:#fff}
#readerHeading .heading-filter{display:block;width:max-content;max-width:100%;margin-top:.25rem}
#adminHeading .stats-button{display:block;margin-top:.25rem}
.zone-popover{position:fixed;inset:auto;width:max-content;max-width:calc(100vw - 16px);margin:0;padding:.5rem .6rem;border:1px solid #d9dee8;border-radius:.6rem;background:#fff;color:#182332;box-shadow:0 12px 36px #0a132155;font-size:.82rem;line-height:1.25;overflow:visible}
.zone-popover .zone-countdown{margin:0 0 .3rem;color:var(--matches-link,#8d1730);font-size:1rem;font-weight:600;font-variant-numeric:tabular-nums}
.zone-popover h3{margin:0 0 .3rem;font-size:.92rem}
.zone-popover table{width:auto;min-width:0;max-width:100%}
.zone-popover td{padding:.08rem .3rem;border:0;vertical-align:middle}
.zone-popover td:last-child{white-space:nowrap}
.zone-popover tr.viewer-zone td{background:var(--matches-soft,#edf0f5);font-weight:600}
.zone-popover tr.viewer-zone td:first-child{box-shadow:inset 3px 0 var(--org-color,var(--matches-link,#8d1730))}
.list-controls input{width:100%}
input,select,textarea{border:1px solid #a2abb7;border-radius:.4rem;padding:.5rem;background:white;color:#182332}
input[type=search]{width:100%}
.table-wrap{width:100%;min-width:0;margin-inline:auto;overflow:visible;border:1px solid #d9dee8;border-radius:.7rem;background:#fff}
table{width:100%;min-width:0;table-layout:auto;border-collapse:separate;border-spacing:0}
th,td{min-width:0;padding:.6rem .45rem;text-align:left;vertical-align:top;border-bottom:1px solid #d9dee8;overflow-wrap:anywhere}
th{position:sticky;top:0;z-index:2;background:#edf0f5}
@media(min-width:1200px){
  .table-wrap{width:fit-content;max-width:100%}
  #matchTable{width:max-content;max-width:100%}
  #matchTable :is(th,td):is(:nth-child(1),:nth-child(2),:nth-child(3),:nth-child(4),:nth-child(5),:nth-child(7),:nth-child(9),:nth-child(10)){width:1%;white-space:nowrap;overflow-wrap:normal}
  #matchTable #startHeading,#matchTable #startHeading .heading-zone{min-width:20ch}
  #matchTable :is(th,td):nth-child(8){white-space:nowrap}
  #matchTable .player-list{display:inline-flex;max-width:min(42rem,45vw)}
}
.sort-button{border:0;background:transparent;color:inherit;padding:0;font-weight:600;text-align:left}
.sort-button:hover{text-decoration:underline}
.sort-button:focus-visible{outline:2px solid currentColor;outline-offset:3px}
.sort-button span{display:inline-block;min-width:1ch}
.start-cell .button.start-soon{background:var(--matches-soon,#fff1bc);color:var(--matches-soon-text,#684900);border-color:var(--matches-soon-text,#684900)}
td{font-variant-numeric:tabular-nums}
td.players{min-width:0}
.player-list{display:flex;align-items:center;flex-wrap:wrap;gap:.2rem clamp(.5rem,1.2vw,1rem);margin:0;padding:0;list-style:none}
.player-list li{display:inline-flex;align-items:baseline;min-width:0;max-width:100%;white-space:normal;overflow-wrap:anywhere}
.player-list li>span:last-child{min-width:0}
.player-flag{display:inline-block;flex:none;min-width:1.55em;margin-right:.15em;font-family:'Noto Color Emoji','Apple Color Emoji','Segoe UI Emoji',sans-serif;font-size:1.05em;vertical-align:-.08em}
.reader-person{display:inline-flex;align-items:baseline;max-width:100%;overflow-wrap:anywhere}
.reader-person>span:last-child{min-width:0}
.player-seed{font-weight:500}
.muted{color:#65717d}
.action-cell{white-space:normal}
.action-cell.reader-focused{background:var(--matches-soft,#edf0f5);font-weight:600}
.action-cell .button{font-size:.86rem;padding:.25rem .5rem;white-space:nowrap;overflow-wrap:normal}
dialog{width:min(94vw,36rem);max-height:88vh;overflow:auto;border:1px solid #d9dee8;border-radius:.8rem;padding:1.2rem;background:#fff;color:#182332;box-shadow:0 24px 70px #0a132155}
dialog::backdrop{background:#07101d9e}
.dialog-head{display:flex;justify-content:space-between;align-items:start;gap:1rem}
.dialog-head h2{margin:0 0 .8rem}
.plain{border:0;background:transparent;color:inherit;font-size:1.6rem;line-height:1}
#dialogBody form{display:grid;gap:.8rem}
#dialogBody label{display:grid;gap:.2rem;font-weight:600}
#dialogBody .schedule-time{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.25rem .6rem}
#dialogBody .schedule-time .time-heading{grid-column:1/-1;font-weight:600}
#dialogBody .schedule-time label{min-width:0;font-weight:400}
#dialogBody .schedule-time select{width:100%}
#dialogBody [hidden]{display:none!important}
#dialogBody textarea{min-height:8rem;resize:vertical}
#dialogBody .actions{display:flex;gap:.5rem;flex-wrap:wrap;align-items:center}
#dialogBody p{margin:.3rem 0 .6rem}
.stats-org+.stats-org{border-top:1px solid var(--matches-line,#d9dee8);margin-top:1rem;padding-top:.75rem}
.stats-org h3{font-size:1.05rem;margin:.75rem 0 .4rem}
.stats-table{width:100%;border-collapse:collapse}
.stats-table th{position:static;background:var(--matches-soft,#edf0f5)}
.stats-table th,.stats-table td{padding:.35rem .5rem;border-bottom:1px solid var(--matches-line,#d9dee8)}
.stats-table th:last-child,.stats-table td:last-child{text-align:right}
#dialogStatus{min-height:1.2rem;margin:.6rem 0 0}
body.org-theme .matches-header{background:var(--org-color)}
body.org-theme .pill,body.org-theme .button.primary{border-color:var(--org-color)}
body.org-theme .pill{color:var(--org-color)}
body.org-theme .pill.active,body.org-theme .button.primary{background:var(--org-color);color:#fff}
@media(max-width:1199px){
  .table-wrap{border:0;background:transparent}
  .mobile-zone{display:block;width:min(100%,14rem);padding:.3rem .4rem;font-size:.82rem}
  #matchTable,#matchRows{display:block;width:100%}
  #matchTable thead{display:block;position:sticky;top:0;z-index:3;margin-bottom:.6rem;border:1px solid var(--matches-line,#d9dee8);border-radius:.55rem;background:var(--matches-soft,#edf0f5);box-shadow:0 2px 8px #0a132122}
  #matchTable thead tr{display:flex;align-items:center;flex-wrap:wrap;gap:.25rem .35rem;padding:.35rem}
  #matchTable thead th{display:none;position:static;padding:0;border:0;background:transparent}
  #matchTable thead th:nth-child(6){display:block;flex:1 1 16rem}
  #matchTable thead th:nth-child(8){display:block;flex:0 0 auto}
  #matchTable thead th#adminHeading:not([hidden]){display:block;flex:0 0 auto}
  #matchTable thead .heading-title,#readerHeading .sort-button{display:none}
  #matchTable thead .heading-filters{margin:0}
  #readerHeading .heading-filter{margin:0}
  #adminHeading .stats-button{margin:0}
  #matchRows{display:grid;gap:.8rem}
  #matchRows tr{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));min-width:0;border:1px solid var(--matches-line,#d9dee8);border-radius:.65rem;background:var(--matches-surface,#fff)}
  #matchRows td{display:block;width:auto;min-width:0;padding:.45rem .7rem;border-bottom:1px solid var(--matches-line,#d9dee8);overflow-wrap:anywhere}
  #matchRows td::before{content:attr(data-label);display:block;color:var(--matches-muted,#65717d);font-size:.72rem;font-weight:600;text-transform:uppercase;letter-spacing:.03em}
  #matchRows td:nth-child(-n+5){padding:.4rem .35rem}
  #matchRows td.players{grid-column:1/-1}
  #matchRows .player-list{flex-direction:row;align-items:baseline;gap:.25rem .7rem}
  #matchRows td.start-cell{grid-column:span 2}
  #matchRows td:nth-child(8){grid-column:span 2}
  #matchRows td:nth-child(9){grid-column:span 1}
  #matchRows tr.has-admin td:nth-child(8){grid-column:span 1}
  #matchRows td.admin-cell{grid-column:span 1}
  #matchRows td.admin-cell:empty{display:none}
  #matchRows tr.empty-row td{grid-column:1/-1}
  #matchRows tr.empty-row td::before{display:none}
}
@media(max-width:759px){.matches-header{align-items:start;flex-wrap:wrap}.matches-header nav{order:3;width:100%}.filter-bar{justify-content:flex-start}.resource-group+.resource-group{border-left:0;padding-left:0}}
@media(max-width:649px){#matchRows td.start-cell{grid-column:1/-1}#matchRows td:nth-child(8){grid-column:span 3}#matchRows td:nth-child(9){grid-column:span 2}#matchRows tr.has-admin td:nth-child(8){grid-column:span 3}#matchRows tr.has-admin td:nth-child(9){grid-column:span 1}.list-controls{flex:1 1 100%;max-width:none}}
@media(max-width:480px){#matchRows td:nth-child(-n+5){padding:.35rem .2rem;font-size:.9rem}#matchRows td:nth-child(-n+5)::before{font-size:.65rem;letter-spacing:0}}
