:root {
  --ink: #17221d;
  --muted: #64716a;
  --line: #dfe7e1;
  --paper: #ffffff;
  --canvas: #f2f5f1;
  --green: #176b45;
  --green-dark: #0f5135;
  --lime: #c9f05b;
  --red: #b73939;
  --shadow: 0 12px 35px rgba(24, 45, 33, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(201, 240, 91, 0.18), transparent 24rem),
    var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  padding: 3.5rem max(1.25rem, calc((100vw - 1180px) / 2)) 2.5rem;
  color: white;
  background:
    linear-gradient(120deg, rgba(10, 53, 34, 0.98), rgba(23, 107, 69, 0.94)),
    repeating-linear-gradient(90deg, transparent 0 79px, rgba(255,255,255,.08) 80px);
}

.eyebrow,
.kicker {
  margin: 0 0 0.5rem;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.eyebrow {
  color: var(--lime);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 720px;
  margin-bottom: 0.55rem;
  font-size: clamp(2.2rem, 5vw, 4.2rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.45rem;
  letter-spacing: -0.025em;
}

.subtitle {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.75);
}

.save-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  max-width: 430px;
}

.control-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem;
}

[hidden] {
  display: none !important;
}

.status {
  width: 100%;
  margin-bottom: 0.3rem;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
  text-align: right;
}

.status.synced {
  color: var(--lime);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0.68rem 1rem;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 750;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button.primary {
  color: white;
  background: var(--green);
}

.button.primary:hover {
  background: var(--green-dark);
}

.button.secondary {
  color: var(--ink);
  background: var(--lime);
}

.button.ghost {
  color: inherit;
  border-color: currentColor;
  background: transparent;
}

.hero .button.ghost {
  color: white;
  border-color: rgba(255, 255, 255, 0.35);
}

.button.danger {
  color: white;
  background: var(--red);
}

.button.full {
  width: 100%;
  margin-top: 0.8rem;
}

.file-label input {
  display: none;
}

main {
  width: min(1180px, calc(100% - 2.5rem));
  margin: 2rem auto 4rem;
}

.card {
  padding: 1.5rem;
  border: 1px solid rgba(23, 34, 29, 0.07);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.standings-card {
  margin-bottom: 1.25rem;
}

.schedule-card {
  margin-bottom: 1.25rem;
}

.schedule-intro {
  margin: -0.6rem 0 1.2rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.schedule-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.schedule-legend span,
.scheduled-player {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}

.position-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.position-dot.right {
  background: #3182ce;
}

.position-dot.backhand {
  background: #d97706;
}

.schedule-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  max-height: 560px;
  padding-right: 0.35rem;
  overflow-y: auto;
}

.schedule-round {
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfcfa;
}

.schedule-round.played {
  border-color: rgba(23, 107, 69, 0.3);
  background: rgba(201, 240, 91, 0.1);
}

.schedule-round.next {
  border-color: var(--green);
  box-shadow: inset 3px 0 0 var(--green);
}

.schedule-round-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.round-number {
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.round-date {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.round-teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.55rem;
  align-items: center;
}

.scheduled-team {
  display: grid;
  gap: 0.38rem;
}

.scheduled-team:last-child {
  justify-items: end;
}

.scheduled-team:last-child .scheduled-player {
  flex-direction: row-reverse;
}

.scheduled-player {
  font-size: 0.84rem;
  font-weight: 750;
}

.round-vs {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
}

.round-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--line);
}

.round-status {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.round-status.done {
  color: var(--green);
}

.use-round-button {
  padding: 0.35rem 0.55rem;
  color: var(--green);
  border: 1px solid rgba(23, 107, 69, 0.3);
  border-radius: 7px;
  background: white;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 800;
}

.use-round-button:hover {
  background: rgba(201, 240, 91, 0.18);
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.35rem;
}

.kicker {
  color: var(--green);
}

.muted,
.ranking-note,
.field small,
.empty-state small {
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th,
td {
  padding: 0.82rem 0.72rem;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}

tbody tr:first-child td {
  background: rgba(201, 240, 91, 0.14);
}

.position {
  color: var(--green);
  font-weight: 900;
}

.player {
  font-weight: 800;
}

.positive {
  color: var(--green);
  font-weight: 800;
}

.negative {
  color: var(--red);
}

.ranking-note {
  margin: 0.75rem 0 0;
  font-size: 0.78rem;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.field {
  display: grid;
  gap: 0.42rem;
  margin-bottom: 0.9rem;
}

.field > span,
legend,
.sets-block > span {
  font-size: 0.82rem;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 43px;
  padding: 0.62rem 0.72rem;
  color: var(--ink);
  border: 1px solid #cbd7ce;
  border-radius: 8px;
  background: white;
}

input:focus,
select:focus {
  border-color: var(--green);
  outline: 3px solid rgba(23, 107, 69, 0.12);
}

.teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.8rem;
  align-items: center;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.versus {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: var(--green);
  border-radius: 50%;
  background: rgba(201, 240, 91, 0.35);
  font-size: 0.72rem;
  font-weight: 900;
}

.sets-block {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 11px;
  background: #f7f9f6;
}

.set-header,
.set-row {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) 90px 90px;
  gap: 0.65rem;
  align-items: center;
}

.set-header {
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.set-header span:first-child {
  text-align: left;
}

.set-row + .set-row {
  margin-top: 0.6rem;
}

.set-row strong {
  font-size: 0.84rem;
}

.set-row small {
  color: var(--muted);
  font-weight: 500;
}

.set-row input {
  text-align: center;
}

.form-error {
  min-height: 1.25rem;
  margin: 0.8rem 0 0;
  color: var(--red);
  font-size: 0.84rem;
  font-weight: 650;
}

.empty-state {
  padding: 3rem 1rem;
  color: var(--muted);
  text-align: center;
}

.empty-state .ball {
  margin-bottom: 0.8rem;
  color: var(--lime);
  font-size: 3rem;
  line-height: 1;
  text-shadow: 0 2px 0 #a5c63d;
}

.empty-state p {
  margin-bottom: 0.25rem;
  color: var(--ink);
  font-weight: 800;
}

.match-list {
  display: grid;
  gap: 0.8rem;
}

.match-card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.match-top,
.match-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.match-date {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: capitalize;
}

.delete-button {
  padding: 0.25rem 0.4rem;
  color: var(--muted);
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
}

.delete-button:hover {
  color: var(--red);
}

.match-score {
  margin-top: 0.55rem;
}

.team-name {
  flex: 1;
  font-size: 0.91rem;
  font-weight: 750;
}

.team-name:last-child {
  text-align: right;
}

.team-name.winner {
  color: var(--green);
}

.score {
  padding: 0.4rem 0.55rem;
  border-radius: 7px;
  background: #f0f4f0;
  font-weight: 900;
  white-space: nowrap;
}

dialog {
  max-width: 420px;
  padding: 1.4rem;
  border: 0;
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

#loginDialog form {
  min-width: min(340px, calc(100vw - 4rem));
}

dialog::backdrop {
  background: rgba(12, 22, 17, 0.56);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.7rem;
  margin-top: 1.4rem;
}

@media (max-width: 850px) {
  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .save-panel,
  .status {
    justify-content: flex-start;
    text-align: left;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .schedule-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .hero {
    padding-top: 2.2rem;
  }

  main {
    width: min(100% - 1rem, 1180px);
    margin-top: 0.5rem;
  }

  .card {
    padding: 1rem;
    border-radius: 12px;
  }

  .teams {
    grid-template-columns: 1fr;
  }

  .versus {
    margin: -0.25rem auto;
  }

  .set-header,
  .set-row {
    grid-template-columns: minmax(72px, 1fr) 70px 70px;
  }

  .save-panel .button {
    flex-grow: 1;
  }
}
