/* Motion Eval — FunSlop.com
   AR-lite reflex eval. Faded mirrored webcam feed behind floating examples;
   per-region frame-difference motion detection registers hits. Pointer/touch
   fallback when the camera is denied. Self-contained neon-on-near-black. */

:root {
    --bg-dark: #090b10;
    --neon-green: #39ff14;
    --cyan: #05d9e8;
    --neon-purple: #bd00ff;
    --pink: #ff2a6d;
    --gold: #ffd54a;
    --text-primary: #f0f4f8;
    --text-muted: #8b9bb4;
    --glass-border: rgba(255, 255, 255, 0.08);
    --font-body: 'Outfit', system-ui, -apple-system, sans-serif;
    --font-display: 'Space Grotesk', 'Outfit', system-ui, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    min-height: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--bg-dark);
    color: var(--text-primary);
}

/* Ambient neon glow */
.glow-bg {
    position: fixed;
    top: -80px;
    left: -80px;
    width: 360px;
    height: 360px;
    background: radial-gradient(circle, var(--cyan) 0%, transparent 70%);
    opacity: 0.14;
    z-index: -1;
    filter: blur(60px);
    pointer-events: none;
    animation: float 12s infinite alternate;
}

@keyframes float {
    0% { transform: translate(0, 0); }
    100% { transform: translate(120px, 60px); }
}

.game-container {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    user-select: none;
    -webkit-user-select: none;
}

.content {
    text-align: center;
    padding: 1.75rem 1rem 6rem;
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
}

.title {
    font-family: var(--font-display);
    font-size: 2.1rem;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 0.9rem;
    background: linear-gradient(45deg, var(--cyan), var(--pink));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* HUD */
.hud {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 0.9rem;
}

.hud-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
}

.hud-item b {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.5px;
}

.hud-score b { color: var(--cyan); }
.hud-combo b { color: var(--gold); }
.hud-lives b { color: var(--pink); letter-spacing: 1px; }

.hud-combo.combo-hot b {
    text-shadow: 0 0 12px rgba(255, 213, 74, 0.7);
    animation: combo-throb 0.4s ease-in-out;
}

@keyframes combo-throb {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.25); }
}

/* Arena: square-ish play surface holding video + canvases */
.arena-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
}

.arena {
    position: relative;
    width: min(94vw, 460px);
    aspect-ratio: 3 / 4;
    border-radius: 18px;
    overflow: hidden;
    background: #05060a;
    border: 1px solid rgba(5, 217, 232, 0.25);
    box-shadow:
        0 0 30px rgba(5, 217, 232, 0.22),
        inset 0 0 22px rgba(189, 0, 255, 0.10);
    touch-action: none;
    cursor: crosshair;
}

/* Mirrored, faded webcam feed sits at the very back */
#cam {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* mirror so it reads like a reflection */
    opacity: 0.28;
    filter: saturate(0.6) contrast(1.05);
    display: none; /* shown only when camera is live */
    pointer-events: none;
}

.cam-on #cam {
    display: block;
}

/* Subtle scanline / grid feel over the feed */
.arena::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(rgba(5, 217, 232, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(189, 0, 255, 0.04) 1px, transparent 1px);
    background-size: 36px 36px, 36px 36px;
    mix-blend-mode: screen;
    z-index: 1;
}

/* Hidden working canvas for motion diff (debug heatmap overlay) */
#motion {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform: scaleX(-1);
    opacity: 0.0;
    pointer-events: none;
    z-index: 2;
}

.show-motion #motion {
    opacity: 0.35;
}

/* The main gameplay canvas where examples are drawn */
#play {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

/* Overlay panel for idle / gameover messaging */
.arena-overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    padding: 1.5rem;
    text-align: center;
    background: rgba(5, 6, 10, 0.72);
    backdrop-filter: blur(3px);
}

.state-playing .arena-overlay {
    display: none;
}

.overlay-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--cyan);
    text-shadow: 0 0 16px rgba(5, 217, 232, 0.5);
}

.overlay-body {
    font-weight: 300;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
    max-width: 30ch;
}

.overlay-sub {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: -0.2rem;
}

.state-gameover.new-best .overlay-title {
    color: var(--gold);
    text-shadow: 0 0 18px rgba(255, 213, 74, 0.6);
}

.game-btn {
    font-family: var(--font-display);
    padding: 0.85rem 2rem;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    color: #04130a;
    background: linear-gradient(135deg, var(--cyan), var(--neon-green));
    box-shadow: 0 0 22px rgba(5, 217, 232, 0.4);
    transition: transform 0.12s, box-shadow 0.15s, filter 0.15s;
}

.game-btn:hover {
    filter: brightness(1.08);
    box-shadow: 0 0 30px rgba(5, 217, 232, 0.6);
}

.game-btn:active {
    transform: scale(0.95);
}

.game-btn:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}

/* Camera status badge */
.cam-badge {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    z-index: 5;
    font-family: var(--font-display);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 0.22rem 0.55rem;
    border-radius: 999px;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border);
    transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.cam-on .cam-badge {
    color: var(--neon-green);
    border-color: rgba(57, 255, 20, 0.5);
    box-shadow: 0 0 12px rgba(57, 255, 20, 0.4);
}

.cam-pointer .cam-badge {
    color: var(--gold);
    border-color: rgba(255, 213, 74, 0.5);
}

.hint {
    font-size: 0.92rem;
    color: var(--text-muted);
    margin-top: 0.85rem;
    min-height: 1.2em;
    line-height: 1.4;
}

.state-gameover .hint {
    color: var(--text-primary);
}

/* Legend */
.legend {
    display: flex;
    gap: 0.9rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 0.7rem;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.legend-item .dot {
    width: 0.8rem;
    height: 0.8rem;
    border-radius: 50%;
}

.legend-good .dot {
    background: var(--cyan);
    box-shadow: 0 0 10px rgba(5, 217, 232, 0.8);
}

.legend-bad .dot {
    background: var(--pink);
    box-shadow: 0 0 10px rgba(255, 42, 109, 0.8);
}

/* Hide legend + hint during the overlay-heavy idle pitch to reduce clutter? keep them. */

/* SEO / how-to content */
.how-to-play {
    text-align: left;
    margin: 2.5rem auto 0;
    max-width: 560px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.75rem;
}

.how-to-play h2 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.how-to-play h3 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    margin: 1.25rem 0 0.5rem;
    color: var(--cyan);
}

.how-to-play p {
    font-weight: 300;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.how-to-play strong { color: var(--text-primary); font-weight: 500; }
.how-to-play em { color: var(--neon-green); font-style: normal; }

.how-to-play ol {
    margin: 0.5rem 0 0.75rem 1.25rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.fun-fact {
    margin-top: 1.25rem;
    padding: 1rem;
    border-left: 3px solid var(--neon-purple);
    background: rgba(189, 0, 255, 0.06);
    border-radius: 0 10px 10px 0;
}

.fun-fact p { margin: 0; }

.related-games {
    margin: 2rem auto 0;
    max-width: 560px;
    text-align: center;
}

.related-games h3 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

.related-games-list {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
}

.related-game-link {
    text-decoration: none;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    padding: 0.45rem 1rem;
    font-size: 0.9rem;
    transition: border-color 0.2s, color 0.2s;
}

.related-game-link:hover {
    border-color: var(--cyan);
    color: var(--cyan);
}

/* Hide SEO content while playing to keep focus on the arena */
.state-playing .how-to-play,
.state-playing .related-games {
    display: none;
}

/* Home link */
.home-link {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem 1.1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    backdrop-filter: blur(8px);
    transition: border-color 0.2s, color 0.2s;
    z-index: 10;
}

.home-link:hover {
    border-color: var(--neon-purple);
    color: var(--neon-purple);
}

.home-link:active {
    transform: translateX(-50%) scale(0.95);
}

.home-link:focus-visible {
    outline: 3px solid var(--cyan);
    outline-offset: 2px;
}

/* Responsive */
@media (max-width: 600px) {
    .title { font-size: 1.75rem; }
    .overlay-title { font-size: 1.25rem; }
    .overlay-body { font-size: 0.92rem; }
    .hud-item { font-size: 0.82rem; }
    .game-btn { padding: 0.75rem 1.6rem; font-size: 1rem; }
}

@media (max-height: 720px) {
    .content { padding-top: 1rem; }
    .arena { aspect-ratio: 1 / 1; }
}
