:root {
  --ink: #0c1b2a;
  --panel: #122a3f;
  --panel-line: #23415c;
  --ice: #eaf3fa;
  --muted: #7f9bb0;
  --blue: #2e7bdb;
  --blue-dim: #1c4b87;
  --yellow: #e8b23a;
  --yellow-dim: #93711f;
  --danger: #d9634f;
  --radius: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--ice);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

body {
  min-height: 100vh;
  padding-bottom: 3rem;
}

h1, h2, h3 {
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

a { color: var(--ice); }

.tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ---------- header ---------- */

.top-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 1.5rem 2rem 1rem;
  border-bottom: 1px solid var(--panel-line);
}

.top-bar h1 {
  font-size: 1.5rem;
}

.top-bar .subtitle {
  color: var(--muted);
  font-size: 0.85rem;
}

.top-bar a.admin-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  border: 1px solid var(--panel-line);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
}
.top-bar a.admin-link:hover { border-color: var(--muted); }

/* ---------- draw tabs ---------- */

.draw-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 1rem 2rem 0;
  overflow-x: auto;
}

.draw-tab {
  background: transparent;
  border: 1px solid var(--panel-line);
  color: var(--muted);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 0.6rem 1.1rem;
  font-size: 0.95rem;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
}

.draw-time {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 400;
}

.draw-heading {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.85rem;
  padding-bottom: 0.25rem;
}

.draw-tab .n {
  font-weight: 700;
  color: var(--ice);
  margin-right: 0.35rem;
}

.draw-tab[aria-selected="true"] {
  background: var(--panel);
  color: var(--ice);
  border-color: var(--panel-line);
}

/* ---------- sheet grid ---------- */

.sheet-grid {
  background: var(--panel);
  padding: 1.5rem 2rem 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1rem;
}

.sheet-card {
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  overflow: hidden;
}

.sheet-card .sheet-label {
  background: var(--ink);
  padding: 0.5rem 0.9rem;
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.final-badge {
  background: var(--blue-dim);
  color: var(--ice);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius);
}

.sheet-card .empty {
  padding: 1.5rem 0.9rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.team-row {
  display: grid;
  grid-template-columns: 1fr repeat(8, 1.6rem) 2.4rem;
  align-items: center;
  padding: 0.4rem 0.6rem;
  gap: 2px;
}

.team-row + .team-row {
  border-top: 1px solid var(--panel-line);
}

.team-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 0.4rem;
}

.rock {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  flex: none;
  display: inline-block;
}
.rock.blue { background: var(--blue); box-shadow: 0 0 0 2px var(--blue-dim); }
.rock.yellow { background: var(--yellow); box-shadow: 0 0 0 2px var(--yellow-dim); }

.end-score {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.end-score.scored { color: var(--ice); font-weight: 600; }

.end-header {
  display: grid;
  grid-template-columns: 1fr repeat(8, 1.6rem) 2.4rem;
  padding: 0.3rem 0.6rem 0;
  font-size: 0.65rem;
  color: var(--muted);
}
.end-header span { text-align: center; }
.end-header span:first-child { text-align: left; }

.total {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
}

/* ---------- admin ---------- */

.admin-shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
}

.admin-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: -1px;
  overflow-x: auto;
}

.admin-tab {
  background: transparent;
  border: 1px solid var(--panel-line);
  color: var(--muted);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 0.6rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.admin-tab[aria-selected="true"] {
  background: var(--panel);
  color: var(--ice);
}

.admin-panel {
  display: none;
  border-top-left-radius: 0;
}

.admin-panel.active {
  display: block;
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.card h2 {
  font-size: 1.05rem;
  margin-bottom: 0.9rem;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

input[type="text"], input[type="password"], input[type="number"], select {
  background: var(--ink);
  border: 1px solid var(--panel-line);
  color: var(--ice);
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  width: 100%;
}

input:focus, select:focus, button:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

button {
  background: var(--blue);
  border: none;
  color: var(--ice);
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
}
button:hover { background: #3d8bec; }
button.secondary { background: transparent; border: 1px solid var(--panel-line); color: var(--ice); }
button.secondary:hover { border-color: var(--muted); }
button.danger { background: var(--danger); }

.rock-choice {
  display: flex;
  gap: 0.75rem;
}
.rock-choice label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ice);
  font-size: 0.9rem;
  cursor: pointer;
}
.rock-choice input { width: auto; }

.matchup-grid {
  display: grid;
  gap: 0.5rem;
}

.matchup-row {
  display: grid;
  grid-template-columns: 5rem 1fr 1fr 8rem auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.4rem;
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
}

.matchup-row .slot-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.draw-time-row {
  display: grid;
  grid-template-columns: 5rem 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.4rem;
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
}

.ends-editor {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.end-field {
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  padding: 0.5rem;
}

.end-field .end-num {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.status-msg {
  font-size: 0.85rem;
  margin-top: 0.6rem;
}
.status-msg.ok { color: #6fc98a; }
.status-msg.err { color: var(--danger); }

.login-shell {
  max-width: 360px;
  margin: 4rem auto;
  padding: 0 1rem;
}
