/* «أنقذ ماهر» pixel game screen (opens inside the dark room) */
.px-game { position: fixed; inset: 0; z-index: 140; display: flex; align-items: center; justify-content: center; padding: 12px; background: radial-gradient(ellipse at center, #140606 0%, #050202 75%); animation: fadeIn .5s; }
.px-game[hidden] { display: none; }
.px-shell { width: min(760px, 100%); display: flex; flex-direction: column; gap: 10px; }
.px-top { display: flex; align-items: center; justify-content: space-between; }
.px-title { font-family: "Reem Kufi", var(--head, sans-serif); color: #ff4d4d; font-size: 1.25rem; letter-spacing: .5px; text-shadow: 0 0 12px rgba(255, 0, 0, .45); }
.px-x { width: 40px; height: 40px; border-radius: 10px; background: #1a0f0a; color: #efe3d3; border: 2px solid #5a3824; font-size: 1.1rem; cursor: pointer; }
.px-x:hover { border-color: #d4a87a; }
.px-screen { position: relative; aspect-ratio: 4 / 3; width: 100%; background: #000; border: 4px solid #3a2418; border-radius: 6px; box-shadow: 0 0 0 2px #000, 0 0 60px rgba(255, 0, 0, .18); overflow: hidden; }
.px-screen canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }
.px-screen::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .18) 0 1px, transparent 1px 3px); }

.px-dialog { position: absolute; left: 2%; right: 2%; bottom: 3%; z-index: 2; min-height: 26%; padding: 10px 14px 12px; background: rgba(12, 6, 4, .94); border: 3px solid #d4a87a; border-radius: 4px; box-shadow: 0 4px 0 #000; color: #efe3d3; cursor: pointer; font-family: "IBM Plex Sans Arabic", sans-serif; }
.px-dialog[hidden] { display: none; }
.px-dialog.narr { border-color: #7a5a3a; }
.px-who { display: inline-block; margin-bottom: 4px; padding: 1px 10px; background: #d4a87a; color: #1a0f0a; font-weight: 800; font-size: clamp(.8rem, 2.2vw, .95rem); border-radius: 2px; }
.px-who[hidden] { display: none; }
.px-text { margin: 0; font-size: clamp(.9rem, 2.6vw, 1.12rem); line-height: 1.7; font-weight: 600; min-height: 1.7em; }
.px-next { position: absolute; left: 12px; bottom: 6px; color: #d4a87a; font-size: .7rem; animation: pxBob .8s infinite; }
.px-dialog.choosing .px-next { display: none; }
.px-choices { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.px-choices:empty { display: none; }
.px-choices button, .px-btns button, .px-dg button { font-family: inherit; font-weight: 800; font-size: clamp(.85rem, 2.4vw, 1rem); padding: 7px 14px; background: #2a1a12; color: #efe3d3; border: 3px solid #5a3824; border-radius: 3px; box-shadow: 0 3px 0 #000; cursor: pointer; text-align: start; }
.px-choices button.on, .px-choices button:hover { border-color: #d4a87a; background: #3a2418; }
.px-choices button.on::before { content: "◀ "; color: #d4a87a; }

.px-panel { position: absolute; inset: 0; z-index: 3; display: flex; align-items: flex-end; justify-content: center; padding: 3%; background: linear-gradient(to bottom, transparent 20%, rgba(0, 0, 0, .78) 60%); font-family: "IBM Plex Sans Arabic", sans-serif; }
.px-panel[hidden] { display: none; }
.px-card { width: min(520px, 100%); padding: 14px 16px; text-align: center; background: rgba(12, 6, 4, .92); border: 3px solid #d4a87a; border-radius: 4px; box-shadow: 0 4px 0 #000; color: #efe3d3; }
.px-card h2 { margin: 0 0 4px; font-family: "Reem Kufi", sans-serif; font-size: clamp(1.4rem, 5vw, 2.1rem); color: #ff4d4d; text-shadow: 0 2px 0 #000; }
.px-card h3 { margin: 0 0 8px; font-size: 1.05rem; color: #d4a87a; }
.px-card p { margin: 0 0 10px; font-size: clamp(.85rem, 2.4vw, 1rem); color: #d9c3a8; }
.px-card small { color: #b49a80; font-weight: 700; }
.px-end.end-A h2 { color: #ffe08a; }
.px-end.end-C h2 { color: #c9a0ff; }
.px-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.px-btns button { text-align: center; border-color: #d4a87a; }
.px-btns button.ghost { border-color: #5a3824; color: #c9b298; }
.px-btns button:hover { background: #3a2418; }
.px-tally { margin-top: 10px; font-size: .85rem; color: #b49a80; display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap; }
.px-tally span { display: inline-grid; place-items: center; width: 26px; height: 26px; border: 2px solid #3a2418; border-radius: 3px; color: #5a3824; font-weight: 800; }
.px-tally span.got { border-color: #d4a87a; color: #ffe08a; background: #2a1a12; }

.px-kp { width: min(330px, 100%); align-self: center; }
.px-kp.bad { animation: tremble .12s 3; border-color: #ff3b3b; }
.px-digits { display: flex; gap: 10px; justify-content: center; direction: ltr; margin-bottom: 12px; }
.px-dg { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.px-dg b { display: grid; place-items: center; width: 48px; height: 52px; font-size: 1.8rem; font-family: monospace; color: #ffe08a; background: #000; border: 3px solid #5a3824; }
.px-dg.on b { border-color: #d4a87a; box-shadow: 0 0 10px rgba(212, 168, 122, .5); }
.px-dg button { padding: 2px 12px; text-align: center; }

.px-pad { display: none; align-items: center; justify-content: space-between; direction: ltr; padding: 0 6px; user-select: none; -webkit-user-select: none; touch-action: none; }
.px-dpad { position: relative; width: 150px; height: 150px; }
.px-dpad button, .px-a { position: absolute; width: 50px; height: 50px; border-radius: 8px; background: #2a1a12; color: #d4a87a; border: 3px solid #5a3824; box-shadow: 0 4px 0 #000; font-size: 1.1rem; touch-action: none; }
.px-dpad button:active, .px-a:active { transform: translateY(3px); box-shadow: 0 1px 0 #000; }
.px-dpad .u { left: 50px; top: 0; } .px-dpad .d { left: 50px; bottom: 0; } .px-dpad .l { left: 0; top: 50px; } .px-dpad .r { right: 0; top: 50px; }
.px-a { position: static; width: 78px; height: 78px; border-radius: 50%; font-size: 1.5rem; font-weight: 900; border-color: #d4a87a; }
.px-help { text-align: center; color: #8a7a6a; font-size: .8rem; }
@media (pointer: coarse) { .px-pad { display: flex; } .px-help { display: none; } }
@media (max-width: 600px) { .px-game { padding: 6px; align-items: flex-start; padding-top: 14px; } .px-dialog { min-height: 34%; padding: 8px 10px; } }
@keyframes pxBob { 50% { transform: translateY(3px); } }
