:root {
  /* Portrush Hockey Club — amber, black, white, Red Hand red */
  --amber:       #f2a03d;
  --amber-deep:  #d27d16;
  --amber-tint:  #fdf0db;
  --red:         #e2231a;
  --red-tint:    #fde7e5;
  --paper:       #faf7f1;
  --card:        #ffffff;
  --ink:         #1a1a1a;
  --muted:       #7c746a;
  --line:        #e7e1d6;

  /* role aliases used throughout the components */
  --pitch:       #1a1a1a;   /* primary action / header base = club black */
  --pitch-deep:  #000000;
  --pitch-line:  rgba(242,160,61,.14);
  --accent:      #f2a03d;   /* amber accent line under header / active tabs */
  --in:          #b9791a;   /* "still in" = club amber-brown text */
  --in-bg:       #fdf0db;
  --out:         #cf1f17;   /* knocked out = Red Hand red */
  --out-bg:      #fde7e5;
  --pending:     #b06d00;
  --pending-bg:  #fbf1d8;
  --shadow:      0 1px 2px rgba(26,26,26,.06), 0 8px 24px rgba(26,26,26,.08);
  --radius:      14px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
a { color: var(--pitch); }
h1, h2, h3 { margin: 0; line-height: 1.05; letter-spacing: -.02em; }

/* ---------- Top banner (club black + amber) ---------- */
.topbar {
  background:
    radial-gradient(120% 160% at 85% -30%, rgba(242,160,61,.22), transparent 55%),
    linear-gradient(180deg, #232323 0%, #0b0b0b 120%);
  color: #fff;
  padding: 22px 0;
  border-bottom: 4px solid var(--amber);
}
.topbar .inner { max-width: 1100px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; row-gap: 12px; }
.topbar .inner.admin-bar { justify-content: space-between; }
.crest {
  flex: 0 0 auto; width: 76px; height: 76px; border-radius: 14px; background: #fff;
  display: flex; align-items: center; justify-content: center; padding: 7px;
  box-shadow: 0 4px 14px rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.6);
}
.crest img { width: 100%; height: 100%; object-fit: contain; display: block; }
.title-block { min-width: 0; }
.eyebrow {
  text-transform: uppercase; letter-spacing: .22em; font-size: 11px; font-weight: 700;
  color: var(--amber); margin-bottom: 6px;
}
.topbar h1 {
  font-size: clamp(24px, 5vw, 42px); font-weight: 850; text-transform: uppercase;
  color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.35);
}
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.stat {
  background: rgba(242,160,61,.14); border: 1px solid rgba(242,160,61,.3);
  border-radius: 999px; padding: 7px 15px; display: flex; align-items: baseline; gap: 8px;
}
.stat b { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--amber); }
.stat span { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.82); }
.stat.alert { background: var(--red); border-color: var(--red); }
.stat.alert b, .stat.alert span { color: #fff; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 26px 20px 60px; }

/* ---------- Standings board ---------- */
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin: 6px 0 20px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; vertical-align: -1px; margin-right: 6px; }

.row {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 12px;
  display: grid; grid-template-columns: 1fr auto; gap: 12px 16px; align-items: center;
}
.row .who { min-width: 0; }
.row .name { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.row .note { color: var(--muted); font-size: 13px; }
.row .out-line { color: var(--out); font-size: 13px; font-weight: 600; margin-top: 2px; }
.row .in-line  { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* stamped status badge */
.badge {
  justify-self: end; font-weight: 850; text-transform: uppercase; letter-spacing: .04em;
  padding: 8px 16px; border-radius: 10px; font-size: 15px; border: 2px solid; white-space: nowrap;
}
.badge.in  { color: var(--in);  border-color: var(--in);  background: var(--in-bg); }
.badge.out { color: var(--out); border-color: var(--out); background: var(--out-bg);
  transform: rotate(-3deg); }

/* survival track */
.track { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; padding-top: 4px; }
.chip {
  --c: var(--line);
  border: 1.5px solid var(--c); border-radius: 9px; min-width: 60px; padding: 5px 8px;
  display: flex; flex-direction: column; gap: 1px; background: #fff;
}
.chip .gw { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.chip .team { font-size: 12.5px; font-weight: 700; line-height: 1.15; }
.chip.win     { --c: var(--in);  background: var(--in-bg); }
.chip.win .team { color: #0d7a45; }
.chip.lose    { --c: var(--out); background: var(--out-bg); }
.chip.lose .team { color: var(--out); }
.chip.pending { --c: var(--pending); background: var(--pending-bg); }
.chip.pending .team { color: #9a6a00; }
.chip.void { --c: #9aa6f0; background: #eef0fe; }
.chip.empty { opacity: .5; }
.chip.empty .team { color: var(--muted); font-weight: 600; font-style: italic; }

.empty-state { text-align: center; color: var(--muted); padding: 50px 20px; }
.footer-note { color: var(--muted); font-size: 12.5px; margin-top: 22px; text-align: center; }

/* ---------- Buttons / forms (shared with admin) ---------- */
button, .btn {
  font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  border: 1px solid var(--pitch); background: var(--pitch); color: #fff;
  padding: 9px 16px; border-radius: 10px; transition: filter .12s, background .12s;
}
button:hover, .btn:hover { filter: brightness(1.06); }
button.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
button.ghost:hover { background: #f6f6f1; filter: none; }
button.danger { background: #fff; color: var(--out); border-color: var(--out); }
button.danger:hover { background: var(--out-bg); filter: none; }
button:disabled { opacity: .45; cursor: not-allowed; filter: none; }

input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--pitch); outline-offset: 0; border-color: var(--pitch); }
code { font-family: var(--mono); font-size: 12.5px; background: var(--amber-tint); color: var(--amber-deep); padding: 1px 6px; border-radius: 6px; }
label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: block; margin-bottom: 5px; }

/* ---------- Admin layout ---------- */
.admin-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 22px 0 18px; border-bottom: 2px solid var(--line); }
.tab {
  background: none; border: none; color: var(--muted); font-weight: 700; padding: 10px 14px;
  border-bottom: 3px solid transparent; border-radius: 0; margin-bottom: -2px;
}
.tab:hover { filter: none; color: var(--ink); }
.tab.active { color: var(--pitch); border-bottom-color: var(--accent); }

.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card h3 { font-size: 16px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 14px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
td.num { font-variant-numeric: tabular-nums; }
.score-in { width: 56px; text-align: center; }

.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-form > div { flex: 1; min-width: 140px; }

.pill { display: inline-block; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 3px 9px; border-radius: 999px; }
.pill.win { color: var(--in); background: var(--in-bg); }
.pill.lose { color: var(--out); background: var(--out-bg); }
.pill.sched { color: var(--muted); background: #f0f1ec; }
.pill.auto { color: #5b63c9; background: #eef0fe; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .25s; z-index: 50;
  font-size: 14px; font-weight: 600; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--out); }

.login-wrap { max-width: 380px; margin: 12vh auto; }
.muted { color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.gw-meta { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.gw-meta b { color: var(--ink); }
.row-gap > * + * { margin-top: 10px; }

@media (max-width: 640px) {
  .row { grid-template-columns: 1fr; }
  .badge { justify-self: start; }
  .chip { min-width: 54px; flex: 1 0 auto; }
}

/* ---------- Public: anonymous summary + survivor list ---------- */
.summary-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.gw-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.gw-pill {
  background: #fff; color: var(--muted); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; font-weight: 800;
}
.gw-pill:hover { filter: none; background: #f6f6f1; color: var(--ink); }
.gw-pill.active { background: var(--pitch); color: #fff; border-color: var(--pitch); }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 170px) 1fr auto; align-items: center; gap: 12px; }
.bar-team { font-weight: 700; font-size: 14px; }
.bar-track { background: #eef0ea; border-radius: 999px; height: 16px; overflow: hidden; }
.bar-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--amber-deep), var(--amber));
  min-width: 6px; transition: width .4s ease;
}
.bar-count { font-variant-numeric: tabular-nums; font-weight: 800; min-width: 28px; text-align: right; }

.name-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.name-tag {
  display: flex; flex-direction: column; gap: 1px; padding: 8px 14px; border-radius: 11px;
  border: 1.5px solid; min-width: 0;
}
.name-tag .nm { font-weight: 800; font-size: 15px; letter-spacing: -.01em; }
.name-tag .sub { font-size: 11.5px; opacity: .8; }
.name-tag.in  { border-color: var(--amber); background: var(--amber-tint); color: var(--ink); }
.name-tag.in .sub { color: var(--amber-deep); }
.name-tag.out { border-color: var(--line); background: #f3f1ec; color: var(--muted); }

.login-crest { display: flex; justify-content: center; margin-bottom: 14px; }
.login-crest img { width: 92px; height: 92px; object-fit: contain; }

/* ---------- Locked (pre-start) summary ---------- */
.locked { display: flex; align-items: center; gap: 14px; padding: 18px; background: #f7f7f3; border: 1px dashed var(--line); border-radius: 12px; }
.lock-icon { font-size: 26px; }
.locked b { font-size: 15px; }
