
        #loading-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.9); display: none; flex-direction: column; align-items: center; justify-content: center; z-index: 9999; color: #fff; font-family: monospace; }
    .spinner { width: 50px; height: 50px; border: 4px solid #fff; border-top: 4px solid #000; border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 1rem; }
    @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

* { box-sizing: border-box; font-family: monospace; }
body { background-color: #000; color: #fff; margin: 0; padding: 0; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; height: 100vh; width: 100vw; -webkit-user-select: none; user-select: none; }


    .flex { display: flex; }
    .flex-col { flex-direction: column; }
    .hidden { display: none !important; }


    #top-nav { position: fixed; top: 0; left: 0; width: 100%; height: 60px; display: flex; align-items: center; justify-content: center; gap: 4rem; background-color: #000; z-index: 1000; }
    .nav-link { color: #666; text-decoration: none; text-transform: uppercase; font-weight: bold; font-size: 1.1rem; letter-spacing: 0.1em; padding: 4px 10px; transition: color 0.2s ease; }
    .nav-link:hover, .nav-link.active { background-color: transparent; color: #fff; }


    #login-screen { 
    position: fixed; 
    top: 60px; 
    bottom: 0; 
    left: 0; 
    right: 0; 
    background-color: #000; 
    background-image: url('../assets/background.webp');
    background-repeat: no-repeat;
    background-position: center center; 
    background-size: cover; 
    z-index: 50; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: flex-start; 
    padding: 120px 1rem 1rem; 
    border: none; 
    margin: 0; 
}

.login-center-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
}

.login-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;     
    justify-content: center;
    height: calc(100vh - 60px);
    width: 100%;
    margin-top: 0; } 
    .login-wrap { text-align: center; max-width: 400px; width: 100%; margin: 0 auto; border: none; }
    .login-title { font-size: 1.45rem; font-weight: bold; color: #000; border: none; padding-bottom: 0.5rem; margin-bottom: 1.5rem; text-transform: uppercase; letter-spacing: 0.1em; }
    .bw-input { width: 100%; background-color: #000; border: 2px solid #fff; color: #fff; padding: 0.75rem; text-align: center; font-size: 1rem; outline: none; text-transform: uppercase; margin-bottom: 1rem; }
    .bw-input:focus { background-color: #fff; color: #000; }
    .toggle-container { display: flex; border: 2px solid #fff; margin-bottom: 1rem; }
    .toggle-btn { flex: 1; background: #000; color: #fff; border: none; padding: 0.5rem; font-weight: bold; cursor: pointer; text-transform: uppercase; }
    .toggle-btn.active { background: #fff; color: #000; }
    .bw-btn { width: 100%; background-color: #fff; color: #000; font-weight: bold; padding: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; border: 2px solid #fff; cursor: pointer; font-size: 1rem; }
    .bw-btn:hover { background-color: #000; color: #fff; }


    #vtt-interface { position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; z-index: 10; }
    canvas { touch-action: none; -webkit-user-select: none; user-select: none; }
    #vtt-canvas { flex: 1; min-height: 0; position: relative; width: 100%; background-color: #000; cursor: grab; display: block; }
    #vtt-canvas.plotting { cursor: crosshair !important; }


    .dice-history-ticker, .video-ribbon { flex-shrink: 0; }


    .toolbar { position: absolute; background: #000; border: 2px solid #fff; padding: 0.5rem; display: flex; flex-direction: column; gap: 0.35rem; z-index: 10; }
    #toolbar-left { top: 4rem; left: 1rem; box-shadow: 4px 4px 0px 0px #fff; width: 110px; }
    #toolbar-right { top: 4rem; right: 1rem; box-shadow: 4px 4px 0px 0px #fff; width: 170px; }


    .panel-label { font-size: 10px; text-align: center; border-bottom: 1px solid #fff; padding-bottom: 2px; text-transform: uppercase; color: #888; letter-spacing: 0.05em; cursor: move; padding-top: 2px; background: #111; margin: -0.5rem -0.5rem 0.2rem -0.5rem; }
    .panel-label:active { background: #fff; color: #000; }


    .tool-btn { background: #000; color: #fff; border: 1px solid #fff; padding: 0.25rem; font-size: 11px; text-transform: uppercase; cursor: pointer; font-weight: bold; width: 100%; text-align: center; display: block; margin-bottom: 4px; transition: all 0.2s ease; }
    .tool-btn:hover { background: #fff; color: #000; }
    .tool-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem; }
    .tool-row .tool-btn { margin-bottom: 0; }
    .toolbar-empty-slot { visibility: hidden; pointer-events: none; }
    .import-export-row { margin-bottom: 0.2rem; }
    #room-display { font-size: 10px; text-align: center; text-transform: uppercase; color: #fff; background: #222; padding: 4px; letter-spacing: 0.03em; }
    .tool-divider { border-top: 1px dashed #444; margin: 4px 0; }
    .grid-dice { display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem; }


    #ctx-menu { position: absolute; display: none; background: #000; border: 2px solid #fff; box-shadow: 4px 4px 0px 0px #fff; padding: 2px; z-index: 100; min-width: 150px; }
    .ctx-item { background: #000; color: #fff; border: none; padding: 6px 8px; font-size: 11px; font-weight: bold; text-transform: uppercase; text-align: left; width: 100%; display: block; cursor: pointer; }
    .ctx-item:hover { background: #fff; color: #000; }
    .ctx-item.danger { color: #ff3333; }
    .ctx-item.danger:hover { background: #ff3333; color: #000; }


    #torch-panel { top: 4rem; left: 40%; width: 240px; box-shadow: 4px 4px 0px 0px #fff; z-index: 60; }
    #turn-tracker-panel { top: 4rem; right: 30%; width: 300px; box-shadow: 4px 4px 0px 0px #fff; z-index: 60; }
    #fog-panel { top: 4rem; left: 20%; width: 180px; box-shadow: 4px 4px 0px 0px #fff; z-index: 60; }


    .torch-controls { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 10px; }
    .torch-status { font-size: 14px; font-weight: bold; padding: 2px 6px; color: #666; cursor: pointer; text-transform: uppercase; transition: color 0.2s ease; }
    .torch-status:hover { color: #aaa; }
    .torch-status.active { color: #fff; background: transparent; cursor: default; }
    #torch-clock { font-size: 1.5rem; font-weight: bold; color: #fff; letter-spacing: 0.05em; text-align: center; flex: 1; }


    .tracker-wrapper { display: flex; align-items: flex-end; justify-content: center; gap: 0; margin-top: 15px; margin-bottom: 5px; }
    .turn-col { display: flex; flex-direction: column; align-items: center; position: relative; }
    .turn-lbl { font-size: 11px; font-weight: bold; height: 16px; text-transform: uppercase; color: #ccc; }
    .turn-box { width: 32px; height: 32px; border: 2px solid #fff; border-right: none; background: #000; cursor: pointer; display: flex; justify-content: center; align-items: center; font-weight: bold; font-size: 20px; }
    .turn-col:last-of-type .turn-box { border-right: 2px solid #fff; }
    .turn-box.checked::after { content: 'X'; color: #fff; }
    .turn-reset-btn { background: transparent; border: none; color: #fff; font-size: 22px; cursor: pointer; margin-left: 14px; padding-bottom: 4px; font-weight: bold; }
    .turn-reset-btn:hover { color: #888; }
    #turn-message { margin-top: 10px; font-size: 10px; text-align: center; color: #fff; text-transform: uppercase; min-height: 40px; line-height: 1.4; font-weight: bold; }


    .dice-history-ticker { width: 100%; height: 35px; background: #000; border-top: 2px solid #fff; display: flex; align-items: center; justify-content: flex-start; padding: 0 1rem; font-size: 12px; font-weight: bold; overflow-x: auto; white-space: nowrap; gap: 1.5rem; z-index: 20; }
    .ticker-entry { color: #fff; text-transform: uppercase; border-right: 1px dashed #333; padding-right: 1.5rem; display: inline-block; }
    .ticker-entry span { color: #888; margin-right: 4px; }


    .video-ribbon {
    width: 100%;
    background: #000;
    border-top: 2px solid #fff;
    padding: 4px;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    height: clamp(126px, 10.25vw, 180px);
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.video-box {
    position: relative;
    flex: 0 1 clamp(150px, 15.65vw, 260px);
    aspect-ratio: 16 / 9;
    height: auto;
    max-height: calc(100% - 8px);
    background: #111;
    border: 2px solid #000;   /* Future initiative border */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-sizing: border-box;   /* Border won't resize box */
}
.video-box.initiative-active {
    outline: 3px solid #fff;
    outline-offset: 0;
}
    .video-box video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #111;
}
#local-video {
    transform: scaleX(-1);
    -webkit-transform: scaleX(-1);
    -moz-transform: scaleX(-1);
}
    .video-label { position: absolute; bottom: 4px; left: 4px; background: #000; color: #fff; font-size: 10px; padding: 2px 4px; border: 1px solid #fff; text-transform: uppercase; z-index: 5; }
    .video-controls-overlay { position: absolute; top: 4px; right: 4px; display: flex; gap: 2px; z-index: 5; opacity: 0.4; transition: opacity 0.2s ease; }
    .video-box:hover .video-controls-overlay { opacity: 1; }
    .media-toggle-btn { background: #000; color: #fff; border: 1px solid #fff; font-size: 8px; font-weight: bold; padding: 2px 4px; cursor: pointer; text-transform: uppercase; }
    .media-toggle-btn.muted-state { background: #ff3333; color: #fff; border-color: #ff3333; }
    .hardware-fail-alert { text-align: center; color: #666; font-size: 9px; padding: 10px; text-transform: uppercase; line-height: 1.3; font-weight: bold; }


.remote-media-status {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.82);
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    letter-spacing: 0.04em;
    z-index: 4;
    pointer-events: none;
}

.video-box[data-cam-enabled="false"] .remote-media-status {
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111;
}



    .dice-container-overlay { position: absolute; width: 120px; height: 140px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; pointer-events: none; z-index: 40; text-align: center; transition: opacity 0.5s ease-in-out; }
    .dice-sprite-frame { width: 100px; height: 100px; background-repeat: no-repeat; background-size: 700px 100px; background-position: 0px 0px; display: flex; align-items: center; justify-content: center; position: relative; }
    .dice-numerical-overlay { font-size: 24px; font-weight: bold; color: #fff; text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000; display: none; z-index: 2; }
    .dice-player-label { margin-top: 4px; background-color: #000; color: #fff; border: 1px solid #fff; font-size: 11px; padding: 2px 6px; text-transform: uppercase; letter-spacing: 0.05em; box-shadow: 2px 2px 0px 0px #fff; white-space: nowrap; }


    ::-webkit-scrollbar { width: 4px; height: 4px; }
    ::-webkit-scrollbar-track { background: #000; }
    ::-webkit-scrollbar-thumb { background: #fff; }    

.video-box.initiative-active { border-color: #fff; }

.gm-room-note { font-size: 11px; color: #fff; text-align: center; margin-top: -0.5rem; margin-bottom: 0.75rem; }

.community-counter {
    font-size: 11px;
    color: #fff;
    text-align: center;
    margin-top: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    min-height: 14px;
}


.note-editor {
    position: absolute;
    width: 260px;
    background: #000;
    border: 2px solid #fff;
    box-shadow: 4px 4px 0px 0px #fff;
    padding: 0.5rem;
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.note-editor label {
    font-size: 10px;
    color: #aaa;
    text-transform: uppercase;
    font-weight: bold;
}

.note-input,
.note-textarea {
    width: 100%;
    background: #000;
    color: #fff;
    border: 1px solid #fff;
    padding: 0.35rem;
    font-size: 12px;
    outline: none;
}

.note-input {
    -webkit-user-select: text;
    user-select: text;
}

.note-input:focus,
.note-textarea:focus {
    background: #fff;
    color: #000;
}

.note-textarea {
    min-height: 90px;
    resize: vertical;
    -webkit-user-select: text;
    user-select: text;
}

.note-editor-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.35rem;
}

.tool-btn.danger {
    color: #ff3333;
    border-color: #ff3333;
}

.tool-btn.danger:hover {
    background: #ff3333;
    color: #fff;
}


.sketch-tool-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.25rem;
}

.sketch-tool-btn {
    width: 100%;
    min-height: 28px;
    font-size: 18px;
    line-height: 1;
    margin-bottom: 4px;
    padding: 0.2rem 0;
}


#btn-sketch-circle {
    font-size: 22px;
}

.sketch-tool-btn.active {
    background: #fff;
    color: var(--sketch-icon-color, #000);
}

.sketch-tool-btn.active.sketch-color-white {
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

.sketch-tool-btn.active:hover {
    background: #fff;
    color: var(--sketch-icon-color, #000);
}

#vtt-canvas.sketching {
    cursor: crosshair !important;
}

#vtt-canvas.erasing-sketch {
    cursor: not-allowed !important;
}


@media (max-width: 1100px) {
    .video-ribbon {
        justify-content: flex-start;
    }

    .video-box {
        flex-basis: 140px;
    }

    .video-label,
    .remote-media-status,
    #local-media-status {
        font-size: 9px !important;
    }
}


.video-moderation-menu {
    position: fixed;
    z-index: 1200;
    width: 140px;
    padding: 3px;
    background: #000;
    border: 1px solid #fff;
    box-shadow: 3px 3px 0 #555;
}
.video-moderation-menu-item {
    display: block;
    width: 100%;
    padding: 7px 9px;
    background: #000;
    color: #fff;
    border: 0;
    text-align: left;
    font: inherit;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
}
.video-moderation-menu-item:hover:not(:disabled) { background: #fff; color: #000; }
.video-moderation-menu-item:disabled { color: #666; cursor: default; }
