:root {
  /* Палитра под референс «IN PIECES»: почти чёрный фон,
     насыщенный алый акцент и глубокий бордовый как второстепенный тон,
     плюс лёгкий малиновый оттенок для объёма на отдельных гранях. */
  --bg: #121013;
  --panel: #1b171b;
  --panel-alt: #221c21;
  --panel-hover: #2b2328;
  --border: #3d2c31;
  --text: #f7f4f5;
  --text-muted: #b9adb0;
  --text-dim: #7a6d70;

  /* 10% — акцент: яркий алый, как основные грани букв */
  --accent: #e5233a;
  --accent-dim: rgba(229, 35, 58, 0.16);
  --accent-strong: #ff3b4e;

  /* 30% — второстепенный: глубокий бордовый, как тёмные грани букв */
  --secondary: #6e1a26;
  --secondary-dim: rgba(110, 26, 38, 0.28);
  --secondary-strong: #9c2635;

  /* Малиновый — точечный третий оттенок для граней/подсветки, как на "S" в референсе */
  --magenta: #c9296a;
  --magenta-dim: rgba(201, 41, 106, 0.18);
  --magenta-strong: #e8407f;

  --gold: #EAB308;
  --gold-dim: rgba(234, 179, 8, 0.14);
  --gold-strong: #FACC15;
  --green: #6fcf73;
  --green-dim: rgba(111, 207, 115, 0.14);
  --red: #ff4d5e;
  --line: #3d2c31;
  --font-display: "Sora", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ---------- layout shell ---------- */
.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px 80px;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.5px;
  margin-right: auto;
}
.brand-mark {
  display: block;
  width: 30px; height: 30px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}
.accent { color: var(--accent); }
.brand-ffa { color: var(--red); }
.brand-beamerz { color: var(--text); }
.topbar-mid { display: flex; gap: 10px; align-items: center; }
.topbar-right { display: flex; gap: 10px; }

/* ---------- buttons & inputs ---------- */
.btn {
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 8px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  color: var(--text);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-hover); border-color: #33383f; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #ffffff; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-secondary { background: var(--secondary-dim); border-color: rgba(122,42,46,0.55); color: var(--accent-strong); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: rgba(255,77,94,0.14); border-color: rgba(255,77,94,0.45); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.select, .input {
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--text);
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
}
.select:focus, .input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text-dim); }

/* ---------- empty state ---------- */
.empty-state { display: grid; place-items: center; padding: 90px 20px; }
.empty-card {
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  max-width: 420px;
}
.empty-card h2 { font-family: var(--font-display); margin: 0 0 8px; }
.empty-card p { color: var(--text-muted); margin: 0 0 22px; font-size: 14px; }

/* ---------- tournament header ---------- */
.tournament-header {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.th-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 10px; }
.th-badges { display: flex; gap: 8px; }
.badge {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--green-dim);
  color: var(--green);
}
.badge-outline { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.th-actions { display: flex; gap: 8px; }
.th-title { font-family: var(--font-display); font-size: 30px; margin: 0 0 18px; }
.th-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.progress-row { display: flex; align-items: center; gap: 12px; }
.progress-track { flex: 1; height: 6px; background: var(--panel-alt); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); transition: width .3s ease; }
.progress-label { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ---------- participants panel ---------- */
.participants-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 18px;
}
.participants-panel h3 { margin: 0; font-family: var(--font-display); font-size: 15px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.participants-toggle {
  all: unset;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  cursor: pointer;
  margin-bottom: 12px;
}
.participants-count { color: var(--text-dim); font-size: 12.5px; }
.participants-toggle-label {
  margin-left: auto;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--accent-strong);
}
.participants-chevron {
  display: inline-grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--accent-dim);
  color: var(--accent-strong);
  font-size: 18px;
  line-height: 1;
  transition: transform 0.18s ease, background 0.15s ease;
}
.participants-toggle:hover .participants-chevron { background: var(--accent); color: #fff; }
.participants-panel.collapsed .participants-toggle { margin-bottom: 0; }
.participants-panel.collapsed .participants-chevron { transform: rotate(-90deg); }
.participants-panel.collapsed .participants-list { display: none; }
.participants-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.participant-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-alt); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px;
}
.participant-row-clickable { cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.participant-row-clickable:hover { border-color: var(--accent); background: var(--panel-hover); }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #10120f;
  flex-shrink: 0;
}
.participant-row .p-name { flex: 1; font-size: 13.5px; font-weight: 500; }
.p-remove { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 4px; }
.p-remove:hover { color: var(--red); }

/* ---------- bracket ---------- */
.bracket-wrap {
  overflow-x: auto;
  padding-bottom: 20px;
  cursor: grab;
  scrollbar-width: none;      /* Firefox */
  -ms-overflow-style: none;   /* old Edge/IE */
}
.bracket-wrap::-webkit-scrollbar { display: none; } /* Chrome/Safari */
.bracket-wrap.dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.bracket { position: relative; display: inline-flex; gap: 64px; padding: 56px 10px 30px; }

.bracket-round { position: relative; width: 250px; flex-shrink: 0; }
.round-label {
  text-align: center;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--accent-strong);
  background: linear-gradient(160deg, rgba(229,35,58,0.16), rgba(201,41,106,0.08));
  border: 1px solid rgba(229,35,58,0.3);
  border-radius: 999px;
  padding: 6px 14px;
  display: inline-block;
  position: absolute;
  top: -42px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}

.bracket-lines { position: absolute; top: 0; left: 100%; pointer-events: none; overflow: visible; }

.match-card {
  position: absolute;
  left: 0;
  width: 100%;
  height: 80px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.match-card:hover { border-color: var(--secondary-strong); box-shadow: 0 0 0 1px rgba(229,35,58,0.18); }
.match-card.is-final { border-color: rgba(229,35,58,0.45); }
.match-card.is-locked { cursor: default; }
.match-card.is-locked:hover { border-color: var(--border); box-shadow: none; }
.match-row {
  display: flex; align-items: center; gap: 9px;
  height: 40px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
}
.match-row:last-child { border-bottom: none; }
.match-row.winner { background: var(--green-dim); }
.match-row.winner .m-name { color: var(--green); font-weight: 700; }
.match-row.tbd { opacity: 0.45; }
.match-row.swappable { cursor: pointer; }
.match-row.swappable:hover { background: var(--panel-hover); }
.match-row.selected-swap { background: var(--accent-dim); outline: 1.5px solid var(--accent); outline-offset: -1.5px; }
.match-row.selected-swap .m-name { color: var(--accent-strong); font-weight: 700; }
.btn-active { background: var(--accent); border-color: var(--accent); color: #ffffff; }
.key-input-row { display: flex; gap: 8px; }
.key-input-row .input { flex: 1; }

.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-tabs .auth-tab { flex: 1; }
.m-name { flex: 1; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-score {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  min-width: 22px;
  text-align: center;
  color: var(--text-muted);
  background: var(--panel-alt);
  border-radius: 5px;
  padding: 2px 6px;
}
.match-row.winner .m-score { color: var(--green); background: rgba(111,207,115,0.12); }

/* ---------- layout: sidebar + main column ---------- */
.layout { display: flex; align-items: flex-start; gap: 20px; }
.sidebar {
  width: 268px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 20px;
}
.main-col { flex: 1; min-width: 0; }

/* ---------- sidebar cards (shared) ---------- */
.side-card {
  position: relative;
  background: linear-gradient(160deg, var(--panel-alt), var(--panel) 70%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 20px 22px;
  box-shadow: 0 10px 30px -18px rgba(0,0,0,0.6);
}
.side-card-icon {
  display: inline-grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--accent-dim);
  font-size: 15px;
  margin-right: 8px;
  vertical-align: middle;
}
.side-card-label {
  display: flex;
  align-items: center;
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-strong);
  margin-bottom: 14px;
}

/* ---------- tournament card ---------- */
.side-tournament-name {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 800;
  line-height: 1.25;
  margin: 0 0 6px;
}
.side-tournament-tagline {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 18px;
  line-height: 1.4;
}
.side-countdown {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 11px;
  margin-bottom: 18px;
  background: linear-gradient(160deg, rgba(229,35,58,0.16), rgba(201,41,106,0.08));
  border: 1px solid rgba(229,35,58,0.3);
}
.side-countdown-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
}
.side-countdown-value {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-strong);
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.side-countdown.is-live .side-countdown-value { color: var(--gold-strong); }
.side-countdown.is-over {
  background: linear-gradient(160deg, rgba(148,163,184,0.12), rgba(148,163,184,0.05));
  border-color: var(--border);
}
.side-countdown.is-over .side-countdown-value { color: var(--text-muted); }

.side-info-rows { display: flex; flex-direction: column; gap: 14px; }
.side-info-row { display: flex; align-items: flex-start; gap: 10px; }
.side-info-row .side-info-icon {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 7px;
  background: var(--panel-hover);
  font-size: 12.5px;
  flex-shrink: 0;
  margin-top: 1px;
}
.side-info-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.side-info-value { font-size: 14px; font-weight: 600; color: var(--text); }

/* ---------- champion / final card ---------- */
.champion-card {
  text-align: center;
  padding: 26px 18px 24px;
  border-color: rgba(229,35,58,0.3);
  background: linear-gradient(160deg, rgba(229,35,58,0.16), rgba(201,41,106,0.10) 55%, var(--panel) 85%);
}
.champion-card .side-card-icon.champion-trophy {
  width: 44px; height: 44px;
  font-size: 22px;
  background: var(--accent-dim);
  margin: 0 auto 10px;
  display: grid;
}
.champion-card-label {
  justify-content: center;
  margin-bottom: 10px;
}
.side-champion-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1.3;
  margin-bottom: 6px;
  transition: color .2s ease, font-size .2s ease;
}
.side-champion-sub { font-size: 12px; color: var(--text-dim); margin: 0; }

/* winner determined: bigger, bolder, стоит выделяться */
.side-champion-name.has-winner {
  font-size: 27px;
  font-weight: 800;
  color: var(--gold-strong);
  text-shadow: 0 0 22px rgba(250, 204, 21, 0.35);
}
.champion-card.has-winner {
  border-color: rgba(250, 204, 21, 0.45);
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.14), var(--panel) 75%);
}
.champion-card.has-winner .side-card-icon.champion-trophy { background: var(--gold-dim); }
.champion-card.has-winner .champion-card-label { color: var(--gold-strong); }

@media (max-width: 900px) {
  .layout { flex-direction: column; align-items: stretch; }
  .sidebar { width: 100%; flex-direction: row; position: static; }
  .sidebar .side-card { flex: 1; }
}
@media (max-width: 560px) {
  .sidebar { flex-direction: column; }
}

/* ---------- modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(6,7,9,0.7); backdrop-filter: blur(2px); }
.modal {
  position: relative; z-index: 2;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 24px; width: 380px; max-width: calc(100vw - 40px);
}
.modal h3 { margin: 0 0 16px; font-family: var(--font-display); font-size: 17px; }
.modal label { display: block; font-size: 12.5px; color: var(--text-muted); margin: 12px 0 6px; }
.modal .input { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal-actions.modal-actions-split { justify-content: space-between; align-items: center; }
.modal-actions-right { display: flex; gap: 8px; }
.link-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--accent); font-size: 12.5px; text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--accent-strong); }
.score-inputs { display: flex; align-items: center; gap: 14px; }
.score-side { flex: 1; text-align: center; }
.score-side .p-name-lg { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.score-side input { width: 100%; text-align: center; font-family: var(--font-mono); font-size: 20px; font-weight: 700; }
.score-vs { color: var(--text-dim); font-size: 13px; padding-top: 20px; }
.modal-hint { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin-top: 2px; }

/* ---------- account modal: profile, avatar picker, password change ---------- */
.account-header { display: flex; align-items: center; gap: 14px; }
.avatar-circle {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: 50%;
}
.avatar-circle.avatar-lg { width: 56px; height: 56px; font-size: 28px; }
.account-id { min-width: 0; }
.account-login { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.account-email { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; word-break: break-all; }
.account-details {
  margin-top: 16px; padding: 12px 14px; background: var(--panel-alt);
  border: 1px solid var(--border); border-radius: 10px;
}
.account-detail-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; padding: 4px 0; }
.account-detail-row span { color: var(--text-muted); }
.account-detail-row strong { font-weight: 600; }
.account-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.account-actions .btn { flex: 1; }
.avatar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 4px; }
.avatar-option {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1; font-size: 24px; border-radius: 12px;
  background: var(--panel-alt); border: 1px solid var(--border); cursor: pointer;
}
.avatar-option:hover { background: var(--panel-hover); }
.avatar-option-active { border-color: var(--accent); background: var(--accent-dim); }
.avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar-option .avatar-img { border-radius: 8px; }
.account-btn-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; overflow: hidden; border-radius: 50%; vertical-align: -3px;
}
.avatar-upload-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.modal pre {
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; font-size: 11.5px; overflow-x: auto; color: #c9cdd4; font-family: var(--font-mono);
}
.modal.modal-lg {
  width: 720px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
}
.modal.modal-lg .rules-text { max-height: 52vh; flex: 1; }
.rules-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.rules-tab {
  flex: 1;
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.rules-tab:hover { background: var(--panel-hover); }
.rules-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.rules-text {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-muted);
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}
.rules-empty { color: var(--text-dim); font-style: italic; }

/* ---------- team roster modal ---------- */
.roster-list {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 14px; max-height: 360px; overflow-y: auto;
}
.roster-member {
  background: var(--panel-alt); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.roster-member-main { display: flex; align-items: center; gap: 8px; }
.roster-member-name { font-size: 14px; font-weight: 600; color: var(--text); }
.roster-role-badge {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
  padding: 2px 8px; border-radius: 999px;
  background: var(--panel-hover); color: var(--text-muted); border: 1px solid var(--border);
  white-space: nowrap;
}
.roster-role-badge.captain { background: var(--accent-dim); color: var(--accent-strong); border-color: var(--accent); }
.roster-member-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 12.5px; color: var(--text-muted);
}
.roster-steamid code {
  background: var(--panel-hover); border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 6px; font-family: var(--font-mono); font-size: 12px; color: #e3a8ff;
}
.roster-steam-link { color: var(--accent-strong); text-decoration: none; font-weight: 600; white-space: nowrap; }
.roster-steam-link:hover { text-decoration: underline; }
.roster-steam-link.disabled { color: var(--text-dim); font-weight: 500; }

/* rendered markdown elements inside .rules-text */
.rules-text strong { color: var(--text); font-weight: 700; }
.rules-text em { font-style: italic; }
.rules-text u { text-decoration: underline; }
.rules-text s { text-decoration: line-through; opacity: 0.75; }
.rules-text code {
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 5px; font-family: var(--font-mono); font-size: 12.5px; color: #e3a8ff;
}
.rules-text pre {
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin: 6px 0; overflow-x: auto;
}
.rules-text pre code { background: none; border: none; padding: 0; color: #c9cdd4; }
.rules-text .rules-h { font-family: var(--font-display); color: var(--text); margin: 10px 0 4px; line-height: 1.3; }
.rules-text h4.rules-h { font-size: 16px; }
.rules-text h5.rules-h { font-size: 14.5px; }
.rules-text h6.rules-h { font-size: 13.5px; text-transform: uppercase; letter-spacing: 0.4px; }
.rules-text .rules-quote {
  margin: 4px 0; padding: 2px 0 2px 10px; border-left: 3px solid var(--accent);
  color: var(--text-muted);
}
.rules-text .rules-bullet { color: var(--accent); font-weight: 700; }
.rules-text .rules-spoiler {
  background: #202225; color: transparent; border-radius: 3px; cursor: pointer;
  padding: 0 2px; transition: color .1s ease;
}
.rules-text .rules-spoiler.revealed { color: inherit; background: var(--panel-alt); }

.rules-editwrap { position: relative; margin-top: 0; }
.rules-textarea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.5;
  margin-top: 4px;
}
.modal.modal-lg .rules-textarea { min-height: 320px; }

/* Discord-style floating format toolbar shown on text selection */
.format-toolbar {
  position: absolute;
  display: flex;
  gap: 2px;
  background: #18191c;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.45);
  transform: translateY(-100%);
  z-index: 5;
}
.format-btn {
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: #dcddde;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-body);
}
.format-btn:hover { background: var(--panel-hover); color: #fff; }
.format-btn[data-key="italic"] { font-style: italic; }
.format-btn[data-key="underline"] { text-decoration: underline; }
.format-btn[data-key="strike"] { text-decoration: line-through; }

/* ---------- toast ---------- */
.toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel-alt); border: 1px solid var(--border); color: var(--text);
  padding: 10px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 4px 18px rgba(0,0,0,0.4);
  animation: toast-in .2s ease;
}
.toast.error { border-color: rgba(255,77,94,0.5); color: #ffb3b3; }
.toast.success { border-color: rgba(111,207,115,0.4); color: var(--green); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 720px) {
  .app { padding: 14px 12px 60px; }
  .th-title { font-size: 22px; }
  .topbar-mid { width: 100%; order: 3; }
}
