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

:root {
    --primary: #0a1628;
    --primary-light: #1a2d4a;
    --accent: #3b82f6;
    --accent-light: #60a5fa;
    --white: #fff;
    --gray-300: #d1d5db;
    --gray-600: #6b7280;
    --line: rgba(59, 130, 246, 0.18);
    --herb: #22c55e;
    --carn: #ef4444;
    --sand: #eab308;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    background: var(--primary);
    color: var(--white);
    padding-bottom: 2rem;
}

.conn {
    position: fixed; top: 0; left: 0; right: 0; z-index: 50;
    background: #7f1d1d; color: #fecaca; text-align: center;
    padding: 0.5rem; font-size: 0.9rem;
}
.hidden { display: none; }

.topbar {
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    padding: 1rem 1.5rem; background: rgba(10, 22, 40, 0.95);
    border-bottom: 1px solid var(--line);
}
.brand { color: var(--white); text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.brand span { color: var(--accent); }
.live { margin-right: auto; color: var(--gray-300); font-size: 0.85rem; display: flex; align-items: center; gap: 0.45rem; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--herb); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.back-link { color: var(--accent-light); text-decoration: none; font-size: 0.9rem; font-weight: 500; }
.back-link:hover { text-decoration: underline; }

main { max-width: 1240px; margin: 0 auto; padding: 1.5rem; display: grid; gap: 1.25rem; }

.intro h1 { font-size: 2.1rem; font-weight: 800; margin-bottom: 0.6rem; }
.intro p { color: var(--gray-300); max-width: 860px; }
.hint { color: var(--gray-600); font-size: 0.88rem; margin-top: 0.5rem; }

.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.75rem; }
.kpi {
    background: var(--primary-light); border: 1px solid var(--line);
    border-radius: 12px; padding: 0.85rem; text-align: center;
}
.kpi .num { font-size: 1.5rem; font-weight: 700; color: var(--accent-light); line-height: 1.1; }
.kpi .num.green { color: var(--herb); }
.kpi .num.red { color: var(--carn); }
.kpi .num.sand { color: var(--sand); }
.kpi .lbl { color: var(--gray-600); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }

.card {
    background: var(--primary-light); border: 1px solid var(--line);
    border-radius: 14px; padding: 1.25rem;
}
.card h2 {
    font-size: 0.95rem; color: var(--gray-300); text-transform: uppercase;
    letter-spacing: 0.06em; margin-bottom: 0.85rem;
}
.card .sub { color: var(--gray-600); font-size: 0.85rem; margin-bottom: 0.5rem; }

.grid { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr); gap: 1.25rem; }

.map-wrap, .chart-wrap { width: 100%; overflow: hidden; border-radius: 10px; }
#map, #chart { width: 100%; height: auto; display: block; background: #071019; border-radius: 10px; }

.legend { display: flex; flex-wrap: wrap; gap: 0.9rem; margin-top: 0.7rem; color: var(--gray-600); font-size: 0.78rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.sw.water { background: #14324d; }
.sw.coast { background: #2b4a5e; }
.sw.land { background: #3f3a24; }
.sw.plant { background: #4ade80; }
.sw.dot-herb { background: var(--herb); border-radius: 50%; }
.sw.dot-carn { background: var(--carn); border-radius: 50%; }
.sw.dot-adapt { background: var(--sand); border-radius: 50%; }

.creature-box {
    background: #071019; border: 1px solid var(--line); border-radius: 10px;
    display: flex; align-items: center; justify-content: center; padding: 0.5rem;
}
#creature { width: 100%; height: auto; display: block; }

#slider { width: 100%; margin-top: 0.9rem; accent-color: var(--accent); }
.slider-note { color: var(--gray-600); font-size: 0.78rem; margin-top: 0.3rem; }

.genes { margin-top: 0.85rem; display: grid; gap: 0.4rem; }
.gene { display: grid; grid-template-columns: 5.5rem 1fr 2.4rem; align-items: center; gap: 0.5rem; font-size: 0.78rem; }
.gene .gname { color: var(--gray-300); }
.gene .gbar { height: 7px; background: rgba(0, 0, 0, 0.35); border-radius: 4px; overflow: hidden; }
.gene .gfill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-light)); border-radius: 4px; }
.gene .gval { color: var(--accent-light); text-align: right; font-variant-numeric: tabular-nums; }

.milestones { display: grid; gap: 0.4rem; max-height: 260px; overflow-y: auto; }
.ms { display: flex; gap: 0.6rem; align-items: baseline; font-size: 0.85rem; padding: 0.4rem 0; border-top: 1px solid rgba(59, 130, 246, 0.1); }
.ms:first-child { border-top: none; }
.ms .mt { color: var(--gray-600); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.ms .mtx { color: var(--gray-300); }
.ms.land-touch .mtx, .ms.land-born .mtx, .ms.land-colonized .mtx { color: var(--sand); font-weight: 600; }
.empty { color: var(--gray-600); font-style: italic; font-size: 0.85rem; }

.avg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.avg-grid h3 { font-size: 0.85rem; margin-bottom: 0.5rem; }
.green { color: var(--herb); }
.red { color: var(--carn); }

footer { text-align: center; color: var(--gray-600); font-size: 0.85rem; padding: 1.5rem; }
footer a { color: var(--accent); text-decoration: none; }

@media (max-width: 980px) {
    .grid { grid-template-columns: 1fr; }
    .kpis { grid-template-columns: repeat(3, 1fr); }
    .avg-grid { grid-template-columns: 1fr; }
}

/* Ovládání */
.controls { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.btn {
    background: rgba(59, 130, 246, 0.14); color: var(--accent-light);
    border: 1px solid rgba(59, 130, 246, 0.35); border-radius: 9px;
    padding: 0.5rem 1rem; font: inherit; font-size: 0.88rem; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
}
.btn:hover { background: rgba(59, 130, 246, 0.28); color: var(--white); }
.btn.danger { color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); background: rgba(239, 68, 68, 0.12); }
.btn.danger:hover { background: rgba(239, 68, 68, 0.24); color: #fff; }
.btn.on { background: var(--accent); color: var(--white); border-color: var(--accent); }
.ctrl-note { color: var(--gray-600); font-size: 0.8rem; }
.admin-ctl { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-left: auto; }
.admin-tag {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--sand); border: 1px solid rgba(234, 179, 8, 0.35);
    background: rgba(234, 179, 8, 0.12); padding: 0.15rem 0.5rem; border-radius: 6px;
}
.sim-banner {
    background: rgba(234, 179, 8, 0.14); border: 1px solid rgba(234, 179, 8, 0.4);
    color: #fde68a; border-radius: 10px; padding: 0.6rem 1rem; font-size: 0.9rem;
}
