:root {
  --page-bg: linear-gradient(180deg, #dff1ff 0%, #ffffff 85%);
  --card-bg: #ffffff;
  --accent: #38bdf8;
  --green: #22c55e;
  --danger: #ef4444;
  --title-grad: linear-gradient(90deg, #38bdf8 0%, #f6c453 100%);
  --radius-lg: 1.4rem;
  --shadow-sm: 0 6px 18px rgba(15, 23, 42, 0.04);
  --shadow-card: 0 10px 30px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  font-family: "Tajawal", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #0f172a;
}

.topbar {
  display: flex;
  justify-content: center;
  padding: 1.2rem 1rem 0.7rem;
}

.title-box {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(5px);
  border-radius: 1.5rem;
  padding: 0.55rem 1.2rem 0.7rem;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
}

.title-box .icon {
  font-size: 1.8rem;
}

.titles { text-align: center; }

.main-title {
  margin: 0;
  font-size: 36px;
  background: var(--title-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
  line-height: 1.05;
}

.sub-title {
  margin: 0.25rem 0 0;
  font-family: "Poppins", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  direction: ltr;
  text-align: center;
  font-size: 0.9rem;
  color: #0f172a;
}

.container {
  max-width: 1150px;
  margin: 0 auto;
  padding: 1rem 1rem 4rem;
}

.controls {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  align-items: center;
}

.btn {
  border: none;
  background: #ffffff;
  color: #0f172a;
  padding: 0.55rem 0.9rem;
  border-radius: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: 0.15s;
}
.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.07);
}

.btn.warn {
  background: #f97316;
  color: #fff;
}

.score {
  background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%);
  color: #fff;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
}

.progress-wrap {
  background: #dbeafe;
  border-radius: 999px;
  overflow: hidden;
  height: 20px;
  margin-bottom: 1.1rem;
}
.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #22c55e 0%, #16a34a 80%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  transition: width 0.4s ease;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.8rem;
}

.word-card {
  background: var(--card-bg);
  border-radius: 1.3rem;
  padding: 0.6rem 0.65rem 0.55rem;
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(56, 189, 248, 0);
  transition: 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  animation: fadeup 0.3s ease;
}
.word-card:hover { border-color: rgba(56, 189, 248, 0.4); }

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

.word-en {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.word-en .en-text { font-weight: 600; }
.word-en .num {
  margin-left: auto;
  color: #38bdf8;
  font-weight: 700;
  direction: ltr;
}
.word-ar { font-weight: 600; color: #0f172a; }

.input-word {
  width: 100%;
  padding: 0.35rem 0.55rem;
  border-radius: 0.7rem;
  border: 1px solid #cbd5f5;
  direction: ltr;
  font-family: inherit;
}
.input-correct { border-color: #22c55e; background: #ecfdf3; }
.input-wrong { border-color: #ef4444; background: #fef2f2; }

.correct-answer {
  font-size: 0.7rem;
  margin-top: 0.2rem;
}

.footer {
  text-align: center;
  padding: 1.15rem 0.5rem 1.5rem;
  color: #0f172a;
}
.footer #message { margin-bottom: 0.4rem; font-weight: 500; }
.footer .copyright {
  font-size: 0.7rem;
  color: #94a3b8;
}

.excellent {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-size: 3.2rem;
  font-weight: 700;
  color: #facc15;
  text-shadow: 0 0 12px rgba(250, 204, 21, 0.8);
  opacity: 0;
  z-index: 10000;
}
.excellent.show {
  animation: zoomfade 2s ease-out forwards;
}
@keyframes zoomfade {
  0% { opacity: 0; transform: scale(.6); }
  25% { opacity: 1; transform: scale(1); }
  60% { opacity: 1; transform: scale(1.04); }
  100% { opacity: 0; transform: scale(1.1); }
}

.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}
.confetti {
  position: absolute;
  width: 10px;
  height: 16px;
  background: #38bdf8;
  top: -20px;
  animation: fall 3s linear forwards;
  border-radius: 3px;
}
@keyframes fall {
  to { transform: translateY(120vh) rotate(360deg); opacity: 0; }
}

.score.flash { animation: flash 1s ease-in-out 2; }
@keyframes flash {
  0% { background: transparent; }
  50% { background: rgba(250, 204, 21, .35); }
  100% { background: transparent; }
}

@media (max-width: 700px) {
  .controls { flex-direction: column; align-items: flex-start; }
  .main-title { font-size: 28px; }
  .word-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
