@font-face { font-family: 'Baloo Bhaijaan 2'; font-weight: 600; font-display: swap; src: url(/fonts/baloo-bhaijaan-2-arabic-600-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Baloo Bhaijaan 2'; font-weight: 800; font-display: swap; src: url(/fonts/baloo-bhaijaan-2-arabic-800-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Baloo Bhaijaan 2'; font-weight: 600; font-display: swap; src: url(/fonts/baloo-bhaijaan-2-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: 'Baloo Bhaijaan 2'; font-weight: 800; font-display: swap; src: url(/fonts/baloo-bhaijaan-2-latin-800-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }

:root {
  --ink: #22264b; --paper: #fff; --sky: #9ad8ff; --line: #d5d9e6; --panel: #eef1f8;
  --orange: #ff9f43; --orange-press: #e07f1f; --green: #2ecc71; --green-press: #1fa558;
  --blue: #3aa0ff; --blue-press: #1f7fd9; --yellow: #ffc93c; --yellow-press: #e0a81c;
  --radius-card: 26px; --radius-panel: 34px; --space-4: 14px; --tap: 58px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { overflow-x: clip; }
body {
  background: var(--sky); color: var(--ink);
  font-family: 'Baloo Bhaijaan 2', system-ui, sans-serif; font-weight: 600;
  padding: max(var(--space-4), env(safe-area-inset-top)) max(var(--space-4), env(safe-area-inset-right)) max(var(--space-4), env(safe-area-inset-bottom)) max(var(--space-4), env(safe-area-inset-left));
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
main { max-width: 960px; margin: 0 auto; }

.title { color: var(--paper); font-weight: 800; font-size: clamp(46px, 12vw, 96px); line-height: .95; text-align: center; margin: 24px 0 26px; text-shadow: 0 6px 0 var(--ink); }
.subtitle { color: var(--paper); font-weight: 800; font-size: clamp(30px, 7vw, 40px); line-height: 1.1; margin: 0; text-shadow: 0 4px 0 var(--ink); }

.panel { background: var(--paper); border-radius: var(--radius-panel); box-shadow: 0 10px 0 var(--line); padding: 26px; max-width: 460px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.panel label { font-size: 21px; font-weight: 800; }
.panel input { font: inherit; font-size: 22px; font-weight: 800; color: var(--ink); background: var(--panel); border: 3px solid transparent; border-radius: 18px; padding: 12px 16px; min-height: var(--tap); width: 100%; }
.panel input:focus { outline: none; border-color: var(--blue); }
.panel input.code { letter-spacing: 10px; text-align: center; direction: ltr; }
.hint { font-size: 16px; margin: 0; }
.error { font-size: 18px; font-weight: 800; color: #c0392b; margin: 0; min-height: 1em; }

button, .btn { font: inherit; border: 0; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: var(--tap); transition: transform .08s ease, box-shadow .08s ease; }
.pill { border-radius: 999px; padding: 10px 26px; font-size: 22px; font-weight: 800; color: var(--paper); }
.pill.orange { background: var(--orange); box-shadow: 0 6px 0 var(--orange-press); }
.pill.green { background: var(--green); box-shadow: 0 6px 0 var(--green-press); }
.pill.blue { background: var(--blue); box-shadow: 0 6px 0 var(--blue-press); }
.pill.ghost { background: var(--paper); color: var(--ink); box-shadow: 0 6px 0 var(--line); }
.pill.panel-btn { background: var(--panel); color: var(--ink); box-shadow: 0 6px 0 var(--line); font-size: 18px; }
.pill:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--line); }
.pill.orange:active { box-shadow: 0 2px 0 var(--orange-press); }
.pill.green:active { box-shadow: 0 2px 0 var(--green-press); }
button:disabled { opacity: .6; cursor: default; }
.round { width: var(--tap); height: var(--tap); border-radius: 50%; background: var(--paper); box-shadow: 0 5px 0 var(--line); color: var(--ink); }
.round svg { width: 30px; height: 30px; }
.round.spin svg { animation: spin .8s linear infinite; }
/* دائرة التحميل الفعلي حول زر التحديث: تمتلي بالأخضر حسب الملفات اللي نزلت */
#refresh-all { position: relative; }
.ring { position: absolute; inset: -6px; border-radius: 50%; pointer-events: none; background: conic-gradient(var(--green) calc(var(--p, 0) * 1%), rgba(255, 255, 255, .55) 0); -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px)); mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px)); transition: --p .3s; }
.ring[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.round:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 26px; position: sticky; top: 0; z-index: 20; background: var(--sky); margin-top: calc(-1 * max(var(--space-4), env(safe-area-inset-top))); padding: max(var(--space-4), env(safe-area-inset-top)) 0 12px; }
/* خلفية الشريط على عرض الشاشة كامل (بدون ظل/قص: في سفاري الظل كان يغطي الألعاب تحت) */
.bar::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 100vw; transform: translateX(-50%); background: var(--sky); z-index: -1; pointer-events: none; }
.bar:has(.back) { justify-content: flex-start; }
.bar .actions { display: flex; gap: 12px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 14px; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 26px 18px; } }
.game { background: var(--paper); border-radius: var(--radius-card); box-shadow: 0 7px 0 var(--line); padding: 8px 8px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; transition: transform .08s ease, box-shadow .08s ease; }
.game:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--line); }
.game .art { width: 100%; aspect-ratio: 4 / 3; border-radius: 18px; display: grid; place-items: center; overflow: hidden; }
.game .art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.game .art svg { width: 44%; height: 44%; color: var(--paper); }
.game .name { font-size: clamp(17px, 4.6vw, 21px); font-weight: 800; line-height: 1.3; text-align: center; }
.game .meta { font-size: 16px; display: flex; gap: 8px; align-items: center; }
.game .tag { background: var(--panel); border-radius: 999px; padding: 0 10px; }
.game.locked { opacity: .55; pointer-events: none; }
.game .art { position: relative; }
/* نسخة جديدة من اللعبة تنزل */
.game.updating .art img { opacity: .5; }
.game.updating .art::after, .game.updated .art::after { content: attr(data-upd); position: absolute; inset: auto 8px 8px; padding: 2px 10px; border-radius: 999px; background: var(--paper); color: var(--ink); font-size: 15px; font-weight: 800; text-align: center; }
.game.updating .art::after { animation: upd 1s ease-in-out infinite alternate; }
.game.updated .art::after { background: var(--green); color: var(--paper); }
@keyframes upd { from { opacity: .7; } to { opacity: 1; } }
.game.nudge { animation: nudge .4s ease; }
@keyframes nudge { 25% { translate: -6px 0; } 75% { translate: 6px 0; } }
.game.opening { animation: game-press .45s ease-out forwards; pointer-events: none; }
@keyframes game-press { 0% { transform: translateY(5px) scale(.96); box-shadow: 0 2px 0 var(--line); } 55% { transform: translateY(-4px) scale(1.04); box-shadow: 0 11px 0 var(--line); } 100% { transform: none; box-shadow: 0 7px 0 var(--line); } }
.opening-overlay { position: absolute; inset: 0; border-radius: inherit; background: rgba(34, 38, 75, .55); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--paper); font-size: clamp(16px, 4.4vw, 20px); font-weight: 800; animation: fade-in .2s ease-out; }
.opening-overlay.failed { background: rgba(34, 38, 75, .82); padding: 8px; text-align: center; }
.opening-overlay.failed .retry { font-size: .8em; font-weight: 600; background: var(--orange); border-radius: 999px; padding: 2px 12px; }
.opening-overlay .spinner { width: 40px; height: 40px; border-radius: 50%; border: 5px solid rgba(255, 255, 255, .35); border-top-color: var(--paper); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } }
.stars { display: inline-flex; gap: 4px; direction: ltr; }
.stars svg { width: 20px; height: 20px; fill: var(--line); }
.stars svg.on { fill: var(--yellow); }

.empty { text-align: center; }
.empty p { font-size: 21px; font-weight: 800; margin: 0; }

.offline { background: var(--ink); color: var(--paper); border-radius: 999px; padding: 4px 16px; font-size: 16px; text-align: center; margin: 0 auto 18px; width: fit-content; }

.report-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 0; border-bottom: 3px solid var(--panel); }
.report-row:last-child { border-bottom: 0; }
.report-row .name { font-size: 21px; font-weight: 800; }
.report-row .detail { font-size: 16px; grid-column: 1 / -1; }
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; text-align: center; }
.totals div { background: var(--panel); border-radius: 18px; padding: 10px 4px; }
.totals b { display: block; font-size: 32px; line-height: 1.1; }
.totals span { font-size: 16px; }

.devices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.device { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; background: var(--panel); border-radius: 22px; padding: 16px 10px 12px; position: relative; }
.device.me { box-shadow: inset 0 0 0 3px var(--green); }
.device .ic { width: 58px; height: 58px; border-radius: 50%; background: var(--paper); display: flex; align-items: center; justify-content: center; color: var(--ink); }
.device .ic svg { width: 32px; height: 32px; }
.device .who { font-size: 16px; font-weight: 800; line-height: 1.3; }
.device .tag { font-size: 13px; font-weight: 800; color: #fff; background: var(--green); border-radius: 999px; padding: 0 10px; }
.device .when { font-size: 13px; line-height: 1.4; }
.device .pill { min-height: 44px; font-size: 16px; padding: 4px 16px; margin-top: 4px; width: 100%; }
.wide { max-width: 640px; }
a.pill { display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); text-decoration: none; }
.device .pill.panel-btn { background: var(--paper); }

/* منع الزوم (قرص أو لمستين) */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
