/* ============================================================
   STYLE.CSS - Chimera Wars unified game styles
   ============================================================ */

:root {
    --bg: #11111b;
    --panel: #313244;
    --surface: #181825;
    --text: #cdd6f4;
    --subtext: #a6adc8;
    --overlay: #45475a;
    --gold: #f9e2af;
    --wood: #a6e3a1;
    --food: #fab387;
    --essence: #74c7ec;
    --danger: #f38ba8;
    --accent: #89b4fa;
    --purple: #cba6f7;
    --success: #a6e3a1;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

#game-root {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 10px;
    gap: 10px;
    position: relative;
}

#music-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 30;
    display: flex;
    gap: 6px;
}
.music-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(24, 24, 37, 0.9);
    color: var(--text);
    border: 1px solid var(--overlay);
    font-size: 16px;
    line-height: 1;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
}
.music-btn:hover {
    background: var(--panel);
    border-color: var(--accent);
}
.music-btn.music-muted {
    color: var(--danger);
    border-color: rgba(243, 139, 168, 0.5);
}
.music-btn.music-active {
    color: var(--essence);
    border-color: rgba(116, 199, 236, 0.55);
}

/* ---- RESOURCE BAR ---- */
#resource-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--panel);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 15px;
    flex-shrink: 0;
    padding-right: 96px;
}
.res-gold { color: var(--gold); }
.res-wood { color: var(--wood); }
.res-food { color: var(--food); }
.res-essence { color: var(--essence); }
.res-workers { color: var(--accent); }

/* ---- MAIN LAYOUT ---- */
#main-layout {
    display: flex;
    gap: 10px;
    flex: 1;
    min-height: 0;
}

/* ---- GAME VIEW (Canvas) ---- */
#game-view {
    flex: 2;
    position: relative;
    background: #232a2d;
    border-radius: 8px;
    border: 2px solid var(--overlay);
    overflow: hidden;
    cursor: crosshair;
}
canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ---- UI PANEL ---- */
#ui-panel {
    flex: 1;
    max-width: 380px;
    background: var(--panel);
    padding: 15px;
    border-radius: 8px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}
#ui-panel h3 {
    margin: 0;
    color: var(--accent);
    border-bottom: 1px solid var(--overlay);
    padding-bottom: 6px;
    font-size: 15px;
}

/* ---- SHARED COMPONENTS ---- */
button {
    background: var(--accent);
    color: var(--bg);
    border: none;
    padding: 8px 12px;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.15s;
    font-size: 13px;
}
button:hover { filter: brightness(1.15); }
button:disabled, button.disabled-btn {
    background: var(--overlay);
    color: #6c7086;
    cursor: not-allowed;
    filter: none;
}

.control-group {
    background: var(--surface);
    padding: 10px;
    border-radius: 6px;
}
.flex-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}
.flex-row:last-child { margin-bottom: 0; }
.hint {
    font-size: 11px;
    color: var(--subtext);
    font-style: italic;
}

/* ---- SHAPES ---- */
.shape-container {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 5px;
}
.shape { width: 40px; height: 40px; transition: 0.2s; }
.shape-tiny { width: 18px; height: 18px; display: inline-block; vertical-align: middle; margin-right: 5px; }
.lvl0-human { border-radius: 50%; }
.lvl0-monster { border-radius: 0; }
.lvl1 { border-radius: 30%; }
.lvl2 { clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); }
.lvl3 { clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%); }
.super { box-shadow: 0 0 12px 4px var(--gold); border: 2px solid var(--gold); }
.lvl2.super, .lvl3.super { filter: drop-shadow(0 0 8px var(--gold)); border: none; }

/* ---- MENU SCENE ---- */
.menu-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
}
.menu-title {
    font-size: 56px;
    font-weight: bold;
    color: var(--danger);
    text-shadow: 0 0 30px rgba(243, 139, 168, 0.4);
    margin-bottom: 10px;
    letter-spacing: 6px;
}
.menu-subtitle {
    font-size: 18px;
    color: var(--subtext);
    margin-bottom: 40px;
    letter-spacing: 2px;
}
.menu-buttons {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}
.menu-btn {
    padding: 15px 40px;
    font-size: 18px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--bg);
}
.menu-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(137, 180, 250, 0.3); }
.menu-saves {
    background: var(--surface);
    padding: 20px;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
}
.menu-saves h3 { color: var(--subtext); margin: 0 0 10px 0; }
.save-slot {
    padding: 10px;
    background: var(--panel);
    border-radius: 6px;
    margin-bottom: 5px;
    cursor: pointer;
    transition: 0.15s;
    font-size: 13px;
}
.save-slot:hover { background: var(--overlay); }
.save-slot.empty { color: var(--subtext); cursor: default; }
.menu-footer {
    position: absolute;
    bottom: 30px;
    color: var(--overlay);
    font-size: 13px;
}

/* ---- STARTER SELECT ---- */
.starter-screen {
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.starter-title {
    color: var(--accent);
    text-align: center;
    margin: 0 0 5px 0;
}
.starter-subtitle {
    color: var(--subtext);
    text-align: center;
    font-size: 13px;
    margin-bottom: 20px;
}
.starter-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    flex: 1;
    overflow-y: auto;
    align-content: flex-start;
}
.starter-card {
    background: var(--surface);
    padding: 15px;
    border-radius: 8px;
    width: 160px;
    text-align: center;
    cursor: pointer;
    border: 3px solid transparent;
    transition: 0.2s;
}
.starter-card:hover { background: var(--overlay); }
.starter-card.selected { border-color: var(--accent); box-shadow: 0 0 15px rgba(137, 180, 250, 0.25); }
.starter-name { font-weight: bold; margin: 8px 0 4px; font-size: 14px; }
.starter-stats { font-size: 12px; color: var(--subtext); display: flex; justify-content: space-around; margin-bottom: 6px; }
.starter-desc { font-size: 11px; color: var(--subtext); font-style: italic; }
.starter-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--overlay);
}
.starter-count { font-size: 16px; font-weight: bold; color: var(--accent); }

/* ---- BASE SCENE ---- */
.action-btn {
    width: 100%;
    margin-bottom: 5px;
    padding: 10px;
}
.btn-save { background: var(--overlay); color: var(--text); }
.btn-save:hover { background: #585b70; }

.build-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    margin-bottom: 5px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--overlay);
}
.build-option:hover { border-color: var(--accent); }
.build-option.active-build {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(137, 180, 250, 0.3);
}
.research-card.completed {
    border-color: rgba(166, 227, 161, 0.55);
}
.research-card.queued {
    border-color: rgba(249, 226, 175, 0.55);
}
.build-desc { font-size: 10px; color: var(--subtext); margin-top: 2px; }
.base-panel-note {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--overlay);
    font-size: 11px;
    color: var(--subtext);
    line-height: 1.5;
}
.base-selected-building {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.selected-block-title {
    margin-top: 6px;
    font-size: 11px;
    font-weight: bold;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.worker-adjust-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.worker-adjust-row button {
    min-width: 34px;
}

.btn-cancel {
    width: 100%;
    background: var(--overlay);
    color: var(--text);
    margin-top: 5px;
}
.selected-remove-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 5px;
}
.selected-remove-row .hint {
    flex: 1;
}
.btn-demolish {
    width: 30px;
    min-width: 30px;
    height: 30px;
    padding: 0;
    background: var(--danger);
    color: var(--bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
}
.btn-demolish:hover {
    filter: brightness(1.08);
}

.roster-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.roster-card-mini {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: var(--surface);
    border-radius: 4px;
    font-size: 12px;
}
.roster-stats { margin-left: auto; color: var(--subtext); font-size: 11px; }

.save-slot-btn {
    display: block;
    width: 100%;
    margin-bottom: 5px;
    text-align: left;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--overlay);
}
.save-slot-btn:hover { border-color: var(--accent); }
.save-overlay {
    position: absolute;
    inset: 15px;
    background: rgba(17, 17, 27, 0.96);
    border: 1px solid var(--overlay);
    border-radius: 8px;
    padding: 15px;
    z-index: 10;
}

/* ---- BREEDING SCENE ---- */
.breeding-layout {
    display: flex;
    gap: 15px;
    height: 100%;
}
.breeding-station-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.breeding-roster-panel {
    flex: 1.5;
    overflow-y: auto;
}
.station-title {
    color: var(--purple);
    font-size: 22px;
    margin: 0 0 5px;
}
.station-desc {
    color: var(--subtext);
    font-size: 12px;
    margin-bottom: 20px;
}
.breed-pedestals {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}
.breed-pedestal {
    width: 120px;
    height: 120px;
    background: var(--surface);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--overlay);
    padding: 8px;
}
.breed-pedestal.filled { border-color: var(--purple); }
.pedestal-name { font-size: 11px; font-weight: bold; margin-top: 5px; }
.pedestal-stats { font-size: 10px; color: var(--subtext); }
.breed-plus { font-size: 28px; color: var(--overlay); font-weight: bold; }

.breed-action-area {
    background: var(--surface);
    padding: 15px;
    border-radius: 8px;
    width: 100%;
    margin-bottom: 15px;
}
.breed-cost {
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: bold;
}
.breed-cost span { margin: 0 8px; }
.discount-badge {
    color: var(--success);
    font-size: 11px;
    margin-top: 4px;
}
.btn-breed-main {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    background: var(--purple);
}
.btn-back {
    width: 100%;
    background: var(--overlay);
    color: var(--text);
    margin-top: auto;
}

.breed-queue-box {
    width: 100%;
    background: var(--surface);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 15px;
    text-align: left;
}
.breed-queue-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
}
.breed-queue-item {
    background: var(--bg);
    border: 1px solid var(--overlay);
    border-radius: 6px;
    padding: 8px 10px;
}
.breed-queue-item.active {
    border-color: var(--purple);
    box-shadow: 0 0 0 1px rgba(203, 166, 247, 0.22);
}
.breed-queue-label {
    font-size: 12px;
    font-weight: bold;
    margin: 4px 0 2px;
}
.breed-queue-time {
    font-size: 11px;
    color: var(--subtext);
}

.roster-title {
    margin: 0 0 10px;
    color: var(--subtext);
    border-bottom: 1px solid var(--overlay);
    padding-bottom: 8px;
}
.breed-roster-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.breed-card {
    background: var(--surface);
    padding: 10px;
    border-radius: 8px;
    width: 110px;
    text-align: center;
    cursor: pointer;
    border: 3px solid transparent;
    transition: 0.15s;
}
.breed-card:hover { background: var(--overlay); }
.breed-card.selected { border-color: var(--purple); box-shadow: 0 0 10px rgba(203, 166, 247, 0.2); }
.breed-card.wounded { opacity: 0.5; }
.card-name {
    font-weight: bold;
    font-size: 11px;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-lvl { font-size: 10px; color: var(--purple); margin-bottom: 3px; }
.card-stats {
    font-size: 10px;
    color: var(--subtext);
    display: flex;
    justify-content: space-between;
    background: var(--bg);
    padding: 3px 5px;
    border-radius: 3px;
}

/* ---- WORLD MAP SCENE ---- */
.village-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
}
.village-card {
    background: var(--surface);
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: 0.15s;
}
.village-card:hover { border-color: var(--overlay); }
.village-card.selected { border-color: var(--danger); }
.village-card.defeated { opacity: 0.6; }
.village-name { font-weight: bold; font-size: 13px; }
.village-diff { font-size: 11px; color: var(--gold); }
.village-desc { font-size: 11px; color: var(--subtext); }
.village-detail {
    font-size: 12px;
    margin: 8px 0;
    line-height: 1.6;
}
.village-detail div { border-bottom: 1px solid var(--overlay); padding: 2px 0; }

.march-bar {
    height: 20px;
    background: var(--surface);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--overlay);
}
.march-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--danger));
    transition: width 0.1s;
    border-radius: 10px;
}

/* Squad select */
.squad-controls {
    display: flex;
    gap: 5px;
    margin-bottom: 8px;
}
.squad-section {
    background: var(--surface);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 8px;
}
.squad-section-title {
    font-size: 12px;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 4px;
}
.squad-section-hint {
    font-size: 10px;
    color: var(--subtext);
    margin-bottom: 6px;
}
.stay-home-section .squad-section-title {
    color: var(--food);
}
.btn-small {
    background: var(--overlay);
    color: white;
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 4px;
}
.btn-small:hover { background: var(--accent); color: var(--bg); }

.squad-roster {
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-content: flex-start;
    max-height: 180px;
}
.stay-home-roster {
    max-height: 110px;
}
.squad-card {
    background: var(--surface);
    padding: 6px;
    border-radius: 6px;
    width: 30%;
    text-align: center;
    cursor: pointer;
    border: 2px solid transparent;
    transition: 0.1s;
    position: relative;
}
.squad-card:hover { background: var(--overlay); }
.squad-card.in-squad { border-color: var(--success); background: var(--panel); }
.squad-card.stay-home {
    border-color: var(--food);
    background: rgba(250, 179, 135, 0.08);
}
.squad-card.wounded { opacity: 0.4; cursor: not-allowed; }
.card-title { font-size: 10px; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-mini-stats { font-size: 9px; color: var(--subtext); }
.wounded-badge { font-size: 8px; color: var(--danger); font-weight: bold; }
.stay-home-badge { font-size: 8px; color: var(--food); font-weight: bold; }
.squad-check {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--success);
    color: var(--bg);
    font-size: 10px;
    font-weight: bold;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.squad-summary {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: bold;
    padding: 8px;
    background: var(--surface);
    border-radius: 6px;
    margin-bottom: 8px;
    border: 1px dashed var(--accent);
}
.btn-raid {
    background: var(--danger);
    color: var(--bg);
    padding: 14px;
    font-size: 16px;
    width: 100%;
    margin-bottom: 8px;
}
.btn-raid:hover { box-shadow: 0 0 15px rgba(243, 139, 168, 0.3); }

/* ---- SIEGE SCENE ---- */
.reward-section {
    background: var(--surface);
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 13px;
    line-height: 1.6;
}
.battle-unit-list {
    max-height: 200px;
    overflow-y: auto;
}
.battle-unit-info {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    padding: 3px 0;
    border-bottom: 1px solid var(--surface);
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--overlay); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--subtext); }
