/* ===== المسرح (الخلفية) ===== */
.stage { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; background: var(--bg); }
.stage-glow {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 45% at 50% 0%, rgba(80, 120, 200, .22), transparent 70%),
    radial-gradient(ellipse 50% 40% at 50% 100%, rgba(232, 191, 98, .08), transparent 70%),
    linear-gradient(180deg, #0A1226 0%, #070D1C 55%, #050A16 100%);
}
.stage-beams { position: absolute; inset: -20% -10%; }
.stage-beams i {
  position: absolute; top: -10%; left: 50%; width: 22vw; height: 130%;
  transform-origin: 50% 0; opacity: .5; mix-blend-mode: screen;
  background: linear-gradient(180deg, rgba(150, 185, 255, .22), rgba(150, 185, 255, 0) 70%);
  clip-path: polygon(46% 0, 54% 0, 100% 100%, 0 100%);
}
.stage-beams i:nth-child(1) { transform: rotate(-24deg); }
.stage-beams i:nth-child(2) { transform: rotate(0deg); width: 28vw; opacity: .35; }
.stage-beams i:nth-child(3) { transform: rotate(24deg); }
.stage-pattern {
  position: absolute; inset: 0; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%23E8BF62' stroke-width='1'%3E%3Crect x='20' y='20' width='40' height='40'/%3E%3Crect x='20' y='20' width='40' height='40' transform='rotate(45 40 40)'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 80px 80px;
}
#dust, #confetti { position: absolute; inset: 0; width: 100%; height: 100%; }
#confetti { position: fixed; z-index: 60; pointer-events: none; }
.stage-vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(2, 5, 12, .65) 100%); }

/* ===== الشاشات ===== */
#app { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; outline: none; }
.screen { min-height: 100vh; min-height: 100dvh; padding: var(--gutter); }
.skip-link { position: absolute; top: -60px; inset-inline-start: 12px; z-index: 100; background: var(--gold); color: #1a1405; padding: 8px 14px; }
.skip-link:focus { top: 8px; }

/* ===== الرئيسية ===== */
#screen-home { display: flex; flex-direction: column; }
.home-tools { display: flex; justify-content: flex-start; }
.home-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .4rem; padding-bottom: 4vh; }
.logo-wrap { position: relative; margin-bottom: .6rem; }
.logo { width: clamp(120px, 20vw, 210px); height: auto; filter: drop-shadow(0 0 28px rgba(232, 191, 98, .3)); }
.home-title { background: linear-gradient(180deg, var(--gold-hi), var(--gold) 60%, var(--gold-lo)); -webkit-background-clip: text; background-clip: text; color: transparent; padding-block: .1em; }
.home-slogan { color: var(--text-2); font-size: clamp(1rem, 1.7vw, 1.35rem); max-width: 36ch; }
.home-actions { margin-top: 1.6rem; display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.home-links { display: flex; align-items: center; gap: .6rem; }
.dot { width: 5px; height: 5px; transform: rotate(45deg); background: var(--gold); opacity: .7; }
.home-note { margin-top: 1.8rem; color: var(--text-2); font-size: .85rem; max-width: 60ch; }

/* ===== الإعداد ===== */
#screen-setup { display: flex; justify-content: center; padding-bottom: 0; }
.setup { width: min(1000px, 100%); display: flex; flex-direction: column; min-height: calc(100dvh - 2 * var(--gutter)); }
.setup-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; padding-bottom: 1rem; }
.setup-titles { text-align: center; }
.setup-titles h1 { font-size: clamp(1.8rem, 3.6vw, 2.8rem); color: var(--gold-hi); }
.setup-titles p { color: var(--text-2); }
.steps { display: flex; gap: .4rem; justify-content: center; flex-wrap: wrap; padding-bottom: 1.2rem; border-bottom: 1px solid var(--line-soft); }
.step-body { flex: 1; padding-block: 1.6rem 7rem; }
.step-h { font-size: clamp(1.4rem, 2.4vw, 2rem); margin-bottom: 1.2rem; }
.setup-foot {
  position: sticky; bottom: 0; margin-inline: calc(-1 * var(--gutter)); padding: .9rem var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(7, 13, 28, 0), rgba(7, 13, 28, .96) 35%); border-top: 1px solid var(--line-soft);
  backdrop-filter: none;
}
.foot-sum { color: var(--text-2); font-size: .95rem; }
.foot-btns { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.grade-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }
.unit-list { display: grid; gap: .7rem; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.bar-btns { display: flex; gap: .4rem; }
.tgl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: .7rem; margin-block: 1rem; }
.field { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-block: 1rem; }
.field-l { min-width: 8rem; color: var(--text-2); }

/* ===== المسابقة ===== */
#screen-game { padding: 0; }
.game { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; }
.g-top {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 1.2rem;
  padding: .7rem var(--gutter); border-bottom: 1px solid var(--line-soft); background: rgba(7, 13, 28, .6);
}
.g-brand { display: flex; align-items: center; gap: .6rem; }
.g-brand b { font-family: var(--font-display); color: var(--gold-hi); font-size: 1.1rem; display: block; line-height: 1.3; }
.g-brand small { color: var(--text-2); }
.mini-logo { width: 40px; height: 40px; }
.g-tools { display: flex; gap: .4rem; align-items: center; }
.g-pl { display: flex; justify-content: space-between; font-size: .95rem; color: var(--text-2); }
.g-score b { color: var(--gold-hi); font-size: 1.15rem; }
.g-body { display: grid; grid-template-columns: minmax(0, 1fr) clamp(210px, 19vw, 300px); gap: var(--gutter); padding: 1rem var(--gutter); min-height: 0; }
.arena { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; justify-content: safe center; gap: 1.2rem; padding-block: .5rem; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem 1.4rem; }
.ladder-wrap { min-height: 0; display: flex; flex-direction: column; border: 1px solid var(--line-soft); background: rgba(16, 26, 49, .7); padding: .8rem; }
.ladder-h { text-align: center; color: var(--gold); font-size: 1.05rem; padding-bottom: .5rem; }
.ladder { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; scrollbar-width: thin; }
.g-foot { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem var(--gutter); border-top: 1px solid var(--line-soft); background: rgba(7, 13, 28, .6); flex-wrap: wrap; }
.jokers { display: flex; gap: .6rem; flex-wrap: wrap; }
.kbd-note { color: var(--text-2); font-size: .8rem; }

/* ===== النتائج ===== */
#screen-results { display: flex; justify-content: center; }
.results { width: min(1000px, 100%); display: flex; flex-direction: column; gap: 2rem; padding-bottom: 3rem; }
.res-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: .4rem; padding-top: 1rem; }
.res-hero h1 { font-size: clamp(2.2rem, 5vw, 3.8rem); color: var(--gold-hi); }
.res-ring .logo { width: clamp(90px, 14vw, 140px); }
.res-score { font-size: 1.2rem; color: var(--text-2); }
.big-score { font-family: var(--font-display); font-size: clamp(3rem, 8vw, 5.5rem); color: var(--gold); line-height: 1.2; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; }
.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.4rem; }
.res-body { display: flex; flex-direction: column; gap: 1.2rem; }
.res-actions { display: flex; gap: .7rem; flex-wrap: wrap; justify-content: center; }
.review { display: grid; gap: 1rem; margin-top: 1rem; }

/* منع شريط التمرير في شاشة المسابقة */
html:has(body[data-screen='game']), body[data-screen='game'] { overflow: hidden; height: 100%; }
.arena, .ladder, .dlg-frame { scrollbar-width: none; }
.arena::-webkit-scrollbar, .ladder::-webkit-scrollbar { display: none; }
