:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-soft: #eef1ee;
  --text: #14181a;
  --muted: #666f6c;
  --line: #dfe3df;
  --accent: #ea580c;
  --accent-strong: #c2410c;
  --accent-soft: #ffe8d5;
  --accent-rgb: 234, 88, 12;
  --danger: #b3402f;
  --shadow: 0 18px 48px rgba(20, 30, 28, 0.08);
  --shadow-lift: 0 26px 64px rgba(20, 30, 28, 0.14);
  --radius: 20px;
  --radius-sm: 12px;
  --speed: 220ms;
  --font-display: "Space Grotesk", ui-sans-serif, sans-serif;
  --font-body: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0f0e;
  --surface: #161917;
  --surface-soft: #1e211f;
  --text: #f2f4f1;
  --muted: #9aa39d;
  --line: #2a2e2b;
  --accent: #ff8a3d;
  --accent-strong: #ffb877;
  --accent-soft: rgba(255, 138, 61, 0.14);
  --accent-rgb: 255, 138, 61;
  --danger: #f0968a;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.36);
  --shadow-lift: 0 30px 80px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  margin: 0;
  font-family: var(--font-body);
  background:
    radial-gradient(680px 360px at 12% -10%, rgba(var(--accent-rgb), 0.1), transparent 60%),
    var(--bg);
  color: var(--text);
  transition: background-color var(--speed) ease, color var(--speed) ease;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  margin: 0;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(20px);
}

.header-inner,
.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.header-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  min-height: 76px;
  align-items: center;
  gap: 18px;
  padding: 10px 0;
}

.header-inner .brand {
  justify-self: start;
}

.header-inner .tabs {
  justify-self: center;
}

.header-inner .header-actions {
  justify-self: end;
  flex-wrap: nowrap;
}

@media (max-width: 860px) {
  .header-inner {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .header-inner .brand,
  .header-inner .tabs,
  .header-inner .header-actions {
    justify-self: center;
  }
}

@media (max-width: 480px) {
  .header-inner .header-actions {
    flex-wrap: wrap;
    justify-content: center;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  color: #2a1200;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  flex: none;
  overflow: hidden;
  padding: 5px;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.brand strong {
  display: block;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.tab-button {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13.5px;
  transition: background var(--speed) ease, color var(--speed) ease;
}

.tab-button svg {
  width: 16px;
  height: 16px;
}

.tab-button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  transition: opacity var(--speed) ease;
}

.search.is-inactive {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.search svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.search input {
  border: none;
  outline: none;
  background: transparent;
  width: 160px;
  color: var(--text);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: transform var(--speed) ease, background var(--speed) ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  background: var(--surface-soft);
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.icon-button.quiet {
  border-color: transparent;
  background: transparent;
}

.primary-button[hidden],
.secondary-button[hidden],
.icon-button[hidden] {
  display: none !important;
}

.icon-button,
.pass-button {
  text-decoration: none;
}

.pass-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  border: 1px solid transparent;
  box-shadow: 0 12px 26px rgba(var(--accent-rgb), 0.32);
  transition: transform var(--speed) ease;
  will-change: transform;
}

.pass-button:hover {
  transform: translateY(-1px);
}

.pass-button img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: contain;
  flex: none;
}

/* Текст остаётся только для скринридеров и как title-тултип на наведении — сама кнопка не растягивается */
.pass-button span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 13.5px;
  border: 1px solid transparent;
  transition: transform var(--speed) ease, background var(--speed) ease;
  white-space: nowrap;
}

.primary-button svg,
.secondary-button svg {
  width: 16px;
  height: 16px;
}

.primary-button {
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  color: #2a1200;
  box-shadow: 0 12px 26px rgba(var(--accent-rgb), 0.32);
  will-change: transform;
}

.primary-button:hover {
  transform: translateY(-1px);
}

.secondary-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.secondary-button:hover {
  transform: translateY(-1px);
  background: var(--surface-soft);
}

.danger-button {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.full-width {
  width: 100%;
  justify-content: center;
}

/* ---------- layout ---------- */

.shell {
  padding: 40px 0 90px;
}

.view[hidden] {
  display: none !important;
}

.intro {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 40px;
  padding: 20px 0 34px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 34px;
  flex-wrap: wrap;
}

.kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.intro h1 {
  font-size: clamp(26px, 3.4vw, 38px);
  max-width: 640px;
  line-height: 1.15;
}

.intro > p {
  max-width: 320px;
  color: var(--muted);
  margin: 0;
  font-size: 14.5px;
  line-height: 1.6;
}

/* ---------- form panel ---------- */

.form-panel {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(-8px);
  transition: max-height 320ms ease, opacity 220ms ease, transform 220ms ease, margin 320ms ease;
  margin-bottom: 0;
}

.form-panel.is-open {
  max-height: 720px;
  opacity: 1;
  transform: translateY(0);
  margin-bottom: 30px;
}

.player-form {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 26px;
  box-shadow: var(--shadow);
}

.form-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.form-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.field-grid select {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 500;
  outline: none;
  transition: border-color var(--speed) ease, box-shadow var(--speed) ease;
}

.field-grid select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18);
}

.field-grid label,
.modal-form label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.field-grid input,
.modal-form input {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 500;
  outline: none;
  transition: border-color var(--speed) ease, box-shadow var(--speed) ease;
}

.field-grid input:focus,
.modal-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18);
}

.skin-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 13px;
}

.skin-preview img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  image-rendering: pixelated;
  background: var(--surface-soft);
  border-radius: 10px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

/* ---------- toolbar ---------- */

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.toolbar h2 {
  font-size: 21px;
}

.toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

.sort-select {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.sort-select select {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: var(--surface);
  color: var(--text);
}

/* ---------- player grid ---------- */

.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
}

.player-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px);
  transition: transform var(--speed) ease, box-shadow var(--speed) ease, opacity 480ms ease, translate 480ms ease;
}

.player-card.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.player-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lift);
}

.skin-wrap {
  position: relative;
  height: 210px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(140px 140px at 50% 22%, rgba(var(--accent-rgb), 0.16), transparent 70%),
    var(--surface-soft);
}

.skin-wrap img {
  height: auto;
  width: auto;
  max-height: 88%;
  max-width: 46%;
  object-fit: contain;
  image-rendering: pixelated;
  transition: transform 320ms ease;
}

.player-card:hover .skin-wrap img {
  transform: translateY(-4px) scale(1.03);
}

.skin-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.skin-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(6px);
  color: var(--muted);
}

.skin-toggle svg {
  width: 15px;
  height: 15px;
}

.skin-toggle.is-active {
  background: var(--accent);
  color: #2a1200;
  border-color: transparent;
}

.card-body {
  padding: 16px 18px 18px;
}

.card-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.player-name {
  font-size: 16.5px;
  font-family: var(--font-display);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.social-links {
  display: flex;
  gap: 8px;
  flex: none;
}

.social-link {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  transition: transform var(--speed) ease;
}

.social-link:hover {
  transform: translateY(-2px) scale(1.05);
}

.social-link svg {
  width: 15px;
  height: 15px;
}

.social-link.is-twitch {
  background: rgba(145, 71, 255, 0.14);
  color: #9147ff;
  position: relative;
}

.social-link.is-twitch.is-live {
  outline: 2px solid #ff3b3b;
  outline-offset: 1px;
  box-shadow: 0 0 8px 2px rgba(255, 59, 59, 0.65);
  animation: twitch-live-glow 1.8s ease-in-out infinite;
}

@keyframes twitch-live-glow {
  0%,
  100% {
    box-shadow: 0 0 6px 1px rgba(255, 59, 59, 0.55);
  }
  50% {
    box-shadow: 0 0 11px 3px rgba(255, 59, 59, 0.85);
  }
}

/* Role badge, top-left corner of the card avatar */
.role-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  max-width: 118px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-badge.is-editable {
  cursor: pointer;
  transition: transform var(--speed) ease, background var(--speed) ease;
}

.role-badge.is-editable:hover {
  transform: translateY(-1px);
  background: var(--accent-soft);
}

.role-badge.is-empty {
  border-style: dashed;
  opacity: 0.55;
  color: var(--muted);
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.card-actions .secondary-button {
  flex: 1;
  justify-content: center;
  padding: 9px 10px;
  font-size: 12.5px;
}

/* ---------- empty state ---------- */

.empty-state {
  display: grid;
  min-height: 290px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 36px 18px;
  text-align: center;
}

.empty-state[hidden] {
  display: none !important;
}

.empty-state svg {
  width: 34px;
  height: 34px;
  color: var(--accent-strong);
}

.empty-state h2 {
  font-size: 18px;
  margin-top: 12px;
}

.empty-state p {
  color: var(--muted);
  margin: 8px 0 0;
  max-width: 320px;
}

.empty-state .primary-button {
  margin-top: 18px;
}

/* ---------- modals ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(6, 10, 9, 0.5);
  backdrop-filter: blur(4px);
  padding: 20px;
  animation: fadeIn 180ms ease;
}

.modal-backdrop[hidden] {
  display: none !important;
}

/* Модалка "как работает голосование" открывается поверх самой панели голосования (z-index: 300) */
#votingInfoModalBackdrop {
  z-index: 310;
}

.modal {
  width: min(420px, 100%);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lift);
  padding: 24px;
  animation: modalIn 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.modal-head h2 {
  font-size: 18px;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

.link-button {
  border: none;
  background: transparent;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 2px 0;
  align-self: center;
}

.link-button:hover {
  color: var(--accent);
}

.admins-list {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.admin-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  font-size: 13.5px;
  font-weight: 600;
}

.admin-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-row .badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 999px;
  margin-left: 6px;
}

.admin-row button {
  border: none;
  background: transparent;
  color: var(--danger);
  display: grid;
  place-items: center;
}

.admin-row button svg {
  width: 15px;
  height: 15px;
}

.admin-row-perms {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.admin-row-perms label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}

.admin-row-perms input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

/* ---------- admin add tabs (существующий / новый) ---------- */
.admin-add-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  margin-bottom: 14px;
}

.admin-add-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12.5px;
  transition: background var(--speed) ease, color var(--speed) ease;
}

.admin-add-tab.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.admin-permissions-field {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px 12px;
  margin: 4px 0 4px;
}

.admin-permissions-field legend {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 0 4px;
}

.permission-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 0;
  cursor: pointer;
}

.permission-check input[type="checkbox"] {
  margin-top: 2px;
  width: 15px;
  height: 15px;
  flex: none;
  accent-color: var(--accent);
}

/* ---------- voting info button + modal ---------- */
.voting-info-button {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: color var(--speed) ease, border-color var(--speed) ease;
}

.voting-info-button:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.voting-info-button svg {
  width: 14px;
  height: 14px;
}

.voting-info-text p {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
  margin: 0 0 12px;
}

.voting-info-text p:last-child {
  margin-bottom: 0;
}

/* ---------- tierlist ---------- */

.tierlist-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.tierlist-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tier-export-area {
  background: var(--bg);
  padding: 2px;
}

.tier-export-title {
  display: none;
  font-family: var(--font-display);
  font-size: 20px;
  margin: 0 0 14px;
  color: var(--text);
}

.tier-export-area.is-exporting {
  padding: 20px;
  border-radius: var(--radius);
}

.tier-export-area.is-exporting .tier-export-title {
  display: block;
}

.tier-export-area.is-exporting .tier-name {
  cursor: default;
}

.tier-export-area.is-exporting input[type="color"] {
  display: none !important;
}

.tier-export-area.is-exporting .tier-remove {
  display: none !important;
}

.tier-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 34px;
}

.log-list {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
}

.log-row {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  font-size: 13px;
}

.log-row .log-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.log-empty {
  color: var(--muted);
  font-size: 13.5px;
  text-align: center;
  padding: 18px 0;
}

.modal-actions {
  margin-top: 6px;
}

.tier-row {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  min-height: 108px;
}

.tier-label {
  flex: none;
  width: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  color: #05130f;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  position: relative;
}

.tier-label .tier-name {
  width: 100%;
  max-height: 3.2em;
  overflow: hidden;
  border: none;
  background: transparent;
  outline: none;
  text-align: center;
  font: inherit;
  color: inherit;
  font-size: 14px;
  line-height: 1.15;
  word-break: break-word;
  white-space: normal;
  cursor: text;
}

.tier-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 999px;
  background: rgba(5, 19, 15, 0.28);
  color: #fff;
  opacity: 0;
  transition: opacity var(--speed) ease, background var(--speed) ease;
}

.tier-remove svg {
  width: 11px;
  height: 11px;
}

.tier-label:hover .tier-remove {
  opacity: 1;
}

.tier-remove:hover {
  background: var(--danger);
}

.tier-label input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(5, 19, 15, 0.35);
  background: transparent;
  padding: 0;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
}

.tier-label input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 999px;
}

.tier-label input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 999px;
}

.tier-label input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 999px;
}

.tier-drop {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 10px;
  padding: 12px;
  transition: background var(--speed) ease;
}

.tier-drop.is-dragover {
  background: var(--accent-soft);
}

.tier-pool-wrap h3 {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tier-pool-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  opacity: 0.75;
}

.tier-pool-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
}

.tier-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 90px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  transition: background var(--speed) ease;
}

.tier-pool.is-dragover {
  background: var(--accent-soft);
}

.tier-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: grab;
  font-size: 13px;
  font-weight: 600;
  transition: transform var(--speed) ease, box-shadow var(--speed) ease, rotate var(--speed) ease;
  user-select: none;
}

.tier-chip > img {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  object-fit: cover;
  image-rendering: pixelated;
  background: var(--surface-soft);
}

.tier-chip:hover {
  box-shadow: var(--shadow);
}

.tier-chip.is-dragging {
  opacity: 0.4;
  rotate: -3deg;
  transform: scale(1.05);
}

/* Превью фото игрока — чистый CSS :hover, без единой строчки JS для
   показа/скрытия. Появляется/пропадает средствами самого браузера, поэтому
   не может "зависнуть" в открытом состоянии ни при каких условиях. JS только
   один раз подставляет src и добавляет класс has-photo, если файл нашёлся. */
.tier-chip-photo {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  pointer-events: none;
  align-items: center;
  justify-content: center;
  width: max-content;
  max-width: 170px;
  max-height: 170px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.tier-chip:hover > .tier-chip-photo.has-photo {
  display: flex;
}

body.tier-photos-off .tier-chip-photo {
  display: none !important;
}

.tier-chip.is-dragging .tier-chip-photo {
  display: none !important;
}

.tier-chip-photo img {
  display: block;
  max-width: 154px;
  max-height: 154px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  background: var(--surface-soft);
}

.tier-remove-hint {
  color: var(--muted);
  font-size: 12px;
  margin: 10px 2px 0;
}

/* ---------- misc / a11y ---------- */

.admin-only[hidden] {
  display: none !important;
}

.player-card.is-highlighted {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.28), var(--shadow-lift);
  animation: cardPulse 1.2s ease-in-out 2;
}

@keyframes cardPulse {
  0%,
  100% {
    transform: translateY(-4px);
  }
  50% {
    transform: translateY(-4px) scale(1.01);
  }
}

.city-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(6px);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  max-width: 130px;
  transition: transform var(--speed) ease, background var(--speed) ease, border-color var(--speed) ease;
}

.city-badge svg {
  width: 13px;
  height: 13px;
  color: var(--accent-strong);
  flex: none;
}

.city-badge span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.city-badge:hover {
  transform: translateY(-2px);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

/* ---------- political map ---------- */

body.is-polmap-view .shell {
  width: 100%;
  max-width: none;
  padding: 0;
}

.view-polmap {
  min-height: calc(100dvh - 76px);
}

.polmap-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100dvh - 76px);
  background: var(--bg);
}

.polmap-toolbar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px);
  z-index: 4;
}

.polmap-toolbar-head .kicker {
  margin-bottom: 10px;
}

.polmap-draw-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 700;
  font-size: 13px;
  transition: transform var(--speed) ease, background var(--speed) ease, box-shadow var(--speed) ease;
}

.polmap-draw-toggle svg {
  width: 16px;
  height: 16px;
}

.polmap-draw-toggle.is-active {
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  color: #2a1200;
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(var(--accent-rgb), 0.34);
}

.polmap-draw-toggle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.polmap-tool-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.polmap-tool {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  transition: transform 160ms ease, background var(--speed) ease, color var(--speed) ease, box-shadow var(--speed) ease;
}

.polmap-tool svg {
  width: 18px;
  height: 18px;
}

.polmap-tool:hover:not(:disabled) {
  transform: translateY(-2px);
  color: var(--text);
  background: var(--surface-soft);
}

.polmap-tool.is-active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.18);
}

.polmap-tool:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.polmap-tool-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.polmap-color-field,
.polmap-stroke-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.polmap-color-field input[type="color"] {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  padding: 4px;
  cursor: pointer;
}

.polmap-stroke-field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.polmap-tool-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.polmap-tool-actions .secondary-button {
  justify-content: center;
}

.polmap-hotkeys {
  margin: auto 0 0;
  font-size: 11px;
  line-height: 1.55;
  color: var(--muted);
}

.polmap-hotkeys span {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  font-weight: 700;
  color: var(--text);
}

.polmap-toolbar .is-hidden {
  display: none !important;
}

/* ---- board selector ---- */

.polmap-board-field {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.polmap-board-select-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.polmap-board-select-wrap select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
}

.polmap-board-btn {
  flex: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  width: 36px;
  height: 36px;
}

/* ---- admin city editor toggle ---- */

.polmap-edit-cities-toggle {
  justify-content: center;
}

.polmap-edit-cities-toggle.is-active {
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  color: #2a1200;
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(var(--accent-rgb), 0.34);
}

.polmap-viewport.is-edit-cities-mode .polmap-city-hit {
  cursor: crosshair;
}

/* ---- vertex handles (city outline editing) ---- */

.polmap-vertex-handle {
  fill: #fff;
  stroke: var(--city-color, var(--accent));
  stroke-width: 0.45;
  vector-effect: non-scaling-stroke;
  cursor: grab;
  pointer-events: all;
  transition: r 140ms ease, fill 140ms ease;
}

.polmap-vertex-handle:hover {
  r: 1.5;
  fill: var(--city-color, var(--accent));
}

.polmap-vertex-handle:active {
  cursor: grabbing;
}

/* ---- floating city edit panel ---- */

.polmap-city-edit-panel {
  position: absolute;
  z-index: 9;
  width: min(260px, calc(100% - 24px));
  border-radius: 16px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-lift);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  transition: opacity 180ms ease, transform 260ms cubic-bezier(0.24, 1.1, 0.32, 1);
}

.polmap-city-edit-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.polmap-edit-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.polmap-edit-field input[type="text"] {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.polmap-edit-field input[type="color"] {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  padding: 4px;
  cursor: pointer;
}

.polmap-edit-hint {
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

.polmap-city-edit-panel .polmap-tool-actions {
  flex-direction: row;
}

.polmap-city-edit-panel .primary-button,
.polmap-city-edit-panel .secondary-button {
  flex: 1;
  justify-content: center;
}

/* ---- markers (admin pins) ---- */

.polmap-markers-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.polmap-marker {
  --marker-color: #e8590c;
  cursor: pointer;
}

.polmap-marker-halo {
  fill: color-mix(in srgb, var(--marker-color) 25%, transparent);
  pointer-events: all;
  transition: r 200ms ease, opacity 200ms ease;
}

.polmap-marker-dot {
  fill: var(--marker-color);
  stroke: #fff;
  stroke-width: 3;
  pointer-events: all;
  transition: transform 200ms cubic-bezier(0.24, 1.4, 0.4, 1);
  transform-box: fill-box;
  transform-origin: center;
}

.polmap-marker-label {
  fill: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 5;
  opacity: 0;
  transition: opacity 160ms ease;
  pointer-events: none;
}

.polmap-marker:hover .polmap-marker-dot {
  transform: scale(1.35);
}

.polmap-marker:hover .polmap-marker-label {
  opacity: 1;
}

.polmap-marker:hover .polmap-marker-halo {
  r: 22;
}

/* ---- marker popup ---- */

.polmap-marker-popup {
  position: absolute;
  z-index: 8;
  width: min(240px, calc(100% - 24px));
  border-radius: 16px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-lift);
  padding: 12px;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  transition: opacity 180ms ease, transform 260ms cubic-bezier(0.24, 1.1, 0.32, 1);
}

.polmap-marker-popup.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.polmap-marker-popup-title {
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.polmap-marker-popup-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.polmap-marker-popup-actions .secondary-button {
  justify-content: center;
}

.polmap-viewport {
  position: relative;
  overflow: hidden;
  cursor: grab;
  background:
    radial-gradient(circle at 20% 20%, rgba(var(--accent-rgb), 0.06), transparent 40%),
    repeating-linear-gradient(0deg, transparent, transparent 23px, color-mix(in srgb, var(--line) 35%, transparent) 24px),
    repeating-linear-gradient(90deg, transparent, transparent 23px, color-mix(in srgb, var(--line) 35%, transparent) 24px),
    var(--surface-soft);
  box-shadow: inset 0 0 90px color-mix(in srgb, var(--bg) 55%, transparent);
}

.polmap-viewport.is-draw-mode {
  cursor: crosshair;
}

.polmap-viewport:active {
  cursor: grabbing;
}

.polmap-stage {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.polmap-stage.is-flying {
  transition: transform 650ms cubic-bezier(0.22, 0.9, 0.15, 1);
}

.polmap-stage.is-entering {
  animation: polmapStageIn 700ms cubic-bezier(0.16, 0.9, 0.22, 1);
}

@keyframes polmapStageIn {
  0% {
    opacity: 0;
    filter: saturate(0.6) brightness(1.15);
  }
  100% {
    opacity: 1;
    filter: saturate(1) brightness(1);
  }
}

.polmap-image {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  pointer-events: none;
}

.polmap-cities-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.polmap-cities-layer.is-hidden {
  display: none;
}

.polmap-city-group {
  --city-color: var(--accent);
}

.polmap-city-hit {
  fill: rgba(var(--accent-rgb), 0);
  stroke: transparent;
  stroke-width: 0.35;
  stroke-linejoin: round;
  pointer-events: all;
  cursor: pointer;
  transition: fill 260ms ease, stroke 260ms ease, stroke-width 260ms ease, filter 260ms ease;
}

.polmap-city-hit.is-debug {
  fill: rgba(var(--accent-rgb), 0.12);
  stroke: rgba(var(--accent-rgb), 0.55);
}

.polmap-viewport:not(.is-draw-mode) .polmap-city-group:hover .polmap-city-hit,
.polmap-city-hit.is-focused {
  fill: color-mix(in srgb, var(--city-color) 22%, transparent);
  stroke: var(--city-color);
  stroke-width: 0.55;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--city-color) 65%, transparent));
}

.polmap-city-hit.is-focused {
  animation: polmapFocusPulse 1.2s ease-out 2;
}

@keyframes polmapFocusPulse {
  0% {
    stroke-width: 0.35;
    filter: drop-shadow(0 0 0 color-mix(in srgb, var(--city-color) 0%, transparent));
  }
  40% {
    stroke-width: 0.9;
    filter: drop-shadow(0 0 10px color-mix(in srgb, var(--city-color) 85%, transparent));
  }
  100% {
    stroke-width: 0.55;
    filter: drop-shadow(0 0 6px color-mix(in srgb, var(--city-color) 60%, transparent));
  }
}

.polmap-city-pulse {
  fill: var(--city-color);
  opacity: 0;
  pointer-events: none;
  transform-origin: center;
  transform-box: fill-box;
}

.polmap-city-group.has-players .polmap-city-pulse {
  opacity: 0.9;
  animation: polmapPulse 2.2s ease-out infinite;
}

@keyframes polmapPulse {
  0% {
    transform: scale(0.4);
    opacity: 0.9;
  }
  70% {
    transform: scale(2.6);
    opacity: 0;
  }
  100% {
    transform: scale(2.6);
    opacity: 0;
  }
}

.polmap-draw-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.polmap-city-popup {
  position: absolute;
  z-index: 8;
  width: min(280px, calc(100% - 24px));
  border-radius: 16px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-lift);
  padding: 12px;
  opacity: 0;
  overflow: hidden;
  transform: translateY(8px) scale(0.96);
  transition: opacity 180ms ease, transform 260ms cubic-bezier(0.24, 1.1, 0.32, 1);
}

.polmap-city-popup.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.polmap-city-popup::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, color-mix(in srgb, var(--accent) 30%, transparent) 48%, transparent 66%);
  transform: translateX(-120%);
  pointer-events: none;
}

.polmap-city-popup.is-open::before {
  animation: polmapShimmer 900ms ease 60ms 1;
}

@keyframes polmapShimmer {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(120%);
  }
}

.polmap-city-popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.polmap-city-popup-head.is-draggable {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.polmap-city-popup-head.is-draggable.is-dragging {
  cursor: grabbing;
}

.polmap-city-popup-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.polmap-city-popup-title {
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.polmap-city-popup-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--city-color, var(--accent));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--city-color, var(--accent)) 25%, transparent);
  flex: none;
}

.polmap-city-popup-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
}

.polmap-city-player {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  transition: background var(--speed) ease, transform var(--speed) ease;
  opacity: 0;
  animation: polmapRowIn 320ms ease forwards;
}

.polmap-city-popup-list li:nth-child(1) .polmap-city-player { animation-delay: 40ms; }
.polmap-city-popup-list li:nth-child(2) .polmap-city-player { animation-delay: 80ms; }
.polmap-city-popup-list li:nth-child(3) .polmap-city-player { animation-delay: 120ms; }
.polmap-city-popup-list li:nth-child(4) .polmap-city-player { animation-delay: 160ms; }
.polmap-city-popup-list li:nth-child(n+5) .polmap-city-player { animation-delay: 190ms; }

@keyframes polmapRowIn {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.polmap-city-player img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  image-rendering: pixelated;
  background: var(--surface-soft);
}

.polmap-city-player:hover {
  background: var(--accent-soft);
  transform: translateX(3px);
}

.polmap-city-popup-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 4px;
}

.polmap-zoom-hint {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(10px);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
  animation: hintFade 4s ease 1s forwards;
}

.polmap-zoom-hint svg {
  width: 14px;
  height: 14px;
}

@keyframes hintFade {
  0%,
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@media (max-width: 900px) {
  .polmap-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .polmap-toolbar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .polmap-tool-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .polmap-hotkeys {
    display: none;
  }
}

@media (max-width: 860px) {
  .field-grid {
    grid-template-columns: 1fr;
  }

  .search input {
    width: 110px;
  }

  .intro {
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .tier-row {
    flex-direction: column;
  }

  .tier-label {
    width: 100%;
    flex-direction: row;
    min-height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
.toolbar-actions{display:flex;align-items:end;gap:16px}.brand-mark{display:flex;align-items:center;justify-content:center}.secondary-button#logoutButton span{display:none}.role-badge-wrap{position:absolute;top:10px;left:10px;display:flex;align-items:center;gap:4px}.role-delete{opacity:0;transition:.2s;cursor:pointer}.role-badge-wrap:hover .role-delete{opacity:1}.tier-name{font-size:clamp(10px,1vw,14px)!important;text-overflow:ellipsis;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}.players-grid{grid-template-columns:repeat(auto-fill,minmax(250px,1fr))!important;gap:28px!important}

/* ---------- Vote score badge (admin only) ---------- */
.vote-score-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #ff8a3d;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.vote-score-badge svg {
  width: 12px;
  height: 12px;
}

/* ---------- Voting widget (centered modal, blurred backdrop) ---------- */
.voting-bar {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 8, 12, 0.58);
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  animation: votingBackdropIn 260ms ease both;
}

.voting-bar[hidden] {
  display: none;
}

@keyframes votingBackdropIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.voting-bar-inner {
  position: relative;
  width: 100%;
  max-width: 620px;
  max-height: min(88vh, 720px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  padding: 26px 26px calc(22px + env(safe-area-inset-bottom, 0px));
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4), 0 4px 18px rgba(0, 0, 0, 0.25);
  animation: votingModalIn 340ms cubic-bezier(0.2, 0.9, 0.24, 1.08) both;
}

@keyframes votingModalIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.voting-info {
  text-align: center;
}

.voting-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
  min-height: 26px;
  justify-content: center;
  display: flex;
  align-items: center;
}

.voting-hint {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
  min-height: 16px;
  text-align: center;
}

.voting-heads {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 4px 2px;
}

.voting-head {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 76px;
  padding: 8px 6px;
  border-radius: 14px;
  border: 2px solid transparent;
  background: var(--surface-soft);
  transition: transform var(--speed) ease, border-color var(--speed) ease, background var(--speed) ease;
}

.voting-head:hover {
  transform: translateY(-2px);
}

.voting-head-avatar {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--surface-soft);
}

.voting-head-avatar img {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  object-fit: contain;
}

.voting-head-name {
  font-size: 11px;
  font-weight: 600;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voting-head.is-fav {
  border-color: #2fbf6a;
  background: rgba(47, 191, 106, 0.14);
}

.voting-head.is-unfav {
  border-color: #e5484d;
  background: rgba(229, 72, 77, 0.14);
}

.voting-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.voting-actions .secondary-button,
.voting-actions .primary-button {
  flex: 1 1 160px;
  justify-content: center;
}

@media (max-width: 640px) {
  .voting-bar {
    padding: 12px;
  }
  .voting-bar-inner {
    padding: 20px 18px calc(18px + env(safe-area-inset-bottom, 0px));
    border-radius: 18px;
  }
  .voting-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .voting-actions .secondary-button,
  .voting-actions .primary-button {
    flex: none;
  }
}

/* ---------- Voting admin tab ---------- */
.voting-admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 16px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  margin-bottom: 22px;
}

.voting-timer-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.voting-admin-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- Тост "Сообщение от администрации" ---------- */

.admin-message-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 360px;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  transform: translateY(24px);
  opacity: 0;
  transition: transform 260ms ease, opacity 260ms ease;
  pointer-events: none;
}

.admin-message-toast.is-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.admin-message-toast[hidden] {
  display: none !important;
}

.admin-message-toast-icon {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.admin-message-toast-body {
  flex: 1;
  min-width: 0;
}

.admin-message-toast-title {
  margin: 0 0 4px;
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-message-toast-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.admin-message-toast-close {
  flex: none;
}

@media (max-width: 560px) {
  .admin-message-toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }
}

.voting-timer-label {
  font-size: 12px;
  color: var(--muted);
}

.voting-timer {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.voting-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}

.voting-admin-empty {
  color: var(--muted);
  font-size: 14px;
}

.voting-admin-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: transform var(--speed) ease, border-color var(--speed) ease;
}

.voting-admin-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.voting-admin-avatar {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--surface-soft);
}

.voting-admin-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.voting-admin-name {
  font-size: 12.5px;
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voting-admin-counts {
  display: flex;
  gap: 10px;
  font-size: 11.5px;
  font-weight: 700;
}

.count-fav {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #2fbf6a;
}

.count-unfav {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #e5484d;
}

.count-fav img,
.count-unfav img {
  width: 15px;
  height: 15px;
  object-fit: contain;
  border-radius: 3px;
  vertical-align: middle;
  transform: scale(1.35); /* картинка визуально крупнее, но карточку не раздвигает — размер в layout остаётся прежним */
}

/* ---------- Voting stats modal ---------- */
.modal-wide {
  width: min(680px, 100%);
}

.voting-stats-summary {
  display: flex;
  gap: 22px;
  margin-bottom: 16px;
}

.voting-stats-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.voting-stats-stat .count-fav,
.voting-stats-stat .count-unfav {
  font-size: 20px;
}

.voting-stats-stat .count-fav img,
.voting-stats-stat .count-unfav img {
  width: 24px;
  height: 24px;
  transform: scale(1.25);
}

.voting-stats-stat small {
  color: var(--muted);
  font-size: 11.5px;
}

.voting-stats-chart {
  width: 100%;
}

.voting-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.voting-chart-line {
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.voting-chart-line-fav {
  stroke: #2fbf6a;
}

.voting-chart-line-unfav {
  stroke: #e5484d;
}

.voting-chart-grid {
  stroke: var(--line);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.voting-chart-axis-label {
  font-size: 9px;
  fill: var(--muted);
}

.voting-chart-empty {
  color: var(--muted);
  font-size: 13.5px;
  padding: 30px 0;
  text-align: center;
}

.voting-stats-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  margin-right: 4px;
  vertical-align: middle;
}

.legend-fav {
  background: #2fbf6a;
}

.legend-unfav {
  background: #e5484d;
}