@font-face { font-family: Cairo; font-weight: 400; font-display: swap; src: url(/fonts/cairo-arabic-400-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: Cairo; font-weight: 600; font-display: swap; src: url(/fonts/cairo-arabic-600-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: Cairo; font-weight: 800; font-display: swap; src: url(/fonts/cairo-arabic-800-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: Cairo; font-weight: 900; font-display: swap; src: url(/fonts/cairo-arabic-900-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: Cairo; font-weight: 400; font-display: swap; src: url(/fonts/cairo-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF; }
@font-face { font-family: Cairo; font-weight: 600; font-display: swap; src: url(/fonts/cairo-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF; }
@font-face { font-family: Cairo; font-weight: 800; font-display: swap; src: url(/fonts/cairo-latin-800-normal.woff2) format('woff2'); unicode-range: U+0000-00FF; }
@font-face { font-family: Cairo; font-weight: 900; font-display: swap; src: url(/fonts/cairo-latin-900-normal.woff2) format('woff2'); unicode-range: U+0000-00FF; }

:root {
  --bg: #FFF3E6;
  --paper: #FFFFFF;
  --ink: #2A1238;
  --ink-2: #6B5A75;
  --line: #2A1238;
  --lie: #FF3D7F;
  --lie-soft: #FFE0EB;
  --truth: #12B394;
  --truth-soft: #D6F7EF;
  --sun: #FFC23D;
  --sun-soft: #FFF0C7;
  --grape: #7B5CFF;
  --danger: #E5383B;
  --radius: 18px;
  --shadow: 4px 4px 0 var(--line);
  --shadow-sm: 2px 2px 0 var(--line);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; }
body {
  font-family: Cairo, system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(circle at 1px 1px, #F3DCC6 1.2px, transparent 0);
  background-size: 22px 22px;
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
#app { max-width: 520px; margin: 0 auto; padding: 18px 16px calc(110px + var(--safe-b)); min-height: 100vh; min-height: 100dvh; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ── شعار */
.logo { text-align: center; margin: 22px 0 6px; }
.logo .mark { width: 92px; height: 92px; display: block; margin: 0 auto 6px; filter: drop-shadow(4px 4px 0 var(--line)); }
.logo h1 { font-size: 40px; font-weight: 900; margin: 0; line-height: 1.15; letter-spacing: -0.5px; }
.logo h1 span { color: var(--lie); }
.logo p { margin: 4px 0 0; color: var(--ink-2); font-weight: 600; }

/* ── بطاقات وأزرار */
.card { background: var(--paper); border: 2.5px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin: 16px 0; }
.card h2 { margin: 0 0 10px; font-size: 20px; font-weight: 800; }
.card h3 { margin: 0 0 8px; font-size: 16px; font-weight: 800; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.center { text-align: center; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  border: 2.5px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: var(--shadow-sm);
  padding: 13px 16px; font-weight: 800; font-size: 17px; transition: transform .08s, box-shadow .08s; min-height: 54px;
}
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--line); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--lie); color: #fff; }
.btn.truth { background: var(--truth); color: #fff; }
.btn.sun { background: var(--sun); }
.btn.grape { background: var(--grape); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; border-style: dashed; }
.btn.danger { color: var(--danger); }
.btn.sm { white-space: nowrap; min-height: 40px; padding: 6px 12px; font-size: 14px; border-radius: 11px; width: auto; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.between > h2, .between > h3 { flex: 1; }
.between > .btn { width: auto; flex: none; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; align-items: center; }
.stack > * + * { margin-top: 10px; }

.field { width: 100%; border: 2.5px solid var(--line); border-radius: 14px; padding: 12px 14px; font-size: 18px; font-weight: 700; background: #fff; outline: none; min-height: 54px; }
.field:focus { border-color: var(--lie); box-shadow: 0 0 0 4px var(--lie-soft); }
.field.code { letter-spacing: 8px; text-align: center; font-size: 26px; font-weight: 900; direction: ltr; }
label.lbl { display: block; font-weight: 800; margin: 0 0 6px; font-size: 15px; }
.err { color: var(--danger); font-weight: 700; font-size: 14px; margin-top: 6px; min-height: 1em; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-weight: 700; font-size: 14px; margin: 14px 0; }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 2px dashed #D9C3B0; }

/* ── الشريط العلوي */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 12px; font-weight: 800; font-size: 14px; white-space: nowrap; }
.pill.lie { background: var(--lie-soft); }
.pill.sun { background: var(--sun-soft); }
.pill.truth { background: var(--truth-soft); }
.iconbtn { width: 42px; height: 42px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-size: 18px; display: grid; place-items: center; box-shadow: var(--shadow-sm); flex: none; }

/* ── رمز الغرفة */
.roomcode { text-align: center; }
.roomcode .digits { font-size: 54px; font-weight: 900; letter-spacing: 12px; direction: ltr; line-height: 1.1; margin: 4px 0; }
.roomcode .digits span { display: inline-block; background: var(--sun); border: 2.5px solid var(--line); border-radius: 12px; padding: 0 8px; margin: 0 3px; box-shadow: var(--shadow-sm); letter-spacing: 0; }

/* ── اللاعبين */
.players { display: grid; gap: 8px; }
.player { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; border: 2px solid var(--line); border-radius: 14px; padding: 8px 10px; background: #fff; }
.player.off { opacity: .5; }
.pctrl { display: flex; gap: 8px; align-items: center; width: 100%; padding-inline-start: 48px; }
.pctrl select.mini { flex: 1; max-width: none; min-height: 38px; }
.pctrl .btn { flex: none; width: 40px; min-height: 38px; padding: 0 !important; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 900; font-size: 17px; color: #fff; flex: none; }
.player .name { flex: 1; font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 12px; font-weight: 800; border-radius: 999px; padding: 1px 9px; border: 1.5px solid var(--line); background: var(--sun); white-space: nowrap; }
.badge.me { background: var(--truth-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; border: 2px solid var(--line); border-radius: 999px; padding: 3px 10px 3px 4px; background: #fff; font-weight: 700; font-size: 14px; }
.chip .avatar { width: 24px; height: 24px; font-size: 12px; border-width: 1.5px; }
.chip.done { background: var(--truth-soft); }
.chip.wait { opacity: .55; border-style: dashed; }

/* ── التصنيفات */
.cats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.cat { border: 2.5px solid var(--line); border-radius: 16px; background: #fff; padding: 14px 8px; text-align: center; font-weight: 800; font-size: 16px; box-shadow: var(--shadow-sm); transition: transform .08s; }
.cat .ic { font-size: 32px; display: block; line-height: 1.3; }
.cat:active { transform: translate(2px, 2px); box-shadow: none; }
.cat.random { background: var(--sun-soft); grid-column: span 2; display: flex; align-items: center; justify-content: center; gap: 8px; }
.cat.random .ic { font-size: 22px; display: inline; }
.cat.disabled { opacity: .5; box-shadow: none; }
.togglecats { display: flex; flex-wrap: wrap; gap: 8px; }
.tcat { border: 2px solid var(--line); border-radius: 999px; padding: 5px 12px; background: #fff; font-weight: 700; font-size: 14px; }
.tcat.on { background: var(--lie); color: #fff; }

/* ── السؤال */
.question { background: var(--ink); color: #fff; border: 2.5px solid var(--line); border-radius: 22px; padding: 22px 18px; box-shadow: 5px 5px 0 var(--lie); margin: 14px 0 18px; }
.question .cat-tag { display: inline-block; font-size: 13px; font-weight: 800; background: rgba(255,255,255,.14); border-radius: 999px; padding: 2px 12px; margin-bottom: 8px; }
.question .text { font-size: 23px; font-weight: 800; line-height: 1.65; }
.question .blank { display: inline-block; min-width: 86px; border-bottom: 4px solid var(--sun); color: var(--sun); text-align: center; line-height: 1.2; margin: 0 4px; }

/* ── المؤقت */
.timer { position: relative; height: 14px; border: 2px solid var(--line); border-radius: 999px; background: #fff; overflow: hidden; }
.timer i { position: absolute; inset: 0; background: var(--truth); transform-origin: right; transition: transform .25s linear, background .3s; }
.timer.low i { background: var(--lie); }
.timerow { display: flex; align-items: center; gap: 10px; margin: 6px 0 4px; }
.timerow .timer { flex: 1; }
.timerow b { min-width: 34px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 900; }

/* ── الخيارات */
.options { display: grid; gap: 10px; }
.opt { border: 2.5px solid var(--line); background: #fff; border-radius: 16px; padding: 15px 16px; font-size: 19px; font-weight: 800; text-align: right; box-shadow: var(--shadow-sm); transition: transform .08s; width: 100%; }
.opt:active { transform: translate(2px, 2px); box-shadow: none; }
.opt.chosen { background: var(--sun); }
.mine { border: 2.5px dashed var(--line); border-radius: 16px; padding: 10px 14px; background: var(--lie-soft); font-weight: 700; margin-top: 12px; }

.suggest { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.suggest button { border: 2px dashed var(--line); background: var(--sun-soft); border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: 14px; }

/* ── الكشف */
.reveal-item { border: 2.5px solid var(--line); border-radius: 18px; background: #fff; padding: 14px 16px; margin: 12px 0; box-shadow: var(--shadow-sm); position: relative; animation: pop .45s cubic-bezier(.2,1.4,.4,1) both; }
.reveal-item .t { font-size: 21px; font-weight: 900; }
.reveal-item .who { margin-top: 8px; font-weight: 700; font-size: 15px; }
.reveal-item .voters { margin-top: 8px; }
.reveal-item.truth { background: var(--truth-soft); border-color: var(--truth); box-shadow: 4px 4px 0 var(--truth); }
.reveal-item.lie .stamp { background: var(--lie); }
.stamp { position: absolute; top: -12px; left: 12px; color: #fff; background: var(--truth); border: 2px solid var(--line); border-radius: 10px; padding: 0 10px; font-weight: 900; font-size: 14px; transform: rotate(-4deg); }
.plus { color: var(--truth); font-weight: 900; }
@keyframes pop { from { opacity: 0; transform: scale(.85) translateY(10px); } to { opacity: 1; transform: none; } }

/* ── النقاط */
.board { display: grid; gap: 8px; }
.brow { display: flex; align-items: center; gap: 10px; border: 2px solid var(--line); border-radius: 14px; padding: 8px 12px; background: #fff; }
.brow .rank { width: 26px; font-weight: 900; text-align: center; }
.brow .nm { flex: 1; font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brow .sc { font-weight: 900; font-variant-numeric: tabular-nums; }
.brow .d { font-size: 13px; font-weight: 800; color: var(--truth); min-width: 52px; text-align: left; }
.brow.top { background: var(--sun-soft); }
.teamcard { border: 2.5px solid var(--line); border-radius: 16px; padding: 10px 12px; background: #fff; margin-bottom: 10px; }
.teamcard .th { display: flex; align-items: center; gap: 8px; font-weight: 900; }
.teamcard .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.teamcard .members { margin-top: 8px; }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 18px 0 8px; }
.podium .p { flex: 1; max-width: 140px; text-align: center; }
.podium .bar { border: 2.5px solid var(--line); border-radius: 14px 14px 0 0; box-shadow: var(--shadow-sm); display: grid; place-items: center; font-size: 30px; font-weight: 900; }
.podium .n { font-weight: 900; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .s { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.p1 .bar { height: 130px; background: var(--sun); }
.p2 .bar { height: 96px; background: #fff; }
.p3 .bar { height: 72px; background: var(--lie-soft); }

/* ── شريط المضيف السفلي */
.dock { position: fixed; bottom: 0; left: 0; right: 0; padding: 10px 16px calc(10px + var(--safe-b)); background: rgba(255,243,230,.94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-top: 2.5px solid var(--line); z-index: 10; }
.dock .inner { max-width: 520px; margin: 0 auto; display: flex; gap: 10px; }
.dock .inner > .btn { flex: 1; }

/* ── الإعدادات */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 2px dashed #EADBCB; }
.setting:last-child { border-bottom: 0; }
.setting .k { font-weight: 800; }
.setting .k small { display: block; font-weight: 600; color: var(--ink-2); font-size: 13px; }
.stepper { display: flex; align-items: center; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; flex: none; }
.stepper button { width: 38px; height: 38px; border: 0; background: var(--sun-soft); font-size: 20px; font-weight: 900; }
.stepper span { min-width: 46px; text-align: center; font-weight: 900; font-variant-numeric: tabular-nums; }
.switch { position: relative; width: 56px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border: 2px solid var(--line); border-radius: 999px; background: #fff; transition: background .2s; }
.switch i::after { content: ''; position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); transition: transform .2s; }
.switch input:checked + i { background: var(--truth); }
.switch input:checked + i::after { transform: translateX(-24px); background: #fff; border: 2px solid var(--line); top: 2px; }
select.mini { border: 2px solid var(--line); border-radius: 10px; padding: 4px 8px; background: #fff; font-weight: 700; font-size: 14px; max-width: 140px; }

details.how { margin-top: 10px; }
details.how summary { font-weight: 800; cursor: pointer; list-style: none; }
details.how summary::-webkit-details-marker { display: none; }
details.how ol { padding-inline-start: 22px; margin: 10px 0 0; }
details.how li { margin-bottom: 6px; }

/* ── شاشة التمرير (أوفلاين) */
.pass { text-align: center; padding: 30px 10px; }
.pass .big { font-size: 34px; font-weight: 900; margin: 10px 0 4px; }
.pass .hand { font-size: 64px; display: block; animation: wiggle 1.6s ease-in-out infinite; }
@keyframes wiggle { 0%,100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }

.waiting { text-align: center; padding: 18px 8px; }
.waiting .em { font-size: 52px; display: block; animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.banner { border: 2.5px solid var(--line); background: var(--sun); border-radius: 14px; padding: 8px 12px; font-weight: 900; text-align: center; margin: 10px 0; box-shadow: var(--shadow-sm); }
.net { font-size: 13px; font-weight: 800; }
.net.on { color: var(--truth); }
.net.off { color: var(--danger); }

#toast { visibility: hidden; position: fixed; top: 14px; left: 50%; transform: translate(-50%, -200%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 14px; font-weight: 800; z-index: 50; transition: transform .25s, visibility .25s; max-width: calc(100% - 32px); text-align: center; box-shadow: 3px 3px 0 var(--lie); }
#toast.show { transform: translate(-50%, 0); visibility: visible; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border: 1.5px solid var(--line); border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 560px) { #app { padding-top: 30px; } }
