/* Camera Games: full-screen camera stage with big, friendly controls (same look as the Music Studio). */
:root {
  --ink: #fff; --muted: #c9c3ef; --panel: rgba(16, 12, 44, .86); --line: rgba(255, 255, 255, .16);
  --gold: #ffc72c; --pink: #ff5fa2; --violet: #8b5cf6; --mint: #34d399; --sky: #38bdf8;
  --head: 'Baloo 2', 'Trebuchet MS', system-ui, sans-serif; --body: 'Nunito', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0820; color: var(--ink); font: 700 16px/1.4 var(--body); }
body { touch-action: none; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
#cam { position: absolute; width: 2px; height: 2px; opacity: 0; pointer-events: none; }
#stage, #hud { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#stage { cursor: crosshair; }
#hud { z-index: 12; pointer-events: none; }

/* ---------- Top bar ---------- */
.cg-top {
  position: fixed; z-index: 20; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  pointer-events: none;
}
.cg-top > * { pointer-events: auto; }
.cg-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 18px; border-radius: 999px;
  background: var(--panel); border: 2px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 900;
  backdrop-filter: blur(8px); box-shadow: 0 6px 16px rgba(0, 0, 0, .35);
}
.cg-pill[hidden] { display: none; }
.cg-pill:hover { border-color: var(--gold); }
.cg-now {
  margin: 0 auto; display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 95, 162, .9), rgba(139, 92, 246, .9)); font: 800 20px/1 var(--head);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35); white-space: nowrap;
}
.cg-now span { font-size: 26px; }
@media (max-width: 640px) {
  .cg-pill { padding: 0 12px; } .cg-pill b { display: none; } .cg-pill span { font-size: 22px; }
  .cg-now { font-size: 16px; padding: 0 14px; } .cg-now span { font-size: 20px; }
}

/* ---------- Score row ---------- */
.cg-stats {
  position: fixed; z-index: 16; left: 50%; top: calc(66px + env(safe-area-inset-top)); transform: translateX(-50%);
  display: flex; gap: 8px; pointer-events: none;
}
.cg-stats[hidden] { display: none; }
.cg-stat {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 999px;
  background: rgba(10, 8, 30, .72); border: 2px solid var(--line); font: 800 20px/1 var(--head); white-space: nowrap;
}
.cg-stat[hidden] { display: none; }
.cg-score b { color: var(--gold); min-width: 2ch; }
.cg-best { color: var(--muted); font-size: 16px; }
.cg-stat.bump { animation: cg-bump .3s; }
.cg-stat.warn { border-color: #ff5f6d; color: #ffd0d4; }
@keyframes cg-bump { 40% { transform: scale(1.18); } }

/* ---------- Hint, steps, toast, colours ---------- */
.cg-hint {
  position: fixed; z-index: 15; left: 50%; top: calc(116px + env(safe-area-inset-top)); transform: translateX(-50%);
  margin: 0; max-width: min(92vw, 640px); padding: 10px 18px; border-radius: 18px; text-align: center;
  background: rgba(10, 8, 30, .72); border: 1px solid var(--line); font-size: 17px; pointer-events: none;
}
.cg-hint:empty { display: none; }
.cg-steps {
  position: fixed; z-index: 15; left: max(14px, env(safe-area-inset-left)); bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; pointer-events: none;
}
.cg-steps[hidden] { display: none; }
.cg-steps li {
  padding: 8px 14px; border-radius: 999px; background: rgba(10, 8, 30, .72); border: 2px solid var(--line);
  font: 800 16px/1 var(--head); color: var(--muted); transition: all .2s;
}
.cg-steps li.on { background: linear-gradient(135deg, var(--pink), var(--violet)); color: #fff; border-color: #fff; transform: scale(1.08); }
.cg-steps li.done { color: var(--mint); }
.cg-toast {
  position: fixed; z-index: 45; left: 50%; top: 42%; transform: translate(-50%, 20px) scale(.9); opacity: 0;
  padding: 14px 24px; border-radius: 999px; background: #fff; color: #1b1240; font: 800 24px/1.1 var(--head);
  transition: opacity .2s, transform .2s; pointer-events: none; text-align: center; max-width: 90vw;
}
.cg-toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.cg-colors {
  position: fixed; z-index: 16; right: max(14px, env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; padding: 8px; border-radius: 999px; background: rgba(10, 8, 30, .72); border: 2px solid var(--line);
}
.cg-colors[hidden] { display: none; }
.cg-swatch {
  width: 44px; height: 44px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .35); padding: 0;
  background: radial-gradient(circle at 35% 30%, #fff, var(--c) 45%, color-mix(in srgb, var(--c) 60%, #000));
  box-shadow: 0 0 14px var(--c);
}
.cg-swatch.on { border-color: #fff; transform: scale(1.15); }
@media (max-width: 640px) { .cg-swatch { width: 36px; height: 36px; } .cg-steps li { font-size: 13px; padding: 6px 10px; } .cg-stat { font-size: 17px; padding: 0 10px; } }

/* ---------- Screens (picker, start, game over, locked) ---------- */
.cg-screen {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 76px 16px 18px; overflow: auto;
  touch-action: pan-y;
  background: radial-gradient(900px 500px at 20% 0%, rgba(255, 95, 162, .35), transparent 60%),
    radial-gradient(900px 600px at 100% 100%, rgba(139, 92, 246, .4), transparent 60%), rgba(11, 8, 32, .96);
}
.cg-screen[hidden] { display: none; }
.cg-screen-see { background: rgba(8, 5, 26, .6); backdrop-filter: blur(3px); }
.cg-picker { width: min(980px, 100%); text-align: center; }
.cg-picker h1, .cg-start-card h1 { margin: 6px 0; font: 800 clamp(34px, 7vw, 58px)/1 var(--head); }
.cg-picker h1 em, .cg-start-card h1 em { font-style: normal; color: var(--gold); }
.cg-lead { color: var(--muted); font-size: 18px; margin: 4px 0 18px; }
.cg-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 18px; }
.cg-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 20px 20px;
  border-radius: 32px; border: 3px solid rgba(255, 255, 255, .55); color: #fff; text-align: center; overflow: hidden;
  box-shadow: 0 10px 0 var(--edge), 0 22px 40px rgba(0, 0, 0, .45); transition: transform .15s;
}
.cg-card:hover { transform: translateY(-4px) rotate(-.6deg); }
.cg-card:active { transform: translateY(4px); box-shadow: 0 4px 0 var(--edge), 0 12px 24px rgba(0, 0, 0, .45); }
.cg-card-spider { --edge: #3b1a7a; background: radial-gradient(circle at 30% 15%, #7c4dff, #4c1d95 60%, #2b0f5c); }
.cg-card-sword { --edge: #0b4a6e; background: radial-gradient(circle at 70% 15%, #38bdf8, #1e3a8a 60%, #10173f); }
.cg-card-armor { --edge: #5a3d08; background: radial-gradient(circle at 50% 15%, #2f4a80, #14203d 60%, #070c1c); text-decoration: none; border-color: rgba(255, 194, 74, .8); }
.cg-core {
  inset: 38px !important; border-radius: 50%; background: radial-gradient(circle, #fff 0 15%, #7ef9ff 35%, rgba(56, 189, 248, 0) 70%);
  animation: cg-glow 1.6s ease-in-out infinite;
}
.cg-card-art { position: relative; display: grid; place-items: center; width: 150px; height: 150px; font-size: 84px; line-height: 1; }
.cg-card-art > * { position: absolute; inset: 0; }
.cg-web {
  border-radius: 50%; opacity: .55;
  background: repeating-radial-gradient(circle, transparent 0 14px, rgba(255, 255, 255, .7) 15px 16px),
    repeating-conic-gradient(from 10deg, transparent 0 28deg, rgba(255, 255, 255, .7) 29deg 30deg);
  -webkit-mask: radial-gradient(circle, #000 55%, transparent 72%); mask: radial-gradient(circle, #000 55%, transparent 72%);
}
.cg-beam {
  inset: 10px 66px !important; border-radius: 99px; background: linear-gradient(#fff, #7dd3fc 30%, #38bdf8);
  box-shadow: 0 0 22px 8px rgba(56, 189, 248, .8), 0 0 60px 20px rgba(56, 189, 248, .4); transform: rotate(35deg);
  animation: cg-glow 1.6s ease-in-out infinite;
}
@keyframes cg-glow { 50% { box-shadow: 0 0 30px 12px rgba(125, 211, 252, .95), 0 0 80px 30px rgba(56, 189, 248, .5); } }
.cg-card b { font: 800 30px/1.05 var(--head); }
.cg-card small { font-size: 15px; font-weight: 800; color: rgba(255, 255, 255, .85); max-width: 34ch; }
.cg-card-best { font-size: 14px; color: var(--gold); min-height: 1.2em; }
.cg-card-go {
  margin-top: 6px; padding: 12px 28px; border-radius: 999px; background: linear-gradient(180deg, #7ef0a8, #1fae52);
  color: #062b14; font: 800 22px/1 var(--head); box-shadow: 0 5px 0 #0a5a26;
}
.cg-start-card {
  width: min(620px, 100%); text-align: center; padding: 26px 24px; border-radius: 32px;
  background: var(--panel); border: 2px solid var(--line); box-shadow: 0 30px 60px rgba(0, 0, 0, .5);
  animation: cg-pop .25s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes cg-pop { from { transform: scale(.92); opacity: 0; } }
.cg-start-art { font-size: clamp(38px, 9vw, 62px); letter-spacing: 6px; animation: cg-bob 2.4s ease-in-out infinite; }
@keyframes cg-bob { 50% { transform: translateY(-8px); } }
.cg-start-card p { color: var(--muted); margin: 8px 0; }
.cg-how { text-align: left; margin: 12px auto 4px; padding: 0; max-width: 470px; list-style: none; counter-reset: how; display: grid; gap: 8px; }
.cg-how li {
  counter-increment: how; display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 16px;
  background: rgba(255, 255, 255, .07); font-size: 15px;
}
.cg-how li::before {
  content: counter(how); flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--gold); color: #2a1700; font: 800 16px/1 var(--head);
}
.cg-start-actions { display: flex; flex-direction: column; gap: 12px; margin: 18px 0 6px; }
.cg-big {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 68px; padding: 0 22px;
  border-radius: 999px; border: 3px solid rgba(255, 255, 255, .6); font: 800 22px/1 var(--head); text-decoration: none;
}
.cg-go { background: linear-gradient(180deg, #7ef0a8, #1fae52); color: #062b14; box-shadow: 0 6px 0 #0a5a26; }
.cg-alt { background: rgba(255, 255, 255, .1); color: var(--ink); }
.cg-big:disabled { opacity: .6; cursor: wait; }
.cg-big:active { transform: translateY(3px); }
.cg-status { min-height: 1.4em; color: var(--gold) !important; }
.cg-small { font-size: 13px; color: var(--muted); }
.cg-link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 8px; font-weight: 800; }
.cg-over-score { font: 800 56px/1 var(--head); color: var(--gold) !important; margin: 4px 0 !important; }
.cg-new { color: var(--mint) !important; font: 800 24px/1.1 var(--head); animation: cg-bump .6s 3; }

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