/* ---------------------------------------------------------------- Tokens */
:root {
  color-scheme: light;
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --surface-3: #e7eaf2;
  --border: #dde1ea;
  --border-strong: #c9cfdb;
  --text: #171b26;
  --muted: #667085;
  --faint: #98a1b3;
  --accent: #5b5bd6;
  --accent-strong: #4a48c4;
  --accent-weak: #ecebfd;
  --accent-text: #ffffff;
  --win: #18864b;
  --win-weak: #e2f5ea;
  --lose: #9aa1b1;
  --draw: #a86512;
  --draw-weak: #fcf1df;
  --danger: #c9372c;
  --danger-weak: #fdecea;
  --line: #c4cad7;
  --gold: #c8960c;
  --silver: #8d98a6;
  --bronze: #a8693a;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 2px 8px rgba(20, 24, 40, .05);
  --shadow-lg: 0 8px 28px rgba(20, 24, 40, .14);
  --radius: 10px;
  --radius-sm: 7px;
  --card-w: 208px;
  --slot-h: 32px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1117;
    --surface: #171a23;
    --surface-2: #1d212c;
    --surface-3: #252a37;
    --border: #2a2f3d;
    --border-strong: #394052;
    --text: #e7e9f0;
    --muted: #9aa3b5;
    --faint: #6b7487;
    --accent: #8b8bff;
    --accent-strong: #a3a3ff;
    --accent-weak: #262849;
    --accent-text: #0f1117;
    --win: #4cc386;
    --win-weak: #173527;
    --lose: #6b7487;
    --draw: #e3a64e;
    --draw-weak: #3a2b14;
    --danger: #ff7b70;
    --danger-weak: #3d1d1b;
    --line: #3c4356;
    --gold: #e6b93a;
    --silver: #aab4c2;
    --bronze: #d08a54;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 10px rgba(0, 0, 0, .2);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .45);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1117; --surface: #171a23; --surface-2: #1d212c; --surface-3: #252a37; --border: #2a2f3d; --border-strong: #394052;
  --text: #e7e9f0; --muted: #9aa3b5; --faint: #6b7487; --accent: #8b8bff; --accent-strong: #a3a3ff; --accent-weak: #262849; --accent-text: #0f1117;
  --win: #4cc386; --win-weak: #173527; --lose: #6b7487; --draw: #e3a64e; --draw-weak: #3a2b14; --danger: #ff7b70; --danger-weak: #3d1d1b;
  --line: #3c4356; --gold: #e6b93a; --silver: #aab4c2; --bronze: #d08a54;
}

/* ---------------------------------------------------------------- Base */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.45 var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.icon, .format-icon, .summary-icon, .trophy, .empty-icon, .logo {
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------------------------------------------------------------- Buttons */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  font-weight: 550;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12.5px;
  color: var(--muted);
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.danger:hover { color: var(--danger); border-color: var(--danger); }
.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; font-size: inherit; }
.tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  margin-left: 6px;
  vertical-align: 1px;
}

/* ---------------------------------------------------------------- Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.logo { width: 28px; height: 28px; color: var(--accent); stroke-width: 2.4; flex: none; }
.title-input {
  font-size: 18px;
  font-weight: 700;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  min-width: 0;
  width: min(480px, 100%);
}
.title-input:hover { border-color: var(--border); }
.title-input:focus { border-color: var(--accent); outline: none; background: var(--surface-2); }
.top-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------------------------------------------------------------- Layout */
.layout { flex: 1; display: grid; grid-template-columns: 340px minmax(0, 1fr); min-height: 0; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 6px 0 24px;
}
.stage { overflow: auto; padding: 20px 24px 40px; min-width: 0; }
.panel { padding: 14px 18px; }
.panel + .panel { border-top: 1px solid var(--border); }
.panel-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.count {
  font-size: 11.5px;
  background: var(--surface-3);
  color: var(--text);
  padding: 1px 8px;
  border-radius: 999px;
  letter-spacing: 0;
  text-transform: none;
}

/* Format picker */
.format-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.format-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  text-align: left;
  padding: 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color .12s, background .12s;
}
.format-card:hover { border-color: var(--border-strong); }
.format-card.on { border-color: var(--accent); background: var(--accent-weak); }
.format-icon { width: 22px; height: 22px; grid-row: span 2; color: var(--muted); }
.format-card.on .format-icon { color: var(--accent); }
.format-name { font-weight: 650; font-size: 13px; line-height: 1.2; }
.format-desc { font-size: 11.5px; color: var(--muted); line-height: 1.3; margin-top: 2px; }

.options { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.options:empty { display: none; }
.opt { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.opt input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; }
.opt strong { display: block; font-weight: 600; font-size: 13px; }
.opt small { display: block; color: var(--muted); font-size: 12px; }
.opt-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.opt-label { font-weight: 600; font-size: 13px; min-width: 88px; }
.opt-note { color: var(--muted); font-size: 12px; flex-basis: 100%; padding-left: 98px; margin-top: -4px; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button { border: 0; background: var(--surface); padding: 5px 11px; font-size: 12.5px; color: var(--muted); }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button.on { background: var(--accent-weak); color: var(--accent); font-weight: 650; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.stepper button { border: 0; background: var(--surface); width: 30px; height: 28px; font-size: 16px; }
.stepper button:hover:not(:disabled) { background: var(--surface-2); }
.stepper-val { min-width: 32px; text-align: center; font-weight: 700; }

/* Players */
.add-form { display: flex; gap: 6px; }
.add-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
}
.add-form input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.tool-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.bulk { margin-top: 10px; }
.bulk textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  resize: vertical;
}
.bulk textarea:focus { outline: none; border-color: var(--accent); }
.bulk-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.hint { color: var(--faint); font-size: 12px; margin: 12px 0 6px; }
.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.empty-list { color: var(--muted); padding: 14px 0; text-align: center; font-size: 13px; }
.player {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 2px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  position: relative;
}
.player:hover { background: var(--surface-2); }
.player.dragging { opacity: .4; }
.player.drop-before::before, .player.drop-after::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}
.player.drop-before::before { top: -2px; }
.player.drop-after::after { bottom: -2px; }
.grip { cursor: grab; color: var(--faint); font-size: 12px; letter-spacing: -2px; padding: 0 3px; user-select: none; }
.seed-badge {
  flex: none;
  width: 24px; height: 22px;
  display: grid; place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-3);
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.pname {
  flex: 1;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  padding: 4px 6px;
}
.pname:hover { border-color: var(--border); }
.pname:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.player.dropped .pname { text-decoration: line-through; color: var(--muted); }
.row-actions { display: flex; gap: 1px; opacity: .35; transition: opacity .12s; }
.player:hover .row-actions, .player:focus-within .row-actions { opacity: 1; }
.icon-btn {
  border: 0;
  background: transparent;
  width: 24px; height: 24px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.icon-btn.remove:hover, .icon-btn.warn:hover { background: var(--danger-weak); color: var(--danger); }
.icon-btn.restore { color: var(--accent); }
.icon-btn.remove, .icon-btn.warn { font-size: 17px; }

/* ---------------------------------------------------------------- Stage: summary & podium */
.print-title { display: none; }
.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 28px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.summary-main { display: flex; align-items: center; gap: 12px; }
.summary-icon { width: 34px; height: 34px; color: var(--accent); background: var(--accent-weak); border-radius: 9px; padding: 6px; }
.summary-title { font-size: 17px; font-weight: 700; }
.summary-meta { color: var(--muted); font-size: 13px; }
.progress-wrap { min-width: 200px; flex: 0 1 280px; }
.progress-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; text-align: right; font-variant-numeric: tabular-nums; }
.progress { height: 7px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.stage-hint { color: var(--faint); font-size: 12.5px; margin: 0 0 6px; }

.podium {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 16px;
  animation: pop .35s ease-out;
}
@keyframes pop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
.podium-head { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 10px; }
.trophy { width: 22px; height: 22px; color: var(--gold); }
.podium-places { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.place { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.place-num {
  width: 30px; height: 30px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800;
  color: #fff;
  background: var(--faint);
}
.place.gold .place-num { background: var(--gold); }
.place.silver .place-num { background: var(--silver); }
.place.bronze .place-num { background: var(--bronze); }
.place.gold { background: color-mix(in srgb, var(--gold) 14%, var(--surface)); }
.place-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.place-name { font-weight: 700; font-size: 15px; }

/* ---------------------------------------------------------------- Match card */
.match {
  position: relative;
  z-index: 1;
  width: var(--card-w);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  flex: none;
}
.match.decided { border-color: var(--border-strong); }
.match.final { border-color: var(--accent); }
.match.ghost { visibility: hidden; }
.match.skipped { opacity: .45; box-shadow: none; border-style: dashed; }
.match.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: var(--shadow); } }
.match-tag {
  position: absolute;
  top: -17px;
  left: 2px;
  font: 600 10.5px/1 var(--mono);
  color: var(--faint);
  letter-spacing: .02em;
  white-space: nowrap;
}
.match-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px 4px;
  border-bottom: 1px solid var(--border);
  min-height: 27px;
}
.match-code { font: 600 11px/1 var(--mono); color: var(--faint); }
.draw-btn {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 999px;
  font-size: 11px;
  padding: 1px 8px;
  color: var(--muted);
}
.draw-btn:hover { border-color: var(--draw); color: var(--draw); }
.draw-btn.on { background: var(--draw-weak); border-color: var(--draw); color: var(--draw); font-weight: 650; }
.match-note { font-size: 11px; color: var(--muted); text-align: center; padding: 2px 0 4px; }

.slot {
  display: flex;
  align-items: center;
  height: var(--slot-h);
  padding-left: 6px;
  gap: 6px;
  position: relative;
}
.slot + .slot { border-top: 1px solid var(--border); }
.match-head + .slot { border-top: 0; }
.slot:first-of-type { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.slot .seed {
  width: 18px;
  flex: none;
  font-size: 11px;
  color: var(--faint);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.slot .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 520; }
.slot.tbd .name { color: var(--faint); font-style: italic; font-weight: 400; font-size: 12.5px; }
.slot.clickable { cursor: pointer; }
.slot.clickable:hover { background: var(--surface-2); }
.slot.clickable:focus-visible { outline-offset: -2px; }
.slot.win { background: var(--win-weak); }
.slot.win .name { font-weight: 700; color: var(--win); }
.slot.win::before {
  content: "";
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--win);
}
.slot.lose .name { color: var(--lose); }
.slot.draw { background: var(--draw-weak); }
.slot.draw .name { color: var(--draw); font-weight: 600; }
.match > .slot:last-child { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.score {
  width: 38px;
  height: 100%;
  flex: none;
  border: 0;
  border-left: 1px solid var(--border);
  background: transparent;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 0;
}
.score::placeholder { color: var(--faint); font-weight: 400; }
.score:hover { background: var(--surface-3); }
.score:focus { outline: none; background: var(--accent-weak); box-shadow: inset 0 0 0 2px var(--accent); }
.slot.win .score { color: var(--win); }

/* ---------------------------------------------------------------- Bracket */
.bracket-scroll { overflow-x: auto; padding-bottom: 12px; }
.bracket-section + .bracket-section { margin-top: 18px; }
.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin: 18px 0 4px;
}
.bracket-section .section-title { margin-top: 6px; }
.bracket-row {
  position: relative;
  display: flex;
  align-items: stretch;
  width: max-content;
  padding: 4px 4px 4px 0;
}
.round { display: flex; flex-direction: column; flex: none; }
.round + .round { margin-left: 56px; }
.round-title {
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  text-align: center;
  padding: 4px 0 6px;
  border-bottom: 2px solid var(--surface-3);
  margin-bottom: 8px;
  white-space: nowrap;
}
.round-matches {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 28px;
  padding: 18px 0 6px;
}
.connectors {
  position: absolute;
  inset: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 0;
  fill: none;
  stroke: var(--line);
  stroke-width: 1.6;
  stroke-linejoin: round;
}
.connectors path.live { stroke: var(--accent); stroke-width: 2; }

/* ---------------------------------------------------------------- Tables */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.table-card { padding: 12px 14px 8px; min-width: 0; }
.card-title { margin: 0 0 8px; font-size: 13px; font-weight: 700; }
.table-scroll { overflow-x: auto; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; align-items: start; }
table { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.standings { width: 100%; }
.standings th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 650;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.standings td { padding: 7px 8px; text-align: center; border-bottom: 1px solid var(--border); }
.standings tr:last-child td { border-bottom: 0; }
.standings .left { text-align: left; }
.standings td.left { font-weight: 560; white-space: nowrap; }
.standings .seed { font-size: 11px; color: var(--faint); display: inline-block; min-width: 16px; text-align: right; }
.standings .rank { color: var(--muted); font-weight: 650; width: 28px; }
.standings .pts { font-weight: 800; }
.standings tr.leader td { background: color-mix(in srgb, var(--gold) 12%, transparent); }
.standings tr.leader .rank { color: var(--gold); }
.standings tr.dropped td { color: var(--faint); }

.cross th, .cross td { border: 1px solid var(--border); }
.cross thead th { font-size: 11px; color: var(--muted); font-weight: 650; padding: 4px; min-width: 40px; }
.cross .corner { border: 0; }
.cross .row-head {
  text-align: left;
  font-weight: 560;
  padding: 4px 10px 4px 6px;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cross .row-head .seed { font-size: 11px; color: var(--faint); }
.cross td { padding: 2px; text-align: center; min-width: 40px; height: 32px; }
.cross td.self { background: repeating-linear-gradient(135deg, var(--surface-2) 0 4px, var(--surface-3) 4px 8px); }
.xres {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 650;
  padding: 3px 2px;
  background: transparent;
  color: var(--faint);
}
.xres + .xres { margin-top: 2px; }
.xres:hover { outline: 1px solid var(--border-strong); }
.xres.win { background: var(--win-weak); color: var(--win); }
.xres.lose { background: var(--danger-weak); color: var(--danger); }
.xres.draw { background: var(--draw-weak); color: var(--draw); }

/* ---------------------------------------------------------------- Fixtures (RR & Swiss) */
.rounds-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 14px; }
.round-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.round-block .match { width: 100%; }
.round-block-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; font-size: 13px; padding: 0 2px; }
.bye-row { font-size: 12.5px; color: var(--muted); padding: 2px 4px; }
.bye-row .tag { margin-left: 0; }

.swiss-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.swiss-status { font-weight: 700; }
.swiss-buttons { display: flex; gap: 8px; }
.swiss-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 16px; align-items: start; }
.swiss-rounds { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.swiss-rounds .round-block { width: 248px; flex: none; }

/* ---------------------------------------------------------------- Empty & toast */
.empty { max-width: 420px; margin: 12vh auto; text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); margin: 14px 0 6px; font-size: 19px; }
.empty p { margin: 0 0 18px; }
.empty-icon { width: 64px; height: 64px; color: var(--accent); background: var(--accent-weak); padding: 14px; border-radius: 18px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  max-width: calc(100vw - 32px);
}

/* ---------------------------------------------------------------- Screens */
body.mode-home .editor-only, body.mode-editor .home-only { display: none !important; }
body:not(.mode-home):not(.mode-editor) .layout, body:not(.mode-home):not(.mode-editor) .home { display: none; }

.home-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius-sm);
  padding: 3px 8px 3px 4px;
  flex: none;
}
.home-label { font-weight: 700; font-size: 15px; white-space: nowrap; }
.back-chevron { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); display: none; }
body.mode-editor .back-chevron { display: block; }
body.mode-editor .home-label { color: var(--muted); font-weight: 600; font-size: 14px; }
body.mode-editor .home-link:hover { background: var(--surface-2); }
body.mode-editor .home-link:hover .home-label, body.mode-editor .home-link:hover .back-chevron { color: var(--text); }
body.mode-home .home-link { pointer-events: none; }
.crumb-sep { color: var(--faint); }

/* ---------------------------------------------------------------- Library */
.home { flex: 1; overflow-y: auto; }
.home-inner { max-width: 1180px; margin: 0 auto; padding: 28px 24px 48px; }
.home-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.home-head h1 { margin: 0 0 4px; font-size: 24px; display: flex; align-items: center; gap: 10px; }
.home-head h1 .count { font-size: 12px; font-weight: 600; }
.home-head p { margin: 0; }
.home-buttons { display: flex; gap: 8px; }
.home-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.home-tools[hidden] { display: none; }
.home-tools input[type="search"], .sort select, .field input, .field select {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
}
.home-tools input[type="search"] { flex: 1; min-width: 180px; max-width: 360px; }
.home-tools input:focus, .sort select:focus, .field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.sort { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }

.t-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.t-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  min-height: 186px;
  transition: border-color .12s, transform .12s, box-shadow .12s;
}
.t-card:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.t-card:focus-within { border-color: var(--accent); }
.t-open { position: absolute; inset: 0; border-radius: var(--radius); z-index: 1; }
.t-open:focus-visible { outline-offset: -2px; }
.t-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.t-icon { width: 36px; height: 36px; padding: 7px; border-radius: 9px; background: var(--accent-weak); color: var(--accent); fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.t-card.complete .t-icon { background: color-mix(in srgb, var(--gold) 16%, var(--surface)); color: var(--gold); }
.t-actions { position: relative; z-index: 2; display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.t-card:hover .t-actions, .t-card:focus-within .t-actions { opacity: 1; }
.t-actions .icon-btn { width: 30px; height: 30px; display: grid; place-items: center; }
.t-actions .icon { width: 17px; height: 17px; }
.t-name { margin: 0; font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
.t-meta { color: var(--muted); font-size: 12.5px; }
.t-status { margin-top: auto; padding-top: 6px; }
.t-card .progress { height: 5px; }
.t-foot { color: var(--faint); font-size: 12px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pill.live { background: var(--accent-weak); color: var(--accent); }
.pill.done { background: color-mix(in srgb, var(--gold) 16%, var(--surface)); color: var(--gold); }
.pill-icon { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.t-new {
  align-items: center;
  justify-content: center;
  border: 1.5px dashed var(--border-strong);
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-weight: 650;
  font-size: 14px;
}
.t-new:hover { color: var(--accent); background: var(--accent-weak); }
.t-new-plus { font-size: 30px; font-weight: 300; line-height: 1; }
.home-empty { margin-top: 6vh; grid-column: 1 / -1; }
.no-match { grid-column: 1 / -1; }

/* ---------------------------------------------------------------- Dialog */
.dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  padding: 22px 22px 18px;
  width: min(460px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(10, 12, 20, .45); }
.dialog h2 { margin: 0 0 16px; font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.restore-paste { margin-top: 14px; }
.restore-paste textarea {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font: 12px/1.4 var(--mono);
  resize: vertical;
}
.restore-paste textarea:focus { outline: none; border-color: var(--accent); }
#restoreMsg { margin-bottom: 8px !important; }

.toast { display: flex; align-items: center; gap: 12px; }
.toast[hidden] { display: none; }
.toast-action { border: 0; background: none; color: var(--accent-weak); font-weight: 700; padding: 0; text-decoration: underline; }

/* ---------------------------------------------------------------- Phone registration (organizer) */
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.reg-box { margin-bottom: 12px; }
.reg-start {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 10px 12px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: transparent;
}
.reg-start:hover { border-color: var(--accent); background: var(--accent-weak); }
.reg-start strong { display: block; font-size: 13px; }
.reg-start small { display: block; font-size: 12px; color: var(--muted); }
.reg-start-icon { width: 26px; height: 26px; flex: none; color: var(--accent); fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.reg-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--surface-2);
}
.reg-card.open { border-color: color-mix(in srgb, var(--win) 45%, var(--border)); background: color-mix(in srgb, var(--win) 7%, var(--surface)); }
.reg-line { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 13px; }
.reg-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.reg-card.open .reg-dot { background: var(--win); box-shadow: 0 0 0 0 color-mix(in srgb, var(--win) 60%, transparent); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--win) 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.reg-state { flex: 1; }
.reg-code { font: 700 13px/1 var(--mono); letter-spacing: .12em; background: var(--surface); border: 1px solid var(--border); padding: 4px 7px; border-radius: 6px; }
.reg-sub { color: var(--muted); font-size: 12px; margin: 3px 0 8px 16px; }
.reg-actions { display: flex; gap: 6px; }
.reg-warn {
  background: var(--danger-weak);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 12.5px;
  margin: 8px 0;
}
.reg-warn[hidden] { display: none; }
.reg-waiting { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.reg-waiting strong { display: block; font-size: 13px; }
.reg-waiting small { display: block; color: var(--muted); font-size: 12px; }
.reg-names { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-static {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  font-size: 13px;
  font-weight: 550;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip-static.phone::before { content: "●"; color: var(--win); font-size: 9px; margin-right: 6px; vertical-align: 2px; }
.chip-static.fresh { background: var(--win-weak); color: var(--win); animation: pop .4s ease-out; }
.chip-static.me { background: var(--accent); color: var(--accent-text); }
.pill.reg { background: var(--win-weak); color: var(--win); margin-left: 6px; font-family: var(--mono); }

.reg-dialog { width: min(860px, calc(100vw - 32px)); padding: 26px 28px 20px; }
.dialog-x { position: absolute; top: 10px; right: 10px; font-size: 22px; width: 34px; height: 34px; }
.reg-dialog:fullscreen {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  border: 0;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.reg-dialog:fullscreen #regDialogBody { width: min(1200px, 100%); }
.reg-dialog:fullscreen .qr { width: min(46vh, 42vw); }
.reg-dialog:fullscreen .big-code span { font-size: clamp(40px, 7vw, 84px); width: 1.15em; }
.reg-dialog:fullscreen .reg-title { font-size: clamp(26px, 4vw, 46px); }
.reg-hero { display: flex; gap: 30px; align-items: center; flex-wrap: wrap; }
.qr {
  position: relative;
  width: 260px;
  max-width: 100%;
  flex: none;
  background: #fff;
  padding: 10px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.qr svg { display: block; width: 100%; height: auto; }
.qr.closed svg { opacity: .12; }
.qr-closed { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; color: #1b1f2a; font-size: 18px; text-align: center; }
.reg-info { flex: 1; min-width: 240px; }
.reg-kicker { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); }
.reg-title { margin: 2px 0 14px; font-size: 26px; line-height: 1.15; overflow-wrap: anywhere; }
.reg-steps { margin: 0 0 6px; color: var(--muted); }
.reg-url { font: 700 17px/1.3 var(--mono); margin-bottom: 10px; overflow-wrap: anywhere; }
.big-code { display: flex; gap: 8px; }
.big-code span {
  display: grid;
  place-items: center;
  width: 1.2em;
  height: 1.45em;
  font: 800 44px/1 var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.reg-roster { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); }
.reg-roster-head { display: flex; align-items: baseline; gap: 4px; margin-bottom: 10px; }
.live-dot { margin-left: auto; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--win); }
.live-dot::before { content: "●"; margin-right: 5px; }
.live-dot.off { color: var(--danger); }
.reg-roster .reg-names { max-height: 150px; overflow-y: auto; }
.reg-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.reg-buttons { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.net-pick { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.net-pick select { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm); padding: 4px 6px; font-size: 12.5px; max-width: 300px; }
.danger-link { color: var(--danger); margin-right: 6px; }
.cmd { font: 600 14px/1.4 var(--mono); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }

/* ---------------------------------------------------------------- Phone join page */
body.join-page { overflow: auto; display: block; height: auto; min-height: 100%; }
.join-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.join-top .logo { width: 22px; height: 22px; }
.join-main { max-width: 480px; margin: 0 auto; padding: 18px 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.join-head { text-align: center; padding: 6px 0 2px; }
.join-kicker { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); }
.join-head h1 { margin: 4px 0 6px; font-size: 26px; line-height: 1.2; overflow-wrap: anywhere; }
.join-code { color: var(--muted); font-size: 13px; }
.join-code strong { font-family: var(--mono); letter-spacing: .1em; color: var(--text); }
.join-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 20px 18px;
  text-align: center;
}
.join-card h1 { font-size: 22px; margin: 0 0 6px; }
.join-card h2 { font-size: 19px; margin: 0 0 6px; }
.join-card p { margin: 0 0 14px; }
.join-form { display: flex; flex-direction: column; gap: 10px; }
.join-input {
  width: 100%;
  font-size: 18px;
  padding: 13px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  text-align: center;
}
.join-input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.code-input { font: 800 28px/1 var(--mono); letter-spacing: .25em; text-transform: uppercase; }
.join-btn { width: 100%; padding: 13px 16px; font-size: 16px; border-radius: 10px; }
.join-error { color: var(--danger); font-size: 14px; min-height: 0; margin: 0 !important; }
.join-error:empty { display: none; }
.join-name { font-size: 24px; font-weight: 800; margin: 4px 0 8px; overflow-wrap: anywhere; }
.join-actions { display: flex; flex-direction: column; gap: 8px; }
.danger-text { color: var(--danger); }
.status-icon {
  width: 64px; height: 64px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 30px; font-weight: 800;
}
.status-icon.ok { background: var(--win-weak); color: var(--win); animation: pop .4s ease-out; }
.status-icon.wait { background: var(--accent-weak); color: var(--accent); }
.status-icon.closed { background: var(--danger-weak); color: var(--danger); }
.join-roster h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 4px 2px 10px; }

/* ---------------------------------------------------------------- Avatars (organizer) */
.avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  display: inline-grid;
  place-items: center;
  background: var(--surface-3);
}
.avatar.initials {
  background: hsl(var(--hue, 240) 55% 88%);
  color: hsl(var(--hue, 240) 45% 30%);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: -.02em;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .avatar.initials { background: hsl(var(--hue, 240) 35% 26%); color: hsl(var(--hue, 240) 70% 85%); }
}
.avatar.sm { width: 22px; height: 22px; font-size: 9px; }
.avatar.chip { width: 22px; height: 22px; margin: -2px 6px -2px -7px; vertical-align: middle; }
.avatar.lg { width: 44px; height: 44px; border: 2px solid var(--surface); box-shadow: var(--shadow); }
.chip-static.with-photo { padding-left: 9px; }
.avatar-btn { border: 0; padding: 0; background: none; border-radius: 50%; display: grid; }
.avatar-btn:hover .avatar { outline: 2px solid var(--danger); }
.place-avatars { display: flex; }
.place-avatars .avatar + .avatar { margin-left: -10px; }
.slot .avatar { margin-left: -2px; }

/* ---------------------------------------------------------------- Selfie (phone) */
.selfie-pick {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  margin: 2px 0 14px;
  padding: 10px;
  border-radius: 12px;
  background: var(--surface-2);
}
.selfie-btn {
  width: 72px; height: 72px;
  flex: none;
  border-radius: 50%;
  border: 2px dashed var(--accent);
  background: var(--accent-weak);
  display: grid;
  place-items: center;
  padding: 0;
  overflow: hidden;
}
.selfie-btn.has { border: 3px solid var(--accent); }
.selfie-btn img { width: 100%; height: 100%; object-fit: cover; }
.selfie-cam { font-size: 30px; }
.selfie-cta strong { display: block; font-size: 15px; }
.selfie-cta small { display: block; color: var(--muted); font-size: 12.5px; margin-bottom: 2px; }
.status-photo { position: relative; width: 120px; height: 120px; margin: 0 auto 12px; animation: pop .4s ease-out; }
.status-photo img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 3px solid var(--surface); box-shadow: var(--shadow-lg); }
.status-badge {
  position: absolute; right: 0; bottom: 2px;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800; font-size: 18px;
  border: 3px solid var(--surface);
}
.status-badge.ok { background: var(--win); color: #fff; }
.status-badge.wait { background: var(--accent); color: var(--accent-text); }
.status-badge.closed { background: var(--danger); color: #fff; }

body.selfie-open { overflow: hidden; }
.selfie-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 10, 16, .75);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.selfie-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 100%;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 10px 14px max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}
@media (min-width: 520px) { .selfie-overlay { align-items: center; } .selfie-sheet { border-radius: 18px; max-height: 96vh; } }
.selfie-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.selfie-head strong { font-size: 16px; }
.selfie-stage { display: flex; justify-content: center; }
.selfie-canvas {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1;
  border-radius: 14px;
  touch-action: none;
  background: #000;
  box-shadow: var(--shadow);
  cursor: grab;
}
.selfie-tools { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.selfie-tools[hidden] { display: none; }
.selfie-tools button {
  min-width: 40px; height: 36px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 9px;
  font-size: 17px;
  padding: 0 10px;
}
.selfie-tools .del { color: var(--danger); font-size: 13px; font-weight: 650; }
.selfie-row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.selfie-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 4px; }
.selfie-label small { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--faint); }
.selfie-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.selfie-filter {
  flex: none;
  width: 74px;
  border: 0;
  background: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  scroll-snap-align: start;
}
.selfie-thumb { width: 64px; height: 64px; border-radius: 12px; border: 2.5px solid transparent; display: block; }
.selfie-filter.on { color: var(--accent); }
.selfie-filter.on .selfie-thumb { border-color: var(--accent); }
.selfie-sticker {
  flex: none;
  width: 52px; height: 52px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 12px;
  font-size: 30px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.selfie-sticker:active { transform: scale(.92); }
.sticker-canvas { width: 40px; height: 40px; border-radius: 6px; }

/* ---------------------------------------------------------------- Present button, standings avatars, big avatars */
.summary-side { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.present-btn { font-weight: 650; }
.celebrate-btn { margin-left: auto; }
.standing-name { display: inline-flex; align-items: center; gap: 7px; }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.avatar.xl { width: min(34vh, 30vw); height: min(34vh, 30vw); font-size: min(11vh, 9vw); border: 5px solid rgba(255,255,255,.9); box-shadow: 0 12px 40px rgba(0,0,0,.45); }
.avatar.xxl { width: min(40vh, 60vw); height: min(40vh, 60vw); font-size: min(13vh, 18vw); border: 7px solid #f5c542; box-shadow: 0 0 0 6px rgba(245,197,66,.25), 0 16px 60px rgba(0,0,0,.5); }
.avatar.wall { width: 76px; height: 76px; font-size: 22px; box-shadow: var(--shadow); }

/* ---------------------------------------------------------------- Check-in photo wall */
.photo-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 12px 8px;
  max-height: 290px;
  overflow-y: auto;
  padding: 4px 2px;
}
.wall-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; text-align: center; }
.wall-name { font-size: 12.5px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wall-phone { color: var(--win); font-size: 9px; margin-right: 4px; vertical-align: 2px; }
.wall-tile.fresh .avatar { animation: wallpop .7s cubic-bezier(.2, 1.6, .4, 1); box-shadow: 0 0 0 4px var(--win), 0 0 22px color-mix(in srgb, var(--win) 60%, transparent); }
.wall-tile.fresh .wall-name { color: var(--win); }
@keyframes wallpop { 0% { transform: scale(.2) rotate(-12deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.reg-dialog:fullscreen #regDialogBody {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  column-gap: 48px;
  align-items: start;
}
.reg-dialog:fullscreen .reg-hero { flex-direction: column; align-items: flex-start; grid-row: 1 / span 3; }
.reg-dialog:fullscreen .reg-roster { grid-column: 2; margin-top: 0; padding-top: 0; border-top: 0; }
.reg-dialog:fullscreen .reg-warn { grid-column: 2; }
.reg-dialog:fullscreen .reg-footer { grid-column: 1 / -1; }
.reg-dialog:fullscreen .photo-wall { max-height: 70vh; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 20px 12px; }
.reg-dialog:fullscreen .avatar.wall { width: 112px; height: 112px; font-size: 32px; }
.reg-dialog:fullscreen .wall-name { font-size: 16px; }

/* ---------------------------------------------------------------- Presentation (projector) view */
.show-dialog {
  --show-bg: #0d0f1a;
  --show-text: #f3f4fa;
  --show-muted: #a4abc2;
  width: min(1280px, calc(100vw - 24px));
  height: min(860px, calc(100vh - 24px));
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  border-radius: 18px;
  color: var(--show-text);
  background: radial-gradient(1200px 700px at 50% 30%, #262a5a 0%, var(--show-bg) 70%);
  overflow: hidden;
}
.show-dialog::backdrop { background: rgba(5, 6, 12, .8); }
.show-dialog:fullscreen { width: 100vw; height: 100vh; border-radius: 0; }
#showBody { height: 100%; display: flex; flex-direction: column; }
.show-top { display: flex; align-items: center; gap: 16px; padding: 14px 20px; flex: none; }
.show-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.show-logo { width: 26px; height: 26px; fill: none; stroke: #9b9bff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.show-tabs { display: flex; background: rgba(255,255,255,.08); border-radius: 999px; padding: 3px; }
.show-tabs button { border: 0; background: none; color: var(--show-muted); padding: 6px 16px; border-radius: 999px; font-weight: 650; }
.show-tabs button.on { background: rgba(255,255,255,.95); color: #14162a; }
.show-top-btns { display: flex; gap: 8px; flex: 1; justify-content: flex-end; }
.show-btn {
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.08);
  color: var(--show-text);
  border-radius: 999px;
  padding: 7px 16px;
  font-weight: 650;
}
.show-btn:hover { background: rgba(255,255,255,.16); }
.show-btn.close { width: 38px; height: 38px; padding: 0; font-size: 22px; line-height: 1; }
.show-scene { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vh; padding: 0 3vw 3vh; position: relative; }
.show-label { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.show-kicker { font-size: clamp(13px, 1.6vw, 20px); font-weight: 800; letter-spacing: .2em; text-transform: uppercase; color: #9b9bff; }
.show-label span:last-child { font-size: clamp(15px, 2vw, 26px); color: var(--show-muted); font-weight: 600; }
.show-versus { display: flex; align-items: center; justify-content: center; gap: 3vw; width: 100%; }
.show-player {
  flex: 1;
  max-width: 44vw;
  border: 0;
  background: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2vh;
  padding: 2vh 1vw;
  border-radius: 24px;
  transition: transform .25s, filter .5s, opacity .5s, background .2s;
}
.show-player:not(:disabled):hover { background: rgba(255,255,255,.06); transform: translateY(-4px); }
.show-player:not(:disabled):hover .avatar { border-color: #3ccf91; }
.show-player:disabled { cursor: default; opacity: 1; }
.show-face-wrap { position: relative; }
.show-name { font-size: clamp(22px, 3.6vw, 52px); font-weight: 800; line-height: 1.1; overflow-wrap: anywhere; text-align: center; }
.show-seed { font-size: clamp(12px, 1.4vw, 18px); color: var(--show-muted); font-weight: 600; }
.show-verdict { font-size: clamp(18px, 2.6vw, 34px); font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.show-player.winner { animation: winnerpop .6s cubic-bezier(.2, 1.6, .4, 1); }
.show-player.winner .avatar { border-color: #f5c542; box-shadow: 0 0 0 8px rgba(245,197,66,.3), 0 0 80px rgba(245,197,66,.5); }
.show-player.winner .show-verdict { color: #f5c542; }
.show-player.loser { filter: grayscale(1) brightness(.55); transform: scale(.88) rotate(-3deg); }
.show-player.loser .show-verdict { color: #ff7b70; }
.show-player.draw .show-verdict { color: #e3a64e; }
@keyframes winnerpop { 0% { transform: scale(.9); } 60% { transform: scale(1.1); } 100% { transform: scale(1.04); } }
.show-crown { position: absolute; top: -9%; left: 50%; transform: translateX(-50%) rotate(-8deg); font-size: min(10vh, 8vw); filter: drop-shadow(0 6px 10px rgba(0,0,0,.4)); animation: crowndrop .5s ease-out; }
@keyframes crowndrop { from { transform: translate(-50%, -60%) rotate(-30deg); opacity: 0; } }
.vs {
  font-size: clamp(36px, 7vw, 110px);
  font-weight: 900;
  font-style: italic;
  background: linear-gradient(180deg, #ffd34d, #ff5d8f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 20px rgba(255,93,143,.45));
  animation: vspulse 1.6s ease-in-out infinite;
  flex: none;
}
@keyframes vspulse { 50% { transform: scale(1.08); } }
.show-controls { display: flex; align-items: center; gap: 14px; min-height: 48px; }
.show-nav { width: 48px; height: 48px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); color: inherit; font-size: 26px; line-height: 1; }
.show-nav:disabled { opacity: .25; }
.show-hint { color: var(--show-muted); font-size: clamp(13px, 1.4vw, 18px); }
.empty-scene h2 { font-size: clamp(24px, 3.4vw, 44px); margin: 0; text-align: center; }
.show-empty-emoji { font-size: clamp(60px, 10vw, 140px); }
.show-cta { border: 0; border-radius: 999px; padding: 14px 28px; font-size: clamp(16px, 1.8vw, 22px); font-weight: 800; background: #f5c542; color: #1a1400; }

.champion { gap: 1.4vh; }
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.champ-kicker { font-size: clamp(16px, 2.2vw, 30px); font-weight: 900; letter-spacing: .3em; text-transform: uppercase; color: #f5c542; animation: pop .6s ease-out; }
.champ-faces { display: flex; gap: 3vw; }
.champ-face { position: relative; animation: winnerpop .8s cubic-bezier(.2, 1.6, .4, 1); }
.champ-crown { position: absolute; top: -14%; left: 50%; transform: translateX(-50%) rotate(-10deg); font-size: min(12vh, 14vw); z-index: 1; filter: drop-shadow(0 8px 12px rgba(0,0,0,.45)); animation: crowndrop .7s .3s ease-out both; }
.champ-name { font-size: clamp(30px, 5.5vw, 84px); font-weight: 900; margin: 0; text-align: center; line-height: 1.05; text-shadow: 0 6px 30px rgba(0,0,0,.4); overflow-wrap: anywhere; }
.champ-rest { display: flex; gap: 4vw; flex-wrap: wrap; justify-content: center; }
.champ-place { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,.07); border-radius: 999px; padding: 6px 20px 6px 6px; }
.champ-small { display: flex; }
.champ-small .avatar + .avatar { margin-left: -14px; }
.champ-place-label { font-size: 13px; color: var(--show-muted); font-weight: 700; }
.champ-place-name { font-size: clamp(16px, 1.8vw, 24px); font-weight: 800; }
.show-btn.again { position: absolute; bottom: 2vh; right: 2vw; z-index: 3; }

@media (prefers-reduced-motion: reduce) {
  .vs, .show-player.winner, .champ-face, .champ-crown, .show-crown, .wall-tile.fresh .avatar, .champ-kicker { animation: none !important; }
  .show-player { transition: none; }
}
@media (max-width: 640px) {
  .show-top { flex-wrap: wrap; }
  .show-tabs { order: 3; width: 100%; justify-content: center; }
  .show-versus { gap: 2vw; }
  .avatar.xl { width: 32vw; height: 32vw; }
}

/* ---------------------------------------------------------------- Phone: next match & results */
.pp { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 16px; text-align: left; }
.pp-kicker { font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.pp-label { font-size: 13px; color: var(--muted); margin: 2px 0 10px; }
.pp-next, .pp-last { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.pp-vs { display: flex; align-items: center; justify-content: space-around; gap: 8px; }
.pp-side { display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 700; min-width: 0; flex: 1; }
.pp-side span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-face { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 3px solid var(--surface); box-shadow: var(--shadow); background: var(--surface-3); display: grid; place-items: center; font-weight: 800; font-size: 22px; color: var(--muted); }
.pp-vs-badge { font-weight: 900; font-style: italic; font-size: 24px; color: var(--accent); }
.pp-hint { color: var(--muted); font-size: 13.5px; text-align: center; margin-top: 8px; }
.pp-big { font-size: 20px; font-weight: 800; text-align: center; margin-top: 6px; }
.pp-last-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-weight: 600; }
.pp-last-row .pp-face { width: 40px; height: 40px; font-size: 14px; flex: none; }
.pp-last.won { border-color: color-mix(in srgb, var(--win) 50%, var(--border)); background: var(--win-weak); }
.pp-last.lost { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: var(--danger-weak); }
.pp-last.draw { background: var(--draw-weak); }
.pp-banner { text-align: center; font-size: 20px; font-weight: 900; padding: 14px; border-radius: 12px; background: var(--accent-weak); color: var(--accent); }
.pp-banner.place-1 { background: color-mix(in srgb, var(--gold) 22%, var(--surface)); color: var(--gold); font-size: 22px; animation: pop .5s ease-out; }
.pp-banner.out { background: var(--danger-weak); color: var(--danger); }
.pp-rank { text-align: center; font-weight: 700; color: var(--muted); font-size: 14px; }

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 1100px) {
  .split, .swiss-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  body { overflow: auto; height: auto; }
  .layout { display: block; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); overflow: visible; }
  .stage { overflow: visible; padding: 16px; }
  .topbar { flex-wrap: wrap; padding: 10px 16px; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .panel { padding: 14px 16px; }
  .row-actions { opacity: 1; }
  .home { overflow: visible; }
  .home-inner { padding: 20px 16px 40px; }
  .t-actions { opacity: 1; }
  .home-label { display: none; }
  body.mode-home .home-label { display: inline; }
}
@media (max-width: 380px) {
  .format-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- Print */
@media print {
  body { overflow: visible; height: auto; background: #fff; display: block; }
  .topbar, .sidebar, .stage-hint, .swiss-controls, .draw-btn, .progress-wrap { display: none !important; }
  .layout { display: block; }
  .stage { overflow: visible; padding: 0; }
  .print-title { display: block; font-size: 20px; margin: 0 0 10px; }
  .bracket-scroll, .swiss-rounds, .table-scroll { overflow: visible; }
  .match, .card, .podium { box-shadow: none; }
  .score::placeholder { color: transparent; }
}

/* Privacy page and footer link */
.legal { line-height: 1.6; gap: 0; }
.legal h1 { margin: 8px 0 0; font-size: 26px; }
.legal h2 { margin: 22px 0 4px; font-size: 17px; }
.legal p, .legal ul { margin: 6px 0; }
.legal ul { padding-left: 20px; }
.legal a, .site-foot a { color: var(--accent); }
.site-foot { text-align: center; padding: 24px 16px 32px; font-size: 13px; }
.site-foot a { color: var(--muted); }
.share-qr { margin-top: 8px; font-size: 12px; }
.share-qr summary { cursor: pointer; color: var(--muted); }
.share-qr .qr { max-width: 200px; margin-top: 8px; }
