/* ألعاب الأسرة: التخطيط المشترك. الألوان والخطوط والزينة في watan.css (بيت الجدة) وfasiha.css (صفحة المعجم). */
*, *::before, *::after { box-sizing: border-box; }
:root {
  --bg: #f4ecdc; --paper: #fffaf0; --ink: #3a2a1e; --ink-soft: #6e5a48; --line: #e2d3b8;
  --accent: #8a1538; --accent-ink: #fff; --ok: #2f7d4f; --ok-bg: #e3f3e8; --no: #b3261e; --no-bg: #fbe3e0;
  --font-body: 'Tajawal', 'Segoe UI', Tahoma, sans-serif; --font-title: 'Tajawal', sans-serif;
  --radius: 18px;
}
html { -webkit-text-size-adjust: 100%; }
/* hidden قبل clip: Safari قبل 16 وأندرويد القديم لا يعرفان clip فيأخذان hidden */
html, body { overflow-x: hidden; overflow-x: clip; }
[hidden] { display: none !important; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 1.08rem; line-height: 1.65; overscroll-behavior-y: contain;
}
h1, h2, h3 { font-family: var(--font-title); line-height: 1.35; margin: 0; }
button { font: inherit; color: inherit; touch-action: manipulation; }
.deco { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
main, .bar { position: relative; z-index: 1; }

/* ===== الشريط ===== */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; }
.brand { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-family: var(--font-title); font-weight: 700; font-size: 1.05rem; }
.brand-dept { font-size: 0.85rem; color: var(--ink-soft); font-weight: 700; }
.bar-tools { display: flex; align-items: center; gap: 8px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; padding: 4px 12px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); direction: ltr; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); cursor: pointer; font-size: 1.1rem; }

main { width: min(100%, 760px); margin: 0 auto; padding: 4px 14px 40px; }
.screen[hidden] { display: none; }

/* ===== الأزرار ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 50px; padding: 10px 22px; border-radius: 14px;
  border: 2px solid var(--accent); background: var(--paper); color: var(--accent); font-weight: 800; cursor: pointer; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-big { width: 100%; font-size: 1.2rem; min-height: 58px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ===== البداية ===== */
.start-card, .end-card { background: var(--paper); border-radius: var(--radius); padding: 26px 22px; margin-top: 10px; box-shadow: 0 10px 30px rgba(60, 35, 15, 0.12); }
.eyebrow { margin: 0 0 4px; font-weight: 800; color: var(--accent); font-size: 0.95rem; }
.start-card h1 { font-size: clamp(2rem, 8vw, 2.8rem); }
.sub { margin: 4px 0 14px; font-size: 1.15rem; color: var(--ink-soft); font-weight: 700; }
.rules { margin: 0 0 18px; padding: 0 20px 0 0; color: var(--ink-soft); }
.rules li { margin: 4px 0; }
.team-form label { display: block; font-weight: 800; margin-bottom: 6px; }
.team-form input { width: 100%; min-height: 54px; padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line); background: #fff; font: inherit; font-size: 1.15rem; color: var(--ink); }
.team-form input:focus { outline: none; border-color: var(--accent); }
.field-error { min-height: 1.6em; margin: 4px 0 8px; color: var(--no); font-weight: 700; }

/* ===== السؤال ===== */
.progress { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 2px 10px; font-weight: 800; color: var(--ink-soft); }
.dots { display: flex; gap: 5px; flex-wrap: wrap; }
.dots i { width: 11px; height: 11px; border-radius: 50%; background: var(--line); }
.dots i.now { background: var(--accent); transform: scale(1.25); }
.dots i.done { background: var(--ink-soft); }
.dots i.done.ok { background: var(--ok); }
.q-card { position: relative; background: var(--paper); border-radius: var(--radius); padding: 22px 18px 20px; box-shadow: 0 10px 30px rgba(60, 35, 15, 0.12); }
.q-icon { width: 58px; height: 58px; color: var(--accent); margin-bottom: 6px; }
.q-icon svg { width: 100%; height: 100%; }
.q-kicker { margin: 0 0 4px; font-weight: 800; font-size: 0.92rem; color: var(--accent); }
.q-text { font-size: clamp(1.25rem, 4.6vw, 1.6rem); margin-bottom: 16px; }
.q-card.locked .q-area { pointer-events: none; }
.hint { margin: -6px 0 12px; color: var(--ink-soft); font-weight: 700; font-size: 0.95rem; }

.opts { display: grid; gap: 10px; }
.opt { min-height: 56px; padding: 12px 16px; border-radius: 14px; border: 2px solid var(--line); background: #fff; text-align: start; font-weight: 700; font-size: 1.1rem; cursor: pointer; transition: border-color .15s, background .15s; }
.opt:not(:disabled):hover { border-color: var(--accent); }
.opt.ok { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.opt.no { border-color: var(--no); background: var(--no-bg); color: var(--no); text-decoration: line-through; }
.opt:disabled { cursor: default; }
.tf-opts { grid-template-columns: 1fr 1fr; }
.tf-opts .opt { text-align: center; font-size: 1.3rem; min-height: 70px; }
.flag-opts { grid-template-columns: 1fr; }
@media (min-width: 560px) { .flag-opts { grid-template-columns: 1fr 1fr; } }
.flag-opts .opt { padding: 10px; display: grid; place-items: center; }
.flag-opts .opt svg { width: 100%; aspect-ratio: 28 / 11; height: auto; display: block; border-radius: 4px; box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.flag-opts .opt.no svg { opacity: .35; }

.tap-sentence { font-size: clamp(1.3rem, 5vw, 1.7rem); line-height: 2.4; margin: 0; text-align: center; }
.tap-word { border: 2px dashed var(--line); background: #fff; border-radius: 12px; padding: 2px 10px; cursor: pointer; font-weight: 700; }
.tap-word.ok { border: 2px solid var(--ok); background: var(--ok-bg); color: var(--ok); }
.tap-word.no { border-color: var(--no); color: var(--no); text-decoration: line-through; }

.chip { min-height: 52px; padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line); background: #fff; font-weight: 700; cursor: pointer; text-align: center; line-height: 1.45; }
.chip.picked { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 21, 56, .25); }
.chip:disabled { cursor: default; }
.tray { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px 0; }
.tray.flash { animation: flash .6s; }
.order-slots { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: slot; }
.slot { counter-increment: slot; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 4px 10px; border-radius: 14px; border: 2px dashed var(--line); }
.slot::before { content: counter(slot); flex: 0 0 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--line); font-weight: 800; }
.slot.filled { border-style: solid; border-color: var(--ok); background: var(--ok-bg); }
.slot.filled::before { background: var(--ok); color: #fff; }
.slot .chip { flex: 1; border: 0; background: transparent; color: var(--ok); min-height: 0; padding: 4px; }

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match-col { display: grid; gap: 8px; align-content: start; }
.match-chip.paired { color: #fff; border-color: transparent; }
.pair-1 { background: #2f7d4f !important; } .pair-2 { background: #2b5d8a !important; }
.pair-3 { background: #8a5a14 !important; } .pair-4 { background: #6a3b8a !important; }
.pair-5 { background: #8a1538 !important; } .pair-6 { background: #176a6a !important; }

.bins { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bin { min-height: 150px; padding: 10px; border-radius: 16px; border: 2px dashed var(--accent); background: rgba(255, 255, 255, .75); cursor: pointer; display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.bin-label { font-weight: 800; color: var(--accent); font-size: 1.05rem; }
.bin-cards { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.bin .chip { min-height: 0; padding: 4px 10px; border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.card-chip { display: inline-flex; flex-direction: column; align-items: center; min-width: 86px; }
.card-chip b { font-size: 1.15rem; }
.card-chip small { font-weight: 500; color: var(--ink-soft); font-size: 0.85rem; }
.bin .card-chip small { display: none; }

.slider { display: grid; gap: 12px; justify-items: center; padding: 6px 0; }
.slider-value { font-size: 3.2rem; font-weight: 800; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.slider.ok .slider-value { color: var(--ok); }
.slider-row { display: flex; align-items: center; gap: 10px; width: 100%; }
.slider-row input { flex: 1; accent-color: var(--accent); height: 40px; }
.step { width: 50px; height: 50px; border-radius: 50%; border: 2px solid var(--accent); background: #fff; color: var(--accent); font-size: 1.5rem; font-weight: 800; cursor: pointer; }
.slider-hint { min-height: 1.6em; margin: 0; font-weight: 800; color: var(--no); }

.bounce { animation: shake .45s; border-color: var(--no) !important; }
@keyframes shake { 0%,100% { transform: none; } 20% { transform: translateX(-7px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@keyframes flash { 50% { background: var(--no-bg); } }

/* ===== بطاقة التوضيح ===== */
.note { margin-top: 14px; background: var(--paper); border-radius: var(--radius); padding: 18px 18px 20px; border: 2px solid var(--ok); box-shadow: 0 10px 30px rgba(60, 35, 15, 0.14); }
.note.enter { animation: rise .35s ease-out; }
.note-title { color: var(--ok); font-size: 1.4rem; margin-bottom: 8px; }
.note-body { display: grid; gap: 10px; margin-bottom: 14px; }
.entry-head { font-size: 1.3rem; color: var(--accent); }
.entry-text { margin: 2px 0 0; font-size: 1.12rem; }
.entry-src { margin: 2px 0 0; font-size: 0.88rem; color: var(--ink-soft); font-weight: 700; }
.entry-src::before { content: '— '; }
.note .btn { width: 100%; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.question.enter .q-card { animation: rise .35s ease-out; }

/* ===== النهاية ===== */
.end-card h1 { font-size: clamp(1.8rem, 7vw, 2.4rem); margin-bottom: 12px; }
.end-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.end-stats > div { background: var(--bg); border-radius: 14px; padding: 12px; text-align: center; display: grid; gap: 2px; }
.stat-label { font-size: 0.85rem; font-weight: 700; color: var(--ink-soft); }
.stat { font-size: 1.8rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.rank { font-weight: 800; font-size: 1.1rem; min-height: 1.6em; }
.recap-title { margin: 18px 0 8px; font-size: 1.3rem; }
.recap { margin: 0 0 18px; padding: 0 22px 0 0; display: grid; gap: 10px; }
.recap li { padding: 8px 10px; border-radius: 12px; background: var(--bg); }
.recap .entry-head { font-size: 1.08rem; }
.recap .entry-text { font-size: 1rem; }
.end-card .btn { width: 100%; margin-top: 6px; }

/* ===== التنبيه ===== */
.toast { position: fixed; inset-inline: 0; bottom: 18px; margin: 0 auto; width: max-content; max-width: 90vw; padding: 10px 20px; border-radius: 999px;
  background: var(--ink); color: #fff; font-weight: 800; opacity: 0; transform: translateY(20px); transition: .2s; pointer-events: none; z-index: 60; }
.toast.show { opacity: 1; transform: none; }
.toast.bad { background: var(--no); }

/* ===== الاحتفال (من style.css الألعاب) ===== */
.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: .95;
  animation: confetti-fall var(--dur, 2.4s) cubic-bezier(.25, .6, .4, 1) var(--delay, 0s) forwards; }
@keyframes confetti-fall { to { transform: translate(var(--dx, 0), 110vh) rotate(var(--rot, 540deg)); opacity: .3; } }

/* ===== التاب (من عرض 700): خط وأزرار أكبر نحو الربع ===== */
@media (min-width: 700px) {
  body { font-size: 1.2rem; }
  main { width: min(100%, 860px); padding-inline: 24px; }
  .q-card { padding: 30px 30px 26px; }
  .opt, .chip { min-height: 64px; font-size: 1.25rem; }
  .opts:not(.tf-opts):not(.flag-opts) { grid-template-columns: 1fr 1fr; }
  .q-icon { width: 70px; height: 70px; }
}
/* الهاتف أفقياً (ارتفاع قليل): شريط أنحف، وبلا أيقونة، وبطاقة أضيق حواشي */
@media (max-height: 460px) and (orientation: landscape) {
  .bar { padding: 4px 14px; }
  .brand-dept { display: none; }
  .icon-btn { width: 36px; height: 36px; }
  .q-icon { display: none; }
  .q-card { padding: 14px 16px; }
  .q-text { font-size: 1.2rem; margin-bottom: 10px; }
  .progress { margin: 2px 2px 6px; }
  .opt, .chip { min-height: 46px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
