/* =============================================================================
   mines.css — «ألغام». نفس عائلة البوابة (قاعدة داكنة، أزرار بحافة، Baloo) بلونها
   المميّز: الأزرق الثلجي. الخانات المغلقة بلاطات بارزة بحافة (قطع لعب)، والمفتوحة مسطّحة
   غائرة؛ ألوان الأرقام تقليدية مُعدّلة للخلفية الداكنة، والرقم نفسه يكفي بلا لون.
   ========================================================================== */
:root {
  --panel: #142338;
  --panel-2: #1c3150;
  --line: rgba(255, 255, 255, 0.09);
  --accent: #60a5fa;
  --accent-2: #2563eb;
  --text: #eef5ff;
  --dim: #a9bcd8;
  --good: #34d399;
  --bad: #ff5d6c;
  --gold: #ffd166;
  --font: "Baloo Bhaijaan 2", "Segoe UI", Tahoma, system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
html, body { height: 100%; font-family: var(--font); color: var(--text); overflow: hidden; }
body { background: radial-gradient(90% 60% at 50% -10%, rgba(96, 165, 250, .26) 0%, transparent 60%), radial-gradient(130% 100% at 50% 110%, #12223b 0%, #070d18 60%); user-select: none; }
::selection { background: rgba(96, 165, 250, .35); }
button, a, [role="button"] { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
[hidden], .party-card.hidden { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ui-ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.st-ic { width: 19px; height: 19px; flex: none; }
.pill-ic { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)); }
.screen.hidden { display: none; }
#party, #levels, #free { justify-content: flex-start; overflow-y: auto; overscroll-behavior: contain; }
#menu, #settings { justify-content: safe center; overflow-y: auto; overscroll-behavior: contain; }

/* ---------- أزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-family: inherit; font-size: 18px; font-weight: 800; color: var(--text); cursor: pointer;
  background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: 18px; padding: 14px 22px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .32), inset 0 1px 0 rgba(255, 255, 255, .08); transition: transform .07s ease, filter .15s ease;
}
@media (hover: hover) and (pointer: fine) { .btn:hover { filter: brightness(1.12); } }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .32); }
.btn-primary { background: linear-gradient(180deg, #93c5fd, var(--accent-2)); color: #06183d; box-shadow: 0 5px 0 #1e3a8a, inset 0 1px 0 rgba(255, 255, 255, .35); }
.btn-primary:active { box-shadow: 0 2px 0 #1e3a8a; }
.btn.big { font-size: 21px; padding: 16px 28px; }
.btn-ghost { background: rgba(255, 255, 255, .06); box-shadow: none; }
.btn.small { align-self: center; font-size: 15px; padding: 8px 14px; border-radius: 13px; }
.btn.small .ui-ic { width: 18px; height: 18px; }
.btn.danger { background: linear-gradient(180deg, #e0453a, #b5342b); box-shadow: 0 5px 0 #7c231c; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { font-size: 26px; font-weight: 800; background: rgba(255, 255, 255, .07); border: 1px solid var(--line); color: var(--text); width: 46px; height: 46px; border-radius: 15px; cursor: pointer; line-height: 1; flex: none; font-family: inherit; }
.icon-btn:active { transform: translateY(2px); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- القائمة ---------- */
.hub-link { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px; z-index: 3; display: inline-flex; align-items: center; gap: 7px;
  color: var(--dim); text-decoration: none; font-weight: 800; font-size: 15px; background: rgba(255, 255, 255, .06); border: 1px solid var(--line); border-radius: 13px; padding: 8px 14px; }
.hub-mark { width: 20px; height: 20px; flex: none; }
@media (hover: hover) and (pointer: fine) { .hub-link:hover { color: var(--text); } }
.menu-card { text-align: center; max-width: 460px; width: 100%; }
.emblem-wrap { width: clamp(118px, 26vw, 170px); margin: 0 auto 4px; }
.logo-emblem { width: 100%; height: auto; display: block; filter: drop-shadow(0 14px 26px rgba(0, 0, 0, .5)); }
.title { font-size: clamp(46px, 11vw, 76px); font-weight: 800; line-height: 1.15; color: #eef5ff; text-shadow: 0 4px 0 #0b1f4d, 0 10px 26px rgba(0, 0, 0, .45); }
.tagline { color: var(--dim); font-size: clamp(15px, 3.6vw, 18px); margin: 2px auto 22px; max-width: 30ch; text-wrap: balance; }
.menu-buttons { display: flex; flex-direction: column; gap: 12px; }
.menu-stats { display: flex; justify-content: center; gap: 22px; margin-top: 20px; color: var(--gold); font-weight: 800; font-size: 18px; }
.menu-stats span, .bar-right { display: inline-flex; align-items: center; gap: 6px; direction: ltr; unicode-bidi: isolate; }
.menu-stats b, .bar-right b, .pill b { font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- الأشرطة والمراحل ---------- */
.bar { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 820px; margin-bottom: 12px; gap: 12px; }
.bar h2 { font-size: 26px; font-weight: 800; }
.bar-right { min-width: 46px; color: var(--gold); font-weight: 800; }
.hint-line { color: var(--dim); margin-bottom: 14px; font-size: 15px; }
.tier-legend { display: flex; gap: 8px; margin-bottom: 12px; font-size: 12px; font-weight: 800; }
.tl { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--dim); }
.tl::before { content: "●"; color: var(--tier); margin-inline-end: 5px; }
.easy { --tier: #34d399; } .medium { --tier: #60a5fa; } .hard { --tier: #fb923c; } .expert { --tier: #f472b6; }
.levels-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 12px; width: 100%; max-width: 820px; padding: 6px; align-content: start; grid-auto-rows: max-content; }
.lvl { position: relative; aspect-ratio: 1; border-radius: 20px; cursor: pointer; color: var(--text); font-family: inherit;
  border: 1px solid color-mix(in srgb, var(--tier) 35%, var(--line)); background: linear-gradient(180deg, color-mix(in srgb, var(--tier) 16%, var(--panel-2)), var(--panel));
  box-shadow: 0 4px 0 rgba(0, 0, 0, .3); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.lvl:active { transform: translateY(3px); }
.lvl .num { font-size: 27px; font-weight: 800; line-height: 1.1; }
.lvl .lvl-stars { display: flex; gap: 2px; height: 14px; color: rgba(255, 255, 255, .18); }
.lvl .lvl-stars svg { width: 13px; height: 13px; }
.lvl .lvl-stars svg.on { color: var(--gold); }
.lvl.locked { filter: grayscale(.8) brightness(.55); cursor: not-allowed; }
.lvl.locked .num, .lvl.locked .lvl-stars { opacity: 0; }
.lvl.locked::after { content: ""; position: absolute; top: 50%; left: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; opacity: .85;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='4.5' y='10.5' width='15' height='11' rx='3' fill='%23cfe0f7'/%3E%3Cpath d='M8 10.5V8a4 4 0 0 1 8 0v2.5' fill='none' stroke='%23cfe0f7' stroke-width='2.4'/%3E%3Ccircle cx='12' cy='16' r='1.7' fill='%23142338'/%3E%3C/svg%3E") center/contain no-repeat; }
.lvl.current { outline: 3px solid var(--tier); outline-offset: 1px; }
.tier-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; max-width: 460px; }
.tier-pick .btn { flex-direction: column; gap: 2px; padding: 18px 10px; border-color: color-mix(in srgb, var(--tier) 45%, var(--line)); }
.tier-pick .btn small { color: var(--dim); font-size: 13px; font-weight: 700; }

/* ---------- الإعدادات ---------- */
.settings-body { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 14px; }
.settings-body .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: 18px; padding: 15px 18px; font-weight: 700; cursor: pointer; }
.row-label { display: inline-flex; align-items: center; gap: 9px; }
.settings-body input[type=checkbox] { -webkit-appearance: none; appearance: none; flex: none; position: relative; cursor: pointer; width: 52px; height: 30px; border-radius: 20px; background: rgba(255, 255, 255, .14); transition: background .2s; }
.settings-body input[type=checkbox]::before { content: ""; position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .3); transition: transform .2s cubic-bezier(.22, 1, .36, 1); }
.settings-body input[type=checkbox]:checked { background: var(--accent-2); }
.settings-body input[type=checkbox]:checked::before { transform: translateX(-22px); }
.note { color: var(--dim); font-size: 13.5px; text-align: center; line-height: 1.6; }

/* ---------- القائمة: لغز اليوم ---------- */
.menu-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.menu-row .btn { padding: 13px 10px; font-size: 17px; }
.btn-daily { justify-content: flex-start; text-align: start; gap: 12px; background: linear-gradient(180deg, #ffe08a, #f5a524); color: #3d2300; box-shadow: 0 5px 0 #9a5b00, inset 0 1px 0 rgba(255, 255, 255, .45); }
.btn-daily:active { box-shadow: 0 2px 0 #9a5b00; }
.btn-daily .daily-txt { flex: 1; display: flex; flex-direction: column; line-height: 1.15; }
.btn-daily small { font-size: 13.5px; font-weight: 700; opacity: .8; }
.btn-daily.done { background: linear-gradient(180deg, var(--panel-2), var(--panel)); color: var(--text); box-shadow: 0 5px 0 rgba(0, 0, 0, .32), inset 0 1px 0 rgba(255, 255, 255, .08); border-color: rgba(255, 209, 102, .4); }
.streak { display: inline-flex; align-items: center; gap: 3px; padding: 4px 10px; border-radius: 999px; background: rgba(0, 0, 0, .16); font-size: 17px; direction: ltr; unicode-bidi: isolate; }
.streak svg { width: 17px; height: 17px; color: #e8590c; }
.btn-daily.done .streak svg { color: #ff922b; }

/* ---------- الإعدادات: طريقة اللعب ---------- */
.how { background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 18px; padding: 14px 18px; display: flex; flex-direction: column; gap: 8px; }
.how h3 { font-size: 17px; }
.how p { color: var(--dim); font-size: 14.5px; line-height: 1.7; }
.how b { color: var(--text); }

/* ---------- اللعب ---------- */
#game { justify-content: flex-start; gap: 10px; padding-left: 10px; padding-right: 10px; }
.game-bar { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 560px; }
.game-title { flex: 1; display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.game-title span { font-weight: 800; font-size: 19px; }
.game-title small { color: var(--dim); font-size: 12.5px; font-weight: 700; }
.pills { display: flex; flex-direction: column; gap: 4px; min-width: 74px; }
.pill { display: inline-flex; align-items: center; justify-content: center; gap: 4px; font-weight: 800; font-size: 13.5px; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .07); border: 1px solid var(--line); direction: ltr; }
.pill-ic.fill { fill: currentColor; stroke: none; }
.pill.bad { color: #ffb3bb; }
.pill.bad.hot { color: #fff; background: #e5484d; border-color: transparent; }

/* اللوحة: شبكة خانات. --cell يُحسب من العرض والارتفاع المتاحين فتملأ اللوحة الشاشة دون تمرير.
   المغلقة بلاطة بارزة، والمفتوحة غائرة مسطّحة. */
.board-wrap { position: relative; flex: none; }
.board { --cell: min(calc((100vw - 40px - (var(--cols) - 1) * 2px) / var(--cols)), calc((100dvh - 302px - var(--coach-h, 0px) - (var(--rows) - 1) * 2px) / var(--rows)), 50px);
  display: grid; grid-template-columns: repeat(var(--cols), var(--cell)); grid-auto-rows: var(--cell); gap: 2px; padding: 6px;
  border-radius: 14px; background: #0a1322; box-shadow: 0 0 0 3px rgba(96, 165, 250, .45), 0 16px 40px rgba(0, 0, 0, .5);
  touch-action: manipulation; direction: ltr; user-select: none; -webkit-user-select: none; }
.cell { position: relative; display: grid; place-items: center; border-radius: calc(var(--cell) * .18); cursor: pointer;
  font-weight: 800; font-size: calc(var(--cell) * .58); line-height: 1; -webkit-touch-callout: none; }
.cell.h { background: linear-gradient(180deg, #3b5f93, #2a4a7a); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 calc(var(--cell) * .07) 0 #172c4d; }
@media (hover: hover) and (pointer: fine) { .cell.h:hover { filter: brightness(1.15); } }
.cell.h:active { transform: translateY(1px); }
.cell.o { background: #13213a; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .03); cursor: default; }
.cell.o.tap { cursor: pointer; }
.cell svg { width: 62%; height: 62%; pointer-events: none; }
.cell.f svg { width: 58%; height: 58%; }
.cell.boom { background: #e5484d; box-shadow: none; animation: boom .4s ease; }
@keyframes boom { 30% { transform: scale(1.18); } }
.cell.mine-show { background: #1d2d48; }
.cell.wrong { background: #3a1f2a; }
.cell.hint { animation: hint 1.1s ease 2; }
/* المدرّب (المراحل 1–3): الرقم الذي يحسم بإطار ذهبي، والخانات التي يحسمها بإطار أحمر (لغم) أو أخضر (آمنة) */
#game.coaching { --coach-h: 58px; }
.coach { width: min(100% - 24px, 560px); margin: 2px auto 6px; padding: 8px 12px; border-radius: 12px; text-align: center;
  font-size: 14px; font-weight: 700; line-height: 1.55; color: var(--text); background: rgba(255, 209, 102, .12);
  border: 1px solid rgba(255, 209, 102, .45); }
.coach[hidden] { display: none; }
.cell.c-src { box-shadow: 0 0 0 2px #ffd166, 0 0 12px rgba(255, 209, 102, .55); z-index: 1; }
.cell.c-mine { box-shadow: 0 0 0 2px #ff7a7a, inset 0 0 0 999px rgba(255, 122, 122, .18); animation: coach 1.4s ease-in-out infinite; }
.cell.c-safe { box-shadow: 0 0 0 2px #57d68d, inset 0 0 0 999px rgba(87, 214, 141, .18); animation: coach 1.4s ease-in-out infinite; }
@keyframes coach { 50% { filter: brightness(1.3); } }
@keyframes hint { 50% { box-shadow: 0 0 0 3px #fff; filter: brightness(1.4); } }
.n1 { color: #6cb4ff; } .n2 { color: #57d68d; } .n3 { color: #ff7a7a; } .n4 { color: #c39bff; }
.n5 { color: #ffa45c; } .n6 { color: #3fd4c6; } .n7 { color: #ff9fd0; } .n8 { color: #e5e7eb; }
.board.shake { animation: shake .35s ease; }
@keyframes shake { 25% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
.board.won .cell.o { animation: won .6s ease both; animation-delay: calc(var(--d) * 14ms); }
@keyframes won { 40% { filter: brightness(1.6); } }

/* زرّ الوضع: حفر أو علم — مقطعان في زرّ واحد */
.mode { flex: 1.4; display: inline-flex; padding: 3px; gap: 3px; border-radius: 14px; background: rgba(0, 0, 0, .25); border: 1px solid var(--line); }
.mode button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-family: inherit; font-size: 15px; font-weight: 800;
  color: var(--dim); background: transparent; border: 0; border-radius: 11px; padding: 8px 6px; cursor: pointer; }
.mode button[aria-pressed="true"] { background: var(--accent-2); color: #fff; }
.mode .ui-ic { width: 20px; height: 20px; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); font-weight: 800; }
.loading[hidden] { display: none; }

.tools { display: flex; gap: 10px; width: 100%; max-width: 560px; justify-content: center; }
.tool { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-family: inherit; font-size: 15px; font-weight: 800; color: var(--text);
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line); border-radius: 14px; padding: 11px 8px; cursor: pointer; }
.tool:active { transform: translateY(2px); }
.tool:disabled { opacity: .4; cursor: default; }
.tool .cost { color: var(--gold); font-variant-numeric: tabular-nums; }
.rule-line { color: var(--dim); font-size: 13px; font-weight: 700; text-align: center; }

/* ---------- نتيجة لغز اليوم ---------- */
.result-daily { display: flex; flex-direction: column; align-items: center; margin-bottom: 4px; }
.result-daily[hidden] { display: none; }
.big-streak { display: inline-flex; align-items: center; gap: 4px; font-size: 44px; font-weight: 800; color: #ffb347; line-height: 1; direction: ltr; }
.big-streak svg { width: 42px; height: 42px; color: #ff6b1a; }
.result-daily p { color: var(--dim); font-weight: 700; font-size: 14px; }
.overlay .next-note { margin: 12px 0 0; }

.toast { position: fixed; bottom: max(24px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 20; background: rgba(5, 11, 22, .94); border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px; font-weight: 800; }

/* ---------- النوافذ ---------- */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(2, 6, 14, .62); backdrop-filter: blur(3px); padding: 16px; }
.overlay.hidden { display: none; }
.overlay-card { width: 100%; max-width: 400px; text-align: center; background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: 24px; padding: 26px 20px; box-shadow: 0 30px 80px rgba(0, 0, 0, .55); }
.overlay-card h2 { font-size: 28px; margin-bottom: 10px; }
.result-stars { display: flex; justify-content: center; gap: 6px; height: 58px; color: var(--gold); }
.result-stars i { display: inline-block; opacity: .18; filter: grayscale(1); transform: scale(.6); transition: transform .35s cubic-bezier(.2, 1.6, .4, 1), opacity .3s, filter .3s; }
.result-stars i.on { opacity: 1; filter: none; transform: scale(1); }
.rs-ic { width: 48px; height: 48px; }
.result-rows { display: flex; justify-content: center; gap: 22px; margin: 6px 0 18px; }
.result-rows div { display: flex; flex-direction: column; }
.result-rows span { color: var(--dim); font-size: 13px; font-weight: 700; }
.result-rows b { font-size: 20px; font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.overlay-buttons { display: flex; flex-direction: column; gap: 10px; }
.overlay .note { margin-bottom: 16px; }

/* ---------- تحدٍّ مع الأصدقاء ---------- */
.party-body { width: 100%; max-width: 460px; }
.party-card { display: flex; flex-direction: column; gap: 14px; text-align: center; background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: 22px; padding: 20px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; text-align: start; font-weight: 800; font-size: 14px; color: var(--dim); }
.field input, .field select, .join-row input { font-family: inherit; font-size: 18px; font-weight: 700; color: var(--text); min-width: 0; background: rgba(0, 0, 0, .28); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; user-select: text; }
.field select option { color: #111; }
.or { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 13px; font-weight: 700; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.join-row { display: flex; gap: 10px; }
.join-row input { flex: 1; text-align: center; letter-spacing: .3em; direction: ltr; font-size: 22px; font-variant-numeric: tabular-nums; }
.code-label { color: var(--dim); font-weight: 800; font-size: 14px; }
.room-code { font-size: 54px; font-weight: 800; line-height: 1; letter-spacing: .12em; direction: ltr; font-variant-numeric: tabular-nums; color: #eef5ff; }
.players { list-style: none; display: flex; flex-direction: column; gap: 6px; text-align: start; }
.players li { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 12px; background: rgba(255, 255, 255, .05); font-weight: 800; }
.players li small { color: var(--dim); font-weight: 700; }
.players li.away { opacity: .45; }
.players .crown { width: 18px; height: 18px; color: var(--gold); flex: none; }
.players .dot { width: 9px; height: 9px; margin: 0 4.5px; border-radius: 50%; background: var(--good); flex: none; }
.race { width: 100%; max-width: 560px; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 5px; }
.race.hidden { display: none; }
.racer { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; background: rgba(255, 255, 255, .06); border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; }
.racer.me { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.racer.away, .racer.out { opacity: .5; }
.racer .rn { max-width: 9ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.racer .rb { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.racer .rb i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .4s ease; }
.racer.won .rb i { background: var(--gold); }
.racer b { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.ranking { list-style: none; counter-reset: rk; display: flex; flex-direction: column; gap: 6px; margin: 6px 0 16px; text-align: start; }
.ranking li { counter-increment: rk; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .06); font-weight: 800; }
.ranking li::before { content: counter(rk); width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, .1); font-size: 13px; }
.ranking li:first-child::before { background: var(--gold); color: #3a2a00; }
.ranking li.me { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); }
.ranking li span { flex: 1; }
.ranking li b { color: var(--dim); font-variant-numeric: tabular-nums; }

@media (max-height: 700px) { .tools .tool { padding: 6px; } .rule-line { display: none; } }
@media (prefers-reduced-motion: reduce) { .board, .cell, .result-stars i { transition: none; animation: none !important; } }
/* على الجوال: الشريط أعلى، واللوحة في وسط المساحة، والأدوات أسفلها قرب الإبهام */
.board-wrap { margin-block: auto; }
.rule-line { margin-bottom: max(6px, 2vh); }

.guide-link { display: inline-block; margin-top: 14px; color: var(--dim); font-weight: 700; font-size: 15px; text-underline-offset: 4px; }
.moves-line { color: var(--dim); font-size: 13.5px; font-weight: 700; text-align: center; direction: rtl; }
.moves-line b { color: var(--text); font-variant-numeric: tabular-nums; }

/* شكل الأرقام: اختيار من اثنين في الإعدادات، وزرّ صغير في اللعب يبدّل فوراً (مثل سودوكو) */
.digits-row { cursor: default; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 13px; background: rgba(0, 0, 0, .25); border: 1px solid var(--line); }
.seg button { font-family: inherit; font-size: 14px; font-weight: 700; color: var(--dim); background: transparent; border: 0; border-radius: 10px; padding: 6px 11px; cursor: pointer; }
.seg button b { font-size: 16px; font-weight: 800; }
.seg button[aria-checked="true"] { background: var(--accent-2); color: #fff; }
.seg button:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; }
.digits-tool { flex: 0 0 auto; min-width: 58px; font-size: 17px; letter-spacing: .02em; }

/* شاشة كبيرة (آيباد، كمبيوتر): المجموعة كلها في الوسط بلا فراغ، والخانة تكبر حتى ٧٢ بكسل */
@media (min-width: 600px) and (min-height: 760px) {
  #game { justify-content: safe center; gap: 14px; }
  .board { --cell: min(calc((100vw - 40px - (var(--cols) - 1) * 2px) / var(--cols)), calc((100dvh - 290px - var(--coach-h, 0px) - (var(--rows) - 1) * 2px) / var(--rows)), 72px); }
  .board-wrap { margin-block: 0; }
  .rule-line { margin-bottom: 0; }
}

/* ---------- إيقاف مؤقت: اللوحة تختفي والوقت يتجمّد ---------- */
.pause-btn { display: grid; place-items: center; }
.pause-btn[hidden] { display: none; }
.pause-big { width: 54px; height: 54px; fill: none; stroke: var(--accent); stroke-width: 1.9; stroke-linejoin: round; margin-bottom: 6px; }
.pause-time { color: var(--dim); font-weight: 700; margin-bottom: 18px; }
.pause-time b { color: var(--text); direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
#game.paused .board-wrap { visibility: hidden; }

/* ---------- خلفية مرسومة (bg.webp) ----------
   لوحة داكنة خلف كل الشاشات وفوقها تعتيم يبقي النص مقروءاً؛ شاشة اللعب تعتّمها أكثر كي لا تزاحم اللوحة.
   الصورة مربّعة وتفاصيلها على الأطراف: الجوال يرى أعلاها وأسفلها، والشاشة العريضة جانبيها. */
body {
  background:
    radial-gradient(90% 60% at 50% -10%, rgba(96, 165, 250, .22) 0%, transparent 60%),
    linear-gradient(180deg, rgba(7, 13, 24, .46) 0%, rgba(7, 13, 24, .8) 100%),
    url("bg.webp?v=1") center / cover no-repeat rgb(7, 13, 24);
}
#game { background: rgba(7, 13, 24, .64); }

/* ---------- قطع مرسومة داخل اللوحة والأدوات (icons/art) ----------
   المغلقة بلاطة جليد مرسومة (فوقها تعتيم أزرق كي لا تبهر)، والمفتوحة قاع غائر داكن؛ اللغم والعلم والانفجار صور. */
.board { padding: 7px; gap: 3px; border-radius: 18px; background: linear-gradient(180deg, #0c1830, #070f1f);
  box-shadow: 0 0 0 2px rgba(147, 197, 253, .55), 0 0 0 6px rgba(37, 99, 235, .22), 0 18px 44px rgba(0, 0, 0, .55); }
.cell.h { background: linear-gradient(180deg, rgba(16, 46, 110, .10), rgba(16, 46, 110, .46)), url("../../icons/art/ui-icetile.webp") center / 100% 100% no-repeat;
  box-shadow: 0 calc(var(--cell) * .07) 0 #0f2a55; }
.cell.o { background: #0f1b33; box-shadow: inset 0 2px 5px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(147, 197, 253, .06); }
.cell img { width: 82%; height: 82%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .45)); }
.cell.f img { width: 78%; height: 78%; animation: flag-in .22s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes flag-in { from { transform: scale(.3) translateY(-30%); } }
.cell.boom { background: radial-gradient(circle, #ffb347 0%, #e5484d 70%); }
.cell.boom img { width: 104%; height: 104%; }
.cell.mine-show { background: #16233f; }
.cell.wrong { background: #3a1f2a; }
.cell.wrong img { opacity: .55; filter: grayscale(.6); }
.n1 { color: #7cc0ff; } .n2 { color: #5fe39a; } .n3 { color: #ff8585; }
.cell.o { text-shadow: 0 2px 0 rgba(0, 0, 0, .45); }

.pill-art { width: 18px; height: 18px; flex: none; object-fit: contain; }
.pill { padding: 3px 10px 3px 6px; }
.mode-art { width: 26px; height: 26px; flex: none; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .4)); }
.mode button { padding: 6px; }
.mode button[aria-pressed="false"] .mode-art { filter: grayscale(.7) brightness(.8); opacity: .75; }
.mode button[aria-pressed="true"] { background: linear-gradient(180deg, #60a5fa, var(--accent-2)); box-shadow: 0 3px 0 #1e3a8a, inset 0 1px 0 rgba(255, 255, 255, .35); }
.tool { background: linear-gradient(180deg, var(--panel-2), var(--panel)); box-shadow: 0 4px 0 rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .08); }
.tool .cost { display: inline-flex; align-items: center; gap: 2px; }
.tier-pick .btn { box-shadow: 0 5px 0 rgba(0, 0, 0, .32), inset 0 4px 0 var(--tier); }
