/* Найди пару: дроби — тёмный премиум (финтех / золотой акцент) */
:root {
  /* База (продуктовая палитра) */
  --bg-main: #0f1115;
  --bg-secondary: #151821;
  --card-bg: rgba(255, 255, 255, 0.04);
  --text-main: #f5f7fb;
  --text-secondary: #9aa3b2;
  --accent-main: #c9a96e;
  --accent-soft: #e7d3a7;
  --success: #4ade80;
  --error: #fb7185;

  /* Алиасы для существующих правил */
  --bg: var(--bg-main);
  --card: var(--card-bg);
  --bg-elevated: var(--bg-secondary);
  --text: var(--text-main);
  --text-muted: var(--text-secondary);
  --primary: var(--accent-main);
  --accent: var(--accent-soft);
  --accent-2: var(--accent-main);
  --ring: rgba(201, 169, 110, 0.4);
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  --shadow-hover: 0 20px 56px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 10px 40px rgba(0, 0, 0, 0.35);
  --glow-gold: 0 10px 40px rgba(201, 169, 110, 0.2);
  --gradient-primary: linear-gradient(135deg, #c9a96e, #e7d3a7);
  --gradient-surface: linear-gradient(160deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);

  --radius: 20px;
  --radius-sm: 16px;
  --btn-radius: 14px;
  --font: "DM Sans", system-ui, sans-serif;
  --max-w: 960px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-tap-highlight-color: transparent;
  min-height: 100%;
  min-height: -webkit-fill-available;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  font-family: var(--font);
  color: var(--text-main);
  background: radial-gradient(circle at 20% 30%, rgba(201, 169, 110, 0.08), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.05), transparent 40%),
    #0f1115;
  line-height: 1.5;
  overflow-x: hidden;
  box-sizing: border-box;
}

.app {
  min-height: min(100dvh, 100%);
  min-height: -webkit-fill-available;
  width: 100%;
  max-width: 100vw;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* Экраны: на весь вьюпорт, с учётом чёлок и home indicator */
.screen {
  flex: 1;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: 100svh;
  padding: max(0.75rem, env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px))
    max(0.75rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
  display: flex;
  align-items: center;
  justify-content: center;
  animation: screenIn 0.45s ease;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

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

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

.screen__inner {
  width: 100%;
  max-width: var(--max-w);
}

.start-screen,
.intro-screen,
.screen--round-end .screen__inner,
.screen--victory .screen__inner,
.screen--encourage .screen__inner {
  background: var(--gradient-surface);
  background-color: rgba(21, 24, 33, 0.85);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  padding: 2rem 1.75rem 2.25rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.screen--round-end,
.screen--victory {
  position: relative;
  overflow: hidden;
}

.fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  display: block;
}

.screen__inner--fx {
  position: relative;
  z-index: 1;
}

.screen--encourage .encourage-emoji {
  font-size: 2.5rem;
  margin: 0 0 0.5rem;
  text-align: center;
  line-height: 1;
  opacity: 0.8;
}

.screen--encourage .encourage-text {
  font-size: 1.1rem;
  color: var(--text);
  margin: 0 0 0.5rem;
  line-height: 1.4;
  font-weight: 500;
}

.screen--encourage .encourage-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 1.4rem;
  line-height: 1.45;
}

.btn--block {
  width: 100%;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.title {
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 700;
  margin: 0 0 0.75rem;
  line-height: 1.2;
  color: var(--text);
  letter-spacing: -0.02em;
}

.title--h2 {
  font-size: clamp(1.35rem, 3.5vw, 1.75rem);
  margin-bottom: 0.5rem;
}

.lead {
  color: var(--text-muted);
  font-size: 1rem;
  margin: 0 0 1.5rem;
  max-width: 38ch;
}

/* Продуктовый главный экран */
.start-screen--product {
  text-align: center;
}

.start-screen--product .product-badge {
  display: inline-block;
  margin: 0 0 1rem;
  padding: 0.35rem 0.9rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-soft);
  background: rgba(201, 169, 110, 0.08);
  border: 1px solid rgba(201, 169, 110, 0.22);
  border-radius: 999px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.25);
}

.start-screen--product .title--display {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.12;
  margin-bottom: 0.85rem;
  background: linear-gradient(120deg, #f5f7fb 0%, var(--accent-soft) 55%, var(--accent-main) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  max-width: 22ch;
  margin-left: auto;
  margin-right: auto;
}

.start-screen--product .lead--tight {
  max-width: 32ch;
  margin-left: auto;
  margin-right: auto;
  font-size: 1.02rem;
  line-height: 1.55;
  margin-bottom: 1.75rem;
}

.start-screen--product .start-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.start-screen--product .btn--hero {
  min-height: 48px;
  padding: 0.8rem 2rem;
  font-size: 1.02rem;
  box-shadow: 0 8px 32px rgba(201, 169, 110, 0.25);
}

.start-screen--product .start-trigger {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  max-width: 32ch;
  line-height: 1.4;
}

.info-card--premium {
  margin-top: 1.75rem;
  text-align: left;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem 1.5rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.info-card--premium .info-card__h {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 0.9rem;
  letter-spacing: -0.02em;
}

.info-card--premium .info-card__list {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.55;
  padding-left: 1.1rem;
}

.info-card--premium .info-card__list li {
  margin: 0.5rem 0;
  color: var(--text-secondary);
}

@media (max-width: 520px) {
  .screen--start {
    padding: 1rem 1rem 1.5rem;
  }

  .start-screen--product .title--display {
    max-width: 100%;
  }

  .start-screen--product .lead--tight {
    max-width: 100%;
  }

  .info-card--premium {
    padding: 1.15rem 1.2rem 1.25rem;
  }
}

/* Кнопки */
.btn,
.button {
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--btn-radius);
  padding: 0.7rem 1.35rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
  min-height: 44px;
  touch-action: manipulation;
}

.btn:disabled,
.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn--primary,
.button {
  background: linear-gradient(135deg, #c9a96e, #e7d3a7);
  color: #0f1115;
  box-shadow: 0 6px 24px rgba(201, 169, 110, 0.28);
}

.btn--primary:hover:not(:disabled),
.button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 36px rgba(201, 169, 110, 0.35);
}

.btn--primary:active:not(:disabled),
.button:active:not(:disabled) {
  transform: scale(0.97);
}

.btn--secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--btn-radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.btn--secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(201, 169, 110, 0.25);
  transform: translateY(-1px);
}

.btn--secondary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--btn-radius);
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  min-height: 40px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.25);
}

.btn--ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-main);
  border-color: rgba(201, 169, 110, 0.35);
  transform: translateY(-1px);
}

.info-card {
  margin-top: 2rem;
  padding: 1.25rem 1.35rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.info-card h2 {
  font-size: 0.95rem;
  margin: 0 0 0.75rem;
  font-weight: 600;
  color: var(--accent-main);
}

.info-card ul {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.info-card li {
  margin: 0.35rem 0;
  line-height: 1.6;
}

/* Intro: бейдж, заголовок, описание, правила — по центру */
.round-badge {
  display: inline-block;
  background: rgba(201, 169, 110, 0.1);
  color: var(--accent-soft);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  margin: 0 0 0.75rem;
  border: 1px solid rgba(201, 169, 110, 0.25);
}

.screen--intro {
  text-align: center;
}

.screen--intro .intro-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
}

.screen--intro .round-badge,
.screen--intro .title--h2,
.screen--intro #introTitle {
  text-align: center;
}

.screen--intro .title--h2,
.screen--intro #introTitle {
  width: 100%;
}

.intro-desc {
  color: var(--text-muted);
  margin: 0 0 1rem;
  font-size: 0.95rem;
  line-height: 1.6;
}

.screen--intro .intro-desc {
  text-align: center;
  max-width: 40ch;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.rule-box {
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 0.75rem;
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.08);
  white-space: pre-wrap;
  word-wrap: break-word;
  text-align: center;
}

.screen--intro .rule-box,
.screen--intro #introRules {
  text-align: center;
  max-width: min(100%, 40rem);
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 1.5rem;
  line-height: 1.6;
}

.screen--intro .hint,
.screen--intro #introHint {
  text-align: center;
  max-width: 38ch;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

/* Верх панель (игра: только счётчики + название уровня) */
.top-bar {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex: 1;
  align-items: stretch;
}

.screen--play .stats {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  justify-content: center;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.stat-pill {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  background: rgba(15, 17, 21, 0.6);
  border-radius: 14px;
  padding: 0.4rem 0.65rem 0.5rem;
  min-width: 3.2rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-pill__label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-pill__val {
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.round-title-wrap {
  text-align: center;
  margin: 0.25rem 0;
}

.round-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0;
}

.top-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.play-bottom__actions {
  gap: 0.65rem;
}

/* Прогресс */
.progress {
  max-width: 1000px;
  margin: 0.35rem auto 0;
  padding: 0 0.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.play-top .progress {
  margin-bottom: 0.15rem;
}

.progress-rail {
  height: 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 10px;
  background: linear-gradient(135deg, #c9a96e, #e7d3a7);
  transition: width 0.35s ease;
  box-shadow: 0 0 14px rgba(201, 169, 110, 0.45);
}

.progress__track {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  gap: 0.2rem;
}

.progress__track::before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 2px;
  background: linear-gradient(90deg, rgba(201, 169, 110, 0.4), rgba(231, 211, 167, 0.3));
  opacity: 0.4;
  z-index: 0;
  transform: translateY(-50%);
  pointer-events: none;
}

.progress__dot {
  position: relative;
  z-index: 1;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.12);
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s, transform 0.25s;
}

.progress__dot--done,
.progress__dot--current {
  background: var(--accent-main);
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 2px rgba(201, 169, 110, 0.25);
}

.progress__dot--current {
  transform: scale(1.25);
}

.progress__track--many {
  flex-wrap: wrap;
  justify-content: center;
  row-gap: 0.35rem;
  column-gap: 0.18rem;
  padding: 0.25rem 0.1rem;
}

.progress__track--many::before {
  display: none;
}

.progress__track--many .progress__dot {
  width: 7px;
  height: 7px;
  border-width: 1.5px;
}

/* Доска + разметка игрового экрана: верх — счётчики, центр — карты, низ — действия */
.screen--play {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: max(0.65rem, env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px))
    max(0.65rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
  min-height: 100dvh;
  min-height: 100svh;
  box-sizing: border-box;
}

.play-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  min-height: 0;
}

.play-top {
  flex-shrink: 0;
}

.play-bottom {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  padding-top: 0.85rem;
  padding-bottom: max(0.35rem, env(safe-area-inset-bottom));
}

.board-wrap {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
  min-height: 0;
  padding: 0.35rem 0 0.25rem;
}

/* Оболочка поля: тост в потоке не участвует — не дёргает сетку */
.board-stage {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 0.65rem;
  max-width: 720px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
  perspective: 1000px;
  width: 100%;
}

@media (min-width: 480px) {
  .board {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
  }
}

@media (min-width: 600px) {
  .board {
    grid-template-columns: repeat(4, 1fr);
    max-width: 580px;
  }
}

/* Раунд 2/3 — 3 колонки на узком, 4+ на широком; для 12 карт: 3x4 на мобиле */
.board.board--n12 {
  max-width: 100%;
  grid-template-columns: repeat(3, 1fr);
}

@media (min-width: 520px) {
  .board.board--n12 {
    grid-template-columns: repeat(4, 1fr);
    max-width: 640px;
  }
}

/* Плотные сетки: 16+ карт */
.board.board--n16,
.board.board--n20 {
  max-width: 100%;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

@media (max-width: 520px) {
  .board.board--n16,
  .board.board--n20 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.board.board--n24,
.board.board--n32,
.board.board--n40 {
  max-width: 960px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.45rem;
}

@media (max-width: 800px) {
  .board.board--n24,
  .board.board--n32,
  .board.board--n40 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .board.board--n32,
  .board.board--n40 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .board.board--n32 .card__inner,
  .board.board--n40 .card__inner {
    font-size: clamp(0.75rem, 2.4vw, 0.9rem);
  }
}

.board-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}

/* Микро-фраза: над сеткой, вне потока — карточки не прыгают */
.game-toast {
  position: absolute;
  left: 50%;
  bottom: 100%;
  z-index: 2;
  max-width: min(92%, 20rem);
  margin-bottom: 0.4rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.86rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.35;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%) translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}

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

@media (max-width: 520px) {
  .game-toast {
    font-size: 0.8rem;
    padding: 0.4rem 0.75rem;
    max-width: min(94%, 18rem);
    margin-bottom: 0.5rem;
    white-space: normal;
  }
}

/* Карточка */
.card-wrap {
  aspect-ratio: 0.9;
  min-height: 88px;
  list-style: none;
}

/* Появление раунда: +70ms на карточку (задержка в --enter-delay из JS) */
.card-wrap--enter {
  animation: cardEnter 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: var(--enter-delay, 0ms);
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card {
  width: 100%;
  height: 100%;
  position: relative;
  border-radius: 20px;
  transform-style: preserve-3d;
  transition: transform 0.4s ease, box-shadow 0.3s ease;
  cursor: pointer;
  outline: none;
  box-shadow: var(--shadow-card);
  border: none;
  background: none;
  padding: 0;
  font-family: inherit;
}

.card:focus-visible {
  box-shadow: 0 0 0 3px var(--ring), var(--shadow-card);
}

/* Наведение: рубашка / лицо — разные transform */
.card:not(.card--flipped):not(.card--matched):not(:disabled):hover {
  transform: translateY(-6px) scale(1.03);
  box-shadow: var(--glow-gold);
}

.card.card--flipped:not(.card--matched):not(:disabled):hover {
  transform: rotateY(180deg) translateY(-5px) scale(1.03);
  box-shadow: var(--glow-gold);
}

.card:not(.card--flipped):not(.card--matched):not(:disabled):active {
  transform: scale(0.96);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

.card.card--flipped:not(.card--matched):not(:disabled):active {
  transform: rotateY(180deg) scale(0.96);
}

/* Переворот (= .flip в ТЗ) */
.card--flipped {
  transform: rotateY(180deg);
}

.card--matched {
  pointer-events: none;
  transition: none;
  animation: matchSuccess 0.65s ease forwards;
}

.card--matched .card__face--front {
  background: rgba(74, 222, 128, 0.12);
  border-color: rgba(74, 222, 128, 0.35);
  color: #86efac;
}

.card--error {
  animation: cardShakeWrong 0.3s ease;
}

.card--error .card__face--front {
  box-shadow: 0 0 0 1px rgba(251, 113, 133, 0.35), 0 0 20px rgba(251, 113, 133, 0.12);
  border-color: rgba(251, 113, 133, 0.25);
}

/* Грани карты: эквивалент .back / .front из ТЗ */
.card__inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  border-radius: 20px;
  font-weight: 600;
  font-size: clamp(0.85rem, 2.2vw, 1.05rem);
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* «Рубашка» */
.card__face--back {
  background: linear-gradient(165deg, #1a1c22 0%, #23262f 100%);
  color: var(--accent-main);
  font-size: 1.5rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(201, 169, 110, 0.22);
}

/* Лицо (обёртка = .front) */
.card__face--front {
  background: rgba(255, 255, 255, 0.04);
  transform: rotateY(180deg);
  padding: 0.4rem 0.35rem;
  text-align: center;
  line-height: 1.2;
  word-break: break-word;
  flex-direction: column;
  gap: 0.1rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Дроби с линией (как в формуле) */
.card-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  max-width: 100%;
  width: 100%;
  min-height: 0;
}

.card-label__plain {
  font-weight: 600;
  font-size: 1.02em;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.card-label__mix {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.2em 0.35em;
  max-width: 100%;
}

.card-label__whole {
  font-weight: 600;
  font-size: 1.05em;
  line-height: 1.2;
  align-self: center;
}

.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  min-width: 1.1em;
  max-width: 100%;
  vertical-align: middle;
  font-size: 0.98em;
}

.frac__num,
.frac__den {
  display: block;
  text-align: center;
  font-weight: 600;
  line-height: 1.1;
  padding: 0 0.12em;
}

.frac__bar {
  display: block;
  height: 0.1em;
  min-height: 1.5px;
  width: 100%;
  min-width: 1.4em;
  background: currentColor;
  border-radius: 0.5px;
  margin: 0.12em 0 0.1em;
  flex-shrink: 0;
  align-self: stretch;
  opacity: 0.9;
}

/* Дроби внутри обычного текста (правила, «Чему тренируемся») */
.frac.frac--inline {
  display: inline-flex;
  font-size: 0.9em;
  vertical-align: middle;
  margin: 0 0.12em;
}

.frac-inline-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.22em;
  vertical-align: middle;
  margin: 0 0.1em;
}

.frac-inline-whole {
  font-weight: 600;
  line-height: 1.3;
  color: inherit;
}

.card__spacer {
  width: 1px;
  height: 1px;
  overflow: hidden;
  position: absolute;
}

@keyframes matchSuccess {
  0% {
    transform: rotateY(180deg) scale(1);
    box-shadow: var(--shadow-card), 0 0 0 0 rgba(74, 222, 128, 0.15);
  }
  40% {
    transform: rotateY(180deg) scale(1.1);
    box-shadow: 0 12px 36px rgba(74, 222, 128, 0.18), 0 0 28px rgba(74, 222, 128, 0.32);
  }
  100% {
    transform: rotateY(180deg) scale(1);
    box-shadow: 0 8px 28px rgba(74, 222, 128, 0.12), 0 0 16px rgba(74, 222, 128, 0.28);
  }
}

@keyframes cardShakeWrong {
  0%,
  100% {
    transform: rotateY(180deg) translateX(0);
  }
  25% {
    transform: rotateY(180deg) translateX(-5px);
  }
  50% {
    transform: rotateY(180deg) translateX(5px);
  }
  75% {
    transform: rotateY(180deg) translateX(-5px);
  }
}

/* Итоги */
.motivational {
  font-size: 1.05rem;
  color: var(--accent-main);
  font-weight: 500;
  margin: 0 0 1.25rem;
}

.summary-list {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.summary-list li {
  margin: 0.4rem 0;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-row--stack {
  flex-direction: column;
  align-items: stretch;
}

.title--victory-head {
  font-size: clamp(1.5rem, 4vw, 2rem);
  text-align: center;
  margin-bottom: 0.75rem;
}

.victory-prose {
  text-align: center;
  max-width: 36ch;
  margin: 0 auto 1rem;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text);
}

.victory-prose p {
  margin: 0 0 0.65rem;
}

.victory-prose p:last-child {
  margin-bottom: 0;
}

.victory-prose__line {
  font-weight: 500;
  color: var(--accent-soft);
}

.victory-lead {
  color: var(--text-muted);
  margin: 0 0 1rem;
  font-size: 0.95rem;
  text-align: center;
}

/* Модалка */
.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal__backdrop,
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.modal__panel {
  position: relative;
  background: rgba(21, 24, 33, 0.96);
  border-radius: 20px;
  padding: 1.5rem 1.4rem 1.6rem;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-hover);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: modalPanelIn 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modalPanelIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal__panel h3 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  color: var(--text-main);
  font-weight: 600;
}

.modal__panel p {
  margin: 0 0 1.1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Адаптив: крупнее карточки и кнопки, плотная сетка 2–3 в ряд */
@media (max-width: 600px) {
  .board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
  }

  .card-wrap {
    min-height: 96px;
  }

  .card__inner {
    font-size: clamp(0.8rem, 2.5vw, 1rem);
  }
}

@media (max-width: 400px) {
  .board:not(.board--n24):not(.board--n32):not(.board--n40) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
  }

  .card-wrap {
    min-height: 104px;
  }

  .btn,
  .button {
    min-height: 48px;
    padding: 0.75rem 1.2rem;
  }

  .top-actions .btn--ghost {
    min-height: 44px;
  }
}

/* Уменьшение движения */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
