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

body {
    background-color: #121212;
    display: flex;
    flex-direction: column; /* Changed to column to stack player and chat */
    justify-content: flex-start; /* Start from top */
    align-items: center;
    height: 100vh;
    overflow: hidden;
    position: relative;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}



/* Add background dimming overlay */
body::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0);
    pointer-events: none;
    z-index: 0;
    transition: background-color 0.3s ease;
}

body.dimmed-background::after {
    background-color: var(--dimming-color, rgba(0, 0, 0, 0));
    z-index: 0;
}

.tv-container {
    position: relative;
    width: 100%;
    flex: 1; /* Take available space above chat */
    min-height: 0; /* Allow shrinking */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible; 
}

.tv-frame {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tv-image {
    position: absolute;
    width: auto;
    height: 100%; /* Adjusted to fit within flex container */
    max-height: 100vh;
    object-fit: contain;
    z-index: 2;
    pointer-events: none;
}

.tv-screen {
    position: absolute;
    background-color: black;
    z-index: 1;
    overflow: hidden;
    border-radius: 0;
    cursor: default;
}

.tv-screen.drag-mode {
    cursor: move;
}

.tv-screen.resize-mode {
    cursor: nwse-resize;
}

.tv-screen.mobile-adjust-drag {
    cursor: move;
}

.tv-screen.mobile-adjust-resize {
    cursor: nwse-resize;
}

#player {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    /* 4:3 aspect ratio will be set by JavaScript */
}

body.no-frame .tv-image {
    display: none;
}

body.no-frame .tv-screen {
    position: relative;
    width: auto;
    height: 90vh;
    margin: 0 auto;
    z-index: 1;
    top: auto;
    left: auto;
}

body.no-frame #player {
    width: 100%;
    height: 100%;
    aspect-ratio: 4/3;
    max-height: 90vh;
}

.tv-controls {
    position: absolute;
    bottom: 50%;
    right: 5%;
    transform: translateY(50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 80vh; 
    overflow-y: auto; 
}

.control-section {
    display: flex;
    flex-direction: column;
    gap: 5px;
    justify-content: center;
}

.control-btn {
    background-color: #333;
    color: white;
    border: 2px solid #555;
    border-radius: 5px;
    padding: 6px 10px;
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.5);
}

.control-btn:hover {
    background-color: #444;
}

.control-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.volume-controls {
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-bottom: 10px;
}

.volume-up, .volume-down {
    width: 80px;
    height: 35px;
    font-size: 18px;
    font-weight: bold;
}

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

.channel-btn {
    width: 80px;
    height: 35px;
    font-size: 18px;
}

.mobile-adjust-controls {
    display: none;
}

.mobile-adjust-btn,
.mobile-adjust-drag-btn,
.mobile-adjust-resize-btn,
.mobile-adjust-done-btn {
    width: 80px;
    height: 35px;
    font-size: 16px;
    font-weight: bold;
    background-color: #444;
}

.mobile-adjust-done-btn {
    background-color: #3a6;
}

.power-btn {
    width: 80px;
    height: 35px;
    background-color: #e74c3c;
    color: white;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 5px;
}

.power-btn:hover {
    background-color: #c0392b;
}

.chat-container {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 320px;
    height: calc(100% - 40px);
    background-color: #222;
    border: 5px solid #444;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.7);
    z-index: 10;
    display: flex;
    flex-direction: column;
    font-family: 'VT323', 'Courier New', monospace;
    overflow: hidden;
    cursor: default;
    max-height: 100%;
}

.chat-header {
    background-color: #444;
    padding: 5px 10px;
    color: #fff;
    font-weight: bold;
    cursor: move;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.chat-header-title {
    text-transform: uppercase;
    letter-spacing: 1px;
}

.chat-toggle-btn {
    background-color: #333;
    border: 2px solid #555;
    border-radius: 3px;
    width: 25px;
    height: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.chat-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
}

.chat-messages {
    flex-grow: 1;
    padding: 10px;
    background-color: #000;
    color: #0f0;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.4;
    scrollbar-width: thin;
    scrollbar-color: #555 #222;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #222;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: #555;
    border-radius: 4px;
}

.chat-message {
    margin-bottom: 6px;
    word-wrap: break-word;
}

.chat-username {
    color: #ff0;
    font-weight: bold;
}

.system-message {
    color: #aaa;
    font-style: italic;
    margin-bottom: 6px;
}

.chat-input-container {
    display: flex;
    padding: 10px;
    background-color: #333;
    border-top: 3px solid #444;
}

.chat-input {
    flex-grow: 1;
    background-color: #000;
    border: 2px solid #555;
    border-radius: 5px 0 0 5px;
    color: #0f0;
    padding: 8px;
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 14px;
}

.chat-send-button {
    background-color: #444;
    color: #fff;
    border: 2px solid #555;
    border-left: none;
    border-radius: 0 5px 5px 0;
    padding: 8px 15px;
    cursor: pointer;
    font-family: 'VT323', 'Courier New', monospace;
    font-weight: bold;
    text-transform: uppercase;
}

.chat-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 15px;
    height: 15px;
    background-color: #444;
    cursor: nwse-resize;
    border-top-left-radius: 3px;
}

.chat-container.dragging {
    opacity: 0.8;
}

.chat-container.resizing {
    opacity: 0.8;
}

.chat-container.minimized {
    height: auto !important;
    width: auto !important;
    min-width: 200px;
}

.guide-time-header {
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    padding: 8px;
    margin-bottom: 10px;
    background-color: #333;
    border-radius: 4px;
}

.guide-channel-entry {
    margin-bottom: 12px;
    padding: 8px;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #1a1a1a;
    cursor: pointer;
    transition: background-color 0.2s;
}

.guide-channel-entry:hover {
    background-color: #252525;
}

.guide-channel-entry.current-channel {
    background-color: #2a3a2a;
    border-color: #0f0;
}

.guide-channel-entry.current-channel:hover {
    background-color: #3a4a3a;
}

.guide-channel-name {
    font-size: 16px;
    font-weight: bold;
    color: #ff0;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.guide-current-program, .guide-next-program {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
}

.guide-program-title {
    color: #0f0;
    flex-grow: 1;
}

.guide-program-time {
    color: #0af;
    margin-left: 10px;
    font-weight: bold;
}

.guide-next-program .guide-program-title {
    color: #7f7;
    font-style: italic;
}

.debug-log-container {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 300px;
    height: 200px;
    background-color: rgba(0, 0, 0, 0.8);
    color: #0f0;
    border: 2px solid #444;
    border-radius: 5px;
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 12px;
    z-index: 9999;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.debug-log-header {
    background-color: #333;
    padding: 5px;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #444;
    cursor: move;
    user-select: none;
}

.debug-log-title {
    font-weight: bold;
}

.debug-log-toggle {
    cursor: pointer;
    background: none;
    border: none;
    color: #fff;
    font-family: inherit;
}

.debug-log-clear {
    cursor: pointer;
    background: none;
    border: none;
    color: #fff;
    font-family: inherit;
}

.debug-log-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 5px;
    scrollbar-width: thin;
    scrollbar-color: #555 #222;
}

.debug-log-content::-webkit-scrollbar {
    width: 8px;
}

.debug-log-content::-webkit-scrollbar-track {
    background: #222;
}

.debug-log-content::-webkit-scrollbar-thumb {
    background-color: #555;
    border-radius: 4px;
}

.debug-log-entry {
    margin-bottom: 3px;
    border-bottom: 1px dotted #333;
    padding-bottom: 3px;
    word-break: break-word;
}

.debug-log-info {
    color: #0f0;
}

.debug-log-warning {
    color: #ff0;
}

.debug-log-error {
    color: #f00;
}

.debug-log-container.collapsed .debug-log-content {
    display: none;
}

.debug-log-container.collapsed {
    height: auto;
}

.debug-log-resize {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background-color: #444;
    cursor: nwse-resize;
}

@media (max-width: 768px) {
    .debug-log-container {
        width: 250px;
        height: 150px;
        font-size: 10px;
    }
}

.welcome-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: #222;
    border: 3px solid #444;
    border-radius: 10px;
    padding: 30px;
    max-width: 500px;
    text-align: center;
    color: white;
    font-family: 'VT323', 'Courier New', monospace;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #eee;
    font-size: 28px;
}

.modal-content p {
    font-size: 18px;
}

.modal-content ul {
    text-align: left;
    margin: 20px 0;
    padding-left: 20px;
    font-size: 18px;
}

.modal-content li {
    margin-bottom: 10px;
    line-height: 1.5;
}

#username-input {
    width: 100%;
    padding: 10px;
    margin: 15px 0;
    background-color: #333;
    border: 2px solid #555;
    border-radius: 5px;
    color: white;
    font-size: 18px;
    font-family: 'VT323', 'Courier New', monospace;
}

.settings-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background-color: rgba(34, 34, 34, 0.7);
    border: 2px solid #444;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    color: #fff;
}

.settings-btn:hover {
    background-color: rgba(68, 68, 68, 0.8);
    transform: rotate(30deg);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 200;
    overflow-y: auto;
}

.modal-content {
    background-color: #222;
    margin: 50px auto;
    padding: 20px;
    width: 80%;
    max-width: 800px;
    border: 3px solid #444;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    color: #fff;
    font-family: 'VT323', 'Courier New', monospace;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #444;
}

.modal-header h2 {
    margin: 0;
    color: #0f0;
}

.close-modal {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover {
    color: #fff;
}

.settings-section {
    margin-bottom: 30px;
}

.settings-section h3 {
    color: #0af;
    margin-bottom: 15px;
    border-bottom: 1px solid #333;
    padding-bottom: 5px;
}

.background-options {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: flex-start;
}

.background-option {
    width: 150px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    padding: 8px;
    border-radius: 5px;
    border: 2px solid transparent;
}

.background-option:hover {
    background-color: #333;
}

.background-option.selected {
    border-color: #0f0;
    background-color: rgba(0, 255, 0, 0.1);
}

.bg-preview {
    width: 120px;
    height: 90px;
    margin-bottom: 5px;
    background-size: cover;
    background-position: center;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid #555;
}

.bg-none {
    background-color: #121212;
    position: relative;
}

.bg-none:after {
    content: '✕';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: #555;
}

.background-option span {
    display: block;
    font-size: 14px;
    color: #ddd;
}

.timezone-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-left: 10px;
}

.timezone-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    cursor: pointer;
}

.timezone-options input[type="radio"] {
    margin: 0;
    cursor: pointer;
    accent-color: #0f0;
}

.dimming-controls {
    margin-top: 10px;
}

.dimming-slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
}

#background-dimming {
    flex-grow: 1;
    accent-color: #0f0;
}

#dimming-level {
    min-width: 25px;
    text-align: center;
}

.font-size-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 10px;
}

.font-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.font-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}

.font-btn {
    width: 30px;
    height: 30px;
    font-size: 18px;
    background-color: #333;
    color: #fff;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.font-btn:hover {
    background-color: #444;
}

.font-size-value {
    min-width: 30px;
    text-align: center;
    font-size: 16px;
}

.log-display-option {
    margin-top: 10px;
}

.log-display-option label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

#show-logs {
    accent-color: #0f0;
}

.mobile-program-guide {
    display: none;
    width: 100%;
    background-color: #222;
    border-top: 3px solid #444;
    border-bottom: 3px solid #444;
    font-family: 'VT323', 'Courier New', monospace;
    overflow: hidden;
    color: #0f0;
    height: auto;
    min-height: 100px;
    z-index: 5;
    opacity: 1 !important;
    flex-direction: column;
}

.mobile-guide-header {
    background-color: #444;
    padding: 2px;
    text-align: center;
    color: #fff;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    flex-shrink: 0;
    font-size: 14px;
}

.mobile-guide-content {
    padding: 5px;
    display: flex;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    height: 100%;
    align-items: stretch;
    scrollbar-width: thin;
    scrollbar-color: #555 #222;
}

.mobile-guide-content::-webkit-scrollbar {
    height: 4px;
}

.mobile-guide-content::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 2px;
}

.mobile-guide-channel {
    display: flex;
    flex-direction: column;
    padding: 6px;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #1a1a1a;
    min-width: 140px;
    width: 140px;
    flex-shrink: 0;
    cursor: pointer;
}

.mobile-guide-channel:active {
    background-color: #333;
}

.mobile-guide-channel:last-child {
    border-right: 1px solid #444;
}

.mobile-guide-channel-name {
    color: #ff0;
    font-weight: bold;
    text-align: center;
    border-bottom: 1px solid #333;
    padding-bottom: 2px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.mobile-guide-programs {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    min-height: 0;
}

.mobile-guide-current {
    color: #0f0;
    font-size: 12px;
    line-height: 1.1;
    margin-bottom: 3px;
}

.mobile-guide-next {
    color: #7f7;
    font-style: italic;
    font-size: 11px;
    line-height: 1.1;
    opacity: 0.8;
}

.mobile-guide-channel.current-channel {
    background-color: rgba(0, 255, 0, 0.15);
    border-color: #0a0;
}

.mobile-buttons-container {
    display: none;
    width: 100%;
    padding: 5px;
    background-color: #222;
    border-top: 3px solid #444;
    border-bottom: 3px solid #444;
}

.mobile-button-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

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

.mobile-channels-scroll-container {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding: 5px 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.mobile-channels-scroll-container::-webkit-scrollbar {
    display: none;
}

.mobile-channel-btn {
    flex: 0 0 auto;
    width: auto;
    min-width: 70px;
    background-color: #333;
    color: white;
    border: 1px solid #555;
    border-radius: 3px;
    padding: 8px 10px;
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 16px;
    margin: 0;
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
}

.mobile-control-btn {
    flex: 1;
    background-color: #333;
    color: white;
    border: 1px solid #555;
    border-radius: 3px;
    padding: 5px 2px;
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 14px;
    margin: 0 2px;
    cursor: pointer;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.mobile-vote-down svg, .mobile-vote-up svg {
    fill: #ccc;
}

.mobile-vote-up:active svg {
    fill: #0f0;
}

.mobile-vote-down:active svg {
    fill: #f55;
}

.vote-count {
    font-size: 16px;
    font-weight: bold;
}

.mobile-power-btn {
    background-color: #e74c3c;
}

@media (max-width: 768px) {
    .no-frame-option {
        display: none; /* Hide no-frame toggle on mobile */
    }
    
    body {
        overflow: hidden;
    }
    
    /* Force no-frame mode on mobile */
    body.mobile-device .tv-image {
        display: none;
    }
    
    body.mobile-device .tv-screen {
        position: relative;
        width: 100vw;
        height: calc(100vw * 0.75); /* 4:3 aspect ratio */
        margin: 0 auto;
        z-index: 1;
        top: auto;
        left: auto;
    }
    
    body.mobile-device #player {
        width: 100%;
        height: 100%;
        aspect-ratio: 4/3;
    }
    
    .tv-controls {
        bottom: 50%;
        right: 2%;
        transform: translateY(50%) scale(0.7);
        max-height: 90vh;
        opacity: 0.85;
        transition: opacity 0.3s ease;
        z-index: 10; 
    }
    
    .tv-controls:hover {
        opacity: 1;
    }
    
    .mobile-adjust-controls {
        display: flex; 
    }
    
    .tv-image {
        height: 80vh;
        width: auto;
        object-fit: contain;
    }
    
    .tv-screen {
    }
    
    .chat-container {
        width: 180px;
        height: 250px;
        font-size: 12px;
        top: 10px;
        left: 10px;
        opacity: 0.85;
        transition: opacity 0.3s ease;
        z-index: 5;
    }
    
    .chat-container:hover {
        opacity: 1;
    }
    
    .chat-container.minimized {
        width: auto;
        min-width: 160px;
    }
    
    .guide-time-header {
        font-size: 14px;
        padding: 5px;
        margin-bottom: 5px;
    }
    
    .guide-channel-entry {
        margin-bottom: 8px;
        padding: 5px;
    }
    
    .guide-channel-name {
        font-size: 14px;
    }
    
    .guide-program-title, .guide-program-time {
        font-size: 12px;
    }
    
    .chat-input {
        font-size: 12px;
        padding: 5px;
    }
    
    .chat-send-button {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    .modal-content {
        width: 95%;
        margin: 30px auto;
        padding: 15px;
    }
    
    .background-option {
        width: 120px;
    }
    
    .bg-preview {
        width: 100px;
        height: 75px;
    }
    
    .settings-btn {
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
    
    .font-control {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .channels {
        grid-template-columns: repeat(3, 1fr); 
    }
    
    .channel-btn {
        padding: 4px 6px;
        font-size: 12px;
        height: 30px;
    }
    
    .control-btn {
        padding: 4px 6px;
    }
    
    .mobile-button-row:first-child .mobile-control-btn {
        font-size: 11px; 
        padding: 5px 1px;
    }

    .mobile-buttons-container {
        padding: 2px 4px;
    }

    .mobile-button-row {
        margin-bottom: 3px;
    }

    .mobile-control-btn {
        height: 34px;
        padding: 2px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 767px) {
  .settings-btn {
    display: none !important;
  }
}

@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  .settings-btn {
    display: none !important;
  }
}

@media (max-width: 767px) {
  .desktop-only {
    display: none !important;
  }
}

.complete-guide-btn {
    background-color: #3a3a3a;
    color: white;
    border: 2px solid #555;
    border-radius: 5px;
    padding: 10px 15px;
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.5);
    margin: 10px 0;
    width: 100%;
    text-align: center;
}

.complete-guide-btn:hover {
    background-color: #4a4a4a;
}

.content-editor-btn {
    background-color: #3a3a3a;
    color: white;
    border: 2px solid #555;
    border-radius: 5px;
    padding: 10px 15px;
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.5);
    margin: 10px 0;
    width: 100%;
    text-align: center;
}

.content-editor-btn:hover {
    background-color: #4a4a4a;
    border-color: #0f0;
    color: #0f0;
}

.complete-guide-content {
    width: 95%;
    max-width: 1200px;
    height: 80vh;
    display: flex;
    flex-direction: column;
}

.day-selector {
    display: flex;
    justify-content: space-between;
    overflow-x: auto;
    padding: 10px 0;
    margin-bottom: 15px;
    scrollbar-width: thin;
    scrollbar-color: #555 #222;
}

.day-btn {
    background-color: #333;
    color: white;
    border: 2px solid #555;
    border-radius: 5px;
    padding: 8px 12px;
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    margin: 0 5px;
    flex-shrink: 0;
}

.day-btn:hover {
    background-color: #444;
}

.day-btn.active {
    background-color: #0c6;
    border-color: #0a4;
}

.complete-guide-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    border: 2px solid #444;
    border-radius: 8px;
    background-color: #222;
}

.time-header {
    display: flex;
    position: sticky;
    top: 0;
    background-color: #333;
    z-index: 2;
    overflow-x: auto;
    scrollbar-width: none;
    border-bottom: 2px solid #444;
}

.time-header::-webkit-scrollbar {
    display: none;
}

.time-header-cell {
    min-width: 120px;
    padding: 10px;
    text-align: center;
    font-weight: bold;
    color: #0f0;
    border-right: 1px solid #444;
    flex-shrink: 0;
}

.channel-programs {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.channel-row {
    display: flex;
    position: relative;
    border-bottom: 1px solid #444;
}

.channel-name {
    position: sticky;
    left: 0;
    width: 120px;
    min-width: 120px;
    padding: 10px;
    background-color: #333;
    color: #ff0;
    font-weight: bold;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-right: 2px solid #444;
}

.programs-row {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    flex-grow: 1;
}

.programs-row::-webkit-scrollbar {
    display: none;
}

.program-cell {
    padding: 8px;
    border-right: 1px solid #333;
    font-size: 14px;
    color: #fff;
    cursor: default;
    min-height: 60px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.program-title {
    font-weight: bold;
    color: #0f0;
    margin-bottom: 4px;
}

.program-time {
    font-size: 12px;
    color: #0af;
}

.scroll-controls {
    display: flex;
    justify-content: space-between;
    position: absolute;
    width: 100%;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.scroll-left, .scroll-right {
    background-color: rgba(51, 51, 51, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    z-index: 3;
    margin: 0 10px;
}

@media (max-width: 768px) {
    .complete-guide-content {
        width: 100%;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }
    
    .day-selector {
        padding: 8px 0;
    }
    
    .day-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .time-header-cell {
        min-width: 100px;
        padding: 8px;
        font-size: 12px;
    }
    
    .channel-name {
        width: 80px;
        min-width: 80px;
        padding: 8px;
        font-size: 12px;
    }
    
    .program-cell {
        padding: 6px;
        font-size: 12px;
        min-height: 50px;
    }
    
    .program-time {
        font-size: 10px;
    }
    
    .scroll-left, .scroll-right {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .day-btn {
        padding: 4px 8px;
        font-size: 11px;
        margin: 0 2px;
    }
    
    .time-header-cell {
        min-width: 80px;
    }
    
    .channel-name {
        width: 60px;
        min-width: 60px;
    }
}

@media (max-width: 768px) {
    .no-frame-option {
        display: none; /* Hide no-frame toggle on mobile */
    }
    
    body {
        overflow: hidden;
    }
    
    /* Force no-frame mode on mobile */
    body.mobile-device .tv-image {
        display: none;
    }
    
    body.mobile-device .tv-screen {
        position: relative;
        width: 100vw;
        height: calc(100vw * 0.75); /* 4:3 aspect ratio */
        margin: 0 auto;
        z-index: 1;
        top: auto;
        left: auto;
    }
    
    body.mobile-device #player {
        width: 100%;
        height: 100%;
        aspect-ratio: 4/3;
    }
    
    .tv-controls {
        bottom: 50%;
        right: 2%;
        transform: translateY(50%) scale(0.7);
        max-height: 90vh;
        opacity: 0.85;
        transition: opacity 0.3s ease;
        z-index: 10; 
    }
    
    .tv-controls:hover {
        opacity: 1;
    }
    
    .mobile-adjust-controls {
        display: flex; 
    }
    
    .tv-image {
        height: 80vh;
        width: auto;
        object-fit: contain;
    }
    
    .tv-screen {
    }
    
    .chat-container {
        width: 180px;
        height: 250px;
        font-size: 12px;
        top: 10px;
        left: 10px;
        opacity: 0.85;
        transition: opacity 0.3s ease;
        z-index: 5;
    }
    
    .chat-container:hover {
        opacity: 1;
    }
    
    .chat-container.minimized {
        width: auto;
        min-width: 160px;
    }
    
    .guide-time-header {
        font-size: 14px;
        padding: 5px;
        margin-bottom: 5px;
    }
    
    .guide-channel-entry {
        margin-bottom: 8px;
        padding: 5px;
    }
    
    .guide-channel-name {
        font-size: 14px;
    }
    
    .guide-program-title, .guide-program-time {
        font-size: 12px;
    }
    
    .chat-input {
        font-size: 12px;
        padding: 5px;
    }
    
    .chat-send-button {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    .modal-content {
        width: 95%;
        margin: 30px auto;
        padding: 15px;
    }
    
    .background-option {
        width: 120px;
    }
    
    .bg-preview {
        width: 100px;
        height: 75px;
    }
    
    .settings-btn {
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
    
    .font-control {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

@media (orientation: portrait) {
    body {
        overflow: hidden;
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: 100dvh; /* Use dynamic viewport height for mobile browsers */
    }
    
    .tv-container {
        flex: 0 0 auto !important;
        height: auto;
        min-height: auto;
        display: flex !important;
        justify-content: center;
    }

    .tv-frame {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        padding-top: 0; /* Remove top padding to stick player to top */
    }
    
    .tv-image {
        height: auto;
        width: 95vw;
        object-fit: contain;
    }
    
    body.no-frame .tv-screen {
        width: 100vw;
        height: calc(100vw * 0.75); /* 4:3 aspect ratio */
        max-height: 45vh; /* Limit height to leave room for guide and chat */
        margin-top: 0; /* Remove margin to stick to top */
        flex-shrink: 0;
    }
    
    .tv-controls {
        display: none !important; /* Hide desktop controls in portrait */
    }
    
    .mobile-buttons-container {
        display: block !important; /* Force display for all devices in portrait */
        margin-top: 0; /* Remove margin to stick to player */
        border-top: none; /* Remove top border */
        flex-shrink: 0;
    }
    
    .mobile-program-guide {
        display: flex !important;
        flex-direction: column;
        width: 100vw;
        margin-top: 0;
        flex: 1 1 auto !important; /* Fill remaining space */
        height: auto !important;
        min-height: 0;
        overflow: hidden;
        z-index: 5;
        opacity: 1 !important;
        position: relative;
        border-bottom: none;
        background-color: #111;
    }
    
    .mobile-guide-content {
        flex: 1;
        display: flex;
        flex-direction: column !important;
        overflow-y: auto !important;
        overflow-x: hidden;
        padding: 0;
        gap: 0;
    }

    .mobile-guide-channel {
        flex-direction: row !important;
        width: 100% !important;
        min-width: 0 !important;
        border: none;
        border-bottom: 1px solid #333;
        border-radius: 0;
        margin: 0;
        padding: 10px;
        align-items: center;
        justify-content: flex-start;
        min-height: 70px;
    }
    
    .mobile-guide-channel:last-child {
        border-bottom: none;
    }

    .mobile-guide-channel-name {
        width: 70px;
        flex: 0 0 70px;
        border-bottom: none;
        border-right: 1px solid #444;
        margin-bottom: 0;
        padding-bottom: 0;
        padding-right: 10px;
        margin-right: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100%;
        white-space: normal;
        text-align: center;
        font-size: 16px;
    }

    .mobile-guide-programs {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        overflow: hidden;
        min-width: 0; /* Allow text truncate */
    }

    .mobile-guide-current {
        font-size: 14px;
        margin-bottom: 4px;
    }
    
    .mobile-guide-current strong {
        font-size: 15px;
        color: #fff;
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-guide-next {
        font-size: 12px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }


    
    .chat-container {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        width: 100vw !important;
        height: auto !important;
        max-height: calc(100vh - 60vh); /* Reserve space based on TV and controls */
        margin-top: 10px;
        box-sizing: border-box;
        border-radius: 0;
        border-left: none;
        border-right: none;
        z-index: 3 !important;
    }
    
    .chat-container.minimized {
        width: 100vw !important;
        min-width: 100vw !important;
    }
    
    .chat-content {
        max-height: calc(100vh - 70vh);
        overflow-y: auto;
    }
    
    .chat-container {
        display: none !important; /* Hide the regular guide in portrait mode */
    }
}

@media (orientation: landscape) and (max-width: 1024px) {
    html, body {
        margin: 0;
        padding: 0;
        background-color: #000 !important;
        overflow: hidden !important;
        width: 100%;
        height: 100%;
    }

    /* Target both explicit mobile class and general touch devices in this size range */
    body.mobile-device .tv-image,
    body .tv-image {
        display: none !important;
    }
    
    body.mobile-device .tv-container,
    body .tv-container {
        width: 100% !important;
        height: 100% !important;
        position: static !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
        flex: none !important;
        display: block !important;
    }

    body.mobile-device .tv-frame,
    body .tv-frame {
        width: 100% !important;
        height: 100% !important;
        position: static !important;
        display: block !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
    }
    
    body.mobile-device .tv-screen,
    body .tv-screen {
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: none !important;
        max-width: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        margin: 0 !important;
        z-index: 2147483647 !important;
        background: #000;
        border: none !important;
        transform: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }
    
    body.mobile-device #player,
    body #player {
        width: 100% !important;
        height: 100% !important;
        aspect-ratio: auto !important;
    }

    /* Hide everything else */
    body.mobile-device .mobile-buttons-container,
    body.mobile-device .mobile-program-guide,
    body.mobile-device .tv-controls,
    body.mobile-device .chat-container,
    body.mobile-device .debug-log-container,
    body.mobile-device .settings-btn,
    body.mobile-device .modal,
    body.mobile-device .chat-toggle-btn,
    body.mobile-device .guide-time-header,
    .mobile-buttons-container,
    .mobile-program-guide,
    .tv-controls,
    .chat-container,
    .settings-btn {
        display: none !important;
    }
}

@media only screen and (min-width: 768px) and (max-width: 1024px) {
    .mobile-buttons-container {
        display: none;
    }
    
    .mobile-program-guide {
        display: none;
    }
    
    .tv-controls {
        display: block;
    }
    
    .chat-container {
        display: block;
    }
    
    .settings-btn {
        display: block;
    }
}

@media only screen and (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    .mobile-buttons-container {
        display: block !important;
    }
    
    .mobile-program-guide {
        display: block !important;
        flex: 1;
    }
    
    .chat-container {
        display: none !important;
    }
    
    .tv-controls {
        display: none !important;
    }
}

@media (any-pointer: coarse) and (min-width: 960px) and (min-height: 540px) {
    .tv-image {
        height: 117vh;
    }
    
    .control-btn {
        font-size: 20px;
        padding: 12px 16px;
    }
    
    .volume-up, .volume-down, .channel-btn, .power-btn {
        width: 95px;
        height: 45px;
        font-size: 22px;
    }
    
    .chat-container,
    .debug-log-container {
        font-size: 18px;
    }
    
    .guide-channel-name {
        font-size: 20px;
    }
    
    .guide-program-title, 
    .guide-program-time {
        font-size: 16px;
    }
    
    .guide-time-header {
        font-size: 20px;
    }
    
    .settings-btn {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
    
    .modal-content h2 {
        font-size: 32px;
    }
    
    .modal-content p, 
    .modal-content li,
    .timezone-options label {
        font-size: 20px;
    }
}

@media screen and (min-width: 1920px) and (max-height: 1080px) and (orientation: landscape) {
    .tv-image {
        height: 117vh;
    }
    
    .control-btn {
        font-size: 22px;
        padding: 14px 18px;
    }
    
    .volume-up, .volume-down, .channel-btn, .power-btn {
        width: 100px;
        height: 50px;
        font-size: 24px;
    }
    
    .chat-container,
    .debug-log-container {
        font-size: 20px;
    }
}

@media (min-width: 1024px) and (max-width: 1366px) {
    .control-btn {
        padding: 5px 8px;
        font-size: 15px;
    }
    
    .volume-up, .volume-down, .channel-btn {
        width: 75px;
        height: 32px;
    }
    
    .tv-image {
        height: 104%;
    }
}

@media (min-width: 1367px) and (max-width: 1920px) {
    .control-btn {
        padding: 8px 12px;
        font-size: 16px;
    }
    
    .tv-image {
        height: 104%;
    }
}

@media (min-width: 1921px) {
    .control-btn {
        padding: 8px 12px;
        font-size: 16px;
    }
    
    .volume-up, .volume-down, .channel-btn {
        width: 85px;
        height: 35px;
    }
    
    .tv-image {
        height: 104%;
    }
}

/* Editor Styles */
.editor-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.editor-controls {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.editor-group {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.editor-group label {
    color: #0f0;
    font-size: 18px;
}

.editor-group select {
    background-color: #333;
    color: white;
    border: 2px solid #555;
    padding: 8px;
    font-family: 'VT323', monospace;
    font-size: 16px;
    border-radius: 4px;
}

.editor-group select:focus {
    border-color: #0f0;
    outline: none;
}

.editor-video-list-container {
    border: 2px solid #444;
    border-radius: 5px;
    padding: 10px;
    background-color: #1a1a1a;
    max-height: 300px;
    display: flex;
    flex-direction: column;
}

.editor-video-list-container h3 {
    color: #ddd;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
    margin-bottom: 10px;
}

.editor-video-list {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 100px;
    scrollbar-width: thin;
    scrollbar-color: #555 #222;
}

.editor-video-list::-webkit-scrollbar {
    width: 8px;
}

.editor-video-list::-webkit-scrollbar-track {
    background: #222;
}

.editor-video-list::-webkit-scrollbar-thumb {
    background-color: #555;
    border-radius: 4px;
}

.video-item {
    display: flex;
    flex-direction: column;
    background-color: #333;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #444;
}

.video-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.video-info {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 10px;
    color: #aaa;
    font-size: 14px;
}

.video-id {
    color: #0f0;
    font-weight: bold;
}

.video-item-actions {
    display: flex;
    gap: 5px;
}

.preview-video-btn, .delete-video-btn {
    border: none;
    border-radius: 3px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-family: 'VT323', monospace;
    font-size: 16px;
    transition: background-color 0.2s;
}

.delete-video-btn {
    background-color: #e74c3c;
    color: white;
}

.delete-video-btn:hover {
    background-color: #c0392b;
}

.preview-video-btn {
    background-color: #444;
    color: #0f0;
    border: 1px solid #555;
}

.preview-video-btn:hover {
    background-color: #555;
    border-color: #0f0;
}

.video-preview-container {
    width: 100%;
    margin-top: 10px;
    background-color: #000;
    border: 1px solid #444;
    display: none;
}

.video-preview-container iframe {
    display: block;
}

.editor-add-section {
    background-color: #2a2a2a;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid #444;
}

.editor-add-section h3 {
    color: #0af;
    margin-bottom: 10px;
}

.add-video-inputs {
    display: flex;
    gap: 10px;
}

#new-video-url {
    flex: 1;
    background-color: #111;
    border: 2px solid #555;
    color: white;
    padding: 8px;
    font-family: 'VT323', monospace;
    font-size: 16px;
    border-radius: 4px;
}

#new-video-url:focus {
    border-color: #0f0;
    outline: none;
}

#add-video-btn {
    background-color: #0c6;
    color: white;
    border: none;
    padding: 0 20px;
    font-family: 'VT323', monospace;
    font-size: 18px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
}

#add-video-btn:hover {
    background-color: #0a5;
}

.input-hint {
    color: #888;
    font-size: 14px;
    margin-top: 5px;
    font-style: italic;
}

.editor-actions {
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid #444;
    padding-top: 15px;
}

.reset-btn {
    background-color: #444;
    color: #fff;
    border: 1px solid #555;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'VT323', monospace;
    font-size: 16px;
}

.reset-btn:hover {
    background-color: #555;
    color: #f00;
    border-color: #f00;
}

.no-videos-message {
    color: #666;
    text-align: center;
    padding: 20px;
    font-style: italic;
}

@media (max-width: 600px) {
    .add-video-inputs {
        flex-direction: column;
    }
    
    #add-video-btn {
        width: 100%;
        padding: 10px;
    }
    
    .editor-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .editor-group {
        min-width: 100%;
    }
}

/* Program Info Icon and Modal */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background-color: #333;
    border: 2px solid #555;
    border-radius: 4px;
    color: #0af;
    font-size: 18px;
    font-family: 'VT323', monospace;
    font-weight: bold;
    font-style: normal;
    cursor: pointer;
    margin-left: 8px;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    line-height: 1;
    text-shadow: 1px 1px 0 #000;
}

.info-icon:hover {
    background-color: #444;
    border-color: #0af;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.6);
}

.info-icon:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.program-info-content {
    max-width: 500px;
    background-color: #222;
    border: 2px solid #0af;
    box-shadow: 0 0 20px rgba(0, 170, 255, 0.3);
}

.program-info-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
    text-align: left;
}

.info-row {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid #333;
    padding-bottom: 8px;
}

.info-label {
    color: #0af;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.info-value {
    color: #ddd;
    font-size: 18px;
}

.info-description {
    margin-top: 10px;
}

.info-description p {
    color: #ccc;
    line-height: 1.5;
    font-size: 18px;
    margin-top: 5px;
}

@media (max-width: 768px) {
    .info-icon {
        width: 28px;
        height: 28px;
        font-size: 20px;
        /* Larger visual size for touch */
        position: relative;
    }
    
    /* Extend hit area */
    .info-icon::after {
        content: '';
        position: absolute;
        top: -5px;
        right: -10px;
        bottom: -5px;
        left: -10px;
    }

    .program-info-content {
        width: 90%;
        margin: 20% auto;
    }
}

/* Votos - destaque do botão selecionado */
#btn-vote-up.voted-up,
.mobile-vote-up.voted-up {
    outline: 2px solid #2ecc71;
    box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.35);
}

#btn-vote-down.voted-down,
.mobile-vote-down.voted-down {
    outline: 2px solid #e74c3c;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.35);
}
