/* Cozy, Paper-like Color Palette and Layout Styles */

:root {
    /* Color tokens */
    --color-bg-page: #FAF7F0;       /* Cozy warm paper */
    --color-bg-card: #F3EFE0;       /* Slightly deeper warm paper card */
    --color-text-main: #2A362B;     /* Deep charcoal green */
    --color-text-sub: #5B6B5D;      /* Sage charcoal */
    
    /* State colors (Forest theme) */
    --color-healthy: #366638;       /* Mossy forest green */
    --color-healthy-light: #E4ECE3; /* Soft sage green background */
    --color-burning: #D15632;       /* Terracotta clay/fire */
    --color-burning-light: #FCECE8; /* Warm light peach */
    --color-water: #4E7B92;         /* Cool slate lake blue */
    --color-water-light: #E6EEF2;   /* Soft slate blue background */
    --color-dirt: #9B8871;          /* Earthy taupe/clay */
    --color-dirt-light: #F4EFEB;    /* Earthy warm sand */
    --color-ash: #636D64;           /* Soft wood ash grey */
    --color-ash-light: #EBECEB;     /* Muted grey background */
    
    /* Layout details */
    --border-warm: 1px solid #E3DCB9;
    --border-focus: 2px solid #366638;
    --shadow-soft: 0 6px 20px rgba(54, 45, 36, 0.05), 0 1px 3px rgba(54, 45, 36, 0.02);
    --shadow-inset: inset 0 2px 4px rgba(54, 45, 36, 0.04);
}

/* Base resets & typography */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--color-bg-page);
    color: var(--color-text-main);
    font-family: 'Outfit', sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.serif {
    font-family: 'Lora', Georgia, serif;
    font-weight: 600;
}

/* Layout container */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header style */
.app-header {
    margin-bottom: 2.5rem;
    text-align: center;
    border-bottom: var(--border-warm);
    padding-bottom: 1.5rem;
}

.app-header h1 {
    font-size: 2.5rem;
    color: var(--color-healthy);
    letter-spacing: -0.02em;
}

.tagline {
    font-size: 1.05rem;
    color: var(--color-text-sub);
    margin-top: 0.5rem;
}

/* Content grid */
.app-content {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 2.5rem;
    flex: 1;
}

/* Sidebar & Cards */
.sidebar-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background-color: var(--color-bg-card);
    border: var(--border-warm);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: var(--shadow-soft);
}

.card h3 {
    font-size: 1.25rem;
    margin-bottom: 1.25rem;
    color: var(--color-text-main);
    border-bottom: 1px solid rgba(227, 220, 185, 0.6);
    padding-bottom: 0.5rem;
}

/* Controls */
.control-group {
    margin-bottom: 1.25rem;
}

.control-group:last-of-type {
    margin-bottom: 0;
}

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.badge {
    background-color: var(--color-healthy-light);
    color: var(--color-healthy);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(54, 102, 56, 0.2);
}

.control-desc {
    font-size: 0.8rem;
    color: var(--color-text-sub);
    margin-top: 0.25rem;
}

/* Divider line */
.divider {
    height: 1px;
    background-color: #E3DCB9;
    margin: 1.5rem 0;
}

/* Custom styled sliders */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: #E3DCB9;
    border-radius: 3px;
    outline: none;
    margin: 0.5rem 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--color-healthy);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s ease, background 0.1s ease;
    box-shadow: 0 2px 5px rgba(54, 45, 36, 0.15);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    background: #2a522c;
}

/* Compass and Wind Widget */
.wind-section {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.wind-compass-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.wind-label {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text-main);
}

.compass-dial {
    position: relative;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background-color: var(--color-bg-page);
    border: 2px solid #E3DCB9;
    cursor: pointer;
    box-shadow: var(--shadow-inset);
    user-select: none;
}

.compass-dial:hover {
    border-color: var(--color-healthy);
}

.compass-marker {
    position: absolute;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-text-sub);
    font-family: 'Lora', Georgia, serif;
}

.compass-marker.n { top: 4px; left: 50%; transform: translateX(-50%); }
.compass-marker.e { right: 6px; top: 50%; transform: translateY(-50%); }
.compass-marker.s { bottom: 4px; left: 50%; transform: translateX(-50%); }
.compass-marker.w { left: 6px; top: 50%; transform: translateY(-50%); }

.compass-needle {
    position: absolute;
    width: 6px;
    height: 38px;
    background: linear-gradient(to bottom, var(--color-burning) 50%, var(--color-text-sub) 50%);
    border-radius: 3px;
    top: calc(50% - 19px);
    left: calc(50% - 3px);
    transform-origin: 50% 50%;
    transform: rotate(0deg);
    transition: transform 0.15s ease-out;
}

/* Little dot at the center of needle */
.compass-needle::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    background-color: var(--color-bg-card);
    border-radius: 50%;
    border: 1px solid #E3DCB9;
    top: calc(50% - 3px);
    left: calc(50% - 3px);
}

.wind-angle-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-sub);
}

/* Button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.75rem 1.25rem;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    outline: none;
}

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

.btn-primary {
    background-color: var(--color-healthy);
    color: #FFF;
    box-shadow: 0 4px 10px rgba(54, 102, 56, 0.15);
}

.btn-primary:not(:disabled):hover {
    background-color: #274d28;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(54, 102, 56, 0.25);
}

.btn-secondary {
    background-color: var(--color-bg-page);
    color: var(--color-text-main);
    border: 1px solid #E3DCB9;
}

.btn-secondary:not(:disabled):hover {
    background-color: #F3ECE0;
    border-color: var(--color-text-sub);
    transform: translateY(-1px);
}

.btn-danger {
    background-color: var(--color-burning-light);
    color: var(--color-burning);
    border: 1px solid rgba(209, 86, 50, 0.2);
}

.btn-danger:not(:disabled):hover {
    background-color: #F8DBD2;
    transform: translateY(-1px);
}

.btn-full {
    width: 100%;
    margin-top: 0.75rem;
}

.main-buttons {
    display: grid;
    grid-template-columns: 1.2fr 0.9fr 0.9fr;
    gap: 0.6rem;
}

.seed-text {
    font-size: 0.75rem;
    color: var(--color-text-sub);
    text-align: center;
    margin-top: 0.6rem;
}

/* Simulation viewports styling */
.simulation-viewport {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
}

.canvas-frame {
    position: relative;
    background-color: var(--color-bg-card);
    border: 10px solid var(--color-bg-card);
    outline: 2px solid #E3DCB9;
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    line-height: 0;
    overflow: hidden;
}

#sim-canvas {
    width: 580px;
    height: 580px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    cursor: crosshair;
    display: block;
    background-color: var(--color-bg-page);
}

/* Lightning strike effect */
.lightning-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #FFF;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.05s ease-out;
}

.lightning-flash.strike {
    opacity: 0.85;
    transition: none;
}

.viewport-controls {
    width: 100%;
    max-width: 580px;
}

.instruction-box {
    background-color: var(--color-healthy-light);
    border: 1px solid rgba(54, 102, 56, 0.15);
    border-radius: 14px;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.instruction-icon {
    font-size: 1.25rem;
    color: #e09300;
}

.instruction-box p {
    font-size: 0.9rem;
    color: var(--color-healthy);
}

/* Stats dashboard styling */
.stats-card {
    width: 100%;
    max-width: 580px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.stat-item {
    background-color: var(--color-bg-page);
    border: var(--border-warm);
    border-radius: 14px;
    padding: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.healthy .stat-dot { background-color: var(--color-healthy); }
.healthy { background-color: var(--color-healthy-light); border-color: rgba(54, 102, 56, 0.15); }

.burning .stat-dot { background-color: var(--color-burning); }
.burning { background-color: var(--color-burning-light); border-color: rgba(209, 86, 50, 0.15); }

.ash .stat-dot { background-color: var(--color-ash); }
.ash { background-color: var(--color-ash-light); border-color: rgba(99, 109, 100, 0.15); }

.barren .stat-dot { background-color: var(--color-dirt); }
.barren { background-color: var(--color-dirt-light); border-color: rgba(155, 136, 113, 0.15); }

.stat-details {
    display: flex;
    flex-direction: column;
}

.stat-num {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--color-text-sub);
    font-weight: 500;
}

/* Damage progress bar container */
.burn-percentage-container {
    margin-top: 1rem;
    border-top: 1px solid rgba(227, 220, 185, 0.6);
    padding-top: 1rem;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
}

.bar-track {
    height: 12px;
    background-color: var(--color-bg-page);
    border: var(--border-warm);
    border-radius: 6px;
    display: flex;
    overflow: hidden;
    box-shadow: var(--shadow-inset);
}

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

.healthy-fill { background-color: var(--color-healthy); }
.burning-fill { background-color: var(--color-burning); }
.ash-fill { background-color: var(--color-ash); }

/* Loader/Overlay Screen styles */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(250, 247, 240, 0.96);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader-card {
    background-color: var(--color-bg-card);
    border: var(--border-warm);
    padding: 3rem 2rem;
    border-radius: 24px;
    box-shadow: var(--shadow-soft);
    text-align: center;
    max-width: 420px;
    width: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.loader-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--color-bg-page);
    border-top: 4px solid var(--color-healthy);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-card h2 {
    color: var(--color-healthy);
    font-size: 1.5rem;
}

.loader-card p {
    font-size: 0.9rem;
    color: var(--color-text-sub);
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background-color: var(--color-bg-page);
    border: var(--border-warm);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    width: 15%;
    height: 100%;
    background-color: var(--color-healthy);
    transition: width 0.2s ease;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Footer layout */
.app-footer {
    text-align: center;
    padding-top: 2rem;
    margin-top: auto;
    border-top: var(--border-warm);
    font-size: 0.8rem;
    color: var(--color-text-sub);
}

/* Responsive adjustment for laptop/tablet */
@media (max-width: 1024px) {
    .app-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .sidebar-panel {
        order: 2;
    }
    
    .simulation-viewport {
        order: 1;
    }
}
