/* ===== الأساس المشترك لكل الصفحات ===== */
:root {
  --plum-900: #2f0d3b;
  --plum-800: #431456;
  --plum-700: #5b2378;
  --plum-500: #8a46b5;
  --violet-300: #c7a6f0;
  --violet-100: #f1e8ff;
  --rose-600: #cf3f7c;
  --rose-500: #e2558f;
  --rose-300: #f6a5c6;
  --rose-100: #fde6f0;
  --coral-400: #ff8f70;
  --gold-500: #e0a63a;
  --gold-400: #f5c14e;
  --gold-100: #fff3d6;
  --mint-500: #2fae8c;
  --mint-400: #4fc4a4;
  --mint-100: #def6ee;
  --ink: #2a1433;
  --ink-soft: #6c5577;
  --surface: #ffffff;
  --surface-2: #fbf6fe;
  --line: #ecdff3;
  --bg-1: #fff5fa;
  --bg-2: #f3eaff;
  --grad-brand: linear-gradient(135deg, #ec5f97 0%, #b04fb0 55%, #8a46b5 100%);
  --grad-gold: linear-gradient(135deg, #fbe2a0, #e0a63a);
  --shadow: 0 18px 40px -22px rgba(67, 20, 86, 0.45), 0 2px 6px -2px rgba(67, 20, 86, 0.08);
  --shadow-sm: 0 6px 16px -8px rgba(67, 20, 86, 0.35);
  --radius: 24px;
  --radius-sm: 14px;
  --font-body: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  --font-title: 'El Messiri', 'Tajawal', 'Segoe UI', sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; background: var(--bg-1); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2));
  display: flex;
  flex-direction: column;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

/* هالات لونية ثابتة خلف المحتوى */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(38rem 30rem at 8% 0%, rgba(246, 165, 198, 0.5), transparent 70%),
    radial-gradient(34rem 28rem at 100% 12%, rgba(199, 166, 240, 0.55), transparent 70%),
    radial-gradient(40rem 26rem at 60% 105%, rgba(245, 193, 78, 0.22), transparent 70%);
}

img, svg { max-width: 100%; }

h1, h2, h3 { font-family: var(--font-title); line-height: 1.3; margin: 0; font-weight: 700; }

a { color: var(--plum-700); }

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid var(--rose-500);
  outline-offset: 3px;
  border-radius: 12px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ===== الترويسة ===== */
.site-header {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--plum-900);
  min-width: 0;
}

.brand-mark {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--grad-brand);
  box-shadow: 0 8px 18px -8px rgba(207, 63, 124, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.brand-mark svg { width: 28px; height: 28px; }

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-family: var(--font-title); font-weight: 700; font-size: 1.2rem; line-height: 1.25; }
.brand-dept { font-weight: 700; font-size: 0.95rem; color: var(--plum-700); line-height: 1.3; }
.brand-sub { font-size: 0.88rem; color: var(--ink-soft); line-height: 1.35; }

.nav-link {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--plum-700);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.nav-link:hover { background: var(--rose-100); }

main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 4px 16px 40px;
}

/* ===== الأزرار والحقول ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 10px 28px;
  border: 0;
  border-radius: 999px;
  font-weight: 800;
  font-size: 1.08rem;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  color: #fff;
  background: var(--grad-brand);
  box-shadow: 0 10px 22px -10px rgba(207, 63, 124, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn-primary:hover { box-shadow: 0 14px 28px -10px rgba(207, 63, 124, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.3); }

.btn-soft {
  color: var(--plum-700);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.btn-soft:hover { background: var(--rose-100); }

.btn-sm { min-height: 42px; padding: 6px 16px; font-size: 0.95rem; }

.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; text-align: start; }
.field label { font-weight: 700; color: var(--plum-700); }
.field input {
  font: inherit;
  font-size: 1.15rem;
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus { outline: none; border-color: var(--rose-500); box-shadow: 0 0 0 4px var(--rose-100); }
.field-error { min-height: 1.5em; margin: 0; font-size: 0.92rem; color: var(--rose-600); }

/* ===== البطاقة العامة ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  border: 1px solid rgba(236, 223, 243, 0.8);
}

/* ===== شاشات الألعاب ===== */

.intro {
  max-width: 540px;
  margin: 8px auto 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.intro-art { width: 150px; height: auto; margin: 0 auto; }
.intro h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); color: var(--plum-900); }
.intro p { margin: 0; color: var(--ink-soft); }

.result-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}
.stat {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
}
.stat-value {
  display: block;
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--plum-700);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-label { font-size: 0.92rem; color: var(--ink-soft); }
.result-rank { min-height: 1.7em; font-weight: 800; font-size: 1.15rem; color: var(--rose-600); margin: 0; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.bravo {
  font-family: var(--font-title);
  font-size: clamp(2rem, 6vw, 2.8rem);
  color: var(--rose-500);
  margin: 0;
  line-height: 1.3;
}

/* ===== شريط الحالة داخل اللعبة ===== */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 auto 14px;
}
.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 16px;
  box-shadow: var(--shadow-sm);
  font-weight: 800;
  color: var(--plum-700);
  font-variant-numeric: tabular-nums;
}

/* ===== قصاصات الاحتفال ===== */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}
.confetti i {
  position: absolute;
  top: -24px;
  width: 10px;
  height: 14px;
  border-radius: 3px;
  opacity: 0.95;
  animation: confetti-fall var(--dur, 2.4s) cubic-bezier(0.25, 0.6, 0.4, 1) var(--delay, 0s) forwards;
}
@keyframes confetti-fall {
  to { transform: translate(var(--dx, 0), 110vh) rotate(var(--rot, 540deg)); opacity: 0.3; }
}

/* ===== التذييل ===== */
.site-footer {
  text-align: center;
  padding: 18px 16px 24px;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* الشاشات الكبيرة والعرض في الصف: تكبير متناسب لكل ما يقاس بـ rem */
@media (min-width: 1600px) {
  html { font-size: 20px; }
  .site-header, main { max-width: 1500px; }
}
@media (min-width: 2400px) {
  html { font-size: 26px; }
  .site-header, main { max-width: 2000px; }
}

@media (max-width: 480px) {
  .brand-mark { width: 42px; height: 42px; border-radius: 14px; }
  .brand-name { font-size: 1.05rem; }
  .brand-sub { font-size: 0.8rem; }
  .card { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .confetti { display: none; }
}

/* زر كتم الصوت في شريط اللعبة */
.sound-btn { min-width: 46px; padding-inline: 10px; font-size: 1.15rem; }
