:root {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #173e35;
  background: #f2f5f1;
  --ink: #173e35;
  --green: #087e65;
  --line: #dfe7df;
  --muted: #77877c;
  --lime: #d7f36a;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 16px;
  min-height: 44px;
  font-weight: 600;
}
button:hover {
  background: #edf4eb;
}
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
button.primary {
  background: var(--green);
  color: white;
  border-color: var(--green);
}
a {
  color: inherit;
  text-decoration: none;
}
input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cad8cd;
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fff;
}
input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid #a5d4b4;
  outline-offset: 2px;
}
label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 30px;
  letter-spacing: -0.8px;
}
h2 {
  font-size: 20px;
}
h3 {
  font-size: 16px;
}
.small,
.muted {
  font-size: 12px;
  color: var(--muted);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 18px 30px;
  gap: 20px;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
}
.brand-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--lime);
  border-radius: 12px;
  font-size: 25px;
  transform: rotate(-8deg);
}
.brand small {
  display: block;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 2px;
  margin-top: 3px;
  color: var(--muted);
}
.nav {
  display: flex;
  gap: 5px;
}
.nav a {
  padding: 10px 13px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
}
.nav a.active {
  color: var(--green);
  background: #eaf2e9;
  font-weight: 700;
}
.connection {
  font-size: 12px;
  white-space: nowrap;
}
.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #0c9f70;
  margin-right: 7px;
}
.off .dot {
  background: #d69a3c;
}
.container {
  max-width: 1440px;
  margin: auto;
  padding: 34px 34px 55px;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 2px;
  font-weight: 800;
  color: var(--green);
  margin-bottom: 10px;
}
.heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 27px;
}
.heading p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
}
.actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  border-radius: 20px;
  padding: 6px 10px;
  background: #e7f2e8;
  color: var(--green);
  white-space: nowrap;
}
.warn {
  background: #fff0d3;
  color: #93671b;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 29px;
}
.stat {
  background: white;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 20px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.stat-value {
  font-size: 31px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  margin-top: 8px;
}
.stat-icon {
  font-size: 24px;
  color: #9db0a0;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
}
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 16px;
}
.section-title h2 {
  font-size: 18px;
}
.courts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.court-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}
.court-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 12px;
  gap: 5px;
}
.court-body {
  padding: 16px 18px;
}
.team-score {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
}
.team-name {
  font-size: 17px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.players {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  margin-top: 6px;
  overflow-wrap: anywhere;
}
.score {
  font-size: 46px;
  line-height: 1.1;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
}
.leading .score {
  color: var(--green);
}
.separator {
  height: 1px;
  background: var(--line);
  margin: 9px 0;
}
.court-foot {
  background: #f8faf6;
  border-top: 1px solid var(--line);
  padding: 13px 16px;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 5px;
  flex-wrap: wrap;
}
.court-actions {
  padding: 0 16px 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.court-actions button {
  font-size: 12px;
  padding: 8px;
  min-height: 38px;
}
.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 21px;
}
.panel + .panel {
  margin-top: 18px;
}
.panel h3 {
  margin-bottom: 15px;
}
.rank-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid #edf1e9;
  font-size: 13px;
}
.rank-mini:last-child {
  border: 0;
}
.rank-num {
  display: inline-grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 7px;
  background: #eff4e9;
  font-size: 12px;
  font-weight: 700;
}
.rank-mini:first-of-type .rank-num {
  background: var(--lime);
}
.name {
  flex: 1;
}
.pts {
  font-weight: 800;
}
.rules-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.9;
  margin-top: 16px;
}
.section-gap {
  margin-top: 24px;
}
.round-tabs,
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.round-tabs button {
  font-size: 12px;
  padding: 8px 13px;
}
.round-tabs button.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.tabs {
  border-bottom: 1px solid var(--line);
  gap: 23px;
}
.tabs button {
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--muted);
  padding: 13px 0;
}
.tabs button.active {
  color: var(--green);
  border-bottom: 3px solid var(--green);
}
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}
th {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  background: #f7f9f3;
  padding: 15px 17px;
}
td {
  padding: 14px 17px;
  border-top: 1px solid #edf1e9;
}
td button {
  font-size: 12px;
  padding: 8px 10px;
}
.notice {
  font-size: 13px;
  line-height: 1.8;
  background: #fff3d8;
  color: #8e671e;
  border: 1px solid #efdfbb;
  padding: 13px 16px;
  border-radius: 10px;
  margin-bottom: 19px;
}
.notice.success {
  background: #e8f3e9;
  border-color: #cee3d0;
  color: var(--green);
}
.empty {
  text-align: center;
  padding: 65px 22px;
  color: var(--muted);
  line-height: 1.9;
}
.teams-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 17px;
}
.team-editor {
  border: 1px solid var(--line);
  background: white;
  border-radius: 13px;
  padding: 20px;
}
.team-editor h3 {
  margin-bottom: 16px;
}
.player-input {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
}
.player-input span {
  width: 18px;
  font-size: 12px;
  color: var(--muted);
}
.player-input input {
  font-size: 13px;
}
.form-row {
  max-width: 600px;
  margin-bottom: 20px;
}
.form-footer {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-top: 20px;
}
.login {
  max-width: 430px;
  margin: 70px auto;
  padding: 32px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
}
.login h1 {
  font-size: 25px;
  margin-bottom: 10px;
}
.login p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.8;
  margin-bottom: 23px;
}
.login button {
  width: 100%;
  margin-top: 16px;
}
.lineup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.lineup-row {
  display: grid;
  grid-template-columns: 42px 1fr 1fr;
  gap: 7px;
  align-items: center;
  margin-top: 12px;
  font-size: 12px;
}
.lineup-row select {
  padding: 8px;
  font-size: 12px;
}
.auth-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.auth-grid p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.8;
  margin: 15px 0 20px;
}
.auth-grid button {
  width: 100%;
}
.ref-container {
  max-width: 780px;
  margin: auto;
  padding: 24px 22px 45px;
}
.ref-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.ref-title h1 {
  font-size: 23px;
}
.ref-scoreboard {
  background: var(--ink);
  color: white;
  border-radius: 20px;
  padding: 24px;
}
.ref-meta {
  display: flex;
  justify-content: space-between;
  color: #bed5bf;
  font-size: 12px;
}
.progress {
  display: flex;
  gap: 6px;
  margin: 20px 0;
}
.progress span {
  height: 4px;
  border-radius: 3px;
  flex: 1;
  background: #4d715d;
}
.progress span.done {
  background: var(--lime);
}
.ref-sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  text-align: center;
}
.ref-side {
  min-width: 0;
}
.ref-side h2 {
  font-size: 21px;
  overflow-wrap: anywhere;
}
.ref-side .players {
  font-size: 13px;
  color: #c7d9c4;
  min-height: 43px;
}
.ref-score {
  font-size: 98px;
  line-height: 1.3;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -4px;
}
.point-btn {
  height: 90px;
  width: 100%;
  margin-top: 12px;
  background: var(--lime);
  border: 0;
  border-radius: 15px;
  font-size: 32px;
  color: var(--ink);
  user-select: none;
}
.point-btn:hover {
  background: #cbe85b;
}
.ref-status {
  font-size: 12px;
  text-align: center;
  color: #c7d9c4;
  margin-top: 20px;
}
.ref-controls {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.ref-controls button {
  flex: 1;
}
.next-players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 15px;
}
.next-players p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}
.screen-mode {
  background: #082f29;
  color: #fff;
  min-height: 100vh;
}
.screen-mode .topbar {
  background: #092a25;
  border-color: #315342;
}
.screen-mode .brand small,
.screen-mode .connection,
.screen-mode .heading p,
.screen-mode .small {
  color: #b9ccba;
}
.screen-mode .nav a {
  color: #b9ccba;
}
.screen-mode .nav a.active {
  background: #254b39;
  color: var(--lime);
}
.screen-mode .container {
  max-width: 1800px;
}
.screen-mode .eyebrow {
  color: var(--lime);
}
.screen-mode .court-card {
  background: #103f32;
  border-color: #315942;
}
.screen-mode .court-head {
  border-color: #315942;
  padding: 20px 24px;
}
.screen-mode .court-body {
  padding: 28px 24px;
}
.screen-mode .score {
  font-size: clamp(65px, 6vw, 115px);
  color: var(--lime);
}
.screen-mode .team-name {
  font-size: 24px;
}
.screen-mode .players {
  font-size: 15px;
  color: #b9ccba;
}
.screen-mode .separator {
  background: #315942;
  margin: 20px 0;
}
.screen-mode .court-foot {
  background: #0d382c;
  border-color: #315942;
  color: #b9ccba;
  font-size: 12px;
}
.screen-mode .pill {
  background: #28503a;
  color: var(--lime);
}
.screen-mode button {
  background: #244b36;
  color: #fff;
  border-color: #46664a;
}
.screen-ranks {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-top: 20px;
}
.screen-rank {
  padding: 18px;
  background: #123b2e;
  border: 1px solid #315942;
  border-radius: 12px;
}
.screen-rank strong {
  display: block;
  font-size: 18px;
  margin: 12px 0;
}
.screen-rank .rank-num {
  background: #29513b;
  color: var(--lime);
}
dialog {
  width: min(680px, calc(100vw - 28px));
  max-height: 90vh;
  border: 0;
  border-radius: 18px;
  color: var(--ink);
  padding: 27px;
}
dialog::backdrop {
  background: #082f29ad;
  backdrop-filter: blur(3px);
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.dialog-head button {
  border: 0;
  background: #eef4ea;
  padding: 8px 14px;
}
.qr {
  display: block;
  width: 230px;
  height: 230px;
  margin: 16px auto;
}
.share-link {
  background: #f1f5ed;
  border-radius: 9px;
  padding: 13px;
  font-size: 12px;
  overflow-wrap: anywhere;
  margin: 16px 0;
}
.footer {
  margin-top: 30px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
}
#toast {
  display: none;
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 22px;
  background: #173e35;
  color: white;
  font-size: 13px;
  border-radius: 12px;
  max-width: 90vw;
  z-index: 100;
  box-shadow: 0 6px 25px #0003;
}
#toast.show {
  display: block;
}
@media (max-width: 1150px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
  }
  .sidebar .panel + .panel {
    margin: 0;
  }
  .topbar {
    padding: 16px 22px;
  }
  .container {
    padding: 28px 22px;
  }
  .teams-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 720px) {
  .topbar {
    padding: 13px 16px;
    flex-wrap: wrap;
    gap: 12px;
  }
  .brand {
    font-size: 16px;
  }
  .brand-icon {
    width: 34px;
    height: 34px;
  }
  .topbar .nav {
    order: 3;
    width: 100%;
    justify-content: space-between;
    border-top: 1px solid var(--line);
    padding-top: 9px;
  }
  .nav a {
    font-size: 12px;
    padding: 9px;
  }
  .container {
    padding: 24px 16px 40px;
  }
  .heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
  }
  h1 {
    font-size: 25px;
  }
  .stats {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 24px;
  }
  .stat {
    padding: 15px;
  }
  .stat-value {
    font-size: 27px;
  }
  .courts,
  .teams-grid,
  .auth-grid,
  .sidebar,
  .lineup-grid {
    grid-template-columns: 1fr;
  }
  .court-body {
    padding: 12px 20px;
  }
  .score {
    font-size: 48px;
  }
  .tabs {
    gap: 17px;
  }
  .tabs button {
    font-size: 13px;
  }
  .ref-container {
    padding: 19px 14px;
  }
  .ref-scoreboard {
    padding: 20px 15px;
  }
  .ref-score {
    font-size: 80px;
  }
  .ref-side h2 {
    font-size: 18px;
  }
  .ref-sides {
    gap: 12px;
  }
  .screen-ranks {
    grid-template-columns: repeat(2, 1fr);
  }
  .screen-mode .score {
    font-size: 70px;
  }
  .screen-mode .team-name {
    font-size: 22px;
  }
  .screen-mode .court-body {
    padding: 20px;
  }
  .screen-mode .topbar .nav {
    border-color: #315942;
  }
  .login {
    margin: 25px 16px;
    padding: 26px;
  }
  .footer {
    flex-direction: column;
  }
  .form-footer {
    align-items: flex-start;
    flex-direction: column;
  }
  .form-footer button {
    width: 100%;
  }
  .ref-title h1 {
    font-size: 20px;
  }
}
