/* ════════════════════════════════════════════════════════════════
   modals.css — модальные окна и связанные компоненты
   Содержание:
   1.  Каркас модалки
   2.  Окно (window) и шапка
   3.  Модалка серверных игр
   4.  Базовые элементы (заголовок, текст, действия)
   5.  Toast
   6.  Превью
   7.  Редактирование истории
   8.  Правила
   9.  Калькулятор — каркас
   10. Калькулятор — выбранные плитки
   11. Калькулятор — структура и разложение
   12. Калькулятор — шапка секции и счётчик
   13. Калькулятор — плитки и пикер
   14. Калькулятор — группы и условия
   15. Калькулятор — результат
   16. Объяснение счёта
   17. Адаптив калькулятора
   18. @keyframes
   ════════════════════════════════════════════════════════════════ */

/* ── 1. Каркас модалки ── */

.modal {
  display: none;
  position: fixed;
  z-index: 20000;
  inset: 0;
  padding: 16px;
  box-sizing: border-box;
  background-color: var(--color-modal-backdrop);
  backdrop-filter: blur(10px) saturate(1.3);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal.modal--layered {
  background-color: rgb(0 0 0 / 28%);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Правила поверх калькулятора: без второго слоя размытия */
#modalOverlayRules.modal--layered {
  background-color: transparent;
}

.modal.show {
  display: flex;
  opacity: 1;
}

.modal-content {
  background-color: var(--color-surface);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  padding: 20px;
  border-radius: 20px;
  border: 1px solid rgb(255 255 255 / 52%);
  width: min(92vw, 520px);
  max-height: calc(100vh - 32px);
  overflow: auto;
  text-align: center;
  box-shadow: 0 8px 28px rgb(15 23 42 / 14%), inset 0 1px 0 rgb(255 255 255 / 60%);
  transform: scale(0.92);
  transition: transform 0.25s ease;
}

.modal.show .modal-content {
  transform: scale(1);
}

.modal.show .modal-content--window,
.modal-content--window {
  transform: none !important;
}

/* Появление контента: обычные модалки всплывают с пружинкой */
.modal.show .modal-content:not(.modal-content--window) {
  animation: modalContentIn 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

/* Окна (правила/калькулятор) двигаются через left/top — только плавное проявление */
.modal.show .modal-content--window {
  animation: modalWindowIn 0.3s ease-out backwards;
}

/* Ступенчатое появление прямых дочерних блоков */
.modal.show .modal-content > * {
  animation: modalChildIn 0.42s cubic-bezier(0.22, 1.08, 0.36, 1) backwards;
}

.modal.show .modal-content > :nth-child(1) { animation-delay: 0.04s; }
.modal.show .modal-content > :nth-child(2) { animation-delay: 0.12s; }
.modal.show .modal-content > :nth-child(3) { animation-delay: 0.2s; }
.modal.show .modal-content > :nth-child(4) { animation-delay: 0.28s; }
.modal.show .modal-content > :nth-child(5) { animation-delay: 0.36s; }
.modal.show .modal-content > :nth-child(6) { animation-delay: 0.44s; }

@media (prefers-reduced-motion: reduce) {
  .modal.show .modal-content:not(.modal-content--window),
  .modal.show .modal-content--window,
  .modal.show .modal-content > *,
  .modal.closing .modal-content:not(.modal-content--window),
  .modal.closing .modal-content--window,
  .modal.closing .modal-content > * {
    animation: none;
  }

  .modal.closing {
    transition-delay: 0s;
    transition-duration: 0.2s;
  }

  .modal-content {
    transition: none;
  }
}

/* ── Закрытие: контент сворачивается в центр, затем гаснет фон ── */

.modal.closing {
  opacity: 0;
  transition: opacity 0.25s ease 0.32s;
}

.modal.closing .modal-content:not(.modal-content--window) {
  animation: modalContentOut 0.32s cubic-bezier(0.55, 0, 1, 0.45) both;
}

.modal.closing .modal-content--window {
  animation: modalWindowOut 0.32s cubic-bezier(0.55, 0, 1, 0.45) both;
}

.modal.closing .modal-content > * {
  animation: modalChildOut 0.22s ease-out both;
}

.modal.closing .modal-content > :nth-child(1) { animation-delay: 0s; }
.modal.closing .modal-content > :nth-child(2) { animation-delay: 0.04s; }
.modal.closing .modal-content > :nth-child(3) { animation-delay: 0.08s; }
.modal.closing .modal-content > :nth-child(4) { animation-delay: 0.12s; }
.modal.closing .modal-content > :nth-child(5) { animation-delay: 0.16s; }
.modal.closing .modal-content > :nth-child(6) { animation-delay: 0.2s; }

.modal--floating {
  display: block !important;
  padding: 0;
}

.modal--floating.modal.show {
  display: block !important;
}

.modal-content--chart {
  width: min(96vw, 960px);
  background-color: var(--color-section);
}

.modal-content--dialog {
  width: min(92vw, 460px);
}

#modalOverlayAccessPassword .modal-content--dialog {
  text-align: left;
}

#modalOverlayInfo .modal-content--dialog,
#modalOverlayQuestion .modal-content--dialog,
#modalOverlayAccessPassword .modal-content--dialog {
  width: min(92vw, 500px);
  padding: 26px 22px 22px;
}

.access-password-input {
  width: 100%;
  box-sizing: border-box;
  margin-top: 8px;
  padding: 12px 14px;
  font-size: 18px;
  font-family: inherit;
  color: var(--color-text);
  background-color: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.access-password-input:focus {
  border-color: var(--color-accent, #2a9d8f);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent, #2a9d8f) 25%, transparent);
}

.modal-content--server-games {
  width: min(92vw, 520px);
  text-align: left;
}

/* ── 2. Окно (window) и шапка ── */

.modal-content--window {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  transition: border-radius 0.2s ease;
}

.modal-content--window.is-positioned {
  position: fixed;
  z-index: 1;
  margin: 0;
}

.modal-content--window.is-maximized {
  position: fixed !important;
  inset: 16px !important;
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  border-radius: 12px;
}

.modal-content--window.is-maximized .modal-window-header {
  border-radius: 12px 12px 0 0;
}

.modal-window-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  margin: -20px -20px 1px;
  padding: 10px 10px 10px 20px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-panel);
  border-radius: 20px 20px 0 0;
  cursor: move;
  user-select: none;
  touch-action: none;
}

.modal-window-header .modal-title {
  flex: 1;
  margin: 0;
  text-align: left;
  font-size: 1.15em;
  line-height: 1.25;
  min-width: 0;
  cursor: move;
}

.modal-window-header .modal-title i {
  margin-right: 8px;
}

.modal-window-header .modal-window-control {
  flex-shrink: 0;
  align-self: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  max-width: 32px;
  min-height: 32px;
  max-height: 32px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transform: none;
  box-sizing: border-box;
}

.modal-window-header .modal-window-control:hover {
  background: var(--color-surface-alt);
  color: var(--color-heading);
  transform: none;
}

.modal-window-header .modal-window-control:active {
  transform: none;
}

.modal-window-header .modal-window-control i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin: 0;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  pointer-events: none;
}

.modal-window-header .modal-window-control i::before {
  display: block;
  width: 14px;
  line-height: 14px;
  text-align: center;
}

.modal-content--window.modal-content--rules {
  max-height: calc(100vh - 32px);
}

.modal-content--window.modal-content--rules .rules-content {
  flex: 1 1 auto;
  min-height: 0;
}

.modal-content--window.modal-content--rules .modal-actions {
  flex-shrink: 0;
}

.modal-content--window.is-maximized .rules-content {
  max-height: none;
}

/* ── 3. Модалка серверных игр ── */

.server-games-hint {
  margin: -8px 0 14px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--color-text-muted);
}

.server-games-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(60vh, 420px);
  margin-bottom: 16px;
  padding: 2px;
  overflow-x: hidden;
  overflow-y: auto;
}

.server-games-empty {
  margin: 0;
  padding: 28px 16px;
  border-radius: 16px;
  background: var(--color-panel);
  color: var(--color-text-muted);
  text-align: center;
  font-size: 15px;
  line-height: 1.45;
}

.server-games-empty--error {
  color: var(--color-red);
}

.server-games-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  flex-shrink: 0;
  gap: 4px;
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0;
  padding: 8px 8px 8px 10px;
  border: 1px solid rgb(103 103 103 / 14%);
  border-radius: 16px;
  background: var(--color-surface);
  color: var(--color-heading);
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.server-games-item:hover {
  border-color: rgb(23 158 211 / 35%);
  background: var(--color-surface);
  color: var(--color-heading);
  box-shadow: 0 4px 14px rgb(0 0 0 / 8%);
  transform: translateY(-1px);
}

.server-games-item--current {
  border-color: rgb(31 122 83 / 55%);
  box-shadow: inset 0 0 0 1px rgb(31 122 83 / 22%);
}

.server-games-item--current:hover {
  border-color: rgb(31 122 83 / 65%);
  box-shadow: inset 0 0 0 1px rgb(31 122 83 / 28%), 0 4px 14px rgb(0 0 0 / 8%);
}

.server-games-item__top {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.server-games-item__badge {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgb(31 122 83 / 16%);
  color: #1f7a53;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.4;
  white-space: nowrap;
}

.server-games-item__open {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  min-width: 0;
  max-width: none;
  min-height: 0;
  max-height: none;
  margin: 0;
  padding: 6px 8px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
  transition: background-color 0.18s ease;
}

.server-games-item__open:hover {
  background: rgb(23 158 211 / 8%);
}

.server-games-item__open:active {
  transform: none;
}

.server-games-item__delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  max-width: 36px;
  min-height: 36px;
  max-height: 36px;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--color-red, #af4c4c);
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  box-sizing: border-box;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.server-games-item__delete:hover {
  background: rgb(175 76 76 / 12%);
  border-color: rgb(175 76 76 / 28%);
  color: var(--color-red-dark, #8a0000e8);
}

.server-games-item__delete:active {
  transform: scale(0.96);
}

.server-games-item__delete i {
  margin: 0;
  line-height: 1;
  pointer-events: none;
}

.server-games-item__players {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--color-heading);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-games-item__meta,
.server-games-item__date {
  font-size: 13px;
  line-height: 1.35;
  color: var(--color-text-muted);
}

/* ── 4. Базовые элементы (заголовок, текст, действия) ── */

.modal-title {
  margin: 0 0 16px;
  font-size: 1.4em;
  color: var(--color-heading);
}

.modal-chart-wrap {
  width: 100%;
  overflow-x: auto;
}

.modal-chart-wrap canvas {
  display: block;
  width: 100%;
  max-height: 60vh;
}

.modal-text {
  margin: 0;
  padding: 18px 20px;
  border-radius: 16px;
  background-color: var(--color-panel);
  font-size: 19px;
  line-height: 1.55;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.modal-text i {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  margin: 2px 0 0;
  border-radius: 50%;
  font-size: 30px;
  line-height: 1;
  background: color-mix(in srgb, var(--color-info-border) 15%, transparent);
  color: var(--color-info-border);
  box-shadow: var(--elev-2);
}

.modal-text > span {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  font-weight: 500;
}

.modal-text--info {
  background:
    linear-gradient(
      135deg,
      color-mix(in srgb, var(--color-info-border) 7%, transparent),
      transparent 55%
    ),
    var(--color-panel);
}

.modal-text--question {
  background:
    linear-gradient(
      135deg,
      color-mix(in srgb, var(--color-question-border) 8%, transparent),
      transparent 55%
    ),
    var(--color-panel);
}

.modal-text--question i {
  background: color-mix(in srgb, var(--color-question-border) 15%, transparent);
  color: var(--color-question-border);
}

.modal-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.modal-actions button {
  margin-top: 0px;
  min-width: 88px;
  max-width: 132px;
  min-height: 0;
  max-height: 38px;
  padding: 8px 16px;
  font-size: 14px;
}

#modalOverlayInfo .modal-actions button,
#modalOverlayQuestion .modal-actions button {
  min-width: 96px;
  max-width: 180px;
  max-height: none;
  min-height: 40px;
  padding: 10px 22px;
  font-size: 16px;
}

#modalOverlayInfo .modal-actions--split,
#modalOverlayQuestion .modal-actions--split {
  justify-content: center;
}

.modal-content button,
.modal-actions button {
  background-color: rgb(255 255 255 / 45%);
}

.modal-actions--edit-history.modal-actions button {
  margin-top: 15px;
}

.modal-content--dialog:has(.score-explanation) {
  width: min(92vw, 650px);
}

/* ── 5. Toast ── */

.toast-notification {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: color-mix(in srgb, var(--color-toast) 82%, transparent);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 40px;
  border: 1px solid rgb(255 255 255 / 25%);
  font-size: 12px;
  z-index: 30000;
  box-shadow: 0 4px 15px rgb(15 23 42 / 18%), inset 0 1px 0 rgb(255 255 255 / 30%);
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.toast-notification.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-notification.show::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--color-gold);
  width: 100%;
  animation: toastProgress 4s linear forwards;
}

/* ── 6. Превью ── */

.preview-modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 12px;
  text-align: left;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

#modalOverlayPreview .modal-content {
  max-height: none;
  overflow: visible;
}

.preview-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-section + .preview-section {
  padding-top: 16px;
  border-top: 1px solid rgb(0 0 0 / 8%);
}

.preview-section-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-heading);
}

.preview-subtitle {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--color-text-muted);
}

.preview-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--color-panel);
  font-size: 15px;
}

.preview-payment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--color-panel);
  font-size: 14px;
}

.preview-payment-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-payment-amount {
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  font-weight: 700;
  color: var(--color-payment);
  white-space: nowrap;
}

.preview-empty {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-muted);
}

.preview-player {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-total {
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  font-weight: 600;
  min-width: 48px;
  text-align: right;
}

.preview-modal-note {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ── 7. Редактирование истории ── */

.edit-history-subtitle {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--color-text-muted);
}

.edit-history-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.edit-history-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--color-grid-head-round) 10%, rgb(255 255 255 / 58%));
  border-radius: 18px;
  background: var(--color-surface);
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    var(--elev-2),
    inset 0 1px 0 rgb(255 255 255 / 42%);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.edit-history-card__underlay {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(
      165deg,
      color-mix(in srgb, var(--color-grid-head-round) 38%, #8aa89a) 0%,
      color-mix(in srgb, var(--color-grid-head-round) 20%, transparent) 48%,
      rgb(255 255 255 / 28%) 100%
    ),
    url("../img/patterns/history-card-underlay.svg?v=9");
  background-size: auto, 175% auto;
  background-position: center, right 38%;
  background-repeat: no-repeat;
}

.edit-history-card--winner {
  border-color: color-mix(in srgb, var(--color-gold) 34%, var(--color-border));
  background: var(--color-surface);
  box-shadow:
    var(--elev-2),
    0 0 0 1px color-mix(in srgb, var(--color-gold) 16%, transparent),
    0 0 20px rgb(224 188 81 / 16%),
    inset 0 1px 0 rgb(255 255 255 / 48%);
}

.edit-history-card--winner .edit-history-card__underlay {
  background-image:
    linear-gradient(
      165deg,
      color-mix(in srgb, var(--color-gold) 34%, #c8b888) 0%,
      color-mix(in srgb, var(--color-gold) 18%, transparent) 48%,
      rgb(255 255 255 / 30%) 100%
    ),
    url("../img/patterns/history-card-underlay-winner.svg?v=12");
  background-size: auto, 175% auto;
  background-position: center, right 38%;
  background-repeat: no-repeat;
}

.edit-history-card > :not(.edit-history-card__underlay) {
  position: relative;
  z-index: 1;
}

.edit-history-card__head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 12px 12px 16px;
}

.edit-history-card__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  text-shadow:
    0 1px 2px rgb(0 0 0 / 55%),
    0 0 1px rgb(0 0 0 / 45%);
}

.edit-history-card__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 12px;
  background: var(--surface-glass);
  border: 1px solid var(--surface-glass-border);
  border-bottom: none;
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border-radius: 16px 16px 17px 17px;
  box-shadow: var(--surface-glass-shadow);
}

.edit-history-card__score,
.edit-history-card__preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.edit-history-card__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.35px;
  color: color-mix(in srgb, var(--color-text-muted) 82%, var(--color-heading));
}

.edit-history-card__score .number-input-wrapper--compact {
  width: 112px;
  flex-shrink: 0;
}

.edit-history-card__delta {
  min-width: 52px;
  padding: 4px 8px;
  border-radius: 30px;
  text-align: right;
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: 14px;
  font-weight: 700;
}

.edit-history-card__mahjong {
  margin-top: auto;
}

.edit-history-card__mahjong .round-card__mahjong-face {
  min-height: 40px;
  padding: 7px 10px 7px 38px;
}

.edit-history-card__mahjong .round-card__mahjong-copy {
  font-size: 12px;
  line-height: 1.15;
}

.edit-history-card .history-player-card__wind {
  font-size: 20px;
  min-width: 32px;
  padding: 3px 8px;
}

.edit-history-score {
  width: 100%;
  min-height: 38px;
  padding: 8px 48px 8px 10px;
}

.number-input-wrapper--compact .edit-history-score,
.number-input-wrapper--compact input[type="number"] {
  min-height: 38px;
}

/* ── 16. Объяснение счёта ── */

.modal-text:has(.score-explanation) {
  border-top: 5px solid var(--color-gold);
  border-left-color: transparent;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
}

.score-explanation {
  position: relative;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  font-size: 14px;
}

/* Шапка */
.score-explanation__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.score-explanation__head i {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 0;
  border-radius: 10px;
  background: color-mix(in srgb, var(--color-teal-accent) 14%, var(--color-panel));
  color: var(--color-teal-accent);
  font-size: 15px;
  flex-shrink: 0;
}

.score-explanation__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-heading);
}

/* Карточка победителя */
.score-winner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--color-gold) 36%, var(--color-border));
  box-shadow: var(--elev-1);
}

.score-winner__icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--color-gold) 24%, var(--color-panel));
  color: var(--color-gold);
  font-size: 14px;
  flex-shrink: 0;
}

.score-winner__icon i {
  margin: 0;
  width: auto;
  height: auto;
  font-size: 14px;
  line-height: 1;
  border-radius: 0;
  background: none;
  color: inherit;
  box-shadow: none;
  display: inline-block;
}

.score-winner__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.score-winner__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-text-muted);
}

.score-winner__name {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-winner__wind {
  margin-left: auto;
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

/* Секции */
.score-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.score-section__title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--color-text-muted);
}

.score-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Строка расчёта */
.score-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto minmax(46px, 46px);
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-section-shadow);
  box-shadow: var(--elev-1);
}

.score-row__players {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.score-row__player {
  font-weight: 600;
  color: var(--color-text);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-row__arrow,
.score-row__eq {
  color: var(--color-text-muted);
  font-size: 12px;
  flex-shrink: 0;
}

.score-row__formula {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--color-text-muted);
  white-space: nowrap;
  min-width: 0;
}

.score-row__chips {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.score-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-gold) 20%, var(--color-panel));
  border: 1px solid color-mix(in srgb, var(--color-gold) 44%, var(--color-border));
  color: var(--color-heading);
  font-size: 11px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.score-row__total {
  min-width: 42px;
  text-align: right;
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.score-row--income .score-row__total {
  color: var(--color-positive);
}

.score-row--transfer .score-row__total {
  color: var(--color-payment);
}

/* ── 18. @keyframes ── */

@keyframes modalContentIn {
  0% {
    opacity: 0;
    transform: scale(0.9) translateY(14px);
  }

  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes modalWindowIn {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

@keyframes modalChildIn {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalContentOut {
  0% {
    opacity: 1;
    transform: scale(1);
  }

  100% {
    opacity: 0;
    transform: scale(0.55);
  }
}

@keyframes modalWindowOut {
  0% {
    opacity: 1;
    scale: 1;
  }

  100% {
    opacity: 0;
    scale: 0.55;
  }
}

@keyframes modalChildOut {
  0% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

@keyframes toastProgress {
  from { width: 100%; }
  to { width: 0; }
}
