/* ===================================================================
   IMPERIJA – IO-Style Full-Screen Medieval Strategy
   Inspired by Imperia Online village UI
   =================================================================== */

/* ── Reset & Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    overflow: hidden;
    scrollbar-width: thin;
    scrollbar-color: #87795D rgba(111,98,66,0.4);
}
html::-webkit-scrollbar { width: 12px; background: rgba(111,98,66,0.4); }
html::-webkit-scrollbar-thumb {
    background-color: #87795D; border: 1px solid #554D3B; border-radius: 4px;
}
html::-webkit-scrollbar-thumb:hover { background-color: #8F8063; }

body {
    font-family: 'Montserrat', Arial, sans-serif;
    background-color: #121212;
    color: #FFEEB6;
    width: 100%; height: 100vh;
    padding: 0 !important;
    user-select: none;
    overflow: hidden;
}

/* ── Auth pages ────────────────────────────────────────────────── */
body.auth-page {
    background:
        linear-gradient(rgba(10,8,4,.45), rgba(12,8,3,.7)),
        url('../images/login_bg.png') center center / cover no-repeat fixed;
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; overflow: auto;
}
.auth-container {
    width: 90%; max-width: 420px; margin: 30px auto; padding: 36px 34px;
    background: linear-gradient(180deg, rgba(247,240,225,.97) 0%, rgba(238,227,204,.97) 100%);
    border: 1px solid rgba(138,90,68,.55); border-radius: 16px;
    box-shadow: 0 18px 50px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.6);
    text-align: center; color: #4a2c2a;
    backdrop-filter: blur(3px);
}
.auth-container::before {
    content: "\269C"; /* ⚜ fleur-de-lis (ljiljan) */
    display: block; font-size: 2.1em; line-height: 1;
    color: #b8863a; margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,.18);
}
.auth-container h1 {
    font-size: 1.85em; margin-bottom: 4px; color: #5a3d18;
    font-weight: 700; letter-spacing: .3px;
}
.auth-container > p { color: #8a6a44; font-size: .92em; margin-bottom: 24px; }

.auth-container .form-group { margin-bottom: 15px; text-align: left; }
.auth-container .form-group label {
    display: block; margin-bottom: 6px;
    color: #6a4a2a; font-size: .76em; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em;
}
.auth-container .form-group input {
    width: 100%; padding: 12px 14px;
    background: rgba(255,252,245,.92);
    border: 1px solid #c9a878; border-radius: 9px;
    color: #3b291b; font-size: .95em; font-family: inherit;
    transition: border-color .18s, box-shadow .18s, background .18s;
}
.auth-container .form-group input::placeholder { color: #b3987a; }
.auth-container .form-group input:focus {
    outline: none; border-color: #b8863a; background: #fffdf8;
    box-shadow: 0 0 0 3px rgba(184,134,58,.22);
}
.auth-container .btn {
    width: 100%; margin-top: 10px; padding: 13px 18px;
    background: linear-gradient(180deg, #dcb661 0%, #b8863a 100%);
    border: 1px solid #a5701f; border-radius: 10px;
    color: #2e1c07; font-size: 1em; font-weight: 700; letter-spacing: .04em;
    text-shadow: none; cursor: pointer;
    box-shadow: 0 4px 14px rgba(120,80,20,.35), inset 0 1px 0 rgba(255,255,255,.4);
    transition: transform .12s, box-shadow .18s, background .18s;
}
.auth-container .btn:hover {
    background: linear-gradient(180deg, #e8c46e 0%, #c89442 100%);
    transform: translateY(-1px);
    box-shadow: 0 7px 20px rgba(120,80,20,.45), inset 0 1px 0 rgba(255,255,255,.45);
}
.auth-container .btn:active { transform: translateY(0); }

.auth-switch { margin-top: 20px; font-size: .9em; color: #6a4a2a; }
.auth-switch a { color: #a5701f; font-weight: 700; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

.auth-container .errors,
.auth-container .success {
    text-align: left; border-radius: 9px; padding: 12px 14px;
    margin-bottom: 20px; font-size: .87em;
}
.auth-container .errors {
    background: rgba(209,91,82,.14); color: #a5352c; border: 1px solid rgba(209,91,82,.42);
}
.auth-container .success {
    background: rgba(76,150,80,.16); color: #2f6b34; border: 1px solid rgba(76,150,80,.42);
}
.auth-container .errors p, .auth-container .success p { margin: 2px 0; }

/* ── Main Game Container (IO-style full screen) ────────────────── */
.imperia {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    overflow: hidden;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

/* ── Village Map (fills entire screen) ─────────────────────────── */
#main-village-container {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
}
.village-map {
    position: relative;
    width: 100%; height: 100%;
    overflow: hidden;
    cursor: default;
    background: #1a2e12;
}
.village-terrain {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}
/* Zoom + drag-pan po mapi */
.village-map.pannable {
    cursor: grab;
    will-change: transform;
    touch-action: none;
}
.village-map.grabbing {
    cursor: grabbing;
}

/* ── Map Building ──────────────────────────────────────────────── */
.map-building {
    position: absolute;
    transform: translate(-50%, -50%);
    text-align: center;
    cursor: pointer;
    transition: transform .2s ease, filter .2s ease;
    z-index: 2;
    user-select: none;
}
.map-building:hover {
    transform: translate(-50%, -50%);
    z-index: 5;
    filter: drop-shadow(0 0 14px rgba(255,200,60,.55));
}
.map-building.clicked {
    transform: translate(-50%, -50%) scale(.98);
    transition: transform .14s ease;
}
.mb-img-wrap { position: relative; display: inline-block; }
.mb-img {
    width: 150px; height: 150px;
    object-fit: contain;
    filter: drop-shadow(3px 5px 8px rgba(0,0,0,.6));
    transition: filter .2s ease;
    image-rendering: auto;
}
.map-building:hover .mb-img {
    filter: drop-shadow(3px 5px 8px rgba(0,0,0,.6)) brightness(1.15);
}

/* Construction overlay */
.mb-construction-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.25);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
}
.mb-hammer { font-size: 1.8em; animation: hammer-swing 1s ease-in-out infinite; }
@keyframes hammer-swing {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-25deg); }
    50% { transform: rotate(15deg); }
}
.map-building.upgrading .mb-img {
    animation: build-pulse 2s ease-in-out infinite;
}
@keyframes build-pulse {
    0%, 100% { filter: drop-shadow(3px 5px 8px rgba(0,0,0,.6)); }
    50% { filter: drop-shadow(0 0 18px rgba(255,180,40,.7)) drop-shadow(3px 5px 8px rgba(0,0,0,.6)); }
}

/* Nameplate */
.mb-nameplate { display: flex; flex-direction: column; align-items: center; margin-top: 3px; }
.mb-label {
    font-size: .72em; font-weight: 600; letter-spacing: .5px;
    color: #FFEEB6;
    background: rgba(0,0,0,.7);
    padding: 2px 10px; border-radius: 3px;
    border: 1px solid rgba(255,238,182,.25);
    text-shadow: 0 1px 3px #000;
    white-space: nowrap;
}
.mb-level {
    font-size: .62em; font-weight: 600;
    color: #ffd780;
    background: rgba(0,0,0,.6);
    padding: 0 6px; border-radius: 2px;
    margin-top: 1px;
    text-shadow: 0 1px 2px #000;
}
.mb-timer {
    display: inline-block;
    background: rgba(180,40,20,.85); color: #fff;
    font-size: .62em; padding: 1px 8px; border-radius: 8px;
    margin-top: 3px;
    box-shadow: 0 1px 4px rgba(0,0,0,.5);
    animation: timer-blink 2s ease-in-out infinite;
}
.mb-timer::before {
    content: "🔨";
    font-size: .95em;
    margin-right: 4px;
    display: inline-block;
}

/* ── Admin: alat za raspored objekata ──────────────────────────── */
#admin-map-toolbar {
    position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
    z-index: 90; display: flex; gap: 8px; align-items: center;
}
#admin-edit-tools {
    display: flex; gap: 8px; align-items: center;
    background: rgba(20,14,6,.92); border: 1px solid #7a5a28;
    border-radius: 10px; padding: 6px 10px;
    box-shadow: 0 6px 20px rgba(0,0,0,.5);
}
#admin-edit-sel { color: #ffd780; font-size: .82em; font-weight: 600; min-width: 130px; text-align: center; }
.admin-map-btn {
    cursor: pointer; background: rgba(40,26,12,.92); color: #FFEEB6;
    border: 1px solid #7a5a28; border-radius: 8px; padding: 6px 10px;
    font-size: .85em; font-weight: 600; line-height: 1;
}
.admin-map-btn:hover { background: rgba(60,40,18,.95); }
.admin-map-primary { background: #c8a24a; color: #241605; border-color: #e0be6a; }
.admin-map-primary:hover { background: #e0be6a; }
.village-map.admin-editing .map-building.admin-movable { cursor: move; }
.village-map.admin-editing .map-building.admin-movable .mb-img-wrap::after {
    content: ""; position: absolute; inset: -4px;
    border: 1px dashed rgba(255,215,128,.45); border-radius: 6px; pointer-events: none;
}
.map-building.admin-selected .mb-img-wrap {
    outline: 2px dashed #ffd780; outline-offset: 4px; border-radius: 6px;
}

/* Dugme za ubrzanje obuke dijamantima */
.timer-card-speed {
    display: inline-block; margin: 8px 0 2px;
    cursor: pointer;
    background: linear-gradient(180deg, #5ac8e0 0%, #3a95bd 100%);
    color: #06222b; font-weight: 700; font-size: .82em;
    border: 1px solid rgba(255,255,255,.35); border-radius: 8px;
    padding: 6px 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.4);
}
.timer-card-speed:hover { filter: brightness(1.08); }
.timer-card-speed:active { transform: translateY(1px); }

/* X za zatvaranje "Tok carstva" */
.activity-close {
    cursor: pointer; background: rgba(0,0,0,.35);
    color: #FFEEB6; border: 1px solid rgba(255,238,182,.25);
    border-radius: 6px; width: 24px; height: 24px; line-height: 1;
    font-size: 1.1em; padding: 0; margin-left: 4px;
}
.activity-close:hover { background: rgba(160,40,20,.6); color: #fff; }
@keyframes timer-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: .7; }
}
.mb-progress {
    width: 70px; height: 5px; margin: 3px auto 0;
    background: rgba(0,0,0,.5); border-radius: 3px; overflow: hidden;
    border: 1px solid rgba(255,255,255,.1);
}
.mb-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #ECC239, #fc4a1a);
    border-radius: 3px; transition: width .9s linear;
    box-shadow: inset 0 1px 2px rgba(255,255,255,.3);
}

/* ── Building Tooltip ──────────────────────────────────────────── */
.building-tooltip {
    position: absolute;
    display: none;
    background: rgba(30,18,8,.95);
    color: #FFEEB6;
    border: 2px solid #7a5a28;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: .82em;
    min-width: 200px; max-width: 280px;
    pointer-events: none;
    z-index: 50;
    box-shadow: 0 4px 20px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.06);
    line-height: 1.5;
    backdrop-filter: blur(4px);
}
.tt-header {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 6px; padding-bottom: 6px;
    border-bottom: 1px solid rgba(122,90,40,.4);
}
.tt-icon { width: 36px; height: 36px; object-fit: contain; filter: drop-shadow(1px 2px 3px rgba(0,0,0,.5)); }
.tt-level { color: #ffd780; font-size: .85em; }
.tt-effect { color: #c8b896; font-size: .85em; margin-bottom: 4px; }
.tt-upgrading { color: #ffb347; font-style: italic; font-size: .85em; }
.tt-maxed { color: #ffd700; font-size: .85em; }
.tt-cost {
    display: flex; gap: 8px; flex-wrap: wrap; font-size: .82em;
    margin-top: 4px; padding-top: 4px;
    border-top: 1px solid rgba(122,90,40,.25);
}
.tt-cost span { white-space: nowrap; }
.tt-hint { color: #a08860; font-size: .75em; text-align: center; margin-top: 4px; font-style: italic; }

/* ===================================================================
   UI OVERLAY SYSTEM — IO-style floating widgets
   =================================================================== */

/* ── UI: Top-Left Profile ──────────────────────────────────────── */
.ui-top-left {
    position: absolute; top: 10px; left: 10px;
    z-index: 10;
}
.profile-box {
    display: flex; align-items: center; gap: 10px;
    background: rgba(40,28,16,.85);
    border: 1px solid rgba(255,238,182,.2);
    border-radius: 6px;
    padding: 8px 16px;
    backdrop-filter: blur(6px);
    box-shadow: 0 3px 12px rgba(0,0,0,.5);
}
.profile-avatar {
    font-size: 2em;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,.3);
    border-radius: 50%;
    border: 2px solid #7a5a28;
}
.profile-name {
    color: #FFEEB6; font-weight: 700; font-size: 1em;
    text-shadow: 1px 1px 3px #000;
    display: block;
}
.profile-title {
    color: #a08860; font-size: .75em; font-weight: 500;
    display: block;
}

/* ── UI: Top-Right Resources ───────────────────────────────────── */
.ui-top-right {
    position: absolute; top: 0; right: 0;
    z-index: 10;
    display: flex; align-items: center;
    gap: 2px;
    background: rgba(40,28,16,.85);
    border-bottom-left-radius: 8px;
    border: 1px solid rgba(255,238,182,.15);
    border-top: none; border-right: none;
    padding: 6px 14px;
    backdrop-filter: blur(6px);
    box-shadow: 0 3px 12px rgba(0,0,0,.4);
}
.ui-res {
    display: flex; align-items: center; gap: 4px;
    padding: 2px 10px;
    font-size: .85em;
    color: #FFEEB6;
    text-shadow: 1px 1px 2px #000;
    position: relative;
    min-width: 65px;
    cursor: default;
}
.ui-res + .ui-res { border-left: 1px solid rgba(255,238,182,.1); }
.res-icon { width: 22px; height: 22px; vertical-align: middle; filter: drop-shadow(1px 1px 2px rgba(0,0,0,.5)); }
.res-emoji { font-size: 1.1em; }
.res-val { font-weight: 600; }
.res-rate {
    font-size: .65em; color: #8a8060;
    position: absolute; bottom: -2px; right: 8px;
}

.ui-activity {
    position: absolute;
    top: 46px;
    right: 10px;
    z-index: 10;
    width: min(360px, calc(100vw - 20px));
}
.activity-widget {
    background: rgba(40,28,16,.88);
    border: 1px solid rgba(255,238,182,.16);
    border-radius: 10px;
    box-shadow: 0 4px 18px rgba(0,0,0,.38);
    backdrop-filter: blur(8px);
    overflow: hidden;
}
.activity-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(65,45,25,.88);
    border-bottom: 1px solid rgba(255,238,182,.12);
}
.activity-widget-header span {
    color: #FFEEB6;
    font-size: .82em;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
}
.activity-shortcuts {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.activity-chip {
    border: 1px solid rgba(255,238,182,.16);
    background: rgba(0,0,0,.24);
    color: #FFEEB6;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: .7em;
    font-weight: 700;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.activity-chip:hover {
    background: rgba(255,238,182,.1);
    border-color: rgba(255,238,182,.3);
    transform: translateY(-1px);
}
.activity-widget-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Resource change animations */
.res-val.res-increment {
    animation: res-glow-up .4s ease-in-out alternate 2;
}
.res-val.res-decrement {
    animation: res-glow-down .4s ease-in-out alternate 2;
}
@keyframes res-glow-up {
    from { text-shadow: 1px 1px 2px #000; }
    to { text-shadow: 0 0 6px lightgreen, 0 0 12px green; color: #8f8; }
}
@keyframes res-glow-down {
    from { text-shadow: 1px 1px 2px #000; }
    to { text-shadow: 0 0 6px indianred, 0 0 12px red; color: #f88; }
}

/* ── UI: Left Menu (nav buttons) ───────────────────────────────── */
.ui-left-menu {
    position: absolute;
    top: 75px; left: 10px;
    z-index: 10;
    display: flex; flex-direction: column;
    gap: 4px;
}
.ui-nav-btn {
    display: flex; align-items: center; gap: 8px;
    background: rgba(40,28,16,.8);
    border: 1px solid rgba(255,238,182,.18);
    border-radius: 5px;
    padding: 8px 14px;
    color: #FFEEB6;
    font-family: inherit;
    font-size: .82em; font-weight: 600;
    cursor: pointer;
    transition: all .2s ease;
    text-shadow: 1px 1px 2px #000;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.ui-nav-btn:hover {
    background: rgba(65,45,25,.9);
    border-color: rgba(255,238,182,.35);
    color: #fff;
    text-shadow: 0 0 4px #FFEEB6;
    transform: translateX(3px);
    box-shadow: 0 2px 10px rgba(0,0,0,.4);
}
.ui-nav-btn.active {
    background: rgba(100,70,30,.9);
    border-color: #FFEEB6;
}
.nav-icon { font-size: 1.2em; width: 22px; text-align: center; }
.nav-text { }

/* Badge/notification on nav buttons */
.ui-nav-btn .badge {
    background: #B53117;
    color: #fff;
    font-size: .7em;
    padding: 1px 5px;
    border-radius: 8px;
    margin-left: auto;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,.4);
}

/* ── UI: Right Bottom (action buttons) ─────────────────────────── */
.ui-right-bottom {
    position: absolute;
    bottom: 60px; right: 10px;
    z-index: 10;
    display: flex; flex-direction: column;
    gap: 6px;
}
.ui-action-btn {
    width: 50px; height: 50px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(120,30,20,.85);
    border: 2px solid rgba(255,100,80,.3);
    border-radius: 8px;
    color: #FFEEB6;
    font-size: 1.4em;
    cursor: pointer;
    transition: all .2s ease;
    box-shadow: 0 3px 10px rgba(0,0,0,.4);
    backdrop-filter: blur(4px);
}
.ui-action-btn:hover {
    background: rgba(160,44,28,.95);
    border-color: rgba(255,100,80,.6);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(255,80,50,.3);
}

/* ── UI: Bottom Bar ────────────────────────────────────────────── */
.ui-bottom-bar {
    position: absolute;
    bottom: 0; left: 0;
    width: 100%;
    z-index: 10;
    pointer-events: none;
}
.bottom-bar-inner {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: rgba(40,28,16,.8);
    border-top: 1px solid rgba(255,238,182,.12);
    backdrop-filter: blur(6px);
    pointer-events: auto;
    width: fit-content;
    border-top-right-radius: 8px;
}
.bb-item {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    background: rgba(0,0,0,.3);
    border: 1px solid rgba(255,238,182,.15);
    border-radius: 5px;
    color: #FFEEB6;
    font-size: 1.1em;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s;
    font-family: inherit;
}
.bb-item:hover {
    background: rgba(65,45,25,.8);
    border-color: rgba(255,238,182,.35);
    color: #fff;
}
.bb-item.muted { opacity: .4; }

/* ===================================================================
   FLOATING PANELS — Slide-in panels for army, training, etc.
   =================================================================== */
.floating-panel {
    position: absolute;
    top: 75px; left: 180px;
    z-index: 15;
    width: 300px;
    max-height: calc(100vh - 100px);
    background: rgba(30,20,10,.92);
    border: 1px solid rgba(255,238,182,.2);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,.6);
    backdrop-filter: blur(8px);
    overflow: hidden;
    animation: panel-slide-in .25s ease-out;
}
@keyframes panel-slide-in {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}
.fp-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px;
    background: rgba(65,45,25,.9);
    border-bottom: 1px solid rgba(255,238,182,.15);
}
.fp-header h3 {
    color: #FFEEB6; font-size: .95em; font-weight: 600;
    text-shadow: 1px 1px 2px #000;
    margin: 0;
}
.fp-close {
    background: none; border: none;
    color: #a08860; font-size: 1.4em;
    cursor: pointer; line-height: 1;
    transition: color .2s;
}
.fp-close:hover { color: #ff6b6b; }

.fp-body {
    padding: 12px;
    overflow-y: auto;
    max-height: calc(100vh - 160px);
    color: #FFEEB6;
    scrollbar-width: thin;
    scrollbar-color: #87795D rgba(0,0,0,.2);
}
.fp-body::-webkit-scrollbar { width: 6px; }
.fp-body::-webkit-scrollbar-thumb { background: #87795D; border-radius: 3px; }

.fp-sub-header {
    font-size: .85em; color: #ffd780;
    margin-bottom: 8px; padding-bottom: 4px;
    border-bottom: 1px solid rgba(255,238,182,.12);
}

.panel-hint {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255,238,182,.12);
    background: rgba(255,238,182,.06);
    color: #c8b896;
    font-size: .82em;
    line-height: 1.5;
}

/* Cards inside panels */
.card {
    background: rgba(255,238,182,.08);
    border: 1px solid rgba(255,238,182,.12);
    padding: 10px; border-radius: 5px;
    margin-bottom: 6px;
    transition: background .2s;
}
.card:hover { background: rgba(255,238,182,.12); }
.card h3 { margin: 0 0 4px; font-size: .9em; color: #ffd780; }
.card p { margin: 2px 0; font-size: .82em; color: #c8b896; }
.army-card { text-align: center; }

.context-help {
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid rgba(255,238,182,.12);
    background: rgba(255,238,182,.08);
}
.context-help strong {
    display: block;
    margin-bottom: 4px;
    color: #ffd780;
}
.context-help p {
    margin: 0;
    color: #c8b896;
    font-size: .82em;
    line-height: 1.5;
}
.context-help-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.build-card {
    padding: 12px;
    margin-bottom: 10px;
}
.build-card.is-ready {
    border-color: rgba(110,214,132,.34);
    box-shadow: inset 0 0 0 1px rgba(110,214,132,.08);
}
.build-card.is-upgrading {
    border-color: rgba(236,194,57,.3);
}
.build-card-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}
.build-card-header h3 {
    margin: 0 0 4px;
}
.build-card-badge {
    flex-shrink: 0;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(0,0,0,.35);
    border: 1px solid rgba(255,238,182,.12);
    color: #ffd780;
    font-size: .72em;
    font-weight: 700;
}
.build-card-meta,
.build-card-status {
    margin-top: 10px;
    color: #c8b896;
    font-size: .8em;
    line-height: 1.5;
}
.build-card-status strong {
    color: #FFEEB6;
}
.build-card-cost {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}
.build-card-cost span {
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(0,0,0,.25);
    border: 1px solid rgba(255,238,182,.08);
    color: #FFEEB6;
    font-size: .76em;
}
.build-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.buildings-browser-shell {
    width: min(1280px, calc(100vw - 24px));
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(71, 39, 18, .9);
    box-shadow: 0 24px 58px rgba(0,0,0,.45);
    background:
        radial-gradient(circle at top left, rgba(255,255,255,.1), transparent 30%),
        linear-gradient(180deg, #eadcb8 0%, #dccda8 100%);
}
.buildings-browser-topbar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 10px 60px;
    color: #f3ddb8;
    background:
        linear-gradient(180deg, #9d5a38 0%, #6f351d 52%, #4e2414 100%);
    border-bottom: 1px solid rgba(30,12,4,.6);
    text-shadow: 0 1px 0 rgba(0,0,0,.55);
}
.buildings-browser-topcap {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, transparent 0%, rgba(255,255,255,.08) 28%, transparent 60%),
        linear-gradient(180deg, rgba(255,255,255,.09), transparent 46%);
    pointer-events: none;
}
.buildings-browser-topbar h2 {
    position: relative;
    margin: 0;
    font-size: 1.05em;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.buildings-browser-close {
    position: absolute;
    top: 6px;
    right: 10px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(55, 22, 11, .35);
    color: #f5d39f;
    font-size: 1.7em;
    line-height: 1;
    cursor: pointer;
    transition: transform .18s ease, background .18s ease;
}
.buildings-browser-close:hover {
    transform: scale(1.06);
    background: rgba(87, 32, 16, .55);
}
.buildings-browser-tabs {
    display: flex;
    gap: 10px;
    padding: 0 18px;
    background: #45392c;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.buildings-browser-tab {
    margin-top: 10px;
    padding: 11px 20px;
    border: 1px solid rgba(82,58,35,.85);
    border-bottom: none;
    border-radius: 7px 7px 0 0;
    background: linear-gradient(180deg, #8c7553 0%, #705a3e 100%);
    color: #f4dfbc;
    font-family: inherit;
    font-size: .92em;
    font-weight: 600;
    cursor: pointer;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}
.buildings-browser-tab:hover {
    background: linear-gradient(180deg, #9c845f 0%, #7b6547 100%);
    transform: translateY(-1px);
}
.buildings-browser-tab.active {
    background: linear-gradient(180deg, #c3ad85 0%, #9f8661 100%);
    color: #2f2015;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
}
.buildings-browser-body {
    padding: 18px;
    overflow: auto;
    background:
        radial-gradient(circle at 15% 22%, rgba(132, 100, 59, .12) 0%, transparent 18%),
        radial-gradient(circle at 85% 18%, rgba(132, 100, 59, .1) 0%, transparent 15%),
        linear-gradient(180deg, rgba(245,236,214,.96), rgba(227,213,181,.95));
}
.buildings-browser-resources {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 10px 18px;
    margin: 0 auto 14px;
    width: fit-content;
    min-width: min(560px, 100%);
    border-radius: 999px;
    background: rgba(128, 103, 67, .24);
    border: 1px solid rgba(118, 90, 52, .32);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.28);
}
.buildings-browser-resource {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #5d4228;
    font-size: .92em;
    font-weight: 700;
}
.buildings-browser-resource img {
    width: 18px;
    height: 18px;
    object-fit: contain;
}
.buildings-browser-resource-emoji {
    font-size: 1em;
}
.buildings-browser-active {
    margin-bottom: 16px;
}
.buildings-browser-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-radius: 9px;
    border: 1px solid rgba(138, 103, 59, .28);
    background: rgba(245,237,214,.7);
    color: #5c4530;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.3);
}
.buildings-browser-banner.is-live {
    border-color: rgba(168, 117, 49, .34);
    background: linear-gradient(180deg, rgba(247,240,221,.88), rgba(232,221,191,.86));
}
.buildings-browser-banner strong {
    display: block;
    margin-bottom: 3px;
    color: #3d2919;
    font-size: .9em;
}
.buildings-browser-banner p {
    margin: 0;
    color: #6a533a;
    font-size: .82em;
}
.buildings-browser-banner-time {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(86, 47, 25, .1);
    border: 1px solid rgba(118, 80, 39, .18);
    color: #7b4c1f;
    font-size: .82em;
    font-weight: 700;
}
.buildings-browser-table-wrap {
    border: 1px solid rgba(132, 104, 66, .28);
    border-radius: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    background: rgba(239, 230, 206, .58);
}
.buildings-browser-row {
    display: grid;
    grid-template-columns: minmax(160px, 1.4fr) 60px minmax(200px, 1.3fr) 62px 62px 62px 78px 140px;
    align-items: center;
}
.buildings-browser-head,
#buildings-browser-table .buildings-browser-row {
    min-width: 780px;
}
.buildings-browser-head {
    background: rgba(117, 90, 55, .14);
    border-bottom: 1px solid rgba(132, 104, 66, .2);
}
.buildings-browser-head .buildings-browser-cell {
    color: #70553a;
    font-size: .78em;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
#buildings-browser-table .buildings-browser-row:nth-child(even) {
    background: rgba(122, 98, 64, .06);
}
.buildings-browser-row.is-ready {
    background: rgba(162, 136, 95, .08);
}
.buildings-browser-row.is-upgrading {
    background: rgba(182, 150, 86, .08);
}
.buildings-browser-row + .buildings-browser-row {
    border-top: 1px solid rgba(132, 104, 66, .12);
}
.buildings-browser-cell {
    min-width: 0;
    padding: 12px 12px;
    color: #57402b;
    font-size: .84em;
}
.buildings-browser-name {
    display: flex;
    align-items: center;
    gap: 12px;
}
.buildings-browser-name img {
    width: 46px;
    height: 46px;
    border-radius: 6px;
    border: 1px solid rgba(115, 87, 58, .26);
    background: rgba(255,255,255,.28);
    object-fit: contain;
    padding: 4px;
}
.buildings-browser-name strong {
    display: block;
    color: #3b291b;
    font-size: 1.02em;
}
.buildings-browser-name span {
    display: block;
    margin-top: 3px;
    color: #7a6249;
    font-size: .78em;
}
.buildings-browser-level {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
}
.buildings-browser-level-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 46px; height: 46px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 30%, #fff7db 0%, #f1d689 42%, #dcb35c 74%, #bd9340 100%);
    border: 2px solid #a5701f;
    color: #573a10;
    line-height: 1;
    box-shadow:
        inset 0 1px 2px rgba(255,255,255,.75),
        inset 0 -2px 4px rgba(120,80,20,.35),
        0 2px 5px rgba(0,0,0,.28);
}
.buildings-browser-level-badge .lvl-cap {
    font-size: .5em; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: #8a6522; margin-bottom: 2px;
}
.buildings-browser-level-badge .lvl-num {
    font-size: 1.2em; font-weight: 800;
    text-shadow: 0 1px 0 rgba(255,255,255,.4);
}
.buildings-browser-effect strong {
    display: block;
    color: #423020;
    font-size: .92em;
}
.buildings-browser-effect span {
    display: block;
    margin-top: 4px;
    color: #7a6249;
    font-size: .79em;
    line-height: 1.45;
}
.buildings-browser-inline-timer {
    color: #965421;
    font-weight: 700;
}
.buildings-browser-cost,
.buildings-browser-time {
    color: #523a25;
    font-weight: 700;
    text-align: center;
}
.buildings-browser-muted {
    color: #9d8b75;
}
.buildings-browser-action {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}
.buildings-browser-upgrade-btn,
.buildings-browser-detail-btn {
    border: 1px solid rgba(96, 59, 35, .55);
    border-radius: 7px;
    font-family: inherit;
    cursor: pointer;
    transition: transform .18s ease, filter .18s ease, opacity .18s ease;
}
.buildings-browser-upgrade-btn {
    min-width: 94px;
    padding: 9px 12px;
    background: linear-gradient(180deg, #8e6d57 0%, #6e4f3f 48%, #5a3f30 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.22);
    color: #fff2dc;
    font-size: .79em;
    font-weight: 700;
    text-shadow: 0 1px 0 rgba(0,0,0,.35);
}
.buildings-browser-upgrade-btn:hover:not(:disabled),
.buildings-browser-detail-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
}
.buildings-browser-upgrade-btn:disabled {
    opacity: .42;
    cursor: not-allowed;
}
.buildings-browser-detail-btn {
    width: 30px;
    height: 30px;
    background: linear-gradient(180deg, #cbc0a1 0%, #ad9972 100%);
    color: #4c3826;
    font-size: .95em;
    font-weight: 700;
}
.buildings-browser-empty {
    padding: 28px 18px;
    text-align: center;
    color: #7a6249;
    font-size: .88em;
}

.timer-card {
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(255,238,182,.12);
    background: rgba(255,238,182,.05);
}
.timer-card + .timer-card {
    margin-top: 10px;
}
.timer-card.is-live {
    border-color: rgba(236,194,57,.22);
    box-shadow: inset 0 0 0 1px rgba(236,194,57,.06);
}
.timer-card.is-idle {
    opacity: .88;
}
.timer-card-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}
.timer-card-title {
    color: #FFEEB6;
    font-size: .84em;
    font-weight: 700;
}
.timer-card-subtitle {
    margin-top: 4px;
    color: #c8b896;
    font-size: .78em;
    line-height: 1.45;
}
.timer-card-badge {
    flex-shrink: 0;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(0,0,0,.32);
    border: 1px solid rgba(255,238,182,.12);
    color: #ffd780;
    font-size: .72em;
    font-weight: 700;
}
.timer-card-meta {
    margin-top: 8px;
    color: #d8ceb0;
    font-size: .78em;
    line-height: 1.55;
}
.timer-card-progress {
    width: 100%;
    height: 6px;
    margin-top: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(0,0,0,.35);
    border: 1px solid rgba(255,238,182,.08);
}
.timer-card-progress-bar {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, #ECC239, #fc4a1a);
    transition: width .9s linear;
}
.timer-card-queue {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.timer-card-queue-item {
    padding-top: 8px;
    border-top: 1px solid rgba(255,238,182,.08);
    color: #c8b896;
    font-size: .77em;
    line-height: 1.45;
}
.timer-card-queue-item:first-child {
    padding-top: 0;
    border-top: none;
}
.timer-card-queue-item strong {
    display: block;
    margin-bottom: 2px;
    color: #FFEEB6;
}
.timer-card-note {
    margin-top: 8px;
    color: #a08860;
    font-size: .76em;
}
.timer-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

/* Forms inside panels */
.form-group { margin-bottom: 10px; }
.form-group label {
    display: block; margin-bottom: 3px;
    font-weight: 600; font-size: .82em; color: #c8b896;
}
.form-group input, .form-group select {
    width: 100%; padding: 7px 10px;
    border: 1px solid rgba(255,238,182,.2);
    background: rgba(0,0,0,.3);
    border-radius: 4px; font-size: .85em;
    color: #FFEEB6;
    font-family: inherit;
    transition: border-color .2s;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: rgba(255,238,182,.5);
    box-shadow: 0 0 8px rgba(255,238,182,.15);
}
.form-group select option {
    background: #2a1a0a; color: #FFEEB6;
}

.train-form.is-disabled {
    opacity: .55;
}
.train-form.is-disabled button {
    pointer-events: none;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
    display: inline-block; padding: 8px 18px;
    background: linear-gradient(180deg, #7a5a28, #5a3d18);
    color: #FFEEB6; border: 1px solid #a07838;
    border-radius: 4px;
    cursor: pointer; font-weight: 600; font-size: .85em;
    font-family: inherit;
    text-shadow: 1px 1px 2px #000;
    transition: all .2s;
    box-shadow: 0 2px 4px rgba(0,0,0,.3);
}
.btn:hover {
    background: linear-gradient(180deg, #8a6a38, #6a4d28);
    border-color: #c09848;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    box-shadow: none;
}
.btn-danger {
    background: linear-gradient(180deg, #8a2020, #601818);
    border-color: #a04040;
}
.btn-danger:hover {
    background: linear-gradient(180deg, #a03030, #702020);
    border-color: #c05050;
}
.btn-diamond {
    background: linear-gradient(180deg, #2a6a9a, #1a4a6a);
    border-color: #3a8aba;
}
.btn-diamond:hover {
    background: linear-gradient(180deg, #3a7aaa, #2a5a7a);
    border-color: #4a9aca;
}

.btn-secondary {
    background: linear-gradient(180deg, #575146, #3c372f);
    border-color: #7b7262;
}
.btn-secondary:hover {
    background: linear-gradient(180deg, #676053, #4a4339);
    border-color: #938672;
}
.btn-small {
    padding: 6px 12px;
    font-size: .77em;
}

/* ===================================================================
   MODALS — IO-style dark theme
   =================================================================== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.75);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(3px);
}
.modal-content {
    background: linear-gradient(180deg, #3a2818, #2a1a0a);
    border: 2px solid #7a5a28;
    border-radius: 8px;
    box-shadow: 0 0 40px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.05);
    padding: 24px;
    position: relative;
    max-height: 90vh; overflow-y: auto;
    color: #FFEEB6;
}
.modal-close {
    position: absolute; top: 10px; right: 14px;
    background: none; border: none; font-size: 1.6em;
    color: #a08860; cursor: pointer;
    transition: color .2s;
}
.modal-close:hover { color: #ff6b6b; }

.building-modal-content { width: 420px; max-width: 95vw; }
.modal-building-header {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 16px;
}
.modal-building-icon { font-size: 3em; line-height: 1; }
.modal-building-img {
    width: 64px; height: 64px; object-fit: contain;
    filter: drop-shadow(2px 3px 5px rgba(0,0,0,.5));
    border-radius: 4px;
    border: 1px solid rgba(255,238,182,.15);
}
.modal-building-header h2 { margin: 0; font-size: 1.3em; color: #FFEEB6; }
.modal-building-level { color: #ffd780; font-weight: 600; font-size: .9em; }

.modal-stat-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0;
}
.stat-label { color: #a08860; font-weight: 600; font-size: .85em; }
.stat-value { font-size: .85em; color: #FFEEB6; }
.modal-divider { border: none; border-top: 1px solid rgba(255,238,182,.12); margin: 8px 0; }

.modal-upgrade-status { text-align: center; padding: 10px 0; }
.status-label { font-weight: 600; color: #ffd780; }
.modal-progress {
    width: 100%; height: 8px; background: rgba(0,0,0,.3);
    border-radius: 4px; overflow: hidden; margin: 8px 0;
    border: 1px solid rgba(255,238,182,.08);
}
.modal-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #ECC239, #fc4a1a);
    border-radius: 4px; transition: width .9s linear;
    box-shadow: inset 0 1px 2px rgba(255,255,255,.2);
}
.status-timer { font-size: .9em; color: #FFEEB6; font-weight: 600; }
.modal-buttons {
    display: flex; gap: 10px; justify-content: center; margin-top: 14px;
}

.confirm-modal-content {
    width: 420px;
    max-width: 92vw;
}
.confirm-message {
    color: #c8b896;
    line-height: 1.6;
    margin-top: 10px;
}

/* ── Global Map Modal ──────────────────────────────────────────── */
.map-modal-content {
    width: 95%; height: 90%; max-width: 1400px; max-height: 90vh;
    display: flex; flex-direction: column;
}
.map-modal-content h2 { color: #FFEEB6; margin-bottom: 10px; }
.interactive-map-wrapper { flex: 1; position: relative; overflow: hidden; }
.global-map-image {
    width: 100%; height: 100%; object-fit: cover;
    display: block; border-radius: 6px;
    border: 1px solid rgba(255,238,182,.1);
}
.map-marker {
    position: absolute; font-size: 22px; cursor: default;
    transition: transform .2s; transform: translate(-50%,-50%);
}
.map-marker:hover { transform: translate(-50%,-50%) scale(1.3); }
.map-marker.own-village { filter: hue-rotate(200deg) brightness(1.2); }
.map-marker.enemy-village { filter: hue-rotate(0deg); cursor: pointer; }
.map-tooltip-gm {
    position: absolute; transform: translate(-50%,-100%);
    background: rgba(30,18,8,.9); color: #FFEEB6;
    border: 1px solid #7a5a28; border-radius: 5px;
    padding: 4px 10px; font-size: .8em; white-space: nowrap;
    pointer-events: none; z-index: 10;
}

/* ===================================================================
   TUTORIAL — IO-style popup
   =================================================================== */
.tutorial-popup {
    position: fixed; bottom: 20px; left: 20px; z-index: 900;
    background: rgba(30,20,10,.95);
    border: 2px solid #7a5a28; border-radius: 8px;
    box-shadow: 0 0 30px rgba(0,0,0,.6);
    max-width: 420px; width: calc(100% - 40px);
    max-height: calc(100vh - 40px); overflow-y: auto;
    color: #FFEEB6;
    backdrop-filter: blur(6px);
}
.tutorial-header {
    display: flex; justify-content: space-between;
    background: rgba(65,45,25,.9);
    padding: 8px 15px; font-weight: 600;
    border-radius: 6px 6px 0 0;
    border-bottom: 1px solid rgba(255,238,182,.15);
}
.close-btn {
    background: none; border: none; color: #a08860;
    font-size: 20px; cursor: pointer;
    transition: color .2s;
}
.close-btn:hover { color: #ff6b6b; }
.tutorial-content-wrapper { display: flex; flex-direction: column; padding: 15px; }
.wizard-left img { height: 80px; margin-bottom: 10px; }
.tutorial-main { flex: 1; }
.tutorial-title { font-size: 1.2em; margin-bottom: 5px; color: #ffd780; }
.tutorial-desc { font-size: .9em; margin-bottom: 12px; color: #c8b896; }
.action-preview img { max-width: 100%; max-height: 120px; border-radius: 5px; margin-bottom: 10px; }
.reward-section { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.reward img { width: 28px; vertical-align: middle; margin-right: 4px; }
.reward span { font-weight: bold; font-size: 1em; }
.btn-accept {
    background: linear-gradient(180deg, #7a5a28, #5a3d18);
    color: #FFEEB6; border: 1px solid #a07838;
    padding: 10px 25px; font-weight: 700; border-radius: 5px;
    cursor: pointer; font-family: inherit;
    transition: all .2s;
    text-shadow: 1px 1px 2px #000;
}
.btn-accept:hover {
    background: linear-gradient(180deg, #8a6a38, #6a4d28);
    color: #fff;
}

/* ===================================================================
   LOADING OVERLAY — IO-style
   =================================================================== */
.loading-overlay {
    position: fixed; inset: 0;
    background: #121212;
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    z-index: 9999;
}
.loading-inner { text-align: center; }
.loading-crown {
    font-size: 4em;
    animation: crown-pulse 2s ease-in-out infinite;
}
@keyframes crown-pulse {
    0%, 100% { transform: scale(1); opacity: .8; }
    50% { transform: scale(1.1); opacity: 1; }
}
.loading-overlay h2 {
    color: #FFEEB6; font-size: 1.2em;
    text-shadow: 0 0 10px rgba(255,238,182,.3);
    margin: 20px 0;
}
.loading-bar {
    width: 300px; height: 6px; margin: 0 auto;
    background: rgba(255,238,182,.1);
    border-radius: 3px; overflow: hidden;
    border: 1px solid rgba(255,238,182,.15);
}
.loading-bar-inner {
    width: 100%; height: 100%;
    background: linear-gradient(90deg, #ECC239, #ffd780);
    border-radius: 3px;
    animation: loading-slide 2s infinite;
    box-shadow: inset 0 1px 2px rgba(255,255,255,.3);
}
@keyframes loading-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===================================================================
   AMBIENT EFFECTS
   =================================================================== */

/* Ambient Light */
.ambient-light {
    position: absolute; inset: 0;
    pointer-events: none; z-index: 1;
    background: radial-gradient(ellipse at 60% 30%, rgba(255,230,150,.15) 0%, transparent 70%);
    animation: ambient-pulse 8s ease-in-out infinite;
}
@keyframes ambient-pulse {
    0%, 100% { opacity: .5; }
    50% { opacity: 1; }
}

/* Smoke */
.smoke-particle {
    position: absolute;
    width: 24px; height: 24px;
    background: radial-gradient(circle, rgba(180,170,150,.6) 0%, rgba(160,150,130,.25) 40%, transparent 70%);
    border-radius: 50%;
    pointer-events: none; z-index: 3;
    opacity: 0;
    animation: smoke-rise 3.5s ease-out infinite;
}
.smoke-particle:nth-child(2) { animation-delay: 1.2s; width: 20px; height: 20px; }
.smoke-particle:nth-child(3) { animation-delay: 2.4s; width: 16px; height: 16px; }
@keyframes smoke-rise {
    0%   { opacity: 0; transform: translate(0, 0) scale(.6); }
    15%  { opacity: .6; }
    50%  { opacity: .35; transform: translate(-10px, -40px) scale(1.2); }
    100% { opacity: 0;   transform: translate(-18px, -75px) scale(1.6); }
}

/* Leaves */
.leaf-particle {
    position: absolute;
    width: 10px; height: 10px;
    background: #6a8a40;
    border-radius: 0 50% 50% 50%;
    pointer-events: none; z-index: 4;
    opacity: 0;
    animation: leaf-drift 6s ease-in-out infinite;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.3));
}
@keyframes leaf-drift {
    0%   { opacity: 0; transform: translate(0, 0) rotate(0deg); }
    10%  { opacity: .7; }
    50%  { opacity: .5; transform: translate(50px, -25px) rotate(180deg); }
    100% { opacity: 0;  transform: translate(100px, 35px) rotate(360deg); }
}

/* Dust */
.dust-particle {
    position: absolute;
    width: 4px; height: 4px;
    background: rgba(180,160,120,.5);
    border-radius: 50%;
    pointer-events: none; z-index: 3;
    opacity: 0;
}
.map-building.upgrading .dust-particle {
    animation: dust-puff 2s ease-out infinite;
}
@keyframes dust-puff {
    0%   { opacity: 0; transform: translate(0, 0) scale(.5); }
    20%  { opacity: .5; }
    100% { opacity: 0;  transform: translate(var(--dx, 15px), var(--dy, -10px)) scale(1.2); }
}

/* ===================================================================
   RESOURCE CHANGE ANIMATION — IO-style zoom + glow
   =================================================================== */
@keyframes resource-change-up {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}
@keyframes resource-change-down {
    0% { transform: scale(1); }
    50% { transform: scale(0.7); }
    100% { transform: scale(1); }
}
.res-change-pop {
    position: absolute;
    top: -14px; right: 0;
    font-size: .7em; font-weight: 700;
    pointer-events: none;
    animation: res-pop-up .8s ease-out forwards;
    z-index: 20;
}
.res-change-pop.positive { color: #4c4; }
.res-change-pop.negative { color: #c44; }
@keyframes res-pop-up {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-20px); }
}

/* ===================================================================
   AUTH PAGES — Messages
   =================================================================== */
.errors, .success, .message { padding: 15px; margin-bottom: 20px; border-radius: 3px; }
.errors { background: #3a1a1a; color: #ff6b6b; border: 1px solid #5a2a2a; }
.success { background: #1a3a1a; color: #6bff6b; border: 1px solid #2a5a2a; }

.toast-stack {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1400;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(480px, calc(100vw - 32px));
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid rgba(255,238,182,.16);
    background: rgba(30,20,10,.95);
    box-shadow: 0 16px 38px rgba(0,0,0,.38);
    backdrop-filter: blur(10px);
    transform: translateY(-14px) scale(.98);
    opacity: 0;
    transition: opacity .18s ease, transform .18s ease;
    pointer-events: auto;
}
.toast.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.toast.is-closing {
    opacity: 0;
    transform: translateY(-10px) scale(.98);
}
.toast-success {
    border-color: rgba(110,214,132,.38);
    box-shadow: 0 16px 38px rgba(0,0,0,.38), inset 0 0 0 1px rgba(110,214,132,.08);
}
.toast-error {
    border-color: rgba(255,107,107,.36);
    box-shadow: 0 16px 38px rgba(0,0,0,.38), inset 0 0 0 1px rgba(255,107,107,.08);
}
.toast-info {
    border-color: rgba(255,215,128,.28);
}
.toast-body {
    flex: 1;
    min-width: 0;
}
.toast-title {
    display: block;
    margin-bottom: 4px;
    color: #FFEEB6;
    font-size: .86em;
    font-weight: 700;
}
.toast-message {
    color: #d8ceb0;
    font-size: .82em;
    line-height: 1.5;
}
.toast-close {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 999px;
    background: rgba(255,255,255,.08);
    color: #FFEEB6;
    cursor: pointer;
    font-size: 1.05em;
    transition: background .18s ease, transform .18s ease;
}
.toast-close:hover {
    background: rgba(255,255,255,.16);
    transform: scale(1.05);
}

/* ===================================================================
   RESPONSIVE
   =================================================================== */
@media (max-width: 768px) {
    .floating-panel { width: 260px; left: 10px; }
    .ui-top-right { padding: 4px 8px; gap: 0; }
    .ui-res { padding: 2px 6px; font-size: .78em; min-width: 50px; }
    .ui-nav-btn .nav-text { display: none; }
    .ui-nav-btn { padding: 8px 10px; }
    .ui-activity {
        top: 52px;
        width: calc(100vw - 20px);
    }
    .activity-widget-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .buildings-browser-shell {
        width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
    }
    .buildings-browser-body {
        padding: 12px;
    }
    .buildings-browser-resources {
        min-width: 100%;
        gap: 10px;
        padding: 10px 12px;
    }
    .buildings-browser-tabs {
        gap: 8px;
        padding: 0 10px;
    }
    .buildings-browser-tab {
        flex: 1;
        padding: 10px 12px;
        text-align: center;
    }
    .buildings-browser-row {
        grid-template-columns: minmax(120px, 1.3fr) 68px minmax(150px, 1fr) 70px 70px 70px 84px minmax(120px, .9fr);
    }
    .buildings-browser-cell {
        padding: 10px 8px;
        font-size: .76em;
    }
    .buildings-browser-name {
        gap: 8px;
    }
    .buildings-browser-name img {
        width: 38px;
        height: 38px;
    }
    .buildings-browser-upgrade-btn {
        min-width: 84px;
        padding: 8px 10px;
        font-size: .74em;
    }
    .buildings-browser-detail-btn {
        width: 30px;
        height: 30px;
    }
}
