/* Language Evolution Simulator - Minimal Scientific UI */

:root {
    /* Minimal Scientific Color Palette */
    --bg-primary: #0a0f14;
    --bg-secondary: #141b22;
    --bg-tertiary: #1a2128;

    /* Green accent - scientific/terminal feel */
    --accent-primary: #22c55e;
    --accent-hover: #16a34a;
    --accent-dim: rgba(34, 197, 94, 0.15);
    --accent-border: rgba(34, 197, 94, 0.3);

    /* Text Colors */
    --text-primary: #e8eaed;
    --text-secondary: #9ca3af;
    --text-dim: #6b7280;

    /* UI Elements */
    --border-default: #2d3748;
    --border-light: #3d4a5c;

    /* Status Colors */
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --color-info: #3b82f6;

    /* Dimensions */
    --header-height: 56px;
    --panel-width: 360px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   HEADER & CONTROLS
   ============================================ */

.controls {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-default);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.controls h1 {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.5px;
    color: var(--accent-primary);
    text-transform: uppercase;
    margin-right: 24px;
}

.simulation-stats {
    display: flex;
    gap: 20px;
    font-size: 12px;
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Consolas', monospace;
}

.simulation-stats span::before {
    content: '>';
    color: var(--accent-primary);
    margin-right: 6px;
}

.control-btn {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    padding: 6px 14px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.control-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.control-btn:active {
    background: var(--accent-dim);
}

.control-btn.playing {
    background: var(--accent-dim);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.control-btn.paused {
    border-color: var(--color-warning);
    color: var(--color-warning);
}

.control-select {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    padding: 6px 10px;
    border-radius: 3px;
    font-size: 12px;
    min-width: 140px;
    cursor: pointer;
}

.control-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
}

.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #000;
}

#world-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    image-rendering: auto;
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

/* ============================================
   PANELS
   ============================================ */

.language-panel {
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: var(--panel-width);
    height: calc(100vh - var(--header-height));
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-default);
    z-index: 900;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    overflow-y: auto;
}

.language-panel:not(.hidden) {
    transform: translateX(0);
}

.panel-header {
    position: sticky;
    top: 0;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-default);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.panel-header h2 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-primary);
}

.close-btn {
    background: transparent;
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: all 0.15s ease;
}

.close-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.panel-content {
    padding: 20px;
}

.language-overview h3,
.phonology-section h3,
.vocabulary-section h3 {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border-default);
    padding-bottom: 6px;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.info-item {
    background: var(--bg-primary);
    padding: 10px;
    border: 1px solid var(--border-default);
    border-radius: 2px;
}

.info-item .label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.info-item .value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.phoneme-categories {
    margin-bottom: 20px;
}

.phoneme-category {
    margin-bottom: 16px;
}

.phoneme-category h4 {
    font-size: 10px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.phoneme-list {
    background: var(--bg-primary);
    padding: 10px;
    border: 1px solid var(--border-default);
    border-radius: 2px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.constraints-info {
    margin-bottom: 20px;
}

.constraints-info h4 {
    font-size: 10px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.constraints-text {
    background: var(--bg-primary);
    padding: 10px;
    border: 1px solid var(--border-default);
    border-radius: 2px;
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.vocab-search {
    margin-bottom: 12px;
}

.vocab-search input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-default);
    border-radius: 2px;
    font-size: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.vocab-search input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.vocabulary-list {
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: 2px;
    max-height: 400px;
    overflow-y: auto;
}

.vocab-item {
    padding: 10px;
    border-bottom: 1px solid var(--border-default);
    font-size: 12px;
    display: flex;
    justify-content: space-between;
}

.vocab-item:hover {
    background: var(--bg-tertiary);
}

.vocab-item:last-child {
    border-bottom: none;
}

.vocab-meaning {
    font-weight: 500;
    color: var(--text-primary);
}

.vocab-word {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    color: var(--accent-primary);
}

.vocab-origin {
    font-size: 10px;
    color: var(--text-dim);
    font-style: italic;
}

/* ============================================
   MODALS
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal:not(.hidden) {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: 2px;
    width: 90%;
    max-width: 560px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-default);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.settings-section {
    margin-bottom: 24px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section h3 {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border-default);
    padding-bottom: 6px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: 2px;
}

.setting-item label {
    flex: 1;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
}

.setting-item .hint {
    flex-basis: 100%;
    font-size: 11px;
    color: var(--text-dim);
    margin-top: -6px;
    font-style: italic;
}

.setting-item input[type="number"] {
    width: 80px;
    padding: 6px 8px;
    border: 1px solid var(--border-default);
    border-radius: 2px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 12px;
}

.setting-item input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.setting-item input[type="range"] {
    width: 120px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    outline: none;
    border: 1px solid var(--border-default);
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent-primary);
    cursor: pointer;
    border-radius: 2px;
}

.setting-item input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--accent-primary);
    cursor: pointer;
    border-radius: 2px;
    border: none;
}

.setting-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

.setting-item span {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: right;
    font-family: 'SF Mono', 'Consolas', monospace;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-default);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: var(--bg-tertiary);
}

.btn {
    padding: 8px 16px;
    border-radius: 2px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.btn-primary {
    background: transparent;
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
}

.btn-primary:hover {
    background: var(--accent-dim);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
}

.btn-secondary:hover {
    border-color: var(--border-light);
    color: var(--text-primary);
}

/* ============================================
   LOADING SCREEN
   ============================================ */

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.loading-screen:not(.hidden) {
    opacity: 1;
    pointer-events: all;
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border-default);
    border-top: 2px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-text {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.loading-progress {
    width: 200px;
    height: 2px;
    background: var(--border-default);
    border-radius: 1px;
    overflow: hidden;
    margin: 0 auto;
}

.loading-bar {
    height: 100%;
    background: var(--accent-primary);
    width: 0%;
    transition: width 0.3s ease;
}

/* ============================================
   STATISTICS PANEL
   ============================================ */

.stats-panel {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 300px;
    height: calc(100vh - var(--header-height));
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-default);
    z-index: 800;
    padding: 20px;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
}

.stats-panel:not(.hidden) {
    transform: translateX(0);
}

.stats-panel h3 {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border-default);
    padding-bottom: 6px;
    margin-bottom: 12px;
}

.stats-panel h4 {
    font-size: 10px;
    font-weight: 600;
    margin-top: 20px;
    margin-bottom: 8px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.language-leaderboard {
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: 2px;
    padding: 10px;
}

.leaderboard-item {
    padding: 6px 0;
    font-size: 11px;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-default);
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Consolas', monospace;
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.sample-words-list {
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: 2px;
    padding: 10px;
}

.sample-word {
    padding: 3px 0;
    font-size: 11px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    color: var(--text-secondary);
}

/* ============================================
   HELP OVERLAY
   ============================================ */

.help-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2500;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.help-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: all;
}

.help-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: 2px;
    padding: 24px;
    max-width: 480px;
    text-align: center;
}

.help-content h2 {
    margin-bottom: 20px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-primary);
}

.shortcut-list {
    text-align: left;
    margin-bottom: 20px;
}

.shortcut {
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.shortcut kbd {
    background: var(--bg-primary);
    padding: 3px 8px;
    border: 1px solid var(--border-default);
    border-radius: 2px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 11px;
    margin-right: 8px;
    color: var(--accent-primary);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-dim);
}

/* ============================================
   SCROLLBAR
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 1px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        height: auto;
        padding: 12px;
        gap: 10px;
    }

    .control-group {
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
        justify-content: center;
    }

    .controls h1 {
        font-size: 14px;
    }

    .main-content {
        top: auto;
        position: relative;
    }

    .language-panel,
    .stats-panel {
        width: 100%;
        top: 0;
        height: 100vh;
    }

    .modal-content {
        width: 95%;
    }
}
