/* Simple, mobile-first styles */
:root {
  --bg: #f3f6f4;
  --card: #ffffff;
  --text: #1c2421;
  --muted: #5f6b66;
  --line: #dde4e0;
  --primary: #1f7a4d;
  --primary-dark: #17603c;
  --accent: #e9f5ee;
  --danger: #b3261e;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
}
.topbar h1 { margin: 0; font-size: 1.15rem; }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

h2 { margin: 0 0 8px; font-size: 1.3rem; }
h3 { margin: 24px 0 8px; font-size: 1.05rem; }
.card h3 { margin-top: 16px; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card.flush { padding: 0; overflow: hidden; }

/* Forms */
label { display: block; margin-bottom: 12px; font-weight: 600; font-size: 0.95rem; }
input[type="text"], input[type="password"], input[type="number"], select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 400;
  border: 1px solid #c5cfca;
  border-radius: 8px;
  background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 0 0 12px; }
legend { font-weight: 600; padding: 0 4px; }
label.choice { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 6px 0; }
label.choice input { width: 20px; height: 20px; }

.row { display: flex; gap: 12px; }
.row > label { flex: 1; }

.team-group { border-left: 4px solid var(--primary); padding-left: 10px; margin-bottom: 12px; }
.team-group .team-label { font-weight: 700; font-size: 0.9rem; color: var(--primary); }
.team-group label { margin-bottom: 6px; }

/* Buttons */
.btn {
  display: inline-block;
  min-height: 44px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  border: 1px solid #c5cfca;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.875rem; }
.btn.link { border: 0; background: none; color: var(--primary); text-decoration: underline; padding: 6px 0; min-height: 0; }

.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 12px; }
.actions.bottom { justify-content: space-between; margin-top: 24px; }

/* Live game */
.session-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.live-dot { font-size: 0.8rem; color: var(--muted); white-space: nowrap; padding-top: 4px; }
.live-dot.on { color: var(--primary); }

.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }

.court { margin-bottom: 0; }
.court h4 { margin: 0 0 10px; font-size: 1rem; display: flex; justify-content: space-between; }
.court.empty { color: var(--muted); border-style: dashed; }
.court.upcoming { background: #fbfcfb; }
.team { padding: 8px 10px; border-radius: 8px; background: var(--accent); font-weight: 600; }
.team .label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.vs { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 4px 0; }
.win-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.win-buttons .btn { width: 100%; }

/* Tables and lists */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { font-size: 0.8rem; color: var(--muted); font-weight: 600; background: #fafcfb; }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: 0; }

.list-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.empty-note { padding: 12px; color: var(--muted); margin: 0; }

.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: #eef1ef; color: var(--muted); }
.chip.playing { background: #dff3e7; color: var(--primary-dark); }
.chip.upcoming { background: #fff3d6; color: #7a5a00; }
.chip.resting { background: #f1e3e2; color: var(--danger); }

/* Dialog + toast */
dialog { border: 0; border-radius: var(--radius); padding: 16px; width: min(420px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog h3 { margin-top: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 8px;
  background: #1c2421;
  color: #fff;
  z-index: 10;
}
.toast.error { background: var(--danger); }

/* Wider screens */
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  #screen-home { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  #screen-home[hidden] { display: none; }
}
@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
