/* ============================================
   단어 카드 매칭 게임 — Premium Game UI
   ============================================ */

/* Game Overlay */
#game-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: #0f172a;
  z-index: 9999; display: none; flex-direction: column; align-items: center;
  overflow-y: auto; font-family: 'Montserrat', 'Lato', sans-serif;
}
#game-overlay.active { display: flex; }

/* Stars background */
#game-overlay::before {
  content: ''; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: radial-gradient(2px 2px at 20% 30%, rgba(255,255,255,0.3), transparent),
              radial-gradient(2px 2px at 40% 70%, rgba(255,255,255,0.2), transparent),
              radial-gradient(1px 1px at 60% 20%, rgba(255,255,255,0.4), transparent),
              radial-gradient(1px 1px at 80% 60%, rgba(255,255,255,0.15), transparent),
              radial-gradient(2px 2px at 10% 80%, rgba(255,255,255,0.25), transparent),
              radial-gradient(1px 1px at 90% 40%, rgba(255,255,255,0.3), transparent),
              radial-gradient(1px 1px at 50% 50%, rgba(255,255,255,0.2), transparent);
  pointer-events: none; z-index: 0;
  animation: starsTwinkle 4s ease-in-out infinite alternate;
}
@keyframes starsTwinkle { 0% { opacity: 0.5; } 100% { opacity: 1; } }

/* Close button */
.game-close {
  position: fixed; top: 16px; right: 20px; z-index: 10002;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  color: #fff; width: 44px; height: 44px; border-radius: 50%; font-size: 20px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
   transition: all 0.3s;
}
.game-close:hover { background: rgba(255,80,80,0.4); transform: rotate(90deg); }

/* ─── Difficulty Select Screen ─── */
.game-difficulty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; z-index: 1; gap: 30px; padding: 20px;
}
.game-difficulty h2 {
  font-size: 32px; color: #fff; font-weight: 800;
  text-shadow: none;
  margin: 0;
}
.game-difficulty p { color: rgba(255,255,255,0.6); margin: 0; font-size: 14px; }
.diff-cards { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; }
.diff-card {
  width: 180px; padding: 30px 20px; border-radius: 20px;
  text-align: center; cursor: pointer; transition: all 0.3s ease;
  border: 2px solid transparent; position: relative; overflow: hidden;
}
.diff-card::before {
  content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  opacity: 0; transition: opacity 0.3s;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.1), transparent 70%);
}
.diff-card:hover::before { opacity: 1; }
.diff-card:hover { transform: translateY(-8px) scale(1.02); }
.diff-card.easy {
  background: #059669;
  border-color: #34d399; box-shadow: 0 8px 32px rgba(52,211,153,0.3);
}
.diff-card.normal {
  background: #d97706;
  border-color: #fbbf24; box-shadow: 0 8px 32px rgba(251,191,36,0.3);
}
.diff-card.hard {
  background: #dc2626;
  border-color: #f87171; box-shadow: 0 8px 32px rgba(248,113,113,0.3);
}
.diff-card .diff-icon { font-size: 40px; margin-bottom: 12px; }
.diff-card .diff-name { font-size: 20px; font-weight: 700; color: #fff; margin-bottom: 6px; }
.diff-card .diff-info { font-size: 13px; color: rgba(255,255,255,0.75); line-height: 1.5; }

/* ─── Game Header ─── */
.game-header {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: 900px; padding: 16px 24px; z-index: 1;
  margin-top: 16px;
}
.game-timer {
  font-size: 36px; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums;
  text-shadow: none;
}
.game-timer.danger { color: #f87171; text-shadow: none; animation: timerPulse 0.5s ease infinite; }
@keyframes timerPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.1); } }

.game-score-area { text-align: right; }
.game-score-label { font-size: 12px; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 2px; }
.game-score-value { font-size: 40px; font-weight: 800; color: #fbbf24; text-shadow: none; }
.game-combo {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0);
  font-size: 48px; font-weight: 900; color: #ff6b35; z-index: 10003;
  text-shadow: none;
  pointer-events: none; opacity: 0; white-space: nowrap;
}
.game-combo.show {
  animation: comboPopup 1s ease forwards;
}
@keyframes comboPopup {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
  40% { transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(0.8); }
}
.game-speed-bonus {
  position: fixed; top: 40%; left: 50%; transform: translateX(-50%);
  font-size: 24px; font-weight: 700; color: #38bdf8; z-index: 10003;
  pointer-events: none; opacity: 0; text-shadow: none;
}
.game-speed-bonus.show { animation: speedBonus 1.2s ease forwards; }
@keyframes speedBonus {
  0% { opacity: 0; transform: translateX(-50%) translateY(0) scale(0.5); }
  20% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-60px) scale(0.7); }
}

/* ─── Game Board ─── */
.game-board {
  display: grid; gap: 10px; max-width: 900px; width: 100%;
  padding: 10px 20px; z-index: 1; justify-items: center;
  flex: 1; align-content: center;
}
.game-board.rows-2 { grid-template-columns: repeat(4, 1fr); }
.game-board.rows-3 { grid-template-columns: repeat(4, 1fr); }
.game-board.rows-4 { grid-template-columns: repeat(4, 1fr); gap: 8px; }

/* ─── Game Card ─── */
.game-card {
  width: 100%; max-width: 200px;
  perspective: 800px; cursor: pointer; position: relative;
  opacity: 0; transform: translateY(60px) scale(0.7);
}
/* Dynamic card height based on rows */
.rows-2 .game-card { height: calc((100vh - 140px) / 2 - 12px); }
.rows-3 .game-card { height: calc((100vh - 140px) / 3 - 12px); }
.rows-4 .game-card { height: calc((100vh - 140px) / 4 - 10px); }
.game-card.dealt {
  animation: dealIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes dealIn {
  0% { opacity: 0; transform: translateY(60px) scale(0.7) rotateY(180deg); }
  60% { opacity: 1; transform: translateY(-10px) scale(1.02) rotateY(20deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotateY(0deg); }
}

.game-card-inner {
  width: 100%; height: 100%; position: relative;
  transform-style: preserve-3d; transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 16px;
}
.game-card.flipped .game-card-inner { transform: rotateY(180deg); }

.game-card-face {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  backface-visibility: hidden; border-radius: 16px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  padding: 12px; text-align: center; box-sizing: border-box;
}

/* Card Back */
.game-card-back {
  background: url('card_back.png') center/cover, #1e293b;
  border: 2px solid rgba(255,215,0,0.3);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4), inset 0 0 30px rgba(255,215,0,0.05);
}

/* Card Front — English */
.game-card-front {
  transform: rotateY(180deg);
  border: 2px solid rgba(255,255,255,0.2);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.game-card.eng .game-card-front {
  background: url('card_eng.png') center/cover, #106bd6;
}
.game-card.kor .game-card-front {
  background: url('card_kor.png') center/cover, #7c3aed;
}
.game-card-text {
  font-weight: 700; color: #fff; z-index: 1; line-height: 1.3;
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
  word-break: keep-all;
}
.game-card.eng .game-card-text { font-size: 18px; }
.game-card.kor .game-card-text { font-size: 15px; }

/* Selection glow */
.game-card.selected .game-card-inner {
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  border-radius: 16px;
}
.game-card.selected .game-card-front {
  border-color: #38bdf8;
}

/* Match success */
.game-card.matched {
  animation: matchOut 0.6s ease forwards;
  pointer-events: none;
}
@keyframes matchOut {
  0% { transform: scale(1); opacity: 1; }
  30% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0); opacity: 0; }
}

/* Wrong shake */
.game-card.wrong .game-card-inner {
  animation: cardShake 0.5s ease;
}
.game-card.wrong .game-card-front {
  border-color: #ef4444 !important;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
@keyframes cardShake {
  0%,100% { transform: rotateY(180deg) translateX(0); }
  20% { transform: rotateY(180deg) translateX(-12px); }
  40% { transform: rotateY(180deg) translateX(12px); }
  60% { transform: rotateY(180deg) translateX(-8px); }
  80% { transform: rotateY(180deg) translateX(8px); }
}

/* ─── Particle Canvas ─── */
#game-particles {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 10001;
}

/* ─── Result Screen ─── */
.game-result {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  z-index: 10005; background: rgba(10,14,39,0.95); 
  gap: 20px; padding: 20px;
}
.game-result.active { display: flex; }
.game-result-title {
  font-size: 42px; font-weight: 900; color: #fff;
  text-shadow: none;
}
.game-result-title.victory { color: #fbbf24; text-shadow: none; }
.game-result-title.gameover { color: #f87171; text-shadow: none; }

.game-stars { display: flex; gap: 12px; margin: 10px 0; }
.game-star {
  font-size: 50px; opacity: 0.2; transition: all 0.5s;
  filter: grayscale(1);
}
.game-star.active {
  opacity: 1; filter: grayscale(0); animation: starPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes starPop {
  0% { transform: scale(0) rotate(-30deg); }
  60% { transform: scale(1.3) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.game-result-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  background: rgba(255,255,255,0.05); border-radius: 16px; padding: 24px;
  border: 1px solid rgba(255,255,255,0.1); min-width: 280px;
}
.game-stat { text-align: center; }
.game-stat-label { font-size: 11px; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 1px; }
.game-stat-value { font-size: 28px; font-weight: 800; color: #fff; margin-top: 4px; }
.game-stat-value.highlight { color: #fbbf24; }
.game-new-record {
  font-size: 18px; font-weight: 700; color: #f472b6;
  animation: recordPulse 1s ease infinite; display: none;
}
.game-new-record.show { display: block; }
@keyframes recordPulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.7; transform: scale(1.1); } }

.game-result-btns { display: flex; gap: 12px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }
.game-btn {
  padding: 14px 28px; border: none; border-radius: 12px; font-size: 16px;
  font-weight: 700; cursor: pointer; transition: all 0.3s;
  font-family: inherit;
}
.game-btn:hover { transform: translateY(-3px); }
.game-btn-primary {
  background: #3b82f6;
  color: #fff; box-shadow: 0 6px 24px rgba(59,130,246,0.4);
}
.game-btn-secondary {
  background: rgba(255,255,255,0.1); color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
}
.game-btn-close {
  background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.1);
}

/* ─── Responsive ─── */
@media (max-width: 600px) {
  .game-board { gap: 8px; padding: 10px; }
  .game-card.eng .game-card-text { font-size: 14px; }
  .game-card.kor .game-card-text { font-size: 12px; }
  .diff-card { width: 140px; padding: 20px 14px; }
  .game-result-title { font-size: 30px; }
}

.game-main-menu {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; width: 100%; z-index: 5; gap: 24px; padding: 30px 20px;
  position: relative; box-sizing: border-box;
  background: #0f172a;
}
.game-logo-area { text-align: center; }
.game-logo-icon {
  font-size: 64px; margin-bottom: 8px;
  animation: logoFloat 3s ease-in-out infinite;
}
@keyframes logoFloat {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
.game-logo-title {
  font-size: 40px; font-weight: 900; color: #fff; margin: 0;
  background: linear-gradient(135deg, #38bdf8, #a78bfa, #fbbf24);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.game-logo-sub {
  color: rgba(255,255,255,0.5); font-size: 14px; margin: 6px 0 0;
}
.game-word-info {
  font-size: 13px; font-weight: 600; margin-top: 10px;
}

/* Game Menu Grid */
.game-menu-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 16px; max-width: 600px; width: 100%;
}
.game-menu-card {
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px; padding: 28px 20px; text-align: center;
  position: relative; overflow: hidden; transition: all 0.3s ease;
  min-height: 160px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
}
.game-menu-card.playable {
  cursor: pointer;
  border-color: rgba(56,189,248,0.3);
  background: linear-gradient(135deg, rgba(56,189,248,0.08), rgba(167,139,250,0.08));
}
.game-menu-card.playable:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: rgba(56,189,248,0.6);
  box-shadow: 0 12px 40px rgba(56,189,248,0.2);
}
.game-menu-card.coming {
  opacity: 0.5; cursor: default;
}
.game-menu-badge {
  position: absolute; top: 12px; right: 12px;
  background: #3b82f6;
  color: #fff; font-size: 10px; font-weight: 800; padding: 4px 10px;
  border-radius: 20px; letter-spacing: 1px;
}
.game-menu-badge.coming-badge {
  background: #4b5563;
}
.game-menu-icon { font-size: 44px; }
.game-menu-name { font-size: 18px; font-weight: 800; color: #fff; }
.game-menu-desc { font-size: 12px; color: rgba(255,255,255,0.5); line-height: 1.5; }

/* Back Button */
.game-back-btn {
  position: absolute; top: 20px; left: 20px;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  color: #fff; padding: 8px 16px; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all 0.3s; font-family: inherit; z-index: 10;
}
.game-back-btn:hover {
  background: rgba(255,255,255,0.2); transform: translateX(-4px);
}

/* ─── Sub-Game Screen (shared) ─── */
.sub-game-screen {
  display: flex; flex-direction: column; align-items: center;
  width: 100%; height: 100vh; z-index: 2; padding: 16px; box-sizing: border-box;
  position: relative;
}
.sub-end-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(10,14,39,0.95); 
  z-index: 10005; gap: 16px;
}

/* ─── ⚡ Speed Quiz ─── */
.sq-header {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: 600px; color: #fff; font-weight: 700;
  font-size: 16px; margin-top: 40px;
}
.sq-combo-display {
  color: #ff6b35; font-size: 24px; font-weight: 900; height: 32px;
  text-shadow: none;
}
.sq-timer-track {
  width: 100%; max-width: 600px; height: 8px; background: rgba(255,255,255,0.1);
  border-radius: 4px; margin: 12px 0; overflow: hidden;
}
.sq-timer-bar {
  height: 100%; width: 100%; border-radius: 4px;
  transition: width 0.1s linear, background 0.3s;
}
.sq-word {
  font-size: 48px; font-weight: 900; color: #fff; margin: 20px 0;
  text-shadow: none;
}
.sq-choices {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  width: 100%; max-width: 600px;
}
.sq-choice {
  padding: 18px 16px; border: 2px solid rgba(255,255,255,0.15);
  border-radius: 14px; background: rgba(255,255,255,0.05);
  color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; font-family: inherit; text-align: center;
  word-break: keep-all;
}
.sq-choice:hover { border-color: rgba(56,189,248,0.5); background: rgba(56,189,248,0.1); }
.sq-choice.sq-correct {
  border-color: #34d399 !important; background: rgba(52,211,153,0.2) !important;
  color: #34d399 !important;
}
.sq-choice.sq-wrong {
  border-color: #f87171 !important; background: rgba(248,113,113,0.2) !important;
  color: #f87171 !important;
}

/* ─── 🎯 Word Shooter ─── */
.ws-header {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; color: #fff; font-weight: 700; font-size: 14px;
  margin-top: 40px; padding: 0 8px;
}
.ws-meaning {
  font-size: 22px; font-weight: 800; color: #fbbf24;
  text-shadow: none;
  text-align: center; flex: 1;
}
.ws-canvas-wrap { flex: 1; width: 100%; position: relative; }

/* ─── 🔤 Hangman ─── */
.hm-header {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: 500px; color: #fff; font-weight: 700;
  font-size: 14px; margin-top: 40px;
}
.hm-body {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; flex: 1; justify-content: center;
}
#hm-canvas { background: transparent; }
.hm-meaning {
  font-size: 18px; color: #fbbf24; font-weight: 700;
  text-shadow: none;
}
.hm-word {
  font-size: 36px; font-weight: 900; color: #fff; letter-spacing: 6px;
  font-family: 'Courier New', monospace;
  text-shadow: none;
}
.hm-keyboard {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 6px; max-width: 500px; padding: 12px 0 20px;
}
.hm-key {
  width: 38px; height: 42px; border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px; background: rgba(255,255,255,0.08);
  color: #fff; font-size: 16px; font-weight: 700; cursor: pointer;
  transition: all 0.2s; font-family: inherit;
}
.hm-key:hover:not(:disabled) { background: rgba(56,189,248,0.2); border-color: #38bdf8; }
.hm-key:disabled { opacity: 0.3; cursor: default; }
.hm-key-correct {
  background: rgba(52,211,153,0.3) !important;
  border-color: #34d399 !important; color: #34d399 !important;
}
.hm-key-wrong {
  background: rgba(248,113,113,0.2) !important;
  border-color: #f87171 !important; color: #f87171 !important;
}

/* ─── Responsive for new games ─── */
@media (max-width: 600px) {
  .sq-word { font-size: 32px; }
  .sq-choices { grid-template-columns: 1fr; }
  .sq-choice { padding: 14px; font-size: 14px; }
  .hm-word { font-size: 24px; letter-spacing: 4px; }
  .hm-key { width: 30px; height: 36px; font-size: 13px; }
  .ws-meaning { font-size: 16px; }
}

/* ─── 🔥 FX System ─── */
.fx-impact {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 64px; font-weight: 900; z-index: 99998;
  pointer-events: none; text-shadow: 0 4px 20px rgba(0,0,0,0.5);
  animation: fxImpactIn 1.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  font-family: 'Montserrat', sans-serif;
}
.fx-failed {
  text-shadow: none;
  animation: fxFailedIn 1.5s ease forwards;
}
.fx-victory {
  text-shadow: none;
}
@keyframes fxImpactIn {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-10deg); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.6) rotate(3deg); opacity: 1; }
  30% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
}
@keyframes fxFailedIn {
  0% { transform: translate(-50%, -50%) scale(3); opacity: 0; }
  10% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  15% { transform: translate(-50%, -50%) scale(1) rotate(2deg); }
  20% { transform: translate(-50%, -50%) scale(1) rotate(-2deg); }
  25% { transform: translate(-50%, -50%) scale(1) rotate(1deg); }
  30% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
}

/* Bomb */
.fx-bomb {
  position: fixed; bottom: 30px; right: 30px;
  font-size: 56px; z-index: 99998; pointer-events: none;
  transition: transform 0.15s, filter 0.15s;
  filter: drop-shadow(0 0 20px rgba(255,100,0,0.8));
  animation: fxBombPulse 0.6s ease infinite;
}
@keyframes fxBombPulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ═══════════════════════════════════════
   LEVEL SELECT BAR
   ═══════════════════════════════════════ */
.level-bar {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  margin: 12px 0 8px; padding: 0 20px;
}
.level-btn {
  padding: 8px 16px; border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px; background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7); font-size: 13px; font-weight: 700;
  cursor: pointer; transition: all 0.25s; font-family: inherit;
}
.level-btn:hover { border-color: rgba(56,189,248,0.5); color: #fff; background: rgba(56,189,248,0.12); }
.level-btn.active {
  background: #3b82f6;
  border-color: #60a5fa; color: #fff;
  box-shadow: 0 4px 16px rgba(59,130,246,0.4);
}

/* ─── Card Matching Start Screen ─── */
.cm-rules {
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px; padding: 24px 28px; max-width: 480px; width: 100%;
  display: flex; flex-direction: column; gap: 10px; margin: 16px 0;
}
.cm-rule-item {
  font-size: 15px; color: rgba(255,255,255,0.8); line-height: 1.5;
}
.cm-rule-item b { color: #fbbf24; }
.cm-start-btn {
  padding: 18px 64px; border: none; border-radius: 16px;
  font-size: 24px; font-weight: 900; cursor: pointer;
  background: #3b82f6;
  color: #fff; letter-spacing: 4px; margin-top: 12px;
  box-shadow: 0 8px 32px rgba(59,130,246,0.5);
  transition: all 0.3s; font-family: inherit;
  animation: startPulse 2s ease-in-out infinite;
}
.cm-start-btn:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 12px 40px rgba(59,130,246,0.7);
}
@keyframes startPulse {
  0%,100% { box-shadow: 0 8px 32px rgba(59,130,246,0.5); }
  50% { box-shadow: 0 8px 48px rgba(59,130,246,0.8), 0 0 20px rgba(59,130,246,0.3); }
}

/* ═══════════════════════════════════════
   CARD MATCHING — LEFT/RIGHT ARENA
   ═══════════════════════════════════════ */
.cm-arena {
  display: flex; align-items: center; justify-content: center;
  gap: 24px; flex: 1; width: 100%; max-width: 800px;
  padding: 10px 20px; z-index: 1;
}
.cm-col { display: flex; flex-direction: column; gap: 12px; flex: 1; max-width: 320px; }
.cm-vs {
  font-size: 32px; font-weight: 900; color: rgba(255,255,255,0.2);
  text-shadow: none; letter-spacing: 4px;
}

/* Card in arena */
.cm-card {
  padding: 18px 16px; border: 2px solid rgba(255,255,255,0.15);
  border-radius: 16px; cursor: pointer; transition: all 0.25s;
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 60px;
}
.cm-card .cm-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255,255,255,0.12); display: flex;
  align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: rgba(255,255,255,0.6);
  flex-shrink: 0;
}
.cm-card .cm-label {
  font-weight: 700; color: #fff; font-size: 18px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3); flex: 1;
  word-break: keep-all;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* English cards (left) */
.cm-col-eng .cm-card {
  background: linear-gradient(135deg, rgba(16,107,214,0.3), rgba(45,142,255,0.15));
  border-color: rgba(59,130,246,0.3);
}
.cm-col-eng .cm-card:hover { border-color: rgba(59,130,246,0.7); background: rgba(59,130,246,0.2); }
.cm-col-eng .cm-card .cm-num { background: rgba(59,130,246,0.3); color: #93c5fd; }
.cm-col-eng .cm-card .cm-label { font-size: 20px; font-family: 'Montserrat', sans-serif; }

/* Korean cards (right) */
.cm-col-kr .cm-card {
  background: linear-gradient(135deg, rgba(124,58,237,0.3), rgba(168,85,247,0.15));
  border-color: rgba(167,139,250,0.3);
}
.cm-col-kr .cm-card:hover { border-color: rgba(167,139,250,0.7); background: rgba(167,139,250,0.2); }
.cm-col-kr .cm-card .cm-num { background: rgba(167,139,250,0.3); color: #c4b5fd; }

/* Selection state */
.cm-card.cm-selected {
  border-color: #38bdf8 !important;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  transform: scale(1.03);
}
.cm-card.cm-selected .cm-num {
  background: #38bdf8; color: #0a0e27;
}

/* Correct answer — highlighted, stays visible */
.cm-card.cm-correct {
  border-color: #34d399 !important;
  background: rgba(52,211,153,0.25) !important;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  animation: cmCorrectPulse 0.6s ease;
  pointer-events: none;
}
.cm-card.cm-correct .cm-num {
  background: #34d399 !important; color: #0a0e27 !important;
}
.cm-card.cm-correct .cm-label {
  color: #fff !important; font-weight: 800;
}
@keyframes cmCorrectPulse {
  0% { transform: scale(1); }
  30% { transform: scale(1.08); }
  60% { transform: scale(1.03); }
  100% { transform: scale(1.05); }
}

/* Correct match fade-out */
.cm-card.cm-matched {
  animation: cmMatchOut 0.5s ease forwards;
  pointer-events: none;
}
@keyframes cmMatchOut {
  0% { transform: scale(1.05); opacity: 1; border-color: #34d399; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
  50% { transform: scale(1.1); opacity: 0.8; }
  100% { transform: scale(0.8); opacity: 0; height: 0; min-height: 0; padding: 0; margin: 0; border: 0; }
}

/* Gravity drop: existing cards shift down */
@keyframes cmGravityDrop {
  0% { transform: translateY(-100%); opacity: 0.7; }
  60% { transform: translateY(5px); opacity: 1; }
  100% { transform: translateY(0); opacity: 1; }
}

/* New card slides in from top */
@keyframes cmSlideDown {
  0% { transform: translateY(-120%); opacity: 0; }
  50% { opacity: 1; }
  70% { transform: translateY(8px); }
  100% { transform: translateY(0); opacity: 1; }
}

/* Card flip-out: card flips to back (face-down) */
.cm-card.cm-flip-out {
  animation: cmFlipOut 0.35s ease-in forwards;
  pointer-events: none;
}
@keyframes cmFlipOut {
  0% { transform: perspective(600px) rotateY(0deg); opacity: 1; }
  100% { transform: perspective(600px) rotateY(90deg); opacity: 0.5; }
}

/* Card flip-in: card flips from back to front (reveal) */
.cm-card.cm-flip-in {
  animation: cmFlipIn 0.45s ease-out forwards;
  pointer-events: none;
}
@keyframes cmFlipIn {
  0% { transform: perspective(600px) rotateY(-90deg); opacity: 0.5; }
  60% { transform: perspective(600px) rotateY(5deg); opacity: 1; }
  100% { transform: perspective(600px) rotateY(0deg); opacity: 1; }
}

.cm-new-card {
  border-color: #60a5fa !important;
  box-shadow: 0 0 12px rgba(96, 165, 250, 0.4) !important;
}

/* Wrong shake (9 times — 3x intensity) */
.cm-card.cm-wrong {
  animation: cmShake3 1.8s ease;
  border-color: #ef4444 !important;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
@keyframes cmShake3 {
  0%   { transform: translateX(0); }
  3%   { transform: translateX(-16px); }
  6%   { transform: translateX(16px); }
  9%   { transform: translateX(-16px); }
  12%  { transform: translateX(14px); }
  15%  { transform: translateX(-14px); }
  18%  { transform: translateX(14px); }
  21%  { transform: translateX(-12px); }
  24%  { transform: translateX(12px); }
  27%  { transform: translateX(-12px); }
  30%  { transform: translateX(10px); }
  33%  { transform: translateX(-10px); }
  36%  { transform: translateX(10px); }
  39%  { transform: translateX(-8px); }
  42%  { transform: translateX(8px); }
  45%  { transform: translateX(-8px); }
  48%  { transform: translateX(6px); }
  51%  { transform: translateX(-6px); }
  54%  { transform: translateX(6px); }
  57%  { transform: translateX(-4px); }
  60%  { transform: translateX(4px); }
  63%  { transform: translateX(-4px); }
  66%  { transform: translateX(3px); }
  69%  { transform: translateX(-3px); }
  72%  { transform: translateX(2px); }
  75%  { transform: translateX(-2px); }
  78%  { transform: translateX(1px); }
  81%  { transform: translateX(-1px); }
  100% { transform: translateX(0); }
}

/* WRONG overlay (X animation) */
.cm-wrong-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  display: none; align-items: center; justify-content: center;
  flex-direction: column; z-index: 10004; pointer-events: none;
}
.cm-wrong-overlay.active { display: flex; animation: cmWrongFade 1s ease forwards; }
@keyframes cmWrongFade {
  0% { opacity: 0; }
  15% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}
.cm-wrong-x {
  font-size: 120px; font-weight: 900; color: #ef4444;
  text-shadow: none;
  animation: cmXIn 0.4s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
@keyframes cmXIn {
  0% { transform: scale(0) rotate(-45deg); opacity: 0; }
  50% { transform: scale(1.3) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.cm-wrong-text {
  font-size: 36px; font-weight: 900; color: #ef4444;
  text-shadow: none;
  letter-spacing: 6px; margin-top: -10px;
}

/* ═══════════════════════════════════════
   MC QUIZ (객관식)
   ═══════════════════════════════════════ */
.mc-header {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: 600px; color: #fff; font-weight: 700;
  font-size: 16px; margin-top: 50px;
}
.mc-timer-area { flex: 1; max-width: 300px; }
.mc-timer-track {
  width: 100%; height: 10px; background: rgba(255,255,255,0.1);
  border-radius: 5px; overflow: hidden;
}
.mc-timer-bar {
  height: 100%; width: 100%; border-radius: 5px;
  background: #3b82f6;
  transition: width 0.1s linear, background 0.3s;
}
.mc-score-label {
  position: absolute; top: 20px; right: 20px;
  background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1);
  padding: 8px 16px; border-radius: 10px; font-weight: 800; font-size: 16px; color: #fbbf24;
}
.mc-word {
  font-size: 53px; font-weight: 900; color: #fff; margin: 40px 0 8px;
  text-shadow: none;
  cursor: pointer; transition: all 0.2s; z-index: 1;
}
.mc-word:hover { color: #38bdf8; text-shadow: none; }
.mc-audio-btns {
  display: flex; gap: 10px; margin-bottom: 24px; z-index: 1;
}
.mc-audio-btn {
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2);
  color: #94a3b8; font-size: 13px; padding: 6px 14px; border-radius: 20px;
  cursor: pointer; transition: all 0.2s;
}
.mc-audio-btn:hover {
  background: rgba(255, 255, 255, 0.2); color: #fff; border-color: rgba(255, 255, 255, 0.4);
}
.mc-choices {
  display: flex; flex-direction: column; gap: 12px;
  width: 100%; max-width: 500px; z-index: 1;
}
.mc-choice {
  padding: 16px 20px; border: 2px solid rgba(255,255,255,0.15);
  border-radius: 14px; background: rgba(255,255,255,0.05);
  color: #fff; font-size: 17px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; font-family: inherit; text-align: left;
  display: flex; align-items: center; gap: 12px;
}
.mc-choice .mc-choice-num {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.1); display: flex;
  align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; color: rgba(255,255,255,0.6);
  flex-shrink: 0;
}
.mc-choice:hover { border-color: rgba(56,189,248,0.5); background: rgba(56,189,248,0.1); }
.mc-choice.mc-correct {
  border-color: #34d399 !important; background: rgba(52,211,153,0.2) !important;
  color: #34d399 !important; animation: mcCorrectPulse 0.5s ease;
}
.mc-choice.mc-correct .mc-choice-num { background: #34d399; color: #0a0e27; }
@keyframes mcCorrectPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
.mc-choice.mc-wrong {
  border-color: #ef4444 !important; background: rgba(248,113,113,0.2) !important;
  color: #f87171 !important; animation: cmShake3 0.6s ease;
}
.mc-choice.mc-wrong .mc-choice-num { background: #ef4444; color: #fff; }
.mc-score-label { color: #fbbf24; font-weight: 800; }

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

@media (max-width: 600px) {
  .cm-arena { flex-direction: column; gap: 12px; }
  .cm-vs { font-size: 20px; }
  .cm-card .cm-label { font-size: 16px; }
  .cm-col-eng .cm-card .cm-label { font-size: 17px; }
  .level-btn { padding: 6px 12px; font-size: 11px; }
  .mc-word { font-size: 37px; }
  .mc-choice { padding: 12px 16px; font-size: 15px; }
}

/* ═══ Ready, Set, Go! Countdown ═══ */
.countdown-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7); z-index: 99998;
}
.countdown-text {
  font-size: 96px; font-weight: 900; color: #3b82f6;
  text-shadow: 0 4px 30px rgba(59,130,246,0.6);
  font-family: 'Montserrat', sans-serif;
  opacity: 0; transform: scale(0.3);
}
.countdown-text.cd-pop {
  animation: cdPop 0.7s ease forwards;
}
@keyframes cdPop {
  0% { opacity: 0; transform: scale(0.3); }
  40% { opacity: 1; transform: scale(1.2); }
  70% { transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1); }
}

/* ═══ Hint Bulb ═══ */
.hint-bulb {
  position: absolute; top: 2px; right: 2px;
  font-size: 30px; line-height: 1; display: none;
  animation: hintBlink 0.6s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 8px rgba(255,200,0,0.9)) drop-shadow(0 0 16px rgba(255,180,0,0.5));
  z-index: 200; pointer-events: none;
}
@keyframes hintBlink {
  0% { opacity: 0.4; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1.1); }
}
.cm-hint-glow {
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  border-color: #fbbf24 !important;
  animation: hintPulse 1s ease-in-out infinite;
}
@keyframes hintPulse {
  0%, 100% { box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
  50% { box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
}

/* ═══ MC Quiz Example ═══ */
.mc-word.has-example {
  font-size: 25px; font-weight: 500; color: #f1f5f9;
  text-shadow: none; max-width: 90%; line-height: 1.5;
  margin: 30px auto 20px;
}
.mc-highlight-main {
  font-size: 56px; font-weight: 900; color: #3b82f6;
  text-shadow: none;
  margin: 0 6px; vertical-align: middle;
}

/* ═══ Time Over Impact ═══ */
.fx-timeover {
  color: #f59e0b !important;
  text-shadow: none;
}

/* ============================================================
   COMPREHENSIVE GAME RESPONSIVE LAYOUT
   ============================================================ */

/* ─── Tablet (≤900px) ─── */
@media (max-width: 900px) {
  .game-main-menu { padding: 20px 12px; gap: 16px; }
  .game-logo-title { font-size: 32px; }
  .game-logo-icon { font-size: 48px; }
  .game-menu-grid { gap: 12px; }
  .game-menu-card { min-height: 140px; padding: 20px 16px; }
  .game-menu-icon { font-size: 36px; }
  .game-menu-name { font-size: 16px; }
  .game-menu-desc { font-size: 11px; }
  .level-bar { gap: 6px; padding: 0 12px; }
  .cm-arena { gap: 16px; padding: 8px 12px; max-width: 100%; }
  .game-header { max-width: 100%; padding: 12px 16px; }
  .game-timer { font-size: 28px; }
  .game-score-value { font-size: 30px; }
}

/* ─── Mobile (≤600px) — extends existing rules ─── */
@media (max-width: 600px) {
  /* Main menu */
  .game-main-menu { padding: 16px 8px; gap: 12px; }
  .game-logo-title { font-size: 24px; }
  .game-logo-icon { font-size: 40px; margin-bottom: 4px; }
  .game-logo-sub { font-size: 12px; }
  .game-word-info { font-size: 11px; }
  .game-menu-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    max-width: 100%;
  }
  .game-menu-card {
    min-height: auto;
    padding: 18px 16px;
  }
  .game-menu-icon { font-size: 32px; }
  .game-menu-name { font-size: 16px; }
  .game-menu-desc { font-size: 11px; line-height: 1.4; }
  .game-menu-badge { font-size: 9px; padding: 3px 8px; }

  /* Level bar — wrap onto multiple rows on mobile */
  .level-bar {
    gap: 6px;
    padding: 0 8px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
  }
  .level-btn {
    flex: 0 1 auto;
    padding: 7px 12px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* Game menu cards — keep 2-column on mobile */
  .game-menu-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    max-width: 100%;
    padding: 0 4px;
  }
  .game-menu-card {
    padding: 14px 10px;
    min-height: 130px;
  }
  .game-menu-icon { font-size: 28px; }
  .game-menu-name { font-size: 14px; }
  .game-menu-desc { font-size: 10px; }
  .game-menu-badge { font-size: 9px; padding: 3px 7px; top: 8px; right: 8px; }

  /* Game header */
  .game-header { padding: 10px 12px; margin-top: 8px; }
  .game-timer { font-size: 22px; }
  .game-score-label { font-size: 10px; letter-spacing: 1px; }
  .game-score-value { font-size: 24px; }
  .game-back-btn { padding: 6px 10px; font-size: 12px; top: 12px; left: 12px; }

  /* Card matching arena — fill screen on mobile */
  .cm-arena {
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    gap: 4px;
    padding: 2px 4px;
    max-width: 100%;
    box-sizing: border-box;
    flex: 1;
    overflow: visible;
  }
  .cm-col {
    flex: 1 1 0;
    max-width: 50%;
    gap: 4px;
    min-width: 0;
    justify-content: stretch;
  }
  .cm-vs {
    display: none;
  }
  .cm-card {
    padding: 6px 8px;
    min-height: 0;
    border-radius: 8px;
    gap: 0;
    flex: 1;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
  }
  .cm-card .cm-num {
    width: 20px; height: 20px;
    font-size: 9px;
    position: absolute;
    top: 4px;
    left: 4px;
  }
  .cm-card .cm-label {
    font-size: 18px;
    line-height: 1.2;
    text-align: center;
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .cm-col-eng .cm-card .cm-label { font-size: 19px; }

  /* Header spacing */
  #game-play {
    padding: 0;
    box-sizing: border-box;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
  }
  .game-header { margin-bottom: 0; padding: 4px 8px; }

  /* Card matching start screen */
  .game-difficulty { gap: 16px; padding: 16px 12px; }
  .game-difficulty h2 { font-size: 24px; }
  .cm-rules { padding: 16px 18px; gap: 8px; }
  .cm-rule-item { font-size: 13px; line-height: 1.4; }
  .cm-start-btn {
    padding: 14px 40px;
    font-size: 18px;
    letter-spacing: 2px;
  }

  /* Result screen */
  .game-result { padding: 16px; gap: 16px; }
  .game-result-title { font-size: 28px; }
  .game-result-stats {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 16px;
    min-width: 0;
    width: 100%;
    max-width: 320px;
  }
  .game-stat-value { font-size: 22px; }
  .game-stat-label { font-size: 10px; }
  .game-result-btns { gap: 8px; flex-direction: column; width: 100%; max-width: 280px; }
  .game-btn { padding: 12px 20px; font-size: 14px; width: 100%; }

  /* MC Quiz */
  .mc-header { font-size: 13px; margin-top: 56px; padding: 0 8px; }
  .mc-word { font-size: 33px; margin: 24px 0 6px; word-wrap: break-word; }
  .mc-word.has-example { font-size: 17px; margin: 20px auto 12px; line-height: 1.4; }
  .mc-highlight-main { font-size: 32px; margin: 0 4px; word-wrap: break-word; }
  .mc-audio-btns { margin-bottom: 16px; flex-wrap: wrap; justify-content: center; }
  .mc-audio-btn { font-size: 12px; padding: 5px 12px; }
  .mc-choice { padding: 12px 14px; font-size: 14px; gap: 8px; }
  .mc-choice .mc-choice-num { width: 26px; height: 26px; font-size: 12px; }
  .mc-timer-track { height: 8px; }

  /* Speed Quiz */
  .sq-header { font-size: 13px; margin-top: 56px; padding: 0 8px; }
  .sq-word { font-size: 28px; margin: 16px 0; }
  .sq-choices { grid-template-columns: 1fr; gap: 8px; }
  .sq-choice { padding: 14px 12px; font-size: 13px; }
  .sq-combo-display { font-size: 18px; height: 24px; }

  /* Word Shooter */
  .ws-header { font-size: 12px; margin-top: 56px; padding: 0 8px; }
  .ws-meaning { font-size: 14px; }

  /* Hangman */
  .hm-header { font-size: 12px; margin-top: 56px; padding: 0 8px; }
  .hm-meaning { font-size: 14px; }
  .hm-word { font-size: 22px; letter-spacing: 3px; }
  #hm-canvas { width: 220px; height: 180px; }
  .hm-keyboard { gap: 4px; padding: 8px 4px 16px; max-width: 100%; }
  .hm-key { width: 28px; height: 34px; font-size: 12px; border-radius: 6px; }

  /* Sub-game screens */
  .sub-game-screen { padding: 12px 8px; }

  /* Countdown overlay */
  .countdown-text { font-size: 64px; }

  /* Wrong overlay */
  .cm-wrong-x { font-size: 80px; }
  .cm-wrong-text { font-size: 24px; letter-spacing: 4px; }

  /* Hint bulb (smaller) */
  .hint-bulb { font-size: 22px; top: 2px; right: 2px; }

  /* Score float text */
  .game-combo { font-size: 28px; }
  .game-speed-bonus { font-size: 18px; }
}

/* ─── Small mobile (≤400px) ─── */
@media (max-width: 400px) {
  .game-logo-title { font-size: 20px; }
  .game-menu-card { padding: 14px 12px; }
  .game-menu-name { font-size: 14px; }
  .game-menu-desc { font-size: 10px; }
  .level-btn { padding: 5px 8px; font-size: 10px; }

  .cm-card { padding: 4px 6px; min-height: 0; }
  .cm-card .cm-label { font-size: 16px; }
  .cm-col-eng .cm-card .cm-label { font-size: 17px; }

  .mc-word { font-size: 27px; }
  .sq-word { font-size: 24px; }

  .hm-key { width: 24px; height: 30px; font-size: 11px; }
  #hm-canvas { width: 180px; height: 150px; }

  .game-timer { font-size: 18px; }
  .game-score-value { font-size: 20px; }
  .game-back-btn { padding: 5px 8px; font-size: 11px; }
}

/* ─── Landscape mobile (low height) ─── */
@media (max-height: 500px) and (orientation: landscape) {
  .game-main-menu { gap: 8px; padding: 12px; min-height: auto; }
  .game-logo-area { display: flex; align-items: center; gap: 12px; }
  .game-logo-icon { font-size: 32px; margin: 0; }
  .game-logo-title { font-size: 22px; }
  .game-logo-sub { font-size: 11px; }
  .game-menu-grid { grid-template-columns: repeat(3, 1fr); }
  .game-menu-card { min-height: 100px; padding: 12px; }
  .game-menu-icon { font-size: 24px; }
  .game-menu-name { font-size: 13px; }
  .game-menu-desc { font-size: 10px; }
}

/* ─── Touch devices: bigger tap targets + disable sticky hover ─── */
@media (hover: none) and (pointer: coarse) {
  .cm-card, .mc-choice, .sq-choice, .level-btn, .game-btn, .game-back-btn, .hm-key {
    min-height: 40px;
  }
  .game-menu-card.playable { min-height: 110px; }

  /* Prevent sticky :hover on touch devices */
  .mc-choice:hover {
    border-color: rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.05);
  }
  .cm-col-eng .cm-card:hover {
    border-color: rgba(59,130,246,0.3);
    background: linear-gradient(135deg, rgba(16,107,214,0.3), rgba(45,142,255,0.15));
  }
  .cm-col-kr .cm-card:hover {
    border-color: rgba(167,139,250,0.3);
    background: linear-gradient(135deg, rgba(124,58,237,0.3), rgba(168,85,247,0.15));
  }
  .sq-choice:hover {
    border-color: rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.05);
  }
}

/* ═══════════════════════════════════════
   RANKING BOARD
   ═══════════════════════════════════════ */
.ranking-modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 20000; display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: scale(0.95);
  transition: opacity 0.3s, transform 0.3s;
}
.ranking-modal.show {
  opacity: 1; transform: scale(1);
}
.ranking-backdrop {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(6px);
}
.ranking-content {
  position: relative; z-index: 1;
  background: linear-gradient(145deg, #1a1f3a, #0f1428);
  border: 1px solid rgba(255,215,0,0.2);
  border-radius: 20px; padding: 0;
  width: 90%; max-width: 440px; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 40px rgba(251,191,36,0.08);
  overflow: hidden;
}

/* Header */
.ranking-header {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 18px 20px 10px;
  position: relative;
  background: linear-gradient(135deg, rgba(251,191,36,0.12), rgba(245,158,11,0.05));
  border-bottom: 1px solid rgba(255,215,0,0.1);
}
.ranking-crown {
  font-size: 28px;
  animation: crownBounce 2s ease-in-out infinite;
}
@keyframes crownBounce {
  0%,100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-4px) rotate(-5deg); }
  75% { transform: translateY(-4px) rotate(5deg); }
}
.ranking-title {
  font-size: 20px; font-weight: 900; color: #fbbf24;
  letter-spacing: 1px;
}
.ranking-close {
  position: absolute; right: 14px; top: 14px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.6); width: 32px; height: 32px;
  border-radius: 50%; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.ranking-close:hover {
  background: rgba(248,113,113,0.3); color: #fff;
}

/* My Rank Highlight */
.ranking-my-rank {
  text-align: center; padding: 14px 20px;
  background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(167,139,250,0.1));
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: baseline; justify-content: center; gap: 8px;
}
.my-rank-label {
  font-size: 13px; color: rgba(255,255,255,0.5); font-weight: 600;
}
.my-rank-value {
  font-size: 36px; font-weight: 900; color: #fbbf24;
  text-shadow: 0 2px 12px rgba(251,191,36,0.4);
}
.my-rank-total {
  font-size: 14px; color: rgba(255,255,255,0.4); font-weight: 500;
}

/* Ranking List */
.ranking-list {
  flex: 1; overflow-y: auto; padding: 0 16px;
  max-height: 50vh;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.ranking-list::-webkit-scrollbar { width: 4px; }
.ranking-list::-webkit-scrollbar-track { background: transparent; }
.ranking-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.rank-header-row {
  display: flex; padding: 10px 12px 6px; gap: 12px;
  font-size: 11px; color: rgba(255,255,255,0.4);
  font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky; top: 0; background: #151a30; z-index: 1;
}
.rank-row {
  display: flex; padding: 9px 12px; gap: 12px;
  align-items: center; border-radius: 8px;
  transition: background 0.2s;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.rank-row:hover {
  background: rgba(255,255,255,0.04);
}

/* My row highlight */
.rank-row.rank-me {
  background: linear-gradient(135deg, rgba(251,191,36,0.15), rgba(245,158,11,0.08));
  border: 1px solid rgba(251,191,36,0.3);
  border-radius: 10px;
  animation: rankMePulse 2s ease-in-out infinite;
  position: relative;
}
.rank-row.rank-me::before {
  content: '▶'; position: absolute; left: -4px;
  color: #fbbf24; font-size: 10px; font-weight: 900;
}
@keyframes rankMePulse {
  0%,100% { box-shadow: 0 0 0px rgba(251,191,36,0); }
  50% { box-shadow: 0 0 12px rgba(251,191,36,0.2); }
}

.rank-pos {
  width: 48px; text-align: center; font-weight: 800;
  color: rgba(255,255,255,0.7); font-size: 14px; flex-shrink: 0;
}
.rank-me .rank-pos { color: #fbbf24; }
.rank-medal { font-size: 20px; }

.rank-name {
  flex: 1; color: rgba(255,255,255,0.85); font-weight: 600;
  font-size: 14px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
.rank-me .rank-name { color: #fbbf24; font-weight: 800; }

.rank-score {
  width: 80px; text-align: right; color: rgba(255,255,255,0.6);
  font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.rank-me .rank-score { color: #fbbf24; }

/* Pagination */
.ranking-pagination {
  display: flex; gap: 4px; justify-content: center;
  padding: 12px 16px 8px; flex-wrap: wrap;
}
.rank-page-btn {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.6);
  font-size: 12px; font-weight: 700; cursor: pointer;
  transition: all 0.2s; font-family: inherit;
  display: flex; align-items: center; justify-content: center;
}
.rank-page-btn:hover {
  border-color: rgba(56,189,248,0.5); color: #fff;
  background: rgba(56,189,248,0.1);
}
.rank-page-btn.active {
  background: #3b82f6; border-color: #60a5fa; color: #fff;
}

/* Footer */
.ranking-footer {
  padding: 8px 16px 16px; text-align: center;
}
.rank-goto-btn {
  padding: 10px 24px; border: 1px solid rgba(251,191,36,0.3);
  border-radius: 10px; background: rgba(251,191,36,0.08);
  color: #fbbf24; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.rank-goto-btn:hover {
  background: rgba(251,191,36,0.15);
  border-color: rgba(251,191,36,0.5);
}

/* Mobile */
@media (max-width: 480px) {
  .ranking-content { width: 95%; max-width: 100%; border-radius: 16px; }
  .ranking-title { font-size: 17px; }
  .my-rank-value { font-size: 30px; }
  .rank-row { padding: 8px 10px; }
  .rank-pos { width: 40px; font-size: 13px; }
  .rank-name { font-size: 13px; }
  .rank-score { width: 70px; font-size: 12px; }
  .ranking-list { max-height: 45vh; }
}

/* ── My Rank Enhanced ── */
.ranking-my-rank {
  text-align: center; padding: 14px 20px 10px;
  background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(167,139,250,0.1));
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.my-rank-top {
  display: flex; align-items: baseline; gap: 8px;
}
.my-rank-pct {
  font-size: 14px; font-weight: 700;
  color: #60a5fa; margin-top: 2px;
}
.my-rank-motivation {
  font-size: 13px; font-weight: 700; margin-top: 2px;
  animation: motivPulse 2s ease-in-out infinite;
}
@keyframes motivPulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ── Group Position Bar ── */
.ranking-group-bar {
  padding: 10px 20px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.rank-group-label {
  font-size: 12px; color: rgba(255,255,255,0.5); font-weight: 700;
  margin-bottom: 6px;
}
.rank-group-track {
  position: relative; height: 8px; background: rgba(255,255,255,0.08);
  border-radius: 4px; overflow: visible;
}
.rank-group-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, #34d399, #3b82f6, #a78bfa, #ef4444);
  opacity: 0.4;
}
.rank-group-marker {
  position: absolute; top: -18px;
  transform: translateX(-50%);
  font-size: 10px; font-weight: 900; color: #fbbf24;
  display: flex; flex-direction: column; align-items: center;
}
.rank-group-marker span {
  background: #fbbf24; color: #0f172a; padding: 1px 6px;
  border-radius: 4px; font-size: 9px; font-weight: 900;
  margin-bottom: 2px;
}
.rank-group-marker::after {
  content: '▼'; font-size: 8px; color: #fbbf24; line-height: 1;
}
.rank-group-ends {
  display: flex; justify-content: space-between;
  font-size: 10px; color: rgba(255,255,255,0.35); margin-top: 4px;
}

/* ── Pagination Dots ── */
.rank-page-dots {
  color: rgba(255,255,255,0.3); font-size: 14px; font-weight: 700;
  display: flex; align-items: center; padding: 0 2px;
}
.rank-page-btn.my-page {
  border-color: rgba(251,191,36,0.4);
  color: #fbbf24;
}

/* ── TOP 20 Button ── */
.rank-goto-top {
  background: rgba(52,211,153,0.08) !important;
  border-color: rgba(52,211,153,0.3) !important;
  color: #34d399 !important;
}
.rank-goto-top:hover {
  background: rgba(52,211,153,0.15) !important;
  border-color: rgba(52,211,153,0.5) !important;
}
.ranking-footer {
  padding: 8px 16px 16px; text-align: center;
  display: flex; gap: 8px; justify-content: center;
}

/* ═══════════════════════════════════════
   MAIN MENU LEADERBOARD (TOP 50)
   ═══════════════════════════════════════ */
.main-leaderboard {
  width: 100%; max-width: 900px; margin-top: 20px;
  background: linear-gradient(145deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
  border: 1px solid rgba(255,215,0,0.15);
  border-radius: 20px; overflow: hidden;
}
.main-lb-header {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 16px 20px 10px;
  background: linear-gradient(135deg, rgba(251,191,36,0.1), rgba(245,158,11,0.03));
  border-bottom: 1px solid rgba(255,215,0,0.08);
}
.main-lb-crown {
  font-size: 24px; animation: crownBounce 2s ease-in-out infinite;
}
.main-lb-title {
  font-size: 18px; font-weight: 900; color: #fbbf24;
}
.main-lb-tabs {
  display: flex; gap: 4px; padding: 10px 12px;
  overflow-x: auto; flex-wrap: nowrap;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.main-lb-tab {
  padding: 6px 12px; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px; background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.5); font-size: 12px; font-weight: 700;
  cursor: pointer; transition: all 0.2s; font-family: inherit;
  white-space: nowrap; flex-shrink: 0;
}
.main-lb-tab:hover {
  border-color: rgba(56,189,248,0.4); color: #fff;
}
.main-lb-tab.active {
  background: #3b82f6; border-color: #60a5fa; color: #fff;
}
.main-lb-list {
  padding: 4px 12px 12px;
}
.main-lb-row {
  display: flex; padding: 8px 12px; gap: 12px;
  align-items: center; border-radius: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.2s;
}
.main-lb-row:hover {
  background: rgba(255,255,255,0.04);
}
.main-lb-top3 {
  background: linear-gradient(135deg, rgba(251,191,36,0.08), rgba(245,158,11,0.03));
  border: 1px solid rgba(251,191,36,0.12);
  border-radius: 10px; margin-bottom: 2px;
}
.main-lb-pos {
  width: 42px; text-align: center; font-weight: 800;
  color: rgba(255,255,255,0.6); font-size: 14px; flex-shrink: 0;
}
.main-lb-top3 .main-lb-pos { color: #fbbf24; }
.main-lb-name {
  flex: 1; color: rgba(255,255,255,0.8); font-weight: 600;
  font-size: 14px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
.main-lb-top3 .main-lb-name { color: #fbbf24; font-weight: 800; }
.main-lb-score {
  width: 80px; text-align: right; color: rgba(255,255,255,0.5);
  font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.main-lb-top3 .main-lb-score { color: #fbbf24; }

@media (max-width: 480px) {
  .main-lb-tabs { gap: 3px; padding: 8px 8px; }
  .main-lb-tab { padding: 5px 8px; font-size: 11px; }
  .main-lb-row { padding: 7px 8px; }
  .main-lb-pos { width: 36px; font-size: 13px; }
  .main-lb-name { font-size: 13px; }
  .main-lb-score { width: 70px; font-size: 12px; }
}

/* 학년별 메인 리더보드 컴팩트 카드 스타일 */
.main-lb-grid {
  display: flex; flex-direction: column; gap: 12px; justify-content: center;
}
.main-lb-col {
  flex: 1; display: flex; flex-direction: column; gap: 6px;
}
.main-lb-col-title {
  text-align: center; font-weight: 800; color: #a78bfa; font-size: 14px;
  padding-bottom: 6px; border-bottom: 2px solid rgba(167,139,250,0.3);
  margin-bottom: 4px;
}
.main-lb-compact-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px; padding: 6px 8px;
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; transition: all 0.2s;
}
.main-lb-compact-card:hover {
  background: rgba(59,130,246,0.15); border-color: #3b82f6; transform: translateY(-2px);
}
.main-lb-cc-left {
  display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: #e2e8f0;
}
.main-lb-cc-right {
  display: flex; align-items: center; gap: 6px; font-size: 11px;
}
.main-lb-cc-name { color: #fbbf24; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50px; }
.main-lb-cc-score { color: #34d399; font-weight: 800; }

@media (max-width: 768px) {
  .main-lb-grid { flex-direction: column; gap: 15px; }
}
