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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a1a;
    color: #e0e0e0;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    background-color: #2a2a2a;
    padding: 1rem 2rem;
    border-bottom: 2px solid #3a3a3a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 1.5rem;
    color: #4CAF50;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.restart-btn {
    background-color: #c62828;
    border: 1px solid #b71c1c;
    color: #ffffff;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: bold;
    transition: background-color 0.2s;
}

.restart-btn:hover {
    background-color: #d32f2f;
}

.restart-btn:active {
    background-color: #b71c1c;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #666;
    transition: background-color 0.3s;
}

.status-indicator.connected {
    background-color: #4CAF50;
    box-shadow: 0 0 8px #4CAF50;
}

.status-indicator.disconnected {
    background-color: #f44336;
}

.status-indicator.connecting {
    background-color: #ff9800;
    animation: pulse 1.5s infinite;
}

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

main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.canvas-container {
    flex: 1;
    position: relative;
    background-color: #0a0a0a;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#world-canvas {
    border: 1px solid #3a3a3a;
    cursor: crosshair;
    image-rendering: pixelated;
}

.canvas-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    flex-direction: column;
}

.canvas-controls button {
    background-color: #2a2a2a;
    border: 1px solid #3a3a3a;
    color: #e0e0e0;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 4px;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.canvas-controls button:hover {
    background-color: #3a3a3a;
}

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

.playback-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #3a3a3a;
}

.playback-btn {
    background-color: #2a2a2a;
    border: 1px solid #3a3a3a;
    color: #e0e0e0;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.playback-btn:hover:not(:disabled) {
    background-color: #3a3a3a;
}

.playback-btn:active:not(:disabled) {
    background-color: #4a4a4a;
}

.playback-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#go-live-btn {
    background-color: #4CAF50;
    border-color: #45a049;
    font-weight: bold;
}

#go-live-btn:hover {
    background-color: #45a049;
}

#go-live-btn:active {
    background-color: #3d8b40;
}

.stats-panel {
    width: 280px;
    background-color: #2a2a2a;
    border-left: 2px solid #3a3a3a;
    padding: 1.5rem;
    overflow-y: auto;
    transition: transform 0.3s ease, width 0.3s ease;
    position: relative;
}

.stats-panel.collapsed {
    transform: translateX(280px);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.panel-header h2 {
    color: #4CAF50;
    font-size: 1.2rem;
    margin: 0;
}

.toggle-panel-btn {
    background-color: #3a3a3a;
    border: 1px solid #4a4a4a;
    color: #e0e0e0;
    cursor: pointer;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: background-color 0.2s, transform 0.3s;
}

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

.stats-panel.collapsed .toggle-panel-btn {
    transform: rotate(180deg);
}

.stats-panel h2 {
    color: #4CAF50;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.stats-panel h3 {
    color: #66BB6A;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.stat-group {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #3a3a3a;
}

.stat-group:last-child {
    border-bottom: none;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
}

.stat-label {
    color: #9e9e9e;
    font-size: 0.9rem;
}

.stat-value {
    color: #e0e0e0;
    font-weight: bold;
    font-size: 0.9rem;
}

.creature-inspector {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 400px;
    max-height: 70vh;
    background-color: #2a2a2a;
    border: 2px solid #4CAF50;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    z-index: 100;
}

.creature-inspector.visible {
    display: flex;
}

.inspector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: #333;
    border-bottom: 2px solid #4CAF50;
}

.inspector-header h2 {
    color: #4CAF50;
    font-size: 1.1rem;
}

#close-inspector {
    background: none;
    border: none;
    color: #e0e0e0;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

#close-inspector:hover {
    background-color: #4a4a4a;
}

.inspector-content {
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.inspector-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #3a3a3a;
}

.inspector-section:last-child {
    border-bottom: none;
}

.inspector-section h3 {
    color: #66BB6A;
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
}

.info-label {
    color: #9e9e9e;
    font-size: 0.9rem;
}

.info-value {
    color: #e0e0e0;
    font-weight: bold;
    font-size: 0.9rem;
}

.genome-display {
    background-color: #1a1a1a;
    padding: 0.75rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: #4CAF50;
    word-wrap: break-word;
    max-height: 150px;
    overflow-y: auto;
    margin-top: 0.5rem;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

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

::-webkit-scrollbar-thumb:hover {
    background: #5a5a5a;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    header {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
    }

    h1 {
        font-size: 1.2rem;
    }

    .header-controls {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-end;
    }

    .restart-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    main {
        flex-direction: column;
    }

    .stats-panel {
        position: fixed;
        top: auto;
        bottom: 0;
        right: 0;
        width: 100%;
        max-height: 50vh;
        border-left: none;
        border-top: 2px solid #3a3a3a;
        z-index: 50;
        padding: 1rem;
        overflow-y: auto;
    }

    .stats-panel.collapsed {
        transform: translateY(calc(100% - 60px));
    }

    .toggle-panel-btn {
        transform: rotate(90deg);
    }

    .stats-panel.collapsed .toggle-panel-btn {
        transform: rotate(-90deg);
    }

    .canvas-controls {
        top: 0.5rem;
        right: 0.5rem;
    }

    .canvas-controls button {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }

    .creature-inspector {
        width: 100%;
        max-width: 100%;
        max-height: 60vh;
    }

    .inspector-header {
        padding: 0.75rem 1rem;
    }

    .inspector-header h2 {
        font-size: 1rem;
    }

    .inspector-content {
        padding: 0.75rem 1rem;
    }
}

/* Tablet styles */
@media (min-width: 769px) and (max-width: 1024px) {
    .stats-panel {
        width: 240px;
    }

    .stats-panel.collapsed {
        transform: translateX(240px);
    }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
    .canvas-controls button,
    .toggle-panel-btn,
    #close-inspector {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Genome Visualization */
.genome-visual {
    display: flex;
    gap: 2px;
    height: 100px;
    align-items: flex-end;
    padding: 10px;
    background-color: #1a1a1a;
    border-radius: 4px;
    overflow-x: auto;
}

.genome-bar {
    flex: 1;
    min-width: 2px;
    border-radius: 2px 2px 0 0;
    transition: opacity 0.2s;
}

.genome-bar:hover {
    opacity: 0.8;
}

/* Sensors Display */
.sensors-display {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 500px;
    overflow-y: auto;
    padding: 4px;
}

.sensor-item {
    display: grid;
    grid-template-columns: 160px 1fr 60px;
    align-items: center;
    gap: 8px;
    padding: 6px;
    background-color: #2a2a2a;
    border-radius: 4px;
    transition: background-color 0.1s;
}

.sensor-item:hover {
    background-color: #333;
}

.sensor-label {
    font-size: 0.82rem;
    color: #bbb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sensor-bar-container {
    height: 16px;
    background-color: #1a1a1a;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.sensor-bar-fill {
    height: 100%;
    transition: width 0.1s ease;
}

.sensor-value {
    font-size: 0.8rem;
    font-family: 'Courier New', monospace;
    text-align: right;
    color: #ddd;
}

/* Neural Network Outputs */
.outputs-display {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 500px;
    overflow-y: auto;
    padding: 4px;
}

.output-item {
    background-color: #2a2a2a;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.1s;
}

.output-item:hover {
    background-color: #333;
}

.output-label {
    display: block;
    font-size: 0.88rem;
    color: #bbb;
    margin-bottom: 6px;
    font-weight: bold;
}

.output-bars {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.output-bar-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.output-bar-fill {
    height: 20px;
    border-radius: 4px;
    transition: width 0.1s ease;
}

.output-bar-fill.raw-output {
    background: linear-gradient(90deg, #2196F3, #64B5F6);
}

.output-bar-fill.probability {
    background: linear-gradient(90deg, #4CAF50, #81C784);
}

.output-value {
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
    color: #ddd;
    min-width: 50px;
}
