/* ===== FIND IT FIRST - MindWorld School v2.4 ===== */

:root {
  --color-ivory: #FFFEF5;
  --color-gold: #F0C952;
  --color-pumpkin: #EC7F17;
  --color-tomato: #F24E2A;
  --color-moss: #2D4739;
  
  /* ЗБІЛЬШЕНО РОЗМІРИ КАРТ */
  --card-size: 320px;           /* Було 280px */
  --card-size-player: 320px;     /* Було 220px - тепер однакові! */
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, var(--color-ivory) 0%, #fff9e6 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== HEADER ===== */
.game-header {
  background: linear-gradient(to top, var(--color-tomato), var(--color-pumpkin));
  color: white;
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  position: relative;
}

.header-logo {
  flex: 1;
  display: flex;
  align-items: center;
}

.logo-img {
  height: 50px;
  width: auto;
  object-fit: contain;
}

.header-center {
  flex: 1;
  text-align: center;
}

.header-lang {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* Мовна капсула */
.lang-capsule {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 25px;
  padding: 5px;
  display: flex;
  gap: 5px;
  backdrop-filter: blur(10px);
}

.lang-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95em;
  transition: all 0.3s ease;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.lang-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.15);
}

.lang-btn.active {
  background: white;
  color: var(--color-pumpkin);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.game-title {
  font-size: 2.5em;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
  margin-bottom: 10px;
}

.game-subtitle {
  font-size: 1.2em;
  opacity: 0.9;
}

/* ===== SETUP SCREEN (МЕНЮ НАЛАШТУВАНЬ) ===== */
.setup-screen {
  max-width: 700px;
  margin: 50px auto;
  padding: 40px;
  background: white;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.setup-section {
  margin-bottom: 30px;
}

.setup-section h3 {
  color: var(--color-pumpkin);
  margin-bottom: 15px;
  font-size: 1.4em;
}

.setup-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: nowrap; /* Не переносити */
  justify-content: space-between;
}

/* КНОПКИ ВИБОРУ (однакова ширина) */
.btn {
  flex: 1; /* Рівномірний розподіл */
  min-width: 0; /* Дозволити стискатись */
  padding: 12px 16px;
  border: 2px solid var(--color-pumpkin);
  background: white;
  color: var(--color-pumpkin);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1em;
  font-weight: bold;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  text-align: center;
  white-space: nowrap; /* Не переносити текст */
}

.btn:hover {
  background: var(--color-pumpkin);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn.active {
  background: var(--color-pumpkin);
  color: white;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn small {
  display: block;
  font-size: 0.7em;
  margin-top: 4px;
  opacity: 0.9;
  font-weight: normal;
  white-space: normal; /* Дозволити перенос для маленького тексту */
}

/* КНОПКА "НАЧАТЬ ИГРУ" - 50% ширини по центру */
.btn-primary {
  background: linear-gradient(135deg, var(--color-pumpkin), var(--color-tomato));
  color: white;
  border: none;
  padding: 15px 40px;
  font-size: 1.2em;
  margin-top: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  width: 50%; /* 50% ширини */
  margin-left: auto;
  margin-right: auto;
  display: block;
}

.btn-primary:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.btn-secondary {
  background: white;
  color: var(--color-pumpkin);
  border: 2px solid var(--color-pumpkin);
}

/* ===== GAME INFO PANEL (ВЕРХНЯ ПАНЕЛЬ) ===== */
.game-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 30px;
  background: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  z-index: 100;
  position: relative;
  gap: 20px; /* Відступ між блоками */
}

.info-left {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1;
  min-width: 150px;
}

.info-left .cards-remaining {
  font-size: 1.1em;
  color: var(--color-moss);
  font-weight: 600;
  white-space: nowrap;
}

.info-left .cards-remaining strong {
  color: var(--color-pumpkin);
  font-size: 1.3em;
}

/* ЦЕНТР: Таймер (для 1 гравця) або Панель гравців (для 2-4) */
.info-center {
  flex: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 200px;
}

/* Таймер (для 1 гравця) */
.timer {
  font-size: 1.5em;
  font-weight: bold;
  color: var(--color-pumpkin);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.timer strong {
  font-size: 1.3em;
  color: var(--color-tomato);
}

/* ПАНЕЛЬ ГРАВЦІВ (для 2-4 гравців) - ВИПРАВЛЕНО */
.players-scores-top {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap; /* Всі гравці в один ряд */
}

.player-score-top {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 20px;
  transition: all 0.3s ease;
  white-space: nowrap; /* НЕ переносити текст всередині блоку */
  min-width: fit-content;
}

.player-score-top.first-clicked {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 140, 0, 0.2));
  border: 2px solid #FFD700;
  animation: pulse-glow 1s ease-in-out infinite;
}

.player-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.player-name-top {
  font-weight: 600;
  font-size: 0.95em;
  color: var(--color-moss);
}

.player-score-top.first-clicked .player-name-top {
  color: #FFD700;
  font-weight: bold;
}

.player-cards-count {
  font-weight: bold;
  font-size: 1em;
  color: var(--color-pumpkin);
}

.first-indicator {
  margin-left: 2px;
  font-size: 1.1em;
  animation: spark 0.5s ease-in-out infinite alternate;
}

.info-right {
  display: flex;
  gap: 10px;
  align-items: center;
  flex: 1;
  justify-content: flex-end;
  min-width: 100px;
}

/* Кнопки Пауза/Вийти */
.btn-icon {
  width: 45px;
  height: 45px;
  border: 2px solid var(--color-pumpkin);
  background: white;
  color: var(--color-pumpkin);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.3em;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.btn-icon:hover {
  background: var(--color-pumpkin);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* ===== GAME BOARD ===== */
.game-board {
  position: relative;
  width: 100%;
  height: calc(100vh - 70px);
  margin: 0 auto;
  flex: 1;
  padding-top: 5px;
}

/* Minimal spacing for multiplayer */
.game-board.multiplayer-3,
.game-board.multiplayer-4 {
  padding-top: 5px;
}

.card-container {
  position: absolute;
  transition: all 0.5s ease;
}

.card {
  width: var(--card-size);
  height: var(--card-size);
  background: white;
  border-radius: 50%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
}

.card.player {
  width: var(--card-size-player);
  height: var(--card-size-player);
}

.card:hover {
  transform: scale(1.05);
}

.card.player.selected {
  box-shadow: 0 0 30px 10px rgba(255, 215, 0, 0.8) !important;
  transform: scale(1.05);
  transition: all 0.3s ease;
}

.card-label {
  text-align: center;
  margin-top: 3px;
  font-weight: bold;
  font-size: 1.1em;
  color: var(--color-moss);
  background: rgba(255, 255, 255, 0.9);
  padding: 4px 12px;
  border-radius: 15px;
  white-space: nowrap;
  position: relative;
  z-index: 10;
}

/* Vertical label positioning */
.card-label.vertical-left {
  position: absolute;
  left: -45px;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  margin-top: 0;
  transform-origin: center;
}

.card-label.vertical-right {
  position: absolute;
  right: -45px;
  top: 50%;
  transform: translateY(-50%) rotate(90deg);
  margin-top: 0;
  transform-origin: center;
}

/* SVG Symbols */
.symbol {
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.symbol:hover {
  opacity: 0.8;
}

/* ===== LOADING SCREEN ===== */
.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.loader {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(236, 127, 23, 0.3);
  border-top-color: var(--color-pumpkin);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  margin-top: 20px;
  font-size: 1.2em;
  color: var(--color-pumpkin);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== RESULTS SCREEN ===== */
.results-content {
  max-width: 600px;
  margin: 50px auto;
  padding: 40px;
  background: white;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.results-title {
  color: var(--color-pumpkin);
  font-size: 2.5em;
  margin-bottom: 30px;
}

.stat-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  margin-bottom: 15px;
  background: rgba(236, 127, 23, 0.1);
  border-radius: 10px;
}

.stat-label {
  font-size: 1.2em;
  color: var(--color-moss);
}

.stat-value {
  font-size: 2em;
  font-weight: bold;
  color: var(--color-pumpkin);
}

.results-actions {
  display: flex;
  gap: 15px;
  margin-top: 30px;
}

.results-actions .btn-primary,
.results-actions .btn-secondary {
  flex: 1;
}

/* ===== MODAL ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  min-width: 300px;
}

.modal-content h3 {
  color: var(--color-pumpkin);
  font-size: 2em;
  margin-bottom: 30px;
}

.modal-content button {
  width: 100%;
  margin-bottom: 10px;
  border-radius: 10px;
}

.modal-content .btn-primary {
  background: linear-gradient(135deg, var(--color-pumpkin), var(--color-tomato));
  color: white;
  border: none;
  padding: 15px 40px;
  font-size: 1.1em;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

.modal-content .btn-primary:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.modal-content .btn-secondary {
  background: linear-gradient(135deg, var(--color-pumpkin), var(--color-tomato));
  color: white;
  border: none;
  padding: 15px 40px;
  font-size: 1.1em;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

.modal-content .btn-secondary:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

/* ===== ANIMATIONS ===== */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
  20%, 40%, 60%, 80% { transform: translateX(10px); }
}

.shake {
  animation: shake 0.5s;
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
  }
}

@keyframes spark {
  from {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  to {
    transform: scale(1.3) rotate(20deg);
    opacity: 0.7;
  }
}

.has-clicked {
  opacity: 0.7;
  background: rgba(0, 255, 0, 0.1);
}

/* Game Over Modal */
.game-over-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.game-over-modal .modal-content {
  background: white;
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  max-width: 500px;
  animation: slideUp 0.5s ease;
}

.game-over-modal h2 {
  color: var(--color-pumpkin);
  font-size: 2.5em;
  margin-bottom: 20px;
}

.winner {
  margin: 30px 0;
}

.winner-name {
  font-size: 2em;
  font-weight: bold;
  margin-bottom: 10px;
}

.winner-cards {
  font-size: 3em;
  font-weight: bold;
  color: var(--color-gold);
}

.game-stats {
  margin: 20px 0;
}

.game-stats p {
  font-size: 1.1em;
  margin: 10px 0;
  color: var(--color-moss);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* ===== UTILITY CLASSES ===== */
.hidden {
  display: none !important;
}

.screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== RESPONSIVE DESIGN ===== */

/* Дуже великі екрани (2560px+) */
@media (min-width: 2560px) {
  :root {
    --card-size: 550px;
    --card-size-player: 550px;
  }
}

/* 2K екрани (2048px-2559px) */
@media (min-width: 2048px) and (max-width: 2559px) {
  :root {
    --card-size: 480px;
    --card-size-player: 480px;
  }
}

/* Великі екрани (1920px-2047px) */
@media (min-width: 1920px) and (max-width: 2047px) {
  :root {
    --card-size: 420px;
    --card-size-player: 420px;
  }
}

/* Стандартні екрани (1024-1920px) */
@media (max-width: 1920px) and (min-width: 1024px) {
  :root {
    --card-size: 320px;
    --card-size-player: 320px;
  }
}

/* Планшети (768-1024px) */
@media (max-width: 1024px) {
  .game-board {
    height: calc(100vh - 65px);
  }

  :root {
    --card-size: 240px;
    --card-size-player: 240px;
  }
  
  .game-info {
    padding: 10px 20px;
    flex-wrap: wrap;
  }
  
  .info-left,
  .info-center,
  .info-right {
    flex: 1 1 auto;
  }
  
  .timer {
    font-size: 1.2em;
  }
  
  .players-scores-top {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .player-score-top {
    padding: 5px 10px;
    font-size: 0.9em;
  }
}

/* Мобільні (max 768px) */
@media (max-width: 768px) {
  .game-board {
    height: calc(100vh - 60px);
  }

  :root {
    --card-size: 180px;
    --card-size-player: 180px;
  }
  
  .game-title {
    font-size: 1.8em;
  }
  
  .game-subtitle {
    font-size: 1em;
  }
  
  .game-info {
    flex-direction: column;
    gap: 10px;
    padding: 10px 15px;
  }
  
  .info-left,
  .info-center,
  .info-right {
    justify-content: center;
    width: 100%;
  }
  
  .setup-screen {
    margin: 20px;
    padding: 30px 20px;
  }
  
  .setup-buttons {
    flex-wrap: wrap;
  }
  
  .btn {
    font-size: 0.9em;
    padding: 10px 12px;
  }
  
  .btn-primary {
    width: 100%;
    font-size: 1.1em;
  }
  
  .player-score-top {
    font-size: 0.85em;
    padding: 4px 8px;
  }
}

/* Дуже маленькі екрани (max 480px) */
@media (max-width: 480px) {
  :root {
    --card-size: 140px;
    --card-size-player: 140px;
  }

  .game-board {
    height: calc(100vh - 55px);
  }
  
  .game-info {
    padding: 8px 10px;
  }
  
  .btn-icon {
    width: 40px;
    height: 40px;
    font-size: 1.1em;
  }
  
  .player-score-top {
    padding: 4px 6px;
    font-size: 0.8em;
    gap: 4px;
  }
  
  .player-color-dot {
    width: 12px;
    height: 12px;
  }
  
  .timer {
    font-size: 1em;
  }
  
  .setup-section h3 {
    font-size: 1.2em;
  }
  
  .btn {
    font-size: 0.85em;
    padding: 8px 10px;
  }
}

/* ===== TIMER SLIDER ===== */
.timer-slider-section {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid rgba(236, 127, 23, 0.2);
}

.timer-slider-section.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.timer-slider-container {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-top: 10px;
}

.timer-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, var(--color-pumpkin), var(--color-tomato));
  outline: none;
}

.timer-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--color-pumpkin);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.timer-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--color-pumpkin);
  cursor: pointer;
}

.timer-value {
  min-width: 60px;
  text-align: center;
  font-weight: bold;
  color: var(--color-pumpkin);
  font-size: 1.1em;
}

/* Timer warning animation */
.timer.warning {
  color: var(--color-tomato);
  animation: timer-pulse 0.5s ease-in-out infinite;
}

.timer.warning strong {
  color: var(--color-tomato);
}

@keyframes timer-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Timer expired */
.timer.expired {
  color: #999;
}

.timer.expired strong {
  color: #999;
}
