* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 15px; line-height: 1.45; }
h1, h2, .brand { font-family: var(--font-display); text-transform: uppercase; font-weight: 800; letter-spacing: 0.02em; margin: 0; }
h1 { font-size: 34px; }
h2 { font-size: 22px; margin: 18px 0 8px; }
a { color: inherit; }
.muted { color: var(--muted); }

.top { display: flex; justify-content: space-between; align-items: center; padding: 12px 32px; background: var(--text); color: var(--surface); }
.brand { text-decoration: none; font-size: 24px; }
.brand span { color: var(--accent); }
.top .muted { color: var(--line); }
main { max-width: 1200px; margin: 0 auto; padding: 24px 32px 64px; }

.bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
.bar p { margin: 0; }

button, .button { font: inherit; font-weight: 600; padding: 8px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; display: inline-block; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.small { padding: 2px 10px; font-size: 13px; margin-left: 12px; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--muted); outline-offset: 2px; }

.grid { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.grid th, .grid td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.grid th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
tr.link { cursor: pointer; }
tr.link:hover { background: var(--surface-2); }

.status { display: inline-block; padding: 1px 10px; border-radius: 100px; font-size: 12px; font-weight: 600; text-transform: uppercase; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); }
.status.live { background: var(--ok); border-color: var(--ok); color: var(--accent-text); }
.status.finished { background: var(--text); border-color: var(--text); color: var(--surface); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs a { padding: 8px 16px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; }
.tabs a[aria-current=page] { color: var(--text); border-bottom-color: var(--accent); }

.form { display: flex; flex-direction: column; gap: 14px; max-width: 760px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; flex: 1; }
.form input, .form textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); width: 100%; }
.form fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.form legend { font-family: var(--font-display); text-transform: uppercase; font-weight: 700; padding: 0 6px; }
.row { display: flex; gap: 16px; }
.check { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 500 !important; flex: none !important; }
.check input { width: auto; }
.summary { margin: 0; padding: 10px 14px; background: var(--surface); border-left: 3px solid var(--accent); font-weight: 600; }

.notice, .error { padding: 10px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.error { border-color: var(--danger); color: var(--danger); font-weight: 600; }

.round .grid { margin-bottom: 6px; }
.round p { margin: 0 0 8px; }
.court { width: 90px; color: var(--muted); font-weight: 600; }
.score { white-space: nowrap; text-align: center !important; }
.score input { width: 4em; text-align: center; font: inherit; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); -moz-appearance: textfield; appearance: textfield; }
.score input::-webkit-outer-spin-button, .score input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.score span { margin: 0 6px; }
.save-state { display: inline-block; min-width: 7em; margin-left: 8px; font-size: 12px; color: var(--ok); text-align: left; }
.save-state.unsaved { color: var(--danger); font-weight: 600; }

.players { max-width: 480px; }
.players li { padding: 4px 0; }
.standings .pts { font-weight: 700; }

.matches { table-layout: fixed; width: 100%; }
.matches td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matches td:nth-child(1) { width: 10%; }
.matches td:nth-child(2) { width: 36%; }
.matches td:nth-child(3) { width: 18%; }
.matches td:nth-child(4) { width: 36%; }
.matches .save-state { display: block; margin: 2px 0 0; min-width: 0; text-align: center; }

main:has(.present) { max-width: none; padding: 12px 32px 16px; }
.present { text-align: center; }
.present h1 { font-size: 40px; margin-bottom: 8px; }
.present .split { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.present .muted { font-size: 0.9rem; }
.standings.big { font-size: 1.3rem; }
.standings.big th, .standings.big td { padding: 5px 8px; }
.standings.big th { font-size: 0.9rem; }
.standings.big td:nth-child(2) { text-align: left; max-width: 11em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 700px) {
  main { padding: 16px; }
  .top { padding: 12px 16px; }
  .row { flex-direction: column; }
  .bar { flex-wrap: wrap; }
  .grid { display: block; overflow-x: auto; }
}
[hidden] { display: none !important; }
