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

:root {
    --primary-blue: #2c4182;
    --accent-blue: #3a8ab9;
    --light-grey: #f5f7fa;
    --dark-grey: #1a1a1a;
    --text-dark: #2d3748;
    --text-light: #ffffff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    background: var(--light-grey);
    color: var(--text-dark);
    overflow-x: hidden;
    width: 100%;
    margin: 0;
    padding: 0;
}

/* Add padding wrapper for main-screen content */
#main-screen #control-panel,
#main-screen #editor-controls {
    margin: 0 auto;
    max-width: calc(100% - 50px);
}

.container {
    max-width: 700px;
    margin: 60px auto;
    padding: 40px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 6px rgba(44, 65, 130, 0.1);
}

.logo-container {
    text-align: center;
    margin-bottom: 30px;
}

.main-logo {
    max-width: 400px;
    width: 100%;
    height: auto;
    margin-bottom: 15px;
}

h1 {
    font-size: 48px;
    font-weight: 700;
    color: var(--primary-blue);
    margin-bottom: 10px;
    letter-spacing: -1px;
}

.tagline {
    font-size: 18px;
    color: var(--accent-blue);
    font-weight: 500;
    margin-bottom: 0;
}

.about-section {
    text-align: center;
    margin: 30px 0;
    padding: 25px;
    background: var(--light-grey);
    border-radius: 12px;
    border-left: 4px solid var(--accent-blue);
}

.about-section p {
    line-height: 1.7;
    color: var(--text-dark);
    font-size: 15px;
}

.room-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#room-code {
    padding: 15px 20px;
    font-size: 18px;
    border: 2px solid var(--primary-blue);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text-dark);
    text-align: center;
    text-transform: uppercase;
    font-weight: 600;
    transition: all 0.3s;
}

#room-code:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(58, 138, 185, 0.1);
}

button {
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    background: var(--primary-blue);
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 3px;
}

button i {
    font-size: 16px;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(44, 65, 130, 0.3);
    background: #243668;
}

button:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary-blue);
}

.btn-primary:hover {
    background: #243668;
}

.btn-success {
    background: var(--accent-blue);
}

.btn-success:hover {
    background: #2d6e96;
}

.btn-info {
    background: #64748b;
}

.btn-info:hover {
    background: #475569;
}

.btn-danger {
    background: #ef4444;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-small {
    padding: 9px 16px;
    font-size: 15px;
    min-width: 50px;
}

#main-screen {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

#main-screen > * {
    padding-left: 0;
    padding-right: 0;
}

/* HORIZONTAL RESPONSIVE CONTROL PANEL */
#control-panel {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 12px 25px;
    background: #ffffff;
    border-bottom: 2px solid var(--light-grey);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: visible;
    width: 100%;
    box-sizing: border-box;
}

#editor-controls {
    padding: 0 25px;
}

#control-panel::-webkit-scrollbar {
    height: 6px;
}

#control-panel::-webkit-scrollbar-track {
    background: var(--light-grey);
}

#control-panel::-webkit-scrollbar-thumb {
    background: var(--accent-blue);
    border-radius: 3px;
}

.control-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
    width: 100%;
    box-sizing: border-box;
}

/* Override flex when grid-3 is present */
.control-row.control-grid-3 {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    gap: 12px;
    align-items: stretch;
}

/* 33% Grid System */
.control-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    align-items: stretch;
}

/* Force 3 columns on desktop */
@media (min-width: 769px) {
    .control-grid-3 {
        grid-template-columns: 1fr 1fr 1fr !important;
    }
}

.control-group {
    background: var(--light-grey);
    padding: 12px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 100%;
    width: 100%;
    box-sizing: border-box;
}

.control-group-compact {
    background: var(--light-grey);
    padding: 10px 12px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
}

.control-group button {
    width: 100%;
    box-sizing: border-box;
}

.control-group-compact button {
    width: 100%;
    box-sizing: border-box;
}

.control-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

/* Prevent color input labels from stretching */
.control-group label:has(input[type="color"]) {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
}

.control-group select {
    width: 100%;
    box-sizing: border-box;
}

.control-group-compact select {
    width: 100%;
    box-sizing: border-box;
}

.control-group input[type="color"] {
    width: 60px;
    max-width: 60px;
    box-sizing: border-box;
}

.section-title {
    color: var(--primary-blue);
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 10px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 2px solid var(--primary-blue);
    padding-bottom: 6px;
    width: 100%;
    box-sizing: border-box;
}

.section-title i {
    font-size: 14px;
}

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

/* First row - Room info and navigation */
.control-row:first-child {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.control-section {
    background: var(--light-grey);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    width: 100%;
}

.control-section h4 {
    color: var(--primary-blue);
    margin-bottom: 10px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-section .control-row {
    margin-bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

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

#room-display {
    flex: 1;
    font-size: 16px;
    color: var(--text-dark);
    font-weight: 600;
}

#room-display strong {
    color: var(--accent-blue);
}

/* User List Sidebar */
#user-list {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100vh;
    background: #ffffff;
    border-left: 2px solid var(--light-grey);
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
    z-index: 200;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

#user-list.user-list-hidden {
    transform: translateX(100%);
}

.user-list-header {
    padding: 20px;
    background: var(--primary-blue);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-list-header h4 {
    margin: 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-list-header button {
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 10px;
    min-width: auto;
}

.user-list-header button:hover {
    background: rgba(255, 255, 255, 0.3);
}

#user-list-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--light-grey);
    border-radius: 8px;
    border-left: 3px solid var(--accent-blue);
}

.user-item.you {
    border-left-color: var(--primary-blue);
    background: rgba(44, 65, 130, 0.1);
}

.user-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.user-item.you .user-icon {
    background: var(--primary-blue);
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 14px;
}

.user-device {
    font-size: 12px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 4px;
}

.user-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--primary-blue);
    color: white;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    margin-top: 4px;
}

#user-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    background: var(--accent-blue);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    margin-left: 4px;
}

label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-dark);
    white-space: nowrap;
}

label i {
    color: var(--accent-blue);
    font-size: 14px;
}

input[type="range"] {
    width: 100px;
    height: 5px;
    border-radius: 3px;
    background: var(--light-grey);
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-blue);
}

input[type="color"] {
    width: 50px;
    height: 35px;
    border: 2px solid var(--light-grey);
    border-radius: 6px;
    cursor: pointer;
}

select {
    padding: 8px 12px;
    background: #ffffff;
    color: var(--text-dark);
    border: 2px solid var(--light-grey);
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s;
    min-width: auto;
    width: 100%;
    box-sizing: border-box;
}

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

#script-selector {
    width: 100%;
    min-width: auto;
    font-weight: 500;
    box-sizing: border-box;
}

#upload-status {
    font-size: 14px;
    font-weight: 500;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(44, 65, 130, 0.9);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #ffffff;
    padding: 35px;
    border-radius: 12px;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.modal-content h3 {
    margin-bottom: 20px;
    color: var(--primary-blue);
    font-size: 24px;
}

.modal-content input {
    width: 100%;
    padding: 14px;
    margin-bottom: 20px;
    background: var(--light-grey);
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--text-dark);
    font-size: 16px;
    transition: all 0.3s;
}

.modal-content input:focus {
    outline: none;
    border-color: var(--accent-blue);
    background: #ffffff;
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.modal-buttons button {
    flex: 1;
}

#script-input {
    width: 100%;
    height: 120px;
    padding: 12px;
    font-size: 16px;
    background: #ffffff;
    color: var(--text-dark);
    border: 2px solid var(--light-grey);
    border-radius: 8px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.6;
    transition: all 0.3s;
    margin-top: 8px;
}

#script-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(58, 138, 185, 0.1);
}

#play-btn {
    background: #2196F3;
    min-width: 100px;
}

#play-btn:hover {
    background: #1976D2;
}

#teleprompter-display {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: none;
    overflow: hidden;
    z-index: 1000;
}

#teleprompter-display.active {
    display: block;
}

#display-controls {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(44, 65, 130, 0.95);
    padding: 12px 20px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0.3;
    transition: opacity 0.3s;
    z-index: 1001;
}

#teleprompter-display:hover #display-controls {
    opacity: 1;
}

#display-controls:hover {
    opacity: 1;
}

#display-controls button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 10px 14px;
    font-size: 18px;
    min-width: auto;
    border-radius: 8px;
}

#display-controls button:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
    transform: none;
}

#play-display-btn {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    min-width: 50px;
}

#play-display-btn:hover {
    background: #2d6e96;
}

#play-display-btn.playing {
    background: #ef4444;
    border-color: #ef4444;
}

#play-display-btn.playing:hover {
    background: #dc2626;
}

.compact-control {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.compact-control:first-child {
    border-left: none;
}

.compact-control > i {
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    min-width: 20px;
}

.compact-slider {
    width: 100px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
}

.compact-slider::-webkit-slider-thumb {
    width: 14px;
    height: 14px;
    background: white;
}

.compact-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: white;
}

.compact-value {
    color: white;
    font-size: 12px;
    font-weight: 600;
    min-width: 45px;
    text-align: center;
}

.compact-buttons {
    display: flex;
    gap: 4px;
}

.compact-buttons button {
    padding: 6px 10px;
    font-size: 14px;
    border-radius: 4px;
}

button.icon-only {
    padding: 8px 10px;
    min-width: auto;
}

#display-controls input[type="color"] {
    width: 35px;
    height: 35px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
}

#display-controls input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

#display-controls input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

#teleprompter-text {
    padding: 50px;
    white-space: pre-wrap;
    line-height: 1.8;
    text-align: center;
    position: absolute;
    width: 100%;
    cursor: grab;
    user-select: none;
    will-change: transform;
    transform: translateZ(0);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    backface-visibility: hidden;
}

#teleprompter-text:active {
    cursor: grabbing;
}

#editor-controls {
    display: block;
}

#editor-controls.hidden {
    display: none;
}

/* Footer */
.app-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--light-grey);
    text-align: center;
}

.app-footer p {
    font-size: 12px;
    color: #64748b;
    margin: 0;
}

.app-footer strong {
    color: var(--primary-blue);
    font-weight: 600;
}

/* Features Page */
.features-container {
    max-width: 1200px;
    padding: 40px 30px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin: 40px 0;
}

.feature-card {
    background: #ffffff;
    padding: 30px;
    border-radius: 12px;
    border: 2px solid var(--light-grey);
    transition: all 0.3s;
    text-align: center;
}

.feature-card:hover {
    border-color: var(--accent-blue);
    box-shadow: 0 8px 20px rgba(44, 65, 130, 0.15);
    transform: translateY(-4px);
}

.feature-icon {
    width: 70px;
    height: 70px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--primary-blue), var(--accent-blue));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 32px;
}

.feature-card h3 {
    color: var(--primary-blue);
    font-size: 20px;
    margin-bottom: 12px;
    font-weight: 700;
}

.feature-card p {
    color: var(--text-dark);
    font-size: 15px;
    line-height: 1.6;
    margin: 0;
}

.cta-section {
    text-align: center;
    margin: 50px 0 30px;
}

.btn-large {
    padding: 18px 40px;
    font-size: 18px;
    font-weight: 700;
}

.btn-large i {
    font-size: 20px;
}

/* MOBILE RESPONSIVE */
@media (max-width: 768px) {
    .main-logo {
        max-width: 280px;
    }
    
    .container {
        margin: 20px auto;
        padding: 20px;
    }
    
    .about-section {
        padding: 18px;
        font-size: 14px;
    }
    
    .tagline {
        font-size: 16px;
    }
    
    #control-panel {
        padding: 10px 15px;
    }
    
    #editor-controls {
        padding: 0 15px;
    }
    
    #main-screen #control-panel,
    #main-screen #editor-controls {
        max-width: calc(100% - 30px);
    }
    
    .control-row.control-grid-3 {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    
    .control-grid-3 {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    
    .control-row {
        flex-direction: column;
        gap: 8px;
        margin-bottom: 8px;
    }
    
    .control-row:first-child {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }
    
    .control-group,
    .control-group-compact {
        margin-bottom: 0;
        padding: 10px;
    }
    
    .control-section {
        margin-bottom: 8px;
        padding: 10px;
    }
    
    label {
        font-size: 12px;
        width: 100%;
        justify-content: space-between;
    }
    
    input[type="range"] {
        width: 100px;
    }
    
    select, #script-selector {
        width: 100%;
        min-width: auto;
    }
    
    button {
        padding: 10px 14px;
        font-size: 13px;
        width: auto;
    }
    
    .btn-small {
        padding: 7px 10px;
        font-size: 12px;
    }
    
    #script-input {
        height: 80px;
        font-size: 13px;
    }
    
    #room-display {
        width: 100%;
        margin-bottom: 8px;
        text-align: center;
    }
    
    #display-controls {
        top: 10px;
        left: 10px;
        right: 10px;
        transform: none;
        flex-wrap: wrap;
        justify-content: center;
        padding: 10px 15px;
        opacity: 1;
        border-radius: 12px;
    }
    
    .compact-control {
        padding: 0 6px;
        flex-shrink: 0;
    }
    
    .compact-slider {
        width: 60px;
    }
    
    .compact-value {
        font-size: 11px;
        min-width: 35px;
    }
    
    #display-controls button {
        padding: 8px 10px;
        font-size: 16px;
    }
    
    .compact-buttons button {
        padding: 6px 8px;
        font-size: 12px;
    }
    
    #user-list {
        width: 100%;
        max-width: 320px;
    }
    
    #user-list-toggle {
        font-size: 14px;
        padding: 10px 16px;
    }
    
    .features-container {
        padding: 30px 20px;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .feature-card {
        padding: 25px;
    }
    
    .feature-icon {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }
    
    .feature-card h3 {
        font-size: 18px;
    }
    
    .btn-large {
        padding: 16px 32px;
        font-size: 16px;
        width: 100%;
    }
}

@media (max-width: 480px) {
    #control-panel {
        padding: 10px;
    }
    
    .control-row {
        gap: 8px;
        margin-bottom: 10px;
    }
    
    button {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    label {
        font-size: 12px;
        gap: 6px;
    }
    
    input[type="range"] {
        width: 80px;
    }
}

/* Notification Animations */
@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}
