:root {
  /* Theme taken from the logos: AMA red + Dotunnest orange, on warm white */
  --bg: #f7f5f3;          /* smoky white page background */
  --card: #ffffff;
  --surface: #faf7f5;     /* subtle panels (card heads, modal footer) */
  --tint: #fdf0ef;        /* light red tint */
  --tint-accent: #fff2eb; /* light orange tint */
  --text: #2e2a29;        /* charcoal - text only */
  --muted: #7a716e;
  --border: #ece5e2;
  --primary: #d7141a;     /* AMA red */
  --primary-dark: #b50f14;
  --accent: #f05a28;      /* Dotunnest orange */
  --accent-text: #c2410c;
  --danger: #c62828;
  --warn: #c2570c;
  --male: #c8161d;
  --female: #d9480f;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(80, 40, 30, .06), 0 4px 14px rgba(80, 40, 30, .05);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3, h4 { margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
[hidden] { display: none !important; }

.container { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }
.muted { color: var(--muted); }
.small { font-size: 12px; font-weight: normal; }
.nowrap { white-space: nowrap; }
.warn-text { color: var(--warn); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px;
  padding: 8px 14px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:disabled { opacity: .6; cursor: wait; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--tint-accent); color: var(--accent-text); border-color: #f6c3aa; }
.btn-accent:hover { background: #ffe6d9; border-color: var(--accent); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--tint); }

.icon-btn {
  border: 1px solid var(--border); background: #fff; border-radius: 6px;
  width: 28px; height: 28px; cursor: pointer; font-size: 14px; line-height: 1;
  color: var(--muted);
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  flex-wrap: wrap; margin-bottom: 18px;
}
.topbar p { margin: 4px 0 0; }
.topbar-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.count-card {
  display: grid; grid-template-columns: auto auto; column-gap: 10px; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 16px; box-shadow: var(--shadow);
}
.count-num { grid-row: span 2; font-size: 30px; font-weight: 700; color: var(--primary); }
.count-label { font-weight: 600; }
.count-split { font-size: 12px; color: var(--muted); }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px;
}
.card-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  flex-wrap: wrap; margin-bottom: 14px;
}
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- config ---------- */
.config-top { display: flex; gap: 28px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.inline-field { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hint {
  background: #fdf7f6; border: 1px dashed #f0c8c4; border-radius: 8px;
  padding: 8px 12px; color: #6b524d; font-size: 13px;
}
.empty-config { padding: 6px 0 12px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.switch input { display: none; }
.slider {
  width: 40px; height: 22px; background: #ddd4d0; border-radius: 22px; position: relative; transition: .2s;
}
.slider::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::after { left: 21px; }

.age-box {
  border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: 8px; padding: 12px; margin-bottom: 12px; background: #fffdfc;
}
.age-box-head { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.age-num {
  width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px;
  margin-bottom: 5px;
}
.age-tools { display: flex; gap: 4px; margin-left: auto; margin-bottom: 2px; }
.weight-list {
  margin: 10px 0 0 36px; padding-left: 12px; border-left: 2px dashed var(--border);
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
}
.weight-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; width: 100%; }
.weight-row .icon-btn { margin-bottom: 2px; }

.mini-field { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); font-weight: 600; }
.mini-field.grow { flex: 1 1 200px; }
.mini-field input { width: 110px; }
.mini-field.grow input { width: 100%; }

input, select, textarea {
  font: inherit; color: var(--text);
  border: 1px solid #ddd5d1; border-radius: 6px; padding: 6px 9px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #f8c9c7; border-color: var(--primary); }
input.invalid, textarea.invalid { border-color: var(--danger); }

.config-footer {
  display: flex; justify-content: flex-end; align-items: center; gap: 12px; flex-wrap: wrap;
  border-top: 1px solid var(--border); margin-top: 14px; padding-top: 14px;
}
.config-footer .errors { margin-right: auto; }
#configDirty { color: var(--warn); font-weight: 600; }
.errors {
  background: #fdeeee; color: var(--danger); border: 1px solid #f3c4c4; border-radius: 8px;
  padding: 8px 12px; font-size: 13px;
}

/* ---------- lists ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type="search"] { flex: 1 1 240px; max-width: 360px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.empty { padding: 30px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 8px; }

.gender-section { margin-bottom: 22px; }
.section-title {
  font-size: 17px; padding: 8px 12px; border-radius: 8px; margin-bottom: 12px;
  background: #f3efec;
}
.section-title.male { background: var(--tint); color: var(--male); border-left: 4px solid var(--male); }
.section-title.female { background: var(--tint-accent); color: var(--female); border-left: 4px solid var(--accent); }
.age-group { margin: 0 0 16px 6px; }
.age-group h4 { font-size: 15px; margin-bottom: 8px; }

.cat-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.cat-card { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.cat-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.cat-title { font-weight: 700; font-size: 14px; }
.cat-head-right { display: flex; align-items: center; gap: 8px; }
.cat-empty { padding: 10px 12px; }
.badge {
  background: var(--primary); color: #fff; font-weight: 700; font-size: 12px;
  border-radius: 20px; padding: 2px 10px; min-width: 28px; text-align: center;
}
.badge-warn { background: var(--warn); }
.unassigned .cat-card { border-color: #f6c9a6; }
.unassigned .cat-head { background: var(--tint-accent); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid #f2edea; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fff; }
tbody tr:hover { background: #fff8f7; }
tbody tr:last-child td { border-bottom: 0; }
td.sno { color: var(--muted); width: 36px; }
td.actions { width: 70px; text-align: right; }
td.actions .icon-btn { width: 26px; height: 26px; font-size: 12px; }
.g-dot {
  display: inline-block; font-size: 10px; font-weight: 700; color: #fff; border-radius: 4px;
  padding: 0 4px; margin-left: 4px; vertical-align: 1px;
}
.g-dot.male { background: var(--male); }
.g-dot.female { background: var(--female); }

/* ---------- modal ---------- */
dialog {
  border: 0; border-radius: 12px; padding: 0; width: min(640px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(80, 30, 20, .18);
}
dialog::backdrop { background: rgba(90, 60, 50, .28); backdrop-filter: blur(2px); }
.modal-head, .modal-foot { display: flex; align-items: center; gap: 10px; padding: 14px 18px; }
.modal-head { justify-content: space-between; border-bottom: 1px solid var(--border); }
.modal-head .icon-btn { font-size: 20px; border: 0; }
.modal-foot { justify-content: flex-end; border-top: 1px solid var(--border); background: var(--surface); }
.modal-foot .check { margin-right: auto; font-size: 13px; }
.modal-body { padding: 16px 18px; max-height: 70vh; overflow-y: auto; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
.field em { color: var(--danger); font-style: normal; }
.field input, .field textarea { font-weight: normal; width: 100%; }
.field textarea { resize: vertical; }
.span-2 { grid-column: span 2; }
.radio-row { display: flex; gap: 18px; padding: 6px 0; font-weight: normal; }
.radio-row label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.err { color: var(--danger); font-weight: normal; min-height: 0; }
.err:empty { display: none; }
#formError { margin-top: 12px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  padding: 10px 18px; border-radius: 8px; font-weight: 600;
  background: #fff; color: var(--text); border: 1px solid var(--border);
  box-shadow: var(--shadow); z-index: 1000;
}
.toast-ok { border-left: 4px solid var(--primary); }
.toast-err { border-left: 4px solid var(--danger); color: var(--danger); }

/* ---------- collapsible config ---------- */
details.card > summary { list-style: none; cursor: pointer; margin-bottom: 0; }
details.card > summary::-webkit-details-marker { display: none; }
details.card[open] > summary { margin-bottom: 14px; }
details.card:not([open]) > summary .row-actions { display: none; }
.chev { display: inline-block; transition: transform .15s; color: var(--muted); }
details[open] .chev { transform: rotate(90deg); }
details[open] .when-closed, details:not([open]) .when-open { display: none; }

/* =====================================================================
   Responsive
   ===================================================================== */

/* Grid/flex children must be allowed to shrink, otherwise wide tables
   push the whole page wider than the screen. */
.cat-grid { grid-template-columns: minmax(0, 1fr); }
.cat-card, .age-group, .gender-section, .card { min-width: 0; }
.cat-head > div:first-child { min-width: 0; }
.m-sno { display: none; }

/* Floating "add" button - phones only */
.fab {
  display: none; position: fixed; right: 18px; bottom: 18px; z-index: 900;
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--primary); color: #fff; font-size: 30px; line-height: 1;
  box-shadow: 0 6px 18px rgba(215, 20, 26, .35); cursor: pointer;
}
.fab:active { transform: scale(.95); }

/* Keep the list filters reachable while scrolling */
.toolbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--card); padding: 8px 0; margin-top: -8px;
}

/* Larger touch targets on touch devices */
@media (pointer: coarse) {
  .icon-btn, td.actions .icon-btn { width: 36px; height: 36px; font-size: 15px; }
  input, select, textarea { font-size: 16px; } /* prevents zoom-on-focus on iOS */
}

/* ---------- tablet ---------- */
@media (max-width: 1000px) {
  .container { padding: 16px 12px 80px; }
  .card { padding: 14px; }
  th, td { padding: 6px 8px; }
  .col-height { display: none; }
}

@media (max-width: 860px) {
  .col-school { display: none; }
  .topbar { align-items: stretch; }
  .topbar-actions { width: 100%; }
  .count-card { flex: 1 1 auto; }
  .topbar-actions .btn-lg { flex: 1 1 auto; justify-content: center; }
}

/* ---------- phone ---------- */
@media (max-width: 700px) {
  body { font-size: 14px; }
  h1 { font-size: 20px; }
  h2 { font-size: 16px; }
  .container { padding: 12px 10px 90px; }
  .card { padding: 12px; border-radius: 8px; }

  .fab { display: block; }

  .topbar { margin-bottom: 12px; gap: 10px; }
  .topbar-actions { gap: 10px; }
  .count-card { padding: 6px 12px; }
  .count-num { font-size: 24px; }
  .topbar-actions .btn-lg { padding: 10px 14px; font-size: 14px; }

  .card-head { gap: 8px; }
  .card-head .row-actions, .card-head .row-actions .btn { width: 100%; justify-content: center; }
  details.card > summary .row-actions .btn { width: auto; flex: 1; }

  /* filters: search full width, the rest on one line */
  .toolbar { gap: 8px; }
  .toolbar input[type="search"] { flex: 1 1 100%; max-width: none; }
  .toolbar select { flex: 1 1 auto; }

  /* config editor: stack fields */
  .config-top { flex-direction: column; align-items: flex-start; gap: 12px; }
  .age-box { padding: 10px; }
  .age-box-head {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  }
  .age-box-head .age-num { position: absolute; }
  .age-box { position: relative; padding-top: 38px; }
  .age-num { top: 8px; left: 10px; margin: 0; }
  .age-tools { position: absolute; top: 6px; right: 8px; margin: 0; }
  .age-box-head .mini-field.grow { grid-column: 1 / -1; }
  .mini-field input, .mini-field.grow input { width: 100%; }
  .weight-list { margin: 10px 0 0 4px; padding-left: 10px; }
  .weight-row {
    display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px 8px;
    padding-bottom: 8px; border-bottom: 1px dashed var(--border);
  }
  .weight-row .mini-field.grow { grid-column: 1 / -1; }
  .config-footer { justify-content: stretch; }
  .config-footer .btn { flex: 1; justify-content: center; }

  /* category lists */
  .section-title { font-size: 15px; padding: 6px 10px; }
  .age-group { margin-left: 0; }
  .cat-head { padding: 8px 10px; }

  /* tables become stacked participant cards */
  .table-wrap { overflow: visible; }
  table.ptable, .ptable tbody { display: block; }
  .ptable thead { display: none; }
  .ptable tbody tr {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 10px;
    position: relative; padding: 10px 10px 10px 12px; border-bottom: 1px solid #f2edea;
  }
  .ptable tbody tr:last-child { border-bottom: 0; }
  .ptable td { display: block; padding: 0; border: 0; min-width: 0; overflow-wrap: anywhere; }
  .ptable td[data-label]::before {
    content: attr(data-label); display: block;
    font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  }
  .ptable td.sno { display: none; }
  .ptable .m-sno { display: inline; color: var(--muted); font-weight: normal; }
  .ptable td.cell-name { grid-column: 1 / -1; font-size: 15px; padding-right: 84px; }
  .ptable td.cell-half { grid-column: span 2; }
  .ptable td.cell-full { grid-column: 1 / -1; }
  .ptable .col-height, .ptable .col-school { display: block; }
  .ptable td.actions { position: absolute; top: 8px; right: 8px; width: auto; display: flex; gap: 6px; }

  /* modal: near full-screen */
  dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  dialog[open] { display: flex; }
  dialog form { display: flex; flex-direction: column; width: 100%; }
  .modal-body { flex: 1; max-height: none; }
  .form-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .span-2, .field:has(textarea), .field:has(.radio-row) { grid-column: 1 / -1; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .check { width: 100%; }
  .modal-foot .btn { flex: 1; justify-content: center; }

  .toast { bottom: 86px; max-width: calc(100vw - 32px); }
}

/* very narrow phones */
@media (max-width: 380px) {
  .ptable tbody tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .topbar-actions { flex-direction: column; align-items: stretch; }
}
.field-label .muted { font-weight: normal; margin-left: 4px; }
.count-card { justify-content: start; }

/* ---------- brand header ---------- */
:root { --brand: var(--primary); }
.brandbar {
  background: #fff; border-bottom: 3px solid transparent;
  border-image: linear-gradient(90deg, var(--primary), var(--accent)) 1;
  box-shadow: 0 1px 6px rgba(80, 40, 30, .06);
}
.brandbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; }
.brand-logo { width: 56px; height: 56px; object-fit: contain; flex: none; }
.brand-name {
  color: var(--brand); font-weight: 800; font-size: 16px; letter-spacing: .04em;
  text-transform: uppercase; line-height: 1.15;
}
.powered { display: flex; align-items: center; gap: 8px; flex: none; color: var(--muted); }
.powered-by { font-size: 12px; }
.powered-logo { height: 30px; width: auto; }
.powered-name { font-weight: 700; color: var(--text); font-size: 15px; }

@media (max-width: 860px) {
  .brand-name { font-size: 14px; }
  .brand-logo { width: 46px; height: 46px; }
}
@media (max-width: 700px) {
  .brandbar-inner { padding: 8px 10px; gap: 10px; }
  .brand { gap: 8px; }
  .brand-logo { width: 40px; height: 40px; }
  .brand-name { font-size: 12px; letter-spacing: .02em; }
  .powered { flex-direction: column; gap: 0; text-align: center; }
  .powered-by { font-size: 9px; }
  .powered-logo { height: 22px; }
  .powered-name { font-size: 10px; }
}

/* theme details */
.g-dot.female { background: var(--accent); }
.badge { background: var(--tint); color: var(--primary-dark); border: 1px solid #f5c4c2; }
.badge-warn { background: var(--tint-accent); color: var(--warn); border-color: #f6c9a6; }
.count-card { border-top: 3px solid var(--primary); }
.age-box { border-left-color: var(--primary); }
.cat-card { border-top: 2px solid #f5d0ce; }

/* ---------- events master page ---------- */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-state h2 { margin-bottom: 6px; }
.empty-state .btn { margin-top: 12px; }

.event-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 14px; }
.event-card {
  display: flex; flex-direction: column; min-width: 0;
  background: #fff; border: 1px solid var(--border); border-top: 3px solid var(--primary);
  border-radius: var(--radius); box-shadow: var(--shadow); transition: box-shadow .15s, transform .15s;
}
.event-card:hover { box-shadow: 0 6px 22px rgba(160, 40, 30, .12); transform: translateY(-1px); }
.event-card-main { display: block; padding: 14px 14px 10px; color: inherit; text-decoration: none; flex: 1; }
.event-card-top { display: flex; gap: 12px; align-items: flex-start; }
.event-card-title { flex: 1; min-width: 0; }
.event-card-title h3 { font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
.date-chip {
  flex: none; width: 54px; text-align: center; border-radius: 8px; overflow: hidden;
  border: 1px solid #f3c9c7; background: var(--tint);
}
.date-day { display: block; font-size: 20px; font-weight: 800; color: var(--primary); padding-top: 4px; }
.date-mon { display: block; font-size: 10px; font-weight: 600; color: var(--primary-dark); padding-bottom: 4px; }
.status {
  flex: none; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 8px; border-radius: 20px; border: 1px solid;
}
.status-upcoming { color: var(--accent-text); background: var(--tint-accent); border-color: #f6c9a6; }
.status-today { color: #fff; background: var(--primary); border-color: var(--primary); }
.status-past { color: var(--muted); background: #f4f1ef; border-color: var(--border); }
.event-desc { margin: 8px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.event-stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 12px;
  background: var(--surface); border-radius: 8px; padding: 8px;
}
.event-stats div { text-align: center; min-width: 0; }
.event-stats b { display: block; font-size: 15px; color: var(--text); }
.event-stats span { display: block; font-size: 10px; color: var(--muted); line-height: 1.2; }
.event-card-actions {
  display: flex; align-items: center; gap: 6px; padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.event-card-actions .spacer { flex: 1; }

/* ---------- event page heading ---------- */
.event-heading { min-width: 0; }
.event-heading h1 { overflow-wrap: anywhere; }
.back-link {
  display: inline-block; margin-bottom: 4px; font-size: 13px; font-weight: 600;
  color: var(--primary); text-decoration: none;
}
.back-link:hover { text-decoration: underline; }
.event-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; }

@media (max-width: 700px) {
  .event-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- event tabs ---------- */
.tabs {
  display: flex; gap: 4px; margin: -4px 0 16px; border-bottom: 2px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.tab {
  padding: 10px 18px; font-weight: 700; color: var(--muted); text-decoration: none; white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -2px; border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--primary); background: var(--tint); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); background: #fff; }
.tab.disabled { cursor: not-allowed; opacity: .55; }
.tab.disabled:hover { color: var(--muted); background: none; }
.lock-chip {
  display: inline-block; vertical-align: middle; font-size: 12px; font-weight: 700;
  padding: 2px 10px; border-radius: 20px; background: var(--tint); color: var(--primary-dark); border: 1px solid #f5c4c2;
}

/* ---------- save / freeze bar ---------- */
.freeze-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.freeze-bar h2 { margin-bottom: 2px; }
.freeze-bar p { margin: 0 0 6px; }
.freeze-info { flex: 1 1 320px; min-width: 0; }
.freeze-bar.is-frozen { background: linear-gradient(90deg, var(--tint), #fff 70%); border-color: #f5c4c2; }
.progress { height: 6px; background: #f1ebe8; border-radius: 6px; overflow: hidden; margin: 6px 0; max-width: 420px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 6px; }
.freeze-counts { line-height: 1.6; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain:disabled { opacity: .7; }

.save-chip { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; border: 1px solid; white-space: nowrap; }
.save-chip.saved { color: #2f7d4f; background: #eef8f1; border-color: #bfe3cc; }
.save-chip.changed { color: var(--warn); background: var(--tint-accent); border-color: #f6c9a6; }
.save-chip.unsaved { color: var(--muted); background: #f6f3f1; border-color: var(--border); }
.cat-head-right { flex-wrap: wrap; justify-content: flex-end; }

/* ---------- event tree page ---------- */
.tree-actions-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.tree-actions-bar h2 { margin-bottom: 2px; }
.tree-actions-bar p { margin: 0; }
.tree-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.cat-nav { padding: 8px; position: sticky; top: 8px; max-height: calc(100vh - 16px); overflow-y: auto; }
.cat-nav-select { display: none; }
.cat-nav-group {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 10px 8px 4px;
}
.cat-nav-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 6px; text-decoration: none; color: var(--text); font-size: 13px;
  border-left: 3px solid transparent;
}
.cat-nav-item:hover { background: var(--tint); }
.cat-nav-item.active { background: var(--tint); border-left-color: var(--primary); font-weight: 700; }
.cat-nav-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-nav-meta { display: flex; align-items: center; gap: 6px; flex: none; }
.st { font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 20px; white-space: nowrap; border: 1px solid; }
.st-nodraw { color: var(--muted); background: #f6f3f1; border-color: var(--border); }
.st-single { color: var(--muted); background: #fff; border-color: var(--border); }
.st-drawn { color: var(--accent-text); background: var(--tint-accent); border-color: #f6c9a6; }
.st-progress { color: var(--primary-dark); background: var(--tint); border-color: #f5c4c2; }
.st-done { color: #2f7d4f; background: #eef8f1; border-color: #bfe3cc; }

.tree-panel { min-width: 0; }
.tree-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.tree-head h2 { overflow-wrap: anywhere; }
.edit-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--tint-accent); border: 1px solid #f6c9a6; border-radius: 8px; padding: 8px 12px; margin-bottom: 10px;
}
.edit-bar .spacer, .modal-foot .spacer { flex: 1; }
.zoom-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.zoom-bar #zoomLabel { min-width: 40px; text-align: center; }
.legend { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 2px solid; }
.lg-ready { border-color: var(--primary); background: #fff; }
.lg-done { border-color: var(--primary); background: var(--tint); }
.member-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 20px; background: #fff; border: 1px solid var(--border); color: var(--text); }

.tree-scroll {
  overflow: auto; border: 1px solid var(--border); border-radius: 8px;
  background: #fffdfc; padding: 16px 8px; max-height: 75vh;
}
.tree-canvas { width: max-content; min-width: 100%; }

/* top-down knockout tree (final on top, participants at the bottom) */
.tree { --line: #d9cfcb; --gap: 22px; }
.tree ul { display: flex; justify-content: center; position: relative; margin: 0; padding: var(--gap) 0 0; }
.tree > ul { padding-top: 0; }
.tree li { list-style: none; position: relative; flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; padding: var(--gap) 4px 0; }
.tree > ul > li { padding-top: 0; }
.tree li::before, .tree li::after {
  content: ""; position: absolute; top: 0; right: 50%; width: 50%; height: var(--gap);
  border-top: 2px solid var(--line);
}
.tree li::after { right: auto; left: 50%; border-left: 2px solid var(--line); }
.tree li:first-child::before, .tree li:last-child::after { border: 0 none; }
.tree li:last-child::before { border-right: 2px solid var(--line); border-radius: 0 6px 0 0; }
.tree li:first-child::after { border-radius: 6px 0 0 0; }
.tree > ul > li::before, .tree > ul > li::after { display: none; }
.tree ul ul::before {
  content: ""; position: absolute; top: 0; left: 50%; height: var(--gap); border-left: 2px solid var(--line);
}

.node {
  width: 112px; min-height: 42px; padding: 4px 7px; border-radius: 8px; background: #fff;
  border: 1.5px solid var(--border); display: flex; flex-direction: column; justify-content: center;
  text-align: center; font-size: 12px; line-height: 1.25; position: relative;
}
.node .nm { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node .sub { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node .lbl { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 2px; }
.node.leaf { border-color: #e7dcd8; background: #fff; }
.node.leaf.bye { border-style: dashed; color: var(--muted); background: transparent; }
.node.leaf.lost { opacity: .5; }
.node.bout { background: var(--surface); }
.node.bout.ready { cursor: pointer; border-color: var(--primary); background: #fff; }
.node.bout.ready:hover { box-shadow: 0 2px 10px rgba(215, 20, 26, .18); }
.node.bout.done { background: var(--tint); border-color: var(--primary); }
.node.bout.waiting { border-style: dashed; }
.node.bout.bye-bout { border-style: dashed; background: transparent; opacity: .75; }
.node .pick { font-weight: 700; color: var(--primary); }
.node.final { width: 140px; border-width: 2px; }
.node.leaf.byed { border-style: dashed; border-color: #e7dcd8; }
.node.final.done { background: linear-gradient(135deg, #fff4ec, var(--tint)); border-color: var(--accent); }
.tree.editing .node.bout { opacity: .55; }
.node.swappable { cursor: pointer; border-color: var(--accent); }
.node.swappable:hover { background: var(--tint-accent); }
.node.picked { background: var(--accent); border-color: var(--accent); color: #fff; }
.node.picked .sub { color: #fff; }
.node:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* winner dialog */
.winner-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.winner-opt {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start; text-align: left;
  font: inherit; padding: 12px; border-radius: 10px; cursor: pointer; background: #fff;
  border: 2px solid var(--border); min-width: 0;
}
.winner-opt .nm { font-weight: 700; font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.winner-opt .sub { font-size: 12px; color: var(--muted); }
.winner-opt .corner { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.winner-opt.corner-red .corner { color: var(--primary); }
.winner-opt.corner-blue .corner { color: #3563c9; }
.winner-opt:hover { border-color: var(--primary); background: var(--tint); }
.winner-opt.selected { border-color: var(--primary); background: var(--tint); }
.winner-opt .tick { font-size: 11px; font-weight: 700; color: var(--primary); }

@media (max-width: 900px) {
  .tree-layout { grid-template-columns: minmax(0, 1fr); }
  .cat-nav { position: static; max-height: none; padding: 10px; }
  .cat-nav-list { display: none; }
  .cat-nav-select { display: flex; flex-direction: column; gap: 4px; }
  .cat-nav-select select { width: 100%; }
}
@media (max-width: 700px) {
  .tabs { margin-top: 0; }
  .tab { padding: 8px 12px; flex: 1; text-align: center; }
  .freeze-bar .row-actions, .tree-actions-bar .row-actions { width: 100%; }
  .freeze-bar .row-actions .btn, .tree-actions-bar .row-actions > * { flex: 1; justify-content: center; }
  .tree-head .row-actions { width: 100%; }
  .winner-options { grid-template-columns: 1fr; }
  .legend { display: none; }
}

/* print the selected tree only */
@media print {
  @page { size: landscape; margin: 10mm; }
  body { background: #fff; }
  .no-print, .tabs, .topbar-actions, .back-link, .zoom-bar, .fab, .toast { display: none !important; }
  .container { max-width: none; padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .tree-layout { display: block; }
  .tree-scroll { overflow: visible; max-height: none; border: 0; padding: 0; }
  .tree-canvas { zoom: 1 !important; }
  .brandbar { box-shadow: none; }
}

/* =====================================================================
   Live rings bar
   ===================================================================== */
:root { --blue-corner: #2f5fc4; --blue-tint: #eef3fd; }
.live-bar { padding: 12px 14px; }
.live-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.live-title { font-weight: 800; font-size: 15px; display: inline-flex; align-items: center; gap: 6px; }
.ring-count { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.ring-count b { min-width: 18px; text-align: center; color: var(--text); }
.dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--primary); display: inline-block;
  animation: pulse 1.4s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.ring-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 10px; }
.ring-card {
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: #fff; min-width: 0;
}
.ring-card.clickable { cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.ring-card.clickable:hover { border-color: var(--primary); box-shadow: 0 3px 12px rgba(215, 20, 26, .12); }
.ring-card.live { border-color: #f3b9b6; border-top: 3px solid var(--primary); }
.ring-card.idle { background: var(--surface); }
.ring-top { display: flex; align-items: center; gap: 8px; }
.ring-name { font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.ring-state { font-size: 10px; font-weight: 800; letter-spacing: .06em; border-radius: 20px; padding: 1px 8px; display: inline-flex; align-items: center; gap: 4px; }
.ring-state.on { color: var(--primary); background: var(--tint); }
.ring-state.free { color: var(--muted); background: #fff; border: 1px solid var(--border); }
.ring-timer {
  margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 800; font-size: 16px;
  padding: 1px 8px; border-radius: 6px; background: #f4f0ee;
}
.ring-timer.running { background: var(--tint); color: var(--primary-dark); }
.ring-timer.timeup { background: var(--primary); color: #fff; animation: pulse 1s infinite; }
.ring-cat { margin: 4px 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ring-idle { margin-top: 6px; }
.ring-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.ring-row + .ring-row { border-top: 1px dashed var(--border); }
.corner-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.ring-row.red .corner-dot { background: var(--primary); }
.ring-row.blue .corner-dot { background: var(--blue-corner); }
.ring-nm { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ring-sc { font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; min-width: 28px; text-align: right; }
.ring-row.red .ring-sc { color: var(--primary); }
.ring-row.blue .ring-sc { color: var(--blue-corner); }

/* live / decided nodes in the tree */
.node.bout.live { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(215, 20, 26, .15); cursor: pointer; }
.node.bout.live .lbl { color: var(--primary); }
.node .sc { display: flex; justify-content: center; align-items: center; gap: 6px; font-size: 16px; font-variant-numeric: tabular-nums; }
.node .sc .r { color: var(--primary); }
.node .sc .b { color: var(--blue-corner); }
.node.bout.done { cursor: pointer; }
.lg-live { border-color: var(--primary); background: var(--primary); }

/* =====================================================================
   Bout dialog
   ===================================================================== */
.vs-line {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  font-weight: 800; font-size: 16px; margin-bottom: 12px; text-align: center;
}
.vs-line .vs { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.vs-red { color: var(--primary); }
.vs-blue { color: var(--blue-corner); }
.bout-section h3 { font-size: 14px; margin-bottom: 8px; }
.bout-section .form-grid { margin-bottom: 10px; }
.bout-section .field select { width: 100%; }
.bout-section > .field { margin-bottom: 10px; }
.or-sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 14px 0; }
.or-sep::before, .or-sep::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.winner-opt.corner-blue:hover, .winner-opt.corner-blue.selected { border-color: var(--blue-corner); background: var(--blue-tint); }
.winner-opt.corner-blue .corner { color: var(--blue-corner); }

/* =====================================================================
   Scoring panel
   ===================================================================== */
dialog.score-panel {
  width: min(1100px, calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 24px);
  border-radius: 14px; padding: 0; overflow: auto;
}
.sp-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.sp-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 600; min-width: 0; }
.ring-pill { background: var(--primary); color: #fff; font-weight: 800; border-radius: 20px; padding: 3px 12px; text-transform: uppercase; letter-spacing: .04em; font-size: 13px; }
.sp-head .icon-btn { font-size: 22px; width: 36px; height: 36px; }

.sp-body { display: grid; grid-template-columns: 1fr minmax(220px, 280px) 1fr; }
.sp-side { padding: 16px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; min-width: 0; }
.sp-side.red { background: linear-gradient(180deg, var(--tint), #fff 70%); border-right: 1px solid var(--border); }
.sp-side.blue { background: linear-gradient(180deg, var(--blue-tint), #fff 70%); border-left: 1px solid var(--border); }
.sp-corner { font-size: 12px; font-weight: 800; letter-spacing: .12em; }
.sp-side.red .sp-corner { color: var(--primary); }
.sp-side.blue .sp-corner { color: var(--blue-corner); }
.sp-name { font-size: 20px; font-weight: 800; max-width: 100%; overflow-wrap: anywhere; }
.sp-club { font-size: 12px; color: var(--muted); min-height: 16px; }
.sp-score { font-size: 96px; line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; margin: 8px 0 12px; }
.sp-side.red .sp-score { color: var(--primary); }
.sp-side.blue .sp-score { color: var(--blue-corner); }
.sp-score.bump { animation: bump .25s; }
@keyframes bump { 50% { transform: scale(1.12); } }
.sp-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; max-width: 280px; }
.sp-btns button {
  font: inherit; font-size: 20px; font-weight: 800; padding: 12px 0; border-radius: 10px; cursor: pointer;
  border: 2px solid; background: #fff; touch-action: manipulation;
}
.sp-side.red .sp-btns button { border-color: var(--primary); color: var(--primary); }
.sp-side.red .sp-btns button:hover { background: var(--primary); color: #fff; }
.sp-side.blue .sp-btns button { border-color: var(--blue-corner); color: var(--blue-corner); }
.sp-side.blue .sp-btns button:hover { background: var(--blue-corner); color: #fff; }
.sp-btns button.minus { grid-column: 1 / -1; font-size: 15px; padding: 7px 0; border-width: 1px; opacity: .8; }
.sp-btns button:active { transform: scale(.96); }

.sp-center { padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; justify-content: center; }
.sp-timer {
  font-size: 64px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1;
  padding: 10px 18px; border-radius: 14px; background: #f4f0ee; min-width: 200px; text-align: center;
}
.sp-timer.running { background: var(--tint); color: var(--primary-dark); }
.sp-timer.timeup { background: var(--primary); color: #fff; animation: pulse 1s infinite; }
.sp-timer-state { color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.sp-play { font-size: 18px; padding: 12px 28px; min-width: 170px; justify-content: center; }
.sp-timer-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.sp-set { display: flex; gap: 6px; align-items: center; }
.sp-set input { width: 80px; text-align: center; }

.sp-foot {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface);
}
.sp-judge { flex: 1 1 240px; }
.sp-judge input { width: 100%; }
.sp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sp-foot .errors { flex-basis: 100%; }

@media (max-width: 860px) {
  .sp-body { grid-template-columns: 1fr 1fr; }
  .sp-center { grid-column: 1 / -1; grid-row: 1; flex-direction: row; flex-wrap: wrap; justify-content: center; border-bottom: 1px solid var(--border); }
  .sp-timer { font-size: 44px; min-width: 150px; }
  .sp-score { font-size: 64px; }
  .sp-side.red { border-right: 1px solid var(--border); }
  .sp-side.blue { border-left: 0; }
}
@media (max-width: 700px) {
  dialog.score-panel { width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .sp-side { padding: 10px 8px; }
  .sp-name { font-size: 16px; }
  .sp-score { font-size: 52px; margin: 4px 0 8px; }
  .sp-btns { gap: 6px; }
  .sp-btns button { font-size: 18px; padding: 10px 0; }
  .sp-play { min-width: 0; padding: 10px 18px; }
  .sp-actions { width: 100%; }
  .sp-actions .btn { flex: 1 1 45%; justify-content: center; }
  .ring-count { margin-left: 0; }
}

@media (max-width: 700px) {
  dialog.score-panel[open], #boutModal[open] { display: block; overflow-y: auto; }
}

/* =====================================================================
   Admin area
   ===================================================================== */
.admin-pill {
  display: inline-block; background: var(--text); color: #fff; font-weight: 800; font-size: 11px;
  letter-spacing: .08em; text-transform: uppercase; padding: 3px 10px; border-radius: 20px; text-decoration: none;
}
.admin-bar { background: #fff; border-bottom: 1px solid var(--border); }
.admin-bar-inner {
  max-width: 1280px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.admin-bar .spacer, .toolbar .spacer, .admin-list-head .spacer { flex: 1; }
.admin-bar form { margin: 0; }
.admin-crumbs { display: flex; gap: 6px; align-items: center; color: var(--muted); min-width: 0; }
.admin-crumbs a { color: var(--primary); text-decoration: none; font-weight: 600; }

.login-card { max-width: 400px; margin: 40px auto; display: flex; flex-direction: column; gap: 14px; }
.login-head h1 { margin: 8px 0 2px; }
.login-card .btn-lg { justify-content: center; }
.login-card .back-link { text-align: center; }

.tab-panel { margin-bottom: 18px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.admin-grid h2 { margin-bottom: 6px; }
.mt { margin-top: 18px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.danger-text { color: var(--danger) !important; }
.btn-danger { background: #fff; color: var(--danger); border-color: #f1b7b7; }
.btn-danger:hover { background: #fdeeee; border-color: var(--danger); }
.hint-card { background: #fdf7f6; border-style: dashed; color: #6b524d; font-size: 13px; }

.admin-table th { white-space: nowrap; }
.admin-table td { vertical-align: middle; }
.admin-table select { max-width: 220px; }
.admin-list { padding: 12px 14px; }
.admin-list-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.admin-list-head .list-title { flex: 1 1 260px; font-weight: 700; }
.admin-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.admin-add select { max-width: 340px; }
.draw-panel .card { padding: 14px; }
.draw-editor { margin: 6px 0 14px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; background: var(--surface); }
.draw-editor summary { cursor: pointer; }
.draw-editor select { width: 100%; }
.bouts-table .row-live { background: var(--tint); }
.corner-red-text { color: var(--primary); font-weight: 600; }
.corner-blue-text { color: var(--blue-corner); font-weight: 600; }

@media (max-width: 900px) {
  .admin-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .admin-table { font-size: 13px; }
  #boutDialog[open], #personDialog[open] { display: flex; }
}
.table-wrap.admin-wrap { overflow-x: auto !important; }
#boutDialog .radio-row { flex-direction: column; gap: 8px; }
.radio-row input[type="radio"] { width: auto; flex: none; margin: 0; }
.radio-row label { justify-content: flex-start; }

/* =====================================================================
   Results (podium per category)
   ===================================================================== */
.res-group { margin-bottom: 18px; }
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 12px; }
.res-card {
  border: 1px solid var(--border); border-radius: 10px; background: #fff; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px; min-width: 0; break-inside: avoid;
}
.res-card.decided { border-top: 3px solid var(--accent); }
.res-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.res-title { font-weight: 800; font-size: 15px; }
.res-empty, .res-note { padding-top: 2px; }
.podium { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.place {
  display: grid; grid-template-columns: 28px 34px minmax(0, 1fr); align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border);
}
.place .medal { font-size: 20px; line-height: 1; }
.place-label { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; }
.place-who { display: flex; flex-direction: column; min-width: 0; }
.place-who b, .place-who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place.gold { background: #fff8e6; border-color: #f3d98b; }
.place.silver { background: #f6f6f7; border-color: #dcdde1; }
.place.bronze { background: #fdf1e8; border-color: #ecc6a6; }
.place.tbd { background: #fff; border-style: dashed; }
.place.tbd .medal { opacity: .4; }

@media print {
  .res-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .res-card { border-color: #ccc; }
  .toolbar, .card-head .row-actions { display: none !important; }
}

/* =====================================================================
   Confirmation dialog (App.ask)
   ===================================================================== */
dialog.ask-dialog { width: min(460px, calc(100vw - 32px)); border-radius: 14px; }
dialog.ask-dialog::backdrop { background: rgba(90, 60, 50, .35); backdrop-filter: blur(2px); }
.ask-body { display: flex; gap: 14px; padding: 20px 20px 8px; }
.ask-icon {
  flex: none; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px; background: var(--tint-accent); color: var(--accent-text);
}
.ask-dialog.danger .ask-icon { background: #fdeaea; color: var(--danger); }
.ask-text { min-width: 0; flex: 1; }
.ask-title { font-size: 17px; line-height: 1.35; overflow-wrap: anywhere; }
.ask-msg { margin: 6px 0 0; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.ask-type { margin-top: 12px; }
.ask-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 14px 20px 18px; }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #a91f1f; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 700px) {
  dialog.ask-dialog[open] { display: block; width: calc(100vw - 24px); height: fit-content; max-height: calc(100dvh - 24px); margin: auto; border-radius: 14px; }
  .ask-foot .btn { flex: 1; justify-content: center; }
}

/* =====================================================================
   Step guide (event progress)
   ===================================================================== */
.steps {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden;
}
.steps-list {
  list-style: none; margin: 0; padding: 10px 8px 4px; display: flex; gap: 0;
  overflow-x: auto; scrollbar-width: thin;
}
.step { flex: 1 0 auto; position: relative; min-width: 110px; }
.step + .step::before {
  content: ""; position: absolute; top: 19px; left: -50%; right: 50%; height: 2px; background: var(--border); z-index: 0;
}
.step.done + .step::before, .step.done + .step.current::before { background: var(--primary); }
.step a {
  position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-decoration: none; color: inherit; padding: 2px 6px 6px; border-radius: 8px; text-align: center;
}
.step a:hover .step-label { color: var(--primary); }
.step-num {
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; background: #fff; border: 2px solid var(--border); color: var(--muted);
}
.step.done .step-num { background: var(--primary); border-color: var(--primary); color: #fff; }
.step.current .step-num { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 4px var(--tint); }
.step-text { display: flex; flex-direction: column; line-height: 1.2; }
.step-label { font-weight: 700; font-size: 13px; white-space: nowrap; }
.step.todo .step-label { color: var(--muted); }
.step-detail { font-size: 11px; color: var(--muted); white-space: nowrap; }
.step-next {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; background: var(--tint); border-top: 1px solid #f5d4d2; font-size: 14px;
}
.step-next.all-done { background: #eef8f1; border-top-color: #bfe3cc; }
.step-next-text { min-width: 0; flex: 1 1 260px; }

/* =====================================================================
   Up next (ready bouts)
   ===================================================================== */
.up-next { padding: 12px 14px; }
.up-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.up-title { font-weight: 800; font-size: 15px; }
.up-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 8px; }
.up-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); min-width: 0;
}
.up-info { flex: 1; min-width: 0; }
.up-cat { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-vs { display: flex; align-items: baseline; gap: 6px; font-weight: 700; min-width: 0; }
.up-vs .vs-red, .up-vs .vs-blue { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.up-vs .vs { font-size: 10px; color: var(--muted); text-transform: uppercase; flex: none; }
.up-more { margin-top: 8px; }

@media (max-width: 700px) {
  .step { min-width: 92px; }
  .step-next .btn { width: 100%; justify-content: center; }
}

/* =====================================================================
   Accounts & roles
   ===================================================================== */
.app-bar { background: #fff; border-bottom: 1px solid var(--border); }
.app-bar-inner {
  max-width: 1280px; margin: 0 auto; padding: 6px 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.app-bar .spacer { flex: 1; }
.app-bar form { margin: 0; }
.app-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.app-nav a { color: var(--text); font-weight: 700; text-decoration: none; padding: 5px 10px; border-radius: 6px; }
.app-nav a:hover { background: var(--tint); color: var(--primary); }
.who { display: inline-flex; align-items: center; gap: 6px; }

.role-chip {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 20px; border: 1px solid; white-space: nowrap; vertical-align: middle;
}
.role-judge { color: #2f5fc4; background: #eef3fd; border-color: #c8d6f5; }
.role-admin { color: var(--accent-text); background: var(--tint-accent); border-color: #f6c9a6; }
.role-super_admin { color: #fff; background: var(--primary); border-color: var(--primary); }
.role-display { color: #6b4fbb; background: #f3effc; border-color: #d9cdf4; }
.role-jury { color: #1f7a5a; background: #eaf7f1; border-color: #bfe6d4; }

.role-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 12px; margin-bottom: 16px; }
.role-card {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
}
.role-count { font-size: 13px; }
tr.row-off td { opacity: .55; }
.narrow-card { max-width: 480px; display: flex; flex-direction: column; gap: 12px; }
.login-help { text-align: center; margin: 0; }
.step-next.not-mine { background: var(--surface); border-top-color: var(--border); }

@media (max-width: 700px) {
  .app-bar-inner { padding: 6px 10px; gap: 6px; }
  .who { flex-basis: 100%; order: -1; }
  #userDialog[open], #pwDialog[open] { display: flex; }
}

/* =====================================================================
   Login page
   ===================================================================== */
body.auth-page { background: var(--bg); min-height: 100vh; }
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }

/* brand side: light, with the logo colours as accents */
.auth-brand {
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center;
  padding: 48px 40px;
  background:
    radial-gradient(circle at 15% 15%, rgba(240, 90, 40, .10), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(215, 20, 26, .10), transparent 50%),
    linear-gradient(160deg, #fff 0%, #fdf3f1 100%);
  border-right: 1px solid var(--border);
}
.auth-brand::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}
.auth-brand-inner { position: relative; z-index: 1; max-width: 440px; text-align: center; }
.auth-logo { width: 150px; height: 150px; object-fit: contain; filter: drop-shadow(0 8px 24px rgba(215, 20, 26, .18)); }
.auth-org {
  margin: 22px 0 10px; color: var(--primary); font-size: 28px; line-height: 1.15; font-weight: 800;
  letter-spacing: .04em; text-transform: uppercase;
}
.auth-tagline { margin: 0 auto 26px; color: #6b524d; font-size: 15px; max-width: 360px; }
.auth-points { list-style: none; padding: 0; margin: 0; display: inline-flex; flex-direction: column; gap: 10px; text-align: left; }
.auth-points li { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--text); }
.auth-dot { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--accent)); flex: none; }
.auth-ring { position: absolute; border-radius: 50%; border: 2px solid rgba(215, 20, 26, .08); pointer-events: none; }
.auth-ring-1 { width: 520px; height: 520px; top: -180px; right: -200px; }
.auth-ring-2 { width: 380px; height: 380px; bottom: -160px; left: -140px; border-color: rgba(240, 90, 40, .10); }

/* form side */
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px 24px; gap: 28px; }
.auth-card {
  width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--border); border-radius: 16px;
  padding: 32px 30px 26px; box-shadow: 0 2px 6px rgba(80, 40, 30, .05), 0 18px 48px rgba(80, 40, 30, .08);
  display: flex; flex-direction: column; gap: 16px;
}
.auth-logo-sm { display: none; width: 64px; height: 64px; margin: 0 auto -4px; }
.auth-head h2 { font-size: 24px; margin: 0 0 4px; }
.auth-head p { margin: 0; font-size: 14px; }

.auth-error {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  background: #fdeeee; border: 1px solid #f3c4c4; color: var(--danger); font-size: 13px; font-weight: 600;
}
.auth-error span {
  flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--danger); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800;
}

.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-label { font-size: 13px; font-weight: 700; }
.auth-input {
  display: flex; align-items: center; gap: 8px; border: 1.5px solid #e4dbd7; border-radius: 10px;
  padding: 0 6px 0 12px; background: #fff; transition: border-color .15s, box-shadow .15s;
}
.auth-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(215, 20, 26, .10); }
.auth-input svg { width: 18px; height: 18px; fill: #b9aca8; flex: none; }
.auth-input:focus-within svg { fill: var(--primary); }
.auth-input input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 12px 0; font-size: 15px;
}
.auth-input input:focus { outline: 0; border: 0; }
.auth-eye {
  border: 0; background: transparent; color: var(--primary); font: inherit; font-size: 12px; font-weight: 700;
  padding: 6px 8px; border-radius: 6px; cursor: pointer;
}
.auth-eye:hover { background: var(--tint); }
.auth-caps { font-size: 12px; font-weight: 600; color: var(--warn); }

.auth-submit {
  margin-top: 4px; border: 0; border-radius: 10px; padding: 13px 16px; font: inherit; font-size: 15px; font-weight: 700;
  color: #fff; cursor: pointer; background: linear-gradient(90deg, var(--primary), #e5361f);
  box-shadow: 0 6px 18px rgba(215, 20, 26, .25); transition: transform .1s, box-shadow .15s, filter .15s;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.auth-submit:hover { filter: brightness(1.04); box-shadow: 0 8px 22px rgba(215, 20, 26, .32); }
.auth-submit:active { transform: translateY(1px); }
.auth-submit:disabled { cursor: wait; opacity: .85; }
.auth-submit.loading::before {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.auth-help { text-align: center; margin: 2px 0 0; }

.auth-foot { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.auth-foot-logo { height: 22px; }
.auth-foot b { color: var(--text); }

.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-brand { display: none; }
  .auth-logo-sm { display: block; }
  .auth-main { min-height: 100vh; padding: 28px 16px 20px; background:
    radial-gradient(circle at 10% 0%, rgba(240, 90, 40, .08), transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(215, 20, 26, .08), transparent 45%); }
  .auth-card { padding: 26px 20px 22px; }
  .auth-head { text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  .shake, .auth-submit.loading::before { animation: none; }
}
.auth-org-sm { display: none; text-align: center; color: var(--primary); font-weight: 800; font-size: 13px; letter-spacing: .05em; text-transform: uppercase; margin-top: -6px; }
@media (max-width: 900px) { .auth-org-sm { display: block; } }

/* =====================================================================
   Point systems
   ===================================================================== */
.ps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 14px; }
.ps-card {
  background: #fff; border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.ps-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.ps-card-head h3 { font-size: 16px; }
.ps-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; background: var(--surface); border-radius: 8px; padding: 8px; }
.ps-facts div { text-align: center; }
.ps-facts b { display: block; font-size: 15px; }
.ps-facts span { font-size: 10px; color: var(--muted); }
.ps-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ps-chips .chip b { color: var(--primary); }
.ps-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 10px; }
.ps-actions .spacer { flex: 1; }

dialog.ps-dialog { width: min(820px, calc(100vw - 24px)); }
.ps-dialog .modal-body { max-height: 74vh; }
.ps-sec { border-top: 1px dashed var(--border); margin-top: 14px; padding-top: 12px; }
.ps-sec h3 { font-size: 14px; margin-bottom: 8px; }
.ps-sec textarea { width: 100%; }
.ps-rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.ps-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ps-row > input:not(.ps-num) { flex: 1 1 200px; min-width: 0; }
.ps-row .ps-note { flex: 1 1 160px; }
.ps-num { width: 70px; }
.ps-inline { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; white-space: nowrap; }
.ps-step { font-weight: 800; color: var(--muted); width: 22px; }
#psPreview { margin: 8px 0 0; background: var(--surface); border-radius: 6px; padding: 6px 10px; }
#psPreview:empty { display: none; }

.ps-tag {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 4px;
  color: var(--accent-text); background: var(--tint-accent); border: 1px solid #f6c9a6; border-radius: 20px;
  padding: 1px 9px; font-weight: 700; font-size: 12px; width: fit-content;
}
.ps-tag-btn { font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; margin-top: 0; }
.ps-tag-btn:hover { border-color: var(--accent); }

/* rule sheet */
dialog.rules-dialog { width: min(680px, calc(100vw - 24px)); }
.rules-dialog .modal-head { gap: 8px; }
.rules-dialog .modal-head .spacer { flex: 1; }
.rules-dialog .modal-body { max-height: 76vh; }
.rules-dialog h3 { font-size: 14px; margin: 16px 0 6px; color: var(--primary-dark); }
.rules-dialog h3:first-of-type { margin-top: 10px; }
.rules-facts { display: flex; flex-wrap: wrap; gap: 8px; }
.rules-facts span { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px; font-size: 12px; }
.rules-tags { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.rules-tags li { background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px; font-size: 13px; }
.rules-table { width: 100%; border-collapse: collapse; }
.rules-table td { padding: 7px 8px; border-bottom: 1px solid #f2edea; }
.rules-table .pts { text-align: right; white-space: nowrap; font-weight: 700; }
.rules-notes { white-space: pre-line; font-size: 13px; background: var(--surface); border-radius: 8px; padding: 10px 12px; }

/* =====================================================================
   Scoring panel: rules-driven buttons
   ===================================================================== */
.sp-tech { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; width: 100%; max-width: 340px; }
.sp-tech-btn {
  display: flex; align-items: center; gap: 8px; text-align: left; font: inherit; cursor: pointer;
  border: 2px solid; border-radius: 10px; background: #fff; padding: 7px 9px; min-height: 48px; touch-action: manipulation;
}
.sp-tech-pts { font-size: 18px; font-weight: 800; flex: none; min-width: 26px; }
.sp-tech-label { font-size: 12px; font-weight: 600; line-height: 1.2; }
.sp-side.red .sp-tech-btn { border-color: #f1b3b1; color: var(--primary-dark); }
.sp-side.red .sp-tech-btn:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.sp-side.blue .sp-tech-btn { border-color: #bccdf2; color: var(--blue-corner); }
.sp-side.blue .sp-tech-btn:hover { background: var(--blue-corner); border-color: var(--blue-corner); color: #fff; }
.sp-tech-btn:active { transform: scale(.97); }

.sp-penalty { width: 100%; max-width: 340px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.sp-warn-info { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-bottom: 6px; }
.sp-warn-count { font-weight: 700; font-size: 13px; }
.sp-warn-next { color: var(--muted); }
.sp-pen-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.sp-warn-btn { background: #fff8e6; border-color: #f3d98b; color: #8a5a00; font-weight: 700; }
.sp-warn-btn:hover { background: #ffefc2; }
.sp-exit-btn { background: var(--tint-accent); border-color: #f6c9a6; color: var(--accent-text); font-weight: 700; }
.sp-last { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 8px; text-align: center; }
.sp-rules { text-align: center; max-width: 260px; margin-top: 6px; }

dialog.foul-dialog { width: min(480px, calc(100vw - 24px)); }
.foul-next { background: #fff8e6; border: 1px solid #f3d98b; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.foul-next.is-dq { background: #fdeaea; border-color: #f1b7b7; color: var(--danger); }
.foul-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.foul-btn { justify-content: center; text-align: center; white-space: normal; min-height: 44px; }

@media (max-width: 700px) {
  .sp-tech { grid-template-columns: minmax(0, 1fr); }
  .sp-tech-btn { min-height: 42px; padding: 6px 8px; }
  .foul-grid { grid-template-columns: 1fr; }
  #foulDialog[open], #rulesDialog[open], #psDialog[open] { display: block; overflow-y: auto; }
  .ps-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* =====================================================================
   Header: navigation + account menu
   ===================================================================== */
.app-bar { position: sticky; top: 0; z-index: 50; box-shadow: 0 1px 0 var(--border); }
.app-bar-inner { padding-top: 4px; padding-bottom: 4px; }
.app-nav { display: flex; gap: 2px; flex-wrap: wrap; font-size: 14px; }
.app-nav a { color: var(--muted); font-weight: 700; text-decoration: none; padding: 9px 12px; border-radius: 8px; position: relative; }
.app-nav a:hover { color: var(--text); background: var(--surface); }
.app-nav a.active { color: var(--primary); background: var(--tint); }

.avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px; letter-spacing: .02em; color: #fff; background: var(--primary); user-select: none;
}
.avatar-judge { background: linear-gradient(135deg, #3d6fd6, #2f5fc4); }
.avatar-admin { background: linear-gradient(135deg, #f37a3c, var(--accent-text)); }
.avatar-display { background: linear-gradient(135deg, #8a6fd6, #6b4fbb); }
.avatar-jury { background: linear-gradient(135deg, #2fa37a, #1f7a5a); }
.avatar-super_admin { background: linear-gradient(135deg, var(--primary), #a50f14); }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }
.avatar-xl { width: 76px; height: 76px; font-size: 26px; box-shadow: 0 6px 18px rgba(80, 40, 30, .15); }

.user-menu { position: relative; }
.user-menu > summary {
  list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 4px 10px 4px 4px; border-radius: 40px; border: 1px solid transparent;
}
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover, .user-menu[open] > summary { background: var(--surface); border-color: var(--border); }
.user-menu-text { display: flex; flex-direction: column; line-height: 1.15; }
.user-menu-name { font-weight: 700; font-size: 13px; }
.user-menu-role { font-size: 11px; color: var(--muted); }
.user-menu-chev { color: var(--muted); font-size: 11px; }
.user-menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); width: 260px; z-index: 60;
  background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 6px;
  box-shadow: 0 12px 32px rgba(80, 40, 30, .14);
}
.user-menu-head { display: flex; gap: 10px; align-items: center; padding: 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.user-menu-head .role-chip { margin-top: 4px; }
.user-menu-pop form { margin: 0; }
.user-menu-item {
  display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 8px; border: 0; background: none;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--text); text-decoration: none; cursor: pointer;
}
.user-menu-item:hover, .user-menu-item.active { background: var(--surface); }

/* =====================================================================
   Account page
   ===================================================================== */
.account { max-width: 1080px; }
.acc-hero {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 20px; align-items: center;
  background: linear-gradient(120deg, #fff 0%, #fff 55%, var(--tint) 100%);
  border: 1px solid var(--border); border-radius: 14px; padding: 22px 24px; margin: 4px 0 20px; box-shadow: var(--shadow);
}
.acc-hero-text h1 { font-size: 24px; margin-bottom: 4px; overflow-wrap: anywhere; }
.acc-hero-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.acc-hero-text p { margin: 8px 0 0; max-width: 460px; }
.acc-hero-facts { display: grid; grid-template-columns: repeat(3, auto); gap: 6px 22px; margin: 0; }
.acc-hero-facts div { min-width: 0; }
.acc-hero-facts dt { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.acc-hero-facts dd { margin: 2px 0 0; font-weight: 700; font-size: 14px; white-space: nowrap; }

.acc-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 20px; align-items: start; }
.acc-nav { position: sticky; top: 70px; display: flex; flex-direction: column; gap: 2px; }
.acc-nav a {
  padding: 9px 12px; border-radius: 8px; color: var(--muted); font-weight: 700; font-size: 14px; text-decoration: none;
  border-left: 3px solid transparent;
}
.acc-nav a:hover { color: var(--text); background: #fff; }
.acc-nav a.active { color: var(--primary); background: #fff; border-left-color: var(--primary); box-shadow: var(--shadow); }
.acc-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.acc-card { padding: 20px 22px; margin: 0; scroll-margin-top: 80px; }
.acc-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap;
  padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.acc-card-head h2 { font-size: 17px; margin-bottom: 2px; }
.acc-card-head p { margin: 0; }
.acc-form { display: flex; flex-direction: column; gap: 14px; }
.acc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.acc-form input:disabled { background: var(--surface); color: var(--muted); }
.acc-actions { display: flex; justify-content: flex-end; padding-top: 4px; }

.pw-wrap { display: flex; align-items: center; border: 1px solid #ddd5d1; border-radius: 6px; background: #fff; }
.pw-wrap:focus-within { outline: 2px solid #f8c9c7; border-color: var(--primary); }
.pw-wrap input { border: 0; flex: 1; min-width: 0; }
.pw-wrap input:focus { outline: 0; }
.pw-eye { border: 0; background: none; color: var(--primary); font: inherit; font-size: 12px; font-weight: 700; padding: 6px 10px; cursor: pointer; }
.pw-meter { display: flex; align-items: center; gap: 12px; }
.pw-bar { flex: 1; max-width: 260px; height: 6px; border-radius: 6px; background: #f1ebe8; overflow: hidden; }
.pw-bar span { display: block; height: 100%; width: 0; border-radius: 6px; background: #d94a3d; transition: width .2s, background .2s; }
.pw-bar span[data-score="2"] { background: #e8962c; }
.pw-bar span[data-score="3"] { background: #6aa84f; }
.pw-bar span[data-score="4"] { background: #2f7d4f; }
.pw-rules { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; color: var(--muted); }
.pw-rules li::before { content: "○"; margin-right: 6px; }
.pw-rules li.ok { color: #2f7d4f; }
.pw-rules li.ok::before { content: "✓"; font-weight: 800; }

.device-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.device { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.device.is-current { border-color: #bfe3cc; background: #f6fbf8; }
.device-icon { font-size: 22px; width: 32px; text-align: center; }
.device-text { min-width: 0; }
.device-text b { margin-right: 6px; }

.access-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; }
.access-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 14px; }
.access-list li.no { color: var(--muted); }
.access-mark { flex: none; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; }
.access-list li.yes .access-mark { background: #eef8f1; color: #2f7d4f; border: 1px solid #bfe3cc; }
.access-list li.no .access-mark { background: #f6f3f1; color: #b9aca8; border: 1px solid var(--border); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.user-cell { display: inline-flex; align-items: center; gap: 10px; }

@media (max-width: 900px) {
  .acc-hero { grid-template-columns: auto minmax(0, 1fr); }
  .acc-hero-facts { grid-column: 1 / -1; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--border); padding-top: 14px; }
  .acc-hero-facts dd { white-space: normal; }
  .acc-layout { grid-template-columns: minmax(0, 1fr); }
  .acc-nav { position: static; flex-direction: row; overflow-x: auto; gap: 4px; }
  .acc-nav a { border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; }
  .acc-nav a.active { border-bottom-color: var(--primary); }
}
@media (max-width: 700px) {
  .user-menu-text, .user-menu-chev { display: none; }
  .user-menu > summary { padding: 2px; }
  .app-nav a { padding: 8px 9px; font-size: 13px; }
  .acc-hero { padding: 16px; gap: 14px; }
  .acc-hero .avatar-xl { width: 56px; height: 56px; font-size: 20px; }
  .acc-hero-text h1 { font-size: 20px; }
  .acc-card { padding: 16px; }
  .acc-row, .pw-rules, .access-list { grid-template-columns: minmax(0, 1fr); }
  .acc-actions .btn { width: 100%; justify-content: center; }
}

.acc-alert { background: #fff8e6; border: 1px solid #f3d98b; color: #6b4a00; border-radius: 10px; padding: 12px 16px; margin: 4px 0 14px; }
.form-note { margin: -4px 0 0; }

/* =====================================================================
   Judging panels
   ===================================================================== */
.seat-pill { background: var(--blue-tint); color: var(--blue-corner); border: 1px solid #c8d6f5; border-radius: 20px; padding: 2px 10px; font-size: 12px; font-weight: 800; }
.sp-panel { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: #fff; }
.judge-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 10px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface);
}
.judge-chip b { color: var(--muted); }
.judge-chip.is-me { border-color: var(--blue-corner); background: var(--blue-tint); }
.judge-chip.is-in { border-color: #bfe3cc; background: #eef8f1; color: #2f7d4f; }
.judge-chip.is-empty { border-style: dashed; color: var(--muted); background: #fff; }

.sp-waiting { padding: 40px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.sp-waiting-big { font-size: 26px; font-weight: 800; }
.sp-card-label { color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }
.sp-foot { flex-direction: column; align-items: stretch; }
.sp-submit, .sp-tie { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.sp-submit > span { flex: 1 1 280px; }
.sp-tie { background: #fff8e6; border: 1px solid #f3d98b; border-radius: 10px; padding: 10px 12px; }
.sp-tech-btn:disabled, .sp-pen-btns .btn:disabled { opacity: .45; cursor: not-allowed; }

.join-info { margin: 8px 0 10px; }
.join-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#joinPick .field select { width: 100%; }

/* score sheet */
.sheet-table { width: 100%; border-collapse: collapse; margin-top: 4px; }
.sheet-table th, .sheet-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.sheet-table .r, .sheet-table .b { text-align: center; width: 30%; font-variant-numeric: tabular-nums; }
.sheet-table th.r { color: var(--primary); }
.sheet-table th.b { color: var(--blue-corner); }
.sheet-table td.r, .sheet-table td.b { font-weight: 700; font-size: 16px; }
.sheet-table tfoot th { font-size: 18px; border-top: 2px solid var(--text); border-bottom: 0; }
.sheet-winner { margin: 12px 0 0; padding: 10px 12px; background: #fff8e6; border: 1px solid #f3d98b; border-radius: 8px; }

/* admin ring dialog */
dialog#ringDialog, dialog#ringsDialog { width: min(640px, calc(100vw - 24px)); }
.ra-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin: 10px 0; }
.ra-score { text-align: center; border-radius: 10px; padding: 10px; }
.ra-score span { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.ra-score b { font-size: 34px; font-variant-numeric: tabular-nums; }
.ra-score.r { background: var(--tint); color: var(--primary); }
.ra-score.b { background: var(--blue-tint); color: var(--blue-corner); }
.ra-timer { text-align: center; display: flex; flex-direction: column; }
.ra-timer b { font-size: 30px; font-variant-numeric: tabular-nums; }
#ringBody .sp-panel { padding: 0; border: 0; margin-bottom: 10px; }
.ra-controls { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* waiting rings / bouts */
.ring-state.wait { color: #8a5a00; background: #fff8e6; border: 1px solid #f3d98b; }
.ring-card.is-waiting { border-top-color: #e8a33c; }
.ring-card.is-mine { box-shadow: 0 0 0 2px var(--blue-corner); }
.ring-sub { margin-top: 4px; }
.ring-meta { margin-left: auto; }
.node.bout.is-waiting { border-style: dashed; border-color: #e8a33c; box-shadow: none; }
.node.bout.is-waiting .lbl { color: #8a5a00; }
.up-item.is-waiting { border-color: #f3d98b; background: #fffbf0; }
.up-meta { display: flex; gap: 8px; align-items: center; margin-top: 3px; flex-wrap: wrap; }

@media (max-width: 700px) {
  .ra-grid { grid-template-columns: 1fr 1fr; }
  .ra-timer { grid-column: 1 / -1; grid-row: 1; }
  .sp-panel { padding: 8px 10px; }
  #ringDialog[open], #ringsDialog[open] { display: block; overflow-y: auto; }
}

/* =====================================================================
   Big screen (/display): fills a TV, sizes follow the screen (vw / vh)
   ===================================================================== */
.bs-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 14px; }
.bs-pick { display: flex; flex-direction: column; gap: 6px; padding: 16px; color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.bs-pick:hover { border-color: var(--primary); box-shadow: 0 6px 20px rgba(215, 20, 26, .1); }
.bs-pick-top { display: flex; align-items: flex-start; gap: 10px; justify-content: space-between; }
.bs-pick-top h3 { font-size: 17px; }
.bs-pick-go { align-self: flex-start; margin-top: 8px; }
.bs-pick-tip { margin-top: 16px; }

body.bs { background: var(--bg); overflow: hidden; cursor: none; }
body.bs.bs-awake { cursor: auto; }
.bs-screen { height: 100vh; display: flex; flex-direction: column; }
.bs-muted { color: var(--muted); }

/* header */
.bs-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 2vw;
  padding: 1.2vh 2vw; background: #fff; border-bottom: 3px solid var(--primary);
  box-shadow: 0 2px 12px rgba(80, 40, 30, .06);
}
.bs-brand { display: flex; align-items: center; gap: .8vw; }
.bs-brand img { height: min(6.5vh, 4vw); }
.bs-brand span { font-weight: 900; text-transform: uppercase; color: var(--primary); font-size: min(1.6vh, 1vw); line-height: 1.2; letter-spacing: .04em; }
.bs-title { text-align: center; min-width: 0; }
.bs-title h1 { font-size: min(3.6vh, 2.2vw); font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bs-label { color: var(--accent-text); font-weight: 700; font-size: min(1.9vh, 1.15vw); text-transform: uppercase; letter-spacing: .12em; }
.bs-side { display: flex; flex-direction: column; align-items: flex-end; gap: .3vh; }
.bs-clock { font-size: min(3.4vh, 2vw); font-weight: 800; font-variant-numeric: tabular-nums; }
.bs-powered { display: flex; align-items: center; gap: .4vw; color: var(--muted); font-size: min(1.4vh, .85vw); }
.bs-powered img { height: min(2.2vh, 1.4vw); }

/* stage + slide-in */
.bs-stage { flex: 1; min-height: 0; padding: 2vh 2vw; display: flex; }
.bs-slide { flex: 1; min-width: 0; min-height: 0; display: flex; }
.bs-slide > * { flex: 1; min-width: 0; }
.bs-enter { animation: bsIn .6s ease-out; }
@keyframes bsIn { from { opacity: 0; transform: translateY(1.5vh); } to { opacity: 1; transform: none; } }
.bs-loading { margin: auto; font-size: 3vh; color: var(--muted); }

/* footer: where in the cycle we are */
.bs-foot { background: #fff; border-top: 1px solid var(--border); }
.bs-steps { display: flex; gap: .6vw; padding: .9vh 2vw; overflow: hidden; flex-wrap: nowrap; }
.bs-steps span {
  font-size: min(1.5vh, .9vw); font-weight: 700; color: var(--muted); padding: .3vh .8vw; border-radius: 99px;
  border: 1px solid var(--border); white-space: nowrap;
}
.bs-steps span.done { color: var(--text); }
.bs-steps span.on { color: #fff; background: var(--primary); border-color: var(--primary); }
.bs-progress { height: .6vh; min-height: 4px; background: var(--tint); }
.bs-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .25s linear; }
body.bs-paused .bs-progress span { background: var(--muted); }

/* status pills */
.bs-pill {
  display: inline-flex; align-items: center; gap: .5em; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  font-size: min(1.7vh, 1vw); padding: .35em 1em; border-radius: 99px; white-space: nowrap; border: 1px solid transparent;
}
.bs-pill.live { color: #fff; background: var(--primary); }
.bs-pill.live .dot { background: #fff; }
.bs-pill.wait { color: #8a5a00; background: #fff8e6; border-color: #f3d98b; }
.bs-pill.pause, .bs-pill.cards { color: var(--accent-text); background: var(--tint-accent); border-color: #f6c9a6; }
.bs-pill.tie { color: #6b4fbb; background: #f3effc; border-color: #d9cdf4; }
.bs-pill.free { color: var(--muted); background: #fff; border-color: var(--border); }
.bs-pill.done { color: #2f7d4f; background: #eef8f1; border-color: #bfe3cc; }
.bs-ring { font-weight: 900; text-transform: uppercase; letter-spacing: .06em; color: #fff; background: var(--primary); border-radius: .4em; padding: .15em .6em; font-size: min(2.2vh, 1.3vw); white-space: nowrap; }
.bs-ring.big { font-size: min(3.4vh, 2vw); }

/* corners */
.bs-red { color: var(--primary); }
.bs-blue { color: var(--blue-corner); }

/* ---- overview: every ring ---- */
.bs-rings { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows), minmax(0, 1fr)); gap: 1.6vh 1.4vw; }
.bs-tile {
  background: #fff; border: 1px solid var(--border); border-top: .7vh solid var(--primary); border-radius: 14px;
  box-shadow: var(--shadow); padding: 1.6vh 1.2vw; display: flex; flex-direction: column; gap: 1vh; min-height: 0; overflow: hidden;
}
.bs-tile.idle { border-top-color: var(--border); }
.bs-tile.wait { border-top-color: #e8a33c; }
.bs-tile.pause, .bs-tile.cards { border-top-color: var(--accent); }
.bs-tile.tie { border-top-color: #8a6fd6; }
.bs-tile-head { display: flex; align-items: center; gap: .8vw; }
.bs-tile-timer { margin-left: auto; font-weight: 900; font-variant-numeric: tabular-nums; font-size: min(5vh, 2.8vw); line-height: 1; }
.bs-tile-timer.live { color: var(--primary); }
.bs-tile-timer.wait, .bs-tile-timer.pause, .bs-tile-timer.cards { color: var(--muted); }
.bs-tile-cat { color: var(--muted); font-size: min(1.9vh, 1.1vw); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bs-tile-row {
  flex: 1; min-height: 0; display: flex; align-items: center; gap: .9vw; padding: 0 1vw; border-radius: 10px;
}
.bs-tile-row.red { background: var(--tint); }
.bs-tile-row.blue { background: var(--blue-tint); }
.bs-tile-row.lead.red { box-shadow: inset 0 0 0 2px var(--primary); }
.bs-tile-row.lead.blue { box-shadow: inset 0 0 0 2px var(--blue-corner); }
.bs-corner { width: 1.2vh; height: 1.2vh; min-width: 8px; min-height: 8px; border-radius: 50%; flex: none; }
.bs-tile-row.red .bs-corner { background: var(--primary); }
.bs-tile-row.blue .bs-corner { background: var(--blue-corner); }
.bs-tile-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bs-tile-name b { font-size: min(3vh, 1.8vw); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bs-tile-name small { color: var(--muted); font-size: min(1.7vh, 1vw); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bs-tile-score { font-weight: 900; font-variant-numeric: tabular-nums; font-size: min(7vh, 4vw); line-height: 1; }
.bs-tile-row.red .bs-tile-score { color: var(--primary); }
.bs-tile-row.blue .bs-tile-score { color: var(--blue-corner); }
.bs-tile-idle { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .6vh; font-size: min(2vh, 1.2vw); }
.bs-tile-idle b { font-size: min(3.4vh, 2vw); }
.bs-dash { color: var(--border); font-weight: 400; }

/* ---- one ring close-up ---- */
.bs-detail, .bs-result { display: flex; flex-direction: column; gap: 2vh; min-height: 0; }
.bs-detail-head { display: flex; align-items: center; gap: 1.2vw; }
.bs-detail-cat { flex: 1; min-width: 0; font-weight: 800; font-size: min(3vh, 1.8vw); display: flex; flex-direction: column; }
.bs-detail-cat small { font-weight: 600; color: var(--muted); font-size: min(2vh, 1.2vw); }
.bs-detail-head .bs-pill { font-size: min(2.2vh, 1.3vw); }
.bs-detail-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr minmax(0, .75fr) 1fr; gap: 1.6vw; }
.bs-side-card {
  border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 2vh 1.5vw; gap: .6vh; min-width: 0; border: 2px solid transparent;
}
.bs-side-card.red { background: linear-gradient(180deg, #fff, var(--tint)); border-color: #f5c6c6; }
.bs-side-card.blue { background: linear-gradient(180deg, #fff, var(--blue-tint)); border-color: #c8d6f5; }
.bs-side-card.lead.red { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(215, 20, 26, .12); }
.bs-side-card.lead.blue { border-color: var(--blue-corner); box-shadow: 0 0 0 4px rgba(47, 95, 196, .12); }
.bs-corner-label { font-weight: 900; text-transform: uppercase; letter-spacing: .16em; font-size: min(2vh, 1.2vw); }
.red .bs-corner-label, .red > h2 { color: var(--primary); }
.blue .bs-corner-label, .blue > h2 { color: var(--blue-corner); }
.bs-side-card h2 { font-size: min(5.2vh, 3vw); font-weight: 900; line-height: 1.1; max-width: 100%; overflow-wrap: anywhere; }
.bs-club { color: var(--muted); font-size: min(2.2vh, 1.3vw); }
.bs-big-score { font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; font-size: min(24vh, 13vw); margin: 1vh 0; }
.red .bs-big-score { color: var(--primary); }
.blue .bs-big-score { color: var(--blue-corner); }
.bs-notes { color: var(--warn); font-weight: 700; font-size: min(2.2vh, 1.3vw); }
.bs-center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2vh; text-align: center; min-width: 0; }
.bs-big-timer {
  font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; font-size: min(14vh, 8vw);
  background: #fff; border: 1px solid var(--border); border-radius: 18px; padding: 2vh 2vw; box-shadow: var(--shadow);
}
.bs-big-timer.live { color: var(--primary); }
.bs-big-timer.wait, .bs-big-timer.pause, .bs-big-timer.cards, .bs-big-timer.tie { color: var(--muted); }
.bs-center-state { font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-size: min(2.2vh, 1.3vw); }
.bs-vs { font-weight: 900; color: var(--border); font-size: min(6vh, 3.5vw); letter-spacing: .1em; }
.bs-judges { display: flex; align-items: center; gap: .8vw; flex-wrap: wrap; font-size: min(2vh, 1.2vw); }
.bs-judge { background: #fff; border: 1px solid var(--border); border-radius: 99px; padding: .5vh 1vw; }
.bs-judge b { color: var(--muted); margin-right: .3em; }
.bs-judge.in { background: #eef8f1; border-color: #bfe3cc; color: #2f7d4f; }
.bs-judge.empty { border-style: dashed; color: var(--muted); }

/* ---- result of a ring that just finished ---- */
.bs-result-main {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 1vh;
  border-radius: 22px; background: radial-gradient(ellipse at top, #fff8e6, #fff 65%); border: 1px solid #f3d98b;
}
.bs-trophy { font-size: min(12vh, 7vw); line-height: 1; animation: bsPop .8s ease-out; }
@keyframes bsPop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }
.bs-result-main h2 { font-size: min(9vh, 5.5vw); font-weight: 900; line-height: 1.05; }
.bs-result-main .bs-club { font-size: min(3vh, 1.8vw); }
.bs-result-how { font-size: min(3.4vh, 2vw); font-weight: 700; }
.bs-result-main > .bs-muted { font-size: min(2.4vh, 1.4vw); }

/* ---- winners ---- */
.bs-winners { display: flex; flex-direction: column; gap: 1.8vh; min-height: 0; }
.bs-winners-head { display: flex; align-items: baseline; gap: 1.5vw; }
.bs-winners-head h2 { font-size: min(4.4vh, 2.6vw); font-weight: 900; }
.bs-winners-head .bs-muted { font-size: min(2.2vh, 1.3vw); }
.bs-win-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 1.6vh 1.4vw; }
.bs-win-card {
  background: #fff; border: 1px solid var(--border); border-top: .6vh solid #e8b33c; border-radius: 14px; box-shadow: var(--shadow);
  padding: 1.6vh 1.2vw; display: flex; flex-direction: column; gap: 1vh; min-height: 0; overflow: hidden;
}
.bs-win-card h3 { font-size: min(2.3vh, 1.35vw); color: var(--accent-text); border-bottom: 1px solid var(--border); padding-bottom: .8vh; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bs-win-card ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .8vh; }
.bs-win-card li { display: flex; align-items: center; gap: .8vw; min-width: 0; }
.bs-win-card li > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.bs-win-card li b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: min(2.3vh, 1.35vw); }
.bs-win-card li small { color: var(--muted); font-size: min(1.6vh, .95vw); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bs-win-card li.gold b { font-size: min(3.2vh, 1.9vw); }
.bs-medal { font-size: min(3.2vh, 1.9vw); line-height: 1; }
.bs-win-card li.gold .bs-medal { font-size: min(4.4vh, 2.6vw); }

/* ---- operator controls / connection ---- */
.bs-controls {
  position: fixed; right: 1.5vw; bottom: 7vh; display: flex; gap: 6px; align-items: center; padding: 8px; border-radius: 12px;
  background: rgba(255, 255, 255, .95); border: 1px solid var(--border); box-shadow: 0 8px 28px rgba(80, 40, 30, .15);
  opacity: 0; pointer-events: none; transition: opacity .3s;
}
body.bs-awake .bs-controls { opacity: 1; pointer-events: auto; }
.bs-logout { margin: 0; }
.bs-offline {
  position: fixed; left: 50%; top: 12vh; transform: translateX(-50%); background: var(--tint-accent); color: var(--accent-text);
  border: 1px solid #f6c9a6; padding: 8px 18px; border-radius: 99px; font-weight: 700;
}
.bs-signedout { position: fixed; inset: 0; background: rgba(247, 245, 243, .96); display: flex; align-items: center; justify-content: center; text-align: center; }
.bs-signedout > div { display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* phones / small windows: let it scroll instead of squeezing */
@media (max-width: 800px) {
  body.bs { overflow: auto; cursor: auto; }
  .bs-screen { height: auto; min-height: 100vh; }
  .bs-head { grid-template-columns: 1fr auto; padding: 10px 16px; }
  .bs-brand span, .bs-powered { display: none; }
  .bs-title { grid-column: 1 / -1; grid-row: 2; text-align: left; }
  .bs-title h1 { font-size: 20px; white-space: normal; }
  .bs-label, .bs-steps span, .bs-pill, .bs-tile-cat, .bs-tile-name small, .bs-club, .bs-center-state, .bs-judges, .bs-notes { font-size: 12px; }
  .bs-clock { font-size: 18px; }
  .bs-brand img { height: 36px; }
  .bs-stage { padding: 12px 16px; }
  .bs-rings, .bs-win-grid { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-rows: auto; }
  .bs-tile-row { padding: 8px 10px; }
  .bs-tile-idle { font-size: 13px; padding: 8px 0; }
  .bs-tile-idle b { font-size: 18px; }
  .bs-tile-name b, .bs-win-card li b, .bs-win-card h3 { font-size: 16px; }
  .bs-tile-score, .bs-tile-timer { font-size: 28px; }
  .bs-ring, .bs-ring.big { font-size: 14px; }
  .bs-detail-cat { font-size: 16px; }
  .bs-detail-cat small { font-size: 12px; }
  .bs-detail-head { flex-wrap: wrap; }
  .bs-detail-main { grid-template-columns: 1fr 1fr; }
  .bs-center { grid-column: 1 / -1; grid-row: 1; }
  .bs-side-card h2 { font-size: 18px; }
  .bs-big-score { font-size: 56px; }
  .bs-big-timer { font-size: 48px; }
  .bs-corner-label { font-size: 11px; }
  .bs-vs { display: none; }
  .bs-result-main { padding: 24px 12px; }
  .bs-result-main h2 { font-size: 30px; }
  .bs-trophy { font-size: 56px; }
  .bs-winners-head { flex-direction: column; gap: 2px; }
  .bs-winners-head h2 { font-size: 22px; }
  .bs-medal, .bs-win-card li.gold .bs-medal { font-size: 22px; }
  .bs-win-card li.gold b { font-size: 18px; }
  .bs-controls { left: 16px; right: 16px; bottom: 16px; flex-wrap: wrap; justify-content: center; }
}

/* =====================================================================
   Sidebar navigation + breadcrumbs
   Desktop: a slim icon rail that opens on hover (or keyboard focus) and closes when the mouse leaves.
   Phones:  the same links as an icon bar at the bottom of the screen.
   ===================================================================== */
:root { --sb-w: 248px; --sb-rail: 68px; --sb-bottom: 62px; }
body:has(> .sidebar) { padding-left: var(--sb-rail); }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sb-rail); z-index: 60; background: #fff; overflow: hidden;
  border-right: 1px solid var(--border); display: flex; flex-direction: column; box-shadow: 1px 0 10px rgba(80, 40, 30, .04);
  transition: width .18s ease, box-shadow .18s ease;
}
.sidebar:hover, .sidebar:focus-within { width: var(--sb-w); box-shadow: 10px 0 34px rgba(80, 40, 30, .14); }
/* text fades in when the rail opens; icons stay where they are */
.sb-text, .sb-brand span, .sb-user-text { white-space: nowrap; opacity: 0; transition: opacity .12s ease; }
.sidebar:hover .sb-text, .sidebar:hover .sb-brand span, .sidebar:hover .sb-user-text,
.sidebar:focus-within .sb-text, .sidebar:focus-within .sb-brand span, .sidebar:focus-within .sb-user-text { opacity: 1; transition-delay: .06s; }
.sb-short { display: none; }

.sb-brand {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; text-decoration: none; flex: none;
  border-bottom: 3px solid var(--primary);
}
.sb-brand img { width: 40px; height: 40px; object-fit: contain; flex: none; }
.sb-brand span { color: var(--primary); font-weight: 900; text-transform: uppercase; font-size: 11px; line-height: 1.25; letter-spacing: .03em; }
.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 10px 16px; display: flex; flex-direction: column; gap: 2px; }
.sb-label {
  font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  height: 30px; padding: 12px 10px 0; white-space: nowrap; overflow: hidden; flex: none;
}
.sb-label .sb-text { display: block; overflow: hidden; text-overflow: ellipsis; }
.sb-label.sb-event { color: var(--accent-text); border-top: 1px solid var(--border); margin-top: 8px; height: 38px; padding-top: 16px; }
.sb-link {
  display: flex; align-items: center; gap: 12px; padding: 9px 13px; border-radius: 8px; color: var(--text); flex: none;
  text-decoration: none; font-weight: 600; font-size: 14px; border: 0; background: none; width: 100%; cursor: pointer; font-family: inherit; text-align: left;
}
.sb-link:hover { background: var(--surface); color: var(--primary); }
.sb-link.active { background: var(--tint); color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); }
.sb-ico { width: 22px; text-align: center; flex: none; font-size: 17px; }
.sb-sub { display: none; flex-wrap: wrap; gap: 4px; padding: 4px 10px 4px 47px; white-space: nowrap; }
.sidebar:hover .sb-sub, .sidebar:focus-within .sb-sub { display: flex; }
.sb-sub-label { flex-basis: 100%; font-size: 11px; color: var(--muted); }
.sb-chip {
  font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 20px; border: 1px solid var(--border);
  color: var(--text); text-decoration: none; background: #fff;
}
.sb-chip:hover, .sb-chip.active { border-color: var(--primary); color: var(--primary); background: var(--tint); }
.sb-foot { border-top: 1px solid var(--border); padding: 10px; display: flex; flex-direction: column; gap: 2px; flex: none; }
.sb-foot form { margin: 0; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: 8px; text-decoration: none; color: var(--text); }
.sb-user .avatar { flex: none; }
.sb-user:hover, .sb-user.active { background: var(--surface); }
.sb-user-text { display: flex; flex-direction: column; min-width: 0; }
.sb-user-text b, .sb-user-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-logout { color: var(--danger); }

.topnav {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 12px; min-height: 52px;
  padding: 6px 20px; background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--border); backdrop-filter: blur(6px);
}
.crumbs { flex: 1; min-width: 0; }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 13px; }
.crumbs li { display: flex; align-items: center; gap: 4px; min-width: 0; }
.crumbs li + li::before { content: '›'; color: var(--muted); margin-right: 2px; }
.crumbs a { color: var(--muted); text-decoration: none; font-weight: 600; }
.crumbs a:hover { color: var(--primary); text-decoration: underline; }
.crumbs [aria-current] { color: var(--text); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40ch; }
.topnav-powered { margin-left: auto; }
.topnav-powered .powered-logo { height: 24px; }
.topnav-powered .powered-name { font-size: 13px; }

/* ---------- phones: bottom icon bar (tablets keep the rail) ---------- */
@media (max-width: 600px) {
  body:has(> .sidebar) { padding-left: 0; padding-bottom: calc(var(--sb-bottom) + env(safe-area-inset-bottom, 0px)); }
  .sidebar, .sidebar:hover, .sidebar:focus-within {
    inset: auto 0 0 0; width: auto; height: calc(var(--sb-bottom) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
    flex-direction: row; border-right: 0; border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(80, 40, 30, .08);
    overflow-x: auto; overflow-y: hidden; scrollbar-width: none; transition: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sb-brand, .sb-label, .sb-sub, .sidebar:hover .sb-sub, .sb-text, .sb-user-text { display: none; }
  .sb-nav { flex: none; flex-direction: row; padding: 0; gap: 0; overflow: visible; }
  .sb-evlink { order: -1; }           /* inside an event: its sections first */
  .sb-nav:has(.sb-evlink) .sb-main[href="/display"] { display: none; } /* the event's own Big screen link is enough */
  .sb-foot { flex-direction: row; border-top: 0; padding: 0; gap: 0; }
  .sb-link, .sb-user {
    flex-direction: column; justify-content: center; align-items: center; gap: 2px; width: auto; min-width: 66px;
    height: var(--sb-bottom); padding: 4px 8px; border-radius: 0; font-size: 10px;
  }
  .sb-link.active { box-shadow: inset 0 3px 0 var(--primary); }
  .sb-short { display: block; font-size: 10px; font-weight: 700; white-space: nowrap; }
  .sb-ico { font-size: 19px; width: auto; }
  .sb-user .avatar { width: 24px; height: 24px; font-size: 10px; }
  .topnav { padding: 6px 12px; }
  .fab { bottom: calc(var(--sb-bottom) + 16px); }
  .toast { bottom: calc(var(--sb-bottom) + 12px); }
}
@media (max-width: 600px) {
  .topnav-powered .powered-by, .topnav-powered .powered-name { display: none; }
  .crumbs ol { font-size: 12px; flex-wrap: nowrap; overflow: hidden; }
  .crumbs li:not(:last-child):not(:nth-last-child(2)) { display: none; }
  .crumbs li:nth-last-child(2)::before { content: none; }
  .crumbs [aria-current] { max-width: 22ch; }
}
@media print { .sidebar, .topnav { display: none !important; } body:has(> .sidebar) { padding: 0; } }

/* =====================================================================
   Event tree: official banner
   ===================================================================== */
.official-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; border-left: 4px solid var(--primary); }
.official-bar h2 { font-size: 17px; }
.moved-chip { font-size: 10px; font-weight: 700; color: #6b4fbb; background: #f3effc; border: 1px solid #d9cdf4; border-radius: 20px; padding: 0 6px; white-space: nowrap; }

/* =====================================================================
   Ring console
   ===================================================================== */
.rc-heading h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rc-ring { font-size: 18px; padding: 4px 14px; }
.rc-event { font-size: 18px; color: var(--muted); font-weight: 700; }
.rc-me { font-size: 12px; }
.rc-pick { display: inline-flex; align-items: center; gap: 6px; }
.rc-error { margin-bottom: 12px; }
.rc-stage { padding: 0; overflow: hidden; }
.rc-stage.is-live { border-color: #f5c4c2; box-shadow: 0 0 0 3px rgba(215, 20, 26, .06), var(--shadow); }
.rc-free { padding: 36px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.rc-free-big { font-size: 24px; font-weight: 800; }
.rc-bout-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.rc-bout-title { min-width: 0; }
.rc-status .ring-state { font-size: 12px; padding: 3px 10px; }
.rc-panel { border-bottom: 1px solid var(--border); }
.rc-jury-chip { border-color: #bfe6d4; background: #eaf7f1; color: #1f7a5a; }
.judge-chip.is-me { font-weight: 700; }
.rc-board { display: grid; grid-template-columns: 1fr minmax(230px, 300px) 1fr; }
.rc-side { padding: 16px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; min-width: 0; }
.rc-side.red { background: linear-gradient(180deg, var(--tint), #fff 70%); border-right: 1px solid var(--border); }
.rc-side.blue { background: linear-gradient(180deg, var(--blue-tint), #fff 70%); border-left: 1px solid var(--border); }
.rc-corner { font-size: 12px; font-weight: 800; letter-spacing: .12em; }
.rc-side.red .rc-corner, .rc-side.red .rc-total { color: var(--primary); }
.rc-side.blue .rc-corner, .rc-side.blue .rc-total { color: var(--blue-corner); }
.rc-name { font-size: 20px; font-weight: 800; max-width: 100%; overflow-wrap: anywhere; }
.rc-club { font-size: 12px; color: var(--muted); min-height: 16px; }
.rc-total-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: 6px; }
.rc-total { font-size: 80px; line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; }
.rc-total.bump, .rc-mycard b.bump { animation: bump .25s; }
.rc-mycard { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.rc-mycard b { font-size: 22px; color: var(--text); margin-left: 4px; font-variant-numeric: tabular-nums; display: inline-block; }
.rc-side.red .sp-tech-btn { border-color: #f1b3b1; color: var(--primary-dark); }
.rc-side.red .sp-tech-btn:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.rc-side.blue .sp-tech-btn { border-color: #bccdf2; color: var(--blue-corner); }
.rc-side.blue .sp-tech-btn:hover { background: var(--blue-corner); border-color: var(--blue-corner); color: #fff; }
.rc-pen { width: 100%; max-width: 340px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.rc-warn { font-weight: 600; color: var(--muted); }
.rc-warn.has { font-weight: 700; color: var(--warn); }
.rc-center { padding: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; }
.rc-timer {
  font-size: 64px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; padding: 10px 18px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); min-width: 200px;
}
.rc-timer.running { background: var(--tint); color: var(--primary-dark); border-color: #f5c4c2; }
.rc-timer.timeup { background: var(--primary); color: #fff; animation: pulse 1s infinite; }
.rc-timer.medical { background: #f3effc; color: #6b4fbb; border-color: #d9cdf4; }
.rc-timer-state { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.rc-med { font-size: 13px; font-weight: 700; color: #6b4fbb; background: #f3effc; border: 1px solid #d9cdf4; border-radius: 20px; padding: 2px 10px; }
.rc-med.on { background: #6b4fbb; color: #fff; }
.rc-med.none { color: var(--muted); background: #fff; border-color: var(--border); }
.rc-play { font-size: 18px; padding: 12px 26px; min-width: 190px; justify-content: center; }
.rc-med-btn { min-width: 190px; justify-content: center; font-weight: 700; color: #6b4fbb; background: #f3effc; border-color: #d9cdf4; }
.rc-med-btn:hover { background: #e9e1fb; }
.rc-med-btn.on { background: #6b4fbb; color: #fff; border-color: #6b4fbb; }
.rc-ready { min-width: 220px; justify-content: center; font-size: 18px; }
.rc-ready-info { margin: 0; }
.rc-mylast { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.rc-admin { width: 100%; border-top: 1px dashed var(--border); padding-top: 8px; }
.rc-admin summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.rc-admin-row { display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.rc-admin-row input { width: 80px; text-align: center; }
.rc-declare { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface); }
.rc-declare .spacer { flex: 1; }
.rc-declare label { display: inline-flex; align-items: center; gap: 6px; }
.rc-win { font-weight: 800; color: #fff; padding: 10px 18px; }
.rc-win.red { background: var(--primary); border-color: var(--primary); }
.rc-win.red:hover { background: var(--primary-dark); }
.rc-win.blue { background: var(--blue-corner); border-color: var(--blue-corner); }
.rc-win.blue:hover { background: #244c9e; }
.rc-cards .sheet-table tr.is-me td { background: #fffbf0; }
.rc-queue { padding: 12px 14px; }
.sp-tech-btn:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 900px) {
  .rc-board { grid-template-columns: 1fr 1fr; }
  .rc-center { grid-column: 1 / -1; grid-row: 1; border-bottom: 1px solid var(--border); flex-direction: row; flex-wrap: wrap; }
  .rc-timer { font-size: 48px; min-width: 160px; }
  .rc-total { font-size: 56px; }
  .rc-side.blue { border-left: 0; }
}
@media (max-width: 560px) {
  .rc-side { padding: 10px 8px; }
  .rc-name { font-size: 16px; }
  .rc-total { font-size: 44px; }
  .rc-play, .rc-med-btn, .rc-ready { min-width: 0; flex: 1 1 140px; }
  .rc-declare .rc-win { flex: 1 1 40%; justify-content: center; }
}

/* =====================================================================
   Rings & officials
   ===================================================================== */
.rg-settings { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); margin-bottom: 12px; }
.rg-ring-table input { width: 110px; }
.rg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 12px; }
.rg-ring { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--surface); display: flex; flex-direction: column; gap: 6px; }
.rg-ring-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; margin-bottom: 4px; }
.rg-ring select { width: 100%; }
.rg-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.rg-sum-item { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 20px; padding: 4px 10px 4px 4px; background: #fff; }
.rg-sum-item.warn { padding-left: 10px; border-color: #f3d98b; background: #fff8e6; }
.rg-group { margin-bottom: 14px; }
.rg-group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.rg-group-head h3 { font-size: 15px; }
.rg-group-head label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.rg-cat-table td:first-child { width: 50%; }
.rg-cat-table select { min-width: 120px; }

/* =====================================================================
   Big screen: judges' cards and medical timer
   ===================================================================== */
.bs-judge.card { display: inline-flex; align-items: center; gap: .5em; }
.bs-card-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.bs-card-score i { font-style: normal; }
.bs-medical { font-weight: 800; color: #6b4fbb; background: #f3effc; border: 1px solid #d9cdf4; border-radius: 99px; padding: .3em 1em; font-size: min(2.2vh, 1.3vw); }
.bs-medical.on { background: #6b4fbb; color: #fff; }

/* =====================================================================
   Page changes: the page slides in, the sidebar stays put, the active tab's
   underline and the active sidebar item glide to their new place.
   (cross-document view transitions; older browsers get a simple fade-in)
   ===================================================================== */
@view-transition { navigation: auto; }
.sidebar { view-transition-name: sidebar; }
.topnav { view-transition-name: topnav; }
.sb-link.active { view-transition-name: sb-active; }
.tab { position: relative; }
.tab.active { border-bottom-color: transparent; }
.tab-ink { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--primary); view-transition-name: tab-ink; }

::view-transition-old(root) { animation: vt-out .16s ease-in both; }
::view-transition-new(root) { animation: vt-in .32s cubic-bezier(.2, .8, .2, 1) both; }
::view-transition-group(tab-ink), ::view-transition-group(sb-active) { animation-duration: .32s; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
::view-transition-group(sidebar), ::view-transition-group(topnav) { animation-duration: .2s; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(12px); } }

@supports not (view-transition-name: none) {
  .container { animation: vt-in .32s cubic-bezier(.2, .8, .2, 1) both; }
}

/* desktop / tablet: the open sidebar pushes the page instead of covering it */
@media (min-width: 601px) {
  body:has(> .sidebar) { transition: padding-left .18s ease; }
  body:has(> .sidebar:hover), body:has(> .sidebar:focus-within) { padding-left: var(--sb-w); }
  .sidebar:hover, .sidebar:focus-within { box-shadow: 1px 0 14px rgba(80, 40, 30, .08); }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .container { animation: none !important; }
  body:has(> .sidebar), .sidebar { transition: none !important; }
}

/* sidebar kept open across a page change (html.sb-open, see sb-state.js) - not on phones */
@media (min-width: 601px) {
  html.sb-open .sidebar { width: var(--sb-w); box-shadow: 1px 0 14px rgba(80, 40, 30, .08); }
  html.sb-open .sb-text, html.sb-open .sb-brand span, html.sb-open .sb-user-text { opacity: 1; }
  html.sb-open .sb-sub { display: flex; }
  html.sb-open body:has(> .sidebar) { padding-left: var(--sb-w); }
}

/* =====================================================================
   Phones: comfortable tap targets and layouts that fit a narrow screen
   ===================================================================== */
@media (max-width: 800px) {
  /* fingers need ~40px */
  .btn-sm { min-height: 38px; padding: 8px 12px; }
  .icon-btn { width: 36px; height: 36px; font-size: 16px; }
  .ps-tag-btn { padding: 5px 10px; }
  .tab { padding: 12px 14px; }
  .pw-eye, #togglePw { min-width: 38px; min-height: 38px; }
  input, select, textarea { font-size: 16px; } /* no zoom-in on focus (iOS) */

  /* breadcrumbs: one line, long names shortened */
  .crumbs ol { flex-wrap: nowrap; overflow: hidden; }
  .crumbs li { min-width: 0; flex: 0 1 auto; }
  .crumbs a, .crumbs [aria-current] { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .crumbs a { max-width: 18ch; }

  .card-head .row-actions { justify-content: flex-start; }

  /* Up next: names get the full width, the button goes underneath */
  .up-item { flex-wrap: wrap; }
  .up-item .up-info { flex: 1 1 100%; }
  .up-item > .btn { flex: 1 1 100%; justify-content: center; }

  /* Rings & officials */
  .rg-ring-table th .muted { display: none; }
  .rg-ring-table td:first-child { white-space: nowrap; }
  .rg-ring-table input { width: 100%; min-width: 70px; }
  .rg-group-head { align-items: flex-start; }
  .rg-cat-table, .rg-cat-table tbody { display: block; }
  .rg-cat-table tr { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 6px 10px; padding: 10px 2px; border-bottom: 1px solid var(--border); }
  .rg-cat-table td { border: 0; padding: 0; width: auto !important; }
  .rg-cat-table td:first-child { grid-column: 1 / -1; }
  .rg-cat-table td:first-child .muted { display: none; }
  .rg-cat-table td:last-child { justify-self: end; }
  .rg-cat-table select { width: 100%; min-width: 130px; }

  /* users: one card per person */
  #usersTable thead { display: none; }
  #usersTable, #usersTable tbody { display: block; }
  #usersTable tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding: 12px 4px; border-bottom: 1px solid var(--border); }
  #usersTable td { border: 0; padding: 0; }
  #usersTable td:nth-child(1) { grid-column: 1; grid-row: 1; min-width: 0; }
  #usersTable td:nth-child(3) { grid-column: 2; grid-row: 1; justify-self: end; }
  #usersTable td:nth-child(2) { grid-column: 1; grid-row: 2; font-size: 13px; }
  #usersTable td:nth-child(4) { grid-column: 2; grid-row: 2; justify-self: end; }
  #usersTable td:nth-child(5) { grid-column: 1 / -1; color: var(--muted); }
  #usersTable td:nth-child(5)::before { content: 'Last login: '; }
  #usersTable td:nth-child(6) { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; white-space: normal; }
  #usersTable td:nth-child(6):empty { display: none; }

  /* ring console: penalty buttons in one tidy row */
  .rc-pen .sp-pen-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 100%; }
  .rc-pen .sp-pen-btns .btn { justify-content: center; }
}

/* =====================================================================
   Category configuration: separate set for boys and girls
   ===================================================================== */
.gender-tabs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.gender-tab {
  font: inherit; font-weight: 700; padding: 9px 16px; border-radius: 10px; cursor: pointer;
  border: 2px solid var(--border); background: #fff; color: var(--muted);
}
.gender-tab.male.active { border-color: var(--male); color: var(--male); background: var(--tint); }
.gender-tab.female.active { border-color: var(--female); color: var(--female); background: var(--tint-accent); }
.gender-tab:hover { border-color: var(--primary); color: var(--text); }
#btnCopyGender { margin-left: auto; }
#ageGroups.for-male .age-box { border-left: 4px solid var(--male); }
#ageGroups.for-female .age-box { border-left: 4px solid var(--female); }
@media (max-width: 600px) {
  .gender-tab { flex: 1 1 40%; }
  #btnCopyGender { margin-left: 0; flex: 1 1 100%; justify-content: center; }
}

/* account page: password managed by an admin (judges / jury) */
.acc-locked { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface); }
.acc-locked-ico { font-size: 22px; line-height: 1; }
.acc-locked p { margin: 4px 0 0; }

/* =====================================================================
   Phones (second pass): content first - compact event header, progress as
   one line, live rings as a swipe row, Up next as tidy rows, tables that scroll
   ===================================================================== */
@media (max-width: 600px) {
  .container { padding: 14px 12px 24px; }
  .card { padding: 14px 12px; }

  /* event header: title, one line of facts, small counter */
  .topbar { gap: 10px; margin-bottom: 12px; }
  .event-heading h1 { font-size: 20px; line-height: 1.25; }
  .event-meta { font-size: 12.5px; gap: 2px 10px; }
  .topbar-actions { width: 100%; gap: 8px; }
  .topbar-actions .count-card { flex: 1 1 auto; padding: 6px 12px; column-gap: 8px; }
  .topbar-actions .count-num { font-size: 22px; }
  .topbar-actions .count-split { display: none; }
  .topbar-actions > .btn-lg { flex: 1 1 auto; justify-content: center; padding: 10px 14px; }

  /* progress guide: only the "next step" line */
  .steps-list { display: none; }
  .step-next { border-top: 0; padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .step-next .btn { flex: 1 1 100%; justify-content: center; }

  /* live rings: one swipe row instead of a stack */
  .live-bar { padding: 10px 0 10px 12px; }
  .live-bar .live-head { padding-right: 12px; flex-wrap: wrap; }
  .live-bar .ring-grid { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 8px; padding: 2px 12px 4px 0; scrollbar-width: none; }
  .live-bar .ring-grid::-webkit-scrollbar { display: none; }
  .live-bar .ring-card { flex: 0 0 82%; scroll-snap-align: start; }
  .live-bar .ring-count { width: 100%; }

  /* Up next: compact rows - names wrap, the button stays on the right */
  .up-item { flex-wrap: nowrap; align-items: center; }
  .up-item .up-info { flex: 1 1 auto; min-width: 0; }
  .up-item > .btn { flex: none; width: auto; padding: 8px 12px; }
  .up-vs { flex-wrap: wrap; row-gap: 0; }
  .up-vs .vs-red, .up-vs .vs-blue { white-space: normal; overflow: visible; }
  .up-cat { white-space: normal; }

  /* wide data tables scroll sideways instead of squeezing every column */
  .table-wrap.admin-wrap > .admin-table:not(#usersTable):not(.rg-ring-table):not(.rg-cat-table) { min-width: 680px; }
  .table-wrap.admin-wrap > .admin-table td:first-child { min-width: 170px; }

  /* forms: one field per row */
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }

  /* dialogs use the whole screen width */
  dialog { width: calc(100vw - 16px) !important; max-width: none; }
}
@media (max-width: 600px) {
  /* event cards: date + status on top, the name gets the full width */
  .event-card-top { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "date status" "title title"; gap: 8px 10px; }
  .event-card-top .date-chip { grid-area: date; }
  .event-card-top .status { grid-area: status; justify-self: end; align-self: start; }
  .event-card-top .event-card-title { grid-area: title; min-width: 0; }
  .event-card-title h3 { font-size: 17px; }
  .event-card-actions { flex-wrap: wrap; }

  /* judge: penalty buttons fit two per row */
  .rc-pen .sp-pen-btns .btn { font-size: 12px; padding: 6px 4px; white-space: normal; line-height: 1.2; min-height: 36px; }
  .rc-side .sp-tech-btn { padding: 6px 7px; gap: 6px; }
  .rc-heading .rc-event { font-size: 15px; }
}
@media (max-width: 600px) {
  .event-card-actions { flex-wrap: nowrap; gap: 6px; }
  .event-card-actions .btn { padding: 8px 9px; font-size: 13px; }
  .event-card-actions .spacer { flex: 1 1 0; min-width: 0; }
}

/* =====================================================================
   Participants module: add, bulk upload, search and complete
   ===================================================================== */
.pp-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.pp-actions h2 { font-size: 17px; }
.pp-actions p { margin: 4px 0 0; max-width: 60ch; }
.pp-toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.pp-toolbar input[type="search"] { flex: 1 1 240px; }
.pp-missing { background: #fff8e6; border: 1px solid #f3d98b; border-radius: 8px; padding: 8px 12px; margin: 0 0 10px; font-size: 13px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pp-list { display: flex; flex-direction: column; gap: 6px; }
.pp-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.pp-row.is-incomplete { border-left: 4px solid #e8a33c; }
.pp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pp-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pp-facts { display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--muted); }
.pp-acts { display: flex; gap: 6px; align-items: center; flex: none; }
.pp-miss { font-size: 10px; font-weight: 700; color: #8a5a00; background: #fff8e6; border: 1px solid #f3d98b; border-radius: 20px; padding: 0 7px; white-space: nowrap; }
.pp-needs { background: #fff8e6; border: 1px solid #f3d98b; border-radius: 8px; padding: 8px 10px; margin: 0 0 10px; }
#ppForm .needs { border-color: #e8a33c; box-shadow: 0 0 0 3px rgba(232, 163, 60, .18); }
#ppMore { margin-top: 8px; }
dialog#ppDialog { width: min(640px, calc(100vw - 24px)); }

dialog.bulk-dialog { width: min(980px, calc(100vw - 24px)); }
.bulk-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; cursor: pointer;
  border: 2px dashed var(--border); border-radius: 14px; padding: 34px 16px; background: var(--surface); margin-bottom: 12px;
}
.bulk-drop:hover { border-color: var(--primary); background: var(--tint); }
.bulk-drop input { max-width: 100%; }
.bulk-drop-ico { font-size: 34px; }
.bulk-file { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.bulk-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.bulk-stat { font-size: 13px; padding: 4px 10px; border-radius: 20px; border: 1px solid var(--border); background: #fff; }
.bulk-stat.ok { background: #eef8f1; border-color: #bfe3cc; color: #2f7d4f; }
.bulk-stat.warn { background: #fff8e6; border-color: #f3d98b; color: #8a5a00; }
.bulk-stat.bad { background: #fdeaea; border-color: #f1b7b7; color: var(--danger); }
.bulk-stat.info { background: var(--blue-tint); border-color: #c8d6f5; color: var(--blue-corner); }
.bulk-dialog h3 { font-size: 14px; margin: 14px 0 6px; }
.bulk-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 8px 12px; }
.bulk-map select { width: 100%; }
.bulk-map .bulk-need select { border-color: var(--danger); }
.bulk-state { max-width: 320px; margin-top: 10px; }
.bulk-sample td, .bulk-sample th { font-size: 12.5px; white-space: nowrap; }
.bulk-sample td.small { white-space: normal; min-width: 220px; }
.bulk-problems { margin-top: 10px; font-size: 13px; }
.bulk-problems summary { cursor: pointer; color: var(--warn); font-weight: 600; }
.bulk-problems ul { max-height: 200px; overflow: auto; margin: 6px 0 0; padding-left: 18px; }
.bulk-result { text-align: center; padding: 20px 10px; }
.bulk-result-big { font-size: 22px; font-weight: 800; color: #2f7d4f; margin-bottom: 8px; }

@media (max-width: 600px) {
  .pp-actions .row-actions { width: 100%; }
  .pp-actions .row-actions .btn { flex: 1 1 100%; justify-content: center; }
  .pp-row { align-items: flex-start; }
  .pp-acts { flex-direction: column; align-items: stretch; }
}
