:root {
    --bg-color: #111111;
    --text-color: #ffffff;
    --accent-color: #3b82f6;
    --glass-bg: rgba(30, 30, 30, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-main: 'Inter', sans-serif;
    --font-display: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    overflow: hidden;
    /* Hide scrollbars, we handle scrolling manually or via overflow-y */
    height: 100vh;
    width: 100vw;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Teleprompter Area */
#prompter-container {
    width: 100%;
    height: 100%;
    overflow-y: hidden;
    /* We scroll the text element or use transform */
    position: relative;
    display: flex;
    justify-content: center;
}

#prompter-text {
    width: 100%;
    padding-top: 45vh;
    /* Start text in middle */
    padding-bottom: 45vh;
    padding-left: 10%;
    /* Controlled by margin setting */
    padding-right: 10%;
    /* Controlled by margin setting */
    font-size: 48px;
    line-height: 1.5;
    outline: none;
    white-space: pre-wrap;
    text-align: left;
    caret-color: var(--accent-color);
    /* Smooth scrolling is handled by JS, but we need this for manual scroll */
    overflow-y: auto;
    height: 100%;
    scrollbar-width: none;
    /* Firefox */
}

#prompter-text::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

#prompter-text.mirror {
    transform: scaleX(-1);
}

/* Scroll Marker (Optional visual aid) */
#scroll-marker {
    position: absolute;
    left: 0;
    top: 40%;
    width: 20px;
    height: 2px;
    background: var(--accent-color);
    opacity: 0.5;
}

/* Floating Controls - Glassmorphism */
#controls-overlay {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 320px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#controls-overlay.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

.controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.controls-header h3 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.2rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group.row {
    flex-direction: row;
    justify-content: space-between;
}

.control-group label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    justify-content: space-between;
}

/* Inputs */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: none;
    cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--glass-border);
    border-radius: 4px;
}

/* Mobile Optimization */
@media (max-width: 768px) {
    #prompter-text {
        font-size: 32px;
        /* Smaller default font on mobile */
        padding-left: 5%;
        padding-right: 5%;
    }

    #controls-overlay {
        width: 100%;
        /* Full width on mobile */
        height: 100%;
        /* Full height */
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
        /* Remove border radius */
        overflow-y: auto;
        /* Enable scrolling */
        padding-bottom: 100px;
        /* Space for floating buttons */
        background: rgba(17, 17, 17, 0.95);
        /* Darker background for readability */
    }

    .floating-btn {
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }

    /* Larger touch targets for inputs */
    input[type="range"]::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }

    .control-group label {
        font-size: 1rem;
        /* Readable labels */
    }

    /* Visual indicator for Edit Mode */
    #prompter-text[contenteditable="true"] {
        border: 2px dashed var(--accent-color);
        border-radius: 8px;
        padding: 20px;
        /* Add some padding so border isn't tight */
        margin-top: 40vh;
        /* Adjust for padding */
        margin-bottom: 40vh;
    }
}

/* Landscape Mobile Optimization */
@media (max-height: 600px) {
    #controls-overlay {
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
        overflow-y: auto;
        padding-bottom: 100px;
        background: rgba(17, 17, 17, 0.95);
    }
}

/* Buttons */
.icon-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.icon-btn:hover {
    opacity: 1;
}

.floating-actions {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 90;
}

.floating-btn {
    position: relative;
    /* Reset absolute positioning */
    bottom: auto;
    right: auto;
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
}

.floating-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.primary-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.primary-btn:hover {
    background: #2563eb;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 40px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch label {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: .4s;
    border-radius: 20px;
}

.toggle-switch label:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.toggle-switch input:checked+label {
    background-color: var(--accent-color);
}

.toggle-switch input:checked+label:before {
    transform: translateX(20px);
}

/* Alignment Buttons */
.alignment-buttons {
    display: flex;
    gap: 8px;
}

.align-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.align-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.align-btn.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

/* Modal */
.modal {
    display: flex;
    /* Hidden by default via class */
    position: fixed;
    z-index: 200;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: #1e1e1e;
    padding: 30px;
    border: 1px solid #333;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    position: relative;
    color: white;
}

.close {
    position: absolute;
    top: 10px;
    right: 20px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: white;
}

#qrcode {
    margin: 20px auto;
    background: white;
    padding: 10px;
    border-radius: 8px;
    width: fit-content;
}

.link-text {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #aaa;
}

.link-text a {
    color: var(--accent-color);
    text-decoration: none;
}

.status {
    margin-top: 15px;
    font-size: 0.8rem;
    color: #666;
}

/* Play Status Overlay */
.status-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.3s;
}

.status-overlay.visible {
    opacity: 1;
    animation: fadeOut 1s forwards;
}

#play-icon {
    font-size: 100px;
    color: rgba(255, 255, 255, 0.3);
}

@keyframes fadeOut {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.5);
    }
}

/* Top Bar */
#top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0));
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    z-index: 200;
    transition: transform 0.3s ease, opacity 0.3s ease;
    padding-top: 10px;
}

#top-bar.hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

#top-bar .icon-btn {
    font-size: 2rem;
    background: rgba(255, 255, 255, 0.1);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
}

#top-bar .icon-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.top-speed-control {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 30px;
    backdrop-filter: blur(5px);
}

.top-speed-control input[type="range"] {
    width: 200px;
}

/* Context Menu */
#context-menu {
    position: absolute;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 300;
    transition: opacity 0.2s, transform 0.2s;
}

#context-menu.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
}

#context-menu button {
    background: none;
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

#context-menu button:hover {
    background: rgba(255, 255, 255, 0.2);
}

#context-menu .separator {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
}

#context-menu input[type="color"] {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: none;
    padding: 0;
}

#context-menu input[type="color"]::-webkit-color-swatch {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}