/* Mind game specific styles */

/* ===== Layout ===== */
.mind_game-section {
  padding: 2rem 0 1rem;
}

/* ===== Setup screen ===== */
.mind_game-setup {
  display: flex;
  justify-content: center;
  padding: 2rem 0;
}

.setup-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  max-width: 560px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.setup-card h2 {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.setup-card>p {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.setup-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  text-align: left;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
  color: var(--text-primary);
}

.form-group select,
.form-group input[type="text"] {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-group select:focus,
.form-group input[type="text"]:focus {
  border-color: var(--primary-color);
}

#playerNamesInputs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#playerNamesInputs input {
  width: 100%;
}

.setup-form .btn {
  margin-top: 0.5rem;
  justify-content: center;
}

/* ===== Top panel ===== */
.mind_game-top-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.mind_game-players {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.player-score-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
  min-width: 90px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
}

.player-score-card.active {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  transform: scale(1.05);
}

.player-score-card .player-name {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

.player-score-card .player-score {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary-color);
}

.player-score-card .player-score.negative {
  color: var(--error-color);
}

.mind_game-round-info {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.mind_game-round-info strong {
  color: var(--primary-color);
}

.mind_game-controls {
  display: flex;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
}

/* ===== Game board ===== */
.mind_game-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.65rem;
  margin-bottom: 1.5rem;
}

.board-category-header {
  grid-column: span 1;
  text-align: center;
  padding: 0.75rem 0.4rem;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: #fff;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.3;
  word-break: break-word;
}

.board-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary-color);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

.board-cell:hover:not(.used) {
  background: var(--primary-color);
  color: #fff;
  transform: scale(1.04);
  box-shadow: var(--shadow-md);
}

.board-cell:active:not(.used) {
  transform: scale(0.98);
}

.board-cell.used {
  opacity: 0.25;
  cursor: default;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
}

.board-cell.used::after {
  content: '✓';
  font-size: 1.2rem;
  color: var(--success-color);
}

/* ===== Game log ===== */
.mind_game-footer {
  margin-top: 0.5rem;
}

.mind_game-log {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  min-height: 2.5rem;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
}

.mind_game-log .log-entry {
  padding: 0.15rem 0;
}

.mind_game-log .log-entry.success {
  color: var(--success-color);
}

.mind_game-log .log-entry.error {
  color: var(--error-color);
}

.mind_game-log .log-entry.info {
  color: var(--primary-color);
}

/* ===== Modal ===== */
.mind_game-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: #fff;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  font-weight: 700;
}

.modal-category {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.9;
}

.modal-value {
  font-size: 1.1rem;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.2rem 0.75rem;
  border-radius: var(--radius-full);
}

.modal-body {
  padding: 1.5rem;
}

.question-text {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.6;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}

.answers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.answer-btn {
  padding: 0.85rem 1rem;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

.answer-btn:hover:not(:disabled) {
  border-color: var(--primary-color);
  background: var(--bg-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.answer-btn:disabled {
  cursor: default;
}

.answer-btn.correct {
  background: var(--success-color);
  border-color: var(--success-color);
  color: #fff;
}

.answer-btn.wrong {
  background: var(--error-color);
  border-color: var(--error-color);
  color: #fff;
}

.answer-btn.dimmed {
  opacity: 0.45;
}

.answer-feedback {
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  min-height: 1.5rem;
  padding-top: 0.25rem;
}

.answer-feedback.success {
  color: var(--success-color);
}

.answer-feedback.error {
  color: var(--error-color);
}

.modal-footer {
  padding: 0 1.5rem 1.5rem;
  text-align: center;
}

.modal-footer .btn {
  min-width: 180px;
  justify-content: center;
}

/* Timer bar */
.timer-bar-wrap {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.timer-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--success-color), var(--warning-color), var(--error-color));
  width: 100%;
  transition: width 1s linear;
  border-radius: 3px;
}

/* ===== Results screen ===== */
.mind_game-results {
  display: flex;
  justify-content: center;
  padding: 3rem 0;
}

.results-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  max-width: 560px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.results-card h2 {
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 1rem;
}

.result-row:last-of-type {
  border-bottom: none;
}

.result-row .rank {
  font-weight: 800;
  color: var(--text-secondary);
  width: 2rem;
}

.result-row .name {
  flex: 1;
  text-align: left;
  font-weight: 600;
  padding: 0 0.5rem;
}

.result-row .score {
  font-weight: 800;
  color: var(--primary-color);
}

.result-row.winner {
  background: rgba(16, 185, 129, 0.08);
  border-radius: var(--radius-md);
}

.results-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.75rem;
  flex-wrap: wrap;
}

/* ===== Info section ===== */
.mind_game-info {
  padding: 3rem 0;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .mind_game-board {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.4rem;
  }

  .board-category-header {
    font-size: 0.65rem;
    padding: 0.5rem 0.25rem;
    min-height: 52px;
  }

  .board-cell {
    min-height: 56px;
    font-size: 1rem;
    border-radius: var(--radius-sm);
  }

  .mind_game-top-panel {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .mind_game-players {
    justify-content: center;
  }

  .player-score-card {
    min-width: 70px;
    padding: 0.4rem 0.7rem;
  }

  .player-score-card .player-score {
    font-size: 1.1rem;
  }

  .mind_game-round-info {
    text-align: center;
  }

  .mind_game-controls {
    justify-content: center;
  }

  .answers-grid {
    grid-template-columns: 1fr;
  }

  .setup-card {
    padding: 1.5rem;
  }

  .modal-body {
    padding: 1.25rem;
  }
}

@media (max-width: 480px) {
  .mind_game-board {
    gap: 0.3rem;
  }

  .board-category-header {
    font-size: 0.55rem;
    padding: 0.4rem 0.2rem;
    min-height: 44px;
  }

  .board-cell {
    min-height: 44px;
    font-size: 0.85rem;
  }

  .mind_game-players {
    gap: 0.4rem;
  }

  .player-score-card {
    min-width: 58px;
    padding: 0.3rem 0.5rem;
  }

  .player-score-card .player-name {
    font-size: 0.6rem;
    max-width: 70px;
  }

  .player-score-card .player-score {
    font-size: 0.95rem;
  }

  .question-text {
    font-size: 1rem;
  }

  .answer-btn {
    padding: 0.7rem 0.8rem;
    font-size: 0.85rem;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

  .modal-content,
  .board-cell,
  .player-score-card {
    animation: none !important;
    transition: none !important;
  }
}