:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1d2330;
  --muted: #6b7280;
  --line: #e5e8ec;
  --brand: #2f6f4f;
  --brand-ink: #ffffff;
  --accent: #c2410c;
  --danger: #b91c1c;
  --win: #ecfdf3;
  --win-line: #16a34a;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.topbar {
  background: var(--brand);
  color: var(--brand-ink);
  padding: .8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  color: var(--brand-ink);
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
}

/* Language switcher */
.langs { display: flex; gap: .25rem; }
.lang {
  color: var(--brand-ink);
  opacity: .7;
  text-decoration: none;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .03em;
  padding: .3rem .5rem;
  border-radius: 6px;
  line-height: 1;
}
.lang:hover { opacity: 1; background: rgba(255, 255, 255, .12); }
.lang-active { opacity: 1; background: rgba(255, 255, 255, .2); }

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
}

h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }

.muted { color: var(--muted); }
.strong { font-weight: 700; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.crumbs { margin-bottom: .75rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1rem;
}
.page-head h1 { margin: 0; }

/* Forms & buttons */
.row { display: flex; gap: .5rem; }
.row input[type=text] { flex: 1; }

input[type=text], input[type=number] {
  padding: .55rem .65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

button, .button {
  display: inline-block;
  padding: .55rem .9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
button:hover, .button:hover { border-color: #cfd4da; }
.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.primary:hover { background: #275c41; }
.danger { color: var(--danger); border-color: #f1c4c4; }
.danger:hover { background: #fdecec; }

.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.actions form { margin: 0; }

.link-danger {
  border: none; background: none; color: var(--muted);
  padding: .2rem .4rem; font-size: 1rem;
}
.link-danger:hover { color: var(--danger); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem .25rem; border-bottom: 1px solid var(--line);
  text-decoration: none; color: var(--ink);
}
.list li:last-child .list-link { border-bottom: none; }
.list-title { font-weight: 600; }
.list-link:hover .list-title { color: var(--brand); }

.players { list-style: none; margin: .75rem 0 0; padding: 0; }
.players li {
  display: flex; align-items: center; justify-content: space-between;
  padding: .45rem .25rem; border-bottom: 1px solid var(--line);
}
.players li:last-child { border-bottom: none; }
.players form { margin: 0; }
.players.locked li { color: var(--ink); }

.badge {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; padding: .2rem .5rem; border-radius: 999px;
}
.badge-active { background: #e7f6ee; color: var(--brand); }
.badge-setup { background: #eef0f3; color: var(--muted); }
.badge-public { background: #eef0f3; color: var(--muted); }
.badge-private { background: #fdeede; color: var(--accent); }
.badges { display: inline-flex; gap: .4rem; align-items: center; }

/* Create form: vertical stack + visibility choices */
.stack { display: flex; flex-direction: column; gap: .75rem; align-items: stretch; }
.choices { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; margin: 0; }
.choices legend { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 0 .3rem; }
.choice { display: flex; gap: .55rem; align-items: flex-start; padding: .3rem 0; cursor: pointer; }
.choice input { margin-top: .25rem; }

/* Shareable link */
.share { margin: .4rem 0 .8rem; }
.share-link {
  width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .9rem; color: var(--ink); background: #f9fafb;
}

.alert {
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
  padding: .6rem .8rem; border-radius: 8px; margin-bottom: 1rem;
}

/* Rounds & matches — mobile first (stacked), row layout on wider screens */
.round h2 { border-bottom: 1px solid var(--line); padding-bottom: .4rem; }
.matches { list-style: none; margin: 0; padding: 0; }
.match {
  display: flex; flex-direction: column; gap: .45rem;
  padding: .7rem .4rem; border-bottom: 1px solid var(--line);
}
.match:last-child { border-bottom: none; }
.match.done { background: linear-gradient(to bottom, var(--win), transparent); border-radius: 8px; }
.court { font-size: .75rem; color: var(--muted); }
.teams { display: flex; flex-direction: column; gap: .15rem; }
.team { font-weight: 600; }
.team.win { color: var(--win-line); }
.team.win::after { content: " 🎀"; }
.vs { color: var(--muted); font-size: .8rem; padding-left: .5rem; }

.score { display: flex; align-items: center; gap: .35rem; margin: 0; }
.score input[type=number] { width: 3.2rem; text-align: center; min-height: 2.6rem; }
.score button { min-height: 2.6rem; }
.dash { color: var(--muted); font-weight: 700; }

@media (min-width: 560px) {
  .match { flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem .9rem; padding: .7rem 0; }
  .match.done { background: linear-gradient(to right, var(--win), transparent); }
  .court { width: 100%; }
  .teams { flex-direction: row; align-items: center; gap: .5rem; flex: 1; min-width: 240px; }
  .vs { padding-left: 0; }
  .score { margin-left: auto; }
  .score input[type=number] { min-height: 0; }
  .score button { min-height: 0; }
}

.byes { margin: .6rem 0 0; color: var(--muted); font-size: .9rem; }

.tip {
  background: #eef6f1; border: 1px solid #cfe7da; color: #2b5e44;
  padding: .55rem .8rem; border-radius: 8px; font-size: .9rem; margin: 0 0 1rem;
}

/* Swappable player chips (drag on desktop, tap on touch) */
.player {
  display: inline-block;
  cursor: grab;
  padding: .25rem .5rem;
  border-radius: 6px;
  border: 1px dashed transparent;
  user-select: none;
  -webkit-user-select: none;
}
.player:hover { background: rgba(16, 24, 40, .06); border-color: var(--line); }
.player:active { cursor: grabbing; }
.player.dragging { opacity: .4; }
.player.drop-target,
.player.selected { border-color: var(--brand); border-style: solid; background: var(--win); }
.player.selected { box-shadow: 0 0 0 2px rgba(47, 111, 79, .25); }
.amp { color: var(--muted); }
.bye-player { margin: 0 .15rem .25rem 0; }

/* Standings */
.standings { width: 100%; border-collapse: collapse; }
.standings th, .standings td {
  text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line);
}
.standings th { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.standings .num { text-align: right; }
.standings .rank { width: 2rem; color: var(--muted); font-weight: 700; }
.standings tr.podium .rank { color: var(--accent); }
.standings tbody tr:last-child td { border-bottom: none; }
