:root {
    --bg-color: #0d0d12;
    --panel-bg: rgba(25, 25, 32, 0.6);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-muted: #8a8a9e;
    --accent-color: #00f0ff;
    --accent-glow: rgba(0, 240, 255, 0.4);
    --hit-color: #39ff14;
    --font-main: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    height: 100vh;
    width: 100vw;
    overflow-y: auto; /* Allow scrolling for SEO content */
}

/* --- VISUAL SYNC AREA --- */
.sync-container {
    position: relative;
    width: 100vw; /* Take full viewport width */
    height: 100vh; /* Take full viewport height */
    flex-shrink: 0; /* Prevent shrinking when SEO content is below */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #1a1a24 0%, #08080b 100%);
}

.sync-target {
    position: relative;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    border: 2px dashed rgba(255,255,255,0.1);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* The rotating radar/clock hand */
.sweeper {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 50%;
    background: linear-gradient(to top, transparent 0%, var(--accent-color) 100%);
    transform-origin: bottom center;
    transform: translate(-50%, -100%) rotate(0deg);
    border-radius: 4px;
    box-shadow: 0 0 15px var(--accent-color);
    z-index: 10;
}

/* The 12 o'clock target line */
.target-line {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 40px;
    background-color: #fff;
    border-radius: 3px;
    z-index: 15;
}

.flash-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--hit-color);
    opacity: 0;
    pointer-events: none;
    z-index: 5;
}

/* Flash animation applied via JS */
.flash-active {
    opacity: 0.15;
}

/* Readouts */
.screen-readouts {
    position: absolute;
    bottom: 50px;
    display: flex;
    gap: 40px;
    font-family: var(--font-mono);
    text-shadow: 0 0 10px rgba(0,0,0,0.8);
}

.readout-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.readout-item .label {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 2px;
    margin-bottom: 5px;
}

.readout-item .value {
    font-size: 2rem;
    font-weight: 700;
}

.target-ms .value {
    color: var(--accent-color);
    text-shadow: 0 0 15px var(--accent-glow);
}

/* --- UI CONTROLS GLASSMORPHISM --- */
.controls-panel {
    position: absolute;
    top: 30px;
    left: 30px;
    width: 340px;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    z-index: 100;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Hide controls nicely if idle for long (optional enhancement later) */
.controls-panel.hidden {
    transform: translateX(-400px);
    opacity: 0;
}

.control-header {
    margin-bottom: 24px;
}

.control-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.control-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.control-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group.row-layout {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}

/* Buttons */
button {
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.primary-btn {
    background: var(--accent-color);
    color: #000;
    padding: 16px; /* Increased for mobile touch target */
    width: 100%;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.primary-btn:hover {
    filter: brightness(1.2);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 240, 255, 0.6);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 16px; /* Increased for mobile touch target */
    border: 1px solid transparent;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

.control-group:first-of-type {
    flex-direction: row;
    gap: 10px;
}

.control-group:first-of-type .primary-btn {
    flex: 1;
}

.control-group:first-of-type .secondary-btn {
    width: 48px;
    padding: 0;
}

/* Inputs & Selects */
select {
    width: 100%;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    border-radius: 8px;
    font-family: var(--font-main);
    font-size: 0.95rem;
    outline: none;
    appearance: none;
}

select:focus {
    border-color: var(--accent-color);
}

.slider-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}

input[type=range]::-webkit-slider-thumb {
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    margin-top: -6px;
    box-shadow: 0 0 10px var(--accent-glow);
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- COLORBARS (SMPTE) --- */
.colorbars-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
    background: #000;
    display: flex;
    flex-direction: column;
}

.colorbars-layer.hidden {
    display: none;
}

.smpte-bars {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.bar-top { flex: 7; display: flex; }
.bar-middle { flex: 1; display: flex; }
.bar-bottom { flex: 3; display: flex; }

.bar-top > div, .bar-middle > div {
    flex: 1;
}

/* SMPTE Colors */
.c-white { background: #EBEBEB; }
.c-yellow { background: #EBEB00; }
.c-cyan { background: #00EBEB; }
.c-green { background: #00EB00; }
.c-magenta { background: #EB00EB; }
.c-red { background: #EB0000; }
.c-blue { background: #0000EB; }
.c-black { background: #000000; }

.c-i { background: #00234B; width: 14.285%; }
.c-q { background: #32004B; width: 14.285%; }

.bar-bottom .pluge-stripe { width: 3.57%; }
.pluge-superblack { background: #000000; } /* Actually slightly darker than reference black but RGB 0,0,0 for web */
.pluge-black { background: #040404; }
.pluge-gray { background: #0a0a0a; }

.pluge-rest { flex: 1; }

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0,0,0,0.5);
    color: white;
    width: 50px; /* Increased padding */
    height: 50px; /* Increased padding */
    border-radius: 50%;
    font-size: 1.4rem;
    border: 2px solid white;
    z-index: 201;
}

.close-btn:hover {
    background: white;
    color: black;
}

/* --- PIXEL GRID (1:1 MAPPING TEST) --- */
.pixelgrid-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 190;
    background-color: #000;
    /* Draws a grid pattern using CSS gradients */
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.3) 1px, transparent 1px),
        linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 100px 100px, 100px 100px, 10px 10px, 10px 10px;
    background-position: center center;
}

.pixelgrid-layer.hidden {
    display: none;
}

.grid-center-mark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid red;
    border-radius: 50%;
}

.grid-info {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    padding: 10px 20px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    text-align: center;
    color: white;
    font-family: var(--font-mono);
}

/* --- SEO & Sharing Section --- */
.seo-guide {
    width: 100%;
    max-width: 800px;
    margin: 60px auto;
    padding: 0 20px 40px 20px; /* added bottom padding */
    color: var(--text-muted);
    font-family: var(--font-main);
}

.seo-guide h2, .seo-guide h3 {
    color: var(--accent-color);
    margin-bottom: 16px;
    margin-top: 32px;
}

.seo-guide p {
    line-height: 1.6;
    margin-bottom: 16px;
}

.seo-guide ul {
    list-style-type: none;
    margin-bottom: 32px;
}

.seo-guide li {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.share-results {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 24px;
    margin-top: 40px;
}

.share-box {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap; /* for responsiveness */
}

.share-box input {
    flex: 1;
    min-width: 250px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    border-radius: 8px;
    font-family: var(--font-main);
}

.share-box .primary-btn {
    width: auto;
    padding: 0 24px;
}

/* --- MOBILE OPTIMIZATION --- */
@media screen and (max-width: 768px) {
    body {
        height: auto;
        overflow-y: auto;
    }

    .sync-container {
        height: 60vh; /* Reduced height on mobile to keep controls visible */
        min-height: 400px;
    }

    .sync-target {
        width: 280px;
        height: 280px;
    }

    .target-line {
        height: 30px;
        top: -15px;
    }

    .screen-readouts {
        bottom: 20px;
        gap: 20px;
    }

    .readout-item .value {
        font-size: 1.4rem;
    }

    .readout-item .label {
        font-size: 0.6rem;
    }

    /* Move controls panel to be part of the flow on mobile */
    .controls-panel {
        position: relative;
        top: 0;
        left: 0;
        width: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
        padding: 20px 5%;
        background: var(--bg-surface);
        backdrop-filter: none;
    }

    .control-header {
        margin-bottom: 16px;
    }

    .primary-btn, .secondary-btn {
        padding: 14px;
    }

    /* SEO section adjustments */
    .seo-section {
        padding: 40px 5%;
    }

    .use-cases-grid {
        grid-template-columns: 1fr;
    }
}
