/* Pixel AE (https://essssam.itch.io/pixel-ae, CC0) — Arabic + English pixel font, 10px default size.
   Download it from itch.io and put PixelAE-Regular.ttf (and PixelAE-Bold.ttf) in public/assets/fonts/. */
@font-face { font-family: 'Pixel AE'; font-weight: 400; font-display: swap;
  src: url('assets/fonts/PixelAE-Regular.ttf') format('truetype'), url('assets/fonts/PixelAE.ttf') format('truetype'); }
@font-face { font-family: 'Pixel AE'; font-weight: 700; font-display: swap;
  src: url('assets/fonts/PixelAE-Bold.ttf') format('truetype'), url('assets/fonts/PixelAE-Regular.ttf') format('truetype'); }
:root { --ink:#0d0b14; --panel:#2b2540; --panel2:#3a3156; --hi:#f6c83c; --txt:#f4eedd; --good:#2f6b3a; --bad:#7a2f35; --line:#4a4260; --muted:#b9b1c9; }
[hidden] { display:none !important; }
html, body { margin:0; height:100%; background:#17141f; overflow:hidden; touch-action:none;
  -webkit-user-select:none; user-select:none; -webkit-tap-highlight-color:transparent;
  font-family:"Pixel AE", "Press Start 2P", "Segoe UI", Tahoma, sans-serif; color:var(--txt); }
html[lang="ar"] body, html[lang="ar"] button, html[lang="ar"] input { font-family:"Pixel AE", "Noto Kufi Arabic", "Segoe UI", Tahoma, sans-serif; }
canvas#game { position:fixed; inset:0; width:100vw; height:100vh; display:block; image-rendering:pixelated; }
button, select, input { font-family:inherit; font-size:11px; color:var(--txt); }
button { cursor:pointer; touch-action:manipulation; }
.px { background:var(--panel); border:3px solid var(--ink); box-shadow:inset -3px -3px 0 rgba(0,0,0,.35), inset 3px 3px 0 rgba(255,255,255,.12);
  border-radius:0; padding:8px 10px; }
.px:active, .px.on { background:var(--panel2); box-shadow:inset 3px 3px 0 rgba(0,0,0,.35); }
.px.on { outline:3px solid var(--hi); }
button:disabled { opacity:.5; cursor:default; }
.muted { color:var(--muted); } .small { font-size:8px; line-height:1.8; } p { line-height:1.9; font-size:10px; margin:8px 0; }
.pre { white-space:pre-wrap; }

#topRight { position:fixed; top:calc(10px + env(safe-area-inset-top)); right:calc(10px + env(safe-area-inset-right));
  display:flex; gap:6px; align-items:center; flex-wrap:wrap; justify-content:flex-end; max-width:60vw; z-index:3; }
#topRight .px { font-size:16px; padding:6px 8px; line-height:1; }
#adminBar { display:flex; gap:6px; }
#roomSel { background:var(--panel); border:3px solid var(--ink); padding:7px 4px; max-width:130px; font-size:9px; }

#controls { position:fixed; right:calc(16px + env(safe-area-inset-right)); bottom:calc(18px + env(safe-area-inset-bottom));
  display:grid; grid-template-columns:auto auto; grid-template-rows:auto auto; gap:10px; align-items:end; z-index:3; }
#controls .small { width:52px; height:52px; font-size:20px; padding:0; }
#btnE { grid-row:1 / span 2; grid-column:2; width:80px; height:80px; border-radius:50%; font-size:26px;
  background:#c94040; border:4px solid var(--ink); box-shadow:inset -4px -4px 0 rgba(0,0,0,.35), inset 4px 4px 0 rgba(255,255,255,.25); }
#btnE.ready { background:#e8a33a; animation:pulse 0.8s infinite alternate; }
#btnE:active { transform:translateY(2px); }
@keyframes pulse { to { transform:scale(1.08); } }
#emotePanel { position:fixed; right:calc(16px + env(safe-area-inset-right)); bottom:calc(140px + env(safe-area-inset-bottom));
  display:grid; grid-template-columns:repeat(5, 48px); gap:6px; background:var(--panel); border:3px solid var(--ink); padding:8px; z-index:4; }
#emotePanel button { width:48px; height:48px; padding:4px; background:#fff; border:3px solid var(--ink); }
#emotePanel canvas { width:36px; height:39px; image-rendering:pixelated; pointer-events:none; }
#chatBar { position:fixed; left:50%; transform:translateX(-50%); top:calc(10px + env(safe-area-inset-top)); width:min(92vw, 480px); display:flex; gap:6px; z-index:5; }
#chatBar input { flex:1; background:#fff; color:#111; border:3px solid var(--ink); padding:10px; font-size:12px; user-select:text; -webkit-user-select:text; }

#toasts { position:fixed; left:50%; transform:translateX(-50%); top:calc(64px + env(safe-area-inset-top));
  display:flex; flex-direction:column; gap:6px; align-items:center; pointer-events:none; z-index:30; width:94vw; }
.toast { background:var(--panel); border:3px solid var(--ink); padding:9px 12px; font-size:10px; line-height:1.5; text-align:center; max-width:440px;
  animation:pop .2s ease-out; transition:opacity .4s, transform .4s; }
.toast.out { opacity:0; transform:translateY(-8px); }
.toast.good { background:var(--good); } .toast.bad { background:var(--bad); }
.toast.badge { background:linear-gradient(#3b2f12, #2a2110); border-color:var(--hi); font-size:11px; padding:12px 16px; }
@keyframes pop { from { transform:scale(.7); opacity:0; } }
#status { position:fixed; left:50%; bottom:40%; transform:translateX(-50%); z-index:40; }

/* ---------- cards / overlays ---------- */
.overlay { position:fixed; inset:0; background:rgba(10,8,16,.74); display:flex; align-items:center; justify-content:center; z-index:10; padding:10px; box-sizing:border-box; }
.card { background:var(--panel); border:4px solid var(--ink); box-shadow:inset -4px -4px 0 rgba(0,0,0,.35), inset 4px 4px 0 rgba(255,255,255,.1);
  padding:16px; width:min(94vw, 480px); max-height:92vh; overflow:auto; box-sizing:border-box; -webkit-user-select:text; user-select:text; }
.card header { display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:12px; }
.card h2 { font-size:12px; color:var(--hi); margin:0; line-height:1.6; }
.card h3 { font-size:11px; color:var(--hi); margin:4px 0 10px; line-height:1.6; }
#mClose, #dashClose { padding:4px 8px; font-size:12px; }
.card .primary { display:block; width:100%; margin:10px 0 0; padding:12px 8px; background:var(--good); border:3px solid var(--ink); font-size:11px;
  box-shadow:inset -3px -3px 0 rgba(0,0,0,.35), inset 3px 3px 0 rgba(255,255,255,.12); }
.card .secondary { display:block; width:100%; margin:8px 0 0; padding:10px 8px; background:var(--panel2); border:3px solid var(--ink); font-size:10px; }
.card .secondary.danger { background:var(--bad); }
.card .mini { background:var(--panel2); border:2px solid var(--ink); font-size:8px; padding:6px 8px; margin:6px 0; }
.choices { display:flex; flex-direction:column; gap:8px; margin:10px 0; }
.choice { text-align:start; line-height:1.7; font-size:10px; padding:10px 12px; background:var(--panel2); border:3px solid var(--ink); color:var(--txt); }
.choice.ok { background:var(--good); } .choice.bad { background:var(--bad); } .choice.locked { opacity:.6; } .choice.here { opacity:.5; }
.choice.mono { font-family:ui-monospace, Menlo, Consolas, monospace; font-size:12px; direction:ltr; text-align:left; }
.inp { display:block; width:100%; box-sizing:border-box; background:#fff; color:#111; border:3px solid var(--ink); padding:10px; font-size:12px; margin:8px 0; }
.lbl { display:block; font-size:9px; color:var(--muted); margin:12px 0 4px; }
.fb { margin:10px 0; padding:10px; font-size:9px; line-height:1.8; border:3px solid var(--ink); }
.fb.good { background:var(--good); } .fb.bad { background:var(--bad); }
.prog { font-size:8px; color:var(--muted); margin-bottom:8px; }
.big { font-size:14px; color:var(--hi); line-height:1.6; margin:6px 0 12px; }
.lesson { background:rgba(0,0,0,.25); padding:10px; border-inline-start:4px solid var(--hi); font-size:9px; line-height:1.9; }
.hint { background:rgba(246,200,60,.15); padding:8px; font-size:9px; line-height:1.8; margin:8px 0; }
.kbd { color:var(--muted); font-size:8px; }
.claim { background:var(--ink); padding:12px; margin:12px 0; text-align:center; font-size:9px; line-height:1.8; }
.claim b { display:block; font-size:16px; color:var(--hi); letter-spacing:3px; margin:6px 0; }
.signbox p { margin:6px 0; }
.lvl { padding:2px 6px; font-size:8px; } .lvl.high { background:#8a5a1e; } .lvl.critical { background:#8a2e2e; }
.post { background:rgba(0,0,0,.25); padding:8px 10px; margin:6px 0; font-size:9px; line-height:1.8; }
.post .by { color:var(--hi); font-size:8px; margin-bottom:4px; }

/* challenge content */
.email { background:#f4f2ee; color:#1d1d24; border:3px solid var(--ink); padding:10px; margin:8px 0; font-size:9px; line-height:1.8; }
.email .meta { border-bottom:1px solid #cfcac2; padding:3px 0; word-break:break-all; }
.email .body p { margin:8px 0; }
.email .link { background:none; border:0; padding:0; color:#1a52c4; text-decoration:underline; font-size:9px; cursor:pointer; }
.email .real { background:#ffe9b0; color:#5a3a00; padding:6px; margin:6px 0; font-size:8px; word-break:break-all; direction:ltr; }
.email .hdr { background:#1d1f2a; color:#9ef0a0; padding:8px; font-size:8px; white-space:pre-wrap; direction:ltr; text-align:left; margin:6px 0 0; }
.email .mini { background:#e4e0d8; color:#1d1d24; border-color:#9a948a; }
.email .att { font-size:8px; margin:6px 0; }
.hiddentext { background:#fff3c4; color:#5a3a00; padding:8px; margin:8px 0; font-size:8px; line-height:1.8; }
.notif { background:#1d1f2a; border:3px solid var(--ink); padding:10px; margin:8px 0; font-size:9px; line-height:1.8; }
.notif .app { color:var(--hi); font-size:8px; margin-bottom:4px; }
.phone { background:#1d1f2a; border:3px solid var(--ink); padding:10px; margin:8px 0; }
.phone .cid { font-size:8px; color:var(--muted); margin:4px 0; } .phone .name { font-size:10px; color:var(--hi); margin:4px 0 8px; }
.bubble { background:#3a3156; padding:8px 10px; margin:6px 0; font-size:9px; line-height:1.8; border-radius:0 10px 10px 10px; }
.sign { background:#f6e04a; color:#2b2b33; padding:10px; margin:8px 0; font-size:9px; line-height:1.8; border:3px solid var(--ink); }
.ai { background:#152238; border:3px solid #3a74d9; padding:10px; margin:8px 0; font-size:9px; line-height:1.8; }
.ai .t { color:#9fd8ff; font-size:8px; margin-bottom:4px; }
.pgrid { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin:8px 0; }
.pcard { background:rgba(0,0,0,.25); padding:8px; display:flex; gap:8px; align-items:flex-start; font-size:8px; line-height:1.7; }
.pcard canvas { width:40px; height:48px; image-rendering:pixelated; flex:none; }
.pcard b { display:block; color:var(--hi); margin-bottom:4px; }
.scene { margin:8px 0; background:#fff; border:3px solid var(--ink); } .scene svg { display:block; width:100%; height:auto; }
.scene .hs { fill:rgba(255,255,255,0); stroke:rgba(255,209,102,.6); stroke-width:1.5; stroke-dasharray:3 3; cursor:pointer; }
.scene .hs.sel { fill:rgba(255,209,102,.35); stroke:#ffd166; stroke-dasharray:none; }
.scene .hs.ok { fill:rgba(6,214,160,.35); stroke:#06d6a0; stroke-dasharray:none; }
.scene .hs.miss { fill:rgba(239,71,111,.2); stroke:#ef476f; stroke-dasharray:none; }
.scene .hs.bad { fill:rgba(239,71,111,.45); stroke:#ef476f; stroke-dasharray:none; }
.grid { display:grid; grid-template-columns:1fr 1fr; gap:6px; margin:8px 0; }
.tile { font-size:8px; line-height:1.6; padding:8px; background:var(--panel2); border:3px solid var(--ink); color:var(--txt); text-align:start; }
.tile.sel { outline:3px solid var(--hi); } .tile.ok { background:var(--good); } .tile.miss { background:#4a3b1e; } .tile.bad { background:var(--bad); }
.notes { font-size:8px; line-height:1.8; padding-inline-start:16px; } .notes .pass { color:#9ef0a0; }
.ransom { background:#5a1416; border:3px solid #e04848; padding:12px; margin:8px 0; font-size:9px; line-height:1.9; }
.ransom b { display:block; color:#ff6b6b; font-size:10px; margin-bottom:6px; }
.timer { font-size:12px; color:var(--hi); margin:8px 0; }
.seq { font-size:9px; line-height:1.9; padding-inline-start:18px; color:#9ef0a0; margin:6px 0; }
.rules { list-style:none; padding:0; margin:8px 0; font-size:8px; line-height:1.9; }
.rules li::before { content:'✖ '; color:#ff8a8a; } .rules li.pass::before { content:'✔ '; color:#9ef0a0; }

/* join card */
.jcard { text-align:center; }
.jcard .logo { font-size:22px; color:var(--hi); text-shadow:3px 3px 0 var(--ink); margin:6px 0; }
.jcard .logo .ar { display:block; font-size:16px; margin-top:8px; }
.jcard .tag { font-size:8px; color:var(--muted); margin-bottom:14px; }
.jcard p, .jcard .choices, .jcard .lbl { text-align:start; }
.langq { font-size:12px; } .langq.last { margin-bottom:14px; } .langbtn { font-size:14px; }
#preview { display:block; margin:10px auto; width:120px; height:132px; image-rendering:pixelated;
  background:repeating-conic-gradient(#e9e6e0 0% 25%, #f4f2ee 0% 50%) 0 0/24px 24px; border:3px solid var(--ink); }
.rows { text-align:start; }
.row { display:flex; align-items:center; gap:6px; margin:8px 0; }
.row .lbl { width:100px; font-size:8px; margin:0; }
.row .val { flex:1; text-align:center; font-size:9px; display:flex; align-items:center; justify-content:center; gap:6px; }
.row .px { padding:6px 10px; }
.adm { color:var(--hi); font-style:normal; }
.sw { display:inline-block; width:18px; height:18px; border:3px solid var(--ink); }
.btnrow { display:flex; gap:8px; margin-top:10px; }
.btnrow .secondary, .btnrow .primary { flex:1; margin:0; }

/* dashboard */
.dashcard { width:min(96vw, 600px); }
#dashTabs { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:12px; }
.tab { font-size:8px; padding:7px 8px; }
.stats { display:grid; grid-template-columns:repeat(4, 1fr); gap:6px; margin-bottom:14px; }
.stats div { background:var(--ink); padding:10px 4px; text-align:center; }
.stats b { display:block; font-size:13px; color:var(--hi); font-weight:normal; margin-bottom:6px; }
.stats span { font-size:6px; color:var(--muted); }
.missions { list-style:none; padding:0; margin:0 0 10px; }
.missions li { display:flex; gap:10px; align-items:flex-start; padding:9px 6px; border-bottom:2px solid rgba(0,0,0,.3); font-size:9px; line-height:1.6; }
.missions li.done { opacity:.6; } .missions li.locked { opacity:.45; }
.missions .st { width:16px; color:#9ef0a0; } .missions li.open .st { color:var(--hi); }
.missions .mt { flex:1; } .missions b { font-weight:normal; } .missions small { font-size:7px; color:var(--muted); }
.missions .mp { color:var(--hi); font-size:8px; }
.achs { display:grid; grid-template-columns:repeat(auto-fill, minmax(118px, 1fr)); gap:6px; }
.achs .a { background:var(--ink); padding:10px 6px; text-align:center; opacity:.45; }
.achs .a.on { opacity:1; outline:2px solid #6b5520; }
.achs .ico { display:block; font-size:22px; margin-bottom:6px; }
.achs b { display:block; font-size:7px; font-weight:normal; color:var(--hi); margin-bottom:4px; line-height:1.5; }
.achs small { font-size:6px; color:var(--muted); line-height:1.6; }
table.board, table.ptable { width:100%; border-collapse:collapse; font-size:8px; }
.board th, .ptable th { text-align:start; color:var(--hi); font-weight:normal; padding:6px 4px; border-bottom:2px solid var(--ink); }
.board td, .ptable td { padding:8px 4px; border-bottom:1px solid rgba(0,0,0,.3); }
.board tr.me td { background:rgba(246,200,60,.15); }
.dot { display:inline-block; width:6px; height:6px; background:#4fd070; margin-inline-end:6px; vertical-align:middle; }
.bars { margin-bottom:16px; }
.bar { display:grid; grid-template-columns:130px 1fr 26px; gap:6px; align-items:center; font-size:7px; margin:5px 0; }
.bar i { display:block; height:10px; background:#3aa8a0; min-width:2px; } .bar b { font-weight:normal; text-align:end; }
@media (max-width:420px) { .bar { grid-template-columns:90px 1fr 22px; } .pgrid { grid-template-columns:1fr; } }
