/* Game UI Styles */
body {
    margin: 0;
    padding: 0;
    font-family: 'Courier New', monospace;
    background-color: #1e1e1e;
    color: #ffffff;
    overflow: hidden;
}

#glCanvas {
    display: block;
    background: #333;
    border: 2px solid #555;
}

#grapharea {
    position: absolute;
    top: 0;
    left: 0;
    right: 400px;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2d2d2d;
}

/* Map toolbar styles */
.map-toolbar {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #555;
    border-radius: 5px;
    padding: 8px;
    z-index: 100;
    display: flex;
    gap: 10px;
    align-items: center;
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-section label {
    font-size: 12px;
    color: #ccc;
    margin-right: 5px;
}

.toolbar-button {
    background: #2d2d2d;
    color: #ccc;
    border: 1px solid #555;
    padding: 6px 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    border-radius: 3px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 80px;
    justify-content: center;
}

.toolbar-button:hover {
    background: #3d3d3d;
    border-color: #666;
}

.toolbar-button.active {
    background: #0078d4;
    color: white;
    border-color: #0078d4;
}

.toolbar-button .icon {
    font-size: 14px;
}

#codearea {
    position: absolute;
    top: 0;
    right: 0;
    width: 400px;
    bottom: 0;
    background: #1e1e1e;
    border-left: 2px solid #555;
    display: flex;
    flex-direction: column;
    padding: 10px;
    box-sizing: border-box;
    overflow-y: auto;
}

#gnomecode {
    flex: 1;
    background: #2d2d2d;
    color: #ffffff;
    border: 1px solid #555;
    padding: 10px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    resize: vertical;
    outline: none;
    min-height: 300px;
    max-height: 60vh;
}

#gnomecode:focus {
    border-color: #0078d4;
    box-shadow: 0 0 5px rgba(0, 120, 212, 0.3);
}

.control-button {
    background: #0078d4;
    color: white;
    border: none;
    padding: 8px 16px;
    margin: 4px;
    cursor: pointer;
    font-family: inherit;
    border-radius: 3px;
    transition: background-color 0.2s;
}

.control-button:hover {
    background: #106ebe;
}

.control-button:disabled {
    background: #555;
    cursor: not-allowed;
}

.control-button.danger {
    background: #d13438;
}

.control-button.danger:hover {
    background: #b71c1c;
}

.control-button.success {
    background: #107c10;
}

.control-button.success:hover {
    background: #0e6e0e;
}

#controlpanel {
    margin-top: 10px;
    padding: 10px;
    background: #333;
    border: 1px solid #555;
    border-radius: 3px;
    flex-shrink: 0;
}

#statusarea {
    margin-top: 10px;
    padding: 10px;
    background: #333;
    border: 1px solid #555;
    border-radius: 3px;
    max-height: 120px;
    overflow-y: auto;
    font-size: 12px;
    flex-shrink: 0;
}

#configpanel {
    margin-top: 10px;
    padding: 10px;
    background: #333;
    border: 1px solid #555;
    border-radius: 3px;
    flex-shrink: 0;
}

.config-item {
    margin: 8px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.config-item label {
    font-size: 12px;
    min-width: 100px;
}

.config-item input, .config-item select {
    background: #2d2d2d;
    color: white;
    border: 1px solid #555;
    padding: 4px 8px;
    border-radius: 3px;
    font-family: inherit;
    font-size: 12px;
}

.status-message {
    padding: 4px 8px;
    margin: 2px 0;
    border-radius: 3px;
    font-size: 11px;
    border-left: 3px solid #555;
}

.status-message.success {
    background: rgba(16, 124, 16, 0.2);
    border-left-color: #107c10;
    color: #4caf50;
}

.status-message.error {
    background: rgba(209, 52, 56, 0.2);
    border-left-color: #d13438;
    color: #f44336;
}

.status-message.warning {
    background: rgba(255, 193, 7, 0.2);
    border-left-color: #ffc107;
    color: #ff9800;
}

.status-message.info {
    background: rgba(0, 120, 212, 0.2);
    border-left-color: #0078d4;
    color: #2196f3;
}

.status-message.log {
    background: rgba(76, 175, 80, 0.2);
    border-left-color: #4caf50;
    color: #66bb6a;
    font-family: 'Courier New', monospace;
}

#manual {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.9);
    padding: 10px;
    border-radius: 5px;
    max-width: 280px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    font-size: 11px;
    border: 1px solid #555;
    z-index: 50;
}

#manual h2, #manual h3 {
    margin: 0 0 10px 0;
    color: #0078d4;
}

#manual ul {
    margin: 0;
    padding-left: 20px;
}

#manual code {
    background: #333;
    padding: 2px 4px;
    border-radius: 2px;
    color: #4caf50;
}

.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Button groups */
.button-group {
    display: flex;
    gap: 5px;
    margin: 10px 0;
}

.button-group .control-button {
    margin: 0;
    flex: 1;
}

/* Configuration panels */
.config-section {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #555;
}

.config-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.config-section h4 {
    margin: 0 0 10px 0;
    color: #0078d4;
    font-size: 14px;
}

/* Input styling */
input[type="number"], input[type="range"] {
    background: #2d2d2d;
    color: white;
    border: 1px solid #555;
    padding: 4px 8px;
    border-radius: 3px;
    font-family: inherit;
    font-size: 12px;
}

input[type="checkbox"] {
    accent-color: #0078d4;
}

/* Range slider styling */
input[type="range"] {
    -webkit-appearance: none;
    height: 6px;
    background: #555;
    border-radius: 3px;
    padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #0078d4;
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #0078d4;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Status area scrollbar */
#statusarea::-webkit-scrollbar {
    width: 8px;
}

#statusarea::-webkit-scrollbar-track {
    background: #1e1e1e;
}

#statusarea::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

#statusarea::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* Codearea scrollbar */
#codearea::-webkit-scrollbar {
    width: 18px;
}

#codearea::-webkit-scrollbar-track {
    background: #fffefe;
}

#codearea::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

#codearea::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* Responsive design */
@media (max-width: 800px) {
    #grapharea {
        right: 0;
        bottom: 300px;
    }
    
    #codearea {
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        width: auto;
        height: 300px;
        border-left: none;
        border-top: 2px solid #555;
    }
    
    #manual {
        position: relative;
        bottom: auto;
        left: auto;
        margin: 10px 0;
        max-width: none;
    }
}

@media (max-width: 600px) {
    #codearea {
        height: 250px;
        padding: 5px;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .config-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .config-item input, .config-item select {
        width: 100%;
        box-sizing: border-box;
    }
}

/* Loading and error states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.error-highlight {
    border-color: #d13438 !important;
    box-shadow: 0 0 5px rgba(209, 52, 56, 0.3) !important;
}

/* Tooltip styles */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 5px 8px;
    border-radius: 3px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Animation classes */
.pulse {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Popup/Modal styles */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease-in;
}

.popup-content {
    background: #2d2d2d;
    border: 2px solid #555;
    border-radius: 8px;
    padding: 30px;
    max-width: 500px;
    min-width: 300px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: popupSlideIn 0.3s ease-out;
}

@keyframes popupSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.popup-content.success {
    border-color: #4caf50;
}

.popup-content.error {
    border-color: #f44336;
}

.popup-content.info {
    border-color: #2196f3;
}

.popup-icon {
    font-size: 48px;
    margin-bottom: 15px;
    display: block;
}

.popup-content.success .popup-icon {
    color: #4caf50;
}

.popup-content.error .popup-icon {
    color: #f44336;
}

.popup-content.info .popup-icon {
    color: #2196f3;
}

.popup-title {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 15px;
    color: #ffffff;
}

.popup-message {
    font-size: 16px;
    line-height: 1.4;
    margin-bottom: 20px;
    color: #cccccc;
}

.popup-stats {
    background: #1e1e1e;
    border: 1px solid #555;
    border-radius: 5px;
    padding: 15px;
    margin: 15px 0;
    text-align: left;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.popup-stats .stat-row {
    display: flex;
    justify-content: space-between;
    margin: 5px 0;
}

.popup-stats .stat-label {
    color: #999;
}

.popup-stats .stat-value {
    color: #fff;
    font-weight: bold;
}

.popup-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.popup-button {
    background: #0078d4;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 5px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: bold;
    transition: background-color 0.2s;
    min-width: 100px;
}

.popup-button:hover {
    background: #106ebe;
}

.popup-button.success {
    background: #4caf50;
}

.popup-button.success:hover {
    background: #45a049;
}

.popup-button.secondary {
    background: #555;
}

.popup-button.secondary:hover {
    background: #666;
}

/* Statistics panel styles */
.stats-section {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #555;
}

.stats-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.stats-section h4 {
    margin: 0 0 10px 0;
    color: #0078d4;
    font-size: 14px;
}

.stat-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 5px 0;
    padding: 3px 0;
}

.stat-display .stat-name {
    font-size: 12px;
    color: #ccc;
}

.stat-display .stat-number {
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    background: #1e1e1e;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #555;
    min-width: 30px;
    text-align: center;
}

.stat-display.highlight .stat-number {
    color: #4caf50;
    border-color: #4caf50;
}

.stat-display.error .stat-number {
    color: #f44336;
    border-color: #f44336;
}