:root {
  --bg: #0a0c14; --card: #1a1f33; --text: #eef1fb; --muted: #9aa3c4;
  --accent: #7c5cff; --accent-2: #00e0c6;
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1100px 520px at 50% -12%, rgba(60, 54, 128, .5), transparent 65%), var(--bg);
  display: flex; flex-direction: column; align-items: center;
  overflow-x: hidden;
}

/* ---- layered animated backdrop ---- */
body::before {
  /* drifting neon glow orbs */
  content: ""; position: fixed; inset: -22%; z-index: -2; pointer-events: none;
  background:
    radial-gradient(420px 420px at 18% 28%, rgba(124, 92, 255, .17), transparent 70%),
    radial-gradient(360px 360px at 82% 16%, rgba(0, 224, 198, .11), transparent 70%),
    radial-gradient(520px 520px at 68% 86%, rgba(124, 92, 255, .11), transparent 70%),
    radial-gradient(300px 300px at 8% 78%, rgba(0, 224, 198, .07), transparent 70%);
  will-change: transform, opacity;
}
body::after {
  /* faint grid + vignette */
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(rgba(124, 92, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 92, 255, .045) 1px, transparent 1px),
    radial-gradient(ellipse at center, transparent 52%, rgba(3, 4, 9, .82) 100%);
  background-size: 44px 44px, 44px 44px, 100% 100%;
}
@media (prefers-reduced-motion: no-preference) {
  body::before { animation: hp-drift 28s ease-in-out infinite alternate; }
  @keyframes hp-drift {
    from { transform: translate3d(-2%, -1.5%, 0) scale(1); opacity: .85; }
    50%  { opacity: 1; }
    to   { transform: translate3d(2%, 2.5%, 0) scale(1.07); opacity: .9; }
  }
}

/* ---- sticky game bar ---- */
.game-bar {
  position: sticky; top: 0; z-index: 50;
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 20px;
  background: rgba(10, 12, 20, .72);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(124, 92, 255, .18);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
.game-bar a.back {
  color: var(--accent-2); font-weight: 700; text-decoration: none; white-space: nowrap;
  padding: 6px 10px; margin-left: -10px; border-radius: 8px; transition: background .15s;
}
.game-bar a.back:hover { background: rgba(0, 224, 198, .12); }
.game-bar h1 {
  font-size: 1.05rem; margin: 0; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 0 18px rgba(124, 92, 255, .5);
}

/* ---- layout ---- */
.game-wrap {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 16px; padding: 24px 16px 40px; width: 100%;
}
@media (max-width: 400px) { .game-wrap { padding: 16px 8px 32px; } }

/* ---- HUD ---- */
.hud {
  color: var(--muted); font-weight: 600; display: flex; gap: 24px;
  flex-wrap: wrap; justify-content: center;
  background: rgba(26, 31, 51, .55); border: 1px solid rgba(124, 92, 255, .18);
  padding: 8px 20px; border-radius: 999px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .3);
}
.hud b { color: var(--accent-2); font-variant-numeric: tabular-nums; text-shadow: 0 0 12px rgba(0, 224, 198, .45); }

/* ---- canvas / stage neon presentation ---- */
canvas {
  background: #0a0c14; border-radius: 12px; max-width: 100%; touch-action: none;
  border: 1px solid rgba(124, 92, 255, .35);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, .6),
    0 0 24px rgba(124, 92, 255, .22),
    0 0 60px rgba(0, 224, 198, .08),
    0 14px 40px rgba(0, 0, 0, .5);
}
.stage {
  position: relative; width: min(100%, 1000px); aspect-ratio: 4 / 3;
  background: #06070d; border-radius: 14px; overflow: hidden;
  border: 1px solid rgba(124, 92, 255, .3);
  box-shadow:
    0 0 28px rgba(124, 92, 255, .18),
    0 0 80px rgba(0, 224, 198, .06),
    0 16px 48px rgba(0, 0, 0, .55);
}
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* loading shimmer + spinner shown inside the stage until the game loads */
.stage .loader {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: linear-gradient(110deg, #0b0d17 35%, #141a33 50%, #0b0d17 65%);
  background-size: 200% 100%;
}
.stage .loader .spin {
  width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid rgba(124, 92, 255, .25); border-top-color: var(--accent-2);
}
@media (prefers-reduced-motion: no-preference) {
  .stage .loader { animation: hp-shimmer 1.6s linear infinite; }
  .stage .loader .spin { animation: hp-spin .8s linear infinite; }
  @keyframes hp-shimmer { to { background-position: -200% 0; } }
  @keyframes hp-spin { to { transform: rotate(360deg); } }
}

/* ---- buttons ---- */
.btn {
  padding: 10px 20px; border-radius: 999px; border: none; cursor: pointer;
  font-weight: 700; font-size: .95rem; font-family: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #0c0e16;
  box-shadow: 0 4px 18px rgba(124, 92, 255, .35);
  transition: transform .12s, box-shadow .12s, filter .12s;
}
.btn:hover { filter: brightness(1.1); box-shadow: 0 6px 24px rgba(124, 92, 255, .5); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn.ghost {
  background: rgba(26, 31, 51, .8); color: var(--text);
  border: 1px solid rgba(124, 92, 255, .3); box-shadow: none;
  text-decoration: none; display: inline-block;
}
.btn.ghost:hover { background: var(--card); border-color: rgba(124, 92, 255, .55); box-shadow: 0 0 16px rgba(124, 92, 255, .25); }

:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.hint { color: var(--muted); font-size: .9rem; text-align: center; margin: 0; }

/* ---- mobile tuning ---- */
@media (max-width: 480px) {
  .game-bar { gap: 8px; padding: 10px 12px; }
  .game-bar h1 { font-size: .98rem; }
  .game-bar .badge { display: none; }     /* save room for the title on phones */
  .play-actions .btn { padding: 9px 16px; font-size: .9rem; }
}
