/* Shared shell for the Pixels & Purpose mini-games.
   Each game is a standalone page (full viewport) so it can be embedded
   in an <iframe> on games.html or opened in its own window. */

@font-face { font-family: 'Clash Display'; src: url('../assets/fonts/clash-display-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Clash Display'; src: url('../assets/fonts/clash-display-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Satoshi'; src: url('../assets/fonts/satoshi-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Satoshi'; src: url('../assets/fonts/satoshi-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Satoshi'; src: url('../assets/fonts/satoshi-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --g-graphite: #1B1F2A;
  --g-ink: #12141B;
  --g-purple: #7C4DFF;
  --g-lilac: #B8A2FF;
  --g-white: #F5F3FF;
  --g-muted: #A7A3C2;
  --g-gold: #FFC857;
  --g-mint: #3DDC97;
  --g-red: #FF5C7A;
  --g-display: 'Clash Display', 'Segoe UI', system-ui, sans-serif;
  --g-body: 'Satoshi', 'Segoe UI', system-ui, sans-serif;
}

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

#app { position: fixed; inset: 0; overflow: hidden; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

/* ---------- HUD ---------- */
.hud { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 12px 0; pointer-events: none; z-index: 3; }
.hud[hidden], .host[hidden] { display: none; }
.hud-box { background: rgba(18, 20, 27, 0.72); border: 1px solid rgba(184, 162, 255, 0.28); border-radius: 14px; padding: 6px 12px 7px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); min-width: 74px; }
.hud-label { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--g-lilac); font-weight: 700; }
.hud-val { display: block; font-family: var(--g-display); font-weight: 700; font-size: clamp(20px, 4.6vw, 30px); line-height: 1.05; font-variant-numeric: tabular-nums; }
.hud-val small { font-size: 0.55em; color: var(--g-muted); font-weight: 600; }
.hud-mid { flex: 1; max-width: 340px; min-width: 0; }
.hud-right { display: flex; gap: 8px; align-items: flex-start; }
.hud-lives { letter-spacing: 3px; font-size: clamp(16px, 4vw, 22px); line-height: 1.3; white-space: nowrap; }
.hud-lives .off { opacity: 0.22; filter: grayscale(1); }

.meter { height: 12px; border-radius: 99px; background: rgba(255, 255, 255, 0.12); overflow: hidden; margin-top: 5px; }
.meter > i { display: block; height: 100%; width: 0%; border-radius: 99px; background: linear-gradient(90deg, var(--g-purple), var(--g-lilac)); transition: width 0.18s ease-out; }
.meter.hot > i { background: linear-gradient(90deg, var(--g-gold), #fff2c4); animation: meterPulse 0.5s ease-in-out infinite alternate; }
@keyframes meterPulse { from { filter: brightness(1); } to { filter: brightness(1.35); } }

.icon-btn { pointer-events: auto; width: 40px; height: 40px; border-radius: 12px; border: 1px solid rgba(184, 162, 255, 0.28); background: rgba(18, 20, 27, 0.72); color: var(--g-white); font-size: 17px; cursor: pointer; display: grid; place-items: center; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.icon-btn:hover { border-color: var(--g-lilac); }
.icon-btn:focus-visible, .btn-g:focus-visible, .pad-btn:focus-visible { outline: 3px solid var(--g-lilac); outline-offset: 2px; }

/* ---------- Host (Bryan) ---------- */
.host { position: absolute; left: 10px; bottom: max(10px, env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 8px; pointer-events: none; z-index: 3; }
.host-face { width: clamp(58px, 13vw, 92px); aspect-ratio: 1; border-radius: 50%; overflow: hidden; border: 2px solid var(--g-purple); background: radial-gradient(circle at 50% 35%, #3a2a78, var(--g-graphite) 75%); box-shadow: 0 6px 22px rgba(124, 77, 255, 0.45); flex: none; }
.host-face img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; display: block; transform: scale(1.18); transform-origin: 50% 20%; }
.host-say { background: var(--g-white); color: var(--g-graphite); font-weight: 700; font-size: clamp(12px, 3vw, 15px); padding: 7px 12px; border-radius: 14px 14px 14px 4px; max-width: min(56vw, 260px); opacity: 0; transform: translateY(6px) scale(0.96); transition: opacity 0.18s, transform 0.18s; margin-bottom: 14px; }
.host-say.on { opacity: 1; transform: none; }

/* ---------- Toast ---------- */
.toast { position: absolute; left: 50%; top: 24%; transform: translate(-50%, -50%) scale(0.9); font-family: var(--g-display); font-weight: 700; font-size: clamp(22px, 6vw, 44px); text-align: center; color: var(--g-white); text-shadow: 0 4px 24px rgba(124, 77, 255, 0.9), 0 2px 0 rgba(0, 0, 0, 0.4); opacity: 0; pointer-events: none; z-index: 3; white-space: nowrap; transition: opacity 0.2s, transform 0.2s; }
.toast.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.toast small { display: block; font-family: var(--g-body); font-size: 0.42em; font-weight: 700; color: var(--g-lilac); letter-spacing: 0.08em; text-transform: uppercase; white-space: normal; }

/* ---------- Overlay (start / pause / game over) ---------- */
.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at 50% 40%, rgba(27, 31, 42, 0.55), rgba(18, 20, 27, 0.9)); z-index: 5; overflow-y: auto; }
.overlay[hidden] { display: none; }
.overlay.low { place-items: end center; background: linear-gradient(180deg, rgba(18, 20, 27, 0) 30%, rgba(18, 20, 27, 0.82) 78%); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.overlay.low .panel { width: min(520px, 100%); }
.panel { width: min(430px, 100%); background: rgba(27, 31, 42, 0.94); border: 1px solid rgba(184, 162, 255, 0.3); border-radius: 22px; padding: clamp(16px, 4vw, 26px); text-align: center; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(124, 77, 255, 0.15) inset; }
.panel .kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--g-lilac); }
.panel h1 { font-family: var(--g-display); font-weight: 700; font-size: clamp(28px, 7.5vw, 42px); line-height: 1.02; margin: 4px 0 8px; }
.panel h1 em { font-style: normal; color: var(--g-lilac); }
.panel p { color: #d6d2ea; font-size: clamp(13.5px, 3.4vw, 15.5px); line-height: 1.45; }
.panel .how { list-style: none; text-align: left; margin: 12px 0 4px; display: grid; gap: 7px; }
.panel .how li { display: flex; gap: 10px; align-items: center; font-size: clamp(13px, 3.3vw, 14.5px); color: #e6e2f7; }
.panel .how b { flex: none; min-width: 62px; text-align: center; font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 8px; background: rgba(124, 77, 255, 0.22); border: 1px solid rgba(184, 162, 255, 0.35); color: var(--g-white); }
.panel .how .touch-only, .panel .how .key-only { display: none; }
@media (hover: none) and (pointer: coarse) { .panel .how .touch-only { display: flex; } }
@media (hover: hover) and (pointer: fine) { .panel .how .key-only { display: flex; } }

.btn-g { appearance: none; border: 0; cursor: pointer; font-family: var(--g-display); font-weight: 700; font-size: 17px; letter-spacing: 0.02em; color: #fff; background: var(--g-purple); padding: 13px 26px; border-radius: 14px; margin-top: 14px; min-width: 190px; box-shadow: 0 10px 28px rgba(124, 77, 255, 0.45); transition: transform 0.12s, background 0.12s; text-decoration: none; display: inline-block; }
.btn-g:hover { background: #8d63ff; transform: translateY(-1px); }
.btn-g:active { transform: translateY(1px); }
.btn-g.ghost { background: transparent; border: 1px solid rgba(184, 162, 255, 0.45); color: var(--g-lilac); box-shadow: none; font-size: 14px; padding: 10px 18px; min-width: 0; margin-top: 10px; }
.btn-g.ghost:hover { border-color: var(--g-lilac); color: #fff; }
.panel .row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.stats { display: flex; justify-content: center; gap: 10px; margin: 12px 0 2px; }
.stat { flex: 1; max-width: 130px; background: rgba(124, 77, 255, 0.14); border: 1px solid rgba(184, 162, 255, 0.25); border-radius: 14px; padding: 8px 6px; }
.stat span { display: block; font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--g-lilac); }
.stat strong { display: block; font-family: var(--g-display); font-size: clamp(22px, 6vw, 30px); line-height: 1.1; font-variant-numeric: tabular-nums; }
.newbest { display: inline-block; margin-top: 6px; font-weight: 700; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--g-graphite); background: var(--g-gold); padding: 3px 10px; border-radius: 99px; }
.newbest[hidden] { display: none; }
.over-face { width: 96px; height: 96px; border-radius: 50%; overflow: hidden; margin: 0 auto 8px; border: 2px solid var(--g-purple); background: radial-gradient(circle at 50% 35%, #3a2a78, var(--g-graphite) 75%); }
.over-face img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; transform: scale(1.18); transform-origin: 50% 20%; }

.loading { position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%); font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--g-lilac); z-index: 6; pointer-events: none; }
.loading[hidden] { display: none; }

.brand-tag { position: absolute; right: 12px; bottom: max(10px, env(safe-area-inset-bottom)); z-index: 3; display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: rgba(245, 243, 255, 0.7); pointer-events: none; }
.brand-tag img { height: 22px; width: auto; display: block; }

/* small inline frames: drop the blurb so the controls and button always fit */
@media (max-height: 540px) {
  .panel > p { display: none; }
  .panel .how { margin-top: 8px; }
}

@media (max-height: 430px) {
  .panel { padding: 12px 16px; }
  .panel h1 { font-size: 26px; }
  .panel .how { grid-template-columns: 1fr 1fr; }
  .btn-g { margin-top: 8px; padding: 10px 22px; }
  .over-face { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .meter > i, .host-say, .toast { transition: none; }
  .meter.hot > i { animation: none; }
}
