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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a472a 0%, #2d5a3d 100%);
    min-height: 100vh;
    color: #f0f8e8;
}

.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(26, 46, 26, 0.95);
    backdrop-filter: blur(10px);
    padding: 15px 30px;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(45deg, #2d6cdf, #4d8cff);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
    border: none;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(45, 108, 223, 0.4);
}

.back-btn:hover {
    background: linear-gradient(45deg, #4d8cff, #6da3ff);
    transform: translateX(-5px);
    box-shadow: 0 5px 16px rgba(45, 108, 223, 0.6);
}

.nav-title {
    font-size: 1.8em;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.nav-info {
    font-size: 0.9em;
    opacity: 0.9;
    padding: 5px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
}

.main-container {
    display: flex;
    gap: 20px;
    padding: 80px 20px 20px 20px;
    max-width: 1800px;
    margin: 0 auto;
    min-height: calc(100vh - 80px);
}

/* Control Panel */
.control-panel {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-shrink: 0;
}

.stats-box, .climate-box, .slider-box, .controls-box, .action-box, .legend-box, .instructions-box {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

h3 {
    margin-bottom: 12px;
    color: #1a472a;
    font-size: 1.1em;
    font-weight: 700;
}

.stat {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 8px;
    background: rgba(45, 108, 223, 0.05);
    border-radius: 6px;
}

.stat-label {
    font-weight: 600;
    color: #2d5a3d;
}

.stat-value {
    font-weight: bold;
    color: #2d6cdf;
    font-size: 1.1em;
}

/* Year Slider */
.slider-box {
    padding: 15px;
}

.slider-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9em;
    color: #2d5a3d;
    font-weight: 600;
}

.year-slider {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: linear-gradient(to right, #4ade80, #facc15, #f87171);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.year-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2d6cdf;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.year-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2d6cdf;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    border: none;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.85em;
    color: #6c757d;
}

/* Buttons */
.mode-btn, .action-btn {
    width: 100%;
    padding: 12px;
    margin-bottom: 8px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 0.95em;
    position: relative;
    overflow: hidden;
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.mode-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.action-btn.reset {
    background: #6c757d;
    color: white;
    border-color: #6c757d;
}

.action-btn.danger {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.action-btn.success {
    background: #28a745;
    color: white;
    border-color: #28a745;
}

.action-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

/* Remove Species Toggle Button */
.remove-btn {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #495057;
    border: 2px solid #dee2e6;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    font-size: 1em;
}

.remove-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.1) 0%, rgba(220, 53, 69, 0.2) 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.remove-btn::after {
    content: '🗑️ Click to remove species';
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75em;
    color: #6c757d;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.remove-btn:hover::before {
    opacity: 1;
}

.remove-btn:hover::after {
    opacity: 1;
}

.remove-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 6px 16px rgba(220, 53, 69, 0.3);
    border-color: #dc3545;
}

.remove-btn.active {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border-color: #bd2130;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4), inset 0 2px 4px rgba(0,0,0,0.2);
    animation: pulseButton 2s ease-in-out infinite;
    font-weight: 800;
    font-size: 1.05em;
}

.remove-btn.active::before {
    opacity: 0;
}

.remove-btn.active::after {
    content: '👁️ Click to exit and view info';
    color: #fff;
    opacity: 1;
    animation: fadeInOut 2s ease-in-out infinite;
}

.remove-btn.active:hover {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.6);
    border-color: #16a34a;
}

.remove-btn.active:hover::after {
    content: '✓ Return to View Mode';
    color: #fff;
}

.remove-btn i {
    transition: transform 0.3s ease;
}

.remove-btn:hover i {
    transform: rotate(10deg) scale(1.1);
}

.remove-btn.active i {
    animation: shakeTrash 0.5s ease-in-out;
}

.remove-btn.active:hover i {
    transform: scale(1.15);
    animation: none;
}

@keyframes pulseButton {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4), inset 0 2px 4px rgba(0,0,0,0.2);
    }
    50% {
        box-shadow: 0 4px 16px rgba(220, 53, 69, 0.6), inset 0 2px 4px rgba(0,0,0,0.2);
    }
}

@keyframes shakeTrash {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Legend */
.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
    font-size: 0.9em;
    color: #2d5a3d;
}

.legend-color {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #333;
    flex-shrink: 0;
}

.legend-color.plant {
    background: #4ade80;
}

.legend-color.insect {
    background: #facc15;
}

.legend-color.bird {
    background: #60a5fa;
}

.legend-color.mammal {
    background: #f87171;
}

.legend-line {
    width: 30px;
    height: 4px;
    background: #333;
}

.legend-line.strong {
    height: 6px;
    background: #22c55e;
}

.legend-line.medium {
    height: 4px;
    background: #facc15;
}

.legend-line.weak {
    height: 2px;
    background: #ef4444;
}

/* Instructions */
.instructions-box ul {
    padding-left: 20px;
}

.instructions-box li {
    margin-bottom: 8px;
    line-height: 1.4;
    color: #495057;
}

/* Canvas */
.canvas-container {
    flex: 1;
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    min-height: 800px;
    height: calc(100vh - 120px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}

#ecosystem-canvas {
    width: 100%;
    flex: 1;
    display: block;
    cursor: pointer;
}

/* SVG Elements */
.species-node {
    cursor: pointer;
    transition: all 0.3s ease;
}

.species-node:hover {
    filter: brightness(1.2);
}

.species-node.extinct {
    opacity: 0.3;
}

.species-node.at-risk {
    animation: warningPulse 2s ease-in-out infinite;
}

/* Node animations */
@keyframes warningPulse {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.3) drop-shadow(0 0 8px rgba(239, 68, 68, 0.6));
    }
}

@keyframes nodeRemoval {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.5;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.species-node.at-risk circle {
    stroke: #ef4444;
    stroke-width: 3;
    animation: pulse 1.5s ease-in-out infinite;
}

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

.connection-line {
    transition: all 0.2s ease;
}

#message-display {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

#message-display.show {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translate(-50%, -20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* Info Button */
.info-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    transition: all 0.3s ease;
    vertical-align: middle;
    padding: 0;
    position: relative;
    z-index: 1001;
}

.info-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.15);
    border-color: rgba(255, 255, 255, 0.6);
}

/* Small Info Button for Actions */
.info-btn-small {
    background: rgba(45, 108, 223, 0.1);
    border: 2px solid rgba(45, 108, 223, 0.3);
    color: #2d6cdf;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
    flex-shrink: 0;
}

.info-btn-small:hover {
    background: rgba(45, 108, 223, 0.2);
    transform: scale(1.1);
    border-color: rgba(45, 108, 223, 0.5);
    box-shadow: 0 2px 8px rgba(45, 108, 223, 0.3);
}

/* Modal */
.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: #fefefe;
    margin: 10% auto;
    padding: 30px;
    border: 1px solid #888;
    border-radius: 12px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    color: #1a472a;
}

.modal-content h2 {
    color: #1a472a;
    margin-bottom: 20px;
}

.modal-content ul {
    margin-left: 20px;
    line-height: 1.6;
}

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

.close:hover,
.close:focus {
    color: #000;
}

.remove-btn {
    background: #ff6b6b !important;
    color: white !important;
    border-color: #ff6b6b !important;
}

.remove-btn:hover {
    background: #ff5252 !important;
}

/* Mode Indicator */
.mode-indicator {
    margin-top: 15px;
    padding: 12px;
    background: linear-gradient(135deg, #4ade80, #22c55e);
    color: white;
    border-radius: 8px;
    text-align: center;
    font-weight: 700;
    font-size: 1em;
    box-shadow: 0 3px 10px rgba(74, 222, 128, 0.4);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
    display: block;
    width: 100%;
    position: relative;
    z-index: 10;
}

.mode-indicator i {
    transition: transform 0.3s ease;
    color: white;
}

.mode-indicator.remove-mode {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.6);
    animation: pulseMode 1.5s ease-in-out infinite;
    transform: scale(1.05);
}

.mode-indicator.remove-mode i {
    animation: bounceIcon 0.6s ease-in-out;
}

@keyframes pulseMode {
    0%, 100% { 
        transform: scale(1.05);
        box-shadow: 0 4px 16px rgba(239, 68, 68, 0.6);
    }
    50% { 
        transform: scale(1.08);
        box-shadow: 0 6px 20px rgba(239, 68, 68, 0.8);
    }
}

@keyframes bounceIcon {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-5px); }
    50% { transform: translateY(0); }
    75% { transform: translateY(-3px); }
}

/* Slider at bottom of canvas */
.slider-box-bottom {
    background: rgba(26, 70, 42, 0.95);
    padding: 15px 20px;
    border-top: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    flex-shrink: 0;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    border-radius: 15px 15px 0 0;
}

.slider-box-bottom .slider-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 1em;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.slider-box-bottom .slider-info span {
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 12px;
    border-radius: 8px;
    backdrop-filter: blur(5px);
    color: #ffffff;
}

.slider-box-bottom .slider-info i {
    margin-right: 5px;
    opacity: 0.9;
    color: #ffffff;
}

/* Year value styling */
#slider-year {
    color: #ffffff;
    font-weight: 800;
}

/* Temperature color coding */
#slider-temp {
    font-weight: 800;
    transition: color 0.3s ease;
}

.temp-low {
    color: #4ade80 !important;
}

.temp-medium {
    color: #facc15 !important;
}

.temp-high {
    color: #f87171 !important;
}

.slider-box-bottom .year-slider {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: linear-gradient(to right, #4ade80, #facc15, #f87171);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    margin-bottom: 8px;
}

.slider-box-bottom .year-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    border: 3px solid #2d6cdf;
}

.slider-box-bottom .year-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    border: 3px solid #2d6cdf;
}

.slider-box-bottom .slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.8);
}

/* Responsive */
@media (max-width: 1200px) {
    .main-container {
        flex-direction: column;
    }
    
    .nav-bar {
        padding: 10px 15px;
    }
    
    .nav-title {
        font-size: 1.2em;
    }
    
    .back-btn {
        padding: 8px 15px;
        font-size: 14px;
    }
    
    .control-panel {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .control-panel > div {
        flex: 1;
        min-width: 250px;
    }
    
    .canvas-container {
        min-height: 500px;
    }
}