:root { --bg1:#2a1b5e; --bg2:#150b33; --card:#221355; --line:#3d2a7d; --txt:#f2efff; --dim:#b9aee8; --acc:#ff7a45; --teal:#2dd4bf; }
* { box-sizing: border-box; }
html { min-height:100%; background:linear-gradient(160deg,#2a1b5e,#150b33) fixed; }
body { min-height:100vh; margin:0; font-family:'Noto Kufi Arabic','Segoe UI',Tahoma,Arial,sans-serif; background:linear-gradient(160deg,var(--bg1),var(--bg2)); color:var(--txt); line-height:1.8; }
body.playing { overflow:hidden; }
.wrap { max-width:1060px; margin:0 auto; padding:18px 16px 80px; }
nav.crumbs { font-size:13px; color:var(--dim); margin:4px 0 10px; }
nav.crumbs a { color:var(--dim); text-decoration:none; }
h1 { font-size:24px; line-height:1.5; margin:6px 0 2px; }
.lede { color:var(--dim); margin:0 0 6px; font-size:15px; }
.altnames { font-size:12.5px; color:var(--dim); opacity:.8; margin:0 0 16px; }
h2.sec { font-size:20px; margin:38px 0 10px; padding-right:12px; border-right:4px solid var(--acc); }
[dir="ltr"] h2.sec { padding-right:0; padding-left:12px; border-right:0; border-left:4px solid var(--acc); }
h3 { font-size:16px; margin:18px 0 6px; color:#ffd9c4; }
p, li { font-size:15.5px; }
a { color:#ffb08a; }
.layout { display:grid; grid-template-columns:minmax(0,7fr) minmax(0,3fr); gap:16px; align-items:start; }
.stage { position:sticky; top:14px; background:#0d0724; border:1px solid var(--line); border-radius:18px; overflow:hidden; box-shadow:0 18px 50px rgba(0,0,0,.45); }
.stage-bar { display:flex; align-items:center; gap:10px; padding:9px 12px; background:rgba(255,255,255,.04); border-bottom:1px solid var(--line); }
.chip { background:rgba(45,212,191,.14); color:var(--teal); border:1px solid rgba(45,212,191,.4); font-size:12px; padding:2px 10px; border-radius:999px; white-space:nowrap; }
.stage-title { font-size:15px; font-weight:700; margin:0; flex:1; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.bar-btn { border:1px solid var(--line); background:rgba(255,255,255,.06); color:var(--txt); font-family:inherit; font-size:13px; padding:5px 12px; border-radius:10px; cursor:pointer; white-space:nowrap; }
.bar-btn:hover { border-color:var(--acc); }
.stage-frame { position:relative; aspect-ratio:4/3; background:#0d0724; }
.stage-frame iframe { position:absolute; inset:0; width:100%; height:100%; border:0; display:block; }
.poster { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px; cursor:pointer; border:0; width:100%; background-color:transparent; background-position:center; background-size:cover; color:var(--txt); font-family:inherit; }
.poster .play-circle { width:76px; height:76px; border-radius:50%; background:var(--acc); display:flex; align-items:center; justify-content:center; box-shadow:0 10px 30px rgba(255,122,69,.5); transition:transform .15s; }
.poster:hover .play-circle { transform:scale(1.08); }
.poster .play-circle svg { width:30px; height:30px; fill:#fff; margin-right:-4px; }
[dir="ltr"] .poster .play-circle svg { margin-right:0; margin-left:-4px; }
.poster .play-label { font-size:17px; font-weight:700; text-shadow:0 2px 8px rgba(0,0,0,.7); }
.poster .play-sub { font-size:12.5px; color:var(--dim); text-shadow:0 2px 8px rgba(0,0,0,.7); }
body.playing .stage, .stage:fullscreen { position:fixed; inset:0; z-index:60; border-radius:0; border:0; top:0; display:flex; flex-direction:column; }
body.playing .stage-bar, .stage:fullscreen .stage-bar { flex:0 0 auto; }
body.playing .stage-frame, .stage:fullscreen .stage-frame { aspect-ratio:auto; flex:1 1 auto; min-height:0; height:auto; }
.side { display:flex; flex-direction:column; gap:14px; }
.info-card { background:var(--card); border:1px solid var(--line); border-radius:16px; padding:16px; }
.info-card h2 { font-size:15px; margin:0 0 10px; border:0; padding:0; }
.info-row { display:flex; justify-content:space-between; gap:10px; font-size:13.5px; padding:7px 0; border-bottom:1px dashed rgba(255,255,255,.08); }
.info-row:last-child { border-bottom:0; }
.info-row b { color:var(--dim); font-weight:400; }
.ctrl { display:flex; align-items:center; gap:8px; font-size:13.5px; padding:6px 0; color:var(--dim); }
kbd { display:inline-flex; align-items:center; justify-content:center; min-width:26px; height:26px; background:rgba(255,255,255,.1); border:1px solid var(--line); border-bottom-width:2px; border-radius:7px; padding:0 6px; font-family:inherit; font-size:14px; font-weight:700; color:#fff; }
.rail { display:flex; gap:12px; overflow-x:auto; scroll-snap-type:x mandatory; padding:6px 2px 14px; -webkit-overflow-scrolling:touch; }
.rail::-webkit-scrollbar { height:6px; }
.rail::-webkit-scrollbar-thumb { background:var(--line); border-radius:3px; }
.grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(165px,1fr)); gap:14px; }
.gcard { scroll-snap-align:start; flex:0 0 150px; background:var(--card); border:1px solid var(--line); border-radius:14px; overflow:hidden; text-decoration:none; color:var(--txt); transition:transform .15s, border-color .15s; position:relative; display:block; }
.gcard.big { flex:none; }
.gcard:hover { transform:translateY(-3px); border-color:var(--acc); }
.gcard img { width:100%; aspect-ratio:16/10; height:auto; object-fit:cover; display:block; }
.gcard .nm { display:block; font-size:14px; font-weight:700; padding:8px 10px 2px; }
.gcard .ds { display:block; font-size:11.5px; color:var(--dim); padding:0 10px 10px; }
.gcard .ctalink { display:block; font-size:12px; color:var(--acc); font-weight:700; padding:0 10px 12px; }
.gcard .soon { position:absolute; top:8px; left:8px; background:rgba(13,7,36,.85); border:1px solid var(--line); font-size:11px; padding:2px 8px; border-radius:999px; color:var(--dim); }
figure { margin:18px 0; }
figure img { width:100%; max-width:640px; height:auto; border-radius:12px; border:1px solid var(--line); display:block; }
figcaption { font-size:13px; color:var(--dim); margin-top:6px; }
.faq details { background:var(--card); border:1px solid var(--line); border-radius:12px; padding:12px 16px; margin:10px 0; }
.faq summary { font-weight:700; cursor:pointer; font-size:15.5px; }
.faq details p { color:var(--dim); margin:8px 0 2px; }
footer { margin-top:48px; font-size:13px; color:var(--dim); text-align:center; }
footer a { color:var(--dim); }
@media (max-width:820px) {
  .layout { grid-template-columns:1fr; }
  .stage { position:relative; top:0; }
}
.poster[hidden] { display:none; }
.bar-btn[hidden] { display:none; }

/* ---- portal layout: featured card, shelves, bottom nav ---- */
:root { --acc2:#8b5cf6; }
.hero { text-decoration:none; position:relative; display:flex; align-items:flex-end; border-radius:20px; overflow:hidden; margin:18px 0 26px;
  border:1px solid var(--line); background:var(--card); min-height:300px; }
.hero img { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; display:block; }
.hero .veil { position:absolute; inset:0; background:linear-gradient(180deg, rgba(13,11,30,0) 0%, rgba(13,11,30,.3) 28%, rgba(13,11,30,.88) 62%, rgba(13,11,30,.97) 100%); }
.hero .meta { position:relative; left:0; right:0; bottom:0; padding:16px; width:100%; }
.hero h2, .hero p { text-shadow:0 2px 10px rgba(0,0,0,.75); }
.hero p { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.hero .tag { display:inline-block; font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase;
  color:#ffd9a0; background:rgba(139,92,246,.28); border:1px solid rgba(139,92,246,.55); padding:3px 9px; border-radius:999px; }
.hero h2 { font-size:24px; margin:8px 0 4px; }
.hero p { margin:0 0 12px; color:#d9d4f2; font-size:13.5px; }
.hero .play { display:inline-flex; align-items:center; gap:8px; background:linear-gradient(135deg,#FF7043,#FFCA28);
  color:#22122b; font-weight:800; font-size:15px; padding:12px 22px; border-radius:999px; }
.shelf { margin:0 0 30px; }
.shelf-h { display:flex; align-items:baseline; justify-content:space-between; gap:12px; margin-bottom:4px; }
.shelf-h h2 { min-width:0; }
.shelf-h a { flex:none; }
.shelf-h h2 { margin:0; font-size:18px; }
.shelf-h a { font-size:13px; color:var(--acc); font-weight:700; white-space:nowrap; }
.shelf .sub { margin:0 0 12px; color:var(--dim); font-size:12.5px; }
.row { display:grid; grid-auto-flow:column; grid-auto-columns:44%; gap:12px; overflow-x:auto;
  scroll-snap-type:x mandatory; padding-bottom:6px; scrollbar-width:none; }
.row::-webkit-scrollbar { display:none; }
.tile { position:relative; display:block; scroll-snap-align:start; border-radius:16px; overflow:hidden;
  border:1px solid var(--line); background:var(--card); }
.tile img { width:100%; aspect-ratio:16/10; height:auto; object-fit:cover; display:block; }
.tile .nm { position:absolute; left:0; right:0; bottom:0; padding:7px 10px; font-size:13px; font-weight:700;
  color:#fff; text-shadow:0 1px 2px rgba(0,0,0,.9); background:rgba(11,9,24,.87);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.grid3 { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.grid3 .tile { min-width:0; }
.grid3 .tile .nm { font-size:12px; padding:6px 7px; }
.catsec { margin:0 0 30px; }
.catsec-h { display:flex; align-items:center; gap:8px; margin-bottom:12px; }
.catsec-h .dot { width:26px; height:26px; border-radius:8px; display:grid; place-items:center; font-size:14px;
  background:rgba(139,92,246,.22); border:1px solid rgba(139,92,246,.45); }
.catsec-h h2 { margin:0; font-size:17px; }
.catsec-h a { margin-inline-start:auto; font-size:13px; color:var(--acc); font-weight:700; }
.ends { display:flex; flex-wrap:wrap; gap:12px; align-items:center; margin:8px 0 26px; }
.pill { text-decoration:none; display:inline-flex; align-items:center; gap:8px; padding:12px 20px; border-radius:999px;
  background:linear-gradient(135deg,#FF7043,#FFCA28); color:#22122b; font-weight:800; font-size:14px; }
.pill.ghost { background:transparent; color:var(--txt); border:1px solid var(--line); }
.bnav { position:fixed; left:0; right:0; bottom:0; z-index:40; display:grid; grid-template-columns:repeat(3,1fr);
  background:rgba(15,12,34,.96); border-top:1px solid var(--line); backdrop-filter:blur(10px);
  padding:6px 4px calc(6px + env(safe-area-inset-bottom)); }
.bnav a, .bnav button { display:flex; flex-direction:column; align-items:center; gap:3px; font-size:10.5px;
  color:var(--dim); background:none; border:0; font-family:inherit; padding:4px 0; }
.bnav .on { color:var(--acc); }
.bnav .ic { font-size:17px; line-height:1; }
body { padding-bottom:74px; }
@media (min-width:700px) {
  .row { grid-auto-columns:calc((100% - 36px)/4); }
  .row > *:nth-child(n+5) { display:none; }
  .hero { min-height:360px; }
  .hero h2 { font-size:34px; }
  .hero .meta { padding:24px; }
  .bnav { display:none; }
  body { padding-bottom:0; }
}
.toast { position:fixed; left:50%; bottom:86px; transform:translateX(-50%) translateY(10px); opacity:0;
  background:rgba(20,16,44,.96); border:1px solid var(--line); color:var(--txt); font-size:13px;
  padding:10px 16px; border-radius:999px; transition:.25s; pointer-events:none; z-index:60; }
.toast.on { opacity:1; transform:translateX(-50%) translateY(0); }
.searchin { width:100%; box-sizing:border-box; margin:6px 0 18px; padding:13px 16px; border-radius:14px;
  background:var(--card); border:1px solid var(--line); color:var(--txt); font-family:inherit; font-size:15px; }
.searchin:focus { outline:none; border-color:var(--acc2); }

.row { -webkit-overflow-scrolling:touch; }
.row::after { content:''; flex:0 0 1px; }
.shelf { position:relative; }
.shelf::after { content:''; position:absolute; top:44px; bottom:6px; inset-inline-end:0; width:26px;
  background:linear-gradient(to var(--fade, left), rgba(13,11,30,0) 0%, rgba(13,11,30,.85) 100%);
  pointer-events:none; border-radius:0 12px 12px 0; }
/* site header */
.hdr { display:flex; align-items:center; gap:14px; padding:10px 0 14px; margin-bottom:4px; position:sticky; top:0; z-index:40;
  background:linear-gradient(to bottom, rgba(13,11,30,.98) 70%, rgba(13,11,30,0)); backdrop-filter:blur(8px); }
.hdr .brand { font-weight:800; font-size:18px; letter-spacing:-.2px; color:var(--txt); text-decoration:none; white-space:nowrap; }
.hnav { display:flex; gap:4px; overflow-x:auto; scrollbar-width:none; flex:1; }
.hnav::-webkit-scrollbar { display:none; }
.hnav a { color:var(--mut); text-decoration:none; font-size:14px; padding:7px 11px; border-radius:999px; white-space:nowrap; }
.hnav a:hover { color:var(--txt); background:rgba(255,255,255,.06); }
.hsearch { flex:0 0 auto; width:38px; height:38px; display:grid; place-items:center; border-radius:50%;
  color:var(--txt); background:var(--card); border:1px solid var(--line); text-decoration:none; }
.hsearch:hover { border-color:var(--acc2); }
/* article */
.article p { max-width:70ch; }
.article h3 { margin-top:22px; }
.article figure { margin:18px 0; }
.shots-row { display:flex; gap:12px; overflow-x:auto; scroll-snap-type:x mandatory; -webkit-overflow-scrolling:touch; padding-bottom:6px; }
.shots-row figure { flex:0 0 86%; scroll-snap-align:start; margin:0; }
.shots-row img { border-radius:14px; }
@media (min-width:900px) { .shots-row figure { flex-basis:48%; } }
@media (max-width:560px) {
  .hdr { gap:8px; }
  .hdr .brand { font-size:16px; }
  .hnav a { font-size:13px; padding:6px 8px; }
  .hsearch { width:34px; height:34px; }
}

/* see-all chevrons, page headline, cross links */
.chev { display:inline-block; width:7px; height:7px; font-size:0; line-height:0; overflow:hidden;
  border-right:2px solid currentColor; border-top:2px solid currentColor; transform:rotate(45deg);
  margin-inline-start:8px; margin-bottom:1px; vertical-align:middle; }
[dir="rtl"] .chev { transform:rotate(-135deg); }

.shelf-h a, .catsec-h a { text-decoration:none; display:inline-flex; align-items:center; }
.shelf-h a:hover, .catsec-h a:hover { text-decoration:underline; }
.pageh1 { font-size:20px; line-height:1.4; margin:2px 0 14px; font-weight:800; letter-spacing:-.2px; }
@media (max-width:560px) { .pageh1 { font-size:17px; margin:0 0 10px; } }
.crosslinks { display:flex; flex-wrap:wrap; gap:8px; margin:22px 0 0; }
.crosslinks a { display:inline-flex; align-items:center; font-size:13.5px; font-weight:700; text-decoration:none;
  background:var(--card); border:1px solid var(--line); border-radius:999px; padding:9px 16px; color:var(--txt); }
.crosslinks a:hover { border-color:var(--acc); }
body.playing .bnav { display:none; }

/* game-page rail: fixed-width tiles with name + description */
.rail { align-items:flex-start; }
.rail .tile { flex:0 0 152px; width:152px; }
.rail .tile .nm { position:static; background:none; padding:8px 10px 0; font-size:13px; }
.rail .tile .ds { display:block; font-size:11.5px; color:var(--dim); padding:3px 10px 10px; line-height:1.45; }
.tile.more { display:grid; place-items:center; aspect-ratio:16/10; background:rgba(139,92,246,.14); border-style:dashed; }
.tile.more .nm { position:static; background:none; padding:0; font-size:13px; text-align:center; }

/* mobile: top nav folds into the bottom bar, keep the header clean */
@media (max-width:560px) { .hnav { display:none; } .hdr { justify-content:space-between; } }
/* rail cards: keep descriptions to two lines so cards stay equal */
.rail .tile { display:flex; flex-direction:column; }
.rail .tile .ds { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }

@media (max-width:560px) { .hero p { display:none; } .hero { min-height:260px; } }

/* language switcher */
.langs { display:flex; gap:2px; flex:0 0 auto; align-items:center; }
.langs a { font-size:12.5px; font-weight:700; color:var(--dim); text-decoration:none; padding:6px 7px; border-radius:8px; }
.langs a:hover { color:var(--txt); background:rgba(255,255,255,.06); }
.langs a.on { color:var(--acc); background:rgba(255,122,69,.14); }
/* footer */
.foot { margin-top:44px; border-top:1px solid var(--line); padding-top:22px; text-align:start; }
.foot-cols { display:grid; grid-template-columns:1.4fr 1fr 1fr; gap:22px; }
.foot-brand { font-weight:800; font-size:16px; margin:0 0 6px; }
.foot-note { color:var(--dim); font-size:13px; margin:0; max-width:34ch; }
.foot-h { font-size:12px; letter-spacing:.08em; text-transform:uppercase; color:var(--dim); margin:0 0 8px; }
.foot a { display:block; font-size:13.5px; color:var(--txt); text-decoration:none; padding:3px 0; }
.foot a:hover { color:var(--acc); }
.foot a.on { color:var(--acc); font-weight:700; }
.foot-legal { margin:20px 0 0; font-size:12.5px; color:var(--dim); }
@media (max-width:560px) { .foot-cols { grid-template-columns:1fr 1fr; } .foot-cols > div:first-child { grid-column:1/-1; } }
/* bottom bar is navigation, not body text */
.bnav a, .bnav button { text-decoration:none; }
/* hero short line on phone */
.herosub { display:none; }
@media (max-width:560px) { .hero p.herosub { display:block; margin:6px 0 12px; font-size:13px; color:#e6e1ff; } }
/* see-all chevron inside the container edge */
.shelf-h a, .catsec-h a { padding-inline-end:6px; }
/* landscape games: frame takes the game's own shape instead of 4:3 letterboxing */
.stage-frame { aspect-ratio:var(--gar, 4/3); }

/* phone: playing stays inline at the game's own shape, page content stays below */
@media (max-width:820px) {
  body.playing .stage { position:relative; inset:auto; z-index:auto; border-radius:18px; border:1px solid var(--line); }
  body.playing .stage-frame { aspect-ratio:var(--gar, 4/3); flex:none; min-height:0; height:auto; }
  body.playing { overflow:auto; }
}

.stage-foot { display:flex; align-items:center; justify-content:center; gap:8px; padding:8px 10px;
  border-top:1px solid var(--line); background:var(--card); border-radius:0 0 14px 14px; }
.stage-foot .bar-btn { background:rgba(255,255,255,.08); border:1px solid var(--line); color:var(--txt);
  font:700 13px/1 inherit; padding:9px 16px; border-radius:999px; cursor:pointer; }

/* phone: while playing, give the game card the screen - intro collapses, page title shrinks */
@media (max-width:820px) {
  body.playing .crumbs, body.playing .lede, body.playing .altnames { display:none; }
  body.playing h1 { font-size:20px; line-height:1.25; margin:6px 0 10px; }
  body.playing .layout { margin-top:0; }
  body.playing .stage-bar { padding:8px 10px; }
}

/* desktop: cap the tall self-hosted stage to the viewport by deriving its width from the game ratio */
@media (min-width:821px) {
  .stage { width:min(100%, calc(min(64vh, 820px) * var(--garr, 1.3333))); justify-self:center; }
  .stage-frame { width:100%; }
}

/* phone: a landscape Y8 game gets a portrait stage so the shell can turn it sideways and fill */
@media (max-width:820px) {
  body.playing .stage:not(.stage-self) .stage-frame { aspect-ratio:var(--garp, 1.3333); }
}
@media (max-width:820px) {
  body.playing .stage:not(.stage-self) { width:min(100%, calc((100vh - 220px) * var(--garp, 0.75))); justify-self:center; }
  body.playing .stage:not(.stage-self) .stage-frame { width:100%; }
}

/* phone while playing: the game name gets the room, the category chip is decoration and goes */
@media (max-width:820px) {
  body.playing .stage-bar .chip { display:none; }
  body.playing .stage-title { font-size:16px; }
}

/* playing is a real overlay: full viewport, opaque, above the header */
body.playing .stage { width:100% !important; max-width:none !important; background:var(--bg,#0d0b1e); }
body.playing .stage-frame { flex:0 0 auto; margin:auto; }
@media (max-width:820px) {
  body.playing .stage:not(.stage-self) { max-width:100%; }
}
