/* ============================================
   CrossMath.co - Game-Specific Styles
   ============================================ */

/* --- Game Container --- */
.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 14px;
  min-height: 60vh;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
}

/* --- Game Header --- */
.game-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  width: 100%;
}

.game-back-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
  line-height: 1;
}

.game-back-btn:hover {
  color: var(--text-primary);
}

.game-icon {
  font-size: 16px;
}

.game-title {
  font-size: 15px;
  font-weight: 700;
}

.game-xp {
  margin-left: auto;
  font-size: 12px;
  color: var(--accent);
  font-family: var(--font-mono);
}

/* --- Game Info --- */
.game-info {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  width: 100%;
}

/* --- How to Play Button --- */
.btn-how-to-play {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 auto 12px;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
}

.btn-how-to-play:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
}

/* --- Game Loading --- */
.game-loading {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
}

/* --- Game Actions --- */
.game-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
  width: 100%;
}

/* --- Hint Counter --- */
.hint-counter {
  font-size: 11px;
  color: var(--hint);
  text-align: center;
  font-weight: 600;
}

/* --- Game Message --- */
.game-message {
  text-align: center;
  font-weight: 700;
  font-size: 14px;
}

/* --- Win / Loss Messages --- */
.msg-win {
  color: var(--success);
}

.msg-lose {
  color: var(--danger);
}


/* ============================================
   Shared Puzzle Grid
   ============================================ */

.puzzle-grid {
  display: grid;
  gap: 4px;
  justify-content: center;
}

.puzzle-cell {
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 600;
  border-radius: 7px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  outline: none;
  background: rgba(255, 255, 255, 0.06);
  color: white;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

/* Remove number input spinners */
.puzzle-cell::-webkit-inner-spin-button,
.puzzle-cell::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.puzzle-cell[type="number"] {
  -moz-appearance: textfield;
}

.puzzle-cell:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.2);
}

/* Compound class names used by crossmath.js */
.puzzle-cell-revealed {
  color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.02);
}

.puzzle-cell-error {
  border: 2px solid #ff4444;
}

.puzzle-cell-correct {
  border: 2px solid #6aaa64;
  background: rgba(106, 170, 100, 0.1);
}

/* Dot-separated fallbacks (for legacy usage) */
.puzzle-cell.revealed {
  color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.02);
}

.puzzle-cell.error {
  border-color: var(--danger);
  background: rgba(231, 76, 60, 0.1);
  animation: shake 0.4s ease;
}

.puzzle-cell.correct {
  border-color: var(--success);
  background: rgba(106, 170, 100, 0.1);
  animation: cellCorrect 0.6s ease;
}

.puzzle-cell.given {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
}

.puzzle-cell:disabled {
  opacity: 0.7;
  cursor: default;
}

/* --- Grid Labels (KenKen, Kakuro, Futoshiki) --- */
.grid-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
}


/* ============================================
   CrossMath
   ============================================ */

.crossmath-target {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #ff6b35;
  font-family: var(--font-mono);
  font-size: 15px;
}

.crossmath-operator {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
}


/* ============================================
   Mathler
   ============================================ */

.mathler-target {
  font-size: 24px;
  font-weight: 800;
  color: #6aaa64;
  font-family: var(--font-mono);
  text-align: center;
}

.mathler-board,
.mathler-grid {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
}

.mathler-row {
  display: flex;
  gap: 3px;
}

.mathler-cell {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  font-size: 18px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: white;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid var(--border);
  transition: all 0.2s ease;
  user-select: none;
}

.mathler-cell-active {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Compound class names (used by mathler.js as .mathler-cell.mathler-correct) */
.mathler-cell.mathler-correct,
.mathler-cell-correct {
  background: #6aaa64;
  border-color: #6aaa64;
  color: #fff;
}

.mathler-cell.mathler-present,
.mathler-cell-present {
  background: #b59f3b;
  border-color: #b59f3b;
  color: #fff;
}

.mathler-cell.mathler-absent,
.mathler-cell-absent {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.mathler-cell-empty {
  background: rgba(255, 255, 255, 0.03);
}

.mathler-cell-current {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.mathler-keyboard {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 290px;
}

.mathler-key {
  width: 36px;
  height: 36px;
  border-radius: 5px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  font-size: 15px;
  font-family: var(--font-mono);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
}

.mathler-key:active {
  transform: scale(0.92);
}

.mathler-key-submit {
  width: 72px;
  background: #6aaa64;
  font-weight: 700;
  font-size: 12px;
}

.mathler-key-wide {
  width: 56px;
  font-size: 0.7rem;
}

.mathler-key.key-correct {
  background: #6aaa64;
  border-color: #6aaa64;
  color: #fff;
}

.mathler-key.key-present {
  background: #b59f3b;
  border-color: #b59f3b;
  color: #fff;
}

.mathler-key.key-absent {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}

.mathler-hint-badge {
  background: rgba(255, 200, 0, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #ffd700;
}


/* ============================================
   2048
   ============================================ */

.game-2048-board,
.g2048-grid {
  display: grid;
  gap: 4px;
  background: rgba(255, 255, 255, 0.05);
  padding: 6px;
  border-radius: 10px;
}

.g2048-header {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 12px;
  font-size: 1rem;
}

.tile-2048,
.g2048-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-weight: 800;
  font-family: var(--font-display);
  transition: all 0.12s ease;
  user-select: none;
}

.tile-0 {
  background: rgba(255, 255, 255, 0.04);
  color: transparent;
}

.tile-2 {
  background: #eee4da;
  color: #776e65;
}

.tile-4 {
  background: #ede0c8;
  color: #776e65;
}

.tile-8 {
  background: #f2b179;
  color: white;
}

.tile-16 {
  background: #f59563;
  color: white;
}

.tile-32 {
  background: #f67c5f;
  color: white;
}

.tile-64 {
  background: #f65e3b;
  color: white;
}

.tile-128 {
  background: #edcf72;
  color: white;
}

.tile-256 {
  background: #edcc61;
  color: white;
}

.tile-512 {
  background: #edc850;
  color: white;
}

.tile-1024 {
  background: #edc53f;
  color: white;
  font-size: smaller;
}

.tile-2048 {
  background: #edc22e;
  color: white;
  font-size: smaller;
}

.tile-super {
  background: #3c3a32;
  color: white;
}

@keyframes tilePop {
  0% { transform: scale(0); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.tile-pop {
  animation: tilePop 0.2s ease;
}

/* Direction Buttons (2048) */
.dir-buttons,
.g2048-arrows {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
}

.dir-btn,
.g2048-arrow-btn {
  width: 44px;
  height: 36px;
  border-radius: 7px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.dir-btn:active,
.g2048-arrow-btn:active {
  transform: scale(0.93);
  background: rgba(255, 255, 255, 0.12);
}


/* ============================================
   Make 24
   ============================================ */

.make24-numbers {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.make24-card {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 23px;
  font-weight: 800;
  font-family: var(--font-mono);
  background: rgba(224, 86, 160, 0.1);
  color: #e056a0;
  border: 2px solid rgba(224, 86, 160, 0.2);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.make24-card:hover {
  background: rgba(224, 86, 160, 0.2);
  transform: scale(1.05);
}

.make24-card.selected {
  background: var(--accent-secondary);
  color: #fff;
  border-color: var(--accent-secondary);
  box-shadow: 0 4px 16px rgba(224, 86, 160, 0.35);
}

.make24-card.used {
  opacity: 0.3;
  pointer-events: none;
}

.make24-ops {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.make24-op {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.make24-op:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.make24-expression {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: center;
  min-height: 1.5em;
}

.make24-input {
  width: 200px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: white;
  font-size: 17px;
  font-family: var(--font-mono);
  text-align: center;
  outline: none;
}

.make24-input:focus {
  border-color: var(--accent-secondary);
}


/* ============================================
   Sprint
   ============================================ */

.sprint-stats {
  display: flex;
  gap: 16px;
  font-size: 14px;
  font-family: var(--font-mono);
}

.sprint-timer {
  color: #00d4ff;
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
}

.sprint-timer.danger {
  color: #e74c3c;
  animation: pulse 0.8s ease infinite;
}

.sprint-timer.sprint-timer-low {
  color: var(--danger);
  animation: pulse 0.8s ease infinite;
}

.sprint-score {
  color: #6aaa64;
}

.sprint-streak {
  color: #f39c12;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
}

.sprint-streak.active {
  animation: pulse 0.8s ease infinite;
}

.sprint-streak-fire {
  display: inline-block;
  animation: pulse 0.8s ease infinite;
}

.sprint-question {
  font-size: 34px;
  font-weight: 800;
  color: white;
  font-family: var(--font-mono);
  text-align: center;
  line-height: 1.3;
}

.sprint-input {
  width: 110px;
  padding: 9px;
  border-radius: 8px;
  border: 2px solid #00d4ff;
  background: rgba(0, 212, 255, 0.07);
  color: white;
  font-size: 26px;
  font-family: var(--font-mono);
  text-align: center;
  outline: none;
}

.sprint-input:focus {
  border-color: #00d4ff;
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.2);
}

.sprint-hint-display {
  min-height: 28px;
  color: #f9a825;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
}

@keyframes sprintCombo {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}

.sprint-combo {
  animation: sprintCombo 0.4s ease;
  font-weight: 800;
  color: var(--warning);
}


/* ============================================
   Sumplete
   ============================================ */

.sumplete-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  font-weight: 700;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.1s;
  border: 2px solid rgba(243, 156, 18, 0.15);
  background: rgba(243, 156, 18, 0.1);
  color: #f39c12;
  user-select: none;
}

.sumplete-cell:hover {
  background: rgba(243, 156, 18, 0.18);
}

.sumplete-cell.marked,
.sumplete-cell.sumplete-marked {
  background: rgba(255, 255, 255, 0.02);
  color: rgba(255, 255, 255, 0.12);
  text-decoration: line-through;
  border-color: rgba(255, 255, 255, 0.03);
}

.sumplete-target {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 800;
  color: #f39c12;
}


/* ============================================
   Quick Games (Multiply, Fractions, PEMDAS)
   ============================================ */

.quick-progress {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  text-align: center;
}

.quick-question {
  font-size: 34px;
  font-weight: 800;
  font-family: var(--font-mono);
  text-align: center;
}

.quick-input {
  width: 110px;
  padding: 9px;
  border-radius: 8px;
  color: white;
  font-size: 26px;
  font-family: var(--font-mono);
  text-align: center;
  outline: none;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.quick-input:focus {
  border-color: var(--accent);
}

/* Legacy quick-game classes */
.quick-game-question {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.4;
  padding: 16px 0;
}

.quick-game-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 300px;
}

.quick-game-option {
  padding: 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid var(--border);
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.quick-game-option:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

.quick-game-option.option-correct {
  background: rgba(106, 170, 100, 0.2);
  border-color: var(--success);
  color: var(--success);
}

.quick-game-option.option-wrong {
  background: rgba(231, 76, 60, 0.15);
  border-color: var(--danger);
  color: var(--danger);
}

/* Fraction buttons (< = >) */
.fraction-buttons {
  display: flex;
  gap: 8px;
}

.fraction-btn {
  width: 54px;
  height: 54px;
  border-radius: 10px;
  border: none;
  font-size: 26px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}


/* ============================================
   In-Game Leaderboard
   ============================================ */

.game-leaderboard {
  max-width: 280px;
  width: 100%;
  margin-top: 16px;
}

.leaderboard-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-family: var(--font-mono);
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.leaderboard-item {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 12px;
  font-family: var(--font-mono);
}

.leaderboard-empty {
  color: rgba(255, 255, 255, 0.2);
  font-size: 12px;
  text-align: center;
  padding: 12px;
}

/* Legacy leaderboard classes */
.leaderboard-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.leaderboard-rank {
  font-weight: 800;
  font-size: 0.9rem;
  width: 24px;
  text-align: center;
}

.leaderboard-rank-1 { color: #ffd700; }
.leaderboard-rank-2 { color: #c0c0c0; }
.leaderboard-rank-3 { color: #cd7f32; }

.leaderboard-name {
  font-size: 0.88rem;
  font-weight: 600;
}

.leaderboard-score {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--warning);
}


/* ============================================
   Leaderboard Page (classifica.php)
   ============================================ */

.leaderboard-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
}

.leaderboard-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.leaderboard-page-title {
  font-size: 24px;
  font-weight: 800;
}

.lb-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}

.lb-tab {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.lb-tab:hover {
  background: rgba(255, 255, 255, 0.04);
}

.lb-tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.lb-list-container {
  width: 100%;
}

.lb-loading {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
}

.lb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.lb-item-gold {
  background: rgba(255, 215, 0, 0.06);
}

.lb-rank {
  font-size: 18px;
  width: 28px;
  text-align: center;
}

.lb-rank-num {
  color: var(--text-muted);
}

.lb-info {
  flex: 1;
}

.lb-name {
  font-weight: 700;
  color: white;
  font-size: 14px;
}

.lb-meta {
  font-size: 10px;
  color: var(--text-muted);
}

.lb-diff {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.15);
}

.lb-score {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
  font-size: 15px;
}


/* ============================================
   Game Result Panel
   ============================================ */

.game-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  animation: slideUp 0.4s ease;
}

.game-result-score {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 800;
}

.game-result-xp {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--success);
}


/* ============================================
   Difficulty Badges
   ============================================ */

.diff-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.diff-0 { color: var(--success); }
.diff-1 { color: var(--warning); }
.diff-2 { color: var(--accent); }
.diff-3 { color: var(--danger); }


/* ============================================
   Animations
   ============================================ */

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@keyframes cellCorrect {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); background: rgba(106, 170, 100, 0.3); }
  100% { transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes scaleIn {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes slideUp {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}
