/* Галерея флагов (вкладки «Флаги», «Голосование», «Победители»). Подключается в index.html.
   Палитра, шрифты и скругления берутся из переменных сайта (--home-*, --font-display, --font-body). */

body.is-gallery {
  --g-card: var(--home-surface);
  --g-block: var(--home-surface-soft);
  --g-focus: #7db4ff;
  --g-flag-bg: #101c33;
}

/* Страница прокручивается самим документом (в приложении body обычно не прокручивается) */
html:has(body.is-gallery) { height: auto; }

body.is-gallery {
  height: auto;
  min-height: var(--app-vh);
  overflow-x: hidden;
  overflow-y: auto;
}

body.is-gallery .main { flex: 1 0 auto; overflow: visible; }

body.is-gallery .screen--active {
  display: block;
  flex: 1 0 auto;
  overflow: visible;
}

body.is-gallery .logo { text-decoration: none; }

/* ---------- страница ---------- */

.gallery-page {
  position: relative;
  width: 100%;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 36px) clamp(16px, 3.2vw, 40px) clamp(22px, 3vw, 36px);
  background: var(--home-surface);
  border: 1px solid var(--home-border);
  border-radius: var(--home-radius-lg);
  box-shadow: 0 0 60px rgba(47, 125, 253, 0.08);
  color: var(--home-text);
  font-family: var(--font-body);
}

body.is-gallery .back-btn {
  display: inline-block;
  margin: 0 0 clamp(10px, 1.6vh, 16px);
  color: var(--home-text-muted);
  font-size: 0.9rem;
  text-decoration: none;
}

body.is-gallery .back-btn:hover { color: var(--home-text); }

.gallery-page__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin: 0 0 clamp(16px, 2.2vw, 22px);
}

.gallery-page__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.6rem, 2.8vw, 2.1rem);
  line-height: 1.15;
  color: var(--home-text);
}

.gallery-page__icon {
  position: absolute;
  top: clamp(16px, 2.6vw, 32px);
  right: clamp(16px, 3.2vw, 40px);
  width: clamp(72px, 10.5vw, 144px);
  height: auto;
}

/* ---------- вкладки ---------- */

.gallery-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gallery-tab {
  min-height: 38px;
  padding: 0 clamp(14px, 2.4vw, 20px);
  border: 1px solid var(--home-border);
  border-radius: 999px;
  background: transparent;
  color: var(--home-text-muted);
  font-family: var(--font-body);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.gallery-tab { transition: background 0.15s, color 0.15s, border-color 0.15s; }

.gallery-tab:hover { color: var(--home-text); border-color: rgba(74, 150, 255, 0.6); }

.gallery-tab[aria-selected="true"] {
  background: var(--home-primary);
  border-color: #6aa8ff;
  color: #fff;
}

.gallery-panel {
  margin-top: clamp(16px, 2vw, 22px);
  padding: clamp(20px, 3vw, 32px) clamp(16px, 3vw, 32px);
  background: var(--g-block);
  border: 1px solid var(--home-border-soft);
  border-radius: var(--home-radius);
  text-align: center;
}

.gallery-panel[hidden] { display: none; }

.gallery-tab:focus-visible,
.gallery-panel:focus-visible,
.flag-tile:focus-visible,
.g-btn:focus-visible,
body.is-gallery .back-btn:focus-visible {
  outline: 2px solid var(--g-focus);
  outline-offset: 3px;
}

/* рамка 3:2 как у флага Италии; картинка вписывается целиком (contain): без обрезки и растяжения */
.flag-frame {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: var(--g-flag-bg);   /* тёмная подложка в стиле сайта: белые части флагов (Катар, Непал…) не сливаются с рамкой */
}

.flag-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---------- ТОП 10 (вкладка «Голосование») ---------- */

.gallery-panel--vote,
.gallery-panel--winners { text-align: left; }

.top__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.top__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.3rem, 2.4vw, 1.7rem);
  line-height: 1.2;
  color: var(--home-text);
}

.top__sub {
  max-width: 62ch;
  margin: 8px 0 clamp(20px, 3vw, 30px);
  color: var(--home-text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.rating__live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border: 1px solid var(--home-border);
  border-radius: 999px;
  color: var(--home-text);
  font-size: 0.85rem;
  font-weight: 600;
}

.rating__live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--home-success); }

/* плашка континента */
.chip {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--home-border);
  border-radius: 999px;
  background: var(--home-primary-soft);
  color: var(--home-text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.top-row__name .mine-badge { display: inline-block; margin-left: 6px; vertical-align: middle; font-family: var(--font-body); }

.mine-badge {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--home-primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

/* пьедестал: на экране порядок 2 · 1 · 3, высота ступеней разная */
.podium {
  --gold: #e0b94a;
  --silver: #b9c6dc;
  --bronze: #c98a62;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: clamp(8px, 1.6vw, 18px);
  max-width: 820px;
  margin: 0 auto clamp(22px, 3vw, 32px);
  padding: 0;
  list-style: none;
}

.podium__item { display: flex; flex-direction: column; min-width: 0; --c: var(--silver); }
.podium__item--1 { --c: var(--gold); }
.podium__item--3 { --c: var(--bronze); }

.podium__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: clamp(10px, 1.6vw, 16px);
  border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: var(--g-card);
  text-align: center;
}

.podium__item--1 .podium__card { padding-top: clamp(14px, 2vw, 22px); box-shadow: 0 -10px 34px color-mix(in srgb, var(--c) 14%, transparent); }

.podium__flag {
  display: block;
  width: 100%;
  max-width: 190px;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: var(--g-flag-bg);   /* тёмная подложка в стиле сайта: белые части флагов (Катар, Непал…) не сливаются с рамкой */
}

.podium__item--1 .podium__flag { max-width: 230px; }

.podium__name {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-family: var(--font-display);
  font-size: clamp(0.9rem, 1.5vw, 1.1rem);
  line-height: 1.25;
  color: var(--home-text);
}

.podium__votes { color: var(--c); font-size: 0.9rem; font-weight: 600; }

.podium__step {
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);
  border-radius: 0 0 12px 12px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 22%, var(--g-card)), var(--g-card));
}

.podium__item--1 .podium__step { height: 92px; }
.podium__item--2 .podium__step { height: 64px; }
.podium__item--3 .podium__step { height: 44px; }

.podium__place {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  line-height: 1;
  color: var(--c);
}

.podium__item.is-mine .podium__card { border-color: #4a96ff; box-shadow: 0 0 0 1px rgba(74, 150, 255, 0.45); }

/* места 4–10 */
.top-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 820px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.top-row {
  display: grid;
  grid-template-columns: 36px 72px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px 14px;
  padding: 8px 16px 8px 10px;
  border: 1px solid var(--home-border-soft);
  border-radius: 14px;
  background: var(--g-card);
}

.top-row.is-mine { border-color: #4a96ff; background: rgba(47, 125, 253, 0.1); }

.top-row__place {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--home-primary-soft);
  color: var(--home-text);
  font-family: var(--font-display);
  font-size: 0.9rem;
}

.top-row__flag {
  display: block;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: var(--g-flag-bg);   /* тёмная подложка в стиле сайта: белые части флагов (Катар, Непал…) не сливаются с рамкой */
}

.top-row__name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.25;
  color: var(--home-text);
}

.top-row__votes { color: var(--home-text-muted); font-size: 0.9rem; font-weight: 600; white-space: nowrap; text-align: right; min-width: 82px; }

/* ---------- вкладка «Победители» ---------- */

.winners {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.winner {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  align-items: start;   /* флаг и текст начинаются на одном уровне во всех карточках, даже если у одной есть пометка «Ничья» */
  gap: 16px;
  padding: 14px;
  border: 1px solid rgba(224, 185, 74, 0.45);
  border-radius: 16px;
  background: var(--g-card);
}

.winner__flag {
  display: block;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: var(--g-flag-bg);   /* тёмная подложка в стиле сайта: белые части флагов (Катар, Непал…) не сливаются с рамкой */
}

.winner__text { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-width: 0; }
.winner__period { color: var(--home-amber); font-size: 0.85rem; font-weight: 600; }
.winner__name { overflow-wrap: anywhere; font-family: var(--font-display); font-size: 1.15rem; line-height: 1.25; color: var(--home-text); }
.winner__votes { color: var(--home-text-muted); font-size: 0.88rem; font-weight: 600; }

/* ---------- кнопки ---------- */

.g-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 clamp(22px, 3vw, 32px);
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--home-primary);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(47, 125, 253, 0.28);
  transition: background 0.15s;
}

.g-btn:hover { background: #2469db; }

.g-btn[hidden] { display: none; }

.g-btn--ghost {
  background: transparent;
  border-color: var(--home-border);
  color: var(--home-text);
  box-shadow: none;
}

.g-btn--ghost:hover { background: var(--home-primary-soft); border-color: rgba(74, 150, 255, 0.6); }

/* ---------- окно крупного просмотра ---------- */

.viewer {
  width: min(94vw, 760px);
  max-height: 92vh;
  padding: clamp(16px, 3vw, 28px);
  border: 1px solid var(--home-border);
  border-radius: 22px;
  background: var(--home-surface);
  color: var(--home-text);
  font-family: var(--font-body);
  text-align: center;
  overflow: auto;
}

.viewer::backdrop { background: rgba(2, 6, 16, 0.78); }

.viewer__flag {
  display: flex;
  justify-content: center;
  margin: 0 0 18px;
}

/* пропорции берутся из самого файла: ширина и высота ограничиваются только максимумами */
.viewer__img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(52vh, 480px);
  object-fit: contain;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: var(--g-flag-bg);   /* тёмная подложка в стиле сайта: белые части флагов (Катар, Непал…) не сливаются с рамкой */
}

.viewer__title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  line-height: 1.2;
}

.viewer__capital {
  margin: 0 0 20px;
  color: var(--home-text-muted);
  font-size: 1rem;
}

.viewer__capital strong { color: var(--home-text); font-weight: 600; }

/* ---------- телефон ---------- */

@media (max-width: 640px) {
  body.is-gallery .main { padding-left: 16px; padding-right: 16px; }
  body.is-gallery .topbar__inner { padding-left: 16px; padding-right: 16px; }

  .gallery-page { padding: 16px 14px 18px; }
  .gallery-panel { padding: 18px 12px; }

  .gallery-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .gallery-tab { padding: 0 4px; font-size: 0.8rem; }
  .gallery-page__head { padding-right: 60px; }

  .viewer .g-btn { width: 100%; }

  .podium { gap: 6px; }
  .podium__card { padding: 8px 6px; gap: 6px; }
  .podium__name { font-size: 0.78rem; }
  .podium__votes { font-size: 0.74rem; }
  .podium .chip { padding: 2px 6px; font-size: 0.68rem; }
  .podium .mine-badge { padding: 2px 6px; font-size: 0.66rem; }
  .podium__item--1 .podium__step { height: 72px; }
  .podium__item--2 .podium__step { height: 50px; }
  .podium__item--3 .podium__step { height: 34px; }

  /* строка: номер, флаг, название; ниже плашка континента и голоса */
  .top-row { grid-template-columns: 28px 60px minmax(0, 1fr) auto; padding: 8px 10px 8px 8px; }
  .top-row__place { width: 28px; height: 28px; font-size: 0.82rem; }
  .top-row__place, .top-row__flag { grid-row: 1 / span 2; }
  .top-row__name { grid-column: 3 / -1; grid-row: 1; }
  .top-row .chip { grid-column: 3; grid-row: 2; justify-self: start; }
  .top-row__votes { grid-column: 4; grid-row: 2; min-width: 0; }

  .winner { grid-template-columns: 84px minmax(0, 1fr); }
}

/* ---------- вкладка «Флаги»: фильтр и сетка ---------- */

.gallery-sub {
  margin: 6px 0 0;
  color: var(--home-text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.gallery-page__head { flex-direction: column; align-items: flex-start; gap: 0; padding-right: clamp(60px, 9vw, 120px); }

.gallery-panel--all { text-align: left; }

.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.gallery-filter {
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid var(--home-border);
  border-radius: 999px;
  background: transparent;
  color: var(--home-text-muted);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.gallery-filter:hover { color: var(--home-text); border-color: rgba(74, 150, 255, 0.6); }
.gallery-filter[aria-pressed="true"] { background: var(--home-primary); border-color: #6aa8ff; color: #fff; }
.gallery-filter:focus-visible { outline: 2px solid var(--g-focus); outline-offset: 2px; }

.gallery-hint {
  margin: 0 0 18px;
  color: var(--home-text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.flag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(92px, 9vw, 120px), 1fr));
  gap: clamp(8px, 1.2vw, 14px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.flag-grid > li { min-width: 0; content-visibility: auto; contain-intrinsic-size: 90px 100px; }

.flag-tile {
  display: block;
  width: 100%;
  padding: 5px;
  border: 1px solid var(--home-border);
  border-radius: 12px;
  background: var(--g-card);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.flag-tile:hover { border-color: rgba(74, 150, 255, 0.7); background: #13203a; }
.flag-tile.is-mine { border-color: #4a96ff; background: rgba(47, 125, 253, 0.12); }

.flag-tile__name {
  display: block;
  margin: 6px 2px 0;
  color: var(--home-text);
  font-size: 0.72rem;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: anywhere;
}

.flag-tile__votes {
  display: block;
  margin: 2px 2px 2px;
  color: var(--home-text-muted);
  font-size: 0.68rem;
  line-height: 1.2;
  text-align: center;
}

.flag-tile.is-mine .flag-tile__votes { color: #9cc4ff; }

/* ---------- состояния: загрузка, пусто, ошибка ---------- */

.gallery-note {
  margin: 0;
  padding: clamp(18px, 3vw, 28px);
  border: 1px dashed var(--home-border);
  border-radius: 14px;
  color: var(--home-text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  text-align: center;
}

.gallery-note .g-btn { margin-top: 14px; }

/* ---------- окно просмотра: голосование ---------- */

.viewer__votes { margin: -8px 0 16px; color: var(--home-text-muted); font-size: 0.92rem; }
.viewer__status { margin: 0 0 16px; color: var(--home-text-muted); font-size: 0.92rem; line-height: 1.45; }
.viewer__status--ok { color: #9cc4ff; font-weight: 600; }
.viewer__status--warn { color: var(--home-amber); }
.viewer__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.g-btn:disabled { opacity: 0.55; cursor: default; box-shadow: none; }

/* ---------- сообщения ---------- */

.gallery-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: min(92vw, 480px);
  margin: 0;
  padding: 12px 18px;
  transform: translateX(-50%);
  border: 1px solid var(--home-border);
  border-radius: 14px;
  background: var(--home-surface);
  color: var(--home-text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.45;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.gallery-toast[hidden] { display: none; }

.winner__tie { color: var(--home-text-muted); font-size: 0.8rem; }

@media (max-width: 640px) {
  .flag-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .flag-tile { padding: 3px; border-radius: 10px; }
  .flag-tile__votes { font-size: 0.6rem; margin: 3px 0 1px; }
  .gallery-filters { flex-wrap: nowrap; overflow-x: auto; margin-inline: -4px; padding: 0 4px 6px; scrollbar-width: none; }
  .gallery-filter { flex: 0 0 auto; }
  .viewer__actions .g-btn { width: 100%; }
}

/* пьедестал, когда голосов ещё мало: один или два флага */
.podium[data-count="1"] { grid-template-columns: minmax(0, 260px); justify-content: center; }
.podium[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.podium:empty, .top-list:empty { display: none; }

/* подзаголовок «Голосования» в одну строку; кнопка перехода к флагам внизу под рейтингом */
#top-sub, #gpanel-winners .top__sub { max-width: none; }
#goto-flags { display: flex; margin: clamp(20px, 3vw, 28px) auto 0; width: fit-content; }
#goto-flags[hidden] { display: none; }

/* ---------- меню: шесть пунктов (добавлена «Галерея») ----------
   В style.css пункты рассчитаны на пять; на узком телефоне чуть уменьшаем шрифт и отступы, чтобы «Рейтинг» не уезжал за край. */
@media (max-width: 520px) {
  body[class] .topbar__link {
    padding: 6px clamp(3px, 1.3vw, 8px);
    font-size: clamp(0.56rem, 2.7vw, 0.78rem);
  }
  body[class] .topbar__nav { gap: clamp(2px, 0.8vw, 4px); }
}

/* ---------- флаги по форме, без подложки ----------
   Раньше флаг вписывался в рамку 3:2 с фоном: у флагов другой формы (Канада 2:1, Катар, Непал) по краям появлялись полосы,
   а белая часть сливалась с белой подложкой. Теперь слот 3:2 остаётся для ровной сетки, а сам флаг лежит в нём по центру
   в своих пропорциях; контур повторяет форму флага (в том числе непрямоугольного). */
.flag-frame, .podium__flag, .top-row__flag, .winner__flag {
  position: relative;
  overflow: visible;
  border: 0;
  background: transparent;
}
.flag-img {
  position: absolute;
  inset: 0;
  margin: auto;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  border-radius: 5px;
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.3));
}
.viewer__img { background: transparent; border: 0; border-radius: 8px; filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.3)); }

/* ---------- ТОП 10: компактнее на одну пятую ---------- */
@media (min-width: 641px) {
  .podium { max-width: 560px; gap: clamp(6px, 1.1vw, 12px); margin-bottom: clamp(14px, 2vw, 22px); }
  .podium__card { gap: 5px; padding: clamp(7px, 1.1vw, 11px); border-radius: 12px 12px 0 0; }
  .podium__item--1 .podium__card { padding-top: clamp(9px, 1.3vw, 14px); }
  .podium__flag { max-width: 128px; }
  .podium__item--1 .podium__flag { max-width: 156px; }
  .podium__name { font-size: clamp(0.68rem, 1vw, 0.8rem); }
  .podium__votes { font-size: 0.66rem; }
  .podium .chip, .top-row .chip { padding: 2px 7px; font-size: 0.58rem; }
  .podium .mine-badge, .top-row .mine-badge { padding: 2px 8px; font-size: 0.6rem; }
  .podium__step { border-radius: 0 0 10px 10px; }
  .podium__item--1 .podium__step { height: 62px; }
  .podium__item--2 .podium__step { height: 43px; }
  .podium__item--3 .podium__step { height: 30px; }
  .podium__place { font-size: clamp(1.1rem, 2vw, 1.45rem); }

  .top-list { max-width: 560px; gap: 5px; }
  .top-row { grid-template-columns: 26px 50px minmax(0, 1fr) auto auto auto; gap: 5px 10px; padding: 5px 12px 5px 7px; border-radius: 10px; }
  .top-row__place { width: 24px; height: 24px; font-size: 0.68rem; }
  .top-row__name { font-size: 0.74rem; }
  .top-row__votes { font-size: 0.66rem; min-width: 58px; }
}

/* карточки победителей: флаг по высоте равен блоку «месяц + название» и стоит на одной линии с ним */
.winner__flag { align-self: start; margin-top: 2px; }

/* ---------- победители: одна карточка на месяц, при ничьей несколько флагов ---------- */
.winner__flags { display: flex; flex-direction: column; gap: 8px; align-self: start; }
.winner__flags .winner__flag { align-self: auto; margin-top: 0; }
.winner__row { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-width: 0; }
.winner--tie .winner__row { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.winner--tie .winner__name { font-size: 1rem; }
.winner__tie { margin: -2px 0 2px; color: var(--home-text-muted); font-size: 0.7rem; line-height: 1.3; }

/* ---------- плашки континента: вдвое меньше ---------- */
.chip, .podium .chip, .top-row .chip, .winner .chip {
  padding: 1px 6px;
  font-size: 0.5rem;
  line-height: 1.35;
  letter-spacing: 0.01em;
}

/* ---------- победители: карточки меньше на одну пятую ---------- */
.winners { grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 11px; }
.winner { grid-template-columns: 84px minmax(0, 1fr); gap: 13px; padding: 11px; border-radius: 13px; }
.winner__flags { gap: 6px; }
.winner__text { gap: 4px; }
.winner__period { font-size: 0.68rem; }
.winner__name { font-size: 0.92rem; }
.winner--tie .winner__name { font-size: 0.8rem; }
.winner__votes { font-size: 0.7rem; }
.winner__tie { font-size: 0.56rem; }
.winner__row { gap: 4px; }

.g-btn--small { min-height: 40px; padding: 0 18px; margin: 0 0 18px; font-size: 0.88rem; }

/* ---------- окно просмотра флага: вдвое меньше (раньше занимало почти весь экран) ---------- */
.viewer { width: min(92vw, 380px); padding: clamp(14px, 2.4vw, 20px); border-radius: 18px; }
.viewer__flag { margin-bottom: 14px; }
.viewer__img { max-height: min(26vh, 220px); }
.viewer__title { font-size: clamp(1.15rem, 2.4vw, 1.4rem); }
.viewer__capital { margin-bottom: 14px; font-size: 0.9rem; }
.viewer__votes { margin-top: -6px; margin-bottom: 12px; font-size: 0.85rem; }
.viewer__status { margin-bottom: 12px; font-size: 0.85rem; }
.viewer .g-btn { min-height: 44px; font-size: 0.92rem; padding: 0 clamp(16px, 2.4vw, 22px); }

/* кнопка «Проголосовать» у флага в рейтинге */
.vote-mini {
  min-height: 28px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--home-primary);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s;
}
.vote-mini:hover { background: #2469db; }
.vote-mini:focus-visible { outline: 2px solid var(--g-focus); outline-offset: 2px; }
.podium__card .vote-mini { margin-top: 8px; }
.top-row .vote-mini { justify-self: end; }
@media (max-width: 640px) {
  .top-row:has(.vote-mini) .top-row__place, .top-row:has(.vote-mini) .top-row__flag { grid-row: 1 / span 3; }
  .top-row .vote-mini { grid-column: 3 / -1; grid-row: 3; justify-self: stretch; min-height: 28px; padding: 0 10px; font-size: 0.7rem; }
  .podium__card .vote-mini { margin-top: 6px; padding: 0 4px; font-size: 0.56rem; min-height: 24px; width: 100%; max-width: 100%; box-sizing: border-box; }
}
