/**
 * game.css - Стилизация интерактивной игры «Найди пару»
 * Оптимизировано для сенсорной доски и тач-устройств.
 */

.game-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding: clamp(10px, 1.2cqw, 18px) clamp(16px, 2cqw, 30px);
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  overflow: hidden;
}

/* Шапка игры */
.game-header {
  display: flex;
  align-items: center;
  gap: clamp(12px, 1.5cqw, 24px);
  margin-bottom: clamp(8px, 1cqw, 14px);
  border-bottom: 2px solid rgba(44, 60, 67, 0.12);
  padding-bottom: clamp(6px, 0.8cqw, 12px);
}

.game-title-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  padding: clamp(6px, 0.8cqw, 10px) clamp(14px, 1.6cqw, 22px);
  border-radius: 20px;
  font-weight: 800;
  font-size: clamp(17px, 1.9cqw, 24px);
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
  flex-shrink: 0;
}

.game-subtitle {
  font-size: clamp(18px, 2.1cqw, 30px);
  color: #0f172a;
  font-weight: 800;
  line-height: 1.3;
}

.game-stats {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.2cqw, 16px);
}

.game-counter {
  font-size: clamp(14px, 1.5cqw, 18px);
  color: #1e293b;
  font-weight: 600;
  background: #f1f5f9;
  padding: clamp(4px, 0.6cqw, 8px) clamp(10px, 1.2cqw, 16px);
  border-radius: 10px;
  border: 1px solid #cbd5e1;
}

.game-counter strong {
  color: #2563eb;
  font-size: clamp(16px, 1.7cqw, 20px);
}

.game-actions {
  display: flex;
  gap: clamp(6px, 0.8cqw, 10px);
}

.game-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: clamp(6px, 0.7cqw, 10px) clamp(10px, 1.2cqw, 16px);
  border-radius: 8px;
  font-size: clamp(12px, 1.3cqw, 15px);
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  touch-action: manipulation;
}

.game-btn:active {
  transform: scale(0.96);
}

.game-btn-secondary {
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.game-btn-secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.game-btn-hint {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.game-btn-hint:hover {
  background: #fde68a;
}

.game-btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  padding: 12px 28px;
  font-size: 16px;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

/* Игровое поле */
.game-arena {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: 2fr 3fr;
  gap: clamp(18px, 2.5cqw, 36px);
  min-height: 0;
  align-items: stretch;
}

/* SVG канвас для линий */
.game-connections-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.connection-line {
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.18));
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
}

.connection-line.animate-draw {
  animation: drawLine 0.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes drawLine {
  to {
    stroke-dashoffset: 0;
  }
}

/* Колонки */
.game-col {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(6px, 0.7cqw, 10px);
  z-index: 10;
}

.game-col-header {
  font-size: clamp(14px, 1.55cqw, 20px);
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

/* Карточки */
.game-card {
  position: relative;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: clamp(6px, 0.8cqw, 10px) clamp(10px, 1.2cqw, 16px);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.04);
  flex: 1;
  min-height: clamp(38px, 4.2cqw, 54px);
}

.game-card:hover {
  border-color: #94a3b8;
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}

.game-card:active {
  transform: scale(0.98);
}

/* Выбранная карточка */
.game-card.selected {
  border-color: var(--accent-color, #2563eb) !important;
  background: #f8fafc;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18), 0 8px 18px rgba(0, 0, 0, 0.1);
  transform: scale(1.02);
  animation: pulseCard 1.5s infinite alternate;
}

@keyframes pulseCard {
  from { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
  to { box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.35); }
}

/* Соединенная правильная карточка */
.game-card.matched {
  border-color: var(--accent-color, #10b981) !important;
  background: rgba(240, 253, 244, 0.9);
  cursor: default;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
  transform: none !important;
}

.game-card.matched .card-check {
  display: flex;
}

/* Ошибка */
.game-card.error {
  border-color: #ef4444 !important;
  background: #fef2f2 !important;
  animation: shakeCard 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shakeCard {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

.card-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-num {
  font-weight: 900;
  font-size: clamp(18px, 2cqw, 26px);
  color: #1e293b;
}

.term-card .card-text {
  font-size: clamp(18px, 2cqw, 26px);
  font-weight: 800;
  color: #1e293b;
  line-height: 1.25;
}

.def-card .card-text {
  font-size: clamp(16px, 1.75cqw, 23px);
  font-weight: 600;
  color: #1e293b;
  line-height: 1.35;
}

/* Пины (точки подключения) */
.card-pin-left, .card-pin-right {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  background: #ffffff;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  transition: all 0.2s;
}

.term-card .card-pin-left {
  position: static;
  width: auto;
  height: auto;
  border: none;
  transform: none;
  font-size: 20px;
}

.term-card .card-pin-right {
  right: -8px;
}

.def-card .card-pin-left {
  left: -8px;
}

.game-card.selected .card-pin-right,
.game-card.selected .card-pin-left {
  border-color: var(--accent-color, #2563eb);
  background: var(--accent-color, #2563eb);
  transform: translateY(-50%) scale(1.3);
}

.game-card.matched .card-pin-right,
.game-card.matched .card-pin-left {
  border-color: var(--accent-color, #10b981);
  background: var(--accent-color, #10b981);
}

.card-check {
  display: none;
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  background: #10b981;
  color: #fff;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: bold;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.4);
  z-index: 12;
}

/* Частицы искр при успехе */
.sparkle-particle {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  pointer-events: none;
  z-index: 20;
  animation: sparkleAnim 0.7s ease-out forwards;
}

@keyframes sparkleAnim {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(0);
    opacity: 0;
  }
}


