/* Global Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #64c8ff;
    --secondary-color: #0066cc;
    --accent-color: #0088ff;
    --dark-bg: #0a0e27;
    --panel-bg: rgba(10, 14, 39, 0.9);
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --border-color: rgba(100, 200, 255, 0.3);
    --success-color: #00ff00;
    --error-color: #ff4444;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background: var(--dark-bg);
    color: var(--text-primary);
}

#app {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Canvas Container */

#canvas-container {
    flex: 1;
    position: relative;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

#webgl-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* UI Overlay */

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
}

.panel {
    pointer-events: all;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(100, 200, 255, 0.1);
    max-width: 400px;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Story Panel */

#story-panel {
    align-self: flex-start;
    max-height: 280px;
    overflow-y: auto;
    background: linear-gradient(135deg, rgba(10, 20, 45, 0.95), rgba(20, 30, 60, 0.95));
    border-left: 3px solid var(--primary-color);
}

#story-panel h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.4em;
    font-weight: 600;
    letter-spacing: 1px;
}

#story-panel p {
    line-height: 1.8;
    color: var(--text-secondary);
    font-size: 0.95em;
    margin-bottom: 12px;
}

#story-panel ul {
    margin-left: 20px;
    margin-top: 10px;
}

#story-panel li {
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* Input Panel */

#input-panel {
    align-self: flex-end;
    width: 100%;
    max-width: 550px;
}

#action-input {
    width: 100%;
    height: 90px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95em;
    resize: none;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

#action-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

#action-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 20px rgba(100, 200, 255, 0.2);
}

#submit-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

#submit-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    transition: left 0.3s ease;
}

#submit-btn:hover::before {
    left: 100%;
}

#submit-btn:hover {
    background: linear-gradient(135deg, #0077dd, #0099ff);
    box-shadow: 0 0 20px rgba(0, 136, 255, 0.6);
    transform: translateY(-2px);
}

#submit-btn:active {
    transform: translateY(0);
}

#submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* World Info Panel */

#world-info {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 280px;
}

#world-info h3 {
    color: var(--primary-color);
    margin-bottom: 12px;
    font-size: 1.1em;
    font-weight: 600;
    letter-spacing: 0.5px;
}

#world-info p {
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-bottom: 8px;
}

#connection-status {
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

#connection-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--error-color);
    animation: pulse 2s infinite;
}

#connection-status.connected::before {
    background: var(--success-color);
    animation: pulse-success 1s infinite;
}

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

@keyframes pulse-success {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Debug Console */

#debug-console {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 350px;
    max-height: 150px;
    display: none;
}

#debug-console.visible {
    display: block;
}

#debug-console h3 {
    color: #64c8ff;
    margin-bottom: 5px;
    font-size: 0.9em;
}

#debug-output {
    overflow-y: auto;
    max-height: 100px;
    font-family: 'Courier New', monospace;
    font-size: 0.75em;
    color: #0f0;
    background: rgba(0, 0, 0, 0.9);
    padding: 5px;
    border-radius: 4px;
}

.debug-line {
    margin: 2px 0;
    word-break: break-all;
}

/* Scrollbar Styling */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: rgba(100, 200, 255, 0.4);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 200, 255, 0.6);
}

/* Loading Spinner */

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(100, 200, 255, 0.3);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Status Messages */

.status-message {
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 0.85em;
    animation: slideIn 0.3s ease-out;
}

.status-success {
    background: rgba(0, 255, 0, 0.1);
    border-left: 3px solid var(--success-color);
    color: var(--success-color);
}

.status-error {
    background: rgba(255, 68, 68, 0.1);
    border-left: 3px solid var(--error-color);
    color: var(--error-color);
}

.status-info {
    background: rgba(100, 200, 255, 0.1);
    border-left: 3px solid var(--primary-color);
    color: var(--primary-color);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Responsive */

@media (max-width: 768px) {
    .panel {
        max-width: none;
        margin: 10px;
    }

    #story-panel {
        max-height: 200px;
        align-self: center;
    }

    #input-panel {
        max-width: none;
        width: 90%;
    }

    #world-info {
        position: static;
        width: auto;
        margin: 10px;
    }

    #debug-console {
        position: static;
        width: auto;
        margin: 10px;
    }

    #submit-btn {
        padding: 10px;
        font-size: 0.9em;
    }
}
