/* ── ثعبان النيون · design tokens ── */
:root {
  --bg: #070b14;
  --bg-2: #0f172a;
  --bg-3: #1f1829;
  --card: rgba(255, 255, 255, .045);
  --card-hi: rgba(255, 255, 255, .08);
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .16);
  --text: #f4f7ff;
  --muted: #8b93a7;
  --green: #22c55e;
  --green-soft: #4ade80;
  --cyan: #22d3ee;
  --blue: #2563eb;
  --violet: #a78bfa;
  --rose: #fb7185;
  --gold: #fbbf24;
  --red: #dc2626;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow: 0 6px 28px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 60px rgba(0, 0, 0, .55);
  --font-body: 'Noto Kufi Arabic', 'Segoe UI', system-ui, sans-serif;
  --font-num: 'Press Start 2P', 'Noto Kufi Arabic', monospace;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.num { font-family: var(--font-num); font-size: .85em; letter-spacing: .02em; }
.glow {
  position: fixed; inset: -35% -15% auto -15%; height: 65vh; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(34, 197, 94, .22), transparent 60%),
    radial-gradient(ellipse at 75% 5%, rgba(37, 99, 235, .22), transparent 60%);
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 6px; }

/* ── الشريط العلوي ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem clamp(.75rem, 3vw, 2rem);
  background: rgba(7, 11, 20, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.brand h1 {
  font-size: clamp(.85rem, 2.4vw, 1.05rem); font-weight: 800; letter-spacing: -.01em;
  background: linear-gradient(90deg, var(--green-soft), var(--cyan));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  white-space: nowrap;
}
.pulse-dot {
  width: 11px; height: 11px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, .7); animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .6); }
  70% { box-shadow: 0 0 0 12px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
.top-stats { display: flex; gap: .5rem; }
.chip {
  display: flex; align-items: center; gap: .5rem;
  padding: .35rem .75rem; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border);
}
.chip.gold { border-color: rgba(251, 191, 36, .3); background: rgba(251, 191, 36, .08); }
.chip-label { font-size: .68rem; color: var(--muted); font-weight: 600; }
.chip-value { font-size: .8rem; color: var(--green-soft); }
.chip.gold .chip-value { color: var(--gold); }
.top-actions { display: flex; gap: .4rem; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 12px; background: var(--card); border: 1px solid var(--border);
  color: var(--text); transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}
.icon-btn:hover { background: var(--card-hi); transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0, 0, 0, .4); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.off { color: var(--muted); }

/* ── التخطيط ── */
.layout {
  position: relative; z-index: 1;
  max-width: 1180px; margin: 0 auto;
  padding: clamp(.75rem, 2.5vw, 1.75rem) clamp(.75rem, 3vw, 2rem) 2rem;
  display: grid; gap: clamp(1rem, 2.5vw, 1.75rem);
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: start;
}
.board-card { display: flex; flex-direction: column; gap: 1rem; animation: fadeUp .5s ease both; }
.board-wrap {
  position: relative; width: 100%;
  max-width: min(70vh, 640px); margin: 0 auto;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at 50% 30%, #0d1526, #070b14 70%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg), inset 0 0 60px rgba(34, 197, 94, .06);
  overflow: hidden;
}
#board { display: block; width: 100%; height: 100%; border-radius: var(--radius-lg); touch-action: none; }
.board-wrap.shake { animation: shake .32s ease; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-6px, 3px); }
  50% { transform: translate(5px, -4px); }
  75% { transform: translate(-3px, -2px); }
}
/* ── أزرار الاتجاهات ── */
.dpad {
  display: grid; gap: .5rem; width: min(260px, 70vw); margin: 0 auto;
  direction: ltr;
  grid-template-columns: repeat(3, 1fr); grid-template-areas: ". up ." "left down right";
}
.dbtn {
  aspect-ratio: 1 / 1; display: grid; place-items: center;
  border-radius: var(--radius); background: var(--card); border: 1px solid var(--border);
  color: var(--text); font-size: 1.4rem; user-select: none;
  transition: transform .12s ease, background .18s ease, box-shadow .18s ease;
  touch-action: manipulation;
}
.dbtn:hover { background: var(--card-hi); }
.dbtn:active, .dbtn.pressed { background: rgba(34, 197, 94, .18); transform: scale(.94); box-shadow: 0 0 22px rgba(34, 197, 94, .25); }
.dbtn svg { width: 26px; height: 26px; }
.dbtn .fallback { color: var(--green-soft); }
.dbtn svg ~ .fallback { display: none; }
.dbtn.up { grid-area: up; } .dbtn.down { grid-area: down; }
.dbtn.left { grid-area: left; } .dbtn.right { grid-area: right; }
@media (hover: hover) and (pointer: fine) { .dpad { opacity: .55; } .dpad:hover { opacity: 1; } }

/* ── شاشات داخل اللوح ── */
.screen {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 1rem;
  background: rgba(7, 11, 20, .74); backdrop-filter: blur(10px);
  animation: fadeUp .28s ease both; text-align: center;
}
.screen-inner { display: flex; flex-direction: column; align-items: center; gap: .8rem; max-width: 330px; }
.eyebrow { font-size: .64rem; letter-spacing: .24em; color: var(--green-soft); }
.screen-title {
  font-size: clamp(1.35rem, 4.6vw, 2rem); font-weight: 800; letter-spacing: -.02em;
  background: linear-gradient(90deg, var(--green-soft), var(--cyan));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.screen-sub { font-size: .82rem; color: var(--muted); line-height: 1.9; }
.big-icon { width: 32px; height: 32px; color: var(--cyan); }
.big-icon.danger { color: var(--red); }
.over-stats { display: flex; gap: 1.4rem; }
.over-stats > div { display: flex; flex-direction: column; gap: .3rem; }
.over-stats .num { font-size: 1.05rem; color: var(--green-soft); }
.over-stats small { font-size: .62rem; color: var(--muted); }
.record { display: flex; align-items: center; gap: .4rem; color: var(--gold); font-size: .76rem; font-weight: 700; }
.record svg { width: 16px; height: 16px; }
.hint { font-size: .7rem; color: var(--muted); line-height: 1.9; }
.countdown {
  position: absolute; inset: 0; z-index: 6; display: grid; place-items: center;
  font-family: var(--font-num); font-size: clamp(2.6rem, 13vw, 5.5rem);
  color: var(--green-soft); text-shadow: 0 0 34px rgba(74, 222, 128, .75);
  animation: pop .55s ease both; pointer-events: none;
}
@keyframes pop { from { transform: scale(.55); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── اللوحة الجانبية ── */
.panel { display: flex; flex-direction: column; gap: 1rem; animation: fadeUp .6s ease both; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem; backdrop-filter: blur(12px); box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.card-title { font-size: .78rem; font-weight: 800; margin-bottom: .85rem; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.stat {
  display: flex; flex-direction: column; gap: .3rem; padding: .55rem .7rem;
  border-radius: var(--radius-sm); background: rgba(255, 255, 255, .03); border: 1px solid var(--border);
}
.stat .num { font-size: .9rem; color: var(--green-soft); }
.stat small { font-size: .6rem; color: var(--muted); }
.effects { margin-top: .85rem; display: flex; flex-direction: column; gap: .5rem; }
.effects .empty { font-size: .7rem; color: var(--muted); }
.effect { display: flex; align-items: center; gap: .55rem; font-size: .7rem; font-weight: 600; }
.effect .tag { min-width: 42px; color: var(--c, var(--cyan)); }
.effect .bar { flex: 1; height: 5px; border-radius: 99px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.effect .bar > i { display: block; height: 100%; width: 100%; background: var(--c, var(--cyan)); }
.legend { list-style: none; display: flex; flex-direction: column; gap: .65rem; }
.legend li { display: flex; align-items: center; gap: .65rem; }
.legend div { display: flex; flex-direction: column; gap: .1rem; }
.legend .swatch {
  width: 26px; height: 26px; border-radius: 8px; flex: 0 0 auto;
  background: rgba(255, 255, 255, .05); border: 2px solid var(--c);
  box-shadow: 0 0 16px -2px var(--c);
}
.legend b { font-size: .74rem; }
.legend small { font-size: .64rem; color: var(--muted); font-weight: 500; }
.panel-actions { display: flex; gap: .5rem; margin-bottom: .6rem; }
.panel-actions .btn { flex: 1; padding: .6rem .4rem; font-size: .76rem; }

/* ── أزرار وتبويبات ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.4rem; border-radius: 999px; font-size: .82rem; font-weight: 700;
  border: 1px solid transparent;
  transition: transform .15s ease, box-shadow .15s ease, background .2s ease, opacity .2s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: linear-gradient(135deg, #22c55e, #22d3ee); color: #04120b; box-shadow: 0 8px 30px rgba(34, 197, 94, .3); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 40px rgba(34, 197, 94, .45); }
.btn-ghost { border-color: var(--border-strong); background: rgba(255, 255, 255, .02); }
.btn-ghost:hover { background: var(--card-hi); transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(.98); }
.diff-tabs {
  display: flex; gap: .25rem; padding: .25rem;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--border); border-radius: 999px;
}
.tab { padding: .45rem .95rem; border-radius: 999px; font-size: .74rem; font-weight: 700; color: var(--muted); transition: all .2s ease; }
.tab:hover { color: var(--text); }
.tab.active { background: linear-gradient(135deg, #22c55e, #22d3ee); color: #04120b; }

/* ── النافذة المنبثقة ── */
.overlay {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 1rem;
  background: rgba(4, 7, 14, .72); backdrop-filter: blur(6px); animation: fadeUp .22s ease both;
}
.modal {
  background: #0e1525; border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  padding: 1.35rem; width: 100%; max-width: 520px; max-height: 85vh; overflow: auto; box-shadow: var(--shadow-lg);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .85rem; }
.modal-head h3 { font-size: .95rem; font-weight: 800; }
.modal-body p { font-size: .78rem; color: var(--muted); line-height: 2.05; margin-bottom: .7rem; }
.modal-body b { color: var(--green-soft); }

/* ── التنبيهات ── */
.toast-wrap { position: fixed; bottom: 1.2rem; inset-inline-start: 1.2rem; z-index: 80; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  padding: .7rem 1.1rem; border-radius: var(--radius-sm); font-size: .76rem; font-weight: 600;
  background: rgba(34, 197, 94, .14); border: 1px solid rgba(34, 197, 94, .32);
  color: var(--green-soft); box-shadow: var(--shadow-lg); animation: fadeUp .28s ease both;
}
.toast.gold { background: rgba(251, 191, 36, .14); border-color: rgba(251, 191, 36, .35); color: var(--gold); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ── الاستجابة ── */
@media (max-width: 1024px) {
  .layout { grid-template-columns: minmax(0, 1fr) 280px; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .board-wrap { max-width: min(78vh, 620px); }
  .panel { display: grid; grid-template-columns: 1fr 1fr; }
  .panel .card:last-child { grid-column: 1 / -1; }
}
@media (max-width: 620px) {
  .topbar { padding: .6rem .7rem; }
  .brand h1 { font-size: .78rem; }
  .chip-label { display: none; }
  .chip { padding: .3rem .6rem; }
  .panel { grid-template-columns: 1fr; }
  .layout { padding: .7rem .7rem 1.6rem; }
  .board-wrap { max-width: 100%; }
  .dpad { width: min(220px, 78vw); }
  .dbtn svg { width: 22px; height: 22px; }
  .toast-wrap { inset-inline: .8rem; bottom: .8rem; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .dpad { display: none; }
  .board-wrap { max-width: min(64vh, 460px); }
}
