:root { --blue: #2fa8ff; --gold: #ffcc1a; --bg: #070b1c; --ui: rgba(8, 12, 28, 0.66); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000; color: #fff; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; overflow: hidden; overscroll-behavior: none; }
#stage { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; background: radial-gradient(ellipse at 50% 30%, #13204a 0%, #050814 70%); touch-action: manipulation; }
#cam { position: fixed; left: 0; top: 0; width: 2px; height: 2px; opacity: 0; pointer-events: none; }

#intro { position: fixed; inset: 0; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); overflow-y: auto;
  background: radial-gradient(circle at 20% 15%, rgba(47, 168, 255, 0.28), transparent 45%), radial-gradient(circle at 85% 85%, rgba(255, 204, 26, 0.22), transparent 45%), var(--bg); z-index: 10; }
#intro[hidden] { display: none; }
.card { width: min(560px, 100%); background: rgba(10, 16, 40, 0.72); border: 1px solid rgba(120, 180, 255, 0.25); border-radius: 22px; padding: clamp(18px, 4vw, 32px); box-shadow: 0 20px 80px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06); backdrop-filter: blur(10px); }
.brand { color: #fff; text-decoration: none; font-weight: 900; letter-spacing: 0.18em; font-size: 13px; opacity: 0.85; }
.brand span { color: var(--gold); }
h1 { font-family: Bangers, Impact, sans-serif; font-weight: 400; margin: 8px 0 6px; line-height: 0.92; letter-spacing: 0.02em; }
h1 .t1 { display: block; font-size: clamp(46px, 12vw, 78px); background: linear-gradient(#fff6bf, #ffd21f 55%, #ff8a00); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 #0a0f2c) drop-shadow(0 0 18px rgba(255, 190, 0, 0.45)); }
h1 .t2 { display: block; font-size: clamp(26px, 6vw, 38px); color: #9fe3ff; filter: drop-shadow(0 0 12px rgba(60, 170, 255, 0.7)); }
.lead { margin: 6px 0 16px; color: #c9d6f5; font-size: 15px; line-height: 1.45; }
.moves { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 10px; }
.moves li { display: flex; gap: 12px; align-items: flex-start; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.07); border-radius: 14px; padding: 10px 12px; }
.moves b { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #48b8ff, #1a5cff); font-weight: 900; }
.moves li:nth-child(3) b { background: linear-gradient(135deg, #ffe066, #ff9a00); color: #1a1200; }
.moves strong { display: block; font-size: 15px; }
.moves span { display: block; color: #b7c4e6; font-size: 13.5px; line-height: 1.4; margin-top: 2px; }
.cta { appearance: none; border: 0; cursor: pointer; font: 800 18px/1 system-ui, sans-serif; letter-spacing: 0.04em; color: #1a1200; padding: 18px 28px; width: 100%; border-radius: 16px; min-height: 56px;
  background: linear-gradient(180deg, #ffe46b, #ffb300); box-shadow: 0 8px 30px rgba(255, 190, 0, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.15); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.cta:disabled { opacity: 0.7; cursor: wait; }
.cta.small { width: auto; flex: 1 1 auto; font-size: 16px; padding: 14px 18px; min-height: 50px; }
.cta.alt { background: linear-gradient(180deg, #7fd0ff, #2f8cff); color: #fff; box-shadow: 0 8px 30px rgba(47, 140, 255, 0.35); }
.cta.ghost { background: rgba(255, 255, 255, 0.1); color: #fff; box-shadow: none; }
.err { background: rgba(255, 70, 70, 0.14); border: 1px solid rgba(255, 90, 90, 0.5); color: #ffd0d0; border-radius: 12px; padding: 10px 12px; font-size: 14px; line-height: 1.4; }
.fine { color: #8d9cc2; font-size: 12.5px; line-height: 1.45; margin: 14px 0 0; }

#loading { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--ui); padding: 14px 20px; border-radius: 14px; border: 1px solid rgba(47, 168, 255, 0.5); z-index: 5; font-weight: 600; }
#loading[hidden] { display: none; }

#controls { position: fixed; z-index: 6; display: flex; gap: 12px; align-items: center; right: max(14px, env(safe-area-inset-right)); top: 50%; transform: translateY(-50%); flex-direction: column; }
#controls[hidden] { display: none; }
.ctl { appearance: none; border: 1px solid rgba(255, 255, 255, 0.22); background: var(--ui); color: #fff; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(8px); padding: 0; touch-action: manipulation; }
.ctl[hidden] { display: none; }
.ctl svg { width: 26px; height: 26px; fill: #fff; stroke: #fff; }
.ctl .slash { display: none; stroke: #ff6262; }
.ctl.off .slash { display: block; }
.ctl.off .wave { display: none; }
.ctl.off { opacity: 0.75; }
.ctl:active { transform: scale(0.94); }
.ctl.rec { width: 72px; height: 72px; border: 3px solid #fff; background: rgba(0, 0, 0, 0.35); }
.ctl.rec span { width: 50px; height: 50px; border-radius: 50%; background: #ff2d3d; transition: all 0.2s; box-shadow: 0 0 18px rgba(255, 45, 61, 0.6); }
.is-rec .ctl.rec span { width: 26px; height: 26px; border-radius: 6px; }
#recBadge { position: fixed; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: none; align-items: center; gap: 8px; background: rgba(0, 0, 0, 0.6); padding: 8px 14px; border-radius: 999px; font: 700 15px/1 ui-monospace, monospace; z-index: 7; }
#recBadge i { width: 12px; height: 12px; border-radius: 50%; background: #ff2d3d; animation: blink 1s infinite; }
.is-rec #recBadge { display: flex; }
@keyframes blink { 50% { opacity: 0.2; } }
#toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); background: var(--ui); border: 1px solid rgba(255, 204, 26, 0.5); padding: 10px 16px; border-radius: 12px; z-index: 8; max-width: min(90vw, 460px); text-align: center; font-size: 14px; }
#toast[hidden] { display: none; }

#result { position: fixed; inset: 0; background: rgba(3, 6, 16, 0.82); z-index: 20; display: grid; place-items: center; padding: 16px; backdrop-filter: blur(6px); }
#result[hidden] { display: none; }
.sheet { width: min(760px, 100%); max-height: 100%; overflow: auto; background: #0b1230; border: 1px solid rgba(120, 180, 255, 0.3); border-radius: 20px; padding: 18px; }
.sheet h2 { margin: 0 0 12px; font-family: Bangers, Impact, sans-serif; font-weight: 400; letter-spacing: 0.04em; font-size: 30px; color: var(--gold); }
#resultMedia video, #resultMedia img { width: 100%; max-height: 60vh; object-fit: contain; border-radius: 12px; background: #000; display: block; }
#resultInfo { color: #9fb0d8; font-size: 13px; margin: 10px 0; word-break: break-all; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

/* portrait phones: controls in a bottom bar, big touch targets */
@media (orientation: portrait) {
  #controls { top: auto; transform: none; right: 0; left: 0; bottom: max(14px, env(safe-area-inset-bottom)); flex-direction: row; justify-content: center; gap: 14px; }
  .ctl { width: 54px; height: 54px; }
  .ctl.rec { width: 74px; height: 74px; order: 0; }
  #btnSound { order: -2; } #btnMic { order: -1; } #btnSnap { order: 1; } #btnSwitch { order: 2; }
}
@media (max-height: 420px) and (orientation: landscape) {
  .ctl { width: 46px; height: 46px; } .ctl.rec { width: 60px; height: 60px; } .ctl.rec span { width: 40px; height: 40px; }
  #controls { gap: 8px; }
}
