/* تركيب الصور */
[hidden] { display: none !important; }
.pz { max-width: 640px; margin-inline: auto; padding: 4px 12px 28px; }
.pz h1 { margin: 6px 0 12px; font-size: 27px; font-weight: 800; text-align: center; }
.pz-levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pz-level { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; aspect-ratio: 1 / 1.2; padding: 8px; border: 0; border-radius: 20px; background: #fff; color: #0f1320; box-shadow: var(--tile-shadow); font: inherit; cursor: pointer; }
.pz-level i { display: grid; width: 58%; aspect-ratio: 1; gap: 2px; margin-bottom: 5px; font-style: normal; }
.pz-level i span { border-radius: 3px; background: #d7dcff; }
.pz-level b { font-size: 17px; font-weight: 800; }
.pz-level small { color: #6c7384; font-size: 12.5px; }
@media (hover: hover) {
  .pz-level:hover { background: linear-gradient(135deg, #2746f2, #1a2fb5); color: #fff; }
  .pz-level:hover small { color: #c9d2ff; }
  .pz-level:hover i span { background: rgba(255, 255, 255, .45); }
}
.pz-level:active { background: linear-gradient(135deg, #2746f2, #1a2fb5); color: #fff; }
.pz-level:focus-visible { outline: 2px solid #2746f2; outline-offset: 2px; }
.pz-rules { display: grid; gap: 7px; margin: 12px 0 0; padding: 14px 16px; border-radius: 18px; background: #fff; box-shadow: var(--tile-shadow); font-size: 14px; line-height: 1.6; list-style: none; }
.pz-rules li { position: relative; padding-inline-start: 16px; }
.pz-rules li::before { content: ''; position: absolute; inset-inline-start: 0; top: .55em; width: 7px; height: 7px; border-radius: 50%; background: #2746f2; }
.pz-top { margin-top: 16px; }
.pz-top h2 { margin-bottom: 8px; font-size: 18px; font-weight: 800; }
.pz-empty { margin: 0; padding: 14px; border-radius: 16px; background: #fff; color: #6c7384; font-size: 14px; text-align: center; }
#topList { margin: 0; padding: 0; list-style: none; }
#topList:empty { display: none; }
#topList .rank-row:first-child { border-top: 0; }
.pz-counters { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 8px; text-align: center; }
.pz-counters b { display: block; font-size: 27px; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.pz-counters small { color: #6c7384; font-size: 12px; }
.pz-board { position: relative; width: 100%; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 18px; background: #d8dbe2; box-shadow: var(--tile-shadow); direction: ltr; touch-action: manipulation; }
.pz-piece { position: absolute; padding: 0; border: 0; background-repeat: no-repeat; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .55); cursor: pointer; transition: left .2s ease, top .2s ease; }
/* الصورة كاملة بدون خطوط بعد ما تتركب */
.pz-board.solved { background-size: 100% 100%; background-repeat: no-repeat; }
.pz-board.solved .pz-piece { box-shadow: none; opacity: 0; transition: opacity .5s ease .25s; pointer-events: none; }
.pz-piece.pick { z-index: 3; box-shadow: inset 0 0 0 4px #2746f2, 0 8px 22px rgba(15, 19, 32, .45); }
.pz-note { min-height: 22px; margin: 6px 0; font-size: 14px; font-weight: 700; text-align: center; }
.pz-ref { display: block; width: 100%; aspect-ratio: 4 / 3; margin-bottom: 8px; border-radius: 18px; box-shadow: var(--tile-shadow); object-fit: cover; }
.pz-row { display: flex; gap: 6px; }
.pz-row .btn { flex: 1; min-width: 0; min-height: 48px; padding: 6px 4px; font-size: 13.5px; line-height: 1.3; }
.pz-win { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(15, 19, 32, .45); backdrop-filter: blur(4px); }
.pz-win > div { width: min(100%, 380px); padding: 22px; border-radius: 24px; background: #fff; box-shadow: var(--float-shadow); text-align: center; }
.pz-win h2 { font-size: 25px; font-weight: 800; }
.pz-win strong { display: block; margin: 6px 0 2px; color: #2746f2; font-size: 44px; font-weight: 800; line-height: 1.2; }
.pz-win p { color: #6c7384; font-size: 14px; }
.pz-win .pz-row { margin-top: 16px; }
.pz-card { display: grid; place-items: center; width: 100%; height: 100%; background: linear-gradient(135deg, #2746f2, #1a2fb5); color: #fff; font-size: 34px; font-weight: 800; }
.pz-ref-card { height: auto; aspect-ratio: 4 / 3; margin-bottom: 8px; border-radius: 18px; box-shadow: var(--tile-shadow); }
.pz-begin { width: 100%; min-height: 52px; font-size: 17px; font-weight: 800; }
.pz-code { display: flex; gap: 7px; margin-top: 12px; }
.pz-code input { flex: 1; min-width: 0; height: 50px; padding-inline: 14px; border: 1px solid #dfe2e8; border-radius: 14px; background: #fff; color: #0f1320; font: inherit; font-size: 15px; }
.pz-code .btn { flex: none; min-height: 50px; width: 84px; padding: 0; }
.pz-results { margin-top: 12px; padding: 14px; border-radius: 18px; background: #fff; box-shadow: var(--tile-shadow); }
.pz-results h2 { margin-bottom: 6px; font-size: 18px; font-weight: 800; }
.pz-results ol { margin: 0; padding: 0; list-style: none; }
.pz-result { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-top: 1px solid #eef0f4; font-size: 14.5px; }
.pz-result:first-child { border-top: 0; }
.pz-result > b { width: 24px; color: #2746f2; font-weight: 800; }
.pz-result span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pz-result small { color: #6c7384; }
.pz-result strong { font-weight: 800; }
.pz-result.me { border-radius: 10px; background: rgba(39, 70, 242, .1); }
.pz-host-card { display: grid; gap: 10px; margin-bottom: 12px; padding: 16px; border-radius: 20px; background: #fff; box-shadow: var(--tile-shadow); }
.pz-host-card h2 { font-size: 17px; font-weight: 800; }
.pz-host-card h2 small { color: #6c7384; font-size: 13px; }
.pz-host-card input { height: 50px; padding-inline: 14px; border: 1px solid #dfe2e8; border-radius: 14px; background: #f7f8fa; font: inherit; }
.pz-host-error { min-height: 1.2em; color: #d92d20; font-size: 13px; }
.pz-host-line { display: flex; justify-content: space-between; gap: 10px; font-size: 14.5px; }
.pz-host-line span { color: #6c7384; }
.pz-host-levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.pz-host-levels .btn { min-height: 46px; padding: 4px; font-size: 13.5px; }
.pz-host-levels .btn:disabled { opacity: .55; cursor: default; }
.pz-host-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.pz-host-list li { display: flex; align-items: center; gap: 9px; padding: 8px 2px; border-top: 1px solid #eef0f4; font-size: 14.5px; }
.pz-host-list li:first-child { border-top: 0; }
.pz-host-list span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pz-host-list small { color: #6c7384; }
.pz-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #c8ccd4; }
.pz-dot.on { background: #12a150; }
.pz-kick { padding: 4px 9px; border: 1px solid #dfe2e8; border-radius: 10px; background: #fff; color: #0f1320; font: inherit; font-size: 12px; cursor: pointer; }
.pz-host-end { width: 100%; }
.pz-ended { padding-top: 40px; text-align: center; }
.pz-ended p { margin: 8px 0 18px; color: #6c7384; }
@media (prefers-reduced-motion: reduce) { .pz-piece { transition: none; } }
/* زر تحدّى صديقك ومستطيل كود الغرفة تحت المستويات */
.pz-friends-tile { display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 10px; padding: 14px 16px; border: 0; border-radius: 20px; background: #fff; color: #0f1320; box-shadow: 0 1px 2px rgba(15, 19, 32, .05), 0 14px 30px -22px rgba(15, 19, 32, .35); font: inherit; text-align: start; cursor: pointer; }
.pz-friends-tile i { font-size: 30px; font-style: normal; }
.pz-friends-tile span { display: grid; gap: 2px; }
.pz-friends-tile b { font-size: 16px; font-weight: 800; }
.pz-friends-tile small { color: #6c7384; font-size: 12px; }
.pz-friends-tile:active { background: #2746f2; color: #fff; }
.pz-code-strip { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; margin-top: 10px; padding: 10px 12px; border-radius: 20px; background: #fff; color: #0f1320; box-shadow: 0 1px 2px rgba(15, 19, 32, .05), 0 14px 30px -22px rgba(15, 19, 32, .35); }
.pz-code-strip label { display: flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 800; white-space: nowrap; }
.pz-code-strip label i { font-style: normal; }
.pz-code-strip input { min-width: 0; height: 42px; padding: 0 10px; border: 1px solid #dfe2e8; border-radius: 12px; background: #f7f8fa; color: #0f1320; font: inherit; font-size: 16px; letter-spacing: 2px; text-align: center; }
.pz-code-strip input::placeholder { letter-spacing: 0; font-size: 12.5px; }
.pz-code-strip .btn { margin: 0; min-height: 42px; padding: 0 14px; }
@media (max-width: 380px) { .pz-code-strip { grid-template-columns: minmax(0, 1fr) auto; } .pz-code-strip label { grid-column: 1 / -1; } }

/* غرفة التحدي */
.pz-lobby { display: grid; gap: 10px; max-width: 560px; margin-inline: auto; text-align: start; }
.pz-lobby h1 { text-align: center; }
.pz-lobby h2 { margin: 4px 0 0; font-size: 16px; }
.pz-lobby-text, .friends-wait { margin: 0; text-align: center; }
.friends-code { margin: 0; text-align: center; font-size: 16px; }
.friends-code b { font-size: 26px; letter-spacing: 3px; font-variant-numeric: tabular-nums; }
.pz-sizes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.pz-sizes button { min-height: 40px; border: 0; border-radius: 12px; background: #fff; color: #0f1320; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.pz-sizes button.on { background: #2746f2; color: #fff; }
.pz-sizes button:disabled:not(.on) { opacity: .55; cursor: default; }
.friends-share { display: grid; gap: 8px; }
.friends-share .btn { width: 100%; margin: 0; text-align: center; }
.friends-online { display: grid; gap: 6px; padding: 10px; border-radius: 16px; background: #fff; color: #0f1320; }
.friends-online button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: 12px; background: #eef1ff; color: #0f1320; font: inherit; font-weight: 700; cursor: pointer; text-align: start; }
.friends-online button span:last-child { margin-inline-start: auto; color: #2746f2; font-size: 13px; }
.friends-online button[disabled] { opacity: .7; cursor: default; }
.friends-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.friends-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: #fff; color: #0f1320; font-weight: 700; }
.friends-list li.off { opacity: .5; }
.friends-list small { margin-inline-start: auto; color: #6c7384; font-weight: 400; }
.friends-list small.ok { color: #17a34a; font-weight: 700; }
.friends-list small.wait { color: #b26b00; }
.friends-bar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 0 0 8px; padding: 0; list-style: none; }
.friends-bar li { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 5px 8px; border-radius: 14px; background: #fff; box-shadow: 0 1px 2px rgba(15, 19, 32, .08); font-size: 13px; font-weight: 700; }
.friends-bar .who { display: grid; min-width: 0; line-height: 1.25; }
.friends-bar .who bdi { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friends-bar .who small { font-size: 12px; font-weight: 400; }
.friends-bar .who, .friends-bar .who * { color: #0f1320 !important; }
.friends-bar li.me { background: #2746f2; }
.friends-bar li.done { background: #17a34a; }
.friends-bar li.me .who, .friends-bar li.me .who *, .friends-bar li.done .who, .friends-bar li.done .who * { color: #fff !important; }
.friends-bar li.off { opacity: .45; }
.friends-bar .rank-avatar, .friends-list .rank-avatar, .friends-online .rank-avatar { width: 26px; height: 26px; font-size: 13px; }
#friendsStart:disabled, #friendsNext:disabled { background: #c9ced8 !important; color: #fff !important; box-shadow: none !important; opacity: 1; cursor: default; }
.friends-ready.on { background: #17a34a !important; color: #fff !important; }
.pz-ended p { white-space: pre-line; }

/* نتيجة جولة التحدي */
.friends-bar .result-tag { margin-inline-start: auto; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.friends-bar .result-tag.win { background: #fff4d6; color: #8a5a00; }
.friends-bar .result-tag.lose { background: #fde8e6; color: #d92d20; }
.pz-board { position: relative; }
.pz-winner { position: absolute; z-index: 5; left: 50%; bottom: 12px; transform: translateX(-50%); padding: 10px 18px; border-radius: 99px; background: rgba(255, 255, 255, .95); color: #0f1320; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5); font-size: 18px; font-weight: 800; white-space: nowrap; pointer-events: none; }

/* «تحدّى المتصلين» أول زر، وجنبه العدد بالأخضر */
.friends-pick .online-count { display: inline-flex; align-items: center; gap: 4px; margin-inline-start: 6px; padding: 2px 10px; border-radius: 99px; background: #dcfce7; color: #15803d; font-size: 13px; font-weight: 800; }
.friends-pick .online-count:empty { display: none; }
.friends-bar li.lost .rank-avatar { filter: grayscale(1); opacity: .65; }

/* القلوب في اللعب الفردي (2026-11-11) */
.pz-hearts { margin: 0 0 6px; text-align: center; font-size: 20px; letter-spacing: 4px; }
.pz-hearts[hidden] { display: none; }
.pz-clock-low { color: #ef4444; }
.pz-win p { white-space: pre-line; }

/* 🧲 الالتصاق (استشارة 16): القطعة بمكانها الصح تنقفل وتلمع */
.pz-piece.locked { cursor: default; box-shadow: inset 0 0 0 2px rgba(255, 215, 90, .9), inset 0 0 14px rgba(255, 215, 90, .35); }
.pz-piece.locked::after { content: '🔒'; position: absolute; top: 3px; inset-inline-end: 4px; font-size: 11px; opacity: .8; filter: drop-shadow(0 0 2px #000); pointer-events: none; }
.pz-piece.snap { animation: pzSnap .55s ease-out; z-index: 2; }
@keyframes pzSnap { 0% { filter: brightness(1.9); transform: scale(1.08); } 100% { filter: none; transform: none; } }
.pz-count { margin: 6px 0 0; text-align: center; font-size: 14px; font-weight: 800; color: #ffd75a; text-shadow: 0 0 8px rgba(255, 215, 90, .5); }

/* 🎉 حفلة الإنجاز: بوالين وورق ملون واسم اللاعب بالذهبي */
.pz-party { position: fixed; inset: 0; z-index: 80; overflow: hidden; display: grid; place-items: center; background: radial-gradient(circle at 50% 45%, rgba(60, 20, 110, .55), rgba(8, 4, 20, .82)); animation: pzFadeIn .3s ease-out; cursor: pointer; }
.pz-party.out { opacity: 0; transition: opacity .7s ease; }
.pz-party-card { position: relative; z-index: 2; text-align: center; padding: 18px 26px; animation: pzPop .6s cubic-bezier(.2, 1.6, .4, 1); }
.pz-party-cake { font-size: 46px; line-height: 1.1; }
.pz-gold-name {
  display: block; margin: 8px 0 4px; font-size: clamp(34px, 11vw, 64px); font-weight: 800; line-height: 1.15;
  background: linear-gradient(180deg, #fff6c2 0%, #ffd75a 35%, #e0a21a 60%, #fff0a6 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #7a4b00) drop-shadow(0 0 18px rgba(255, 200, 60, .75));
  animation: pzShine 1.4s ease-in-out infinite alternate;
}
.pz-party-card p { margin: 6px 0 0; color: #fff; font-size: 20px; font-weight: 800; text-shadow: 0 2px 8px #000; }
.pz-balloon { position: absolute; bottom: -120px; width: 46px; height: 58px; border-radius: 50% 50% 46% 46%; background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .75), transparent 22%), var(--c); box-shadow: inset -6px -8px 0 rgba(0, 0, 0, .15); animation: pzRise linear forwards; }
.pz-balloon::after { content: ''; position: absolute; left: 50%; top: 100%; width: 1px; height: 60px; background: rgba(255, 255, 255, .6); }
.pz-confetti { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; animation: pzFall linear forwards; }
@keyframes pzRise { to { transform: translateY(calc(-100vh - 200px)) translateX(20px) rotate(8deg); } }
@keyframes pzFall { to { transform: translateY(110vh) rotate(calc(var(--spin) * 720deg)); } }
@keyframes pzPop { from { transform: scale(.3); opacity: 0; } }
@keyframes pzFadeIn { from { opacity: 0; } }
@keyframes pzShine { to { filter: drop-shadow(0 2px 0 #7a4b00) drop-shadow(0 0 30px rgba(255, 220, 90, 1)); } }

@media (prefers-reduced-motion: reduce) { .pz-balloon, .pz-confetti { display: none; } .pz-piece.snap, .pz-gold-name, .pz-party-card { animation: none; } }

/* 🏆 كلمة WINNER بالإنجليزي فوق اسم الفايز */
.pz-winner-word {
  display: block; margin-top: 4px; font-family: 'Arial Black', 'Segoe UI', sans-serif; font-size: clamp(30px, 10vw, 54px); font-weight: 900; letter-spacing: 6px; line-height: 1.1;
  background: linear-gradient(180deg, #fff6c2 0%, #ffd75a 40%, #d4930f 70%, #fff0a6 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #7a4b00) drop-shadow(0 0 16px rgba(255, 200, 60, .8));
}
