/* =====================================================
   Memory Game – ملف التنسيق
   الألوان: بنفسجي داكن مع درجات بنفسجية فاتحة
   اللاعب الأول: أزرق | اللاعب الثاني: أحمر
   ===================================================== */

/* ---------- الخطوط (موجودة داخل مجلد assets/fonts) ---------- */
@font-face {
  font-family: "Fredoka";
  src: url(assets/fonts/fredoka.woff2) format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Cairo";
  src: url(assets/fonts/cairo-arabic.woff2) format("woff2");
  font-weight: 200 900;
  font-display: swap;
}

/* ---------- المتغيرات ---------- */
:root {
  --font: "Fredoka", "Cairo", system-ui, sans-serif;
  --deep: #1a0f4a;
  --purple: #3b2492;
  --purple-2: #5a36bb;
  --lav: #8a6cf0;
  --lav-light: #e6dcff;
  --gold: #ffd23f;
  --blue: #52b2ff;
  --red: #ff6a80;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: #fff;
  background: var(--deep);
  overflow: hidden;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; padding: 0; background: none; cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #fff; outline-offset: 3px; box-shadow: 0 0 0 6px rgba(255, 210, 63, .9); }

/* ---------- الخلفية ---------- */
.bg {
  position: fixed; inset: 0; z-index: -1;
  background: url(assets/cover.jpg) center / cover no-repeat;
  transition: filter .5s, transform .5s;
}
.bg::after { content: ""; position: absolute; inset: 0; background: rgba(26, 12, 75, .78); transition: background .4s; }
body:not(.is-home) .bg { filter: blur(12px) saturate(1.1); transform: scale(1.08); }

/* الصفحة الرئيسية: تدرج داكن من جهة النص (اليمين) ليبقى الباب والمفتاح ظاهرين */
body.is-home .bg::after {
  background:
    linear-gradient(to left, rgba(22, 9, 65, .94) 0%, rgba(22, 9, 65, .82) 32%, rgba(22, 9, 65, 0) 62%),
    linear-gradient(to top, rgba(22, 9, 65, .55), rgba(22, 9, 65, 0) 35%);
}

/* ---------- الشاشات ---------- */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; animation: screen-in .4s ease; }
@keyframes screen-in { from { opacity: 0; transform: translateY(14px); } }

/* ---------- الأزرار ---------- */
/* زر كبير: إطار ذهبي + وجه وردي + لمعة */
.pill {
  position: relative; display: inline-flex; padding: 5px; border-radius: 99px;
  background: linear-gradient(#fff3a3, #ffc83a 55%, #f1a21b);
  box-shadow: 0 6px 0 #c2810f, 0 12px 18px rgba(20, 5, 60, .45), 0 0 22px rgba(255, 236, 130, .45);
  transition: transform .12s, box-shadow .12s, filter .12s;
}
.pill__face {
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; gap: .55em;
  min-height: 46px; padding: .35em 1.7em; border-radius: 99px;
  background: linear-gradient(#ff6aa4, #ee3f86 48%, #d52872);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .45), inset 0 -5px 0 #a8175b;
  font-size: clamp(16px, 2.2vw, 20px); font-weight: 700; text-shadow: 0 2px 0 #a8175b; white-space: nowrap;
}
.pill__face::before {
  content: ""; position: absolute; left: 5%; right: 5%; top: 6%; height: 38%; border-radius: 99px;
  background: linear-gradient(rgba(255, 255, 255, .4), rgba(255, 255, 255, .02)); pointer-events: none;
}
.pill .ico { position: relative; width: 1.1em; height: 1.1em; flex: none; }
.pill--alt { background: linear-gradient(#e1fffa, #6fe8d8 55%, #2cbfb0); box-shadow: 0 6px 0 #178a80, 0 12px 18px rgba(10, 60, 70, .4), 0 0 22px rgba(130, 255, 235, .4); }
.pill--alt .pill__face { background: linear-gradient(#4eeedb, #1bbfae 48%, #0f9a8f); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .45), inset 0 -5px 0 #0a6f68; text-shadow: 0 2px 0 #0a6f68; }
.pill--big .pill__face { min-height: 62px; padding: .3em 2.2em; font-size: clamp(22px, 3vw, 30px); }
.pill--big { animation: glow 2.8s ease-in-out infinite; }
@keyframes glow { 50% { filter: brightness(1.08) drop-shadow(0 0 12px rgba(255, 236, 130, .8)); } }
@media (hover: hover) { .pill:hover { filter: brightness(1.08); transform: translateY(-2px); } }
.pill:active { transform: translateY(5px); box-shadow: 0 1px 0 #c2810f; }
.pill--alt:active { box-shadow: 0 1px 0 #178a80; }

/* زر دائري كحلي (أيقونة) */
.round {
  flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 30%, #3b32a0, #241d6b 75%);
  border: 3px solid #7d6be0;
  box-shadow: 0 4px 0 #170f55, 0 0 12px rgba(140, 110, 255, .4), inset 0 2px 0 rgba(255, 255, 255, .18);
  transition: transform .12s, box-shadow .12s, filter .12s;
}
.round svg { width: 54%; height: 54%; color: #fff; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .35)); }
@media (hover: hover) { .round:hover { filter: brightness(1.25); } }
.round:active { transform: translateY(4px); box-shadow: 0 0 0 #170f55, inset 0 3px 5px rgba(0, 0, 0, .35); }

/* =====================================================
   الصفحة الرئيسية
   ===================================================== */
.home__content {
  position: absolute; top: 50%; right: clamp(20px, 5vw, 90px); transform: translateY(-50%);
  width: min(36vw, 520px); text-align: center; display: flex; flex-direction: column; align-items: center;
}
.logo {
  margin: 10px 0 0; font-size: clamp(54px, 7vw, 108px); line-height: .92; font-weight: 700; letter-spacing: .04em;
  background: linear-gradient(#fff 30%, #c9b6ff); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #2d1a7a) drop-shadow(0 8px 18px rgba(0, 0, 0, .45));
}
.slogan { margin: 18px 0 6px; font-size: clamp(26px, 3.2vw, 44px); font-weight: 800; color: var(--gold); text-shadow: 0 3px 0 #a8650a, 0 6px 14px rgba(0, 0, 0, .4); }
.desc { margin: 0 0 26px; font-size: clamp(16px, 1.6vw, 21px); color: var(--lav-light); line-height: 1.7; text-shadow: 0 2px 6px rgba(0, 0, 0, .5); }

/* بطاقات الزينة */
.fan { display: flex; justify-content: center; gap: 0; }
.fan .card { width: clamp(70px, 8vw, 118px); animation: float 4s ease-in-out infinite; pointer-events: none; }
.fan .card:nth-child(1) { transform: rotate(-12deg) translateY(10px); }
.fan .card:nth-child(2) { z-index: 2; animation-delay: -1.3s; margin: 0 -8px; }
.fan .card:nth-child(3) { transform: rotate(12deg) translateY(10px); animation-delay: -2.6s; }
@keyframes float { 50% { translate: 0 -8px; } }

/* الجوال العمودي: النص في الأسفل */
@media (orientation: portrait) {
  body.is-home .bg::after { background: linear-gradient(to top, rgba(22, 9, 65, .97) 0%, rgba(22, 9, 65, .9) 48%, rgba(22, 9, 65, 0) 78%); }
  .home__content { top: auto; right: 0; left: 0; bottom: max(24px, env(safe-area-inset-bottom)); transform: none; width: auto; padding: 0 20px; }
}
@media (orientation: portrait) and (max-height: 700px) { .fan { display: none; } }
@media (max-height: 520px) and (orientation: landscape) { .fan { display: none; } .desc { margin-bottom: 14px; } .slogan { margin-top: 10px; } }

/* =====================================================
   شاشة اختيار نمط اللعب
   ===================================================== */
.mode { overflow-y: auto; padding: clamp(14px, 3vw, 32px); align-items: center; }
.mode__head { margin-top: auto; width: min(100%, 940px); display: flex; align-items: center; gap: 14px; margin-bottom: clamp(16px, 4vh, 40px); }
.mode__head h2 { margin: 0; font-size: clamp(26px, 4vw, 40px); font-weight: 800; text-shadow: 0 3px 0 rgba(20, 5, 80, .6); }
.mode__cards { width: min(100%, 940px); margin: 0 0 auto; display: grid; grid-template-columns: repeat(2, 1fr); gap: clamp(14px, 3vw, 30px); }
.mode-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px;
  padding: clamp(18px, 3vw, 34px) clamp(16px, 2.5vw, 28px);
  border-radius: 28px; border: 4px solid var(--lav);
  background: linear-gradient(rgba(90, 54, 187, .92), rgba(45, 26, 122, .95));
  box-shadow: 0 8px 0 #1a0f55, 0 18px 36px rgba(10, 3, 50, .5), inset 0 3px 0 rgba(255, 255, 255, .15);
  transition: transform .2s;
}
@media (hover: hover) { .mode-card:hover { transform: translateY(-6px); } }
.mode-card__icon {
  display: flex; justify-content: center; align-items: center; min-width: 104px; height: 104px; padding: 0 14px; border-radius: 52px;
  background: radial-gradient(circle at 50% 30%, #3b32a0, #1f1a5c 80%);
  border: 4px solid #7d6be0; box-shadow: 0 5px 0 #170f55, inset 0 2px 0 rgba(255, 255, 255, .18);
}
.mode-card__icon svg { width: 58px; height: 58px; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .35)); }
.mode-card__icon svg + svg { margin-right: -14px; }
.mode-card h3 { margin: 4px 0 0; font-size: clamp(24px, 3vw, 32px); font-weight: 800; color: var(--gold); }
.mode-card p { margin: 0 0 8px; max-width: 24ch; font-size: clamp(15px, 1.7vw, 18px); line-height: 1.7; color: var(--lav-light); flex: 1; }
@media (max-width: 680px) {
  .mode__cards { grid-template-columns: 1fr; }
  .mode-card { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 8px 14px; padding: 16px; }
  .mode-card__icon { min-width: 72px; height: 72px; border-radius: 36px; padding: 0 8px; }
  .mode-card__icon svg { width: 38px; height: 38px; }
  .mode-card h3 { align-self: center; }
  .mode-card p { flex: 1 1 100%; max-width: none; margin: 0; }
}

/* =====================================================
   شاشة اللعبة: HUD + الشبكة
   ===================================================== */
.hud {
  flex: none; display: grid; gap: 10px; padding: 10px clamp(10px, 3vw, 28px) 14px;
  background: linear-gradient(var(--purple), var(--purple-2));
  border-bottom: 3px solid var(--lav); box-shadow: 0 6px 16px rgba(20, 6, 70, .45);
}
.hud__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hud__title { margin: 0; font-size: clamp(18px, 3vw, 28px); font-weight: 700; letter-spacing: .08em; text-shadow: 0 2px 0 rgba(20, 5, 80, .6); }
.hud__ctl { display: flex; gap: 10px; }
.hud__single, .hud__duo { width: min(100%, 920px); margin-inline: auto; }

/* لوحة اللاعب الواحد */
.hud__single { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 62px; padding: 6px 10px;
  border-radius: 18px; background: linear-gradient(#32298a, #231c66); border: 2px solid #7d6be0;
  box-shadow: 0 4px 0 #181347, inset 0 2px 0 rgba(255, 255, 255, .12);
}
.stat__label { font-size: clamp(11px, 1.6vw, 14px); font-weight: 600; opacity: .9; text-align: center; }
.stat__val { display: flex; align-items: center; gap: 6px; font-size: clamp(20px, 3vw, 28px); font-weight: 700; line-height: 1.1; }
.stat output.bump { animation: bump .4s; }
@keyframes bump { 40% { transform: scale(1.3); color: var(--gold); } }
.star { width: 1.1em; height: 1.1em; transform: rotate(-8deg); filter: drop-shadow(0 2px 0 rgba(120, 50, 0, .45)); }
.bar { width: 100%; height: 10px; margin-top: 2px; border-radius: 99px; background: #1f1a5c; border: 2px solid #7a66dc; overflow: hidden; box-shadow: inset 0 3px 4px rgba(0, 0, 0, .4); }
.bar i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(#ffe97a, #ffb62e); transition: width .5s cubic-bezier(.3, 1.4, .5, 1); }

/* لوحة اللاعبين */
.hud__duo { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: stretch; padding-top: 8px; }
.player {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px;
  border-radius: 20px; border: 3px solid var(--rim);
  background: linear-gradient(var(--c1), var(--c2));
  box-shadow: 0 5px 0 var(--sh), inset 0 3px 0 rgba(255, 255, 255, .45);
  filter: saturate(.45) brightness(.7); transform: scale(.95); transition: transform .3s, filter .3s, box-shadow .3s;
}
.player--1 { --c1: #52b2ff; --c2: #2a7de6; --rim: #a8d6ff; --sh: #174fa8; }
.player--2 { --c1: #ff7a8a; --c2: #e03a58; --rim: #ffc1c9; --sh: #9c1f38; }
.player.active { filter: none; transform: scale(1.04); box-shadow: 0 5px 0 var(--sh), 0 0 26px var(--c1), inset 0 3px 0 rgba(255, 255, 255, .45); }
.player__name { display: block; font-size: clamp(15px, 2.4vw, 22px); font-weight: 700; letter-spacing: .04em; text-shadow: 0 2px 0 var(--sh); }
.player__sub { display: block; font-size: 12px; font-weight: 600; opacity: .9; }
.player output { min-width: 1.7em; padding: 0 .25em; border-radius: 14px; background: rgba(0, 0, 0, .25); text-align: center; font-size: clamp(26px, 5vw, 40px); font-weight: 700; line-height: 1.3; }
.player__turn {
  display: none; position: absolute; top: -13px; left: 50%; transform: translateX(-50%); padding: 1px 12px; border-radius: 99px;
  background: var(--gold); color: #5a3a1a; font-size: 12px; font-weight: 800; box-shadow: 0 2px 0 #c2810f; animation: hop 1s ease-in-out infinite;
}
.player.active .player__turn { display: block; }
@keyframes hop { 50% { translate: 0 -3px; } }

.turn {
  --tc: var(--blue); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-width: clamp(96px, 18vw, 190px); padding: 6px 12px; border-radius: 18px; text-align: center;
  background: #1f1a5c; border: 3px solid var(--tc); box-shadow: 0 0 16px var(--tc); transition: border-color .3s, box-shadow .3s;
  font-size: clamp(13px, 2vw, 17px); font-weight: 700;
}
.turn[data-p="2"] { --tc: var(--red); }
.turn small { font-size: 12px; font-weight: 600; opacity: .8; }
.turn__arrow { width: 22px; height: 22px; color: var(--tc); }   /* السهم يشير إلى لوحة اللاعب صاحب الدور */
.turn[data-p="2"] .turn__arrow { transform: scaleX(-1); }
.turn[data-p="1"] .turn__arrow { animation: nudge-r .8s ease-in-out infinite; }
.turn[data-p="2"] .turn__arrow { animation: nudge-l .8s ease-in-out infinite; }
@keyframes nudge-r { 50% { translate: 4px 0; } }
@keyframes nudge-l { 50% { translate: -4px 0; } }

/* الشبكة */
.game { overflow: hidden; }
.stage {
  --cols: 5; --rows: 4; --tw: clamp(150px, 17vw, 230px); --gap: clamp(10px, 2vw, 28px);
  flex: 1; min-height: 0; container-type: size; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  column-gap: var(--gap); padding: 12px clamp(8px, 2vw, 24px);
}
.board-wrap { width: min(calc(100cqw - 2 * var(--tw) - 2 * var(--gap)), calc(100cqh * var(--cols) / var(--rows))); }
.board {
  --ring: var(--lav);
  width: 100%; aspect-ratio: var(--cols) / var(--rows); display: grid; grid-template-columns: repeat(var(--cols), 1fr); grid-template-rows: repeat(var(--rows), 1fr);
  gap: clamp(6px, 1.8vmin, 14px); padding: clamp(8px, 2vmin, 16px); border-radius: 24px;
  background: rgba(22, 10, 70, .6); border: 4px solid var(--ring); box-shadow: 0 0 28px var(--ring), inset 0 0 20px rgba(0, 0, 0, .3);
  transition: border-color .3s, box-shadow .3s;
}
.board[data-turn="1"] { --ring: var(--blue); }
.board[data-turn="2"] { --ring: var(--red); }
.board.vision { --ring: var(--gold); }

/* ---------- مناطق القدرات (بجانب الشبكة) ---------- */
.tray {
  --tc: var(--lav); --tg: rgba(138, 108, 240, .4);
  width: var(--tw); max-height: 100%; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px;
  border-radius: 22px; border: 3px solid var(--tc); background: rgba(22, 10, 70, .6);
  box-shadow: 0 0 18px var(--tg), inset 0 0 14px rgba(0, 0, 0, .3);
}
.tray--1 { --tc: var(--blue); --tg: rgba(82, 178, 255, .4); justify-self: end; }
.tray--2 { --tc: var(--red); --tg: rgba(255, 106, 128, .4); justify-self: start; }
.stage[data-game="single"] .tray--1 { --tc: var(--lav); --tg: rgba(138, 108, 240, .4); }
.stage[data-game="single"] .tray--2 { visibility: hidden; }
.tray__title { margin: 0; font-size: 15px; font-weight: 800; text-align: center; color: var(--tc); }
.tray__slots { display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; gap: 10px 8px; min-height: 0; overflow-y: auto; padding: 2px; scrollbar-width: thin; }
.tray__slots:empty::before {
  content: "لا توجد قدرات بعد"; display: grid; place-items: center; width: 100%; min-height: 84px; padding: 8px;
  border: 2px dashed rgba(185, 164, 255, .45); border-radius: 14px; font-size: 13px; color: var(--lav-light); opacity: .8; text-align: center;
}

/* بطاقة قدرة داخل المنطقة: الصورة + الاسم + وصف قصير */
.slot { --pc: #fff; width: 88px; display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; }
.slot:not(.show) { visibility: hidden; }
.slot__card {
  position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; border-radius: 16%; border: 3px solid var(--pc);
  box-shadow: 0 0 12px var(--pc), 0 4px 0 rgba(0, 0, 0, .3); transition: transform .2s, filter .3s, box-shadow .3s; cursor: default;
}
.slot__card img { display: block; width: 100%; height: 100%; object-fit: cover; }
.slot__badge { position: absolute; left: 0; right: 0; bottom: 0; padding: 1px 0; background: rgba(20, 8, 60, .85); font-size: 11px; font-weight: 800; }
.slot__name { font-size: 12px; font-weight: 700; line-height: 1.1; color: var(--pc); }
.slot__desc { font-size: 11px; line-height: 1.35; color: var(--lav-light); }
.slot.show .slot__card { animation: land .6s ease; }
.slot.show .slot__name, .slot.show .slot__desc { animation: fade .7s .15s both; }
@keyframes land { 50% { transform: scale(1.07); } }
.slot.mine .slot__card { cursor: pointer; animation: ready 1.8s ease-in-out infinite; }
@keyframes ready { 50% { box-shadow: 0 0 22px var(--pc), 0 0 6px 2px var(--pc), 0 4px 0 rgba(0, 0, 0, .3); } }
@media (hover: hover) { .slot.mine .slot__card:hover { transform: translateY(-3px); } }
.slot[data-state="armed"] .slot__card { box-shadow: 0 0 0 3px #fff, 0 0 26px var(--pc), 0 0 44px var(--pc); animation: ready 1s ease-in-out infinite; }
.slot[data-state="armed"] .slot__badge { background: var(--pc); color: #1a0f4a; }
.slot[data-state="used"] .slot__card { filter: brightness(.55) saturate(.6); box-shadow: none; }
.slot[data-state="used"] .slot__name, .slot[data-state="used"] .slot__desc { opacity: .55; }

/* الجوال والشاشات الضيقة: مناطق القدرات في صف فوق الشبكة (الشبكة 4 × 5 على الجوال العمودي) */
@media (orientation: portrait), (max-width: 760px) {
  .stage { --trh: 132px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: var(--trh) minmax(0, 1fr); align-items: start; gap: 8px; }
  .tray { grid-row: 1; min-width: 0; width: auto; height: var(--trh); justify-self: stretch; padding: 6px 8px; gap: 4px; }
  .tray--1 { grid-column: 1; }
  .tray--2 { grid-column: 2; }
  .stage[data-game="single"] .tray--1 { grid-column: 1 / -1; }
  .stage[data-game="single"] .tray--2 { display: none; }
  .tray__title { font-size: 13px; }
  .tray__slots { flex-wrap: nowrap; justify-content: flex-start; overflow: auto hidden; }
  .tray__slots:empty::before { min-height: 70px; }
  .slot { width: 74px; flex: none; }
  .slot__name { font-size: 10px; }
  .slot__desc { font-size: 10px; line-height: 1.25; }
  .slot__badge { font-size: 10px; }
  .board-wrap { grid-column: 1 / -1; grid-row: 2; align-self: center; justify-self: center; width: min(100cqw, calc((100cqh - var(--trh) - 8px) * var(--cols) / var(--rows))); }
}
@media (orientation: portrait) { .stage { --cols: 4; --rows: 5; } }
/* شاشات الكمبيوتر القصيرة: بطاقات القدرات أصغر لتظهر الأربع بدون تمرير */
@media (min-width: 761px) and (orientation: landscape) and (max-height: 760px) {
  .slot { width: 72px; }
  .slot__desc { font-size: 10px; }
}

/* ---------- البطاقات الخاصة ---------- */
.card--power .card__front { border-color: var(--pc); box-shadow: 0 0 14px var(--pc), 0 4px 0 rgba(0, 0, 0, .3); }
.card__ribbon {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 22% 0 4%; text-align: center; white-space: nowrap;
  font-size: 10cqw; font-weight: 800; letter-spacing: .02em; text-shadow: 0 2px 0 rgba(0, 0, 0, .6);
  background: linear-gradient(transparent, rgba(10, 4, 40, .92) 70%);
}
.card.taken { visibility: hidden; }

/* البطاقة العائمة: ترتفع ثم تنقلب ثم تطير إلى منطقة اللاعب */
.flyer { position: fixed; z-index: 45; pointer-events: none; will-change: transform; transition: transform .45s cubic-bezier(.3, .1, .2, 1); }
.flyer.moving { transition: transform 1s cubic-bezier(.55, .05, .25, 1); }
.flyer .card { width: 100%; height: 100%; }
.flyer .card__inner { transition: transform .8s cubic-bezier(.4, .1, .2, 1); }
.flyer__halo {
  position: absolute; inset: -22%; border-radius: 40%; opacity: 0; pointer-events: none;
  background: radial-gradient(circle, var(--glow) 0%, transparent 68%); transition: opacity .6s;
}
.flyer.glow .flyer__halo { opacity: .85; animation: halo 1.2s ease-in-out infinite; }
.flyer.moving .flyer__halo { opacity: 0; animation: none; }
@keyframes halo { 50% { transform: scale(1.12); opacity: .6; } }
.flyer.glow .card__front { box-shadow: 0 0 26px var(--glow), 0 0 8px 2px var(--glow); }

/* رسالة قصيرة */
.toast {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 60; max-width: 92vw; padding: 9px 22px; border-radius: 99px;
  background: #1f1a5c; border: 2px solid var(--lav); box-shadow: 0 6px 18px rgba(0, 0, 0, .4);
  font-size: 16px; font-weight: 700; text-align: center; opacity: 0; transform: translate(-50%, 10px); pointer-events: none; transition: .3s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* لاعب مجمّد */
.player__frozen {
  display: none; position: absolute; bottom: -13px; left: 50%; transform: translateX(-50%); padding: 1px 12px; border-radius: 99px;
  background: #bff4ff; color: #0a4a80; font-size: 12px; font-weight: 800; box-shadow: 0 2px 0 #3a9fd8;
}
.player.frozen { box-shadow: 0 5px 0 var(--sh), 0 0 24px #8fe8ff, inset 0 0 0 4px rgba(191, 244, 255, .7); }
.player.frozen .player__frozen { display: block; }

/* البطاقة */
.card { position: relative; aspect-ratio: 1; perspective: 800px; container-type: inline-size; display: block; }
.card__inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .5s; }
.card.flipped .card__inner { transform: rotateY(180deg); }
.card__face { position: absolute; inset: 0; border-radius: 16%; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.card__back {
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 35%, #8561f0, #4b2bb0 60%, #2d1a7a);
  border: 3px solid #b9a4ff; box-shadow: 0 4px 0 #170f55, inset 0 3px 0 rgba(255, 255, 255, .28);
}
.card__back::before { content: ""; position: absolute; inset: 9%; border-radius: 14%; border: 2px dashed rgba(255, 210, 63, .5); }
.card__back b { position: relative; font-size: 52cqw; font-weight: 700; line-height: 1; color: var(--gold); text-shadow: 0 3px 0 #a8650a, 0 0 18px rgba(255, 210, 63, .6); }
.card__front { transform: rotateY(180deg); background: #fff; border: 3px solid #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, .3); }
.card__front img { display: block; width: 100%; height: 100%; object-fit: cover; }
button.card { cursor: pointer; transition: transform .15s; }
@media (hover: hover) { button.card:not(.flipped):hover { transform: translateY(-4px); } }
button.card:not(.flipped):hover .card__back { border-color: #fff; }

/* البطاقات المتطابقة: إطار بلون من اكتشفها */
.card.matched { cursor: default; animation: match-pop .5s; }
@keyframes match-pop { 40% { scale: 1.1; } }
.card.matched .card__front { border-color: var(--gold); box-shadow: 0 0 14px var(--gold); }
.card[data-owner="1"] .card__front { border-color: var(--blue); box-shadow: 0 0 14px var(--blue); }
.card[data-owner="2"] .card__front { border-color: var(--red); box-shadow: 0 0 14px var(--red); }

/* شاشات الجوال الأفقية القصيرة: HUD في صف واحد */
@media (orientation: landscape) and (max-height: 520px) {
  .hud { grid-template-columns: 1fr auto; align-items: center; padding: 6px 12px 8px; gap: 10px; }
  .hud__top { order: 2; }
  .hud__title { display: none; }
  .stat { min-height: 46px; padding: 2px 8px; }
  .hud__duo { padding-top: 10px; }
  .stage { padding: 6px 8px; }
}
/* الجوال العمودي: لوحة اللاعبين مرصوصة */
@media (max-width: 560px) {
  .hud__duo { gap: 6px; }
  .player { flex-direction: column; gap: 0; padding: 6px 4px; text-align: center; }
  .player__sub { display: none; }
  .player output { line-height: 1.15; }
  .turn { min-width: 84px; padding: 4px 6px; }
  .stat { padding: 6px 4px; }
}

/* =====================================================
   شاشة النهاية
   ===================================================== */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(18, 8, 55, .75); backdrop-filter: blur(4px); animation: fade .3s; }
@keyframes fade { from { opacity: 0; } }
.panel {
  width: min(100%, 440px); max-height: 94dvh; overflow-y: auto; padding: 26px 22px 24px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  border-radius: 30px; border: 5px solid var(--lav);
  background: linear-gradient(var(--purple-2), #2d1a7a);
  box-shadow: 0 10px 0 #1a0f55, 0 0 40px rgba(138, 108, 240, .5), inset 0 3px 0 rgba(255, 255, 255, .18);
  animation: pop .5s cubic-bezier(.3, 1.5, .5, 1);
}
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.panel__icon { width: 92px; height: 92px; filter: drop-shadow(0 5px 0 rgba(0, 0, 0, .3)) drop-shadow(0 0 16px rgba(255, 210, 63, .6)); animation: float 3s ease-in-out infinite; }
.panel h2 { margin: 0; font-size: clamp(28px, 6vw, 38px); font-weight: 800; color: var(--gold); text-shadow: 0 3px 0 rgba(0, 0, 0, .35); }
.panel h2.is-p1 { color: var(--blue); }
.panel h2.is-p2 { color: var(--red); }
.panel p { margin: 0; font-size: 18px; line-height: 1.6; color: var(--lav-light); }
.r-stats { display: flex; gap: 10px; width: 100%; margin: 6px 0; }
.r-stat { flex: 1; padding: 10px 6px; border-radius: 18px; background: linear-gradient(#32298a, #231c66); border: 2px solid #7d6be0; box-shadow: 0 4px 0 #181347; }
.r-stat span { display: block; font-size: 14px; font-weight: 600; opacity: .9; }
.r-stat b { display: block; font-size: 32px; line-height: 1.2; }
.r-stat.is-p1 { border-color: var(--blue); }
.r-stat.is-p2 { border-color: var(--red); }
.r-stat.is-p1 b { color: var(--blue); }
.r-stat.is-p2 b { color: var(--red); }
.panel__btns { display: grid; gap: 14px; width: 100%; margin-top: 6px; justify-items: center; }
.panel__btns .pill__face { font-size: 17px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01s !important; }
}
