:root {
  --sand: #D9B382;
  --clay: #8C5E3C;
  --palm: #5B7F4A;
  --night: #2B2438;
  --mishkat: #E8A93C;
  --ink: #2B2438;
  --cream: #F3E3C5;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: "IBM Plex Sans Arabic", "Cairo", sans-serif;
  background: var(--night);
  color: var(--cream);
  user-select: none;
  touch-action: none;
}
#game-canvas { position: fixed; inset: 0; display: block; }

/* ————— شاشة الدخول ————— */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, #3a3050, var(--night));
  transition: opacity .5s;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

/* شاشة التحميل */
#loading { display: none; z-index: 60; }
#loading.show { display: flex; }
.loading-box { text-align: center; color: var(--cream); }
.loading-box p { margin-top: 16px; font-size: 15px; opacity: .85; }
.loading-spinner {
  width: 46px; height: 46px; margin: 20px auto 0;
  border: 4px solid rgba(232,169,60,.25); border-top-color: var(--mishkat);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.login-card {
  background: rgba(43, 36, 56, .92);
  border: 2px solid var(--mishkat);
  border-radius: 22px;
  padding: 26px 24px 22px;
  width: min(90vw, 360px);
  text-align: center;
  box-shadow: 0 0 60px rgba(232, 169, 60, .25);
}
.lantern-icon { font-size: 54px; animation: glow 3s ease-in-out infinite; }
@keyframes glow { 0%,100%{ filter: drop-shadow(0 0 6px var(--mishkat)); } 50%{ filter: drop-shadow(0 0 20px var(--mishkat)); } }
.login-card h1 { color: var(--mishkat); font-size: 30px; margin: 6px 0; }
.subtitle { font-size: 14px; opacity: .8; margin-bottom: 18px; }
.login-card label { display: block; text-align: right; font-size: 13px; margin: 12px 4px 6px; opacity: .85; }
.login-card input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: none;
  background: rgba(255,255,255,.1); color: var(--cream); font-size: 16px;
  font-family: inherit; text-align: right;
}
.login-card input:focus { outline: 2px solid var(--mishkat); }
/* منتقي الشخصية */
#char-picker { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.char-preview { width: 200px; height: 220px; }
.char-nav { display: flex; align-items: center; justify-content: center; gap: 14px; width: 100%; }
.char-arrow { width: 40px; height: 40px; border-radius: 50%; border: none;
  background: rgba(232,169,60,.2); color: var(--mishkat); font-size: 26px; cursor: pointer; line-height: 1; }
.char-arrow:active { transform: scale(.9); }
.char-name { font-size: 20px; font-weight: 700; color: var(--mishkat); min-width: 90px; text-align: center; }
.char-chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.char-chip { border: 1.5px solid rgba(232,169,60,.35); background: rgba(255,255,255,.05);
  color: var(--cream); border-radius: 10px; padding: 5px 10px; font-family: inherit; font-size: 12px; cursor: pointer; }
.char-chip.sel { background: var(--mishkat); color: var(--night); font-weight: 700; border-color: var(--mishkat); }

.swatches { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatch.sel { border-color: var(--cream); transform: scale(1.12); }
#login-btn {
  margin-top: 20px; width: 100%; padding: 14px; border: none; border-radius: 14px;
  background: var(--mishkat); color: var(--night); font-size: 18px; font-weight: 700;
  font-family: inherit; cursor: pointer; transition: transform .1s;
}
#login-btn:active { transform: scale(.97); }
.hint { font-size: 11px; opacity: .55; margin-top: 14px; line-height: 1.6; }

/* ————— HUD ————— */
#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#hud > * { pointer-events: auto; }

/* بطاقة الترحيب */
#welcome { display: none; z-index: 55; }
#welcome.show { display: flex; }
.welcome-list { list-style: none; text-align: right; margin: 14px 0; padding: 0; }
.welcome-list li { font-size: 14px; line-height: 1.7; margin-bottom: 10px; }
#welcome-ok { margin-top: 8px; width: 100%; padding: 13px; border: none; border-radius: 14px;
  background: var(--mishkat); color: var(--night); font-size: 17px; font-weight: 700; font-family: inherit; cursor: pointer; }
#welcome-ok:active { transform: scale(.97); }

/* شريط المهمة الحالية */
#objective { position: absolute; top: max(100px, calc(env(safe-area-inset-top) + 88px));
  left: 50%; transform: translateX(-50%); max-width: 92vw; display: none;
  background: rgba(43,36,56,.9); border: 1.5px solid rgba(232,169,60,.5); border-radius: 12px;
  padding: 6px 14px; font-size: 13px; font-weight: 600; white-space: nowrap; z-index: 6;
  overflow: hidden; text-overflow: ellipsis; }
#objective.show { display: block; }
.obj-then { opacity: .7; font-weight: 400; font-size: 12px; }

/* شات */
#chat { position: absolute; bottom: calc(88px + env(safe-area-inset-bottom)); left: 12px; z-index: 8; }
#chat-toggle { width: 46px; height: 46px; border-radius: 50%; border: 1.5px solid var(--mishkat);
  background: rgba(43,36,56,.9); font-size: 20px; cursor: pointer; position: relative; }
#chat-toggle.unread::after { content: ''; position: absolute; top: 4px; right: 4px; width: 11px; height: 11px;
  background: #E8452C; border-radius: 50%; border: 2px solid var(--night); }
#chat-panel { display: none; position: absolute; bottom: 54px; left: 0; width: min(78vw, 300px);
  background: rgba(43,36,56,.95); border: 1.5px solid rgba(232,169,60,.4); border-radius: 14px; padding: 8px; }
#chat.open #chat-panel { display: block; }
#chat-list { max-height: 34vh; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; }
.chat-msg { font-size: 13px; line-height: 1.5; word-break: break-word; }
.chat-nm { font-weight: 700; }
/* حدث لعبة داخل الشات — مميز عن رسائل اللاعبين */
.chat-sys {
  font-size: 12.5px; line-height: 1.5; text-align: center; color: #E8C88A;
  background: rgba(232,169,60,.10); border: 1px solid rgba(232,169,60,.22);
  border-radius: 10px; padding: 3px 8px; margin: 1px 4px; word-break: break-word;
}
.chat-input-row { display: flex; gap: 6px; }
#chat-input { flex: 1; padding: 8px 10px; border-radius: 10px; border: none;
  background: rgba(255,255,255,.1); color: var(--cream); font-family: inherit; font-size: 14px; text-align: right; }
#chat-input:focus { outline: 1.5px solid var(--mishkat); }
#chat-send { width: 40px; border: none; border-radius: 10px; background: var(--mishkat); color: var(--night);
  font-size: 16px; font-weight: 700; cursor: pointer; }

/* لوحة النقاط — مثبّتة بالزاوية اليسار فوق الكل */
#scoreboard { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; z-index: 12; }
#sb-toggle {
  background: rgba(43,36,56,.85); color: var(--cream); border: 1.5px solid var(--mishkat);
  border-radius: 12px; padding: 8px 14px; font-size: 16px; font-family: inherit;
  font-weight: 700; cursor: pointer;
}
/* اللوحة absolute حتى لا تمدّد الحاوية وتزحلق زر الكأس في RTL */
#scoreboard .sb-body {
  position: absolute; top: calc(100% + 6px); left: 0;
  background: rgba(43,36,56,.95); border: 1.5px solid rgba(232,169,60,.4);
  border-radius: 12px; padding: 10px; width: 210px; max-height: 0; overflow: hidden;
  transition: max-height .3s; opacity: 0;
}
#scoreboard.open .sb-body { max-height: 340px; opacity: 1; overflow-y: auto; }
.sb-title { font-size: 12px; opacity: .7; margin-bottom: 8px; }
.sb-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-radius: 8px; }
.sb-row.me { background: rgba(232,169,60,.16); }
.sb-row.tappable { cursor: pointer; }
.sb-row.tappable:active { background: rgba(232,169,60,.22); }
.sb-row.tappable::after { content: '⋯'; opacity: .5; font-size: 16px; }
.sb-rank { min-width: 18px; font-size: 12px; font-weight: 700; color: var(--mishkat); text-align: center; }
.sb-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
#sb-feed { display: flex; flex-direction: column; gap: 4px; }
.feed-row { font-size: 12px; opacity: .85; line-height: 1.5; padding: 3px 4px;
  border-right: 2px solid rgba(232,169,60,.4); }
.feed-empty { font-size: 12px; opacity: .5; padding: 4px; }
.sb-name { flex: 1; font-size: 14px; }
.sb-pts { font-size: 13px; color: var(--mishkat); font-weight: 700; }

/* زر المهام (فوق يمين) */
#quests-btn {
  position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; z-index: 12;
  background: rgba(43,36,56,.9); color: var(--cream); border: 1.5px solid var(--mishkat);
  border-radius: 12px; padding: 8px 12px; font-family: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
}
#quests-btn:active { transform: scale(.95); }

/* قائمة المهام */
.qlist-row { display: block; width: 100%; text-align: right; background: rgba(255,255,255,.05);
  border: 1.5px solid transparent; border-radius: 14px; padding: 12px; cursor: pointer; font-family: inherit; }
.qlist-row.ready { border-color: #5FB86B; background: rgba(95,184,107,.12); }
.qlist-row:active { background: rgba(232,169,60,.12); }
.ql-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.ql-npc { font-size: 12.5px; color: var(--mishkat); font-weight: 700; }
.ql-pct { font-size: 13px; font-weight: 700; }
.ql-obj { font-size: 14px; margin-bottom: 8px; }

/* شريط الموارد */
#resource-bar {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%); display: none; align-items: center; gap: 10px;
  background: rgba(43,36,56,.9); border: 1.5px solid rgba(232,169,60,.45);
  border-radius: 16px; padding: 6px 8px 6px 12px; z-index: 7;
}
#resource-bar.show { display: flex; }
#resource-bar .res { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 15px; }
#resource-bar .ri { font-size: 16px; }
#res-boosts { display: inline-flex; gap: 4px; }
.boost-badge { font-size: 12px; font-weight: 700; color: #E8A93C; background: rgba(232,169,60,.16);
  border-radius: 8px; padding: 1px 5px; }
#camp-btn {
  background: linear-gradient(180deg, #F6C868, var(--mishkat)); color: var(--night);
  border: none; border-radius: 12px; padding: 7px 12px; font-family: inherit; font-weight: 700;
  font-size: 13px; cursor: pointer;
}
#camp-btn:active { transform: scale(.95); }

/* مودال عام */
.modal-root {
  position: absolute; inset: 0; z-index: 40; display: none;
  align-items: center; justify-content: center; background: rgba(0,0,0,.55);
  padding: 20px;
}
.modal-root.show { display: flex; }
.modal-card {
  background: #322A44; border: 2px solid var(--mishkat); border-radius: 20px;
  width: min(94vw, 400px); max-height: 82vh; overflow-y: auto; padding: 18px;
  position: relative;
}
.modal-close {
  position: absolute; top: 12px; left: 12px; width: 32px; height: 32px;
  background: rgba(255,255,255,.1); color: var(--cream); border: none; border-radius: 50%;
  font-size: 16px; cursor: pointer;
}
.modal-title { color: var(--mishkat); font-weight: 700; font-size: 19px; text-align: center; margin-bottom: 14px; }
.modal-body { display: flex; flex-direction: column; gap: 10px; }
.loading-row { text-align: center; opacity: .7; padding: 20px; }

.big-action {
  background: linear-gradient(180deg, #5FB86B, #3E9E4E); color: #fff; border: none;
  border-radius: 14px; padding: 14px; font-family: inherit; font-weight: 700; font-size: 16px;
  cursor: pointer;
}
.big-action small { font-weight: 400; opacity: .9; font-size: 13px; }
.big-action:active { transform: scale(.98); }

/* صف مبنى */
.bld-row { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.05);
  border-radius: 14px; padding: 10px; }
.bld-ico { font-size: 28px; width: 40px; text-align: center; }
.bld-info { flex: 1; }
.bld-name { font-weight: 700; font-size: 15px; }
.bld-lvl { color: var(--mishkat); font-size: 12px; font-weight: 400; }
.bld-desc { font-size: 12px; opacity: .6; }
.bld-up, .shop-buy {
  background: var(--mishkat); color: var(--night); border: none; border-radius: 12px;
  padding: 8px 12px; font-family: inherit; font-weight: 700; font-size: 13px; cursor: pointer;
  text-align: center; line-height: 1.3;
}
.bld-up small, .shop-buy small { font-weight: 400; font-size: 11px; }
.bld-up.off, .shop-buy.off { background: #6b6577; color: #cfc8dd; }
.bld-up:active, .shop-buy:active { transform: scale(.95); }

/* صف بضاعة المتجر */
.shop-row { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.05);
  border-radius: 14px; padding: 12px; }
.shop-info { flex: 1; }
.shop-name { font-weight: 700; font-size: 15px; }
.shop-tag { font-size: 11px; font-weight: 700; color: #5FB86B; background: rgba(95,184,107,.15);
  border-radius: 8px; padding: 1px 6px; margin-right: 4px; white-space: nowrap; }
.shop-cat { font-size: 12px; opacity: .6; }

/* مكالمة صوتية */
#voice-bar { position: fixed; top: max(12px, env(safe-area-inset-top)); right: 12px; z-index: 45;
  display: none; align-items: center; gap: 8px; background: rgba(43,36,56,.95);
  border: 1.5px solid #5FB86B; border-radius: 14px; padding: 6px 8px 6px 12px; }
#voice-bar.show { display: flex; }
#voice-status { font-size: 13px; font-weight: 600; }
#voice-bar button { width: 38px; height: 38px; border: none; border-radius: 10px; font-size: 18px; cursor: pointer; }
#voice-mute { background: rgba(255,255,255,.12); }
#voice-hang { background: #C0392B; }
.voice-notif { position: fixed; top: 40%; left: 50%; transform: translateX(-50%); z-index: 60;
  background: #322A44; border: 2px solid #5FB86B; border-radius: 18px; padding: 18px 20px; text-align: center;
  width: min(90vw, 320px); box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.vn-title { font-size: 16px; margin-bottom: 14px; }
.vn-row { display: flex; gap: 10px; }
.vn-yes, .vn-no { flex: 1; padding: 12px; border: none; border-radius: 12px; font-family: inherit;
  font-weight: 700; font-size: 15px; cursor: pointer; }
.vn-yes { background: #5FB86B; color: #fff; }
.vn-no { background: #6b6577; color: var(--cream); }

/* ساحة المعركة الحية */
#battle-overlay { position: fixed; inset: 0; z-index: 70; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  background: #1c1526; padding: 8px; }
#battle-overlay.show { display: flex; }
#battle-hud { display: flex; justify-content: space-between; align-items: center; width: min(520px, 100%);
  padding: 6px 12px; font-weight: 700; font-size: 14px; color: var(--cream); }
#battle-timer { color: var(--mishkat); font-size: 18px; }
#battle-canvas { border-radius: 14px; border: 2px solid var(--mishkat); max-width: 100%; touch-action: none; }
#battle-msg { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(43,36,56,.96); border: 2px solid var(--mishkat); border-radius: 18px; padding: 20px 24px;
  text-align: center; min-width: 240px; }
#battle-msg:empty { display: none; }
#battle-deploy { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap;
  margin-top: 10px; width: min(520px, 100%); }
.deploy-btn { position: relative; width: 60px; height: 56px; border-radius: 14px; border: 2px solid rgba(232,169,60,.4);
  background: rgba(255,255,255,.08); font-size: 26px; cursor: pointer; }
.deploy-btn.sel { border-color: var(--mishkat); background: rgba(232,169,60,.25); }
.deploy-btn:disabled { opacity: .4; }
.dp-n { position: absolute; bottom: 2px; right: 6px; font-size: 12px; font-weight: 700; color: var(--mishkat); }
.deploy-hint { width: 100%; text-align: center; font-size: 11px; opacity: .6; margin-top: 4px; }

/* اختيار نوع المبارزة */
.game-chips { display: flex; gap: 8px; margin: 8px 0; }
.game-chip { flex: 1; padding: 10px; border-radius: 12px; border: 1.5px solid rgba(232,169,60,.35);
  background: rgba(255,255,255,.05); color: var(--cream); font-family: inherit; font-size: 13px; cursor: pointer; }
.game-chip.sel { background: var(--mishkat); color: var(--night); font-weight: 700; }

/* شد الحبل */
.tug-track { position: relative; display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.06); border-radius: 12px; padding: 10px 12px; margin: 10px 0; overflow: hidden; }
.tug-side { font-size: 13px; font-weight: 700; opacity: .85; z-index: 1; }
.tug-knot { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-size: 34px; transition: transform .12s; }

/* رهان المبارزة */
.wager-row { display: flex; align-items: center; gap: 10px; justify-content: center; margin: 8px 0; }
.wager-row input { width: 110px; text-align: center; font-size: 22px; font-weight: 700; padding: 8px;
  border-radius: 12px; border: 1.5px solid rgba(232,169,60,.4); background: rgba(255,255,255,.08);
  color: var(--mishkat); font-family: inherit; }
.duel-spin { text-align: center; font-size: 40px; margin: 14px 0; animation: spin 1.4s linear infinite; }

/* مبارزة */
.duel-score { text-align: center; font-size: 16px; margin-bottom: 10px; }
.duel-score span { opacity: .6; font-size: 13px; }
.duel-hint { text-align: center; opacity: .8; margin-bottom: 6px; }
.duel-choices { display: flex; justify-content: center; gap: 12px; }
.duel-btn { width: 72px; height: 72px; border-radius: 16px; border: 2px solid rgba(232,169,60,.4);
  background: rgba(255,255,255,.06); font-size: 38px; cursor: pointer; }
.duel-btn:active { transform: scale(.9); background: rgba(232,169,60,.25); }
.duel-result { text-align: center; font-size: 16px; margin: 8px 0; }
/* قدرات المبارزة */
.duel-abilities { display: flex; justify-content: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.abil-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-family: inherit;
  padding: 6px 10px; border-radius: 12px; border: 1px solid rgba(232,169,60,.35);
  background: rgba(255,255,255,.05); color: #F3E3C5; cursor: pointer; }
.abil-btn:active { transform: scale(.94); }
.abil-btn.armed { border-color: #5FB86B; background: rgba(95,184,107,.18); box-shadow: 0 0 10px rgba(95,184,107,.4); }
.abil-q { font-weight: 700; color: var(--mishkat); background: rgba(0,0,0,.25); border-radius: 8px; padding: 0 5px; }

/* مهمة */
.quest-story { font-size: 15px; line-height: 1.9; background: rgba(255,255,255,.05);
  padding: 12px; border-radius: 12px; border-right: 3px solid var(--mishkat); }
.quest-obj { font-weight: 700; font-size: 14px; margin-top: 4px; }
.quest-howto { font-size: 12.5px; line-height: 1.6; opacity: .85; background: rgba(232,169,60,.12);
  border-radius: 10px; padding: 8px 10px; }
.quest-bar { height: 12px; background: rgba(255,255,255,.1); border-radius: 8px; overflow: hidden; }
.quest-fill { height: 100%; background: linear-gradient(90deg, #5FB86B, #3E9E4E); transition: width .3s; }
.quest-prog { text-align: center; font-size: 13px; opacity: .8; }
.quest-reward { font-size: 13px; color: var(--mishkat); text-align: center; }
.quest-soon { text-align: center; font-size: 13px; opacity: .7; padding: 8px;
  background: rgba(255,255,255,.05); border-radius: 10px; }
.quest-done { text-align: center; font-size: 20px; font-weight: 700; color: #6FCF77; }

/* قسم الجيش */
.army-box { background: rgba(255,255,255,.05); border-radius: 14px; padding: 12px; margin-top: 4px; }
.army-title { font-weight: 700; font-size: 15px; margin-bottom: 10px; display: flex; justify-content: space-between; }
.army-title span { color: var(--mishkat); font-size: 13px; }
.army-title span.over { color: #E86A5C; }
.unit-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.unit-ico { font-size: 20px; }
.unit-name { flex: 1; font-size: 14px; }
.unit-val { min-width: 38px; text-align: center; font-weight: 700; font-size: 16px; }
.stp { width: 34px; height: 34px; border-radius: 10px; border: none; background: rgba(232,169,60,.25);
  color: var(--cream); font-size: 20px; font-weight: 700; cursor: pointer; }
.stp:active { transform: scale(.92); }
.army-hint { font-size: 11px; opacity: .55; margin-top: 8px; line-height: 1.5; }

/* نتيجة الغارة */
.raid-q { text-align: center; font-size: 16px; line-height: 1.7; margin-bottom: 8px; }
.raid-q small { opacity: .7; font-size: 13px; }
.raid-res { text-align: center; font-size: 22px; font-weight: 700; padding: 10px; border-radius: 12px; }
.raid-res.win { color: #6FCF77; }
.raid-res.lose { color: #E86A5C; }
.raid-detail { text-align: center; font-size: 14px; line-height: 1.8; margin-top: 8px; opacity: .9; }

/* التعبيرات داخل الشات */
#chat-emojis { display: flex; gap: 5px; justify-content: space-between; margin-bottom: 8px;
  padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,.08); }
.emoji-btn {
  flex: 1; height: 38px; border: none; background: rgba(255,255,255,.08);
  border-radius: 10px; font-size: 20px; cursor: pointer; transition: transform .1s;
}
.emoji-btn:active { transform: scale(1.2); background: rgba(232,169,60,.3); }

/* زر التفاعل — بوسط أسفل الشاشة */
#interact {
  position: absolute; bottom: calc(28px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%);
  display: none; align-items: center; gap: 8px;
  background: linear-gradient(180deg, #F6C868, var(--mishkat)); color: var(--night);
  border: none; border-radius: 30px; padding: 13px 24px; font-family: inherit; font-weight: 700;
  font-size: 15px; cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,.45);
  animation: pop .3s;
}
#interact.show { display: flex; }
#interact:active { transform: translateX(-50%) scale(.95); }
.interact-icon { font-size: 20px; }
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* شريط صحة الوحش */
#boss-bar { position: absolute; top: max(56px, calc(env(safe-area-inset-top) + 44px));
  left: 50%; transform: translateX(-50%); width: min(80vw, 320px); display: none; text-align: center; }
#boss-bar.show { display: block; }
.boss-label { font-size: 13px; font-weight: 700; color: #E8452C; margin-bottom: 3px;
  text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.boss-track { height: 14px; background: rgba(0,0,0,.5); border: 1.5px solid rgba(232,69,44,.6);
  border-radius: 8px; overflow: hidden; }
#boss-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #E8452C, #B3352E); transition: width .4s; }
#boss-hp { font-size: 11px; opacity: .85; margin-top: 2px; }

/* Toast — أسفل الشاشة (فوق زر التفاعل) عشان ما يزدحم مع أشرطة الأعلى */
#toast {
  position: absolute; bottom: calc(90px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(43,36,56,.96); border: 1.5px solid var(--mishkat); color: var(--cream);
  padding: 10px 18px; border-radius: 14px; font-size: 14px; opacity: 0; z-index: 30;
  transition: opacity .25s, transform .25s; max-width: 90vw; text-align: center; pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* صندوق حوار NPC */
#dialog {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(to top, rgba(43,36,56,.98), rgba(43,36,56,.9));
  border-top: 2px solid var(--mishkat); padding: 16px 20px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .3s; cursor: pointer;
}
#dialog.show { transform: translateY(0); }
#dialog-name { color: var(--mishkat); font-weight: 700; font-size: 17px; margin-bottom: 6px; }
#dialog-text { font-size: 16px; line-height: 1.7; min-height: 44px; }
.dialog-hint { text-align: left; font-size: 12px; opacity: .5; margin-top: 6px; }

/* جويستك عائم — يظهر مكان اللمس، مخفي غير ذلك */
#mobile-controls { position: absolute; inset: 0; pointer-events: none; }
#joy-base {
  position: absolute; width: 128px; height: 128px; transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255,255,255,.10), rgba(255,255,255,.03));
  border: 2px solid rgba(232,169,60,.35); border-radius: 50%;
  opacity: 0; transition: opacity .12s; pointer-events: none;
}
#joy-base.active { opacity: .9; }
#joy-knob {
  position: absolute; top: 50%; left: 50%; width: 54px; height: 54px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #F6C868, var(--mishkat));
  border-radius: 50%; box-shadow: 0 2px 10px rgba(0,0,0,.35);
}

/* زر صد أبوناصر — يظهر أثناء نافذة السرقة، يُضغط مرتين */
#sab-defend {
  position: absolute; left: 50%; bottom: 130px; transform: translateX(-50%) scale(.9);
  display: none; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 22px; border: 2px solid #E86A3C; border-radius: 18px;
  background: rgba(60,45,45,.92); color: #F3E3C5; font-family: inherit;
  box-shadow: 0 0 22px rgba(232,106,60,.5); z-index: 60; cursor: pointer;
  animation: sabPulse .7s ease-in-out infinite alternate;
}
#sab-defend.show { display: flex; }
#sab-defend .sab-emoji { font-size: 30px; line-height: 1; }
#sab-defend .sab-txt { font-size: 15px; font-weight: 700; color: #E8A93C; }
#sab-defend .sab-hits { font-size: 18px; letter-spacing: 4px; color: #E86A3C; min-height: 20px; }
@keyframes sabPulse {
  from { box-shadow: 0 0 14px rgba(232,106,60,.4); }
  to   { box-shadow: 0 0 30px rgba(232,106,60,.85); }
}
