body {
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    overflow: hidden;
    background-color: black;
}

/* AI-assisted addition: scrollable body for the "1:1 native resolution" video scaling
   mode, where the video may be larger than the viewport (see #video.video-scale-native). */
body.video-scroll {
    overflow: auto;
    align-items: flex-start;
    justify-content: flex-start;
}

#video {
    display: block;
    margin: auto;
    z-index: 0;
}

/* AI-assisted addition: video scaling modes, selectable from Settings > Display.
   Exactly one of these classes is applied to #video at a time (see setVideoScalingMode()
   in local-kvm.js). */

/* Fill: always stretch to the container width (may upscale). This is the pre-existing
   default behavior, previously hardcoded as an inline style on the <video> tag. */
#video.video-scale-fill {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100vh;
    object-fit: contain;
}

/* Fit: scale down only if the native stream is larger than the viewport; otherwise shown
   at native size. Never upscales. */
#video.video-scale-fit {
    width: auto;
    height: auto;
    max-width: 100vw;
    max-height: 100vh;
    object-fit: contain;
}

/* Native (1:1): always shown at exact native pixel size, never scaled. Combined with
   body.video-scroll so oversized video is scrollable instead of clipped. */
#video.video-scale-native {
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
}

#menu {
    position: fixed;
    top: 0px;
    left: 50%;
    width: 80%;
    transform: translateX(-50%);
    padding: 0.4em;
    display: flex;
    gap: 3px;
    z-index: 1000;
    background-color: rgba(255,255,255,0.9);
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    align-items: center;
}

@media (max-width: 1280px) {
    #menu {
        width: calc(100% - 1em);
    }
}

#touchscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 500;
    user-select: none;
}

/* Paste Box Styles */
.paste-box-container {
    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: 2000;
}

.paste-box {
    background: white;
    padding: 2em;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.paste-box textarea {
    width: 100%;
    min-height: 200px;
    margin-bottom: 1em;
    font-family: monospace;
    resize: vertical;
}

.paste-box-buttons {
    display: flex;
    gap: 0.5em;
    justify-content: flex-end;
}

.paste-char-counter {
    text-align: right;
    font-size: 0.9em;
    color: #767676;
    margin-bottom: 0.5em;
}

#pasteConfirmModal .message p {
    margin: 0.5em 0;
    font-size: 0.95em;
}

/* On-Screen Keyboard Styles */
.onscreen-keyboard {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(40, 40, 40, 0.95);
    padding: 10px;
    border-radius: 8px 8px 0 0;
    z-index: 1500;
    min-width: 800px;
    max-width: 95vw;
}

.onscreen-keyboard.fullwidth {
    width: 100%;
    max-width: 100%;
    left: 0;
    transform: none;
    border-radius: 0;
}

.keyboard-drag-bar {
    background: rgba(100, 100, 100, 0.5);
    height: 30px;
    margin: -10px -10px 10px -10px;
    border-radius: 8px 8px 0 0;
    cursor: move;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
}

.keyboard-controls {
    display: flex;
    gap: 5px;
}

.keyboard-row {
    display: flex;
    gap: 5px;
    margin-bottom: 5px;
    justify-content: center;
}

.key {
    background: linear-gradient(180deg, #f0f0f0, #d0d0d0);
    border: 1px solid #999;
    border-radius: 4px;
    padding: 8px 12px;
    min-width: 40px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    font-weight: 500;
    color: #333;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.1s;
}

.key:hover {
    background: linear-gradient(180deg, #fff, #e0e0e0);
    transform: translateY(-1px);
}

.key:active, .key.active {
    background: linear-gradient(180deg, #4a9eff, #2078d4);
    color: white;
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.key.held {
    background: linear-gradient(180deg, #ff9800, #f57c00);
    color: white;
    box-shadow: 0 0 8px rgba(255, 152, 0, 0.6);
}

.key.wide {
    min-width: 80px;
}

.key.wider {
    min-width: 100px;
}

.key.widest {
    min-width: 200px;
}

.key-label {
    font-size: 12px;
    display: block;
}

.key-sublabel {
    font-size: 9px;
    color: #666;
    display: block;
}

/* Browser Warning Styles */
#browserWarning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

#browserWarning.visible {
    opacity: 1;
    pointer-events: auto;
}

.warning-content {
    background-color: #f5f5f5;
    padding: 2.5em 3em;
    border-radius: 0.8em;
    max-width: 600px;
    width: 92vw;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.warning-icon {
    font-size: 64px;
    color: #f2711c;
    margin-bottom: 0.6em;
}

.warning-content h2 {
    color: #db2828;
    margin-bottom: 0.8em;
}

.warning-content p {
    font-size: 1.05em;
    line-height: 1.6;
    margin-bottom: 1.2em;
    color: #333;
}

.supported-browsers {
    display: flex;
    justify-content: center;
    gap: 0.8em;
    margin: 1.2em 0;
    flex-wrap: wrap;
}

.browser-badge {
    padding: 0.5em 1em;
    background: #eaeaea;
    border: 1px solid #d8d8d8;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.92em;
    color: #444;
}

/* KVM Connect Prompt Styles */
#kvmConnectPrompt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

#kvmConnectPrompt.visible {
    opacity: 1;
    pointer-events: auto;
}

.kvm-prompt-panel {
    background-color: #f5f5f5;
    padding: 2.5em 3em;
    border-radius: 0.8em;
    max-width: 560px;
    width: 92vw;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.kvm-prompt-panel .prompt-icon {
    font-size: 56px;
    margin-bottom: 0.5em;
    color: #2185d0;
}

.kvm-prompt-panel h2 {
    color: #333;
    margin-bottom: 0.6em;
    font-size: 1.4em;
}

.kvm-prompt-panel p {
    font-size: 1em;
    line-height: 1.6;
    color: #555;
    margin-bottom: 1em;
}

.kvm-prompt-panel .prompt-steps {
    text-align: left;
    margin: 1.2em auto;
    max-width: 380px;
}

.kvm-prompt-panel .prompt-steps .step-item {
    display: flex;
    align-items: center;
    gap: 0.6em;
    padding: 0.45em 0;
    font-size: 0.95em;
    color: #444;
}

.kvm-prompt-panel .prompt-steps .step-item i.icon {
    color: #2185d0;
    font-size: 1.1em;
    width: 1.4em;
    text-align: center;
}

.kvm-prompt-panel .prompt-actions {
    margin-top: 1.5em;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1em;
}

.kvm-prompt-panel .do-not-show {
    margin-top: 0.5em;
    font-size: 0.88em;
    color: #777;
    display: flex;
    align-items: center;
    gap: 0.4em;
    cursor: pointer;
}

.kvm-prompt-panel .do-not-show input[type="checkbox"] {
    cursor: pointer;
}

/* Copy Box Styles */
.copy-box-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3000;
    cursor: crosshair;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.copy-box-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.copy-box-hint {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 6px 18px;
    border-radius: 6px;
    font-size: 0.95em;
    pointer-events: none;
    z-index: 3001;
}

.copy-box-lang-popup {
    position: fixed;
    z-index: 3100;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.35);
    padding: 12px 16px;
    min-width: 240px;
}

.copy-box-lang-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.copy-box-lang-select {
    width: 100%;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 0.95em;
}

.copy-box-lang-buttons {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 4px;
}

.copy-box-result-container {
    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: 2000;
}

.copy-box-result {
    background: white;
    padding: 2em;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.copy-box-result textarea {
    width: 100%;
    min-height: 200px;
    margin-bottom: 1em;
    font-family: monospace;
    resize: vertical;
}

.copy-box-result-buttons {
    display: flex;
    gap: 0.5em;
    justify-content: flex-end;
}

.copy-box-options {
    margin-bottom: 1em;
}

.copy-box-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1em;
    color: #555;
    font-size: 0.95em;
}

/* No-signal overlay */
#noSignalOverlay {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 50px;
    background: rgba(0, 0, 0, 0.8);
    z-index: 500;
    justify-content: center;
    align-items: center;
}

#noSignalOverlay span {
    color: #f7f7f7;
    font-size: 1em;
    text-align: center;
    padding: 2em;
    max-width: 600px;
    line-height: 1.6;
}

#settings{
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
}

/* Stacked Keys display (bottom-left corner) */
#stackedKeysDisplay {
    display: none;
    position: fixed;
    bottom: 0.6em;
    left: 0.6em;
    z-index: 9000;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4em;
    max-width: 60vw;
    /* Solid background so it never blends with the remote screen content */
    background: #1b1c1d;
    border: 2px solid #2185d0;
    border-radius: 8px;
    padding: 0.6em 0.75em;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#stackedKeysDisplay .stacked-keys-title {
    color: #f7f7f7;
    font-size: 0.78em;
    font-weight: 600;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 0.4em;
    width: 100%;
}

#stackedKeysDisplay .stacked-keys-title .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #21ba45;
    box-shadow: 0 0 6px #21ba45;
    animation: stackedKeysPulse 1.2s ease-in-out infinite;
}

@keyframes stackedKeysPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

#stackedKeysDisplay .stacked-keys-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.35em;
    width: 100%;
}

#stackedKeysDisplay .stacked-key-chip {
    background: #2185d0;
    color: #fff;
    font-size: 0.85em;
    font-weight: 600;
    padding: 0.25em 0.6em;
    border-radius: 5px;
    border: 1px solid #1678c2;
    min-width: 1.6em;
    text-align: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

#stackedKeysDisplay .stacked-keys-empty {
    color: #b0b3b5;
    font-size: 0.82em;
    font-style: italic;
}

#stackedKeysDisplay .stacked-keys-hint {
    color: #9a9d9f;
    font-size: 0.7em;
    width: 100%;
    text-align: left;
    border-top: 1px solid #333436;
    padding-top: 0.35em;
}

/* Stacked Keys long-press trigger indicator (bottom-left) */
#stackTriggerIndicator {
    display: none;
    position: fixed;
    bottom: 0.8em;
    left: 0.8em;
    width: 50px;
    height: 12px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid #ffffff;
    border-radius: 6px;
    overflow: hidden;
    z-index: 9000;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

#stackTriggerIndicator .fill {
    width: 0%;
    height: 100%;
    background: #ffffff;
    border-radius: 6px;
}