/* === Game Stats Bar === */
.game-stats-bar {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 16px;
}
.game-stat-item {
  background: var(--card-bg); border-radius: var(--radius); padding: 12px 8px;
  text-align: center; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.game-stat-value {
  font-size: 1.3rem; font-weight: 800; font-family: 'JetBrains Mono', monospace;
  display: block; color: var(--text);
}
.game-stat-value .fa-heart { margin: 0 1px; }
.game-stat-label {
  font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* === Game Area === */
.game-area-wrapper {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 12px;
  overflow: hidden; position: relative;
}
.game-area {
  position: relative; width: 100%; height: 480px; overflow: hidden;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  border-radius: var(--radius);
}
[data-bs-theme="light"] .game-area {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
}
.game-canvas {
  position: absolute; inset: 0; z-index: 1;
}
.game-overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15,23,42,0.85);
  backdrop-filter: blur(4px);
}
[data-bs-theme="light"] .game-overlay {
  background: rgba(15,23,42,0.75);
}

/* === Start Screen === */
.game-start-screen, .game-pause-screen, .game-over-screen {
  text-align: center; padding: 24px; color: #fff;
}
.game-start-icon {
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(239,68,68,0.15); border: 2px solid rgba(239,68,68,0.3);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto; animation: pulse 2s ease infinite;
}
.game-start-screen h4, .game-pause-screen h4, .game-over-screen h4 { color: #fff; }
.game-start-screen .text-muted, .game-pause-screen .text-muted, .game-over-screen .text-muted { color: #94a3b8 !important; }
.game-start-screen kbd, .game-pause-screen kbd {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px; padding: 2px 8px; color: #e2e8f0; font-size: 0.75rem;
}
.game-result-stat {
  background: rgba(255,255,255,0.08); border-radius: 12px; padding: 12px;
  border: 1px solid rgba(255,255,255,0.1);
}
.game-result-value {
  font-size: 1.5rem; font-weight: 800; font-family: 'JetBrains Mono', monospace;
}
.game-result-label {
  font-size: 0.7rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px;
}
#gameOverHighScore { font-family: 'JetBrains Mono', monospace; }

/* === Falling Words === */
.falling-word {
  position: absolute; z-index: 5; white-space: nowrap;
  font-family: 'JetBrains Mono', monospace; font-size: 1.1rem; font-weight: 700;
  padding: 4px 14px; border-radius: 6px; cursor: default;
  background: rgba(255,255,255,0.08);
  color: #60a5fa;
  border: 1px solid rgba(96,165,250,0.2);
  transition: all 0.1s;
  user-select: none;
  letter-spacing: 1px;
  text-shadow: 0 0 8px rgba(96,165,250,0.3);
}
.falling-word.matched {
  background: rgba(34,197,94,0.2);
  color: #4ade80;
  border-color: rgba(34,197,94,0.4);
  text-shadow: 0 0 12px rgba(34,197,94,0.5);
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(34,197,94,0.15);
}
.falling-word.destroyed {
  animation: wordDestroy 0.35s ease forwards;
  pointer-events: none;
}
@keyframes wordDestroy {
  0% { transform: scale(1); opacity: 1; }
  40% { transform: scale(1.4); opacity: 0.7; box-shadow: 0 0 40px rgba(239,68,68,0.6); }
  100% { transform: scale(0); opacity: 0; }
}
.falling-word.danger {
  color: #f87171;
  border-color: rgba(248,113,113,0.4);
  text-shadow: 0 0 8px rgba(248,113,113,0.3);
}

/* === Floating Score === */
.floating-score {
  position: absolute; z-index: 15; pointer-events: none;
  font-family: 'JetBrains Mono', monospace; font-weight: 800; font-size: 1.2rem;
  color: #4ade80; animation: floatUp 0.8s ease forwards;
  text-shadow: 0 0 10px rgba(74,222,128,0.5);
}
.floating-score.missed {
  color: #f87171;
  text-shadow: 0 0 10px rgba(248,113,113,0.5);
}
@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-60px) scale(1.2); }
}

/* === Game Input === */
.game-input-card {
  background: var(--card-bg); border-radius: var(--radius); padding: 14px 18px;
  box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 10px;
}
.game-input-row {
  display: flex; gap: 10px; align-items: center;
}
.game-input-icon {
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); flex-shrink: 0;
}
#gameInput {
  font-family: 'JetBrains Mono', monospace; font-size: 1.15rem;
  border: 2px solid var(--border); border-radius: 10px;
  background: var(--bg); transition: all 0.2s;
  letter-spacing: 2px;
}
#gameInput:focus {
  border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
#gameInput:disabled { opacity: 0.5; cursor: not-allowed; }
#gameEnterBtn {
  border-radius: 10px; width: 46px; height: 42px; flex-shrink: 0;
}
.game-hint { flex: 1; }
.matched-word-badge {
  font-family: 'JetBrains Mono', monospace; font-size: 0.85rem;
  padding: 3px 10px; border-radius: 6px;
  background: rgba(34,197,94,0.12); color: #4ade80;
  border: 1px solid rgba(34,197,94,0.2); display: inline-block;
}

/* === Game Controls === */
.game-controls {
  background: var(--card-bg); border-radius: var(--radius); padding: 10px 16px;
  box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap;
}
.game-speed-indicator { font-size: 0.85rem; }

/* === High Scores === */
.game-history-card {
  background: var(--card-bg); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.game-history-card .history-table .badge { font-size: 0.7rem; }
.game-trophy-gold { color: #f59e0b; }
.game-trophy-silver { color: #94a3b8; }
.game-trophy-bronze { color: #d97706; }

/* === Responsive === */
@media (max-width: 768px) {
  .game-area { height: 380px; }
  .game-stats-bar { grid-template-columns: repeat(2, 1fr); }
  .game-stats-bar .game-stat-item:last-child { display: none; }
  .game-stat-value { font-size: 1.1rem; }
  .falling-word { font-size: 0.95rem; padding: 3px 10px; }
}
@media (max-width: 576px) {
  .game-area { height: 320px; }
  .game-input-card { padding: 10px 12px; }
  #gameInput { font-size: 1rem; letter-spacing: 1px; }
  .game-controls { flex-direction: column; align-items: stretch; }
  .mode-switcher .btn { font-size: 0.75rem; padding: 0.2rem 0.5rem; }
}

/* === Mode Switcher in Navbar === */
.mode-switcher { margin: 0 12px; }
.mode-switcher .btn { border-radius: 25px !important; padding: 0.55rem 1.5rem; font-size: 1rem; font-weight: 600; }
.mode-tab.active { cursor: default; }

/* === Danger zone line === */
.game-danger-line {
  position: absolute; bottom: 0; left: 0; right: 0; height: 40px;
  background: linear-gradient(0deg, rgba(239,68,68,0.12) 0%, transparent 100%);
  border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius);
  z-index: 2; pointer-events: none;
}
.game-danger-line::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 2px; background: rgba(239,68,68,0.3);
  box-shadow: 0 0 10px rgba(239,68,68,0.2);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-5px); }
  30%, 70% { transform: translateX(5px); }
}
#gameInput.shake {
  animation: shake 0.4s ease;
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.15) !important;
}

@keyframes levelFlash {
  0%, 100% { border-color: var(--border); box-shadow: none; }
  50% { border-color: #f59e0b; box-shadow: 0 0 0 4px rgba(245,158,11,0.2); }
}
#gameInput.level-up-flash {
  animation: levelFlash 0.6s ease 2;
}

/* === Global Leaderboard === */
.game-leaderboard-card {
  background: var(--card-bg); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 20px;
}
.lb-filters .lb-filter-btn {
  border: 1px solid var(--border); color: var(--text-muted);
  background: transparent; border-radius: 20px !important;
  padding: 0.2rem 0.75rem; font-size: 0.78rem; transition: all 0.2s;
}
.lb-filters .lb-filter-btn:hover {
  border-color: var(--current); color: var(--current);
}
.lb-filters .lb-filter-btn.active {
  background: var(--current); color: #fff; border-color: var(--current);
}
.lb-table th { white-space: nowrap; }
.lb-rank { font-size: 1rem; text-align: center; width: 40px; }
.lb-nickname { min-width: 100px; }
.lb-score {
  font-weight: 700; font-family: 'JetBrains Mono', monospace;
  color: var(--current);
}
.lb-date { color: var(--text-muted); font-size: 0.78rem; white-space: nowrap; }
.nickname-badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  background: rgba(37,99,235,0.08); color: var(--text);
  font-weight: 600; font-size: 0.85rem; max-width: 130px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#gameNickname {
  font-family: 'Inter', sans-serif; background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15); color: #fff;
  font-size: 0.9rem; text-align: center;
}
#gameNickname::placeholder { color: rgba(255,255,255,0.35); text-align: center; }
#gameNickname:focus {
  border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
  background: rgba(255,255,255,0.12);
}
[data-bs-theme="light"] .nickname-badge {
  background: rgba(37,99,235,0.06);
}

@media print {
  .ad-slot { display: none !important; }
}
