/* Базовый reset для всех элементов */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button,
.info-link-button,
a.back-button,
button.print-button {
  transition:
    transform 0.14s ease-out,
    box-shadow 0.14s ease-out,
    filter 0.14s ease-out,
    background-color 0.14s ease-out,
    color 0.14s ease-out;
  will-change: transform;
}

button:active,
.info-link-button:active,
a.back-button:active,
button.print-button:active {
  transform: translateY(1px) scale(0.98);
  filter: brightness(0.98);
}

/* Глобальные переменные дизайн-системы */
:root {
  /* Фон страницы: лавандовый градиент в духе бренда */
  --bg-main: radial-gradient(ellipse 110% 85% at 50% 0%, rgba(124, 58, 237, 0.22) 0%, transparent 52%),
    linear-gradient(165deg, #eef2ff 0%, #e9d5ff 45%, #ddd6fe 88%, #d4c4fc 100%);
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: rgba(255, 255, 255, 0.99);
  --text-main: #111827;
  --text-muted: #374151;
  --primary: #667eea;
  --focus-ring: 0 0 0 3px #fff, 0 0 0 5px #4f46e5;
  --radius-xl: 28px;
  --radius-lg: 20px;
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.14);
  --shadow-strong: 0 16px 48px rgba(0, 0, 0, 0.22);
  --space-md: 16px;
  --font-ui: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-title: "Manrope", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mode-accent-classic: #4c1d95;
  --mode-accent-rapid: #a21caf;
  --mode-accent-blitz: #0369a1;
}

/* Общий контейнер страниц */
body {
  font-family: var(--font-ui);
  background: var(--bg-main);
  background-color: #e4dcfa;
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.pawn-lane {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 98px;
  pointer-events: none;
  overflow: hidden;
  z-index: 9999;
  background: linear-gradient(180deg, #ffffff 0%, #f4f4f6 100%);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid rgba(0, 0, 0, 0.16);
}

.flying-pawn {
  position: absolute;
  left: -80px;
  top: 8px;
  width: 62px;
  height: 98px;
  transform-style: preserve-3d;
  animation-name: flyPawn;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
}

.flying-pawn::before {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
}

.pawn-white::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 220'%3E%3Cg stroke='%23000000' stroke-width='7' stroke-linejoin='round'%3E%3Ccircle cx='60' cy='40' r='36' fill='%23f1f1f1'/%3E%3Cpath d='M16 176H104C96 156 90 126 88 96C87 84 88 76 88 70H32C32 76 33 84 32 96C30 126 24 156 16 176Z' fill='%23f1f1f1'/%3E%3Crect x='16' y='176' width='88' height='24' rx='3' fill='%23ececec'/%3E%3C/g%3E%3C/svg%3E");
}

.pawn-black::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 220'%3E%3Cg stroke='%23000000' stroke-width='7' stroke-linejoin='round'%3E%3Ccircle cx='60' cy='40' r='36' fill='%23161616'/%3E%3Cpath d='M16 176H104C96 156 90 126 88 96C87 84 88 76 88 70H32C32 76 33 84 32 96C30 126 24 156 16 176Z' fill='%231f232b'/%3E%3Crect x='16' y='176' width='88' height='24' rx='3' fill='%23252b35'/%3E%3C/g%3E%3Cellipse cx='50' cy='30' rx='16' ry='13' fill='%23ffffff' fill-opacity='0.25'/%3E%3C/svg%3E");
}

/* Одна длительность + равномерные задержки — пешки равномерно по ширине, без длинных «дыр» */
.p1 { animation-duration: 31.5s; animation-delay: 0s; top: 16px; }
.p2 { animation-duration: 31.5s; animation-delay: -1.575s; top: 0; }
.p3 { animation-duration: 31.5s; animation-delay: -3.15s; top: 36px; }
.p4 { animation-duration: 31.5s; animation-delay: -4.725s; top: 8px; }
.p5 { animation-duration: 31.5s; animation-delay: -6.3s; top: 24px; }
.p6 { animation-duration: 31.5s; animation-delay: -7.875s; top: 2px; }
.p7 { animation-duration: 31.5s; animation-delay: -9.45s; top: 44px; }
.p8 { animation-duration: 31.5s; animation-delay: -11.025s; top: 28px; }
.p9 { animation-duration: 31.5s; animation-delay: -12.6s; top: 32px; }
.p10 { animation-duration: 31.5s; animation-delay: -14.175s; top: 6px; }
.p11 { animation-duration: 31.5s; animation-delay: -15.75s; top: 20px; }
.p12 { animation-duration: 31.5s; animation-delay: -17.325s; top: 12px; }
.p13 { animation-duration: 31.5s; animation-delay: -18.9s; top: 40px; }
.p14 { animation-duration: 31.5s; animation-delay: -20.475s; top: 4px; }
.p15 { animation-duration: 31.5s; animation-delay: -22.05s; top: 34px; }
.p16 { animation-duration: 31.5s; animation-delay: -23.625s; top: 18px; }
.p17 { animation-duration: 31.5s; animation-delay: -25.2s; top: 0; }
.p18 { animation-duration: 31.5s; animation-delay: -26.775s; top: 26px; }
.p19 { animation-duration: 31.5s; animation-delay: -28.35s; top: 10px; }
.p20 { animation-duration: 31.5s; animation-delay: -29.925s; top: 38px; }

@keyframes flyPawn {
  0% {
    transform: translateX(-110px) translateY(14px) rotate(0deg);
  }
  25% {
    transform: translateX(24vw) translateY(-6px) rotate(180deg);
  }
  50% {
    transform: translateX(50vw) translateY(16px) rotate(360deg);
  }
  75% {
    transform: translateX(76vw) translateY(-2px) rotate(540deg);
  }
  100% {
    transform: translateX(calc(100vw + 110px)) translateY(14px) rotate(720deg);
  }
}

.page {
  width: 100%;
  max-width: 1200px;
  padding: 60px 40px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-strong);
  backdrop-filter: blur(10px);
}

.title,
h1.title,
h2.title {
  font-family: var(--font-title);
  text-align: center;
  font-size: 40px;
  font-weight: 800;
  margin-bottom: 36px;
  letter-spacing: 0.02em;
  line-height: 1.2;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 44px;
}

.page-header .title {
  margin-bottom: 0;
  width: 100%;
  padding: 0 130px;
  min-width: 0;
}

.buttons-row {
  display: flex;
  justify-content: center;
  gap: 50px;
  flex-wrap: wrap;
}

/* Карточки выбора режима на главной */
.mode-button {
  min-width: 340px;
  min-height: 170px;
  padding: 28px 36px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.2),
    0 4px 8px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 30px;
  font-weight: 600;
  cursor: pointer;
  color: white;
  transition:
    transform 0.2s ease-out,
    box-shadow 0.2s ease-out,
    filter 0.2s ease-out;
  position: relative;
  overflow: hidden;
}

.mode-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  transition: opacity 0.2s ease-out;
  background: rgba(255, 255, 255, 0.2);
}

.mode-button:hover::before {
  opacity: 1;
}

.mode-button span {
  display: block;
  line-height: 1.15;
  position: relative;
  z-index: 1;
}

.mode-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.95);
}

.mode-icon svg {
  width: 40px;
  height: 40px;
  display: block;
}

.mode-meta {
  margin-top: 10px;
  font-size: 15px;
  opacity: 0.9;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* Карточки выбора режима: свой градиент под каждую дисциплину */
.mode-button[data-mode="classic"] {
  background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 55%, #9333ea 100%);
  border-left: 5px solid var(--mode-accent-classic);
}

.mode-button[data-mode="rapid"] {
  background: linear-gradient(135deg, #9d174d 0%, #c026d3 40%, #d946ef 100%);
  border-left: 5px solid var(--mode-accent-rapid);
}

.mode-button[data-mode="blitz"] {
  background: linear-gradient(135deg, #0c4a6e 0%, #0369a1 45%, #0284c7 100%);
  border-left: 5px solid var(--mode-accent-blitz);
}

.mode-button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.mode-button:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.3),
    0 8px 16px rgba(0, 0, 0, 0.2);
  filter: brightness(1.1);
}

.mode-button:active {
  transform: translateY(-2px) scale(0.98);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.25),
    0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Планшет / узкий ноутбук: плотнее, без «игрушечного» масштаба; крупные тап-таргеты остаются на 640px */
@media (max-width: 1100px) and (min-width: 641px) {
  .page {
    padding: 36px 28px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  }

  .title,
  h1.title,
  h2.title {
    font-size: 34px;
    margin-bottom: 28px;
  }

  .page-header {
    margin-bottom: 32px;
  }

  .page-header .title,
  .page-header h1.title {
    font-size: 30px;
  }

  .mode-button {
    min-width: 220px;
    min-height: 128px;
    padding: 20px 26px;
    font-size: 24px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
  }

  .mode-button:hover {
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  }

  .option-button {
    min-width: 120px;
    min-height: 58px;
    padding: 14px 18px;
    font-size: 18px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  }

  .form-label {
    font-size: 20px;
  }

  .calculate-button {
    min-height: 62px;
    font-size: 24px;
  }

  .back-button,
  .print-button {
    min-height: 50px;
    font-size: 18px;
  }
}

.text-muted-13,
.text-muted-13 a {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-muted);
  font-weight: 500;
}

@media (max-width: 768px) {
  .page {
    padding: 40px 20px;
    border-radius: 24px;
  }

  .title {
    font-size: 32px;
    margin-bottom: 40px;
  }

  .mode-button {
    min-width: 280px;
    min-height: 140px;
    font-size: 26px;
    padding: 24px 32px;
  }

  .buttons-row {
    gap: 30px;
  }
}

/* Форма расчёта разрядов */
.rank-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  max-width: 900px;
  margin: 0 auto;
}

/* Страницы калькулятора: плотнее по вертикали, карточка влезает на типичный экран */
body:has(#rankForm) {
  padding: 10px 12px;
}

/* body в ряд (узкий экран): верх по высоте, горизонталь как у всех — justify-content: center из базы */
@media (max-width: 1100px) {
  body:has(#rankForm) {
    align-items: flex-start;
  }
}

/* body в колонку (широкий экран + zoom): flex-start по главной оси = вверх, align center = по центру по ширине */
@media (min-width: 1101px) {
  body:has(#rankForm) {
    align-items: center;
    justify-content: flex-start;
  }
}

.page:has(#rankForm) {
  padding: 18px 16px 14px;
  border-radius: var(--radius-lg);
  max-height: calc(100vh - 20px);
  max-height: calc(100dvh - 20px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.page:has(#rankForm) .page-header {
  margin-bottom: 12px;
}

.page:has(#rankForm) .page-header .title,
.page:has(#rankForm) .page-header h1.title {
  font-size: clamp(1.05rem, 3.6vw, 1.6rem);
  padding: 0 88px;
  line-height: 1.2;
}

.page:has(#rankForm) .back-button {
  min-height: 40px;
  font-size: 14px;
  padding: 7px 11px;
}

.page:has(#rankForm) .rank-form,
.page:has(#rankForm) .form-section,
.page:has(#rankForm) #manualSection {
  gap: 10px;
}

.page:has(#rankForm) .buttons-row,
.page:has(#rankForm) .rank-form .buttons-row {
  gap: 10px;
}

.page:has(#rankForm) .form-label {
  font-size: 17px;
  margin-bottom: 2px;
}

.page:has(#rankForm) .step-badge {
  padding: 3px 8px;
  font-size: 12px;
}

.page:has(#rankForm) .option-button {
  min-width: 0;
  min-height: 50px;
  padding: 10px 12px;
  font-size: 16px;
  border-radius: 14px;
}

.page:has(#rankForm) #manualSection .form-section:nth-of-type(2) .buttons-row {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  max-width: 100%;
  gap: 8px;
}

.page:has(#rankForm) #manualSection > .form-section {
  padding: 12px;
  border-radius: 14px;
}

.page:has(#rankForm) #manualSection .form-label {
  margin-bottom: 8px;
}

.page:has(#rankForm) .input-mode-hint {
  font-size: 13px;
  line-height: 1.35;
  margin-bottom: 2px;
}

.page:has(#rankForm) .input-mode-switch {
  margin-top: 8px;
}

.page:has(#rankForm) .input-mode-button {
  min-height: 40px;
  padding: 8px 10px;
  font-size: 14px;
}

.page:has(#rankForm) .autofill-section {
  padding: 12px;
  max-width: 100%;
}

.page:has(#rankForm) .rating-input {
  padding: 11px 16px;
  font-size: 18px;
  border-radius: 14px;
  border-width: 2px;
}

.page:has(#rankForm) .field-hint {
  margin-top: 6px;
  font-size: 13px;
}

.page:has(#rankForm) .calculate-button {
  min-height: 50px;
  padding: 12px 18px;
  font-size: 18px;
  border-radius: 16px;
  margin-top: 8px;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

#manualSection {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.form-label {
  font-size: 22px;
  font-weight: 600;
  color: #374151;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  text-align: center;
  margin-bottom: 4px;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4f46e5;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.option-button {
  min-width: 150px;
  min-height: 74px;
  padding: 18px 24px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.15),
    0 2px 6px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
  color: white;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  transition:
    transform 0.2s ease-out,
    box-shadow 0.2s ease-out,
    border-color 0.2s ease-out,
    filter 0.2s ease-out;
  position: relative;
  overflow: hidden;
}

.rank-form .buttons-row {
  gap: var(--space-md);
  max-width: 980px;
  margin: 0 auto;
  align-items: center;
}

#manualSection .form-section:nth-of-type(2) .buttons-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  width: 100%;
  max-width: 860px;
}

#manualSection > .form-section {
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  padding: var(--space-md);
}

#manualSection > .form-section + .form-section {
  margin-top: 0;
}

#manualSection .form-label {
  margin-bottom: var(--space-md);
}

#manualSection .buttons-row {
  margin-top: 0;
}

.form-message {
  display: none;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
}

.form-message-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.autofill-section {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid #dbeafe;
  border-radius: 16px;
  padding: var(--space-md);
  max-width: 760px;
  margin: 0 auto;
  gap: var(--space-md);
}

.autofill-section .form-label {
  margin-bottom: var(--space-md);
}

.autofill-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.autofill-gender-block {
  margin-top: var(--space-md);
  text-align: center;
}

.autofill-gender-label {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 10px;
}

.autofill-gender-row {
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.autofill-helper {
  margin-top: 2px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-muted);
  text-align: center;
}

.autofill-helper .autofill-info-link {
  color: #4f46e5;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(79, 70, 229, 0.35);
}

.autofill-helper .autofill-info-link:hover {
  border-bottom-color: #4f46e5;
}

.autofill-status-main {
  display: block;
  font-weight: 700;
}

.autofill-status-detail {
  display: block;
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.45;
  font-weight: 500;
  opacity: 0.95;
}

#tournamentUrl {
  grid-column: 1 / -1;
}

.autofill-input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid #e5e7eb;
  font-size: 15px;
  background: white;
}

.autofill-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.18);
}

.autofill-button {
  margin-top: var(--space-md);
  width: auto;
  align-self: center;
  min-width: 300px;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
  color: white;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.autofill-status {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  margin-top: var(--space-md);
}

.autofill-status-loading {
  background: #eef2ff;
  color: #3730a3;
}

.autofill-status-ok {
  background: #dcfce7;
  color: #166534;
}

.autofill-status-error {
  background: #fee2e2;
  color: #991b1b;
}

.autofill-status-warn {
  background: #fef3c7;
  color: #92400e;
}

.input-mode-hint {
  text-align: center;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 0 auto 4px;
  max-width: 36rem;
}

.field-hint {
  text-align: center;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-muted);
  margin: 10px auto 0;
  max-width: 28rem;
}

.input-mode-switch {
  display: inline-flex;
  margin: var(--space-md) auto 0;
  padding: 4px;
  border-radius: 14px;
  background: #e0e7ff;
  border: 1px solid #c7d2fe;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.65);
  gap: 4px;
  flex-wrap: wrap;
  justify-content: stretch;
  width: 100%;
  max-width: min(560px, 100%);
}

.input-mode-button {
  flex: 1 1 calc(33.333% - 4px);
  min-width: min(140px, 100%);
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: #4338ca;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s ease-out, color 0.2s ease-out, box-shadow 0.2s ease-out;
}

.input-mode-button.selected {
  background: #fff;
  color: #312e81;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.18);
}

.input-mode-button:hover:not(.selected) {
  color: #1e1b4b;
}

.input-mode-button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  z-index: 1;
}

.input-mode-forecast-btn {
  flex: 1 1 calc(33.333% - 4px);
}

/* Прогноз разряда — в потоке страницы (как автозаполнение) */
#forecastSection .autofill-grid .forecast-tournament-url-input {
  grid-column: 1 / -1;
}

#forecastSection .forecast-inline-rounds-input {
  width: 100%;
  max-width: 100%;
}

.forecast-inline-results {
  margin-top: 14px;
}

.forecast-rank-result-section .tournament-ranks-table-scroll {
  width: 100%;
  max-height: min(52vh, 480px);
  margin-top: 8px;
}

.forecast-rank-opt {
  font-weight: 500;
  color: var(--text-muted);
}

.forecast-rank-summary {
  font-size: 15px;
  line-height: 1.5;
  margin: 0 0 12px;
}

.forecast-rank-th-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.forecast-rank-th-sub {
  font-weight: 500;
  font-size: 12px;
  color: var(--text-muted);
}

.forecast-rank-table td:last-child {
  white-space: normal;
  max-width: none;
}

@media (max-width: 520px) {
  .input-mode-button {
    flex: 1 1 calc(50% - 4px);
  }

  .input-mode-forecast-btn {
    flex: 1 1 100%;
  }
}

.option-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  transition: opacity 0.2s ease-out;
  background: rgba(255, 255, 255, 0.2);
}

.option-button:hover::before {
  opacity: 1;
}

.option-button span {
  display: block;
  position: relative;
  z-index: 1;
}

.option-button:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.2),
    0 4px 8px rgba(0, 0, 0, 0.15);
  filter: brightness(1.1);
}

.option-button:active {
  transform: translateY(-1px) scale(0.98);
}

.option-button.selected {
  border-color: rgba(255, 255, 255, 0.85);
  box-shadow:
    0 0 0 3px rgba(102, 126, 234, 0.22),
    0 8px 24px rgba(0, 0, 0, 0.2),
    0 2px 6px rgba(0, 0, 0, 0.15);
  filter: brightness(1.15);
}

.option-button.selected::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 10px;
  height: 6px;
  border-left: 2px solid rgba(255, 255, 255, 0.95);
  border-bottom: 2px solid rgba(255, 255, 255, 0.95);
  transform: rotate(-45deg);
  z-index: 2;
  animation: checkIn 0.22s ease-out;
}

@keyframes checkIn {
  from {
    opacity: 0;
    transform: scale(0.6) translateY(-2px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.rating-input {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: 16px 22px;
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  border: 3px solid #e5e7eb;
  border-radius: 20px;
  background: white;
  color: #111827;
  transition:
    border-color 0.2s ease-out,
    box-shadow 0.2s ease-out,
    transform 0.2s ease-out;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.rating-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow:
    0 0 0 4px rgba(102, 126, 234, 0.2),
    0 8px 24px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

.rating-input::placeholder {
  color: #9ca3af;
  font-weight: 400;
}

.calculate-button {
  width: 100%;
  max-width: 500px;
  margin: var(--space-md) auto 0;
  min-height: 74px;
  padding: 20px 32px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.2),
    0 4px 8px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  cursor: pointer;
  color: white;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  transition:
    transform 0.2s ease-out,
    box-shadow 0.2s ease-out,
    filter 0.2s ease-out;
  position: relative;
  overflow: hidden;
}

.calculate-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.08);
  transform: none;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
}

.calculate-button:disabled:hover {
  transform: none;
  filter: grayscale(0.08);
}

.calculate-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  transition: opacity 0.2s ease-out;
  background: rgba(255, 255, 255, 0.2);
}

.calculate-button:hover::before {
  opacity: 1;
}

.calculate-button span {
  display: block;
  position: relative;
  z-index: 1;
}

.calculate-button:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.3),
    0 8px 16px rgba(0, 0, 0, 0.2);
  filter: brightness(1.1);
}

.calculate-button:not(:disabled):hover {
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.28),
    0 8px 16px rgba(0, 0, 0, 0.2),
    0 0 0 3px rgba(124, 58, 237, 0.2);
}

.calculate-button:active {
  transform: translateY(-2px) scale(0.98);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.25),
    0 2px 4px rgba(0, 0, 0, 0.2);
}

.back-button {
  width: auto;
  max-width: none;
  margin: 0;
  min-height: 56px;
  flex-shrink: 0;
  padding: 14px 24px;
  border-radius: 20px;
  border: 2px solid #667eea;
  background: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  color: #667eea;
  text-decoration: none;
  transition:
    transform 0.2s ease-out,
    box-shadow 0.2s ease-out,
    background-color 0.2s ease-out,
    color 0.2s ease-out;
}

.page-header .back-button {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

.back-button span {
  display: block;
}

.back-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  background-color: #667eea;
  color: white;
}

.back-button:active {
  transform: translateY(-1px);
}

@media (max-width: 640px) {
  .pawn-lane {
    display: none;
  }

  .flying-pawn {
    width: 40px;
    height: 76px;
  }

  body {
    padding: 10px;
  }

  .page {
    padding: 30px 15px;
  }

  .title {
    font-size: 28px;
    margin-bottom: 32px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 24px;
  }

  .page-header .title {
    margin-bottom: 0;
    padding: 0;
  }

  .page-header .back-button {
    position: static;
    transform: none;
  }

  .mode-button {
    min-width: 240px;
    min-height: 120px;
    font-size: 22px;
    padding: 20px 28px;
  }

  .buttons-row {
    gap: 20px;
  }

  .rank-form {
    gap: var(--space-md);
  }

  .rank-form .buttons-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-md);
  }

  #manualSection > .form-section {
    padding: var(--space-md);
    border-radius: 14px;
  }

  /* 5 кнопок: сетка 2 + 2 + 1 (центр), без «ломаной» тройки 3+2 */
  #manualSection .form-section:nth-of-type(2) .buttons-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: none;
  }

  #manualSection .form-section:nth-of-type(2) .buttons-row .option-button:nth-child(5) {
    grid-column: 1 / -1;
    justify-self: center;
    width: 50%;
    min-width: 0;
  }

  .autofill-grid {
    grid-template-columns: 1fr;
  }

  #tournamentUrl {
    grid-column: auto;
  }

  .autofill-button {
    width: 100%;
    min-width: 0;
  }

  .form-label {
    font-size: 21px;
    margin-bottom: 2px;
  }

  .option-button {
    width: 100%;
    min-width: 0;
    min-height: 70px;
    font-size: 18px;
    padding: 16px 24px;
  }

  .rating-input {
    font-size: 20px;
    padding: 18px 20px;
  }

  .calculate-button {
    min-height: 70px;
    font-size: 24px;
    padding: 20px 32px;
  }

  .back-button {
    min-height: 52px;
    font-size: 18px;
    padding: 12px 20px;
    justify-content: flex-start;
  }

  .results-modal {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }

  .results-panel {
    width: 100%;
    max-width: none;
    max-height: min(100dvh, 100vh);
    min-height: 0;
    border-radius: 0;
  }

  .results-header {
    padding: 10px 12px;
    border-radius: 0;
  }

  .results-header .results-title {
    font-size: clamp(0.95rem, 4vw, 1.25rem);
  }

  .results-close {
    width: 38px;
    height: 38px;
    font-size: 24px;
  }

  .results-back {
    min-height: 38px;
    font-size: 14px;
    padding: 6px 10px;
  }

  .results-container {
    padding: 16px;
  }

  .results-sticky-head {
    margin: 0 0 14px;
    padding: 0 0 12px;
  }

  .criterion-card {
    padding: 16px;
  }
}

/* Стили для результатов расчёта: прокрутка внутри карточки, шапка с кнопками закреплена */
.results-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  overflow: hidden;
  overscroll-behavior: contain;
  background: rgba(17, 24, 39, 0.58);
}

.results-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 0 1 auto;
  width: min(1120px, 96vw);
  max-height: min(90vh, 860px);
  min-height: 0;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.results-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: rgba(255, 255, 255, 0.98);
}

.results-header .results-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: clamp(1.05rem, 2.2vw, 1.5rem);
  font-weight: 700;
  text-align: center;
  line-height: 1.25;
  color: #374151;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.results-close {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 2px solid #d1d5db;
  background: white;
  color: #374151;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s ease-out, transform 0.2s ease-out;
}

.results-close:hover {
  background-color: #eef2ff;
  transform: scale(1.03);
}

.results-back {
  flex-shrink: 0;
  min-height: 42px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 2px solid #667eea;
  background: white;
  color: #4f46e5;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease-out, background-color 0.2s ease-out, color 0.2s ease-out;
}

.results-back:hover {
  transform: translateY(-1px);
  background-color: #667eea;
  color: white;
}

.results-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #64748b #e2e8f0;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 0 0 20px 20px;
  padding: 20px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.results-container::-webkit-scrollbar {
  width: 12px;
}

.results-container::-webkit-scrollbar-track {
  background: rgba(226, 232, 240, 0.9);
  border-radius: 0 0 20px 0;
}

.results-container::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 8px;
  border: 3px solid rgba(226, 232, 240, 0.9);
}

.results-container::-webkit-scrollbar-thumb:hover {
  background: #cbd5e1;
}

.results-sticky-head {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 0 18px;
  padding: 0 0 12px;
  border-bottom: 1px solid #e5e7eb;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(6px);
}

.results-sticky-head .recommended-rank-card--hero {
  margin-bottom: 0;
}

@media (max-width: 520px) {
  .results-modal {
    padding: 0;
  }

  .results-panel {
    width: 100vw;
    max-width: none;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .results-header {
    border-radius: 0;
  }

  .results-container {
    border-radius: 0;
  }

  .results-container::-webkit-scrollbar-track {
    border-radius: 0;
  }
}

.params-info {
  background: white;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.rank-theme-kms {
  border-left-color: #7c3aed;
}

.rank-theme-first {
  border-left-color: #2563eb;
}

.rank-theme-second {
  border-left-color: #0891b2;
}

.rank-theme-third {
  border-left-color: #059669;
}

.rank-theme-youth {
  border-left-color: #d97706;
}

.params-info p {
  font-size: 18px;
  margin: 8px 0;
  color: #374151;
}

.params-info strong {
  color: #667eea;
  font-weight: 600;
}

.params-info--secondary {
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 0.95em;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.params-info--secondary p {
  font-size: 16px;
  margin: 4px 0;
}

.criteria-details-block {
  margin-top: 8px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #fafafa;
  padding: 0 4px 8px;
}

.criteria-details-summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-size: 17px;
  font-weight: 700;
  color: #4c1d95;
  border-radius: 12px 12px 0 0;
}

.criteria-details-summary::-webkit-details-marker {
  display: none;
}

.criteria-details-block[open] .criteria-details-summary {
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 8px;
}

.criteria-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.criteria-group-title {
  margin: 8px 0 4px;
  font-size: 18px;
  font-weight: 800;
  color: #4338ca;
}

.criteria-group-title-adult {
  color: #4338ca;
}

.criteria-group-title-adult::before {
  content: "";
  display: inline-block;
  width: 0.4em;
  height: 0.4em;
  margin-right: 0.4em;
  border-radius: 2px;
  background: #4338ca;
  vertical-align: 0.15em;
}

.criteria-group-title-youth {
  color: #6b7280;
  font-weight: 700;
  margin-top: 14px;
}

.criteria-group-title-youth::before {
  content: "";
  display: inline-block;
  width: 0.3em;
  height: 0.3em;
  margin-right: 0.45em;
  border-radius: 50%;
  background: #9ca3af;
  vertical-align: 0.15em;
}

.recommended-rank-card {
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 8px;
  border: 1px solid #c7d2fe;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(124, 58, 237, 0.1) 100%);
}

.recommended-rank-card--hero {
  padding: 24px 22px;
  margin: 0 0 20px;
  border-width: 2px;
  border-color: #818cf8;
  background: linear-gradient(145deg, #eef2ff 0%, #e0e7ff 45%, #f5f3ff 100%);
  box-shadow: 0 8px 28px rgba(67, 56, 202, 0.18);
}

.recommended-rank-card--hero .recommended-rank-title {
  font-size: 1.5rem;
  line-height: 1.25;
}

.recommended-rank-card--hero .recommended-rank-subtitle {
  font-size: 16px;
  color: #374151;
}

.recommended-rank-title {
  font-size: 18px;
  font-weight: 800;
  color: #4338ca;
}

.recommended-rank-subtitle {
  margin-top: 6px;
  font-size: 14px;
  color: #4b5563;
}

.criterion-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-left: 4px solid #667eea;
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
  animation: cardIn 0.35s ease-out both;
}

.criterion-card--compact {
  padding: 16px 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.criterion-card--compact .criterion-rank {
  font-size: 1.1rem;
}

.criterion-status-text {
  font-weight: 600;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.criterion-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.criterion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.criterion-rank {
  font-size: 24px;
  font-weight: 700;
  color: #667eea;
  margin: 0;
}

.criterion-status {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.criterion-status.met {
  background: #d1fae5;
  color: #065f46;
}

.criterion-status.not-met {
  background: #fee2e2;
  color: #991b1b;
}

.criterion-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.criterion-details p {
  margin: 0;
  font-size: 16px;
  color: #4b5563;
  line-height: 1.6;
}

.criterion-details strong {
  color: #374151;
  font-weight: 600;
}

.criterion-points,
.criterion-rating {
  padding: 8px 0;
}

.criterion-rating .met {
  color: #065f46;
  font-weight: 600;
}

.criterion-rating .not-met {
  color: #991b1b;
  font-weight: 600;
}

.criterion-description {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
  font-style: italic;
  color: #6b7280;
}

.info-link-wrap {
  margin-top: 36px;
  display: flex;
  justify-content: center;
}

.info-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  padding: 14px 28px;
  border-radius: 16px;
  border: 2px solid #667eea;
  background: white;
  color: #4f46e5;
  text-decoration: none;
  font-size: 20px;
  font-weight: 600;
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out, background-color 0.2s ease-out, color 0.2s ease-out;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.info-link-button:hover {
  transform: translateY(-2px);
  background-color: #667eea;
  color: white;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.site-footer {
  width: 100%;
  max-width: 1200px;
  margin: 24px auto 32px;
  padding: 0 24px;
}

.site-footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 28px;
}

.site-footer-link {
  color: #4f46e5;
  text-decoration: none;
  font-size: 16px;
  font-weight: 600;
  transition: color 0.2s ease-out;
}

.site-footer-link:hover {
  color: #4338ca;
  text-decoration: underline;
}

.site-footer-link--active {
  color: #312e81;
  text-decoration: underline;
}

.info-page {
  max-width: 980px;
}

.info-card {
  background: white;
  border-radius: 18px;
  padding: 24px 26px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  margin-bottom: 20px;
}

.info-card h2 {
  margin-bottom: 12px;
  color: #374151;
  font-size: 26px;
}

.info-card p {
  color: #4b5563;
  font-size: 18px;
  line-height: 1.55;
}

.source-link {
  color: #4f46e5;
  font-weight: 700;
  text-decoration: none;
}

.source-link:hover {
  text-decoration: underline;
}

.info-list {
  margin: 0;
  padding-left: 22px;
  color: #4b5563;
  font-size: 18px;
  line-height: 1.6;
}

.info-list li + li {
  margin-top: 8px;
}

/* Страница «Как вычисляются разряды»: заголовок и строка действий */
.info-page-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  margin-bottom: 28px;
}

.info-page-header .title {
  padding: 0;
  width: 100%;
  margin-bottom: 0;
}

.info-page-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.info-page .page-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px 16px;
}

.info-page .page-header .back-button {
  position: static;
  transform: none;
}

.info-page .page-header .title {
  padding: 0;
  min-width: 0;
}

.print-button {
  width: auto;
  max-width: none;
  margin: 0;
  min-height: 56px;
  flex-shrink: 0;
  padding: 14px 24px;
  border-radius: 20px;
  border: 2px solid #667eea;
  background: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  color: #667eea;
  text-decoration: none;
}

.print-button span {
  display: block;
}

.print-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  background-color: #667eea;
  color: white;
}

.print-button:active {
  transform: translateY(-1px);
}

.mini-faq .faq-item + .faq-item {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #e5e7eb;
}

.faq-q {
  font-size: 19px;
  font-weight: 700;
  color: #374151;
  margin-bottom: 8px;
  line-height: 1.35;
}

.faq-a {
  font-size: 17px;
  line-height: 1.55;
  color: #4b5563;
  margin: 0;
}

@media (max-width: 640px) {
  .info-page-header-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .info-page-header-actions .back-button,
  .info-page-header-actions .print-button {
    width: 100%;
    justify-content: center;
  }

  .print-button {
    min-height: 52px;
    font-size: 18px;
    padding: 12px 20px;
    justify-content: center;
  }
}

@media print {
  body {
    background: #fff !important;
    padding: 12mm;
    display: block;
  }

  .pawn-lane {
    display: none !important;
  }

  .info-page .back-button,
  .info-page .print-button,
  .info-page-header-actions {
    display: none !important;
  }

  .info-page .page-header {
    display: block;
    margin-bottom: 20px;
  }

  .info-page .title {
    -webkit-text-fill-color: #111827 !important;
    color: #111827 !important;
    background: none !important;
    padding: 0 !important;
    text-align: center;
  }

  .info-card {
    box-shadow: none !important;
    border: 1px solid #d1d5db;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .source-link {
    color: #1e3a8a;
    text-decoration: underline;
  }
}

/* Кнопка «Турнирная таблица разрядов» в шапке результатов */
.tournament-ranks-button-wrap {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.tournament-ranks-open-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  color: #4c1d95;
  background: linear-gradient(135deg, #f0e7ff 0%, #e9d5ff 100%);
  border: 1px solid rgba(124, 58, 237, 0.35);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(91, 33, 182, 0.12);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.tournament-ranks-open-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(91, 33, 182, 0.2);
  background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
}

.tournament-ranks-open-btn:active {
  transform: translateY(0);
}

/* Модалка: турнирная таблица разрядов */
.tournament-ranks-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.tournament-ranks-dialog {
  width: min(94vw, 1000px);
  max-height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
  background: #faf5ff;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(124, 58, 237, 0.2);
  overflow: hidden;
}

.tournament-ranks-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  color: #fff;
}

.tournament-ranks-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
}

.tournament-ranks-close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.tournament-ranks-close:hover {
  background: rgba(255, 255, 255, 0.35);
}

.tournament-ranks-body {
  padding: 16px 18px 20px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.tournament-ranks-hint {
  margin: 0 0 12px;
  font-size: 0.95rem;
  color: #4b5563;
  line-height: 1.45;
}

.tournament-ranks-hint strong {
  color: #1f2937;
}

.tournament-ranks-warn {
  margin: 0 0 12px;
  padding: 10px 12px;
  font-size: 0.9rem;
  line-height: 1.45;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
}

.tournament-ranks-warn strong {
  color: #78350f;
}

.tournament-ranks-table-wrap {
  min-width: 0;
}

.tournament-ranks-table-scroll {
  max-height: min(52vh, 480px);
  overflow: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #e9d5ff;
  border-radius: 10px;
  background: #fff;
}

.tournament-ranks-scroll-hint {
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.tournament-ranks-th-fio,
.tournament-ranks-td-fio {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  box-shadow: 1px 0 0 #e9d5ff;
  max-width: min(22rem, 40vw);
  min-width: 9rem;
  word-break: break-word;
}

.tournament-ranks-table thead th.tournament-ranks-th-fio {
  z-index: 3;
  background: #f3e8ff;
}

.tournament-ranks-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.tournament-ranks-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3e8ff;
  color: #4c1d95;
  text-align: left;
  padding: 10px 12px;
  font-weight: 700;
  border-bottom: 2px solid #d8b4fe;
  white-space: nowrap;
}

.tournament-ranks-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid #f3e8ff;
  color: #374151;
  vertical-align: top;
}

.tournament-ranks-table tbody tr:hover td {
  background: #faf5ff;
}

.tournament-ranks-table tbody tr:hover .tournament-ranks-td-fio {
  background: #faf5ff;
}

.tournament-ranks-loading,
.tournament-ranks-err {
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
  color: #4b5563;
}

.tournament-ranks-err {
  color: #b91c1c;
}

@media (max-width: 640px) {
  .tournament-ranks-title {
    font-size: 1.05rem;
  }

  .tournament-ranks-table {
    font-size: 0.85rem;
  }

  .tournament-ranks-table thead th,
  .tournament-ranks-table tbody td {
    padding: 8px 10px;
  }
}

.option-button:focus-visible,
.calculate-button:focus-visible,
.back-button:focus-visible,
.print-button:focus-visible,
.tournament-ranks-open-btn:focus-visible,
.autofill-button:focus-visible,
.results-close:focus-visible,
.results-back:focus-visible,
.tournament-ranks-close:focus-visible,
.info-link-button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .pawn-lane {
    display: none;
  }
}

/**
 * Интерфейс в 1.5× только на широких экранах (ПК / большие ноутбуки).
 *
 * Zoom на body ломает flex-центрирование внутри него (карточка «уезжает вниз»).
 * Центрируем через html (без zoom), body без полной высоты — по высоте контента.
 */
@media (min-width: 1101px) {
  html {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  body {
    zoom: 1.5;
    box-sizing: border-box;
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }

  /* index.html: контент ниже полоски с пешками */
  body:has(> .pawn-lane) {
    align-self: stretch;
    justify-content: flex-start;
    align-items: center;
    padding-top: calc(98px + 20px);
    padding-bottom: 20px;
  }

  /* Анимация пешек: обратный масштаб к zoom body (1/1.5) */
  .pawn-lane {
    zoom: 0.66666667;
  }

  /*
   * Турнирная таблица и «Прогноз разряда» рендерятся на <html> (вне body с zoom),
   * по умолчанию выглядят мельче основной страницы — выравниваем масштаб ×1.5.
   */
  .tournament-ranks-overlay .tournament-ranks-dialog {
    zoom: 1.5;
  }
}

