body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #004fed;
    color: #005dd7;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.code-pad {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

.editor-container {
    position: relative;
    flex: 1;
}

/* Ensure the editor element and CodeMirror occupy the full viewport height */
#editor {
    width: 100%;
    height: 100vh !important;
}

.CodeMirror {
    height: 100vh !important;
}

.CodeMirror-scroll {
    height: 100vh !important;
}

.background-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.video-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0; /* sits below wrapper; video will be moved into wrapper for layering */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    pointer-events: auto; /* allow playback controls */
}

.video-layer video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.highlight-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0; /* bottom-most inside editor wrapper */
    pointer-events: none;
}

.video-in-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1; /* sits above highlights but below editor text */
}

.mid-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2; /* reserved mid layer (optional) */
    pointer-events: none;
}

.CodeMirror {
    position: relative;
    z-index: 10000; /* editor text sits on top */
}

.CodeMirror {
    position: relative;
    z-index: 10000; /* ensure editor text sits on top of video/highlight layers */
    font-family: 'Courier New', monospace;
    font-size: 14px;
    height: auto;
}

/* Force the visible editor/code text to black for readability, but only
   when the CodeMirror wrapper has the `screen-change-black` class (i.e.
   while the window is unfocused). This avoids overriding theme colors
   at all times. */
.CodeMirror.screen-change-black, .CodeMirror.screen-change-black * {
    color: #000 !important;
    -webkit-text-fill-color: #000 !important;
}

.alt-bg-black {
    background-color: black;
    color: transparent !important;
    /* position: relative; */
    /* z-index: -1; */
}

.alt-bg-white {
    background-color: white;
    color: transparent !important;
    z-index: -1;

}

#runButton {
    margin-top: 1rem;
    align-self: flex-start;
    background-color: #4a5568;
    color: #e2e8f0;
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
}

#runButton:hover {
    background-color: #2d3748;
}

#output {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #2d3748;
    border: 1px solid #4a5568;
    min-height: 100px;
    white-space: pre-wrap;
    color: #045bce;
}

/* Strong overrides to prevent the original .video-layer from floating above the editor.
   These use !important to override any inline styles or third-party rules that
   may create unexpected stacking contexts. */
.video-layer {
    /* display: none !important; */
    /* visibility: hidden !important; */
    z-index: 2 !important;

}

.editor-container, .CodeMirror, .CodeMirror-scroll, .CodeMirror-sizer {
    position: relative !important;
    z-index: 3 !important;
    /* z-index: 100000 !important; */
}

/* Ensure any video moved into the wrapper sits below the editor text */
.video-in-wrapper, #drmVideo {
    position: absolute !important;
    /* z-index: 1 !important; */
    inset: top !important; /* top/right/bottom/left: 0 */
    width: 99.9% !important;
    height: 100% !important;
    z-index: 2 !important;
    border: 1px solid transparent;
    transform: translateZ(0);






}

/* Keep the highlight layer below the video-in-wrapper */
.highlight-layer {
    z-index: 0 !important;
}

/* Force the highlight layer to be a solid white background so it appears
   uniformly white behind/over the editor as needed. Use !important to
   override inline or other competing rules. */
.highlight-layer {
    background: #ffffff !important;
    opacity: 1 !important;
}

/* Ensure the mirrored text in the between-layer is rendered in black for contrast */
.between-text {
    color: #000 !important;
    -webkit-text-fill-color: #000 !important;
}

/* Line number gutter for the mirrored layer */
.line-number-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 48px;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    background: transparent;
}
.line-number-layer {
    /* hide the mirrored line-number layer; use CodeMirror's native gutter */
    display: none !important;
}
.line-number-layer .line-numbers {
    color: #666 !important;
    -webkit-text-fill-color: #666 !important;
    font-family: 'Courier New', monospace !important;
    font-size: 13px !important;
    line-height: 1.35 !important;
    margin: 0 !important;
    padding: 8px 6px 8px 0 !important;
    text-align: right !important;
}

/* Ensure CodeMirror's native gutter (line numbers) is visible and on the code layer */
.CodeMirror-gutters {
    z-index: 10002 !important; /* above video and mirrors, below editor content */
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    background: transparent !important;
}
.CodeMirror-gutter {
    color: #666 !important;
    background: transparent !important;
}
.CodeMirror-gutter-wrapper { display: block !important; }

/* Make the mirrored text larger and more legible */
.between-text {
    font-size: 18px !important;
    font-weight: 600 !important;
    line-height: 1.35 !important;
}

/* Hide native browser video controls (best-effort) and Shaka UI overlays */
#drmVideo::-webkit-media-controls { display: none !important; }
#drmVideo::-webkit-media-controls-enclosure { display: none !important; }
#drmVideo::-webkit-media-controls-panel { display: none !important; }

/* Shaka UI selectors (if Shaka UI is used) */
.shaka-ui, .shaka-controls, .shaka-overlay-container { display: none !important; }

/* Provide a safer programmatic fallback: ensure the video doesn't show controls by default */
#drmVideo[controls] { display: block; }

/* Full-screen overlay shown when the window/tab loses focus */
#screen-change-overlay {
    position: fixed;
    inset: 0;
    display: none; /* toggled from JS */
    align-items: center;
    justify-content: center;
    z-index: 2147483647;
    background: rgba(0,0,0,0.75);
    color: #fff;
    font-size: 28px;
    font-weight: 600;
    text-align: center;
    pointer-events: auto; /* block input while overlay is visible */
    padding: 1rem;
}

@media (max-width: 640px) {
    #screen-change-overlay { font-size: 18px; }
}

/* Hide layers until Shaka player is fully loaded */
.hidden-until-shaka {
    display: none !important;
}

/* When the screen change overlay is active, make the mid/question layer
   visually black so any question content is hidden or darkened. We also
   apply a style to the between-layer to ensure mirrored text matches. */
.mid-layer.screen-change-black {
    background: #000 !important;
    opacity: 1 !important;
}

.between-layer.screen-change-black .between-text {
    color: #000 !important;
    -webkit-text-fill-color: #000 !important;
}