html { scroll-padding-top: 1rem; }
.app-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding-top: env(safe-area-inset-top);
}
.app-header-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 69px;
  gap: 16px;
}
.app-nav { display: flex; gap: 16px; }
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 58px;
  padding-inline: 8px;
  text-decoration: none;
  color: var(--muted);
  font-size: .91rem;
  font-weight: 750;
}
.tab:hover, .tab[aria-current] { color: var(--ink); }
.tab[aria-current]::after { content: ""; position: absolute; inset: auto 7px 3px; height: 3px; background: #b49500; }
.tab svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.profile-link {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  max-width: 100%;
  padding-inline: 8px;
  border-radius: 4px;
  font-size: .91rem;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}
.profile-link:hover, .profile-link[aria-current] { background: var(--sand); }
.workspace { max-width: 1180px; padding-block: 34px 70px; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 25px; }
.page-head h1 { font: 800 clamp(3.6rem, 6.5vw, 6.15rem)/.91 var(--display); letter-spacing: -.016em; text-transform: uppercase; }
.page-head .btn { padding-inline: 17px; white-space: nowrap; }
.page-intro { margin-top: 9px; color: var(--muted); }
.app-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 750;
}
.app-mode::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #9b7700; }

.board-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, .42fr); gap: 24px; align-items: start; }
.board-rail, .stack { display: grid; gap: 12px; }
.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--sand);
  border-radius: 6px;
}
.filters.single { grid-template-columns: minmax(0, 320px); }
.filter, .f { display: grid; gap: 4px; min-width: 0; font-size: .85rem; font-weight: 750; }
select, input:not([type="checkbox"]), textarea {
  width: 100%;
  min-height: 45px;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid #a8a99c;
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 550;
}
.filter select { text-overflow: ellipsis; }
.sec { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 14px; flex-wrap: wrap; margin: 21px 0 11px; }
.sec h2, .side-panel h2 { font: 800 1.95rem/1 var(--display); letter-spacing: -.01em; }
.sec > span, .aside-note { font-size: .85rem; color: var(--muted); }
.card, .side-panel {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}
.side-panel { padding: 18px; scroll-margin-top: 16px; }
.side-panel h2 { margin-bottom: 9px; }
.side-panel .btn { margin-top: 11px; }
.side-panel .btn[aria-pressed="true"] { border-color: #8d770c; background: #f9edb5; }
.side-panel .stack > .card { background: var(--paper); }
.aside-note + .ready-list { margin-top: 10px; }
.ready-list { border-top: 1px solid var(--line); }
.ready-list summary { min-height: 44px; padding-top: 10px; font-size: .88rem; font-weight: 750; cursor: pointer; }
.ready-list ul { margin: 0; padding: 0; list-style: none; }
.rp { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 3px 0; border: 0; background: transparent; text-align: left; }
.rp:hover { text-decoration: underline; }
.mobile-matches { display: none; }

.ticket {
  display: grid;
  grid-template-columns: minmax(75px, 107px) minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}
.tk-time {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 11px;
  border-right: 1px solid var(--line);
  border-top: 4px solid var(--yellow);
  background: var(--sand);
  font-variant-numeric: tabular-nums;
}
.tk-time b { font: 800 clamp(1.95rem, 3.7vw, 2.7rem)/.94 var(--display); }
.tk-time small { font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .035em; }
.tk-time > span { color: var(--muted); font-size: .76rem; }
.tk-body { min-width: 0; padding: 13px 15px; }
.tk-head, .who { display: flex; align-items: start; gap: 10px; }
.tk-head > div, .who > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.player-line { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 7px; margin-bottom: 4px; font-size: .83rem; font-weight: 750; }
.ticket h3 { font-size: clamp(1.04rem, 1.8vw, 1.35rem); }
.ticket .mute { margin-top: 4px; font-size: .85rem; }
.ticket .note { margin-top: 8px; font-size: .89rem; color: var(--muted); overflow-wrap: anywhere; }
.ticket-foot { display: flex; justify-content: space-between; align-items: end; gap: 7px 10px; flex-wrap: wrap; margin-top: 9px; }
.ticket-foot .btn { margin-left: auto; }
.fit { flex: none; text-align: right; font: 800 1.5rem/1 var(--display); font-variant-numeric: tabular-nums; }
.fit small { display: block; margin-top: 3px; font: 650 .7rem/1.1 var(--body); color: var(--muted); }
.pills, .row { display: flex; align-items: center; gap: 5px 7px; flex-wrap: wrap; }
.pill {
  display: inline-block;
  padding: 3px 6px;
  border-radius: 3px;
  background: var(--sand);
  color: var(--muted);
  font-size: .73rem;
  font-weight: 750;
  line-height: 1.15;
}
.pill.ok { background: #e6edda; color: #3f5629; }
.pill.warn { background: #fbefbf; color: #66500a; }
.pill.demo { border: 1px solid var(--line); background: transparent; }
.mute, .hint { color: var(--muted); }
.hint { font-size: .86rem; }
.empty { padding-block: 20px; }
.empty strong { display: block; margin-bottom: 4px; }
.empty .btn { margin-top: 9px; }
.sm { min-height: 44px; padding: 6px 9px; font-size: .84rem; }
.wide { width: 100%; }
.lv { color: var(--ink); font-size: .82rem; font-weight: 750; }
.av {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: var(--sand);
  color: var(--ink);
  font-weight: 850;
  font-size: .78rem;
  line-height: 1;
}
.av.l2 { background: #ede4bc; }
.av.l3 { background: #e5d48b; }
.av.l4 { background: #f3d852; }
.av.sm { width: 28px; height: 28px; min-height: 0; padding: 0; flex-basis: 28px; }
.av.xl { width: 56px; height: 56px; flex-basis: 56px; font-size: 1.2rem; }

.subpage { max-width: 810px; }
.subpage > .card, .subpage > .stack, .subpage > .hint { margin-top: 12px; }
.venue-card a { font-weight: 750; }
.venue-card p { margin-top: 6px; }
.court-notice { border-left: 4px solid #ab890e; background: var(--sand); }
.slot {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px 12px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
}
.slot b { font: 800 1.8rem/1 var(--display); }
.slot .mute { font-size: .83rem; }
.slot .pill { margin-left: 5px; }
.slot.taken { background: var(--sand); }
.rank {
  display: grid;
  grid-template-columns: 25px 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 60px;
  padding: 9px 11px;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.rank:hover, .rank.me, .box tr.me { background: #f8edb7; }
.rank .no { color: var(--muted); font-weight: 800; }
.rank .nm { overflow-wrap: anywhere; }
.rank .nm strong { display: block; }
.rank .mute { font-size: .81rem; }
.rank .pill { margin-left: 4px; }
.elo { text-align: right; font: 800 1.5rem/1 var(--display); font-variant-numeric: tabular-nums; }
.elo small { display: block; margin-top: 3px; font: 600 .73rem/1 var(--body); color: var(--muted); white-space: nowrap; }
.form { display: inline-flex; gap: 3px; margin-left: 5px; }
.form i { width: 6px; height: 6px; border-radius: 50%; background: #8a5c54; }
.form .w { background: #526c38; }
.box h3 { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px; font-size: 1.17rem; }
.box h3 span { color: var(--muted); font-size: .77rem; font-weight: 650; }
.box table { border-collapse: collapse; width: 100%; margin-top: 8px; font-size: .87rem; font-variant-numeric: tabular-nums; }
.box td, .box th { border-top: 1px solid var(--line); text-align: right; padding: 6px 3px; }
.box :is(th, td):first-child { text-align: left; overflow-wrap: anywhere; }
.box .up { color: #3f5629; }
.box .down { color: #934335; }
.duel { display: grid; grid-template-columns: minmax(75px, 98px) 1fr 28px; align-items: center; gap: 10px; font-size: .88rem; }
.bar { height: 8px; background: var(--sand); }
.bar i { display: block; height: 100%; background: #b89700; }
.pro { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pro > div { overflow-wrap: anywhere; }
.pro h2 { font-size: 1.25rem; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.kpi { display: grid; gap: 3px; padding: 10px 6px; text-align: center; background: var(--sand); }
.kpi b { font: 800 1.65rem/1 var(--display); }
.kpi span { color: var(--muted); font-size: .73rem; line-height: 1.15; }
.badges { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 8px; }
.badge { border: 1px solid var(--line); padding: 9px; font-size: .78rem; color: var(--muted); }
.badge b { display: block; color: var(--ink); }
.badge.on { background: #f8edb7; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 15px; min-height: 44px; cursor: pointer; }
input[type="checkbox"] { width: 18px; height: 18px; margin: 0; flex: none; accent-color: #8d7200; }
.profile-details summary { cursor: pointer; font-weight: 750; }
.profile-details p { margin-top: 7px; }

.sheet {
  width: min(100% - 24px, 510px);
  max-height: calc(100dvh - 24px);
  padding: 16px 18px 19px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  overflow: auto;
}
.sheet::backdrop { background: rgb(27 28 23 / .6); }
.sheet header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.sheet h2 { font: 800 2.3rem/.98 var(--display); overflow-wrap: anywhere; }
.sheet h2:focus:not(:focus-visible) { outline: none; }
.x { flex: 0 0 44px; min-height: 44px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); font-size: 1.5rem; }
.x:hover { background: var(--sand); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.sheet fieldset { min-width: 0; margin: 0; padding: 8px; border: 1px solid var(--line); }
.sheet legend { padding: 0 4px; font-size: .87rem; font-weight: 750; }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 7px; }
.checks label { display: flex; gap: 7px; align-items: center; min-height: 44px; font-size: .83rem; cursor: pointer; }
.scores { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.scores button { min-height: 48px; border: 1px solid var(--line); border-radius: 4px; background: var(--sand); font: 800 1.5rem/1 var(--display); }
.scores button.win { background: #f9edb5; }
.scores button:hover { border-color: #806600; }
.form-error { padding: 9px 11px; border-left: 3px solid #a43725; color: #892e20; background: #f9e5df; font-size: .88rem; }
.toast {
  position: fixed;
  z-index: 5;
  right: var(--edge);
  bottom: 16px;
  max-width: min(400px, 100% - var(--edge) * 2);
  padding: 10px 14px;
  border-radius: 4px;
  color: var(--surface);
  background: var(--ink);
  font-size: .91rem;
  box-shadow: 0 8px 24px #1b1c1726;
}

@media (max-width: 840px) {
  .app-header-inner { grid-template-columns: 1fr auto; min-height: 59px; }
  .app-nav {
    position: fixed;
    z-index: 4;
    inset: auto 0 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    background: var(--surface);
  }
  .tab { flex-direction: column; gap: 2px; min-height: 53px; font-size: .74rem; }
  .tab[aria-current]::after { inset: 0 22% auto; }
  .tab:focus-visible { outline-offset: -4px; }
  .workspace { padding-block: 23px calc(72px + env(safe-area-inset-bottom)); }
  .board-grid { gap: 14px; }
  .toast { bottom: calc(62px + env(safe-area-inset-bottom)); }
}
@media (max-width: 680px) {
  .board-grid { grid-template-columns: minmax(0, 1fr); }
  .page-head { align-items: start; flex-direction: column; gap: 12px; margin-bottom: 14px; }
  .page-head h1 { font-size: clamp(3.15rem, 12vw, 5.2rem); }
  .page-head .btn { min-height: 44px; }
  .mobile-matches {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 3px 0;
    border: 0;
    background: transparent;
    font-size: .86rem;
    font-weight: 750;
    text-decoration: underline;
    text-underline-offset: .18em;
  }
  .board-grid .filters { padding: 9px; }
  .ticket { grid-template-columns: 69px minmax(0, 1fr); }
  .tk-time { padding: 11px 6px; }
  .tk-body { padding: 10px 8px 10px 10px; }
  .fit { font-size: 1.23rem; }
  .fit small { font-size: .64rem; }
  .ticket-foot { align-items: start; }
  .side-panel { scroll-margin-bottom: calc(62px + env(safe-area-inset-bottom)); }
  .sheet { margin: auto auto 0; width: 100%; max-width: 510px; max-height: calc(100dvh - 18px); padding-bottom: calc(15px + env(safe-area-inset-bottom)); }
}
@media (max-width: 370px) {
  .profile-link { padding-inline: 4px; gap: 4px; }
  .slot { grid-template-columns: 48px minmax(0, 1fr); }
  .slot > :last-child { grid-column: 2; justify-self: start; }
  .rank { gap: 5px; padding-inline: 6px; }
}
