@import url('https://fonts.googleapis.com/css2?family=Baloo+Bhaijaan+2:wght@400..800&family=Fredoka:wght@400..700&display=swap');

:root {
  --bg:            #0F172A;
  --bg-soft:       #151f38;
  --panel:         rgba(15, 23, 42, .72);
  --border:        rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .18);
  --text:          #FFFFFF;
  --text-muted:    #93a3c4;
  --primary:       #DC2626;
  --secondary:     #2563EB;
  --accent:        #22C55E;
  --gold:          #FBBF24;
  --radius-sm:     8px;
  --radius:        14px;
  --radius-lg:     22px;
  --shadow:        0 4px 24px rgba(0, 0, 0, .45);
  --shadow-lg:     0 18px 60px rgba(0, 0, 0, .6);
  --font: 'Baloo Bhaijaan 2', 'Fredoka', system-ui, -apple-system, sans-serif;
  --font-num: 'Fredoka', 'Baloo Bhaijaan 2', system-ui, sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: -30% -10% auto -10%;
  height: 65vh;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 0%, rgba(37, 99, 235, .35), transparent 62%);
  z-index: 0;
}

button { font-family: inherit; cursor: pointer; }
/* ── Layout ── */
.app {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 1rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .9rem;
  min-height: 100dvh;
}

/* ── HUD ── */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .7rem 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; }

.brand-ball {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fff 12%, var(--primary) 55%, #7f1d1d 100%);
  box-shadow: 0 0 14px rgba(220, 38, 38, .6);
  animation: bob 1.8s ease-in-out infinite;
}

.brand-name { font-size: 1.05rem; letter-spacing: -.01em; }

.stats { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 62px;
  padding: .3rem .6rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--border);
}

.stat-label { font-size: .62rem; letter-spacing: .08em; color: var(--text-muted); }

.stat-value {
  font-family: var(--font-num);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-value.lives { display: flex; gap: 3px; align-items: center; height: 1.35rem; }

.stat-value.lives svg { width: 15px; height: 15px; }
.stat-value.lives .heart-on { color: var(--primary); fill: rgba(220, 38, 38, .35); }
.stat-value.lives .heart-off { color: #3b4663; }
/* ── منطقة اللعب ── */
.stage { flex: 1; display: flex; align-items: center; justify-content: center; }

.frame {
  position: relative;
  width: 100%;
  max-width: 1000px;
  aspect-ratio: 8 / 5;
  max-height: 66vh;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(37, 99, 235, .25);
  background: #0b1224;
  touch-action: manipulation;
}

#game { display: block; width: 100%; height: 100%; }

.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, .035) 0 1px,
    transparent 1px 4px
  );
  mix-blend-mode: overlay;
}

/* ── الألواح العلوية ── */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(6, 10, 22, .62);
  backdrop-filter: blur(6px);
  transition: opacity .25s ease;
}

.overlay.hidden { opacity: 0; pointer-events: none; }

.panel {
  width: min(520px, 100%);
  text-align: center;
  padding: 1.6rem 1.5rem;
  border-radius: var(--radius-lg);
  background: rgba(15, 23, 42, .92);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  animation: pop .3s ease;
}

.panel h2 {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: .35rem;
}

.panel p.sub { color: var(--text-muted); font-size: .95rem; margin-bottom: 1rem; }

.rules { display: grid; gap: .45rem; margin: 0 auto 1.2rem; max-width: 400px; text-align: right; }

.rule {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-size: .9rem;
  color: #cfd8ec;
  padding: .45rem .7rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .045);
  border: 1px solid var(--border);
}

.rule svg { width: 17px; height: 17px; flex: none; color: var(--secondary); }
/* ── الأزرار ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .7rem 1.5rem;
  border-radius: 999px;
  font-size: .95rem;
  font-weight: 600;
  border: none;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #f97316);
  box-shadow: 0 8px 26px rgba(220, 38, 38, .35);
  transition: transform .15s ease, box-shadow .15s ease;
}

.btn:hover { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(220, 38, 38, .5); }
.btn:active { transform: translateY(0) scale(.98); }
.btn svg { width: 18px; height: 18px; }

.btn-alt {
  background: transparent;
  border: 1.5px solid var(--border-strong);
  box-shadow: none;
  color: var(--text);
}

.btn-alt:hover { background: rgba(255, 255, 255, .08); box-shadow: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--border);
  color: var(--text);
  transition: background .2s ease, transform .15s ease, color .2s ease;
}

.icon-btn:hover { background: rgba(255, 255, 255, .12); transform: translateY(-2px); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.muted { color: var(--primary); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .75rem;
  font-weight: 600;
  padding: .25rem .7rem;
  border-radius: 999px;
  margin-bottom: .8rem;
  background: rgba(34, 197, 94, .16);
  color: var(--accent);
}

.badge svg { width: 14px; height: 14px; }

.score-row { display: flex; justify-content: center; gap: 1.6rem; margin-bottom: 1.2rem; }

.score-box { display: flex; flex-direction: column; gap: .15rem; }
.score-box span:first-child { font-size: .68rem; letter-spacing: .08em; color: var(--text-muted); }

.score-box span:last-child {
  font-family: var(--font-num);
  font-size: 1.9rem;
  font-weight: 600;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.panel-actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }
/* ── تلميحات التحكم ── */
.hint {
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
  justify-content: center;
  font-size: .8rem;
  color: var(--text-muted);
}

.hint span { display: inline-flex; align-items: center; gap: .35rem; }
.hint svg { width: 15px; height: 15px; color: var(--secondary); }

/* ── حركات ── */
@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

/* ── تصميم متجاوب ── */
@media (max-width: 720px) {
  .app { padding: .7rem .6rem 1rem; gap: .6rem; }
  .hud { padding: .55rem .7rem; gap: .55rem; border-radius: var(--radius); }
  .brand-name { font-size: .92rem; }
  .stat { min-width: 54px; padding: .25rem .45rem; }
  .stat-value { font-size: 1rem; }
  .icon-btn { width: 36px; height: 36px; }
  .hint { font-size: .72rem; gap: .6rem; }
  .hint span:nth-child(3) { display: none; }
  .panel { padding: 1.2rem 1rem; }
}

@media (max-width: 480px) {
  .stat:nth-child(3) { display: none; }
  .score-row { gap: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .brand-ball, .panel { animation: none; }
  .scanlines { display: none; }
}
