:root {
  --bg: #0b1120;
  --bg-2: #101a33;
  --panel: rgba(15, 23, 42, 0.72);
  --cyan: #22d3ee;
  --mint: #22c55e;
  --magenta: #f43f5e;
  --violet: #8b5cf6;
  --text: #e8eefc;
  --muted: #93a4c6;
  --border: rgba(255, 255, 255, 0.09);
  --radius: 18px;
  --shadow: 0 18px 50px rgba(3, 7, 18, 0.65);
  --font-ar: "Cairo", system-ui, sans-serif;
  --font-num: "Orbitron", "Cairo", monospace;
}

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

html, body {
  height: 100%;
  background:
    radial-gradient(1100px 700px at 78% -10%, rgba(139, 92, 246, 0.22), transparent 60%),
    radial-gradient(900px 600px at 12% 110%, rgba(34, 211, 238, 0.16), transparent 62%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-ar);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: grid;
  place-items: center;
  padding: 14px;
  min-height: 100dvh;
}

.stage {
  position: relative;
  width: min(100%, 520px);
  height: min(100dvh - 28px, 880px);
  border-radius: 26px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(16, 26, 51, 0.9), rgba(8, 13, 26, 0.96));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.028) 0 1px, transparent 1px 3px);
  pointer-events: none;
  z-index: 5;
  mix-blend-mode: overlay;
}
.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  padding: 14px 14px 6px;
  z-index: 6;
}

.hud-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(10px);
}

.hud-mid { align-items: center; }
.hud-card:first-child { align-items: flex-start; }
.hud-card:last-child { align-items: flex-end; }

.hud-label {
  font-size: 11px;
  letter-spacing: 0.4px;
  color: var(--muted);
}

.hud-value {
  font-family: var(--font-num);
  font-size: clamp(18px, 5vw, 24px);
  font-weight: 700;
  line-height: 1.1;
  color: #fff;
  text-shadow: 0 0 18px rgba(34, 211, 238, 0.45);
}

.hud-card:last-child .hud-value {
  color: var(--mint);
  text-shadow: 0 0 18px rgba(34, 197, 94, 0.4);
}

.lives {
  display: flex;
  gap: 7px;
  padding: 6px 16px 2px;
  z-index: 6;
}

.heart {
  width: 15px;
  height: 15px;
  border-radius: 4px 4px 6px 6px;
  background: linear-gradient(180deg, var(--magenta), #9f1239);
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.65);
  transform: rotate(45deg);
  transition: opacity 0.3s ease, transform 0.3s ease, filter 0.3s ease;
}

.heart.is-lost {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
  filter: none;
  opacity: 0.5;
  transform: rotate(45deg) scale(0.82);
}

#game {
  flex: 1;
  width: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 40%, rgba(11, 17, 32, 0.72), rgba(6, 10, 20, 0.94));
  backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.32s ease, visibility 0.32s ease;
}

.overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.panel {
  width: 100%;
  max-width: 360px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: pop 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

.panel-eyebrow {
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--cyan);
  text-transform: uppercase;
}

.panel-title {
  font-size: clamp(34px, 12vw, 52px);
  font-weight: 800;
  line-height: 1.05;
  background: linear-gradient(100deg, #ffffff, var(--cyan) 45%, var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 26px rgba(34, 211, 238, 0.35));
}

.panel-text {
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--muted);
  max-width: 30ch;
}

.panel-text b {
  color: var(--text);
  font-family: var(--font-num);
}
.keys {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.keys span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.keys b {
  font-family: var(--font-num);
  font-size: 11px;
  color: #fff;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(34, 211, 238, 0.16);
  border: 1px solid rgba(34, 211, 238, 0.35);
}

.btn {
  margin-top: 4px;
  padding: 14px 34px;
  border: 0;
  border-radius: 999px;
  font-family: var(--font-ar);
  font-size: 16px;
  font-weight: 800;
  color: #04121b;
  background: linear-gradient(100deg, var(--cyan), #6ee7b7 60%, var(--mint));
  box-shadow: 0 12px 30px rgba(34, 211, 238, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(34, 211, 238, 0.42);
  filter: brightness(1.05);
}

.btn:active { transform: translateY(0) scale(0.98); }

.btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.footer-bar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px 14px;
  z-index: 6;
}

.ghost-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-family: var(--font-ar);
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.ghost-btn:hover {
  color: #fff;
  border-color: rgba(34, 211, 238, 0.5);
  background: rgba(34, 211, 238, 0.1);
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
