body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    background-color: #1a1a1a;
    --tooltip-delay: 0ms;
}
.container {
    text-align: center;
    padding: 40px;
    background-color: #0a0a0a;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(255,255,255,0.1);
}
.auth-status {
    color: #2d8b16;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 20px;
    min-height: 27px;
}
/* Feature menu dropdown styling */
.feature-menu {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

/* Page menu dropdown styling */
.page-menu {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
}

.feature-menu select,
.page-menu select {
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #4a4a4a;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    outline: none;
}

.feature-menu select:hover,
.page-menu select:hover {
    background-color: #3a3a3a;
    border-color: #5a5a5a;
}

.feature-menu select:focus,
.page-menu select:focus {
    border-color: #4CAF50;
}
/* Game title styling - updated */
.game-title {
    color: #4CAF50 !important;
    background-color: #2a2a2a;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 20px;
    height: 60px;
    padding: 10px;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
h1 {
    color: #e0e0e0;
    margin-bottom: 20px;
    min-height: 1.2em;
}
.mega-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 20px;
}
.mini-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.mini-grid.inactive .element {
    background-color: #151515;
    opacity: 0.3;
    pointer-events: none;
}
.mini-grid.test-grid .element {
    background-color: #3a3a3a;
}
.mini-grid.test-grid.checking .element {
    background-color: #5a5a5a;
}
.mini-grid.test-grid.failed .element {
    background-color: #8b0000;
}
.mini-grid.test-grid.success .element {
    background-color: #2d8b16;
}
.element {
    background-color: #2a2a2a;
    color: #e0e0e0;
    width: 80px;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    border-radius: 0;
    user-select: none;
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}
.element .corner-number,
.element .corner-number-br,
.element .corner-number-tr,
.element .corner-number-bl {
    display: none;
}
#mainGrid .element .corner-number {
    display: block;
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 10px;
    color: #888;
}
#mainGrid .element .corner-number-tr {
    display: block;
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 10px;
    color: #888;
}
#mainGrid .element .corner-number-bl {
    display: block;
    position: absolute;
    bottom: 2px;
    left: 2px;
    font-size: 10px;
    color: #888;
}
#mainGrid .element .corner-number-br {
    display: block;
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 10px;
    color: #888;
}
#mainGrid.auth-grid .element {
    font-size: 0;
}
#mainGrid.auth-grid .element .corner-number,
#mainGrid.auth-grid .element .corner-number-tr,
#mainGrid.auth-grid .element .corner-number-bl,
#mainGrid.auth-grid .element .corner-number-br {
    display: none;
}
.element.selected {
    background-color: #4a7c59;
}
/* Mobile responsive styles */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .element {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .mega-grid {
        gap: 5px;
    }
    
    .mini-grid {
        gap: 3px;
    }
    
    .feature-menu {
        top: 10px;
        right: 10px;
    }
    
    .page-menu {
        top: 10px;
        left: 10px;
    }
    
    .feature-menu select,
    .page-menu select {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    /* Larger resize handles for touch on mobile */
    .resize-handle {
        width: 20px;
        height: 20px;
    }
    
    .resize-handle.top-left {
        top: -10px;
        left: -10px;
    }
    
    .resize-handle.bottom-right {
        bottom: -10px;
        right: -10px;
    }
}

/* Voynich Manuscript Viewer Styles */
.voynich-container {
    text-align: center;
    padding: 20px;
    background-color: #0a0a0a;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(255,255,255,0.1);
    max-width: 1200px;
    margin: 0 auto;
}

.voynich-title {
    color: #4CAF50;
    background-color: #2a2a2a;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 20px;
    padding: 10px;
    border-radius: 4px;
}

.zoom-controls {
    position: sticky;
    top: 20px;
    margin-bottom: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    z-index: 100;
    background-color: #0a0a0a;
    padding: 10px;
    border-radius: 4px;
}

.zoom-controls button {
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #4a4a4a;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 16px;
    cursor: pointer;
    min-width: 40px;
}

.zoom-controls button:hover {
    background-color: #3a3a3a;
    border-color: #5a5a5a;
}

.zoom-controls button:active {
    background-color: #4a4a4a;
}

#zoomLevel {
    color: #e0e0e0;
    font-size: 14px;
    min-width: 50px;
    text-align: center;
}

/* Layer Navigation Controls */
.layer-controls {
    position: sticky;
    top: 60px;
    margin-bottom: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    z-index: 100;
    background-color: #0a0a0a;
    padding: 10px;
    border-radius: 4px;
}

.layer-controls button {
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #4a4a4a;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 16px;
    cursor: pointer;
    min-width: 40px;
}

.layer-controls button:hover {
    background-color: #3a3a3a;
    border-color: #5a5a5a;
}

.layer-controls button:active {
    background-color: #4a4a4a;
}

/* Edit Mode button styling */
#editModeBtn {
    margin-left: 10px;
    background-color: #2a2a2a;
    border-color: #666;
}

#editModeBtn:hover {
    background-color: #3a3a3a;
    border-color: #888;
}

#editModeBtn.active {
    background-color: #d32f2f;
    border-color: #f44336;
    color: #fff;
}

#editModeBtn.active:hover {
    background-color: #c62828;
    border-color: #e53935;
}

#layerDisplay {
    color: #4CAF50;
    font-size: 14px;
    font-weight: bold;
    width: 200px;
    text-align: center;
}

#voynichViewer {
    position: relative;
    background-color: #1a1a1a;
    border-radius: 4px;
    padding: 20px;
    overflow: auto;
    max-height: 70vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

#imageContainer {
    display: inline-block;
    position: relative;
}

.word-overlay {
    position: absolute;
    border: 2px solid rgba(76, 175, 80, 0.6);
    background-color: rgba(76, 175, 80, 0.1);
    cursor: pointer;
    box-sizing: border-box;
    transition: background-color 0.1s, border-color 0.1s;
}

.word-overlay:hover {
    background-color: rgba(76, 175, 80, 0.3);
    border-color: rgba(76, 175, 80, 0.9);
    --tooltip-delay: 0ms;
}

/* Resize handles for edit mode */
.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #fff;
    border: 2px solid #333;
    border-radius: 50%;
    display: none;
    z-index: 10;
}

.word-overlay.selected .resize-handle {
    display: block;
}

.resize-handle.top-left {
    top: -5px;
    left: -5px;
    cursor: nwse-resize;
}

.resize-handle.bottom-right {
    bottom: -5px;
    right: -5px;
    cursor: nwse-resize;
}

/* Layer-specific colors and opacity */
.word-overlay.layer-1 {
    border-color: rgba(76, 175, 80, 0.6);     /* Green */
    background-color: rgba(76, 175, 80, 0.1);
}

.word-overlay.layer-1:hover {
    border-color: rgba(76, 175, 80, 0.9);
    background-color: rgba(76, 175, 80, 0.3);
}

.word-overlay.layer-2 {
    border-color: rgba(33, 150, 243, 0.6);    /* Blue */
    background-color: rgba(33, 150, 243, 0.1);
}

.word-overlay.layer-2:hover {
    border-color: rgba(33, 150, 243, 0.9);
    background-color: rgba(33, 150, 243, 0.3);
}

.word-overlay.layer-3 {
    border-color: rgba(0, 188, 212, 0.6);     /* Cyan */
    background-color: rgba(0, 188, 212, 0.1);
}

.word-overlay.layer-3:hover {
    border-color: rgba(0, 188, 212, 0.9);
    background-color: rgba(0, 188, 212, 0.3);
}

.word-overlay.layer-4 {
    border-color: rgba(156, 39, 176, 0.6);    /* Purple */
    background-color: rgba(156, 39, 176, 0.1);
}

.word-overlay.layer-4:hover {
    border-color: rgba(156, 39, 176, 0.9);
    background-color: rgba(156, 39, 176, 0.3);
}

.word-overlay.layer-5 {
    border-color: rgba(255, 152, 0, 0.6);     /* Orange */
    background-color: rgba(255, 152, 0, 0.1);
}

.word-overlay.layer-5:hover {
    border-color: rgba(255, 152, 0, 0.9);
    background-color: rgba(255, 152, 0, 0.3);
}

.word-overlay.layer-6 {
    border-color: rgba(255, 235, 59, 0.8);    /* Yellow - opaque */
    background-color: rgba(255, 235, 59, 0.6);
}

.word-overlay.layer-6:hover {
    border-color: rgba(255, 235, 59, 1);
    background-color: rgba(255, 235, 59, 0.8);
}

.word-overlay.layer-7 {
    border-color: rgba(0, 0, 0, 0.8);     /* Black - opaque (TEST) */
    background-color: rgba(0, 0, 0, 0.6);
}

.word-overlay.layer-7:hover {
    border-color: rgba(0, 0, 0, 1);
    background-color: rgba(0, 0, 0, 0.8);
}

/* Text display on overlay boxes for all layers */
.overlay-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 2px 4px;
    font-size: 10px;
    color: #fff;
    background-color: rgba(75, 0, 130, 0.7);  /* Default: Dark purple */
    pointer-events: none;
    word-wrap: break-word;
    overflow: hidden;
    line-height: 1.2;
    display: none;
    z-index: 5;
    box-sizing: border-box;
}

/* Layer-specific text backgrounds */
.word-overlay.layer-1 .overlay-text {
    background-color: rgba(139, 0, 0, 0.7);  /* Dark red for EVA */
}

.word-overlay.layer-2 .overlay-text {
    background-color: rgba(0, 0, 139, 0.7);  /* Dark blue for Pen Strokes */
}

.word-overlay.layer-3 .overlay-text {
    background-color: rgba(0, 139, 139, 0.7);  /* Dark cyan for Numbers */
}

.word-overlay.layer-4 .overlay-text {
    background-color: rgba(75, 0, 130, 0.7);  /* Dark purple for Semantics */
}

.word-overlay.layer-5 .overlay-text {
    background-color: rgba(139, 69, 0, 0.7);  /* Dark orange for Morphemes */
}

.word-overlay.layer-6 .overlay-text {
    background-color: rgba(139, 139, 0, 0.7);  /* Dark yellow for Morpheme Translation */
}

.word-overlay.layer-7 .overlay-text {
    background-color: rgba(0, 100, 0, 0.7);  /* Dark green for Full Translation */
}

#manuscriptImage {
    display: block;
    border: 1px solid #4a4a4a;
    user-select: none;
    -webkit-user-drag: none;
}

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

.modal-content {
    background-color: #2a2a2a;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #4a4a4a;
    border-radius: 8px;
    width: 80%;
    max-width: 400px;
    color: #e0e0e0;
    position: relative;
}

.modal-content h3 {
    color: #4CAF50;
    margin-top: 0;
}

.modal-field {
    margin: 15px 0;
    font-size: 16px;
}

.modal-field strong {
    color: #4CAF50;
}

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

.modal-close {
    color: #888;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.modal-close:hover,
.modal-close:focus {
    color: #e0e0e0;
}

/* Edit Toolbar Styles */
.edit-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    background-color: #2a2a2a;
    border: 1px solid #4a4a4a;
    border-radius: 0 0 8px 0;
    padding: 10px;
    z-index: 1500;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    /* Prevent toolbar from scaling with page zoom */
    transform-origin: top left;
    will-change: transform;
}

.toolbar-toggle {
    background-color: #3a3a3a;
    color: #e0e0e0;
    border: 1px solid #4a4a4a;
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 14px;
    cursor: pointer;
    min-width: 30px;
    flex-shrink: 0;  /* Never shrink the toggle button */
}

.toolbar-toggle:hover {
    background-color: #4a4a4a;
}

/* Toggle button text changes based on state */
.edit-toolbar:not(.collapsed) .toolbar-toggle::before {
    content: '◀';
}

.edit-toolbar.collapsed .toolbar-toggle::before {
    content: '▶';
}

.toolbar-content {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    transition: max-width 0.3s ease, opacity 0.2s ease;
    max-width: 500px;  /* Enough for all buttons */
    opacity: 1;
}

.edit-toolbar.collapsed .toolbar-content {
    max-width: 0;
    opacity: 0;
    gap: 0;
}

.toolbar-btn {
    background-color: #3a3a3a;
    color: #e0e0e0;
    border: 1px solid #4a4a4a;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background-color: #4a4a4a;
    border-color: #5a5a5a;
}

.toolbar-btn.active {
    background-color: #4CAF50;
    border-color: #66BB6A;
    color: #fff;
}

.toolbar-spacer {
    width: 60px;
    height: 36px;
    border: 1px dashed #4a4a4a;
    border-radius: 4px;
    background-color: #1a1a1a;
}

/* Mobile adjustments for toolbar */
@media (max-width: 768px) {
    .edit-toolbar {
        left: 0;
        right: 0;
        transform: none;
        border-radius: 0 0 8px 8px;
        padding: 8px;
    }
    
    .toolbar-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .toolbar-spacer {
        width: 40px;
        height: 32px;
    }
}

/* Drag selection rectangle */
.selection-rectangle {
    position: absolute;
    border: 2px dashed #4CAF50;
    background-color: rgba(76, 175, 80, 0.2);
    pointer-events: none;
    z-index: 1000;
}

/* Group bounding box (for resizing group) */
.group-bounds {
    position: absolute;
    border: 2px solid #FF9800;
    background-color: transparent;
    pointer-events: none;
    z-index: 999;
}

/* Resize handles for group bounds */
.group-resize-handle {
    position: absolute;
    width: 15px;
    height: 15px;
    background-color: #FF9800;
    border: 2px solid #fff;
    border-radius: 50%;
    pointer-events: auto;
    z-index: 1001;
}

.group-resize-handle.top-left {
    top: -7.5px;
    left: -7.5px;
    cursor: nwse-resize;
}

.group-resize-handle.top-right {
    top: -7.5px;
    right: -7.5px;
    cursor: nesw-resize;
}

.group-resize-handle.bottom-left {
    bottom: -7.5px;
    left: -7.5px;
    cursor: nesw-resize;
}

.group-resize-handle.bottom-right {
    bottom: -7.5px;
    right: -7.5px;
    cursor: nwse-resize;
}

/* Highlight for group-selected boxes */
.word-overlay.group-selected {
    border-color: rgba(255, 193, 7, 0.9) !important;
    background-color: rgba(255, 193, 7, 0.3) !important;
}
