:root {
    --bg-dark: #0a0a0c;
    --accent: #6c5ce7;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --status-active: #3eff84;
    --status-inactive: #ff3e3e;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    display: flex;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.main-panel {
    position: absolute;
    left: 30px;
    top: 30px;
    bottom: 30px;
    width: 320px;
    padding: 30px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

header h1 {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #fff, #a29bfe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.status-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.value {
    font-weight: 600;
    font-size: 1rem;
}

.status-active {
    color: var(--status-active);
}

.status-inactive {
    color: var(--status-inactive);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.group-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.color-picker {
    display: flex;
    gap: 12px;
}

.color-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s, border-color 0.2s;
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.active {
    border-color: white;
    transform: scale(1.1);
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.primary-btn {
    padding: 12px;
    background: linear-gradient(135deg, var(--accent), #a29bfe);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

.secondary-btn {
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 5px;
    background: var(--glass-border);
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(108, 92, 231, 0.5);
}

.gallery-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow: hidden;
}

.snapshot-gallery {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding-right: 5px;
}

.snapshot-gallery::-webkit-scrollbar {
    width: 4px;
}

.snapshot-gallery::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.snapshot-item {
    aspect-ratio: 1;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s;
    position: relative;
}

.snapshot-item:hover {
    border-color: var(--accent);
}

.snapshot-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.empty-msg {
    grid-column: span 2;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 20px 0;
}

.instructions {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 15px;
}

.instructions h3 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--accent);
}

/* Start Overlay */
.start-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    transition: opacity 0.5s ease;
}

.start-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.start-content {
    text-align: center;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    padding: 3rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    width: 90%;
}

.start-content h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.start-content p {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 2rem;
    line-height: 1.6;
}

.start-btn {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.6);
}

.start-btn:active {
    transform: translateY(1px);
}

.instructions ul {
    list-style: none;
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.visualization-area {
    width: 100%;
    height: 100%;
    position: relative;
    background: #000;
}

.flash-effect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    opacity: 0;
    z-index: 1000;
    pointer-events: none;
}

.flash-effect.trigger {
    animation: flash-anim 0.5s ease-out;
}

@keyframes flash-anim {
    0% {
        opacity: 0.8;
    }

    100% {
        opacity: 0;
    }
}

.input-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: rotateY(180deg);
}

.output-canvas,
.writing-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.writing-canvas {
    z-index: 5;
}

.output-canvas {
    z-index: 6;
}

.sentence-container {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 1002;
    width: auto;
    max-width: 80%;
}

.sentence-bar {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px 30px;
    border-radius: 15px;
    color: white;
    font-size: 1.5rem;
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
    white-space: pre;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    min-width: 300px;
    text-align: center;
    letter-spacing: 2px;
}

/* Ambiguity Modal */
.ambiguity-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.ambiguity-modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: rgba(30, 30, 40, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ambiguity-modal.active .modal-content {
    transform: scale(1);
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.options-container {
    display: flex;
    gap: 20px;
}

.option-btn {
    width: 80px;
    height: 80px;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 2.5rem;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:hover {
    background: var(--accent);
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(108, 92, 231, 0.3);
}

@keyframes live-pulse {
    from {
        opacity: 0.4;
        transform: scale(0.95);
    }

    to {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

.backspace-btn {
    background: rgba(255, 62, 62, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 62, 62, 0.2);
    width: 50px;
    height: 50px;
    border-radius: 15px;
    color: #ff3e3e;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.backspace-btn:hover {
    background: rgba(255, 62, 62, 0.2);
    transform: scale(1.05);
}

.backspace-btn:active {
    transform: scale(0.95);
}

.fps-counter {
    position: absolute;
    right: 30px;
    top: 30px;
    padding: 10px 15px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--accent);
}