/* ── Shared Game Styles ──────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Tajawal:wght@400;700;900&display=swap');

:root {
  --primary: #ff6b6b;
  --secondary: #ffd93d;
  --accent: #6bcb77;
  --blue: #4d96ff;
  --purple: #c77dff;
  --bg: #fff9f0;
  --card: #ffffff;
  --shadow: 0 8px 32px rgba(0,0,0,0.13);
  --radius: 24px;
  --font-en: 'Fredoka One', cursive;
  --font-ar: 'Tajawal', sans-serif;
}

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

body {
  min-height: 100vh;
  background: var(--bg);
  font-family: var(--font-ar);
  overflow-x: hidden;
}
body[dir="ltr"] { font-family: var(--font-en); }

/* ── Header ── */
.game-header {
  background: linear-gradient(135deg, #ff6b6b 0%, #ff922b 50%, #ffd93d 100%);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 20px rgba(255,107,107,0.4);
}
.game-header h1 {
  font-size: clamp(1.4rem, 4vw, 2rem);
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.15);
  letter-spacing: 0.5px;
}
.header-right { display: flex; gap: 10px; align-items: center; }

/* ── Lang toggle ── */
.lang-btn {
  background: rgba(255,255,255,0.3);
  border: 2px solid rgba(255,255,255,0.6);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.lang-btn:hover { background: rgba(255,255,255,0.5); transform: scale(1.05); }

/* ── Back button ── */
.back-btn {
  background: rgba(255,255,255,0.25);
  border: 2px solid rgba(255,255,255,0.5);
  color: #fff;
  font-size: 1.4rem;
  width: 42px; height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  transition: all 0.2s;
}
.back-btn:hover { background: rgba(255,255,255,0.45); transform: scale(1.1); }

/* ── Score bar ── */
.score-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 3px solid #ffd93d;
  font-size: 1.1rem;
  font-weight: 700;
  color: #444;
  gap: 12px;
  flex-wrap: wrap;
}
.score-bar span { background: #fff9e0; padding: 6px 18px; border-radius: 50px; border: 2px solid #ffd93d; }

/* ── Game area ── */
.game-area {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* ── Instruction banner ── */
.instruction {
  text-align: center;
  font-size: clamp(1rem, 3vw, 1.35rem);
  color: #555;
  margin-bottom: 22px;
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 20px;
  box-shadow: var(--shadow);
  border: 3px solid #e0e0e0;
  font-weight: 700;
  line-height: 1.5;
}

/* ── Cards grid ── */
.cards-grid {
  display: grid;
  gap: 16px;
  justify-items: center;
}
.cards-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cards-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cards-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Game card ── */
.game-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 12px;
  border: 4px solid transparent;
  width: 100%;
  user-select: none;
  text-align: center;
}
.game-card:hover { transform: translateY(-6px) scale(1.03); box-shadow: 0 16px 40px rgba(0,0,0,0.18); }
.game-card .card-icon { font-size: clamp(2.5rem, 8vw, 4.5rem); line-height: 1; margin-bottom: 10px; }
.game-card .card-label { font-size: clamp(0.85rem, 2.5vw, 1.1rem); font-weight: 700; color: #333; }
.game-card .card-sub { font-size: clamp(0.75rem, 2vw, 0.95rem); color: #888; margin-top: 4px; }

/* ── Card states ── */
.game-card.correct {
  border-color: #6bcb77;
  background: linear-gradient(135deg, #efffee, #d4fad7);
  animation: cardPop 0.4s ease;
}
.game-card.wrong {
  border-color: #ff6b6b;
  background: linear-gradient(135deg, #fff0f0, #ffd4d4);
}
.game-card.selected {
  border-color: var(--blue);
  background: linear-gradient(135deg, #eff6ff, #d4e8ff);
  transform: scale(1.05);
}
.game-card.disabled { pointer-events: none; opacity: 0.6; }

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

/* ── Target display ── */
.target-box {
  text-align: center;
  margin-bottom: 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: var(--radius);
  padding: 24px;
  color: #fff;
  box-shadow: 0 8px 30px rgba(102,126,234,0.4);
}
.target-box .target-icon { font-size: clamp(3rem, 12vw, 6rem); display: block; margin-bottom: 8px; }
.target-box .target-label { font-size: clamp(1.1rem, 4vw, 1.8rem); font-weight: 900; }
.target-box .target-hint { font-size: 0.95rem; opacity: 0.8; margin-top: 6px; }

/* ── Progress bar ── */
.progress-wrap { margin-bottom: 16px; }
.progress-track {
  height: 14px;
  background: #e0e0e0;
  border-radius: 50px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6bcb77, #4d96ff);
  border-radius: 50px;
  transition: width 0.5s ease;
}

/* ── Overlay ── */
#game-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.ov-box {
  background: #fff;
  border-radius: 32px;
  padding: 40px 48px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: ovPop 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes ovPop { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.ov-msg { font-size: 2.2rem; margin-bottom: 10px; }
.ov-sub { font-size: 1.1rem; color: #666; margin-bottom: 24px; font-weight: 600; }
.ov-btn {
  background: linear-gradient(135deg, #ff6b6b, #ff922b);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px 40px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 6px 20px rgba(255,107,107,0.4);
  transition: transform 0.2s;
}
.ov-btn:hover { transform: scale(1.08); }

/* ── Floating bg bubbles ── */
.bg-bubbles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.bubble {
  position: absolute;
  border-radius: 50%;
  opacity: 0.08;
  animation: floatUp linear infinite;
}
@keyframes floatUp {
  from { transform: translateY(100vh) scale(0); }
  to { transform: translateY(-120px) scale(1); }
}

/* ── Matching line canvas ── */
#match-canvas {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 5;
}
.match-area { position: relative; }
.match-col { display: flex; flex-direction: column; gap: 14px; }
.match-item {
  background: #fff;
  border-radius: 18px;
  padding: 14px 20px;
  cursor: pointer;
  border: 3px solid transparent;
  box-shadow: var(--shadow);
  font-size: 1.05rem;
  font-weight: 700;
  transition: all 0.2s;
  text-align: center;
}
.match-item:hover { border-color: var(--blue); background: #eff6ff; }
.match-item.selected-match { border-color: #ff922b; background: #fff4e0; }
.match-item.matched { border-color: #6bcb77; background: #efffee; pointer-events: none; }
.match-item.wrong-match { border-color: #ff6b6b; background: #fff0f0; }

/* ── Timer ── */
.timer-bar {
  height: 10px;
  background: linear-gradient(90deg, #6bcb77, #ffd93d, #ff6b6b);
  border-radius: 50px;
  transition: width 0.5s linear;
  margin-bottom: 14px;
}

/* ── Responsive ── */
@media (max-width: 500px) {
  .cards-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .cards-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .game-card { padding: 14px 8px; }
}
