:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #d8dee7;
  --green: #1f8a5b;
  --red: #c24130;
  --blue: #2563eb;
  --gold: #b7791f;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

.login-view {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}

.login-view.hidden {
  display: none;
}

.login-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 22px;
  box-shadow: 0 16px 40px rgba(31, 35, 40, 0.12);
}

.login-card h2 {
  margin-bottom: 16px;
}

.login-card input,
.login-card button {
  margin-top: 10px;
}

.login-card button {
  width: 100%;
  height: 44px;
}

.login-error {
  min-height: 22px;
  margin-top: 10px;
  color: var(--red);
  font-size: 13px;
}

.user-pill {
  padding: 8px 10px;
  border-radius: 999px;
  background: #edf2ff;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 8px 0 18px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-actions > button:not(.icon-btn) {
  height: 42px;
  padding: 0 14px;
}

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

h1 {
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.1;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 18px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.panel,
.team-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(31, 35, 40, 0.06);
}

.panel {
  padding: 16px;
  margin-bottom: 14px;
}

.setup {
  display: grid;
  gap: 14px;
}

.match-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.import-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 10px;
  margin-bottom: 12px;
}

.import-row button {
  height: 44px;
}

.match-item {
  position: relative;
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 10px;
  text-align: left;
}

.match-item.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.match-item strong,
.match-item span {
  display: block;
}

.match-item strong {
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.delete-match {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 28px;
  height: 28px;
  border: 1px solid #f1c4bd;
  background: #fff1ef;
  color: var(--red);
  font-size: 18px;
  line-height: 1;
}

.field {
  display: grid;
  gap: 6px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 110px;
  margin-top: 12px;
  padding: 12px;
  resize: vertical;
  line-height: 1.6;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.teams,
.settings-grid,
.scoreboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.scoreboard {
  margin-bottom: 14px;
}

.team-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 108px;
  padding: 18px;
}

.team-card strong {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #edf2ff;
  color: var(--blue);
  font-size: 24px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: #e9f7ef;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

.badge.locked {
  background: #fff1ef;
  color: var(--red);
}

.players {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.player {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.player-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 800;
}

.edit-left {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.choice-row {
  display: grid;
  grid-template-columns: 1fr 1fr 72px;
  gap: 8px;
}

.choice {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.choice.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.choice.skip.active {
  border-color: var(--muted);
  background: var(--muted);
}

.choice:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.player.locked-other {
  background: #fafafa;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 20px;
}

.result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) 96px;
  align-items: center;
  gap: 10px;
}

.result-row span {
  color: var(--muted);
  font-weight: 900;
}

.result-row button,
.copy-panel button,
.result-panel .section-head button {
  height: 44px;
  padding: 0 18px;
}

.result-panel .section-head button {
  white-space: nowrap;
}

.settle-text {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 720px) {
  .app {
    padding: 14px;
  }

  .teams,
  .settings-grid,
  .scoreboard,
  .match-list,
  .import-row,
  .players,
  .result-row {
    grid-template-columns: 1fr;
  }

  .choice-row {
    grid-template-columns: 1fr;
  }

  .result-row span {
    display: none;
  }
}
