/* ══ «عالم أبيض» — ورقة أنماط واحدة، أبيض ورمادي فقط ══ */
:root {
  --white: #ffffff;
  --paper: #f6f7f9;
  --paper-2: #eef0f4;
  --line: #e6e8ee;
  --line-2: #d6dae2;
  --ink: #14161a;
  --ink-2: #3d434d;
  --muted: #9aa1ac;
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 28px;
  --pad: clamp(56px, 16vw, 70px);
  --shadow-sm: 0 2px 10px rgba(20, 22, 26, .06);
  --shadow: 0 10px 30px rgba(20, 22, 26, .09);
  --shadow-lg: 0 22px 60px rgba(20, 22, 26, .14);
  --ease: cubic-bezier(.22, .8, .28, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--white);
  color: var(--ink);
  font-family: 'Inter', 'Tajawal', ui-sans-serif, system-ui, -apple-system, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app { position: fixed; inset: 0; overflow: hidden; }

#game {
  position: absolute; inset: 0; display: block;
  width: 100%; height: 100%;
  background: var(--white); touch-action: none;
}

/* ── HUD ── */
.hud {
  position: absolute; top: calc(var(--safe-t) + 12px); left: 12px; right: 12px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  pointer-events: none; z-index: 6;
  opacity: 0; transition: opacity .3s var(--ease);
}
.hud.is-on { opacity: 1; }
.hud-cell {
  display: flex; flex-direction: column; gap: 1px; min-width: 76px;
  padding: 8px 14px; border-radius: var(--radius);
  background: rgba(255, 255, 255, .74);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.hud-cell--mid { align-items: center; }
.hud-cell--end { align-items: flex-end; }
.hud-label {
  font-size: 9.5px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.hud-value {
  font-size: 16px; font-weight: 800; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.hud-cell--mid .hud-value { font-size: 19px; }

/* ── زر الإيقاف المؤقت (أسفل الوسط) ── */
.icon-btn {
  position: absolute; left: 50%; bottom: calc(var(--safe-b) + 22px);
  transform: translateX(-50%); z-index: 8;
  width: 48px; height: 48px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  color: var(--ink); cursor: pointer;
  opacity: 0; pointer-events: none;
  transition: transform .18s var(--ease), background .18s var(--ease),
              opacity .3s var(--ease), box-shadow .18s var(--ease);
}
.icon-btn svg { width: 20px; height: 20px; stroke-width: 1.75; }
.icon-btn.is-on { opacity: 1; pointer-events: auto; box-shadow: var(--shadow-sm); }
.icon-btn.is-on:active { transform: translateX(-50%) scale(.9); background: var(--paper-2); }

/* ── أزرار اللمس ── */
.controls {
  position: absolute; inset-inline: 16px; bottom: calc(var(--safe-b) + 16px);
  z-index: 7; direction: ltr;
  display: flex; align-items: flex-end; justify-content: space-between;
  pointer-events: none;
  opacity: 0; transition: opacity .3s var(--ease);
}
.controls.is-on { opacity: 1; }
.controls-cluster { display: flex; align-items: flex-end; gap: 14px; pointer-events: auto; }

.pad {
  width: var(--pad); height: var(--pad); display: grid; place-items: center;
  border-radius: 999px; border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, .8);
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  color: var(--ink); cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform .14s var(--ease), background .14s var(--ease),
              color .14s var(--ease), box-shadow .14s var(--ease);
}
.pad svg { width: 26px; height: 26px; stroke-width: 1.75; }
.pad.is-down { transform: scale(.9); background: var(--paper-2); }
.pad--solid { background: var(--ink); color: #fff; border-color: var(--ink); }
.pad--solid.is-down { background: #000; box-shadow: 0 0 0 9px rgba(20, 22, 26, .08); }

/* ── الشاشات ── */
.screen {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--safe-t) + 16px) 18px calc(var(--safe-b) + 16px);
  background: rgba(255, 255, 255, .74);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  opacity: 0; visibility: hidden; overflow-y: auto;
  transition: opacity .3s var(--ease), visibility .3s;
}
.screen.is-active { opacity: 1; visibility: visible; }
.screen--soft { background: rgba(255, 255, 255, .58); z-index: 24; }

.panel {
  width: 100%; max-width: 430px; margin: auto; text-align: center;
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: clamp(22px, 6vw, 36px) clamp(16px, 5vw, 30px);
  display: flex; flex-direction: column; align-items: center; gap: 15px;
}
.panel--sm { max-width: 320px; }

.eyebrow {
  font-size: .68rem; font-weight: 600; letter-spacing: .2em;
  text-transform: uppercase; color: var(--muted);
}
.title {
  font-size: clamp(2rem, 11vw, 3.1rem); font-weight: 800;
  letter-spacing: -.05em; line-height: 1.05;
}
.title em {
  font-style: normal; display: inline-block;
  padding: 0 .16em .04em; border-radius: 14px;
  background: var(--ink); color: #fff;
}
.title--sm { font-size: clamp(1.45rem, 6.5vw, 1.9rem); }
.lead {
  font-size: .95rem; line-height: 1.8; color: var(--ink-2);
  max-width: 34ch; text-wrap: pretty;
}

/* ── بطاقات الأرقام ── */
.stats-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; width: 100%; }
.stats-row--3 { grid-template-columns: repeat(3, 1fr); }
.stat {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 6px;
  display: flex; flex-direction: column; gap: 3px;
}
.stat-label {
  font-size: .62rem; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.stat-value {
  font-size: 1.05rem; font-weight: 700; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

/* ── الأزرار ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; max-width: 320px; padding: 15px 22px;
  border: 1px solid transparent; border-radius: 999px;
  font-family: inherit; font-size: 1rem; font-weight: 600; color: var(--ink);
  cursor: pointer;
  transition: transform .16s var(--ease), box-shadow .16s var(--ease),
              background .16s var(--ease), opacity .16s var(--ease);
}
.btn svg { width: 19px; height: 19px; stroke-width: 1.75; flex: none; }
.btn-primary { background: var(--ink); color: #fff; box-shadow: 0 10px 26px rgba(20, 22, 26, .22); }
.btn-primary:active { transform: scale(.97); }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--ink-2); }
.btn-ghost:active { background: var(--paper); }
.btn-sm { font-size: .85rem; padding: 11px 18px; }
.btn.is-off { opacity: .5; }

/* ── التلميحات ── */
.hints { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.hint {
  display: flex; align-items: center; gap: 10px;
  font-size: .82rem; color: var(--ink-2); text-align: right;
  background: var(--paper); border-radius: 999px; padding: 9px 14px;
}
.hint svg { width: 17px; height: 17px; stroke-width: 1.75; color: var(--muted); flex: none; }

/* ── التنبيهات العابرة ── */
.toast-wrap {
  position: absolute; left: 50%; bottom: calc(var(--safe-b) + 112px);
  transform: translateX(-50%); z-index: 30;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  padding: 10px 20px; border-radius: 999px;
  font-size: .85rem; font-weight: 600; white-space: nowrap;
  background: var(--ink); color: #fff; box-shadow: var(--shadow);
  animation: toastIn .38s var(--ease) both;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(14px) scale(.94); }
  to   { opacity: 1; transform: none; }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}
.fade-up { animation: fadeUp .5s var(--ease) both; }

/* ── الاستجابة ── */
@media (max-width: 380px) {
  .hud-value { font-size: 15px; }
  .hint { font-size: .78rem; }
  .icon-btn { width: 44px; height: 44px; }
}
@media (max-height: 640px) {
  .panel { gap: 11px; border-radius: 24px; }
  .hints { display: none; }
  .lead { display: none; }
}
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(20, 22, 26, .26); }
  .btn-ghost:hover { background: var(--paper); }
  .pad:hover { background: var(--paper-2); }
  .icon-btn.is-on:hover { background: var(--paper-2); }
}
@media (prefers-reduced-motion: reduce) {
  .fade-up, .toast { animation: none; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}
