/* Sudan Game Hub — mobile-first, RTL/LTR aware (logical properties) */
:root {
  color-scheme: dark;
  --bg0: #060d1b;
  --bg1: #0d1b35;
  --bg2: #15264a;
  --card: rgba(255, 255, 255, .07);
  --card2: rgba(255, 255, 255, .11);
  --stroke: rgba(255, 255, 255, .13);
  --gold: #f6c453;
  --gold2: #ff9f43;
  --teal: #2dd4bf;
  --red: #ff5d6c;
  --green: #34d399;
  --text: #f5f2e9;
  --muted: #9fb0c8;
  --radius: 20px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Noto Sans Arabic", "Segoe UI", Tahoma, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg0);
  min-height: 100svh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(900px 500px at 85% -5%, rgba(246, 196, 83, .22), transparent 60%),
    radial-gradient(700px 500px at 0% 20%, rgba(45, 212, 191, .14), transparent 60%),
    linear-gradient(180deg, var(--bg1), var(--bg0) 70%);
}
body::after { /* faint geometric pattern */
  content: ""; position: fixed; inset: 0; z-index: -1; opacity: .05; pointer-events: none;
  background-image: repeating-linear-gradient(45deg, #fff 0 1px, transparent 1px 22px),
                    repeating-linear-gradient(-45deg, #fff 0 1px, transparent 1px 22px);
}
button { font-family: inherit; color: inherit; }
.hidden { display: none !important; }

#app { width: 100%; max-width: 520px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 10px) 14px calc(env(safe-area-inset-bottom) + 22px); min-height: 100svh; }
.screen { animation: fadeUp .35s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.05rem; letter-spacing: .2px; }
.brand .flag { font-size: 1.35rem; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 14px; border: 1px solid var(--stroke);
  background: var(--card); font-size: 1.05rem; cursor: pointer; display: grid; place-items: center;
}
.icon-btn:active { transform: scale(.93); }
.top-actions { display: flex; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--stroke); font-size: .85rem; font-weight: 700;
}
.pill b { color: var(--gold); }

/* ---------- hero / player ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 26px; padding: 18px 18px 74px;
  background: linear-gradient(160deg, #24407a, #14264b 60%, #0e1b36); border: 1px solid var(--stroke);
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.hero h1, .hero p { position: relative; z-index: 1; padding-inline-end: 84px; }
.hero h1 { margin: 0 0 4px; font-size: 1.6rem; line-height: 1.25; }
.hero p { margin: 0; color: #cdd8ea; font-size: .92rem; }
.hero .sun {
  position: absolute; inset-inline-end: 22px; top: 18px; width: 64px; height: 64px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff2b0, var(--gold) 55%, var(--gold2));
  box-shadow: 0 0 50px 12px rgba(246, 196, 83, .45); animation: glow 4s ease-in-out infinite;
}
@keyframes glow { 50% { box-shadow: 0 0 70px 20px rgba(246, 196, 83, .6); } }
.hero svg.dunes { position: absolute; inset-inline: 0; bottom: 0; width: 100%; height: 70px; }

.player { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--stroke); margin-bottom: 14px; }
.avatar { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 1.8rem; background: linear-gradient(145deg, var(--gold), var(--gold2)); color: #3a2300; font-weight: 900; flex: none; }
.player .meta { flex: 1; min-width: 0; }
.player .name { font-weight: 800; }
.player .title { color: var(--muted); font-size: .8rem; }
.xpbar { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .12); overflow: hidden; margin-top: 6px; }
.xpbar > i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--teal), var(--gold)); transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.stats { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

/* ---------- cards / tiles ---------- */
.grid { display: grid; gap: 12px; }
.tile {
  position: relative; overflow: hidden; border-radius: 22px; border: 1px solid var(--stroke); min-height: 128px;
  display: flex; align-items: flex-end; padding: 16px; cursor: pointer; text-align: start; color: #fff; width: 100%;
  background-size: cover; background-position: center; box-shadow: var(--shadow); transition: transform .12s;
}
.tile:active { transform: scale(.985); }
.tile::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(5, 10, 25, .1), rgba(5, 10, 25, .85)); }
.tile > * { position: relative; }
.tile h3 { margin: 0 0 2px; font-size: 1.2rem; }
.tile p { margin: 0; font-size: .85rem; color: #d9e2f2; }
.tile .badge { position: absolute; inset-inline-end: 12px; top: 12px; background: rgba(0, 0, 0, .55); border: 1px solid var(--stroke); padding: 5px 10px; border-radius: 99px; font-size: .78rem; font-weight: 800; backdrop-filter: blur(4px); }
.tile.big { min-height: 170px; }
.tile .progress { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .2); margin-top: 8px; overflow: hidden; }
.tile .progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); }
.tile.done::after { content: "✓"; position: absolute; inset-inline-end: 12px; bottom: 12px; width: 30px; height: 30px; border-radius: 50%; background: var(--green); color: #052; display: grid; place-items: center; font-weight: 900; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card { border-radius: var(--radius); background: var(--card); border: 1px solid var(--stroke); padding: 16px; box-shadow: var(--shadow); }
.section-title { margin: 18px 4px 8px; font-weight: 800; font-size: .95rem; color: var(--muted); letter-spacing: .3px; }

/* ---------- buttons ---------- */
.btn {
  display: block; width: 100%; padding: 15px 18px; border: 0; border-radius: 16px; cursor: pointer; font-size: 1.05rem; font-weight: 800;
  background: linear-gradient(180deg, var(--gold), var(--gold2)); color: #3a2300; box-shadow: 0 6px 0 #b8741f, 0 12px 24px rgba(0, 0, 0, .3);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b8741f, 0 6px 12px rgba(0, 0, 0, .3); }
.btn.alt { background: var(--card2); color: var(--text); box-shadow: none; border: 1px solid var(--stroke); }
.btn.alt:active { transform: scale(.98); }
.btn.green { background: linear-gradient(180deg, #4ade80, #22b36b); color: #052e16; box-shadow: 0 6px 0 #167a4a, 0 12px 24px rgba(0, 0, 0, .3); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn + .btn { margin-top: 10px; }
.sticky-bottom { position: sticky; bottom: calc(env(safe-area-inset-bottom) + 10px); z-index: 20; margin-top: 14px; }

/* ---------- play header ---------- */
.playbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.playbar .grow { flex: 1; }
.dots { display: flex; gap: 5px; flex: 1; }
.dots i { flex: 1; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .15); transition: background .3s; }
.dots i.cur { background: var(--gold); }
.dots i.ok { background: var(--green); }
.dots i.no { background: var(--red); }

.qcard { padding: 18px; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 5px 11px; border-radius: 99px; background: rgba(246, 196, 83, .14); border: 1px solid rgba(246, 196, 83, .35); color: var(--gold); font-weight: 800; font-size: .78rem; margin-bottom: 10px; }
.qtext { font-size: 1.3rem; line-height: 1.55; margin: 0 0 14px; font-weight: 700; white-space: pre-line; }
.qimg { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 16px; margin-bottom: 12px; border: 1px solid var(--stroke); background: #0b1428; }
.timer { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .12); overflow: hidden; margin: 2px 0 14px; }
.timer > i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); border-radius: 99px; }
.timer.urgent > i { background: linear-gradient(90deg, var(--gold2), var(--red)); }
.timer.urgent { animation: throb .6s infinite; }
@keyframes throb { 50% { transform: scaleY(1.5); } }

.opts { display: grid; gap: 10px; }
.opt {
  position: relative; text-align: start; padding: 15px 16px; border-radius: 16px; border: 2px solid var(--stroke); background: rgba(255, 255, 255, .06);
  font-size: 1.05rem; font-weight: 600; cursor: pointer; transition: transform .08s, background .2s, border-color .2s;
}
.opt:active { transform: scale(.98); }
.opt.ok { border-color: var(--green); background: rgba(52, 211, 153, .2); animation: pop .35s; }
.opt.no { border-color: var(--red); background: rgba(255, 93, 108, .18); animation: shake .4s; }
.opt.gone { opacity: .25; pointer-events: none; text-decoration: line-through; }
.opt:disabled { cursor: default; }
@keyframes pop { 50% { transform: scale(1.04); } }
@keyframes shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }

.lifelines { display: flex; gap: 8px; margin-top: 12px; }
.life { flex: 1; min-width: 0; padding: 10px 6px; white-space: nowrap; border-radius: 14px; border: 1px dashed var(--stroke); background: transparent; cursor: pointer; font-weight: 700; font-size: .85rem; }
.life:disabled { opacity: .35; }
.fact { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: rgba(246, 196, 83, .1); border: 1px solid rgba(246, 196, 83, .3); color: #f6e9c3; font-size: .95rem; line-height: 1.55; animation: fadeUp .3s both; }
.combo { position: fixed; inset-inline: 0; top: 18%; text-align: center; pointer-events: none; font-weight: 900; font-size: 2.2rem; color: var(--gold); text-shadow: 0 4px 20px rgba(0, 0, 0, .6); animation: floatUp 1s ease forwards; z-index: 50; }
@keyframes floatUp { from { opacity: 1; transform: translateY(20px) scale(.8); } to { opacity: 0; transform: translateY(-60px) scale(1.2); } }

/* ---------- landmark puzzle stage ---------- */
.stage { position: relative; width: 100%; aspect-ratio: 4/3; border-radius: 22px; overflow: hidden; background: #0a1328; border: 1px solid var(--stroke); box-shadow: var(--shadow); }
.stage img, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.stage img { transition: transform .8s cubic-bezier(.2, .8, .2, 1), filter .8s ease; will-change: transform, filter; }
.stage .cover { position: absolute; background: linear-gradient(135deg, #1a2d57, #0c1730); transition: opacity .6s ease; }
.stage .cover::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(45deg, rgba(246, 196, 83, .09) 0 6px, transparent 6px 12px); }
.stage .spin { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-weight: 700; }
.steps { display: flex; gap: 5px; margin: 10px 0 12px; }
.steps i { flex: 1; height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .15); }
.steps i.on { background: var(--teal); }
.mode-tag { position: absolute; inset-inline-start: 10px; top: 10px; z-index: 3; background: rgba(0, 0, 0, .55); border: 1px solid var(--stroke); border-radius: 99px; padding: 4px 10px; font-size: .75rem; font-weight: 800; backdrop-filter: blur(4px); }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choices.three { grid-template-columns: 1fr; }
.choices .opt { text-align: center; padding: 14px 10px; font-size: .98rem; }
.credit { margin-top: 10px; font-size: .72rem; color: var(--muted); line-height: 1.5; }
.credit a { color: var(--teal); }
.reveal-card { margin-top: 12px; animation: fadeUp .4s both; }
.reveal-card h3 { margin: 0 0 2px; font-size: 1.3rem; color: var(--gold); }
.reveal-card .reg { color: var(--teal); font-weight: 700; font-size: .85rem; margin-bottom: 6px; }

/* ---------- level map ---------- */
.chapter { margin-bottom: 18px; }
.chapter-banner { position: relative; height: 96px; border-radius: 20px; overflow: hidden; background-size: cover; background-position: center; display: flex; align-items: flex-end; padding: 12px 14px; border: 1px solid var(--stroke); }
.chapter-banner::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(5, 10, 25, .05), rgba(5, 10, 25, .85)); }
.chapter-banner > * { position: relative; }
.chapter-banner h3 { margin: 0; font-size: 1.05rem; }
.chapter-banner small { color: #cfd9ec; }
.chapter.locked .chapter-banner { filter: grayscale(1) brightness(.6); }
.nodes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; padding: 14px 4px 4px; }
.node {
  position: relative; aspect-ratio: 1; border-radius: 50%; border: 2px solid var(--stroke); background: var(--card2); font-weight: 900; font-size: 1.05rem; cursor: pointer;
  display: grid; place-items: center; transition: transform .1s;
}
.node:active { transform: scale(.92); }
.node small { position: absolute; bottom: -9px; font-size: .62rem; letter-spacing: -1px; white-space: nowrap; }
.node.done { background: linear-gradient(145deg, #1f7a5b, #136148); border-color: var(--green); }
.node.cur { background: linear-gradient(145deg, var(--gold), var(--gold2)); color: #3a2300; border-color: #fff3c4; animation: pulse 1.6s infinite; }
.node.lock { opacity: .4; cursor: not-allowed; }
.node.boss { border-radius: 18px; border-color: var(--red); }
.node.boss::before { content: "👑"; position: absolute; top: -10px; font-size: .9rem; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(246, 196, 83, .6); } 100% { box-shadow: 0 0 0 16px rgba(246, 196, 83, 0); } }

/* ---------- result ---------- */
.result { text-align: center; }
.result h2 { margin: 6px 0 2px; font-size: 1.7rem; }
.stars { display: flex; justify-content: center; gap: 10px; margin: 14px 0; }
.stars span { font-size: 3.2rem; filter: grayscale(1) opacity(.35); transform: scale(.5); }
.stars span.on { filter: drop-shadow(0 4px 12px rgba(246, 196, 83, .7)); animation: starIn .6s cubic-bezier(.2, 1.6, .4, 1) forwards; }
@keyframes starIn { from { transform: scale(0) rotate(-90deg); } to { transform: scale(1) rotate(0); } }
.rewards { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 16px; }
.reward { padding: 9px 14px; border-radius: 14px; background: var(--card2); border: 1px solid var(--stroke); font-weight: 800; }
.squares { font-size: 1.6rem; letter-spacing: 3px; margin: 6px 0 12px; }

/* ---------- passport ---------- */
.pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stamp { position: relative; border-radius: 18px; overflow: hidden; aspect-ratio: 1; border: 1px solid var(--stroke); cursor: pointer; background-size: cover; background-position: center; display: flex; align-items: flex-end; padding: 10px; text-align: start; width: 100%; color: #fff; }
.stamp::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 30%, rgba(5, 10, 25, .9)); }
.stamp > * { position: relative; }
.stamp b { font-size: .92rem; display: block; line-height: 1.25; }
.stamp small { color: var(--teal); font-weight: 700; font-size: .72rem; }
.stamp.locked { background: linear-gradient(145deg, #162a52, #0c1730); cursor: default; }
.stamp.locked::after { content: "🔒"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -60%); font-size: 2.2rem; opacity: .6; }
.stamp.locked::before { background: none; }
.stamp.got::after { content: "✔"; position: absolute; top: 8px; inset-inline-end: 8px; width: 26px; height: 26px; border-radius: 50%; background: var(--green); color: #052; display: grid; place-items: center; font-weight: 900; font-size: .9rem; }

/* ---------- modal / toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(2, 6, 16, .75); backdrop-filter: blur(6px); z-index: 80; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s both; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 520px; max-height: 88svh; overflow: auto; background: linear-gradient(180deg, #172b55, #0d1b35); border: 1px solid var(--stroke); border-radius: 26px 26px 0 0; padding: 18px 18px calc(env(safe-area-inset-bottom) + 22px); animation: fadeUp .3s both; }
.modal h3 { margin: 0 0 10px; }
.modal .close { float: inline-end; }
.toast { position: fixed; inset-inline: 0; bottom: calc(env(safe-area-inset-bottom) + 90px); display: flex; justify-content: center; z-index: 90; pointer-events: none; }
.toast span { background: rgba(10, 18, 36, .95); border: 1px solid var(--stroke); border-radius: 99px; padding: 11px 18px; font-weight: 800; box-shadow: var(--shadow); animation: fadeUp .25s both; }
.stampfx { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; pointer-events: none; }
.stampfx div { font-size: 1.6rem; font-weight: 900; color: var(--gold); border: 5px solid var(--gold); border-radius: 18px; padding: 14px 26px; transform: rotate(-12deg); background: rgba(5, 10, 25, .75); animation: stampIn 1.6s ease forwards; text-align: center; }
@keyframes stampIn { 0% { transform: rotate(-12deg) scale(3); opacity: 0; } 25% { transform: rotate(-12deg) scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: rotate(-12deg) scale(1); opacity: 0; } }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; }

.center { text-align: center; }
.muted { color: var(--muted); }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--stroke); }
.list-row:last-child { border-bottom: 0; }
.toggle { padding: 8px 14px; border-radius: 99px; border: 1px solid var(--stroke); background: var(--card2); font-weight: 800; cursor: pointer; }
footer.note { text-align: center; color: var(--muted); font-size: .75rem; margin-top: 22px; line-height: 1.7; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- optional ad slot (menus/results only) ---------- */
.adslot { margin: 16px 0 4px; min-height: 60px; text-align: center; border-radius: 14px; overflow: hidden; }
.adslot small { display: block; color: var(--muted); font-size: .65rem; margin-bottom: 4px; }
