/*
 * hyLite arcade shell
 * Shared chrome for every browser game on hylitestudios.com. The tokens
 * mirror the main site (deep violet ground, cyan/purple/pink accents,
 * Chakra Petch display type) so a game reads as part of the studio site
 * rather than a separate page. Single dark theme by design: the games are
 * neon-on-dark and have no light variant.
 */
:root {
  color-scheme: dark;
  --bg: #1a1730;
  --bg-deep: #120f22;
  --panel: rgba(45, 38, 78, 0.65);
  --border: rgba(140, 120, 210, 0.28);
  --text: #f2f0f7;
  --muted: #b3adc9;
  --faint: #8f88a8;
  --cyan: #67d7f5;
  --purple: #a057f0;
  --pink: #f472b6;
  --gold: #ffd166;
  --font-display: "Chakra Petch", "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Ambient backdrop: star specks and a receding synth grid, same as the site hero. */
.arcade-backdrop {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,.9), transparent),
    radial-gradient(1px 1px at 80% 15%, rgba(255,255,255,.8), transparent),
    radial-gradient(1.5px 1.5px at 35% 45%, rgba(255,255,255,.9), transparent),
    radial-gradient(1px 1px at 60% 10%, rgba(255,255,255,.7), transparent),
    radial-gradient(1px 1px at 92% 55%, rgba(255,255,255,.8), transparent),
    radial-gradient(1.5px 1.5px at 22% 70%, rgba(255,255,255,.7), transparent),
    radial-gradient(1px 1px at 70% 65%, rgba(255,255,255,.6), transparent),
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(90, 60, 150, .45), transparent 70%),
    var(--bg-deep);
}
.arcade-backdrop::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 32vh;
  background-image:
    linear-gradient(rgba(190, 120, 255, .35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(190, 120, 255, .35) 1px, transparent 1px);
  background-size: 64px 64px;
  transform: perspective(300px) rotateX(62deg);
  transform-origin: bottom;
  -webkit-mask-image: linear-gradient(to top, black 30%, transparent 95%);
  mask-image: linear-gradient(to top, black 30%, transparent 95%);
}

/* Three-row shell: top bar, stage, (touch) controls. Fills the viewport. */
.arcade {
  position: relative; z-index: 1;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: calc(8px + var(--safe-top)) 12px calc(8px + var(--safe-bottom));
  gap: 10px;
  max-width: 1120px;
  margin: 0 auto;
}

/* Top bar */
.arcade-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 44px;
}
.arcade-brand {
  display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text);
}
.arcade-brand img { height: 30px; width: 30px; display: block; }
.arcade-brand b {
  font-family: var(--font-display); font-weight: 700; font-size: 15px; line-height: 1;
  text-transform: uppercase; letter-spacing: .02em;
}
.arcade-brand b small {
  display: block; font-size: 8px; letter-spacing: .24em; color: var(--faint); font-weight: 500; margin-top: 2px;
}
.arcade-hud {
  display: flex; align-items: baseline; gap: 14px;
  font-family: var(--font-display); text-transform: uppercase; letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}
.arcade-hud .hud-score { font-size: 24px; font-weight: 700; color: var(--text); line-height: 1; }
.arcade-hud .hud-best { font-size: 11px; color: var(--faint); font-weight: 600; }
.arcade-hud .hud-best b { color: var(--gold); font-weight: 700; }
.arcade-hud .hud-extra { font-size: 12px; color: var(--cyan); font-weight: 600; }
.arcade-actions { display: flex; gap: 6px; }
.arcade-actions button, .arcade-btn {
  appearance: none; border: 1px solid var(--border); background: var(--panel);
  color: var(--text); width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
  transition: border-color .15s ease, background .15s ease;
}
.arcade-actions button:hover { border-color: rgba(103, 215, 245, .7); }
.arcade-actions button svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.arcade-actions button[aria-pressed="true"] { color: var(--faint); }
.arcade-actions button:focus-visible, .arcade-overlay button:focus-visible, .arcade-controls button:focus-visible {
  outline: 2px solid var(--cyan); outline-offset: 2px;
}

/* Stage: the framed canvas. Gradient border via padding trick, soft glow. */
.arcade-stage {
  position: relative; min-height: 0; border-radius: 18px;
  background: linear-gradient(135deg, rgba(103,215,245,.55), rgba(160,87,240,.55) 55%, rgba(244,114,182,.55));
  padding: 2px;
  box-shadow: 0 0 0 1px rgba(103,215,245,.12), 0 30px 60px -30px rgba(160,87,240,.7);
}
.arcade-stage-inner {
  position: relative; width: 100%; height: 100%; border-radius: 16px; overflow: hidden;
  background: var(--bg-deep);
}
.arcade-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }

/* Overlays: title, pause, game over. */
.arcade-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; text-align: center; padding: 24px 20px;
  background: radial-gradient(ellipse 70% 60% at 50% 30%, rgba(60,40,110,.65), rgba(18,15,34,.86) 75%);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: opacity .25s ease;
}
.arcade-overlay[hidden] { display: none; }
.arcade-overlay .eyebrow {
  font-size: 11px; letter-spacing: .18em; color: var(--pink); font-weight: 600; text-transform: uppercase;
}
.arcade-overlay h1 {
  margin: 0; font-family: var(--font-display); font-weight: 700; text-transform: uppercase;
  font-size: clamp(34px, 7vw, 62px); line-height: 1; letter-spacing: .01em; text-wrap: balance;
  background: linear-gradient(95deg, var(--cyan), var(--purple) 55%, var(--pink));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 24px rgba(160,87,240,.45));
}
.arcade-overlay h2 {
  margin: 0; font-family: var(--font-display); font-weight: 700; text-transform: uppercase;
  font-size: clamp(26px, 5vw, 40px); line-height: 1.05; color: var(--text);
}
.arcade-overlay p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.5; max-width: 42ch; text-wrap: pretty; }
.arcade-overlay .howto {
  display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); max-width: 40ch;
}
.arcade-overlay .howto span { display: flex; gap: 10px; align-items: center; justify-content: center; }
.arcade-overlay kbd {
  font-family: var(--font-display); font-size: 11px; font-weight: 600; letter-spacing: .04em;
  border: 1px solid var(--border); background: rgba(255,255,255,.06); color: var(--text);
  padding: 3px 7px; border-radius: 6px; min-width: 26px; text-align: center;
}
.arcade-overlay .score-block {
  display: flex; gap: 28px; font-family: var(--font-display); text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.arcade-overlay .score-block div { display: flex; flex-direction: column; gap: 4px; }
.arcade-overlay .score-block small { font-size: 11px; letter-spacing: .14em; color: var(--faint); font-weight: 600; }
.arcade-overlay .score-block b { font-size: 40px; line-height: 1; font-weight: 700; color: var(--text); }
.arcade-overlay .score-block b.gold { color: var(--gold); }
.arcade-overlay .badge {
  border: 1px solid rgba(255,209,102,.5); background: rgba(255,209,102,.12); color: var(--gold);
  font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  padding: 6px 14px; border-radius: 999px;
  animation: pop .5s cubic-bezier(.2,1.4,.4,1) both;
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.btn-primary {
  appearance: none; border: 0; cursor: pointer; font-family: var(--font-display); font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; font-size: 15px; color: #fff;
  padding: 14px 32px; border-radius: 12px;
  background: linear-gradient(95deg, #3fb7e0, #8b46e6);
  box-shadow: 0 0 0 1px rgba(103,215,245,.25), 0 10px 28px -8px rgba(160,87,240,.7);
  transition: filter .15s ease, transform .15s ease;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost {
  appearance: none; cursor: pointer; font-family: var(--font-display); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; font-size: 13px; color: var(--text);
  padding: 11px 20px; border-radius: 10px; background: transparent; border: 1px solid rgba(160,150,210,.45);
  text-decoration: none;
}
.btn-ghost:hover { border-color: rgba(103,215,245,.8); color: var(--cyan); }
.overlay-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* Touch controls: hidden on fine-pointer devices, shown as two clusters on touch. */
.arcade-controls { display: none; }
@media (pointer: coarse) {
  .arcade-controls {
    display: flex; justify-content: space-between; align-items: end; gap: 12px; min-height: 96px;
  }
  .arcade-controls:empty { display: none; }
  .arcade-controls .cluster { display: flex; gap: 10px; align-items: end; }
  .arcade-controls .cluster.dpad {
    display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 56px); gap: 6px;
    grid-template-areas: ". up ." "left down right";
  }
  .arcade-controls button {
    appearance: none; border: 1px solid var(--border); background: var(--panel);
    color: var(--text); border-radius: 16px; width: 64px; height: 64px; font-size: 22px;
    font-family: var(--font-display); font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    display: inline-flex; align-items: center; justify-content: center; touch-action: none; padding: 0;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
    transition: background .08s ease, transform .08s ease;
  }
  .arcade-controls .dpad button { width: 56px; height: 56px; border-radius: 12px; }
  .arcade-controls button.big { width: 84px; height: 84px; border-radius: 22px; font-size: 14px; }
  .arcade-controls button.wide { width: 100%; height: 64px; font-size: 15px; }
  .arcade-controls button.accent { background: linear-gradient(135deg, rgba(103,215,245,.35), rgba(160,87,240,.45)); border-color: rgba(103,215,245,.5); }
  .arcade-controls button.hot { background: linear-gradient(135deg, rgba(244,114,182,.4), rgba(160,87,240,.45)); border-color: rgba(244,114,182,.5); }
  .arcade-controls button.pressed, .arcade-controls button:active { transform: scale(.94); background: rgba(103,215,245,.35); }
  .arcade-controls button svg { width: 26px; height: 26px; fill: currentColor; }
  .arcade-controls .cluster.single { width: 100%; }
  .arcade-hud .hud-score { font-size: 20px; }
}
@media (max-width: 480px) {
  .arcade { padding-left: 8px; padding-right: 8px; gap: 8px; }
  .arcade-stage { border-radius: 14px; }
  .arcade-stage-inner { border-radius: 12px; }
  .arcade-overlay p { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .arcade-overlay .badge { animation: none; }
  .btn-primary, .arcade-controls button { transition: none; }
}

/* Floating score toast used by games for combo / bonus text. */
.arcade-toast {
  position: absolute; left: 50%; top: 14%; transform: translate(-50%, 0);
  font-family: var(--font-display); font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  font-size: 18px; color: var(--gold); pointer-events: none; opacity: 0;
  text-shadow: 0 0 18px rgba(255,209,102,.6);
}
.arcade-toast.show { animation: toast 1.1s ease-out forwards; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.9); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.05); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -16px); } }
