/* SAIF-2026-10-14 — رايات المعرفة: hand-painted 90s Arabian-nights cartoon look, light theme */
:root {
  --paper: #FBF4E6;
  --paper-2: #F4E6CB;
  --sand: #E9D1A3;
  --ink: #3B2718;
  --ink-2: #6E5038;
  --ink-3: #9A7B5F;
  --turq: #168C93;
  --turq-2: #0E6B71;
  --saffron: #EBA33A;
  --saffron-2: #C9821C;
  --ok: #3E9B4A;
  --bad: #C9403A;
  --gold: #E9B949;
  --r: 18px;
  --edge: 2.5px solid var(--ink);
  --lift: 0 4px 0 var(--ink);
  --deep: 0 6px 0 var(--ink), 0 18px 40px rgba(59, 39, 24, .22);
  --ui: 'Baloo Bhaijaan 2', 'Segoe UI', Tahoma, sans-serif;
  --title: 'Aref Ruqaa', 'Amiri', serif;
  --star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23B08A5C' stroke-opacity='.16' stroke-width='1.2'%3E%3Cpath d='M32 14l5.3 12.7L50 32l-12.7 5.3L32 50l-5.3-12.7L14 32l12.7-5.3z'/%3E%3Cpath d='M19.3 19.3h25.4v25.4H19.3z' transform='rotate(45 32 32)'/%3E%3C/g%3E%3C/svg%3E");
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--ui);
  color: var(--ink);
  background: var(--paper) var(--star);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid var(--turq); outline-offset: 2px; }

/* ---------- shared pieces ---------- */
.panel {
  position: relative;
  background: var(--paper);
  border: var(--edge);
  border-radius: 24px;
  box-shadow: var(--deep);
}
.panel::before {
  content: ""; position: absolute; inset: 7px; pointer-events: none;
  border: 1.5px solid rgba(59, 39, 24, .22); border-radius: 17px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  font-weight: 700; font-size: 1.05rem; line-height: 1.1;
  padding: .72em 1.3em;
  background: var(--paper);
  border: var(--edge); border-radius: 14px;
  box-shadow: var(--lift);
  transition: transform .08s, box-shadow .08s, background .15s;
  user-select: none;
}
.btn:hover { background: #fff8ea; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--saffron); }
.btn.primary:hover { background: #f2b14e; }
.btn.danger { background: #f6d9cf; }
.btn.big { font-size: 1.35rem; padding: .7em 1.6em; border-radius: 16px; }
.btn.small { font-size: .92rem; padding: .55em 1em; }
.menu { display: grid; gap: 12px; }
.menu-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.menu-row .btn { flex: 1 1 auto; }

.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: block; }

/* ---------- home ---------- */
.home { background: #cfe8f1; }
.home-art { position: absolute; inset: 0; }
.home-art img { width: 100%; height: 100%; object-fit: cover; object-position: 20% 50%; }
.home-panel {
  position: absolute; inset-block: 0; inset-inline-start: 0;
  width: min(50%, 620px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 40px; text-align: center;
}
.emblem { width: 112px; height: 112px; filter: drop-shadow(0 6px 10px rgba(59, 39, 24, .25)); animation: bob 5s ease-in-out infinite; }
.logo {
  font-family: var(--title); font-weight: 700;
  font-size: clamp(3.2rem, 7.5vw, 6.4rem); line-height: 1.1; margin: .05em 0 .1em;
  color: var(--ink);
  text-shadow: 3px 3px 0 var(--saffron), 6px 6px 0 rgba(59, 39, 24, .18);
}
.tag { font-size: clamp(1.05rem, 1.7vw, 1.3rem); font-weight: 600; color: var(--ink-2); margin: 0 0 26px; line-height: 1.6; }
.home .menu { width: min(100%, 380px); }
.stats { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; justify-content: center; }
.stats div {
  background: rgba(251, 244, 230, .88); border: 2px solid var(--ink); border-radius: 12px; padding: 6px 12px;
  display: flex; flex-direction: column; min-width: 80px;
}
.stats b { font-size: 1.25rem; line-height: 1.1; }
.stats span { font-size: .78rem; color: var(--ink-2); }

@keyframes bob { 50% { transform: translateY(-6px) rotate(-2deg); } }

/* ---------- setup ---------- */
.setup {
  background: linear-gradient(rgba(251, 244, 230, .55), rgba(251, 244, 230, .75)), url("../img/hall.webp?v=1") center/cover;
  overflow-y: auto; padding: 24px 16px;
}
.setup.active { display: flex; }
/* profile & daily challenge: the same hall as setup */
.profile, .daily {
  background: linear-gradient(rgba(251, 244, 230, .55), rgba(251, 244, 230, .75)), url("../img/hall.webp?v=1") center/cover;
  overflow-y: auto; padding: 24px 16px;
}
.profile.active, .daily.active { display: flex; }
.profile .sheet, .daily .sheet { width: min(760px, 100%); }
.sheet-h h2 small { font-family: var(--body, inherit); font-size: 1rem; color: var(--ink-2); margin-inline-start: 8px; }

/* level card on the home screen */
.me-chip { display: flex; align-items: center; gap: 10px; margin: 16px auto 0; padding: 6px 14px 6px 8px; width: fit-content; min-width: 220px;
  background: rgba(251, 244, 230, .9); border: 2px solid var(--ink); border-radius: 99px; cursor: pointer; }
.me-chip:empty { display: none; }
.me-chip img { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--ink); object-fit: cover; }
.me-chip div { display: grid; gap: 2px; flex: 1; text-align: start; }
.me-chip b { font-size: 1rem; line-height: 1.1; }
.me-chip span { font-size: .8rem; color: var(--ink-2); font-weight: 700; }
i.xp { display: block; height: 8px; border-radius: 99px; background: rgba(59, 39, 24, .14); overflow: hidden; }
i.xp > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--saffron), var(--gold)); transition: width 1.1s cubic-bezier(.2, .8, .3, 1); }
.daily-btn span { font-size: .78rem; font-weight: 800; padding: 1px 8px; border-radius: 99px; margin-inline-start: 4px; }
.daily-btn span.new { background: var(--saffron); }
.daily-btn span.done { background: #d9f0d5; color: var(--ok); }
.install-btn { width: 100%; border-style: dashed; }
.invite { margin: 4px 0 14px; padding: 10px 14px; background: #fff3cf; border: 2px solid var(--ink); border-radius: 14px; animation: okpop .4s; }
.invite p { margin: 0 0 8px; font-weight: 800; }
.inst-steps { margin: 0 0 10px; padding-inline-start: 22px; display: grid; gap: 8px; font-size: 1.05rem; }
.inst-note { margin: 0; color: var(--ink-2); }

/* profile */
.pf-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.pf-head img { width: 84px; height: 84px; border-radius: 50%; border: 3px solid var(--ink); object-fit: cover; background: #fff; }
.pf-head div { display: grid; gap: 4px; flex: 1; }
.pf-head b { font-size: 1.5rem; }
.pf-head .lv { font-weight: 800; color: var(--ink-2); }
.pf-head small { color: var(--ink-2); }
.pf-head i.xp { height: 12px; }
.profile .res-stats { grid-template-columns: repeat(4, 1fr); }
.pf-h { font-family: var(--title); font-size: 1.4rem; margin: 18px 0 10px; }
.pf-h small { font-family: inherit; font-size: .9rem; color: var(--ink-2); }
.pf-cats { display: grid; gap: 6px; }
.pf-cat { display: grid; grid-template-columns: 30px 110px 1fr 46px; align-items: center; gap: 10px; }
.pf-cat img { width: 30px; height: 30px; }
.pf-cat span { font-weight: 700; }
.pf-cat i.bar { height: 10px; border-radius: 99px; background: rgba(59, 39, 24, .12); overflow: hidden; display: block; }
.pf-cat i.bar > i { display: block; height: 100%; background: var(--ok); border-radius: inherit; }
.pf-cat b { text-align: end; }
.pf-ach { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ach { display: grid; justify-items: center; text-align: center; gap: 2px; padding: 10px 8px; background: #fff; border: 2px dashed var(--ink-3); border-radius: 14px; opacity: .55; filter: grayscale(1); }
.ach.on { opacity: 1; filter: none; border: 2px solid var(--ink); background: #fff8e4; }
.ach i { font-style: normal; font-size: 1.7rem; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: var(--paper-2); border: 2px solid var(--ink); }
.ach.on i { background: var(--gold); }
.ach b { font-size: .95rem; }
.ach span { font-size: .78rem; color: var(--ink-2); }

/* experience after a match or a daily challenge */
.res-xp { display: grid; gap: 8px; margin: 0 0 14px; padding: 10px 14px; background: #fff8e4; border: 2px solid var(--ink); border-radius: 14px; }
.res-xp:empty { display: none; }
.xp-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.xp-top b { font-size: 1.35rem; color: #b06d00; }
.xp-top span { font-size: .82rem; color: var(--ink-2); }
.xp-lv { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; font-weight: 800; }
.xp-lv i.xp { height: 12px; }
.xp-lv em { font-style: normal; color: #fff; background: var(--ok); padding: 1px 10px; border-radius: 99px; animation: okpop .5s; }
.xp-ach { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.xp-ach small { font-weight: 800; color: var(--ink-2); }
.xp-ach .ach { grid-auto-flow: column; padding: 4px 10px 4px 6px; gap: 6px; }
.xp-ach .ach i { width: 30px; height: 30px; font-size: 1.05rem; }

/* daily challenge */
.dl-intro { margin: 0 0 12px; color: var(--ink-2); }
.dl-dots { display: flex; justify-content: center; gap: 8px; margin: 6px 0 18px; }
.dl-dots i { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--ink); background: #fff; }
.dl-dots i.cur { background: var(--saffron); }
.dl-dots i.ok { background: var(--ok); }
.dl-dots i.bad { background: #d9534f; }
.dl-body { display: grid; gap: 12px; justify-items: stretch; }
.dl-score { display: flex; align-items: baseline; justify-content: center; gap: 12px; }
.dl-score b { font-family: var(--title); font-size: 3.2rem; line-height: 1; }
.dl-score span { font-size: 1.3rem; font-weight: 800; }
.dl-streak, .dl-next { text-align: center; margin: 0; font-weight: 700; color: var(--ink-2); }
.dl-next b { font-variant-numeric: tabular-nums; direction: ltr; display: inline-block; }
.sheet { width: min(980px, 100%); margin: auto; padding: 22px 26px 26px; }
.sheet-h { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sheet-h h2 { font-family: var(--title); font-size: 2.2rem; margin: 0; }
.back { width: 44px; height: 44px; border: var(--edge); border-radius: 12px; background: var(--paper-2); box-shadow: var(--lift); font-size: 1.3rem; font-weight: 800; }
.chars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.char {
  background: var(--paper-2); border: var(--edge); border-radius: 16px; padding: 8px 6px 10px;
  box-shadow: var(--lift); display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform .15s, background .15s;
}
.char .pic { width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #f4ebd6; }
.char .pic img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.char b { font-size: 1.1rem; margin-top: 4px; }
.char small { font-size: .74rem; color: var(--ink-2); line-height: 1.3; min-height: 2.6em; text-align: center; }
.char:hover .pic img { transform: scale(1.05); }
.char[aria-pressed="true"] { background: var(--saffron); transform: translateY(-4px); box-shadow: 0 8px 0 var(--ink); }
.char[aria-pressed="true"] small { color: var(--ink); }
.opts { display: grid; grid-template-columns: 1.25fr .95fr 1fr 1fr; gap: 16px; margin-top: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
.field > span { font-size: .95rem; color: var(--ink-2); }
.field input {
  font: inherit; font-size: 1.1rem; padding: .55em .8em; border: var(--edge); border-radius: 12px; background: #fff;
  box-shadow: inset 0 2px 0 rgba(59, 39, 24, .08);
}
.seg { display: flex; border: var(--edge); border-radius: 12px; overflow: hidden; background: #fff; }
.seg button { flex: 1; border: 0; padding: .6em .4em; font-weight: 700; background: transparent; }
.seg button + button { border-inline-start: 2px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--turq); color: #fff; }
.note { text-align: center; color: var(--ink-2); margin: 16px 0 12px; }
.go { display: flex; margin: 0 auto; min-width: 260px; }

/* the hero screen: the heroes, the name, «متابعة» */
#s-setup .opts { grid-template-columns: 1fr; width: min(440px, 100%); margin-inline: auto; }
.name-note { color: var(--bad); font-weight: 800; margin: 10px 0 0; }
/* the new-game modal: who plays, public or private, how many; a code to join with (private); an invitation */
.start { width: min(520px, 100%); display: grid; gap: 14px; }
.start header { margin-bottom: 0; }
.start .note { margin: 0; line-height: 1.6; }
.start .go { margin: 0 auto; }
.start .join-row { margin-top: 0; }
.start .join-banner { margin: 0; }
.who { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 14px 6px 8px; border: 2px solid var(--ink); border-radius: 16px; background: #fff; font: inherit; color: inherit; text-align: start; cursor: pointer; }
.who img { width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--ink); object-fit: cover; background: #f4ebd6; flex: none; }
.who div { display: grid; flex: 1; gap: 1px; min-width: 0; }
.who b { font-size: 1.05rem; line-height: 1.2; }
.who small { color: var(--ink-2); font-weight: 600; }
.who em { font-style: normal; font-weight: 800; color: var(--turq-2); flex: none; }
#m-start[data-mode="join"] .no-join, #m-start:not([data-mode="join"]) .only-join,
#m-start:not([data-kind="private"]) .only-private, #m-start[data-mode="join"] .only-private { display: none !important; }
.btn.online { background: var(--turq); color: #fff; }
.btn.online:hover { background: #1c9ea6; }
.join-banner { text-align: center; background: #e1f2f1; border: 2px dashed var(--turq); border-radius: 14px; padding: 8px 14px; margin: 0 0 12px; font-weight: 600; }
.join-banner b { font-size: 1.15em; letter-spacing: .12em; direction: ltr; display: inline-block; }
.online-actions { display: grid; gap: 10px; }
.online-actions .note { margin: 14px 0 0; }
.join-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; font-weight: 600; color: var(--ink-2); }
.join-row input { font: inherit; font-size: 1.2rem; font-weight: 800; letter-spacing: .2em; text-align: center; width: 9ch; padding: .45em .6em; border: var(--edge); border-radius: 12px; background: #fff; }

/* ---------- a public game: the wait ---------- */
.big-row .btn { flex: 1 1 220px; }
.queue { background: linear-gradient(rgba(251, 244, 230, .55), rgba(251, 244, 230, .78)), url("../img/hall.webp?v=1") center/cover; overflow-y: auto; padding: 24px 16px; }
.queue.active { display: flex; }
.search { width: min(720px, 100%); margin: auto; padding: 26px 24px; text-align: center; }
.search h2 { font-family: var(--title); font-size: 2.2rem; margin: 6px 0 0; }
.search .seats { margin: 14px 0 18px; }
.emblem.spin { margin: 0 auto; width: 104px; height: 104px; animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.seat.seeking .av { animation: pulse 1.4s ease-in-out infinite; }

/* ---------- lobby ---------- */
.lobby { background: linear-gradient(rgba(251, 244, 230, .55), rgba(251, 244, 230, .78)), url("../img/hall.webp?v=1") center/cover; overflow-y: auto; padding: 24px 16px; }
.lobby.active { display: flex; }
.lobby .sheet { width: min(860px, 100%); }
.code-box { display: grid; justify-items: center; gap: 8px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 18px; padding: 12px 16px 14px; margin-bottom: 14px; }
.code-box > span { font-weight: 700; color: var(--ink-2); }
.code-box b { font-size: clamp(2.2rem, 7vw, 3.2rem); letter-spacing: .25em; line-height: 1; padding-inline-start: .25em; color: var(--turq-2); }
.btn.wa { background: #dff3e4; text-decoration: none; color: var(--ink); }
.seats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.seats[data-n="2"] { grid-template-columns: repeat(2, 1fr); }
.seats[data-n="4"] { grid-template-columns: repeat(4, 1fr); }
.seats[data-n="5"] { grid-template-columns: repeat(5, 1fr); gap: 8px; }
.seats[data-n="5"] .seat .av { width: 66px; height: 66px; }
.seat { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; background: #fff; border: var(--edge); border-radius: 18px; padding: 12px 8px; box-shadow: var(--lift); animation: pop .4s; }
.seat .av { width: 84px; height: 84px; border-radius: 50%; overflow: hidden; border: 3px solid var(--ink); background: #f4ebd6; }
.seat .av img { width: 100%; height: 100%; object-fit: cover; }
.seat b { font-size: 1.1rem; }
.seat b small { font-weight: 500; color: var(--ink-2); }
.seat small { color: var(--ink-2); font-size: .82rem; }
.seat .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); vertical-align: middle; }
.seat.off { opacity: .6; }
.seat.empty { background: transparent; border-style: dashed; box-shadow: none; }
.seat.empty .av { border-style: dashed; background: rgba(255, 255, 255, .5); }
.lobby-opts { grid-template-columns: .9fr 1fr 1fr; }
.lobby:not(.is-host) .host-only { display: none !important; }
.seg button:disabled { cursor: default; }
.seg button:disabled:not([aria-pressed="true"]) { color: var(--ink-3); }
.net {
  position: fixed; z-index: 80; top: 10px; left: 50%; transform: translateX(-50%);
  background: #fde6b8; border: 2px solid var(--ink); border-radius: 99px; padding: 4px 16px; font-weight: 700; box-shadow: 0 3px 0 var(--ink);
}

/* ---------- game ---------- */
.game { background: var(--paper-2) var(--star); }
.game.active { display: grid; grid-template-rows: auto 1fr auto; }
.g-top { display: flex; align-items: center; gap: 12px; padding: 10px 14px 8px; }
.hud { display: flex; gap: 10px; flex: 1; min-width: 0; }
.pc {
  --pc: #888;
  position: relative; flex: 1 1 0; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  background: var(--paper); border: var(--edge); border-radius: 16px; padding: 6px 10px 6px 12px;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform .2s, box-shadow .2s, background .2s;
}
.pc .av { flex: none; width: 50px; height: 50px; border-radius: 50%; overflow: hidden; border: 3px solid var(--pc); box-shadow: 0 0 0 2px var(--ink); background: #f4ebd6; }
.pc .av img { width: 100%; height: 100%; object-fit: cover; }
.pc .info { min-width: 0; }
.pc .nm { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.pc .nm small { font-weight: 500; color: var(--ink-2); font-size: .78em; }
.pc .meta { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--ink-2); }
.pc .sc { font-size: 1.3rem; color: var(--pc); font-variant-numeric: tabular-nums; min-width: 2.6em; }
.pc .tw { display: inline-flex; gap: 2px; }
.pc .tw i { width: 9px; height: 13px; background: var(--pc); border: 1.5px solid var(--ink); border-radius: 2px 2px 0 0; }
.pc .tw:empty::after { content: "—"; color: var(--ink-3); }
.pc .ct { white-space: nowrap; }
/* 4–5 players: slimmer cards */
.hud.many { gap: 8px; }
.hud.many .pc { gap: 7px; padding: 5px 8px 5px 9px; }
.hud.many .pc .av { width: 42px; height: 42px; }
@media (max-width: 1500px) { .hud.many .pc .ct { display: none; } }
.pc .turn {
  position: absolute; top: -10px; inset-inline-end: 10px; font-size: .72rem; font-weight: 800;
  background: var(--pc); color: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: 0 8px; line-height: 1.5;
  opacity: 0; transform: translateY(4px); transition: .2s;
}
.pc.active { transform: translateY(-3px); box-shadow: 0 6px 0 var(--ink), 0 0 0 4px color-mix(in srgb, var(--pc) 35%, transparent); background: #fffaf0; }
.pc.active .turn { opacity: 1; transform: none; }
.pc.out { filter: grayscale(1); opacity: .55; }
.pc.away .av { opacity: .5; }
.pc.away .turn { opacity: 1; transform: none; background: #8a7a66; }
.pc.out .turn { opacity: 1; transform: none; background: #777; }
/* truces: the leader's tag, and on both cards of a truce its rounds left with a dot in the other's colour */
.pc .lead-tag { position: absolute; top: -10px; inset-inline-start: 10px; display: none; font-size: .68rem; font-weight: 800; line-height: 1.5;
  background: #94600F; color: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: 0 7px; }
.pc.lead .lead-tag { display: block; }
.pc .pact { position: absolute; bottom: -10px; inset-inline-start: 10px; display: inline-flex; align-items: center; gap: 3px; font-size: .68rem; font-weight: 800;
  line-height: 1.5; background: var(--turq-2); color: #fff; border: 2px solid var(--ink); border-radius: 99px; padding: 0 7px 0 6px; }
.pc .pact[hidden] { display: none; }
.pc .pact i { width: .62em; height: .62em; border-radius: 50%; background: var(--ac); box-shadow: 0 0 0 1.5px #fff; }
.floater {
  position: absolute; inset-inline-start: 56px; top: 0; font-weight: 800; font-size: 1.2rem; color: var(--pc);
  text-shadow: 0 2px 0 #fff, 0 0 6px #fff; pointer-events: none; animation: floatUp 1.4s ease-out forwards;
}
@keyframes floatUp { from { transform: translateY(0); opacity: 0; } 15% { opacity: 1; } to { transform: translateY(-34px); opacity: 0; } }

.g-bar { display: flex; align-items: center; gap: 10px; }
.phase {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--turq); color: #fff; border: var(--edge); border-radius: 14px; padding: 4px 16px; min-width: 150px;
  box-shadow: 0 3px 0 var(--ink); line-height: 1.25;
}
.phase b { font-size: 1.02rem; }
.phase span { font-size: .8rem; opacity: .9; }
.icon-btn {
  width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  background: var(--paper); border: var(--edge); border-radius: 14px; box-shadow: 0 3px 0 var(--ink);
}
.icon-btn span { width: 5px; height: 18px; background: var(--ink); border-radius: 2px; }
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

.board-wrap {
  position: relative; min-height: 0; overflow: auto; overscroll-behavior: contain;
  display: grid; place-content: safe center; padding: 4px 12px 8px;
  scrollbar-width: thin; scrollbar-color: var(--ink-3) transparent;
}
.board {
  position: relative; aspect-ratio: 2752 / 1536; width: 900px;
  container-type: inline-size;
  border: 3px solid var(--ink); border-radius: 20px; overflow: hidden;
  box-shadow: 0 6px 0 var(--ink), 0 20px 40px rgba(59, 39, 24, .25);
  background: #f2e3c4; user-select: none;
}
.board .map { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.board svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* territories: every city holds the land around it, tinted (lightly) with its owner's colour */
.reg {
  --pc: transparent;
  fill: var(--pc); fill-opacity: 0; stroke: #7a5532; stroke-width: .11; stroke-dasharray: .45 .35; stroke-opacity: .32; stroke-linejoin: round;
  transition: fill .5s, fill-opacity .5s, stroke .5s, stroke-opacity .5s;
}
.reg.own { fill-opacity: .3; stroke: var(--pc); stroke-opacity: .8; stroke-width: .16; stroke-dasharray: none; }
.reg.own.castle { fill-opacity: .4; }
.board.picking .reg.own:not(.sel):not(.atk) { fill-opacity: .2; }
.reg.sel, .reg.atk { pointer-events: auto; cursor: pointer; }
.reg.sel { fill: #ffcf4d; fill-opacity: .32; stroke: #a8740f; stroke-opacity: .95; stroke-width: .24; stroke-dasharray: none; animation: regpulse 1.1s ease-in-out infinite; }
.reg.atk { stroke: #b2382f; stroke-opacity: 1; stroke-width: .3; stroke-dasharray: .55 .3; animation: regpulse 1s ease-in-out infinite; }
.reg.sel:hover, .reg.atk:hover { fill-opacity: .55; animation: none; }
.reg.target { stroke: #b2382f; stroke-opacity: 1; stroke-width: .4; stroke-dasharray: none; animation: regpulse .7s ease-in-out infinite; }
.reg.capture, .reg.rise { animation: regflash .9s ease-out; }
.reg.fall { animation: regflash .6s 2; }
@keyframes regpulse { 50% { fill-opacity: .5; } }
@keyframes regflash { 25% { fill-opacity: .75; } }
.r { fill: none; stroke-linecap: round; }
.r.land { stroke: #7a5532; stroke-width: .3; stroke-dasharray: .02 .62; opacity: .8; }
.r.sea { stroke: #0b5d63; stroke-width: .2; stroke-dasharray: .7 .55; opacity: .55; }
.r.front { stroke: #b2382f; opacity: .85; }
.arrow { fill: none; stroke: var(--ac); stroke-width: .7; stroke-linecap: round; filter: drop-shadow(0 .15px 0 #3B2718) drop-shadow(0 0 .4px #fff); }

.city {
  --pc: transparent;
  position: absolute; width: 4.9cqw; height: 4.9cqw; padding: 0; border: 0; background: none;
  transform: translate(-50%, -60%); /* physical left/top = the city's anchor point */
  touch-action: manipulation;
}
.city .spr { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 .25cqw .2cqw rgba(59, 39, 24, .35)); transition: transform .2s; }
.city.castle { width: 5.9cqw; height: 5.9cqw; z-index: 2; }
/* a castle keeps its landmark and gets a small keep beside it */
.city .keep { position: absolute; width: 50%; height: 50%; left: -22%; top: 34%; object-fit: contain; display: none; pointer-events: none;
  filter: drop-shadow(0 .15cqw .1cqw rgba(59, 39, 24, .4)); }
.city.castle .keep { display: block; }
.city .halo { position: absolute; inset: -18%; border-radius: 50%; pointer-events: none; }
.city.own .halo { background: radial-gradient(closest-side, color-mix(in srgb, var(--pc) 45%, transparent), transparent); }
.city .flag { position: absolute; top: -26%; left: 62%; width: .22cqw; height: 2.2cqw; background: var(--ink); border-radius: 2px; display: none; }
.city .flag i {
  position: absolute; top: 0; left: .22cqw; width: 1.7cqw; height: 1.15cqw; background: var(--pc);
  clip-path: polygon(0 0, 100% 50%, 0 100%); outline: none; transform-origin: left center; animation: wave 2.4s ease-in-out infinite;
  filter: drop-shadow(0 0 .1cqw var(--ink));
}
.city.own .flag { display: block; }
.city.castle .flag { left: 50%; top: -34%; }
@keyframes wave { 50% { transform: scaleX(.82) skewY(4deg); } }
.city .lbl {
  position: absolute; top: 92%; left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: baseline; gap: .35em; white-space: nowrap;
  font-size: max(10px, 1.05cqw); font-weight: 700; line-height: 1.35;
  padding: 0 .55em; border-radius: 99px; border: max(1.5px, .14cqw) solid var(--ink);
  background: rgba(251, 244, 230, .94); color: var(--ink);
}
.city.own .lbl { background: var(--pc); color: #fff; }
.city .val { font-weight: 800; font-size: .85em; opacity: .9; }
.city .val:empty { display: none; }
/* strength bars inside the label: a city 1–3, a castle up to 7 */
.city .bars { display: inline-flex; gap: max(1px, .12cqw); align-self: center; margin-inline-end: .1em; }
.city .bars:empty { display: none; }
.city .bars i { width: .34em; height: .78em; background: #fff; border-radius: 1.5px; opacity: .95; box-shadow: 0 0 0 .5px rgba(59, 39, 24, .35); }
.city.castle .bars i { width: .38em; height: .9em; }

/* picking */
.board.picking .city:not(.sel):not(.atk) { filter: saturate(.55) brightness(.92); }
.board.picking .city:not(.sel):not(.atk) .lbl { opacity: .75; }
.city.sel, .city.atk { cursor: pointer; z-index: 3; }
.city.sel .halo { background: radial-gradient(closest-side, rgba(255, 214, 102, .9), rgba(255, 214, 102, 0)); animation: pulse 1.1s ease-in-out infinite; }
.city.atk .halo { background: radial-gradient(closest-side, rgba(220, 60, 50, .75), rgba(220, 60, 50, 0)); animation: pulse 1s ease-in-out infinite; }
.city.sel:hover .spr, .city.atk:hover .spr { transform: translateY(-6%) scale(1.08); }
.city.atk .lbl { box-shadow: 0 0 0 .25cqw rgba(201, 64, 58, .45); }
@keyframes pulse { 50% { transform: scale(1.25); opacity: .65; } }
.city.target { z-index: 4; }
.city.target .halo { background: radial-gradient(closest-side, rgba(220, 60, 50, .85), transparent); animation: pulse .7s ease-in-out infinite; }
.city.source .spr { transform: scale(1.08); }

/* event animations */
.city.rise .spr { animation: rise .8s cubic-bezier(.2, 1.6, .4, 1); }
.city.capture .spr { animation: pop .7s cubic-bezier(.2, 1.6, .4, 1); }
.city.capture .flag i { animation: wave .25s 3; }
.city.hit .spr, .city.hit .keep { animation: shake .6s; }
.city.fall .spr { animation: shake .5s 2, fallflash 1.2s; }
.city.hold::after {
  content: ""; position: absolute; inset: -22%; border-radius: 50%; pointer-events: none;
  border: .35cqw solid rgba(255, 255, 255, .95); box-shadow: 0 0 1cqw #fff, inset 0 0 1cqw rgba(22, 140, 147, .6);
  animation: shield .9s ease-out forwards;
}
@keyframes rise { from { transform: translateY(40%) scale(.2); opacity: 0; } }
@keyframes pop { 35% { transform: scale(1.3) translateY(-8%); } }
@keyframes shake { 20%, 60% { transform: translateX(-6%) rotate(-3deg); } 40%, 80% { transform: translateX(6%) rotate(3deg); } }
@keyframes fallflash { 30% { filter: grayscale(1) brightness(.7); } }
@keyframes shield { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.25); opacity: 0; } }

.prompt {
  justify-self: center; margin: 0 12px 12px; min-height: 44px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-weight: 700; font-size: 1.1rem; padding: 6px 22px;
  background: var(--paper); border: var(--edge); border-radius: 14px; box-shadow: 0 3px 0 var(--ink);
  max-width: min(760px, calc(100% - 24px));
}
.prompt.blank { visibility: hidden; }
/* the countdown of the choice being made: a ring that empties, red in the last five seconds */
.prompt .clk { --p: 1; flex: none; display: grid; place-items: center; width: 34px; height: 34px; margin-inline-start: 12px; border-radius: 50%;
  background: conic-gradient(var(--turq) calc(var(--p) * 360deg), rgba(59, 39, 24, .14) 0); }
.prompt .clk b { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--paper); font-size: .95rem; font-variant-numeric: tabular-nums; }
.prompt .clk.low { background: conic-gradient(var(--bad) calc(var(--p) * 360deg), rgba(59, 39, 24, .14) 0); }
.prompt .clk.low b { color: var(--bad); }
.prompt.me { background: var(--saffron); animation: nudge 1.6s ease-in-out infinite; }
/* the truce buttons while choosing a target: quiet, above the prompt (ui.deal sets `bottom`) */
.deal { position: absolute; left: 50%; transform: translateX(-50%); z-index: 6; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  width: max-content; max-width: calc(100% - 24px); }
.deal[hidden] { display: none; }
.deal .btn { background: var(--paper); box-shadow: 0 2px 0 var(--ink); }
/* the cities of the player's ally: a dashed teal ring around the label */
.city.ally .lbl { outline: max(2px, .17cqw) dashed var(--turq-2); outline-offset: max(2px, .14cqw); }
.prompt.warn { background: #f6cfc5; }
@keyframes nudge { 50% { transform: translateY(-2px); } }

/* ---------- quiz overlay ---------- */
.quiz {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(rgba(59, 39, 24, .35), rgba(59, 39, 24, .55)), url("../img/hall.webp?v=1") center/cover;
  opacity: 0; transition: opacity .25s;
}
.quiz.show { opacity: 1; }
.quiz.spectate { background: rgba(59, 39, 24, .45); }
.q-card {
  position: relative; width: min(780px, 100%); max-height: 100%; overflow-y: auto;
  background: var(--paper) var(--star); border: var(--edge); border-radius: 26px; box-shadow: var(--deep);
  padding: 18px 22px 20px;
  transform: translateY(14px) scale(.97); transition: transform .3s cubic-bezier(.2, 1.4, .4, 1);
}
.quiz.show .q-card { transform: none; }
.q-top { display: flex; align-items: center; gap: 12px; }
.q-cat { display: flex; align-items: center; gap: 6px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 99px; padding: 2px 12px 2px 4px; font-weight: 700; }
.q-cat img { width: 36px; height: 36px; }
.q-title { flex: 1; text-align: center; font-weight: 800; font-size: 1.1rem; color: var(--turq-2); }
.q-timer { position: relative; width: 56px; height: 56px; flex: none; }
.q-timer svg { width: 100%; height: 100%; transform: rotate(-90deg) scaleY(-1); }
.q-timer circle { fill: none; stroke-width: 5; }
.q-timer .bg { stroke: #e9d8b6; fill: #fff; }
.q-timer .fg { stroke: var(--turq); stroke-linecap: round; transition: stroke .3s; }
.q-timer b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.q-timer.low .fg { stroke: var(--bad); }
.q-timer.low b { color: var(--bad); animation: beat .5s ease-in-out infinite; }
@keyframes beat { 50% { transform: scale(1.15); } }
.q-who { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 12px 0 4px; flex-wrap: wrap; }
.q-who .vs { font-family: var(--title); font-size: 1.4rem; color: var(--bad); }
.chip {
  display: flex; align-items: center; gap: 8px; padding: 3px 12px 3px 4px; border-radius: 99px;
  background: #fff; border: 2px solid var(--ink); font-weight: 700; transition: background .2s;
}
.chip img { width: 34px; height: 34px; border-radius: 50%; border: 2.5px solid var(--pc); object-fit: cover; }
.chip .st { font-size: .8rem; color: var(--ink-2); font-weight: 600; }
.chip.done .st { color: var(--turq-2); }
.chip.ok { background: #dff1dc; }
.chip.ok .st { color: var(--ok); font-weight: 800; }
.chip.bad .st { color: var(--bad); font-weight: 800; }
.q-who[data-n="4"], .q-who[data-n="5"] { gap: 6px; }
.q-who[data-n="4"] .chip, .q-who[data-n="5"] .chip { gap: 5px; padding: 2px 9px 2px 3px; font-size: .9rem; }
.q-who[data-n="4"] .chip img, .q-who[data-n="5"] .chip img { width: 28px; height: 28px; }
.rank .aw { font-style: normal; font-size: .78rem; font-weight: 800; color: #fff; background: var(--pc); border-radius: 99px; padding: 0 7px; margin-inline-start: 6px; vertical-align: 1px; }
.rank .aw.fast { background: var(--ink); }
.q-text { font-size: clamp(1.3rem, 2.6vw, 1.75rem); line-height: 1.55; text-align: center; margin: 12px 4px 16px; font-weight: 700; }
.q-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt {
  position: relative; display: flex; align-items: center; gap: 10px; text-align: start;
  min-height: 62px; padding: 8px 12px; font-size: 1.15rem; font-weight: 700;
  background: #fff; border: var(--edge); border-radius: 16px; box-shadow: 0 4px 0 var(--ink);
  transition: transform .1s, background .15s, box-shadow .1s, opacity .25s;
}
.opt .k { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--paper-2); border: 2px solid var(--ink); font-weight: 800; font-size: 1.1rem; }
.opt .t { flex: 1; }
.opt:not(:disabled):hover { background: #fff7e3; transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.opt:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.opt.mine { background: #fde6b8; }
.opt.mine .k { background: var(--saffron); }
.opt.gone { opacity: .25; text-decoration: line-through; }
.opt.ok { background: #d9f0d5; border-color: var(--ok); box-shadow: 0 4px 0 #2b6b33; animation: okpop .45s; }
.opt.ok .k { background: var(--ok); color: #fff; }
.opt.bad { background: #f8d6d1; }
.opt.bad .k { background: var(--bad); color: #fff; }
.opt .marks { display: flex; gap: 2px; }
.opt .marks i { display: block; width: 30px; height: 30px; border-radius: 50%; overflow: hidden; border: 2.5px solid var(--pc); box-shadow: 0 0 0 1.5px var(--ink); animation: pop .4s; }
.opt .marks img { width: 100%; height: 100%; object-fit: cover; }
@keyframes okpop { 40% { transform: scale(1.04); } }
.quiz.spectate .opt { cursor: default; }
.q-foot { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; min-height: 8px; }
.help {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 700;
  background: var(--paper-2); border: 2px solid var(--ink); border-radius: 99px; padding: 5px 14px 5px 6px; box-shadow: 0 3px 0 var(--ink);
}
.help .ico { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--turq); color: #fff; font-weight: 800; }
.help b { background: var(--ink); color: #fff; border-radius: 99px; padding: 0 7px; font-size: .85rem; }
.help:disabled { opacity: .45; }
.hint { font-weight: 800; color: var(--turq-2); background: #e1f2f1; border: 2px dashed var(--turq); border-radius: 12px; padding: 4px 14px; animation: pop .4s; }
.q-tap { position: absolute; bottom: 6px; left: 0; right: 0; text-align: center; font-size: .78rem; color: var(--ink-3); opacity: 0; transition: opacity .3s; pointer-events: none; }
.q-card.tappable { cursor: pointer; }
.q-card.tappable .q-tap { opacity: 1; }
.q-card.revealed .q-foot .help { display: none; }

/* numeric */
.q-num { display: grid; justify-items: center; gap: 12px; }
.q-num .disp {
  direction: ltr; display: flex; align-items: baseline; justify-content: center; gap: 10px;
  min-width: min(360px, 100%); padding: 8px 18px; min-height: 66px;
  background: #fff; border: var(--edge); border-radius: 16px; box-shadow: inset 0 3px 0 rgba(59, 39, 24, .08);
}
.q-num .v { font-size: 2.2rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .02em; min-width: 1ch; }
.q-num .v:empty::after { content: "؟"; color: var(--ink-3); }
.q-num .u { font-size: 1.05rem; color: var(--ink-2); font-weight: 700; direction: rtl; }
.q-num .pad { direction: ltr; display: grid; grid-template-columns: repeat(3, 84px); gap: 8px; }
.q-num .pad button {
  height: 54px; font-size: 1.55rem; font-weight: 800; background: #fff; border: var(--edge); border-radius: 14px; box-shadow: 0 3px 0 var(--ink);
}
.q-num .pad button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.q-num .pad .enter { background: var(--saffron); font-size: 1.1rem; }
.q-num .pad .enter { grid-column: 1 / -1; height: 48px; }
.q-num .pad .dot { font-size: 1.9rem; line-height: 1; }
.q-num .pad .del { background: var(--paper-2); }
.q-num.sent .pad { opacity: .4; pointer-events: none; }
.q-num.sent .disp { background: #fdebc4; }
.q-numres { display: grid; gap: 14px; justify-items: center; }
.truth { display: flex; align-items: baseline; gap: 10px; background: #d9f0d5; border: 2.5px solid var(--ok); border-radius: 16px; padding: 6px 22px; animation: okpop .5s; }
.truth small { font-weight: 700; color: var(--ink-2); }
.truth b { font-size: 2.2rem; font-variant-numeric: tabular-nums; direction: ltr; }
.truth span { font-weight: 700; }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; width: min(560px, 100%); }
.rank li {
  display: grid; grid-template-columns: 30px 40px 1fr auto auto auto; align-items: center; gap: 10px;
  background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 4px 12px 4px 8px; animation: slideIn .4s backwards;
}
.rank li:nth-child(2) { animation-delay: .12s; } .rank li:nth-child(3) { animation-delay: .24s; }
.rank li.win { background: #fff3cf; border-width: 2.5px; box-shadow: 0 3px 0 var(--ink); }
.rank .pos { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--paper-2); border: 2px solid var(--ink); font-weight: 800; }
.rank li.win .pos { background: var(--gold); }
.rank img { width: 38px; height: 38px; border-radius: 50%; border: 2.5px solid var(--pc); object-fit: cover; }
.rank .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .g { font-weight: 800; font-size: 1.2rem; font-variant-numeric: tabular-nums; direction: ltr; }
.rank .d { font-size: .85rem; color: var(--ink-2); font-weight: 700; direction: ltr; unicode-bidi: plaintext; }
.rank li.win .d { color: var(--ok); }
.rank .tm { font-size: .78rem; color: var(--ink-3); }
@keyframes slideIn { from { transform: translateX(-20px); opacity: 0; } }

/* ---------- banner / toasts ---------- */
.banner { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; pointer-events: none; }
.banner .rib {
  display: flex; align-items: center; gap: 16px; padding: 14px 34px 14px 26px;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 22px; box-shadow: var(--deep);
  transform: scale(.6) rotate(-3deg); opacity: 0; transition: transform .35s cubic-bezier(.2, 1.5, .4, 1), opacity .25s;
  max-width: calc(100% - 32px);
}
.banner.war .rib { background: #fbe3d8; }
.banner.truce .rib { background: #ddf0ee; }
.banner.show .rib { transform: none; opacity: 1; }
.banner img { width: 74px; height: 74px; flex: none; }
.banner b { display: block; font-family: var(--title); font-size: clamp(1.9rem, 4.5vw, 2.8rem); line-height: 1.2; }
.banner span { display: block; font-weight: 700; color: var(--ink-2); font-size: 1.05rem; }
.toasts { position: fixed; z-index: 45; top: 86px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; width: min(560px, calc(100% - 24px)); }
.toast {
  font-weight: 700; padding: 8px 18px; border-radius: 14px; border: 2.5px solid var(--ink);
  background: var(--paper); box-shadow: 0 3px 0 var(--ink); animation: toastIn .3s cubic-bezier(.2, 1.4, .4, 1); transition: opacity .4s, transform .4s; text-align: center;
}
.toast.good { background: #d9f0d5; }
.toast.bad { background: #f8d6d1; }
.toast.gold { background: #fde6b8; }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes toastIn { from { transform: translateY(-14px) scale(.9); opacity: 0; } }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(59, 39, 24, .45); opacity: 0; transition: opacity .2s; }
#m-settings { z-index: 62; }
.modal.show { opacity: 1; }
.dlg { width: min(560px, 100%); max-height: calc(100svh - 32px); overflow-y: auto; padding: 20px 24px 22px; transform: scale(.95); transition: transform .25s cubic-bezier(.2, 1.4, .4, 1); }
.modal.show .dlg { transform: none; }
.dlg header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dlg h2 { font-family: var(--title); font-size: 2rem; margin: 0; }
.x { width: 40px; height: 40px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper-2); font-size: 1.5rem; line-height: 1; }
.how { width: min(720px, 100%); }
.steps { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 10px; }
.steps li { display: flex; gap: 14px; align-items: center; background: #fff; border: 2px solid var(--ink); border-radius: 16px; padding: 8px 14px 8px 8px; }
.steps img { width: 62px; height: 62px; flex: none; object-fit: contain; }
.steps b { font-size: 1.1rem; }
.steps p { margin: 2px 0 0; color: var(--ink-2); line-height: 1.6; font-size: .97rem; }
.tip { background: var(--paper-2); border-radius: 14px; padding: 10px 14px; line-height: 1.7; margin: 0 0 14px; }
.how > .btn { display: flex; margin: 0 auto; min-width: 200px; }
/* two heroes side by side for the truce */
.steps .duo { flex: none; width: 62px; height: 62px; position: relative; }
.steps .duo img { position: absolute; width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--ink); background: #f4ebd6; }
.steps .duo img:first-child { top: 2px; inset-inline-start: 0; }
.steps .duo img:last-child { bottom: 2px; inset-inline-end: 0; }
/* a truce offered: who leads and by how much, two answers, and the ten seconds */
.offer { width: min(440px, 100%); text-align: center; display: grid; gap: 12px; }
.offer p { margin: 0; line-height: 1.7; color: var(--ink-2); }
.offer p b { color: var(--ink); }
.offer .menu-row .btn { flex: 1; }
.offer-clk { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; }
.offer-clk .clk { --p: 1; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: conic-gradient(var(--turq) calc(var(--p) * 360deg), rgba(59, 39, 24, .14) 0); }
.offer-clk .clk b { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--paper); font-size: .95rem; font-variant-numeric: tabular-nums; }
.offer-clk .clk.low { background: conic-gradient(var(--bad) calc(var(--p) * 360deg), rgba(59, 39, 24, .14) 0); }
.offer-clk .clk.low b { color: var(--bad); }
.set-list { display: grid; gap: 8px; margin: 8px 0 16px; }
.tog { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 10px 14px; font-weight: 700; cursor: pointer; }
.tog input { position: absolute; opacity: 0; pointer-events: none; }
.tog i { position: relative; width: 52px; height: 30px; flex: none; border-radius: 99px; background: #d8c7a6; border: 2px solid var(--ink); transition: background .2s; }
.tog i::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); transition: inset-inline-start .2s; }
.tog input:checked + i { background: var(--turq); }
.tog input:checked + i::after { inset-inline-start: 24px; }
.tog input:focus-visible + i { outline: 3px solid var(--turq); outline-offset: 2px; }
.pause { text-align: center; }
.pause .emblem { margin: 0 auto; width: 96px; height: 96px; }
.pause p { color: var(--ink-2); margin: 4px 0 16px; }

/* ---------- results ---------- */
.result { background: var(--paper-2); overflow-y: auto; }
.result.active { display: block; }
.res-art { height: 36svh; min-height: 220px; border-bottom: 3px solid var(--ink); overflow: hidden; }
.res-art img { width: 100%; height: 100%; object-fit: cover; animation: kenburns 14s ease-out both; }
@keyframes kenburns { from { transform: scale(1.08); } }
.res-panel { width: min(820px, calc(100% - 32px)); margin: -70px auto 32px; padding: 18px 24px 22px; text-align: center; }
.res-panel h2 { font-family: var(--title); font-size: clamp(2.2rem, 5vw, 3.2rem); margin: 0; line-height: 1.25; }
.res-panel > p { color: var(--ink-2); font-size: 1.1rem; margin: 4px 0 14px; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 6px 0 16px; }
.pod { display: flex; flex-direction: column; align-items: center; width: 150px; animation: rise .7s cubic-bezier(.2, 1.4, .4, 1) backwards; }
.pod.r1 { animation-delay: .25s; } .pod.r3 { animation-delay: .1s; }
.pod .av { width: 76px; height: 76px; border-radius: 50%; overflow: hidden; border: 4px solid var(--pc); box-shadow: 0 0 0 2.5px var(--ink); background: #f4ebd6; }
.pod.r1 .av { width: 96px; height: 96px; }
.pod .av img { width: 100%; height: 100%; object-fit: cover; }
.pod .nm { margin-top: 6px; font-size: 1.05rem; }
.pod .sc { font-weight: 800; color: var(--pc); font-size: 1.25rem; }
.pod .step { width: 100%; margin-top: 6px; background: var(--pc); border: 2.5px solid var(--ink); border-bottom: 0; border-radius: 12px 12px 0 0; display: grid; place-items: center; color: #fff; font-family: var(--title); font-size: 2rem; }
.pod.r1 .step { height: 92px; } .pod.r2 .step { height: 64px; } .pod.r3 .step { height: 44px; }
.pod.me .nm::after { content: " (أنت)"; font-weight: 500; font-size: .85em; color: var(--ink-2); }
.podium { flex-wrap: wrap; }
.rest { flex-basis: 100%; list-style: none; margin: 10px 0 0; padding: 0; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.rest li { display: flex; align-items: center; gap: 6px; background: #fff; border: 2px solid var(--ink); border-radius: 99px; padding: 2px 12px 2px 4px; font-weight: 700; }
.rest li.me { background: #fff3cf; }
.rest i { font-style: normal; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--paper-2); border: 2px solid var(--ink); font-size: .85rem; }
.rest img { width: 30px; height: 30px; border-radius: 50%; border: 2.5px solid var(--pc); object-fit: cover; }
.rest span { color: var(--pc); font-weight: 800; }
.res-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.res-stats div { background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 8px; display: flex; flex-direction: column; }
.res-stats b { font-size: 1.5rem; }
.res-stats span { font-size: .82rem; color: var(--ink-2); }

/* flag a doubtful question (answer card and results) */
.flag { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; font-size: .88rem; }
.flag button { font: inherit; font-weight: 700; padding: 3px 11px; border: 1.5px solid var(--ink-3); border-radius: 99px; background: #fff; color: var(--ink-2); cursor: pointer; }
.flag button:hover { border-color: var(--ink); color: var(--ink); }
.flag .flag-btn { border-style: dashed; background: transparent; }
.flag .ask { font-weight: 700; color: var(--ink-2); }
.flag .ok { font-weight: 700; color: var(--ok); }
.res-qs { margin: 0 0 16px; background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 8px 14px; text-align: start; }
.res-qs summary { cursor: pointer; font-weight: 800; }
.res-qs ol { margin: 10px 0 4px; padding-inline-start: 22px; display: grid; gap: 10px; max-height: 46vh; overflow-y: auto; }
.res-qs li .q { margin: 0; font-weight: 700; }
.res-qs li .a { margin: 2px 0 4px; color: var(--ok); font-weight: 800; }
.res-qs li .flag { justify-content: flex-start; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 70; pointer-events: none; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .chars { grid-template-columns: repeat(3, 1fr); }
  .opts { grid-template-columns: 1fr 1fr; }
  .opts .name { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .home-art { inset: 0 0 auto 0; height: 46svh; }
  .home-art img { object-position: 15% 40%; }
  .home { background: var(--paper) var(--star); overflow-y: auto; }
  .home.active { display: block; }
  .home-panel { position: relative; inset: auto; width: auto; margin-top: calc(46svh - 70px); padding: 0 16px 28px; }
  .home-panel .emblem { width: 96px; height: 96px; }
  .tag { margin-bottom: 18px; }
  .sheet { padding: 16px 14px 18px; }
  .sheet-h h2 { font-size: 1.8rem; }
  .chars { gap: 8px; }
  .char small { display: none; }
  .opts { grid-template-columns: 1fr; }
  .g-top { flex-wrap: wrap; padding: 8px 8px 6px; gap: 8px; }
  .hud { order: 2; flex-basis: 100%; gap: 6px; }
  .g-bar { order: 1; width: 100%; justify-content: space-between; }
  .phase { flex-direction: row; gap: 8px; padding: 3px 12px; min-width: 0; }
  .icon-btn { width: 40px; height: 40px; }
  .pc { gap: 6px; padding: 4px 6px; border-radius: 12px; }
  .pc .av { width: 34px; height: 34px; border-width: 2.5px; }
  .pc .nm { font-size: .82rem; }
  .pc .nm small { display: none; }
  .pc .meta { gap: 4px; font-size: .72rem; flex-wrap: wrap; }
  .pc .sc { font-size: 1.05rem; min-width: 0; }
  .pc .ct { display: none; }
  .pc .tw i { width: 7px; height: 10px; }
  .hud.many { gap: 4px; }
  .hud.many .pc { flex-direction: column; gap: 1px; padding: 4px 2px 3px; text-align: center; }
  .hud.many .pc .av { width: 30px; height: 30px; border-width: 2px; }
  .hud.many .pc .info { width: 100%; }
  .hud.many .pc .nm { font-size: .68rem; }
  .hud.many .pc .meta { justify-content: center; gap: 3px; }
  .hud.many .pc .sc { font-size: .9rem; }
  .hud.many .pc .tw { display: none; }
  .hud.many .pc .turn { font-size: .6rem; padding: 0 5px; top: -9px; inset-inline-end: 4px; }
  .pc .lead-tag, .pc .pact { font-size: .6rem; padding: 0 5px; }
  .hud.many .pc .lead-tag { top: -9px; inset-inline-start: 4px; }
  .hud.many .pc .pact { bottom: -9px; inset-inline-start: 4px; }
  .hud.many .floater { inset-inline-start: 30%; }
  .seats[data-n="4"] { grid-template-columns: repeat(2, 1fr); }
  .seats[data-n="5"] { grid-template-columns: repeat(3, 1fr); }
  .board-wrap { padding: 4px 8px 6px; place-content: safe center start; }
  .prompt { font-size: .98rem; margin: 0 8px 8px; padding: 6px 14px; min-height: 40px; }
  .quiz { padding: 0; }
  .q-card { border-radius: 0; min-height: 100%; border-width: 0; padding: 14px 14px 22px; display: flex; flex-direction: column; }
  .q-text { margin: 8px 0 12px; }
  .q-opts { grid-template-columns: 1fr; gap: 9px; }
  .opt { min-height: 54px; font-size: 1.08rem; }
  .q-num .pad { grid-template-columns: repeat(3, minmax(70px, 1fr)); width: min(100%, 320px); }
  .profile .res-stats { grid-template-columns: repeat(2, 1fr); }
  .pf-cat { grid-template-columns: 26px 90px 1fr 40px; gap: 8px; }
  .pf-head img { width: 64px; height: 64px; }
  .dl-dots { gap: 5px; } .dl-dots i { width: 18px; height: 18px; }
  .rank li { grid-template-columns: 26px 34px 1fr auto auto; }
  .rank .tm { display: none; }
  .toasts { top: 120px; }
  .banner .rib { padding: 12px 18px; gap: 10px; }
  .banner img { width: 54px; height: 54px; }
  .res-art { height: 34svh; }
  .res-stats { grid-template-columns: 1fr 1fr; }
  .seats { gap: 8px; }
  .seat .av { width: 60px; height: 60px; }
  .seat b { font-size: .95rem; }
  .lobby-opts { grid-template-columns: 1fr; }
  .pod { width: 104px; }
  .pod .av { width: 58px; height: 58px; } .pod.r1 .av { width: 72px; height: 72px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .g-top { padding: 4px 8px; }
  .pc .av { width: 34px; height: 34px; }
  .prompt { margin-bottom: 4px; min-height: 34px; font-size: .95rem; }
  .quiz { padding: 0; }
  .q-card { border-radius: 0; min-height: 100%; }
  .q-opts { gap: 8px; }
  .opt { min-height: 46px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
