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

body {
    font-family: 'Courier New', monospace;
    background: #0a0e14;
    color: #0f0;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    padding: 0 10px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: #151922;
    border: 2px solid #0f0;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}

h1 {
    font-size: 2.5em;
    letter-spacing: 4px;
    color: #0f0;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.7);
}

.subtitle {
    color: #0a0;
    margin-top: 10px;
    font-size: 1em;
}

.main-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 350px;
    gap: 20px;
    max-width: 100%;
}

.left-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.canvas-container {
    background: #000;
    border: 2px solid #0f0;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.2);
    padding: 10px;
    position: relative;
    width: fit-content;
    max-width: 100%;
    overflow: hidden;
}

.graph-container {
    background: #000;
    border: 2px solid #0f0;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.2);
    padding: 15px;
    position: relative;
}

.graph-container h2 {
    color: #0f0;
    font-size: 1em;
    margin-bottom: 10px;
    text-align: center;
    text-decoration: none;
}

.graph-container canvas {
    width: 100%;
    height: 200px;
    background: #000;
    display: block;
}

canvas {
    display: block;
    background: #000;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    vertical-align: bottom;
    max-width: 100%;
    height: auto;
}

#worldCanvas {
    cursor: default;
}

#worldCanvas.hovering-creature {
    cursor: pointer;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel {
    background: #151922;
    border: 2px solid #0f0;
    padding: 15px;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.2);
}

h2 {
    color: #0f0;
    font-size: 1.2em;
    margin-bottom: 15px;
    text-align: center;
    text-decoration: underline;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 5px;
    background: rgba(0, 255, 0, 0.05);
}

.stat-row.stat-secondary {
    padding: 3px 5px 3px 15px;
    margin-bottom: 4px;
    background: rgba(0, 255, 0, 0.02);
    font-size: 0.9em;
}

.stat-label {
    color: #0a0;
}

.stat-secondary .stat-label {
    color: #085;
    font-style: italic;
}

.stat-value {
    color: #0f0;
    font-weight: bold;
}

.stat-secondary .stat-value {
    color: #0a0;
}

.btn {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    background: #000;
    color: #0f0;
    border: 2px solid #0f0;
    font-family: 'Courier New', monospace;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    background: #0f0;
    color: #000;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: #0a0;
    color: #000;
    font-weight: bold;
}

.btn-primary:hover {
    background: #0f0;
}

.btn-danger {
    background: #600;
    color: #ff0000;
    border-color: #ff0000;
}

.btn-danger:hover {
    background: #ff0000;
    color: #000;
}

.difficulty-selector {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(0, 255, 0, 0.05);
    border: 1px solid #0a0;
}

.difficulty-selector label {
    display: block;
    margin-bottom: 8px;
    color: #0a0;
    font-weight: bold;
}

.difficulty-select {
    width: 100%;
    padding: 12px 10px;
    background: #000;
    color: #0f0;
    border: 2px solid #0a0;
    font-family: 'Courier New', monospace;
    font-size: 1em;
    cursor: pointer;
    margin-bottom: 5px;
    line-height: 2;
}

.difficulty-select:hover {
    border-color: #0f0;
    box-shadow: 0 0 5px rgba(0, 255, 0, 0.3);
}

.difficulty-select option {
    background: #000;
    color: #0f0;
}

.difficulty-hint {
    display: block;
    color: #0a0;
    font-size: 0.8em;
    font-style: italic;
}

.slider-group {
    margin: 15px 0;
}

.slider-group label {
    display: block;
    margin-bottom: 8px;
    color: #0a0;
}

#speedValue {
    color: #0f0;
    font-weight: bold;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: #000;
    border: 1px solid #0f0;
    outline: none;
    -webkit-appearance: none;
}

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

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

.button-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn-small {
    margin-bottom: 0;
    padding: 10px;
    font-size: 0.9em;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding: 5px;
    background: rgba(0, 255, 0, 0.05);
}

.legend-symbol {
    font-size: 1.5em;
    margin-right: 15px;
    width: 30px;
    text-align: center;
}

.legend-symbol.creature {
    color: #00ffff;
}

.legend-symbol.predator {
    color: #ff0000;
}

.legend-symbol.food {
    color: #ff0;
}

.legend-symbol.ground {
    color: #0a0;
}

.prey-stat .stat-label {
    color: #00ffff !important;
}

.predator-stat .stat-label {
    color: #ff0000 !important;
}

.info-text {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #0a0;
}

.info-text p {
    margin-bottom: 10px;
    color: #0a0;
    line-height: 1.5;
}

.info-text strong {
    color: #0f0;
}

/* Event Log */
.log-panel {
    max-height: 400px;
    display: flex;
    flex-direction: column;
}

.event-log {
    flex: 1;
    max-height: 300px;
    overflow-y: auto;
    background: #000;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #0a0;
    font-size: 0.85em;
    line-height: 1.6;
}

.event-log::-webkit-scrollbar {
    width: 8px;
}

.event-log::-webkit-scrollbar-track {
    background: #000;
}

.event-log::-webkit-scrollbar-thumb {
    background: #0a0;
    border-radius: 4px;
}

.event-log::-webkit-scrollbar-thumb:hover {
    background: #0f0;
}

.log-entry {
    padding: 4px 6px;
    margin-bottom: 2px;
    border-left: 3px solid transparent;
    animation: logFadeIn 0.3s ease-out;
}

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

.log-entry.log-birth {
    color: #0ff;
    border-left-color: #0ff;
}

.log-entry.log-death {
    color: #f66;
    border-left-color: #f66;
}

.log-entry.log-food {
    color: #ff0;
    border-left-color: #ff0;
}

.log-entry.log-predator {
    color: #ff0000;
    border-left-color: #ff0000;
}

.log-entry.log-milestone {
    color: #0f0;
    border-left-color: #0f0;
    font-weight: bold;
}

.log-entry.log-info {
    color: #0a0;
    border-left-color: #0a0;
}

.log-panel .btn-small {
    width: 100%;
}

/* Creature Inspector */
.inspector-panel {
    border-color: #00ffff;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

.inspector-panel h2 {
    color: #00ffff;
}

.inspector-panel.hidden {
    display: none;
}

.inspector-info {
    font-size: 0.9em;
    line-height: 1.8;
}

.inspector-row {
    display: flex;
    justify-content: space-between;
    padding: 5px;
    margin-bottom: 4px;
    background: rgba(0, 255, 255, 0.05);
}

.inspector-label {
    color: #0aa;
    font-weight: bold;
}

.inspector-value {
    color: #0ff;
}

.inspector-section {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #0aa;
}

.inspector-section h3 {
    color: #0ff;
    font-size: 0.95em;
    margin-bottom: 10px;
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .panel {
        flex: 1;
        min-width: 280px;
    }
}

/* Scanline effect */
.canvas-container::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 255, 0, 0.03),
        rgba(0, 255, 0, 0.03) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

.modal.hidden {
    display: none;
}

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

.modal-content {
    background: #151922;
    border: 3px solid #ff0000;
    padding: 60px 40px 40px 40px;
    text-align: center;
    max-width: 500px;
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.5);
    animation: slideIn 0.4s ease-out;
    position: relative;
}

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

.modal-content h2 {
    color: #ff0000;
    font-size: 2em;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(255, 0, 0, 0.7);
}

.modal-content p {
    color: #0f0;
    font-size: 1.2em;
    margin-bottom: 15px;
}

.modal-stats {
    background: rgba(0, 255, 0, 0.05);
    padding: 15px;
    margin: 20px 0;
    border: 1px solid #0a0;
}

.modal-stats strong {
    color: #0f0;
}

.modal-content .btn {
    margin-top: 20px;
    width: auto;
    padding: 15px 30px;
    font-size: 1.1em;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: #f00;
    font-size: 2em;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
}

.modal-close:hover {
    color: #fff;
    background: rgba(255, 0, 0, 0.2);
    transform: rotate(90deg);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: #151922;
    border: 2px solid #0f0;
    padding: 15px 20px;
    min-width: 300px;
    max-width: 400px;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
    animation: toastSlideIn 0.4s ease-out;
    pointer-events: auto;
    position: relative;
    font-weight: bold;
}

.toast.toast-fade-out {
    animation: toastFadeOut 0.4s ease-out forwards;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(450px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastFadeOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(450px);
        opacity: 0;
    }
}

.toast-extinction {
    border-color: #ff0000;
    color: #ff0000;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.6);
}

.toast-milestone {
    border-color: #0f0;
    color: #0f0;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.6);
}

.toast-warning {
    border-color: #ff0;
    color: #ff0;
    box-shadow: 0 0 20px rgba(255, 255, 0, 0.6);
}

.toast-icon {
    font-size: 1.5em;
    margin-right: 10px;
}

.toast-message {
    display: inline;
}
