.hero,
.info {
    box-sizing: border-box;
    margin: 0 auto;
    max-width: 1240px;
}

body {
    background: #20231f;
    color: #f4f1e8;
    font-family: sans-serif;
    text-align: left;
    margin: 0;
    min-height: 100vh;
}

canvas {
    border: 2px solid #5b625c;
    background: #2c332f;
    display: block;
    margin: 0;
    width: 100%;
    max-width: 100%;
    height: auto;
}

.hero {
    display: grid;
    gap: 10px;
    padding: 16px 16px 10px;
}

.game-intro {
    border: 1px solid #5b625c;
    border-radius: 8px;
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(0, 0.7fr) minmax(0, 1fr);
    padding: 12px;
    background: #293027;
}

.game-intro img {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 1px solid #5b625c;
    border-radius: 6px;
    object-fit: cover;
    object-position: left top;
}

.game-intro h2 {
    margin: 0 0 6px;
    font-size: 1.1rem;
}

.game-intro p,
.game-intro li {
    color: #d7d1c0;
    line-height: 1.7;
}

.game-intro ul {
    margin: 8px 0;
    padding-left: 1.2em;
}

.game-intro a {
    color: #f6bd60;
    font-weight: 700;
    text-decoration: none;
}

@media (max-width: 760px) {
    .game-intro {
        grid-template-columns: 1fr;
    }
}

.hero-copy h1 {
    margin: 0 0 6px;
    font-size: 1.35rem;
}

.hero-copy p {
    color: #d7d1c0;
    margin: 0;
    font-size: 0.92rem;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.legend-chip {
    align-items: center;
    background: #293027;
    border: 1px solid #5b625c;
    border-radius: 999px;
    color: #d7d1c0;
    display: inline-flex;
    font-size: 0.78rem;
    gap: 6px;
    min-height: 28px;
    padding: 0 10px;
}

.swatch,
.marker {
    display: inline-block;
    flex: 0 0 auto;
}

.swatch {
    border-radius: 3px;
    height: 10px;
    width: 10px;
}

.swatch.river { background: #38a3a5; }
.swatch.sea { background: #22577a; }
.swatch.forest { background: #386641; }
.swatch.plain { background: #7a9e4b; }
.swatch.mountain { background: #6f4e37; }

.marker.male {
    background: #dcefff;
    border: 1px solid rgba(32, 35, 31, 0.5);
    height: 10px;
    width: 10px;
}

.marker.female {
    background: #f7d6e0;
    border: 1px solid rgba(32, 35, 31, 0.5);
    border-radius: 50%;
    height: 10px;
    width: 10px;
}

.marker.child {
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 11px solid #cfe8a9;
}

.marker.weak {
    border: 2px solid #d1495b;
    border-radius: 50%;
    height: 10px;
    width: 10px;
}

.marker.animal {
    background: #dda15e;
    border-radius: 50%;
    height: 10px;
    width: 10px;
}

.marker.village {
    border: 2px solid #f6bd60;
    border-radius: 50%;
    height: 12px;
    width: 12px;
}

.marker.house {
    background: #8d6e3f;
    height: 8px;
    width: 12px;
}

.app-shell {
    box-sizing: border-box;
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
    margin: 0 auto 24px;
    max-width: 1240px;
    padding: 0 16px;
}

.left-column,
.right-column {
    display: grid;
    gap: 12px;
    align-content: start;
}

.canvas-panel {
    border: 1px solid #5b625c;
    border-radius: 8px;
    background: #293027;
    padding: 10px;
}

.stats {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(130px, 1fr));
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.stat {
    border: 1px solid #5b625c;
    border-radius: 8px;
    padding: 8px;
    background: #293027;
}

.stat-label {
    color: #c9c5b8;
    font-size: 0.78rem;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.stat-value.stat-multiline {
    display: grid;
    gap: 4px;
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1.35;
}

.axis-line {
    color: #f4f1e8;
}

.axis-line .axis-name {
    color: #f1d58a;
    font-weight: 700;
}

.axis-line .axis-poles {
    color: #d7d1c0;
    font-weight: 500;
}

.stat.primary {
    grid-column: span 2;
    background: #34402f;
}

.stat.primary .stat-value {
    font-size: 1.45rem;
}

.start-panel,
.help-panel,
.map-legend-panel {
    border: 1px solid #5b625c;
    border-radius: 8px;
    background: #293027;
    box-sizing: border-box;
    margin: 0;
    max-width: none;
    padding: 12px;
    text-align: left;
}

.start-panel h4,
.help-panel h4 {
    margin: 0 0 8px;
    font-size: 0.95rem;
}

.map-legend-panel {
    padding: 10px 12px;
}

.overlay-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
}

.overlay-toggle,
.overlay-mode {
    align-items: center;
    color: #d7d1c0;
    display: inline-flex;
    font-size: 0.82rem;
    gap: 8px;
}

.overlay-mode select {
    min-width: 170px;
}

.overlay-legend {
    margin-top: 8px;
}

.overlay-help {
    margin: 8px 0 0;
}

.swatch.overlay-coastal { background: rgba(183, 63, 103, 0.85); }
.swatch.overlay-floodplain { background: rgba(87, 117, 144, 0.85); }
.swatch.overlay-levee { background: rgba(255, 214, 102, 0.92); }
.swatch.overlay-terrace { background: rgba(144, 190, 109, 0.9); }
.swatch.overlay-hillside { background: rgba(249, 132, 74, 0.9); }

.map-picker {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.map-help,
.help-panel p,
.help-panel li {
    color: #d7d1c0;
    font-size: 0.82rem;
    line-height: 1.5;
}

.map-help {
    margin: 8px 0 0;
}

.help-panel ul {
    margin: 6px 0 0;
    padding-left: 20px;
}

.control-group {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
    max-width: none;
    padding: 0;
}

.controls {
    align-items: stretch;
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
    margin: 0;
    max-width: none;
    padding: 0;
}

.controls button,
.controls select,
.controls input,
.start-panel button,
.start-panel select {
    background: #f4f1e8;
    border: 1px solid #5b625c;
    border-radius: 8px;
    color: #20231f;
    font: inherit;
    min-height: 34px;
    padding: 6px 10px;
}

.controls input {
    max-width: 110px;
}

.controls label,
.map-picker label,
.advanced-grid label {
    color: #d7d1c0;
    display: grid;
    font-size: 0.82rem;
    gap: 4px;
}

.field-hint {
    color: #aeb7ac;
    font-size: 0.74rem;
    line-height: 1.35;
}

.controls button,
.start-panel button {
    cursor: pointer;
    font-weight: 700;
}

.log-panel {
    max-width: none;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    text-align: left;
}

.advanced-panel {
    border: 1px solid #5b625c;
    border-radius: 8px;
    background: #293027;
    padding: 10px 12px;
}

.advanced-panel summary {
    cursor: pointer;
    font-weight: 700;
}

.advanced-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 10px;
}

.advanced-section {
    display: grid;
    gap: 10px;
}

.advanced-section h4 {
    margin: 10px 0 0;
    font-size: 0.95rem;
}

.advanced-section p {
    margin: 0;
    color: #d7d1c0;
    font-size: 0.82rem;
    line-height: 1.5;
}

.advanced-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.advanced-actions button {
    background: #f4f1e8;
    border: 1px solid #5b625c;
    border-radius: 8px;
    color: #20231f;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    min-height: 34px;
    padding: 6px 10px;
}

.advanced-divider {
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin: 14px 0;
}

.advanced-grid button,
.advanced-grid input {
    background: #f4f1e8;
    border: 1px solid #5b625c;
    border-radius: 8px;
    color: #20231f;
    font: inherit;
    min-height: 34px;
    padding: 6px 10px;
}

.advanced-stats {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 10px;
}

.right-advanced {
    margin-top: -2px;
}

.log-panel h4 {
    margin: 0 0 8px;
    font-size: 0.95rem;
}

#eventLog {
    border: 1px solid #5b625c;
    border-radius: 8px;
    background: #293027;
    margin: 0;
    max-height: 150px;
    overflow: auto;
    padding: 10px 10px 10px 34px;
    font-size: 0.82rem;
    line-height: 1.45;
}

#eventLog li {
    margin: 0 0 4px;
}

.village-memory {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 12px;
}

.village-card {
    border: 1px solid #5b625c;
    border-radius: 8px;
    background: #293027;
    padding: 10px;
}

.village-card h5 {
    margin: 0 0 8px;
    font-size: 0.9rem;
}

.village-card p {
    color: #d7d1c0;
    font-size: 0.78rem;
    line-height: 1.45;
    margin: 4px 0;
}

@media (max-width: 640px) {
    .app-shell {
        grid-template-columns: 1fr;
        padding: 0 12px;
    }

    .stats {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    .village-memory {
        grid-template-columns: 1fr;
    }

    .advanced-grid,
    .advanced-stats {
        grid-template-columns: 1fr;
    }
}
