/* ============================================
   OhMyLol — Pulido final
   Base: aurora + zinc + Inter/Space Grotesk
   ============================================ */
:root {
    --bg: #000000;
    --bg-2: #0a0a0a;
    --surface: #141414;
    --surface-hover: #1e1e1e;
    --border: #2a2a2a;
    --text: #ffffff;
    --text-2: #b3b3b3;
    --text-3: #6f6f6f;
    --accent: #c92bf0;
    --accent-hover: #b01fd6;
    --pink: #e06bf5;
    --red: #ff3b6b;
    --green: #22c55e;
    --yellow: #facc15;
    --radius: 16px;
    --radius-sm: 10px;
    --font: 'Inter', -apple-system, system-ui, sans-serif;
    --mono: 'Space Grotesk', var(--font);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* Aurora background */
#bg-canvas { display: none; }
.aurora {
    position: fixed; inset: 0; z-index: 0; overflow: hidden;
    pointer-events: none; filter: blur(80px) saturate(1.2); opacity: .35;
}
.aurora .blob { position: absolute; border-radius: 50%; }
.aurora .b1 { width: 50vw; height: 50vw; background: radial-gradient(circle, var(--accent), transparent 70%); top: -20vw; left: -10vw; animation: d1 20s ease-in-out infinite; }
.aurora .b2 { width: 40vw; height: 40vw; background: radial-gradient(circle, var(--pink), transparent 70%); bottom: -15vw; right: -5vw; animation: d2 24s ease-in-out infinite; }
.aurora .b3 { width: 35vw; height: 35vw; background: radial-gradient(circle, #06b6d4, transparent 70%); top: 40%; left: 50%; opacity: .5; animation: d3 28s ease-in-out infinite; }
@keyframes d1 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(6vw,8vh)} }
@keyframes d2 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-8vw,-6vh)} }
@keyframes d3 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-5vw,5vh)} }
.grain { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .025;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.8'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.danger-vignette { position: fixed; inset: 0; z-index: 50; pointer-events: none; opacity: 0; transition: opacity .2s; box-shadow: inset 0 0 120px 20px rgba(244,63,94,.4); }

/* App shell */
.app { position: relative; z-index: 1; height: 100dvh; display: flex; flex-direction: column; }

/* Old header removed */
.topbar { display: none; }
.icon-btn {
    width: 34px; height: 34px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-2); font-size: .9rem;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all .12s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }

/* Top row: brand · carousel · filters · menu */
.topbar-row {
    flex-shrink: 0;
    display: flex; align-items: center; gap: .9rem;
}
.brand-name {
    flex-shrink: 0;
    font-family: var(--mono); font-weight: 700;
    font-size: 1.05rem; letter-spacing: -.5px;
    display: flex; align-items: center; gap: .4rem;
    padding-right: .3rem;
}
.brand-logo { height: 112px; width: auto; border-radius: 18px; display: block; box-shadow: 0 4px 20px rgba(201,43,240,.35); }
.menu-trigger { flex-shrink: 0; }

/* Filter selectors (category + sort) */
.carousel-selectors { display: flex; gap: .4rem; flex-shrink: 0; }
.sel-wrap {
    display: flex; align-items: center; gap: .35rem;
    height: 46px; padding: 0 .5rem 0 .7rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    cursor: pointer; transition: border-color .15s;
}
.sel-wrap:hover { border-color: var(--accent); }
.sel-ic { font-size: .85rem; opacity: .7; }
.sel {
    appearance: none; -webkit-appearance: none;
    background: transparent; border: none; outline: none;
    color: var(--text); font-family: var(--font); font-size: .78rem; font-weight: 600;
    cursor: pointer; padding-right: .8rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23a1a1aa' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right center;
}
.sel option { background: var(--bg-2, #111); color: var(--text); }

/* Stage — fills the entire screen */
.stage {
    flex: 1; display: flex; flex-direction: column;
    justify-content: space-between;
    gap: clamp(.6rem, 1.5vh, 1rem);
    padding: clamp(.6rem, 1.5vh, 1rem) clamp(.75rem, 2vw, 1.25rem) clamp(1rem, 2.5vh, 1.6rem);
    min-height: 0; overflow: hidden;
    width: 100%;
    position: relative;
}
.topbar-row { flex-shrink: 0; }
.stage-grid { flex: 0 1 auto; }
.wave-row { flex-shrink: 0; }

/* Carousel */
.carousel-section { display: none; }
.carousel-track-wrap { flex: 1; overflow: hidden; min-width: 0; }
.carousel-track {
    display: flex; gap: .45rem; overflow-x: auto; scroll-snap-type: x mandatory;
    scrollbar-width: none; padding: 2px 0;
}
.carousel-track::-webkit-scrollbar { display: none; }
.drawer-toggles { display: flex; gap: .4rem; margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.car-card {
    flex-shrink: 0; width: 168px; scroll-snap-align: start;
    border-radius: 12px; overflow: hidden;
    cursor: pointer; transition: transform .18s, box-shadow .18s;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.car-card:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.car-card.active { box-shadow: 0 0 0 2px var(--accent), 0 8px 24px rgba(201,43,240,.35); }
.car-thumb { position: relative; }
.car-thumb img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
/* Title as gradient overlay on the thumbnail */
.car-info {
    position: absolute; left: 0; right: 0; bottom: 0;
    padding: .8rem .45rem .3rem;
    background: linear-gradient(transparent, rgba(0,0,0,.85));
    pointer-events: none;
}
.car-title { font-size: .58rem; font-weight: 500; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.car-author { display: none; }
.car-dur {
    position: absolute; top: 4px; right: 4px;
    font-family: var(--mono); font-size: .52rem; font-weight: 600;
    padding: .1rem .3rem; border-radius: 4px;
    background: rgba(0,0,0,.7); backdrop-filter: blur(4px); color: #fff;
}

/* Two screens side by side + vertical progress in the middle */
.stage-grid {
    flex: 1; display: grid; grid-template-columns: 1fr 34px 1fr;
    gap: .75rem; min-height: 0; align-items: stretch;
}
.media { justify-content: stretch; }

/* Vertical progress bar between windows (top → bottom) */
.mid-progress {
    display: flex; flex-direction: column; align-items: center; gap: .4rem;
    padding: .2rem 0;
}
.mid-track {
    flex: 1; width: 16px; border-radius: 999px;
    background: rgba(255,255,255,.07);
    overflow: hidden; position: relative;
    box-shadow: inset 0 0 8px rgba(0,0,0,.5), inset 0 0 0 1px var(--border);
}
.mid-fill {
    position: absolute; top: 0; left: 0; right: 0; height: 0%;
    background: linear-gradient(180deg, var(--accent), var(--pink));
    box-shadow: 0 0 12px rgba(201,43,240,.6);
    transition: height .9s linear, background .3s;
    border-radius: 999px;
}
.mid-time {
    font-family: var(--mono); font-size: .62rem; font-weight: 700;
    color: var(--accent); writing-mode: horizontal-tb;
}

/* Hide the old corner ring (replaced by mid bar) */
.survival { display: none !important; }
.media { display: flex; flex-direction: column; gap: clamp(.7rem, 2.2vh, 1.6rem); min-height: 0; }
.video-frame {
    position: relative; flex: 1; min-height: 0;
    border-radius: 20px; overflow: hidden;
    background: #000;
    box-shadow:
        0 0 0 1px var(--border),
        0 24px 50px -24px rgba(0,0,0,.85),
        inset 0 1px 0 rgba(255,255,255,.05);
    transition: box-shadow .3s;
}
.video-frame.fixed-frame { flex: 1; min-height: 0; width: 100%; }
.media-camera .video-frame.laughing { box-shadow: 0 0 0 1px var(--red), 0 0 45px -8px rgba(244,63,94,.6); }
.video-frame video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.video-frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; transform: scaleX(-1); pointer-events: none; }

/* Overscan the YouTube iframe to crop its chrome (title, share, related, logo)
   so only the video image shows. */
.media-video .video-frame { overflow: hidden; }
.media-video .video-frame iframe {
    position: absolute; top: 50%; left: 50%;
    width: 100%; height: 100%;
    transform: translate(-50%, -50%) scale(1.7);
    transform-origin: center center;
    border: 0;
    pointer-events: none; /* prevent YouTube UI on hover; we use our own controls */
}

/* Overlay that masks YouTube's big center play button when paused */
.paused-overlay { position: absolute; inset: 0; z-index: 5; cursor: pointer; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); }
.paused-overlay[hidden] { display: none; }
.po-play { width: 74px; height: 74px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; color: #fff; padding-left: 5px; background: linear-gradient(135deg, var(--accent), var(--accent-hover)); box-shadow: 0 8px 30px rgba(201,43,240,.55); transition: transform .15s; }
.paused-overlay:hover .po-play { transform: scale(1.08); }

.media-placeholder { position: absolute; inset:0; z-index:3; display:flex; flex-direction: column; gap: .5rem; align-items:center; justify-content:center;
    background: radial-gradient(ellipse at 50% 35%, #1a1a20, #0d0d10); border-radius: 20px; }
.media-placeholder.hidden { display: none; }
.ph-icon { font-size: 2.4rem; opacity: .5; animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }
.cam-ph, .vid-ph { flex-direction: column; gap: 1rem; }
.cam-privacy { max-width: 320px; text-align: center; font-size: .8rem; color: var(--text-2); line-height: 1.45; margin-top: -.2rem; }
.cam-ph-icon, .vid-ph-icon { width: 110px; height: auto; filter: drop-shadow(0 0 20px rgba(201,43,240,.35)); animation: float 2.4s ease-in-out infinite; }
.cam-start { padding: .6rem 1.4rem; border-radius: 999px; border: none; background: var(--accent); color: #fff; font-size: .85rem; font-weight: 700; cursor: pointer; transition: all .2s; box-shadow: 0 4px 16px rgba(201,43,240,.4); }
.cam-start:hover { background: var(--accent-hover); transform: scale(1.04); box-shadow: 0 6px 20px rgba(201,43,240,.55); }
.face-indicator { position: absolute; top: 10px; left: 10px; z-index: 4; display: flex; align-items: center; gap: .3rem; padding: .15rem .4rem; background: rgba(0,0,0,.5); border-radius: 999px; }
.face-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
.face-dot.active { background: var(--green); }

/* Media controls: URL input under video — full width of the video column */
.media-controls { display: flex; gap: .3rem; align-items: center; height: 36px; flex-shrink: 0; }
.media-controls.center { justify-content: center; }
.media-controls { gap: .4rem; height: 40px; }
.media-controls input { flex:1; height:40px; padding: 0 .8rem; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; color: var(--text); font-size: .8rem; outline: none; }
.media-controls input:focus { border-color: var(--accent); }
.media-controls input::placeholder { color: var(--text-3); }
.pill-btn { width: 36px; height: 36px; flex-shrink:0; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; cursor: pointer; font-size: .85rem; transition: background .12s; }
.pill-btn:hover { background: var(--surface-hover); }

/* Level slider — PRO */
.media-camera .media-controls.center { justify-content: stretch; }
.level-bar {
    display: flex; align-items: center; gap: .7rem; height: 40px; width: 100%;
    padding: 0 1rem;
    background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0));
    border: 1px solid var(--border); border-radius: 12px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.level-label {
    font-family: var(--mono); font-size: .8rem; font-weight: 700;
    letter-spacing: 2px; color: var(--text-2); flex-shrink: 0;
}
/* Custom track: emoji thumb, edges aligned */
.level-track-wrap { position: relative; flex: 1; display: flex; align-items: center; height: 100%; }
/* Inner track inset so the emoji stays inside at extremes */
.level-track { position: relative; flex: 1; height: 100%; margin: 0 12px; }
.level-line {
    position: absolute; top: 50%; left: 0; right: 0; transform: translateY(-50%);
    height: 5px; border-radius: 3px; background: rgba(255,255,255,.08);
}
.level-fill {
    position: absolute; top: 50%; left: 0; transform: translateY(-50%);
    height: 5px; border-radius: 3px; width: 33%;
    background: linear-gradient(90deg, var(--accent), var(--pink));
    transition: width .18s cubic-bezier(.2,.8,.2,1);
}
.level-ticks {
    position: absolute; inset: 0; display: flex; justify-content: space-between;
    align-items: center; pointer-events: none;
}
.level-ticks i { width: 4px; height: 4px; border-radius: 50%; background: rgba(255,255,255,.25); }
.level-thumb {
    position: absolute; top: 50%; left: 33%;
    transform: translate(-50%, -50%);
    font-size: 1.35rem; line-height: 1; pointer-events: none;
    filter: drop-shadow(0 0 8px rgba(201,43,240,.6)) drop-shadow(0 2px 4px rgba(0,0,0,.5));
    transition: left .18s cubic-bezier(.2,.8,.2,1), transform .12s;
    z-index: 3;
}
/* Native input: invisible, sits on top for dragging */
.level-bar input[type="range"] {
    position: absolute; inset: 0; z-index: 4;
    width: 100%; height: 100%; margin: 0;
    -webkit-appearance: none; appearance: none;
    background: transparent; cursor: pointer; outline: none; opacity: 0;
}
.level-bar input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 40px; height: 40px; cursor: pointer; }
.level-bar input[type="range"]::-moz-range-thumb { width: 40px; height: 40px; border: none; background: transparent; cursor: pointer; }
.level-bar:hover .level-thumb { transform: translate(-50%, -50%) scale(1.15); }

.level-name {
    font-family: var(--mono); font-size: .8rem; font-weight: 700;
    letter-spacing: 1px; text-transform: uppercase;
    color: var(--accent); flex-shrink: 0; min-width: 64px; text-align: right;
}

.neon-controls, .video-credit, .pill-btn { display: none; }
.hint-flow, .level-control, .privacy-note { display: none; }

/* ===== Control buttons — clear & premium ===== */
.ctrl-btn {
    height: 40px; min-width: 40px; padding: 0 .6rem;
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    border-radius: 11px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, var(--surface-hover), var(--surface));
    color: var(--text); font-size: .8rem; font-weight: 600;
    cursor: pointer; transition: all .15s;
    box-shadow: 0 1px 2px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.05);
}
.ctrl-btn .ci { font-size: 1.85rem; line-height: 1; }
.ctrl-btn:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.35); }
.ctrl-btn:active { transform: translateY(0); }

/* Primary = play/pause, stands out */
.ctrl-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border: none; color: #fff;
    box-shadow: 0 4px 14px rgba(201,43,240,.4);
}
.ctrl-primary:hover { box-shadow: 0 6px 18px rgba(201,43,240,.55); border: none; }

/* Load = labeled text button */
.ctrl-text { font-family: var(--font); }

/* YouTube = brand red with label */
.ctrl-yt {
    background: linear-gradient(135deg, #ff0033, #cc0029);
    border: none; color: #fff;
    font-family: var(--font); font-weight: 700;
    box-shadow: 0 4px 14px rgba(255,0,51,.3);
}
.ctrl-yt:hover { box-shadow: 0 6px 18px rgba(255,0,51,.45); border: none; }

/* Wave panel — the hero: full width, glassy, prominent */
.wave-row { flex-shrink: 0; }
.wave-panel {
    display: flex; align-items: center; gap: 1.5rem;
    padding: 1.1rem 1.5rem;
    background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0));
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 12px 40px -20px rgba(0,0,0,.7);
    backdrop-filter: blur(8px);
}
.wave-readout { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }
.reaction-face { font-size: 3rem; transition: transform .12s, filter .12s; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
.big-pct {
    font-family: var(--mono); font-weight: 700;
    font-size: 3.2rem; line-height: 1; min-width: 110px;
    background: linear-gradient(135deg, var(--accent), var(--pink));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    transition: filter .2s;
}
.big-pct small { font-size: .35em; -webkit-text-fill-color: var(--text-3); }
.big-pct.warning { background: linear-gradient(135deg, var(--yellow), #f97316); -webkit-background-clip: text; background-clip: text; }
.big-pct.danger { background: linear-gradient(135deg, var(--red), #dc2626); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 0 12px rgba(244,63,94,.5)); }
.face-ladder { display: flex; gap: .25rem; flex-shrink: 0; align-items: center; }
.face-ladder span { font-size: .9rem; opacity: .18; transition: all .12s; line-height: 1; }
.face-ladder span.lit { opacity: .55; }
.face-ladder span.current { opacity: 1; transform: scale(1.35) translateY(-1px); }
.wave-holder {
    flex: 1; height: clamp(90px, 16vh, 130px); min-width: 0;
    border-radius: 16px; overflow: hidden;
    background: rgba(0,0,0,.25);
    box-shadow: inset 0 0 20px -8px rgba(0,0,0,.6);
}
.wave-holder canvas { width: 100%; height: 100%; display: block; }

/* Legacy / hidden */
.legacy-meter { position: absolute; width:0; height:0; overflow:hidden; opacity:0; pointer-events:none; }

/* Loading */
.loading-screen { position:fixed; inset:0; z-index:9999; background: var(--bg); display:flex; align-items:center; justify-content:center; transition: opacity .4s, visibility .4s; }
.loading-screen.hidden { opacity:0; visibility:hidden; }
.loader-content { text-align:center; }
.loader-emoji { font-size: 2.5rem; animation: float 1.2s ease-in-out infinite; }
.loader-logo { width: 120px; height: 120px; border-radius: 24px; animation: float 1.4s ease-in-out infinite; box-shadow: 0 10px 40px rgba(201,43,240,.35); }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }
.loader-bar { width: 120px; height: 2px; background: var(--surface); border-radius:1px; margin: 1rem auto 0; overflow:hidden; }
.loader-fill { height:100%; width:0; background: var(--accent); transition: width .3s; }
.loader-text { margin-top:.4rem; color: var(--text-3); font-size:.65rem; }

/* ===== Onboarding (premium intro) ===== */
.onboarding {
    position: fixed; inset: 0; z-index: 8000; display: none;
    align-items: center; justify-content: center;
    background:
        radial-gradient(ellipse at 50% 30%, rgba(201,43,240,.22), transparent 60%),
        rgba(0,0,0,.86);
    backdrop-filter: blur(16px);
}
.onboarding.show { display: flex; animation: fadeIn .35s ease; }
.onb-card {
    position: relative; text-align: center; max-width: 560px; width: 92%;
    padding: clamp(2rem, 5vw, 3.25rem) clamp(1.5rem, 4vw, 2.5rem);
    border-radius: 30px;
    background:
        linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0)) padding-box,
        linear-gradient(135deg, rgba(201,43,240,.7), rgba(224,107,245,.25), transparent 70%) border-box;
    border: 1.5px solid transparent;
    box-shadow: 0 40px 120px rgba(0,0,0,.7), 0 0 60px -20px rgba(201,43,240,.5);
    animation: onbPop .5s cubic-bezier(.2,.8,.2,1);
}
@keyframes onbPop { from { opacity:0; transform: translateY(16px) scale(.96); } to { opacity:1; transform: none; } }
.onb-logo {
    width: 132px; height: 132px; border-radius: 26px; margin: 0 auto .9rem; display: block;
    box-shadow: 0 12px 44px rgba(201,43,240,.45);
    animation: onbFloat 3s ease-in-out infinite;
}
@keyframes onbFloat { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
.onb-emoji { display: none; }
.onb-title { display: none; }
.onb-sub {
    font-family: var(--mono); font-weight: 700;
    font-size: clamp(1.15rem, 3.5vw, 1.55rem); color: var(--text);
    margin-bottom: 2rem; line-height: 1.3;
}
.onb-steps { display: flex; align-items: stretch; justify-content: center; gap: .75rem; margin-bottom: 2.25rem; }
.onb-step {
    flex: 1; max-width: 150px; position: relative;
    padding: 1.4rem .6rem 1rem;
    background: rgba(255,255,255,.03);
    border: 1px solid var(--border); border-radius: 18px;
    transition: transform .2s, border-color .2s, box-shadow .2s;
}
.onb-step:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 10px 30px rgba(201,43,240,.2); }
.onb-ic { font-size: 2.4rem; display: block; margin-bottom: .5rem; filter: drop-shadow(0 0 10px rgba(201,43,240,.4)); }
.onb-num {
    position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
    width: 26px; height: 26px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--pink)); color: #fff;
    font-family: var(--mono); font-size: .75rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(201,43,240,.5);
}
.onb-step p { font-size: .8rem; font-weight: 600; color: var(--text); }
.onb-arrow { display: flex; align-items: center; color: var(--accent); font-size: 1.2rem; opacity: .6; }
.onb-start {
    padding: .95rem 3rem; border: none; border-radius: 999px; cursor: pointer;
    font-size: 1.05rem; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    box-shadow: 0 10px 30px rgba(201,43,240,.5);
    transition: transform .18s, box-shadow .18s;
    animation: onbPulse 2.2s ease-in-out infinite;
}
.onb-start:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 14px 40px rgba(201,43,240,.65); }
@keyframes onbPulse { 0%,100%{box-shadow:0 10px 30px rgba(201,43,240,.5)} 50%{box-shadow:0 10px 44px rgba(201,43,240,.8)} }
.onb-privacy { margin-top: 1.25rem; font-size: .72rem; color: var(--text-3); max-width: 380px; margin-left: auto; margin-right: auto; line-height: 1.4; }
@media (max-width: 520px) {
    .onb-steps { flex-direction: column; align-items: center; }
    .onb-step { max-width: none; width: 100%; }
    .onb-arrow { transform: rotate(90deg); }
}

/* Result */
.result-overlay { position:fixed; inset:0; z-index:1000; display:none; align-items:center; justify-content:center; background: rgba(9,9,11,.9); backdrop-filter: blur(6px); }
.result-overlay.active { display:flex; }
#confetti-canvas { position:absolute; inset:0; pointer-events:none; }
.result-card { position:relative; z-index:1; text-align:center; padding: 1.75rem 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; max-width: 380px; width:90%; }
.result-close { position:absolute; top:.6rem; right:.6rem; width:28px; height:28px; border-radius:50%; border:1px solid var(--border); background:transparent; color: var(--text-3); font-size:.8rem; cursor:pointer; display:flex; align-items:center; justify-content:center; }
.result-close:hover { background: var(--surface-hover); }
.result-top { margin-bottom:.75rem; }
.result-emoji { font-size:2.5rem; }
.result-card h2 { font-family: var(--mono); font-size:1.2rem; font-weight:700; margin-top:.2rem; }
.result-capture { margin-bottom:.75rem; }
.result-capture img { width:100%; max-width:240px; border-radius: var(--radius-sm); display:none; }
.result-capture img.show { display:inline-block; }
.capture-shine { display:none; }
.result-stats { display:flex; justify-content:center; gap:1.5rem; margin-bottom:.75rem; }
.result-stat { text-align:center; }
.rs-value { display:block; font-family: var(--mono); font-size:1.1rem; font-weight:700; }
.rs-label { font-size:.65rem; color: var(--text-3); }
.result-details { display: flex; justify-content: center; gap: 2rem; margin-bottom: .9rem; }
.rd-item { display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.rd-value { font-family: var(--mono); font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.rd-label { font-size: .68rem; color: var(--text-3); }
.result-suggestion {
    margin: 0 auto 1rem; max-width: 300px;
    padding: .7rem 1rem; border-radius: 14px;
    background: rgba(201,43,240,.1); border: 1px solid rgba(201,43,240,.3);
    color: var(--text); font-size: .85rem; font-weight: 600; line-height: 1.35;
}
.result-achievements { margin-bottom:.6rem; }
.result-actions { display:flex; gap:.4rem; justify-content:center; }
.action-btn { display:inline-flex; align-items:center; gap:.3rem; padding:.5rem 1rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size:.78rem; font-weight:600; cursor:pointer; transition: all .12s; }
.action-btn:hover { background: var(--surface-hover); }
.action-btn .ab-icon { font-size:.85rem; }
.action-btn.primary { border:none; background: var(--accent); color:#fff; }
.action-btn.primary:hover { background: var(--accent-hover); }
.action-btn.ghost { border-color:transparent; color: var(--text-3); }

/* Drawer / Panels */
.drawer-backdrop { position:fixed; inset:0; z-index:400; background: rgba(0,0,0,.5); opacity:0; visibility:hidden; transition: all .2s; }
.drawer-backdrop.open { opacity:1; visibility:visible; }
.drawer { position:fixed; top:0; right:0; z-index:401; width:250px; max-width:80vw; height:100%; background: var(--bg); border-left: 1px solid var(--border); transform:translateX(100%); transition: transform .2s; display:flex; flex-direction:column; padding:1rem; }
.drawer.open { transform:translateX(0); }
.drawer-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:.8rem; }
.drawer-title { font-family: var(--mono); font-weight:700; font-size:.85rem; }
.drawer-nav { display:flex; flex-direction:column; gap:.2rem; flex:1; }
.nav-btn { display:flex; align-items:center; gap:.5rem; padding:.5rem .6rem; border:none; background:none; color: var(--text-2); border-radius: 8px; cursor:pointer; font-size:.78rem; text-align:left; transition: all .1s; }
.nav-btn:hover { background: var(--surface); color: var(--text); }
.drawer-foot { display:flex; justify-content:space-around; padding-top:.5rem; border-top: 1px solid var(--border); }
.drawer-foot a { font-size:.85rem; text-decoration:none; opacity:.3; }
.drawer-foot a:hover { opacity:.7; }

.panel-view { position:fixed; inset:0; z-index:350; display:none; background: var(--bg); padding: 3rem 1.25rem 2rem; overflow-y:auto; }
.panel-view.active { display:block; }
.view-close { position:fixed; top:.6rem; right:.6rem; z-index:5; width:30px; height:30px; border-radius:50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size:.85rem; cursor:pointer; display:flex; align-items:center; justify-content:center; }
.gallery-search { display:flex; align-items:center; gap:.4rem; max-width:340px; margin:0 auto .8rem; padding:.5rem .7rem; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.gs-icon { opacity:.4; }
#gallery-search-input { flex:1; background:none; border:none; outline:none; color: var(--text); font-size:.8rem; }
#gallery-search-input::placeholder { color: var(--text-3); }
.gallery-categories { display:flex; gap:.2rem; justify-content:center; margin-bottom:.8rem; }
.cat-btn { width:34px; height:34px; border-radius:50%; border: 1px solid var(--border); background:transparent; cursor:pointer; font-size:.85rem; opacity:.35; transition: all .12s; }
.cat-btn:hover, .cat-btn.active { opacity:1; border-color: var(--accent); }
.gallery-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap:.5rem; max-width:640px; margin:0 auto; }
.gallery-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow:hidden; cursor:pointer; transition: all .15s; }
.gallery-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.gallery-thumb-wrap { position:relative; overflow:hidden; }
.gallery-thumb { width:100%; aspect-ratio: 16/9; object-fit:cover; display:block; }
.gallery-play { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-size:1.3rem; color:#fff; opacity:0; background: rgba(0,0,0,.35); transition: opacity .15s; }
.gallery-card:hover .gallery-play { opacity:1; }
.gallery-badge { position:absolute; top:4px; right:4px; padding:.1rem .3rem; border-radius:3px; background: rgba(0,0,0,.7); font-family: var(--mono); font-size:.5rem; color: var(--accent); }
.gallery-info { padding:.35rem .45rem; }
.gallery-title { font-size:.6rem; color: var(--text-2); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.gallery-meta { display:none; }

.leaderboard-tabs { display:flex; gap:.2rem; justify-content:center; margin-bottom:.7rem; }
.lb-tab { width:34px; height:30px; border-radius:8px; border: 1px solid var(--border); background:transparent; cursor:pointer; font-size:.8rem; opacity:.35; }
.lb-tab:hover, .lb-tab.active { opacity:1; border-color: var(--accent); }
.leaderboard-list, .leaderboard-you { max-width:400px; margin:0 auto; }
.lb-entry { display:flex; align-items:center; gap:.4rem; padding:.4rem .6rem; margin-bottom:.2rem; background: var(--surface); border: 1px solid var(--border); border-radius:8px; font-size:.7rem; }
.lb-rank { font-family: var(--mono); font-weight:700; width:22px; color: var(--text-3); }
.lb-rank.gold { color:#ffd700; } .lb-rank.silver { color:#888; } .lb-rank.bronze { color:#a0522d; }
.lb-name { flex:1; } .lb-score { font-family: var(--mono); font-weight:700; color: var(--accent); }
.achievements-progress { max-width:220px; margin:0 auto .7rem; text-align:center; }
.ach-progress-bar { height:3px; background: var(--surface); border-radius:2px; overflow:hidden; margin-bottom:.2rem; }
.ach-progress-fill { height:100%; background: var(--accent); width:0; }
#ach-progress-text { font-size:.6rem; color: var(--text-3); }
.achievements-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap:.4rem; max-width:620px; margin:0 auto; }
.achievement-card { display:flex; gap:.4rem; align-items:center; padding:.5rem; background: var(--surface); border: 1px solid var(--border); border-radius:8px; opacity:.25; }
.achievement-card.unlocked { opacity:1; border-color: rgba(201,43,240,.25); }
.ach-icon { font-size:1.2rem; } .ach-name { font-weight:600; font-size:.68rem; } .ach-desc { font-size:.55rem; color: var(--text-3); } .ach-date { font-size:.5rem; color: var(--accent); }
.stats-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap:.4rem; max-width:460px; margin:0 auto .7rem; }
.stat-card { padding:.7rem; background: var(--surface); border: 1px solid var(--border); border-radius:8px; text-align:center; }
.stat-card-icon { font-size:1rem; } .stat-card-value { font-family: var(--mono); font-size:1rem; font-weight:700; color: var(--accent); }
.history-list { max-width:400px; margin:0 auto; }
.history-entry { display:flex; justify-content:space-between; padding:.35rem .5rem; margin-bottom:.2rem; background: var(--surface); border: 1px solid var(--border); border-radius:6px; font-size:.65rem; }
.history-time { color: var(--accent); font-family: var(--mono); } .history-date, .history-diff { color: var(--text-3); }
.empty-state { text-align:center; color: var(--text-3); padding:1.5rem; font-size:.75rem; }

/* Modal / Toast / Consent */
.modal { position:fixed; inset:0; z-index:3000; display:none; align-items:center; justify-content:center; background: rgba(0,0,0,.8); }
.modal.active { display:flex; }
.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding:1.5rem; max-width:320px; width:90%; text-align:center; position:relative; }
.modal-close { position:absolute; top:.5rem; right:.6rem; background:none; border:none; color: var(--text-3); font-size:1.1rem; cursor:pointer; }
.share-preview { margin-bottom:1rem; } .share-result { color: var(--text-2); font-size:.72rem; }
.share-buttons { display:flex; gap:.3rem; justify-content:center; }
.share-social { width:36px; height:36px; border-radius:50%; border: 1px solid var(--border); background:transparent; color: var(--text); font-size:.9rem; cursor:pointer; }
.share-social:hover { background: var(--surface); }
.toast-container { position:fixed; top:56px; left:50%; transform:translateX(-50%); z-index:2000; display:flex; flex-direction:column; gap:.3rem; align-items:center; }
.toast { display:flex; align-items:center; gap:.3rem; padding:.35rem .6rem; background: var(--surface); border: 1px solid var(--border); border-radius:999px; font-size:.65rem; animation: ti .2s ease, to .2s ease 2.2s forwards; }
@keyframes ti { from{opacity:0;transform:translateY(-5px)} to{opacity:1;transform:translateY(0)} }
@keyframes to { to{opacity:0;transform:translateY(-5px)} }
.toast-icon { font-size:.8rem; } .toast-text { font-weight:600; } .toast-sub { color: var(--text-3); }
.consent-banner { position:fixed; bottom:0; left:0; width:100%; z-index:5000; display:flex; align-items:center; justify-content:center; gap:.5rem; padding:.6rem 1rem; background: var(--surface); border-top: 1px solid var(--border); }
.consent-text { font-size:.65rem; color: var(--text-2); } .consent-text a { color: var(--accent); }
.consent-actions { display:flex; gap:.3rem; }
.btn-primary { padding:.3rem .7rem; background: var(--accent); color:#fff; border:none; border-radius:999px; font-weight:600; font-size:.65rem; cursor:pointer; }
.btn-secondary { padding:.3rem .7rem; background:none; color: var(--text-2); border: 1px solid var(--border); border-radius:999px; font-size:.65rem; cursor:pointer; }

/* Responsive */
@media (max-width: 768px) {
    body { overflow: auto; }
    .app { height: auto; min-height: 100dvh; }
    .stage-grid { grid-template-columns: 1fr; }
}

/* Utility */
.app.shake { animation: shake .18s linear infinite; }
@keyframes shake { 0%,100%{transform:translate(0)} 50%{transform:translate(1px,-1px)} }
.visually-hidden { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); }
@media (prefers-reduced-motion: reduce) { * { animation:none!important; transition:none!important; } }
::selection { background: rgba(201,43,240,.3); }

/* ============================================
   TENSION SYSTEM — dopamine escalation
   ============================================ */

/* Pulsing ring around the whole app, intensity by zone */
.tension-ring {
    position: fixed; inset: 0; z-index: 45; pointer-events: none;
    opacity: 0; transition: opacity .3s;
    box-shadow: inset 0 0 0 3px transparent;
}
.tension-ring.warn {
    opacity: 1;
    box-shadow: inset 0 0 80px -20px rgba(234,179,8,.5), inset 0 0 0 2px rgba(234,179,8,.3);
    animation: tensionPulse 1s ease-in-out infinite;
}
.tension-ring.hot {
    opacity: 1;
    box-shadow: inset 0 0 100px -20px rgba(249,115,22,.6), inset 0 0 0 3px rgba(249,115,22,.4);
    animation: tensionPulse .6s ease-in-out infinite;
}
.tension-ring.danger {
    opacity: 1;
    box-shadow: inset 0 0 140px -20px rgba(244,63,94,.75), inset 0 0 0 4px rgba(244,63,94,.5);
    animation: tensionPulse .32s ease-in-out infinite;
}
@keyframes tensionPulse {
    0%,100% { filter: brightness(1); }
    50% { filter: brightness(1.6); }
}

/* Screen shake tiers */
.app.shake-soft { animation: shakeSoft .12s linear infinite; }
.app.shake-hard { animation: shakeHard .09s linear infinite; }
@keyframes shakeSoft { 0%,100%{transform:translate(0)} 50%{transform:translate(.5px,-.5px)} }
@keyframes shakeHard {
    0%{transform:translate(0)} 20%{transform:translate(-2px,1px)} 40%{transform:translate(2px,-1px)}
    60%{transform:translate(-1px,-1px)} 80%{transform:translate(1px,1px)} 100%{transform:translate(0)}
}

/* Zoom-punch on the camera when heating up */
.media-camera .video-frame.heat-warn { animation: heatPulse 1s ease-in-out infinite; }
.media-camera .video-frame.heat-hot { animation: heatPulse .55s ease-in-out infinite; }
.media-camera .video-frame.heat-danger { animation: heatPulse .3s ease-in-out infinite; }
@keyframes heatPulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.015)} }

/* Big % heartbeat when critical */
.big-pct.critical { animation: pctBeat .3s ease-in-out infinite; }
@keyframes pctBeat { 0%,100%{transform:scale(1)} 50%{transform:scale(1.12)} }

/* Reaction face jitter when about to lose */
.reaction-face.panic { animation: facePanic .18s linear infinite; }
@keyframes facePanic { 0%,100%{transform:rotate(-6deg)} 50%{transform:rotate(6deg)} }

/* ===== Survival challenge ring (time left) ===== */
.survival {
    position: absolute; top: 10px; right: 10px; z-index: 6;
    width: 56px; height: 56px;
    display: flex; align-items: center; justify-content: center;
}
.survival-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.sr-track { fill: none; stroke: rgba(0,0,0,.5); stroke-width: 4; }
.sr-fill {
    fill: none; stroke: #22c55e; stroke-width: 4; stroke-linecap: round;
    stroke-dasharray: 119.4; stroke-dashoffset: 119.4;
    filter: drop-shadow(0 0 4px rgba(34,197,94,.6));
    transition: stroke-dashoffset .9s linear, stroke .3s;
}
.survival-time {
    position: relative; z-index: 1;
    font-family: var(--mono); font-size: .62rem; font-weight: 700; color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,.7);
    background: rgba(0,0,0,.4); border-radius: 999px; padding: 1px 4px;
}

/* ===== Video Library (big picker) ===== */
.library {
    position: fixed; inset: 0; z-index: 2500;
    display: none; align-items: center; justify-content: center;
    background: rgba(0,0,0,.8); backdrop-filter: blur(10px);
    padding: 2rem 1rem;
}
.library.open { display: flex; animation: fadeIn .2s ease; }
.library-panel {
    width: 100%; max-width: 920px; max-height: 86vh;
    display: flex; flex-direction: column;
    background: #0c0c0c; border: 1px solid var(--border);
    border-radius: 20px; overflow: hidden;
    box-shadow: 0 30px 80px rgba(0,0,0,.7), 0 0 0 1px rgba(201,43,240,.15);
}
.library-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border);
}
.library-title { font-family: var(--mono); font-size: 1.1rem; font-weight: 700; }
.library-close {
    width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border);
    background: transparent; color: var(--text-2); font-size: .95rem; cursor: pointer;
}
.library-close:hover { background: var(--surface); color: var(--text); }

.library-toolbar {
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    padding: .9rem 1.4rem; border-bottom: 1px solid var(--border);
}
.lib-search { display: flex; align-items: center; gap: .5rem; flex: 1; min-width: 180px;
    padding: .55rem .85rem; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.lib-search:focus-within { border-color: var(--accent); }
.lib-search-ic { opacity: .5; }
#lib-search-input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: .85rem; }
#lib-search-input::placeholder { color: var(--text-3); }
.lib-cats { display: flex; gap: .35rem; flex-wrap: wrap; }
.lib-cat {
    padding: .45rem .8rem; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--border); background: transparent; color: var(--text-2);
    font-size: .78rem; font-weight: 600; transition: all .15s;
}
.lib-cat:hover { border-color: var(--accent); color: var(--text); }
.lib-cat.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.lib-sort {
    appearance: none; -webkit-appearance: none;
    padding: .5rem 1.6rem .5rem .8rem; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    font-size: .78rem; font-weight: 600; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23b3b3b3' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .7rem center;
}
.lib-sort option { background: #141414; color: var(--text); }

.library-grid {
    flex: 1; overflow-y: auto; padding: 1.2rem 1.4rem;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem;
    align-content: start;
}
.lib-card { cursor: pointer; border-radius: 12px; overflow: hidden; background: var(--surface); border: 1px solid var(--border); transition: all .18s; }
.lib-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 10px 26px rgba(201,43,240,.2); }
.lib-thumb { position: relative; }
.lib-thumb img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.lib-dur { position: absolute; bottom: 5px; right: 5px; font-family: var(--mono); font-size: .6rem; font-weight: 700; padding: .1rem .35rem; border-radius: 4px; background: rgba(0,0,0,.8); color: #fff; }
.lib-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; color: #fff; opacity: 0; background: rgba(201,43,240,.25); transition: opacity .18s; text-shadow: 0 0 16px rgba(0,0,0,.6); }
.lib-card:hover .lib-play { opacity: 1; }
.lib-info { padding: .55rem .7rem; }
.lib-vtitle { display: block; font-size: .78rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-meta { display: block; font-size: .62rem; color: var(--text-3); margin-top: .2rem; }
.lib-empty { grid-column: 1/-1; text-align: center; color: var(--text-3); padding: 3rem; }
.library-foot { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1.4rem; border-top: 1px solid var(--border); font-size: .72rem; color: var(--text-3); }

/* Old unused selectors */
.carousel-selectors, .carousel-filters { display: none !important; }

/* ===== Language selector ===== */
.lang-select {
    flex-shrink: 0; appearance: none; -webkit-appearance: none;
    height: 44px; padding: 0 1.9rem 0 .85rem; border-radius: 12px;
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    font-family: var(--mono); font-size: 1.15rem; font-weight: 700; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23c92bf0' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .7rem center;
}
.lang-select:hover { border-color: var(--accent); }
.lang-select option { background: #141414; color: var(--text); }

/* Top-right stacked column: language on top, fullscreen below (equal widths) */
.topbar-right { flex-shrink: 0; display: flex; flex-direction: column; gap: .4rem; }
.topbar-right .lang-select { width: 100%; }
.topbar-fs {
    width: 100%; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text); cursor: pointer;
    transition: border-color .2s, background .2s, transform .15s;
}
.topbar-fs .fs-icon { font-size: 2.2rem; line-height: 1; }
.topbar-fs:hover { border-color: var(--accent); background: rgba(201,43,240,.12); transform: translateY(-1px); }

/* RTL */
[dir="rtl"] .level-name, [dir="rtl"] .lib-meta { text-align: left; }

/* ============================================
   RESPONSIVE — tablet & mobile
   ============================================ */
@media (max-width: 900px) {
    body { overflow-y: auto; overflow-x: hidden; }
    .app { height: auto; min-height: 100dvh; }
    .stage {
        justify-content: flex-start;
        gap: .9rem; padding: .8rem .8rem 1.5rem;
        overflow: visible;
    }
    /* Top row wraps: logo + lang on one line, carousel below */
    .topbar-row { flex-wrap: wrap; gap: .6rem; }
    .brand-logo { height: 60px; }
    .carousel-track-wrap { order: 3; width: 100%; flex-basis: 100%; }
    .topbar-right { margin-left: auto; flex-direction: row; align-items: center; }
    .topbar-fs { width: 44px; }

    /* Stack video and camera, drop the middle bar into a horizontal one */
    .stage-grid { grid-template-columns: 1fr; grid-auto-rows: auto; gap: .7rem; }
    .mid-progress { display: none; }
    .video-frame.fixed-frame { aspect-ratio: 16/9; }
    .media-camera .video-frame.fixed-frame { aspect-ratio: 4/3; max-height: 46vh; }

    /* Wave panel stacks */
    .wave-panel { flex-wrap: wrap; gap: .75rem 1rem; padding: .9rem 1rem; }
    .wave-readout { flex: 1 0 auto; }
    .wave-holder { flex: 1 1 100%; height: 70px; order: 3; }
    .big-pct { font-size: 2.4rem; min-width: 0; }
    .reaction-face { font-size: 2.2rem; }

    /* Controls wrap */
    .media-controls { flex-wrap: wrap; height: auto; }
    .media-controls input { flex: 1 1 100%; order: -1; }

    .library-panel { max-height: 92vh; }
    .library-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

@media (max-width: 520px) {
    .brand-logo { height: 48px; }
    .car-card { width: 130px; }
    .big-pct { font-size: 2rem; }
    .reaction-face { font-size: 1.8rem; }
    .result-details { gap: 1.2rem; }
    .ctrl-btn { height: 38px; }
    .lib-cats { width: 100%; order: 3; overflow-x: auto; flex-wrap: nowrap; }
    .library-toolbar { gap: .5rem; }
    .level-name { min-width: 48px; font-size: .72rem; }
    .level-label { font-size: .7rem; }
}

/* Touch: show video controls without hover */
@media (hover: none) {
    .neon-controls { opacity: 1; }
}
