/* ============================================================
   K-Life Game Styles
   Tách từ index.html — toàn bộ CSS của game
   ============================================================ */

:root {
    --bg-color: #090d16;
    --panel-bg: rgba(17, 24, 39, 0.7);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --color-gold: #f59e0b;
    --color-exp: #8b5cf6;
    --color-carrot: #f97316;
    --color-apple: #ef4444;
    --color-success: #10b981;
    --color-empty: #374151;
    --font-family: 'Outfit', sans-serif;
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

input, select, textarea, [contenteditable="true"] {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
}

body {
    padding-top: var(--klife-pad-top);
    padding-right: var(--klife-pad-right);
    padding-bottom: var(--klife-pad-bottom);
    padding-left: var(--klife-pad-left);
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    background-image:
        radial-gradient(at 10% 20%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(16, 185, 129, 0.12) 0px, transparent 50%);
    background-attachment: fixed;
}

/* Glassmorphism */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    box-shadow: var(--glass-shadow);
}

/* Language Switcher */
.lang-switcher {
    display: flex;
    gap: 3px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 3px;
}
.lang-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 4px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 7px;
    font-family: var(--font-family);
    transition: all 0.2s;
}
.lang-btn.active {
    background: var(--color-success);
    color: #fff;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

/* Toast */
#toast-container {
    position: fixed;
    top: calc(16px + var(--klife-pad-top));
    right: calc(16px + var(--klife-pad-right));
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: calc(100vw - 32px);
    pointer-events: none;
}
.toast {
    background: rgba(17, 24, 39, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 10px 16px;
    border-radius: 10px;
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(8px);
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 0.82rem;
    line-height: 1.35;
    max-width: 320px;
    word-break: break-word;
    pointer-events: auto;
}
@media (max-width: 480px) {
    #toast-container {
        top: calc(10px + var(--klife-pad-top));
        right: calc(10px + var(--klife-pad-right));
        left: calc(10px + var(--klife-pad-left));
        max-width: 100%;
        align-items: flex-end;
    }
    .toast { font-size: 0.75rem; padding: 8px 12px; border-radius: 8px; max-width: 100%; gap: 6px; }
}
.toast.show { transform: translateX(0); }

/* Login Screen */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100dvh - var(--klife-pad-top) - var(--klife-pad-bottom));
    padding: 20px;
    box-sizing: border-box;
}
.login-card { width: 100%; max-width: 420px; padding: 40px 30px; text-align: center; }
.logo-container { margin-bottom: 30px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.login-logo-icon { width: 72px; height: 72px; object-fit: contain; border-radius: 16px; box-shadow: 0 8px 24px rgba(0,0,0,0.35); }
.logo-title {
    font-size: 3rem; font-weight: 800;
    background: linear-gradient(135deg, #10b981, #8b5cf6);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    letter-spacing: -1px; margin-bottom: 5px;
}
.logo-subtitle { color: var(--text-secondary); font-size: 0.95rem; font-weight: 400; }
.input-group { margin-bottom: 20px; text-align: left; }
.input-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.input-field {
    width: 100%; background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 12px;
    padding: 14px 18px; color: #fff; font-family: var(--font-family);
    font-size: 1rem; transition: all 0.3s; user-select: text; -webkit-user-select: text;
}
.input-field:focus { outline: none; border-color: #10b981; background: rgba(255, 255, 255, 0.08); box-shadow: 0 0 15px rgba(16, 185, 129, 0.25); }
.btn-primary {
    width: 100%; background: linear-gradient(135deg, #10b981, #059669);
    color: #fff; border: none; border-radius: 12px; padding: 15px;
    font-size: 1rem; font-weight: 600; font-family: var(--font-family);
    cursor: pointer; transition: all 0.3s; box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4); }
.btn-primary:active { transform: translateY(1px); }

/* Password / Auth */
.password-container { position: relative; display: flex; align-items: center; width: 100%; }
.password-container .input-field { padding-right: 48px; }
.eye-toggle { position: absolute; right: 16px; cursor: pointer; color: var(--text-secondary); user-select: none; font-size: 1.2rem; transition: color 0.2s; }
.eye-toggle:hover { color: #fff; }
.back-link { display: inline-block; margin-top: 15px; color: var(--text-secondary); font-size: 0.9rem; text-decoration: none; cursor: pointer; transition: color 0.2s; }
.back-link:hover { color: #10b981; }

/* Game Layout */
#game-screen {
    display: none;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}
@media (min-width: 1400px) { #game-screen { max-width: 1400px; } #farm-3d-container, #farm-animals-container { height: 640px !important; } }
@media (min-width: 1600px) { #game-screen { max-width: 1600px; } #farm-3d-container, #farm-animals-container { height: 720px !important; } }

/* HUD */
.hud-bar { display: flex; align-items: center; justify-content: space-between; padding: 15px 30px; margin-bottom: 25px; flex-wrap: wrap; gap: 20px; }
.profile-section { display: flex; align-items: center; gap: 15px; }
.avatar { width: 48px; height: 48px; border-radius: 12px; background: linear-gradient(135deg, #8b5cf6, #3b82f6); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.3rem; color: white; box-shadow: 0 4px 10px rgba(139, 92, 246, 0.3); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.player-info { display: flex; flex-direction: column; }
.player-name { font-size: 1.1rem; font-weight: 600; }
.level-badge { background: rgba(139, 92, 246, 0.2); color: #c084fc; border: 1px solid rgba(139, 92, 246, 0.3); font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; align-self: flex-start; margin-top: 3px; }
.hud-stats { display: flex; align-items: center; gap: 15px; }
.stat-pill { display: flex; align-items: center; gap: 10px; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.08); padding: 8px 16px; border-radius: 12px; }
.stat-icon { width: 20px; height: 20px; }
.stat-val { font-weight: 600; font-size: 1.05rem; }
.exp-bar-container { width: 150px; height: 8px; background: rgba(255, 255, 255, 0.1); border-radius: 4px; overflow: hidden; margin-top: 5px; }
.exp-bar-fill { height: 100%; background: linear-gradient(90deg, #8b5cf6, #d8b4fe); width: 0%; transition: width 0.5s ease-out; box-shadow: 0 0 8px #8b5cf6; }

/* Visitor Banner */
#visitor-banner, .visitor-banner-wrap { display: none; flex-direction: column; gap: 8px; background: linear-gradient(90deg, rgba(239,68,68,0.2) 0%, rgba(139,92,246,0.2) 100%); border: 1px solid rgba(239,68,68,0.3); border-radius: 16px; padding: 12px 16px 14px; margin-bottom: 20px; box-shadow: 0 4px 20px rgba(239,68,68,0.15); animation: pulse-border 2s infinite; }
.visitor-banner-row { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; width: 100%; }
.visitor-visit-note { display: none; margin: 0; padding: 8px 10px; border-radius: 10px; background: rgba(15,23,42,0.35); border: 1px solid rgba(255,255,255,0.08); font-size: 0.74rem; line-height: 1.45; color: #e2e8f0; text-align: center; width: 100%; box-sizing: border-box; }
.visitor-visit-note.show { display: block; }
@keyframes pulse-border { 0% { border-color: rgba(239,68,68,0.3); } 50% { border-color: rgba(239,68,68,0.6); } 100% { border-color: rgba(239,68,68,0.3); } }
.visitor-text { font-weight: 600; color: #fca5a5; }
.btn-home { background: linear-gradient(135deg, #3b82f6, #1d4ed8); border: none; color: white; padding: 10px 20px; border-radius: 10px; font-family: var(--font-family); font-weight: 600; cursor: pointer; transition: all 0.3s; box-shadow: 0 4px 10px rgba(59,130,246,0.3); }
.btn-home:hover { transform: translateY(-1px); box-shadow: 0 6px 15px rgba(59,130,246,0.45); }

/* Grid Layout */
.game-grid { display: grid; grid-template-columns: 1fr 340px; gap: 25px; }
@media (max-width: 950px) { .game-grid { grid-template-columns: 1fr; gap: 15px; } }

/* Responsive HUD */
@media (max-width: 768px) {
    #game-screen { padding: 10px; }
    .farm-plots-container { padding: 15px; }
    .hud-bar { padding: 8px 12px !important; gap: 8px !important; }
    .hud-profile-row { gap: 8px !important; }
    .profile-section { gap: 8px !important; }
    .avatar { width: 36px !important; height: 36px !important; font-size: 1rem !important; }
    .player-name { font-size: 0.9rem !important; }
    .level-badge { font-size: 0.7rem !important; padding: 1px 6px !important; }
    .hud-stats { gap: 6px !important; display: grid !important; grid-template-columns: 1fr 1fr !important; width: 100% !important; }
    .stat-pill { grid-column: span 2 !important; justify-content: center !important; padding: 6px 10px !important; border-radius: 8px !important; gap: 6px !important; }
    .stat-pill svg { width: 16px !important; height: 16px !important; }
    .stat-val { font-size: 0.75rem !important; }
    .btn-shop, #hud-farm-panel-btn { width: 100% !important; min-width: unset !important; justify-content: center !important; padding: 6px 8px !important; font-size: 0.72rem !important; border-radius: 8px !important; }
    .btn-shop span span, .btn-shop span svg { font-size: 0.72rem !important; }
    .btn-checkin { padding: 6px 10px !important; font-size: 0.75rem !important; }
    .lang-switcher { gap: 2px !important; }
    .lang-btn { padding: 4px 6px !important; font-size: 0.7rem !important; }
    #farm-3d-container, #farm-animals-container { height: 380px !important; }
    .animal-grid-details { display: none !important; }
}

/* Responsive Shop */
@media (max-width: 600px) {
    .shop-modal { width: 95% !important; max-width: 380px !important; padding: 15px 10px !important; }
    .shop-item-row { flex-direction: column !important; align-items: stretch !important; gap: 10px !important; padding: 12px !important; }
    .shop-item-info { justify-content: flex-start !important; flex: 1 1 auto !important; width: auto !important; min-width: 0 !important; }
    .shop-item-actions { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 8px !important; width: 100% !important; }
    .qty-input-box { grid-column: span 2 !important; width: 100% !important; display: flex !important; justify-content: space-between !important; }
    .qty-btn { flex-grow: 1 !important; width: auto !important; min-width: 32px !important; }
    .qty-btn.plus-ten { min-width: 38px !important; }
    .qty-val-input { flex-grow: 2 !important; width: 60px !important; }
    .btn-action-shop { grid-column: span 1 !important; width: 100% !important; margin: 0 !important; height: 38px !important; line-height: 38px !important; padding: 0 !important; display: flex !important; align-items: center !important; justify-content: center !important; font-size: 0.88rem !important; border-radius: 8px !important; }
    .shop-item-actions button.btn-action-shop:only-of-type { grid-column: span 2 !important; }
}

/* Farm Grid Cards */
.farm-grid-card { position: relative; overflow: hidden; }
.farm-grid-card::before { content: ''; position: absolute; inset: 0; background: rgba(255,255,255,0); transition: background 0.25s ease; border-radius: inherit; }
.farm-grid-card:hover::before { background: rgba(255,255,255,0.05); }
.farm-grid-card:active::before { background: rgba(255,255,255,0.12); }
.farm-grid-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.farm-grid-card:active { transform: translateY(0); }

.farm-plots-container { padding: 30px; display: flex; flex-direction: column; justify-content: flex-start; max-width: 100%; box-sizing: border-box; }
.farm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 20px; margin-top: 15px; }

/* Plot Cards */
.plot-card { aspect-ratio: 1; border-radius: 16px; background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.06); display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; cursor: pointer; transition: all 0.3s cubic-bezier(0.4,0,0.2,1); overflow: hidden; }
.plot-card:hover { transform: translateY(-4px); background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.12); }
.plot-card.empty::after { content: '+'; font-size: 2.2rem; color: var(--text-secondary); font-weight: 300; transition: transform 0.3s; }
.plot-card.empty:hover::after { transform: scale(1.2); color: #fff; }
.crop-illustration { width: 64px; height: 64px; margin-bottom: 10px; transition: transform 0.3s ease; }
.plot-card:hover .crop-illustration { transform: scale(1.1); }
.plot-card.growing { border-color: rgba(16,185,129,0.15); }
.plot-card.growing::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 4px; background: rgba(16,185,129,0.2); }
.plot-progress-fill { position: absolute; top: 0; left: 0; height: 4px; background: var(--color-success); width: 0%; transition: width 1s linear; }
.plot-timer { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); background: rgba(0,0,0,0.3); padding: 3px 8px; border-radius: 8px; margin-top: 5px; }
.plot-card.ripe { border-color: var(--color-gold); box-shadow: 0 0 15px rgba(245,158,11,0.15); animation: float 3s ease-in-out infinite; }
.plot-card.ripe .crop-illustration { animation: bounce 1.5s infinite alternate; }
@keyframes float { 0% { transform: translateY(0px); } 50% { transform: translateY(-5px); } 100% { transform: translateY(0px); } }
@keyframes bounce { 0% { transform: translateY(0) scale(1); } 100% { transform: translateY(-8px) scale(1.05); } }
.harvest-glow { font-size: 0.75rem; text-transform: uppercase; font-weight: 700; color: var(--color-gold); letter-spacing: 0.5px; animation: pulse-text 1.5s infinite; }
@keyframes pulse-text { 0% { opacity: 0.6; } 50% { opacity: 1; } 100% { opacity: 0.6; } }

/* Seed Selector */
.seed-selector { position: absolute; width: 100%; height: 100%; top: 0; left: 0; background: rgba(11,15,25,0.95); display: flex; align-items: center; justify-content: space-around; padding: 10px; transform: scale(0); transition: transform 0.25s cubic-bezier(0.175,0.885,0.32,1.275); border-radius: 15px; z-index: 10; }
.seed-selector.show { transform: scale(1); }
.seed-option { display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; flex: 1; padding: 8px; border-radius: 10px; transition: background 0.2s; }
.seed-option:hover { background: rgba(255,255,255,0.05); }
.seed-option svg { width: 32px; height: 32px; }
.seed-count-tag { font-size: 0.72rem; color: var(--text-secondary); font-weight: 500; }

/* Steal Overlay */
.steal-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(239,68,68,0.2); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.3s; z-index: 5; }
.plot-card.ripe:hover .steal-overlay { opacity: 1; }
.steal-btn-circle { width: 48px; height: 48px; border-radius: 50%; background: var(--color-apple); border: 2px solid white; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 15px rgba(239,68,68,0.4); transform: scale(0.8); transition: transform 0.2s; }
.steal-btn-circle:hover { transform: scale(1.1); }
.steal-btn-circle svg { width: 24px; height: 24px; fill: white; }
.limit-tag { position: absolute; bottom: 8px; right: 8px; font-size: 0.7rem; background: rgba(0,0,0,0.4); padding: 1px 6px; border-radius: 4px; color: var(--text-secondary); display: flex; align-items: center; gap: 3px; }

/* Side Panels */
.side-panels { display: flex; flex-direction: column; gap: 25px; }
.panel { padding: 22px; }
.panel-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 15px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 10px; }

/* Shop Button */
.btn-shop { background: linear-gradient(135deg, #f59e0b, #d97706); border: none; color: #fff; padding: 6px 12px; border-radius: 8px; font-size: 0.8rem; font-weight: 600; cursor: pointer; font-family: var(--font-family); box-shadow: 0 3px 10px rgba(245,158,11,0.25); transition: all 0.3s; }
.btn-shop:hover { transform: translateY(-1px); box-shadow: 0 5px 12px rgba(245,158,11,0.35); }

/* Inventory */
.inv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.inv-card { background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.05); padding: 12px; border-radius: 12px; display: flex; align-items: center; gap: 10px; }
.inv-icon-box { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.inv-icon-box svg { width: 26px; height: 26px; }
.inv-meta { display: flex; flex-direction: column; }
.inv-name { font-size: 0.78rem; color: var(--text-secondary); font-weight: 500; text-transform: capitalize; }
.inv-qty { font-size: 1.05rem; font-weight: 700; }

/* Player List */
.player-list { display: flex; flex-direction: column; gap: 10px; max-height: 250px; overflow-y: auto; padding-right: 5px; }
.player-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: 12px; background: rgba(255,255,255,0.01); border: 1px solid rgba(255,255,255,0.04); cursor: pointer; transition: all 0.2s; }
.player-row:hover { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.08); transform: translateX(2px); }
.player-row-left { display: flex; align-items: center; gap: 10px; }
.player-lvl-indicator { width: 24px; height: 24px; border-radius: 6px; background: rgba(139,92,246,0.15); color: #a78bfa; border: 1px solid rgba(139,92,246,0.2); font-size: 0.7rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.player-username { font-size: 0.88rem; font-weight: 600; }
.player-gold-tag { font-size: 0.8rem; color: var(--color-gold); font-weight: 600; display: flex; align-items: center; gap: 4px; }

/* Logs */
.logs-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding-right: 4px; }
.log-empty { text-align: center; padding: 24px 12px; color: var(--text-secondary); font-size: 0.82rem; }
.log-entry { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.05); transition: background 0.2s; }
.log-entry:hover { background: rgba(255,255,255,0.04); }
.log-entry.log-entry-clickable { cursor: pointer; }
.log-entry.log-entry-clickable:hover { background: rgba(139,92,246,0.08); border-color: rgba(139,92,246,0.2); }
.log-avatar { width: 38px; height: 38px; min-width: 38px; border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center; background: rgba(139,92,246,0.15); border: 2px solid rgba(139,92,246,0.25); font-weight: 800; font-size: 0.95rem; color: #c4b5fd; }
.log-avatar img { width: 100%; height: 100%; object-fit: cover; }
.log-avatar-system { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.3); border-radius: 10px; }
.log-avatar-system img { object-fit: contain; padding: 4px; }
.log-avatar-fallback { background: linear-gradient(135deg, rgba(139,92,246,0.25), rgba(99,102,241,0.15)); }
.log-body { flex: 1; min-width: 0; }
.log-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.log-header-left { display: flex; align-items: center; gap: 6px; min-width: 0; flex-wrap: wrap; }
.log-actor { font-weight: 700; font-size: 0.82rem; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.log-badge { font-size: 0.62rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: rgba(255,255,255,0.06); color: var(--text-secondary); white-space: nowrap; letter-spacing: 0.3px; }
.log-time { font-size: 0.65rem; color: var(--text-secondary); white-space: nowrap; flex-shrink: 0; }
.log-message { font-size: 0.78rem; line-height: 1.4; color: var(--text-secondary); word-break: break-word; }
.log-entry.log-danger { border-left: 3px solid #ef4444; background: rgba(239,68,68,0.04); }
.log-entry.log-danger .log-badge { background: rgba(239,68,68,0.12); color: #fca5a5; }
.log-entry.log-success { border-left: 3px solid #10b981; background: rgba(16,185,129,0.04); }
.log-entry.log-success .log-badge { background: rgba(16,185,129,0.12); color: #6ee7b7; }
.log-entry.log-warning { border-left: 3px solid #f59e0b; background: rgba(245,158,11,0.04); }
.log-entry.log-warning .log-badge { background: rgba(245,158,11,0.12); color: #fcd34d; }
.log-entry.log-trade { border-left: 3px solid #10b981; background: rgba(16,185,129,0.04); }
.log-entry.log-trade .log-badge { background: rgba(16,185,129,0.12); color: #6ee7b7; }
.log-entry.log-visit { border-left: 3px solid #3b82f6; background: rgba(59,130,246,0.04); }
.log-entry.log-visit .log-badge { background: rgba(59,130,246,0.12); color: #93c5fd; }
.log-entry.log-info { border-left: 3px solid #8b5cf6; }
.log-entry.log-system .log-actor { color: var(--color-gold); }
.log-entry.log-system .log-avatar { border-radius: 10px; }

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--klife-modal-pad-top) var(--klife-modal-pad-right) var(--klife-modal-pad-bottom) var(--klife-modal-pad-left);
    overflow: hidden;
    overscroll-behavior: contain;
    touch-action: pan-y;
    box-sizing: border-box;
}
#player-profile-overlay.profile-overlay--maps { z-index: 10050 !important; }
.modal-overlay.show { display: flex; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
html.modal-scroll-locked,
body.modal-scroll-locked {
    overflow: hidden !important;
    overscroll-behavior: none;
    height: 100%;
}
body.modal-scroll-locked {
    position: fixed;
    width: 100%;
    left: 0;
    right: 0;
}
.shop-modal { width: 95%; max-width: 660px; padding: 24px 28px; border-radius: 24px; transform: scale(0.9); transition: transform 0.3s cubic-bezier(0.175,0.885,0.32,1.275); max-height: var(--klife-modal-fixed-h-lg, min(85dvh, 720px)); display: flex; flex-direction: column; overscroll-behavior: contain; }
.modal-overlay.show .shop-modal { transform: scale(1); }

/* Bag Slots */
.bag-slot { width: 100%; aspect-ratio: 1/1; max-width: 70px; max-height: 70px; background: rgba(0,0,0,0.25); border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; display: flex; align-items: center; justify-content: center; position: relative; cursor: pointer; transition: all 0.2s; }
.bag-slot:hover { background: rgba(255,255,255,0.05); border-color: #8b5cf6; box-shadow: 0 0 10px rgba(139,92,246,0.3); }
.bag-slot.active { border-color: #10b981; background: rgba(16,185,129,0.1); }
.bag-slot-icon { font-size: 2rem; }
.bag-slot-badge { position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,0.7); color: #fff; font-size: 0.7rem; font-weight: 800; padding: 1px 5px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.1); }

/* Modal header — title spans full width for true center; buttons overlay sides */
.shop-header {
    position: relative;
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding-bottom: 15px;
}
.shop-header .shop-title {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-self: center;
    justify-content: center;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 800;
    min-width: 0;
    max-width: calc(100% - 96px);
    margin: 0;
    pointer-events: none;
    z-index: 0;
}
.shop-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--color-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.modal-header-spacer {
    grid-column: 1;
    grid-row: 1;
    width: 40px;
    height: 36px;
    display: block;
    z-index: 1;
}
.modal-header-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    background: rgba(255,255,255,0.04);
    color: #c4b5fd;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s, box-shadow 0.2s;
    padding: 0;
    flex-shrink: 0;
    line-height: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.05);
    z-index: 1;
}
.modal-header-btn:hover { transform: scale(1.06); }
.modal-header-btn svg { display: block; }
.modal-header-back {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    background: linear-gradient(145deg, rgba(139,92,246,0.22), rgba(109,40,217,0.1));
    border-color: rgba(167,139,250,0.35);
    color: #e9d5ff;
}
.modal-header-back:hover {
    background: linear-gradient(145deg, rgba(167,139,250,0.32), rgba(139,92,246,0.18));
    border-color: rgba(196,181,253,0.5);
    color: #fff;
    box-shadow: 0 3px 10px rgba(139,92,246,0.25), inset 0 1px 0 rgba(255,255,255,0.08);
}
.modal-header-close,
.shop-close.modal-header-btn {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    font-size: inherit;
    background: linear-gradient(145deg, rgba(239,68,68,0.16), rgba(185,28,28,0.08));
    border-color: rgba(248,113,113,0.3);
    color: #fca5a5;
}
.modal-header-close:hover,
.shop-close.modal-header-btn:hover {
    background: linear-gradient(145deg, rgba(239,68,68,0.28), rgba(220,38,38,0.14));
    border-color: rgba(252,165,165,0.45);
    color: #fff;
    box-shadow: 0 3px 10px rgba(239,68,68,0.22), inset 0 1px 0 rgba(255,255,255,0.08);
}
.profile-popup-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
}
/* Legacy shop-close without modal-header-btn (profile popup etc.) */
.shop-close:not(.modal-header-btn) {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}
.shop-close:not(.modal-header-btn):hover { color: #fff; }
/* Panel launcher headers (farm / world grid) */
.panel-launcher-header {
    position: relative;
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    align-items: center;
    gap: 8px;
    padding: 18px 20px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}
.panel-launcher-header .panel-launcher-title-wrap {
    grid-column: 1 / -1;
    grid-row: 1;
    text-align: center;
    min-width: 0;
    max-width: calc(100% - 56px);
    justify-self: center;
    pointer-events: none;
    z-index: 0;
}
.panel-launcher-header .modal-header-close {
    grid-column: 3;
    grid-row: 1;
    align-self: start;
    justify-self: end;
}
.shop-header--center-only {
    grid-template-columns: 1fr;
    justify-items: center;
}
.shop-header--center-only .shop-title {
    grid-column: 1;
}
.btn-autofit { min-width: 86px; width: auto !important; height: 36px !important; padding: 0 12px; white-space: nowrap; overflow: hidden; display: inline-flex !important; align-items: center; justify-content: center; box-sizing: border-box; font-size: 0.75rem !important; font-weight: 700; text-align: center; }
.btn-autofit span { white-space: nowrap; display: inline-block; }
.shop-nav { display: flex; gap: 10px; margin-bottom: 20px; }
.shop-tab-btn { background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06); color: var(--text-secondary); padding: 10px 20px; border-radius: 10px; cursor: pointer; font-family: var(--font-family); font-weight: 600; flex: 1; transition: all 0.2s; }
.shop-tab-btn.active { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.3); color: var(--color-gold); }
.shop-content { display: flex; flex-direction: column; gap: 15px; overflow-y: auto; flex: 1; padding-right: 5px; overscroll-behavior: contain; }

/* Research panel — fixed frame height so tab switches do not resize the modal */
#farm-research-overlay {
    align-items: center;
    justify-content: center;
}
#farm-research-overlay .shop-modal.research-panel-modal {
    max-width: 720px;
    width: 95%;
    height: var(--klife-modal-fixed-h, min(85dvh, 680px));
    max-height: var(--klife-modal-fixed-h, min(85dvh, 680px));
    min-height: var(--klife-modal-fixed-h, min(85dvh, 680px));
    margin: auto;
    flex-shrink: 0;
    overflow: hidden;
    gap: 0;
}
#farm-research-overlay .research-panel-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 2px;
}
#farm-research-overlay #research-tree-viewport {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
}
#farm-research-overlay #research-detail-panel {
    flex: 0 0 auto;
    min-height: 152px;
}

/* Research skill tree — scalable tokens (desktop defaults) */
#farm-research-overlay {
    --research-viewport-pad-y: 20px;
    --research-viewport-pad-x: 14px;
    --research-track-gap: 22px;
    --research-flow-gap: 10px;
    --research-row-gap: 8px;
    --research-row-pad-y: 8px;
    --research-node-size: 60px;
    --research-node-border: 3px;
    --research-badge-size: 20px;
    --research-badge-font: 0.65rem;
    --research-label-size: 0.7rem;
    --research-label-max: 84px;
    --research-connector-w: 40px;
    --research-connector-h: 4px;
    --research-connector-mb: 14px;
    --research-title-size: 0.75rem;
}
#farm-research-overlay .research-tree-viewport {
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    padding: var(--research-viewport-pad-y) var(--research-viewport-pad-x);
    position: relative;
    user-select: none;
    -webkit-overflow-scrolling: touch;
}
#farm-research-overlay .research-tree-container {
    display: flex;
    flex-direction: column;
    gap: var(--research-track-gap);
    min-width: max-content;
    padding: 0 6px;
}
#farm-research-overlay .research-track {
    display: flex;
    flex-direction: column;
    gap: var(--research-flow-gap);
    width: 100%;
}
#farm-research-overlay .research-flow-title {
    font-size: var(--research-title-size);
    font-weight: 700;
    color: #a78bfa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
#farm-research-overlay .research-flow-row {
    display: flex;
    align-items: center;
    gap: var(--research-row-gap);
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: var(--research-row-pad-y) 0;
    -webkit-overflow-scrolling: touch;
}
#farm-research-overlay .research-node {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    z-index: 2;
    flex-shrink: 0;
}
#farm-research-overlay .research-skill-circle {
    width: var(--research-node-size);
    height: var(--research-node-size);
    border-radius: 50%;
    border: var(--research-node-border) solid rgba(139,92,246,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s;
}
#farm-research-overlay .research-skill-circle.is-selected {
    transform: scale(1.08);
}
#farm-research-overlay .research-skill-icon {
    width: 70%;
    height: 70%;
    object-fit: contain;
}
#farm-research-overlay .research-skill-icon.is-locked {
    filter: grayscale(1);
    opacity: 0.4;
}
#farm-research-overlay .research-node-badge {
    position: absolute;
    bottom: -3px;
    right: -3px;
    width: var(--research-badge-size);
    height: var(--research-badge-size);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--research-badge-font);
    font-weight: bold;
    border: 2px solid #1a1c23;
}
#farm-research-overlay .research-node-badge--done {
    background: #10b981;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
#farm-research-overlay .research-node-badge--progress {
    background: #fbbf24;
    color: #fff;
    animation: pulse-dot 1.5s infinite;
}
#farm-research-overlay .research-node-badge--locked {
    background: #374151;
    color: #9ca3af;
}
#farm-research-overlay .research-node-label {
    margin-top: 5px;
    font-size: var(--research-label-size);
    font-weight: 700;
    text-align: center;
    line-height: 1.1;
    max-width: var(--research-label-max);
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
#farm-research-overlay .research-connector {
    width: var(--research-connector-w);
    height: var(--research-connector-h);
    margin-bottom: var(--research-connector-mb);
    flex-shrink: 0;
    border-radius: 2px;
    z-index: 1;
}

/* Shop Items */
.shop-item-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-radius: 16px; background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.05); }
.shop-item-row.locked { position: relative; overflow: hidden; }
.shop-item-row.locked .shop-item-info, .shop-item-row.locked .shop-item-actions { filter: blur(2px) grayscale(0.9); opacity: 0.35; pointer-events: none; }
.shop-item-row-lock-overlay { position: absolute; inset: 0; background: rgba(15,23,42,0.45); display: flex; align-items: center; justify-content: center; z-index: 5; border-radius: 16px; }
.shop-item-row-lock-badge { background: linear-gradient(135deg, #ef4444, #b91c1c); color: #ffffff; padding: 5px 12px; border-radius: 10px; font-size: 0.72rem; font-weight: 800; box-shadow: 0 4px 12px rgba(239,68,68,0.4); border: 1px solid rgba(255,255,255,0.15); letter-spacing: 0.5px; text-transform: uppercase; }
.shop-item-info { display: flex; align-items: center; gap: 12px; flex: 0 0 170px; width: 170px; min-width: 170px; overflow: hidden; }
.shop-item-info > div:last-child { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.shop-item-name { font-weight: 600; text-transform: capitalize; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.92rem; width: 100%; }
.shop-item-price { font-size: 0.82rem; color: var(--color-gold); font-weight: 600; display: flex; align-items: center; gap: 4px; margin-top: 3px; white-space: nowrap; }
.shop-item-actions { display: flex; align-items: center; gap: 10px; }
.qty-input-box { display: flex; align-items: center; border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; background: rgba(0,0,0,0.2); overflow: hidden; }
.qty-btn { background: none; border: none; color: #fff; width: 32px; height: 32px; cursor: pointer; font-weight: bold; font-size: 1.1rem; transition: background 0.2s; }
.qty-btn:hover { background: rgba(255,255,255,0.05); }
.qty-btn.plus-ten { width: 40px; font-size: 0.82rem; border-left: 1px solid rgba(255,255,255,0.08); }
.qty-val { width: 40px; text-align: center; font-weight: 700; font-size: 0.95rem; }
.qty-val-input { width: 45px; height: 32px; background: transparent; border: none; outline: none; color: #fff; text-align: center; font-weight: 700; font-size: 0.95rem; -moz-appearance: textfield; font-family: var(--font-family); }
.qty-val-input::-webkit-outer-spin-button, .qty-val-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.btn-action-shop.sell-all { background: linear-gradient(135deg, #f43f5e, #be123c); margin-left: 5px; }
.btn-action-shop.sell-all:hover { box-shadow: 0 4px 12px rgba(244,63,94,0.3); transform: translateY(-1px); }
.btn-action-shop { border: none; color: #fff; padding: 8px 14px; border-radius: 8px; font-weight: 600; font-family: var(--font-family); cursor: pointer; font-size: 0.82rem; box-shadow: 0 4px 10px rgba(0,0,0,0.2); transition: all 0.3s; min-width: 105px; text-align: center; }
.btn-action-shop.buy { background: linear-gradient(135deg, #10b981, #059669); }
.btn-action-shop.buy:hover { box-shadow: 0 4px 12px rgba(16,185,129,0.3); transform: translateY(-1px); }
.btn-action-shop.sell { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.btn-action-shop.sell:hover { box-shadow: 0 4px 12px rgba(59,130,246,0.3); transform: translateY(-1px); }

/* Shop sell tab loading */
#shop-sell-tab.is-loading { position: relative; }
.shop-sell-list { position: relative; flex: 1; min-height: 0; }
.shop-sell-loading { position: relative; min-height: 100px; display: flex; align-items: center; justify-content: center; }
.shop-sell-loading-backdrop { position: absolute; inset: 0; background: rgba(9,13,22,0.55); backdrop-filter: blur(3px); border-radius: 12px; z-index: 1; }
.shop-sell-loading-card { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 20px 24px; background: rgba(15,23,42,0.85); border: 1px solid rgba(255,255,255,0.08); border-radius: 14px; box-shadow: 0 8px 24px rgba(0,0,0,0.35); }
.shop-sell-loading-spinner { width: 44px; height: 44px; border: 3px solid rgba(255,255,255,0.08); border-top-color: #10b981; border-radius: 50%; animation: spin 0.9s linear infinite; box-shadow: 0 0 14px rgba(16,185,129,0.15); }
.shop-sell-loading-text { font-size: 0.86rem; color: var(--text-primary); font-weight: 700; letter-spacing: 0.2px; }
.shop-sell-empty { text-align: center; padding: 36px 16px; color: var(--text-secondary); font-size: 0.82rem; line-height: 1.45; }
.shop-nav.is-loading .shop-tab-btn { pointer-events: none; opacity: 0.55; cursor: wait; }

/* Loader */
/* App boot splash */
.app-splash { position: fixed; inset: 0; z-index: 30000; display: none; align-items: center; justify-content: center; overflow: hidden; background: #0b1220; }
.app-splash.show { display: flex; }
.app-splash.hide { opacity: 0; transition: opacity 0.4s ease; }
.app-splash-bg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.app-splash-bg img { width: 100%; height: 100%; object-fit: cover; }
.app-splash-overlay { position: absolute; inset: 0; z-index: 1; background: linear-gradient(180deg, rgba(6,10,22,0.35) 0%, rgba(6,10,22,0.72) 55%, rgba(6,10,22,0.88) 100%); }
.app-splash-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    padding: calc(24px + var(--klife-pad-top)) 24px calc(24px + var(--klife-pad-bottom));
    animation: splash-fade-up 0.6s ease;
}
@keyframes splash-fade-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.app-splash-icon { width: clamp(80px, 22vw, 110px); height: clamp(80px, 22vw, 110px); object-fit: contain; border-radius: 22px; box-shadow: 0 12px 40px rgba(0,0,0,0.45), 0 0 30px rgba(56,189,248,0.15); animation: splash-icon-pulse 2.4s ease-in-out infinite; }
@keyframes splash-icon-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.app-splash-title { margin: 4px 0 0; font-size: clamp(1.8rem, 6vw, 2.4rem); font-weight: 800; letter-spacing: 0.5px; background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 35%, #f43f5e 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; text-shadow: none; }
.app-splash-subtitle { margin: 0; font-size: clamp(0.78rem, 2.8vw, 0.92rem); color: rgba(226,232,240,0.85); font-weight: 600; letter-spacing: 0.3px; }
.app-splash-spinner { width: 36px; height: 36px; margin-top: 8px; border: 3px solid rgba(255,255,255,0.1); border-top-color: #f59e0b; border-right-color: #38bdf8; border-radius: 50%; animation: spin 0.85s linear infinite; }
.app-splash-status { margin: 4px 0 0; font-size: 0.76rem; color: rgba(148,163,184,0.95); font-weight: 600; min-height: 1.2em; }
.app-splash-version {
    position: absolute;
    right: calc(12px + var(--klife-pad-right, 0px));
    bottom: calc(10px + var(--klife-pad-bottom, 0px));
    z-index: 3;
    margin: 0;
    font-size: 0.65rem;
    font-weight: 600;
    color: rgba(148, 163, 184, 0.55);
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
    user-select: none;
    pointer-events: none;
}
body.app-splash-active #login-screen { display: none !important; }

#loader { position: fixed; inset: 0; background: rgba(9,13,22,0.82); backdrop-filter: blur(6px); z-index: 20000; display: none; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.25s; }
#loader.show { display: flex; opacity: 1; }
.full-loader-card { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 28px 36px; background: rgba(15,23,42,0.88); border: 1px solid rgba(255,255,255,0.08); border-radius: 20px; box-shadow: 0 16px 40px rgba(0,0,0,0.45); }
.full-loader-text { margin: 0; font-size: 0.86rem; font-weight: 700; color: var(--text-secondary); letter-spacing: 0.2px; min-height: 1.2em; text-align: center; }
.spinner { width: 50px; height: 50px; border: 4px solid rgba(255,255,255,0.1); border-top-color: #10b981; border-radius: 50%; animation: spin 1s infinite linear; box-shadow: 0 0 15px rgba(16,185,129,0.15); }

/* Compact in-game action loader — small floating popup (not full-screen dim) */
.action-loader { position: fixed; inset: 0; z-index: 15000; display: none; align-items: flex-end; justify-content: center; padding: 0 16px calc(28px + env(safe-area-inset-bottom, 0px)); opacity: 0; transition: opacity 0.18s ease; pointer-events: none; }
.action-loader.show { display: flex; opacity: 1; pointer-events: none; }
.action-loader.show.action-loader--blocking { pointer-events: auto; }
.action-loader--blocking .action-loader-backdrop { position: absolute; inset: 0; display: block; background: rgba(3, 12, 18, 0.18); backdrop-filter: blur(1.5px); }
.action-loader--kfarm .action-loader-card { background: linear-gradient(150deg, rgba(18,56,58,0.98), rgba(10,36,44,0.98)); border-color: rgba(141,230,202,0.24); }
.action-loader--kfarm .action-loader-ring { border-top-color: #ffe292; border-right-color: #66d9ad; }
.action-loader-backdrop { display: none; }
.action-loader-card { position: relative; z-index: 1; display: flex; flex-direction: row; align-items: center; gap: 12px; padding: 12px 16px; min-width: 0; max-width: min(280px, 86vw); background: linear-gradient(160deg, rgba(20,28,48,0.97) 0%, rgba(12,18,32,0.96) 100%); border: 1px solid rgba(255,255,255,0.12); border-radius: 14px; box-shadow: 0 10px 28px rgba(0,0,0,0.45), 0 0 0 1px rgba(251,191,36,0.06); animation: action-loader-pop 0.26s cubic-bezier(0.34,1.4,0.64,1); pointer-events: auto; }
@keyframes action-loader-pop { 0% { transform: translateY(10px) scale(0.94); opacity: 0; } 100% { transform: translateY(0) scale(1); opacity: 1; } }
.action-loader-visual { position: relative; width: 36px; height: 36px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.action-loader-ring { position: absolute; inset: 0; border: 2.5px solid rgba(255,255,255,0.07); border-top-color: #fbbf24; border-right-color: #10b981; border-radius: 50%; animation: spin 0.85s linear infinite; }
.action-loader-icon { width: 20px; height: 20px; object-fit: contain; border-radius: 6px; animation: action-loader-bounce 1.2s ease-in-out infinite; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35)); }
@keyframes action-loader-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
.action-loader-text { margin: 0; font-size: 0.78rem; font-weight: 700; color: rgba(226,232,240,0.94); letter-spacing: 0.12px; text-align: left; line-height: 1.3; }

/* Factory panel-local loader (small popup inside modal) */
.factory-panel-loader { position: absolute; inset: 0; z-index: 12; display: none; align-items: center; justify-content: center; background: rgba(9,13,22,0.28); border-radius: inherit; pointer-events: none; }
.factory-panel-loader.show { display: flex; pointer-events: auto; }
.factory-panel-loader-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 20px; min-width: 132px; background: linear-gradient(160deg, rgba(20,28,48,0.96), rgba(12,18,32,0.94)); border: 1px solid rgba(255,255,255,0.1); border-radius: 14px; box-shadow: 0 10px 28px rgba(0,0,0,0.4); }
.factory-panel-loader-spinner { width: 26px; height: 26px; border: 2.5px solid rgba(255,255,255,0.08); border-top-color: #fbbf24; border-right-color: #10b981; border-radius: 50%; animation: spin 0.85s linear infinite; }
.factory-panel-loader-text { font-size: 0.74rem; font-weight: 700; color: rgba(226,232,240,0.92); text-align: center; }

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

/* Scrollbars — base app chrome (Firefox + WebKit) */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(167, 139, 250, 0.4) transparent;
}
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; border-radius: 999px; }
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(167, 139, 250, 0.45), rgba(100, 116, 139, 0.35));
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
    min-height: 28px;
}
::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(196, 181, 253, 0.7), rgba(148, 163, 184, 0.45));
    background-clip: padding-box;
}
::-webkit-scrollbar-corner { background: transparent; }

/* Farm 3D Container */
#farm-3d-container, #farm-animals-container { width: 100%; height: 520px; border-radius: 20px; position: relative; overflow: hidden; background: #0c101a; border: 1px solid rgba(255,255,255,0.08); box-shadow: inset 0 0 30px rgba(0,0,0,0.6); touch-action: none; -webkit-user-select: none; user-select: none; }
/* Canvas under décor chrome (palette / place bar / ghost HUD) — engine appends canvas last */
#farm-3d-container canvas, #farm-animals-container canvas {
    touch-action: none;
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
    z-index: 1;
}


/* Plot Floating UI — base size; JS scales via transform from plot on-screen px (zoom-aware) */
.plot-time-float {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -50%) scale(1);
    transform-origin: center center;
    background: rgba(15,23,42,0.88);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fbbf24;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.15;
    padding: 2px 6px;
    border-radius: 7px;
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    white-space: nowrap;
    z-index: 50;
}
.plot-status-float {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -50%) scale(1);
    transform-origin: center center;
    display: flex;
    gap: 3px;
    pointer-events: none;
    z-index: 52;
}
.plot-status-icon {
    width: 18px;
    height: 18px;
    background: rgba(15,23,42,0.88);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    animation: status-bounce 0.8s infinite alternate ease-in-out;
}
.plot-status-icon svg,
.plot-status-icon img { width: 12px !important; height: 12px !important; }
@keyframes status-bounce { 0% { transform: translateY(0); } 100% { transform: translateY(-3px); } }

/* Equipment Bar */
#equipment-bar { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 15px; padding: 8px; background: rgba(17,24,39,0.4); border: 1px solid rgba(255,255,255,0.1); border-radius: 12px; backdrop-filter: blur(8px); width: 100%; max-width: 420px; box-sizing: border-box; flex-wrap: nowrap; }
.equipment-slot { flex: 1; min-width: 0; max-width: 48px; aspect-ratio: 1/1; height: auto; border-radius: 10px; border: 2px solid transparent; background: rgba(255,255,255,0.05); display: flex; align-items: center; justify-content: center; font-size: 1.8rem; cursor: pointer; transition: all 0.2s cubic-bezier(0.4,0,0.2,1); user-select: none; }
@media (max-width: 480px) { .equipment-slot { font-size: 1.3rem; } }
.equipment-slot:hover { transform: scale(1.1); background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.3); }
.equipment-slot.active { background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(37,99,235,0.2)); border-color: #3b82f6; box-shadow: 0 0 10px rgba(59,130,246,0.4); transform: scale(1.1); }

/* Floating Menu */
/* Seed/plot floating menu — desktop a bit wider so hover motion doesn't force X-scroll */
.floating-menu {
    position: fixed;
    background: rgba(11,15,25,0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    z-index: 10005;
    display: none;
    flex-direction: column;
    gap: 6px;
    width: 280px;
    max-width: min(280px, calc(100vw - 16px));
    max-height: 420px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    box-sizing: border-box;
}
.floating-menu-title { font-size: 0.8rem; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid rgba(255,255,255,0.08); padding-bottom: 4px; }
.floating-seed-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s ease, border-color 0.15s ease;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}
.floating-seed-item:hover:not(.locked) { background: rgba(255,255,255,0.08); }
.floating-seed-item.locked { opacity: 0.5; cursor: not-allowed; }
.floating-seed-info { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.floating-seed-icon { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.floating-seed-name { font-size: 0.85rem; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.floating-seed-count { font-size: 0.75rem; font-weight: 700; color: var(--color-success); flex-shrink: 0; }
.floating-seed-count.zero { color: var(--text-secondary); }
.floating-seed-req { font-size: 0.7rem; color: #ef4444; font-weight: 600; flex-shrink: 0; white-space: nowrap; }
.floating-menu--mobile {
    left: 50% !important;
    top: 50% !important;
    bottom: auto !important;
    /* transform owned by game-polish (must stay free for enter animation) */
    /* Compact width; taller max-height so seed list shows more items */
    width: min(84vw, 300px) !important;
    max-width: min(84vw, 300px) !important;
    max-height: min(82dvh, 560px) !important;
    padding: 8px 8px 10px !important;
    gap: 4px !important;
    border-radius: 14px !important;
    z-index: 10006 !important;
    box-shadow: 0 16px 40px rgba(0,0,0,0.55);
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}
.floating-menu--mobile .btn-primary {
    padding: 7px 10px !important;
    font-size: 0.78rem !important;
    min-height: 34px !important;
}
.floating-menu--mobile .floating-menu-title {
    font-size: 0.68rem !important;
    margin-bottom: 2px !important;
    padding-bottom: 3px !important;
}
.floating-seed-selector-inner { display: flex; flex-direction: column; gap: 3px; min-height: 0; max-width: 100%; overflow-x: hidden; }
.floating-seed-plot-header { padding: 4px 2px 6px; border-bottom: 1px solid rgba(255,255,255,0.06); text-align: left; flex-shrink: 0; }
.floating-seed-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 0;
    flex: 1;
    max-width: 100%;
    padding-right: 2px;
    overscroll-behavior: contain;
}

/* Chat */
.chat-box {
    display: flex;
    flex-direction: column;
    gap: 0;
    height: 360px;
    min-height: 360px;
    padding: 8px;
    border-radius: 14px;
    background:
        radial-gradient(ellipse 120% 80% at 0% 0%, rgba(139, 92, 246, 0.1), transparent 55%),
        radial-gradient(ellipse 90% 70% at 100% 100%, rgba(6, 182, 212, 0.08), transparent 50%),
        linear-gradient(165deg, rgba(12, 18, 32, 0.72), rgba(8, 12, 22, 0.55));
    border: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.chat-messages {
    flex: 1;
    min-height: 270px;
    overflow-y: auto;
    padding: 2px 4px 2px 2px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.chat-messages .chat-msg { padding: 0; }
.chat-messages .chat-msg-card {
    --chat-avatar-size: 28px;
    --chat-avatar-gap: 8px;
    --chat-card-accent: #8b5cf6;
    --chat-card-border: rgba(139, 92, 246, 0.18);
    --chat-card-divider: rgba(139, 92, 246, 0.12);
    display: grid;
    grid-template-columns: var(--chat-avatar-size) minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    column-gap: var(--chat-avatar-gap);
    row-gap: 2px;
    align-items: start;
    width: 100%;
    padding: 9px 11px 10px;
    border-radius: 12px;
    border: 1px solid var(--chat-card-border);
    background: linear-gradient(145deg, rgba(139, 92, 246, 0.11), rgba(30, 27, 75, 0.22));
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.chat-messages .chat-msg-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 0 4px 4px 0;
    background: linear-gradient(180deg, var(--chat-card-accent), transparent);
    opacity: 0.85;
}
.chat-messages .chat-msg-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 88% 12%, rgba(255, 255, 255, 0.07), transparent 42%);
    pointer-events: none;
}
.chat-messages .chat-msg:nth-child(even) .chat-msg-card {
    --chat-card-accent: #06b6d4;
    --chat-card-border: rgba(6, 182, 212, 0.2);
    --chat-card-divider: rgba(6, 182, 212, 0.14);
    background: linear-gradient(145deg, rgba(6, 182, 212, 0.1), rgba(15, 40, 55, 0.24));
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.chat-messages .chat-msg.mine .chat-msg-card {
    --chat-card-accent: #10b981;
    --chat-card-border: rgba(16, 185, 129, 0.24);
    --chat-card-divider: rgba(16, 185, 129, 0.16);
    background: linear-gradient(145deg, rgba(16, 185, 129, 0.12), rgba(6, 78, 59, 0.2));
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.chat-messages .chat-msg-card:hover {
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.chat-messages .chat-msg-avatar { grid-column: 1; grid-row: 1 / 3; line-height: 0; align-self: start; position: relative; z-index: 1; }
.chat-messages .chat-msg-name { grid-column: 2; grid-row: 1; min-width: 0; line-height: 1.2; position: relative; z-index: 1; }
.chat-messages .chat-msg-level { grid-column: 2; grid-row: 2; font-size: 0.65rem; font-weight: 600; color: #34d399; line-height: 1.2; min-width: 0; position: relative; z-index: 1; }
.chat-messages .chat-msg-level--empty { display: none; }
.chat-messages .chat-time-wrap {
    grid-column: 3;
    grid-row: 1 / 3;
    justify-self: end;
    align-self: start;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    text-align: right;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    z-index: 1;
}
.chat-messages .chat-time-hour {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.62rem;
    white-space: nowrap;
    line-height: 1.2;
}
.chat-messages .chat-time-date {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.56rem;
    white-space: nowrap;
    line-height: 1.2;
    opacity: 0.85;
}
.chat-messages .chat-msg-body {
    grid-column: 1 / -1;
    grid-row: 3;
    width: 100%;
    margin-top: 4px;
    padding-top: 7px;
    border-top: 1px solid var(--chat-card-divider);
    position: relative;
    z-index: 1;
}
.chat-messages .chat-sender-clickable,
.chat-messages .chat-sender-name {
    font-weight: 700;
    color: #c4b5fd;
    font-size: 0.74rem;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-messages .chat-sender-clickable { cursor: pointer; transition: color 0.2s, text-decoration 0.2s; }
.chat-messages .chat-sender-clickable:hover { color: #e9d5ff; text-decoration: underline; }
.chat-messages .chat-msg-card--mine .chat-sender-clickable,
.chat-messages .chat-msg.mine .chat-sender-clickable { color: #6ee7b7; }
.chat-messages .chat-msg-text {
    color: var(--text-primary);
    font-size: 0.78rem;
    line-height: 1.5;
    word-break: break-word;
    width: 100%;
}
.chat-messages .chat-avatar-chip { font-size: 0.68rem !important; border-width: 1.5px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); }
.chat-messages .chat-avatar-chip span { font-size: 0.68rem; }
.chat-input-row { display: flex; gap: 6px; margin-top: 10px; }
.chat-input { flex: 1; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-radius: 8px; padding: 6px 10px; color: #fff; font-family: var(--font-family); font-size: 0.8rem; outline: none; transition: border-color 0.2s; }
.chat-input:focus { border-color: #8b5cf6; }
.chat-send-btn { background: linear-gradient(135deg, #8b5cf6, #6d28d9); border: none; color: white; border-radius: 8px; padding: 6px 12px; font-weight: 700; font-size: 0.78rem; cursor: pointer; font-family: var(--font-family); transition: all 0.2s; white-space: nowrap; }
.chat-send-btn:hover { opacity: 0.9; }


.chat-bubble-me { background: linear-gradient(135deg, #a78bfa, #7c3aed); color: white; padding: 8px 12px; border-radius: 12px 12px 2px 12px; font-size: 0.8rem; max-width: 80%; word-break: break-word; box-shadow: 0 2px 6px rgba(124,58,237,0.15); }
.chat-bubble-them { background: rgba(255,255,255,0.08); color: var(--text-primary); padding: 8px 12px; border-radius: 12px 12px 12px 2px; font-size: 0.8rem; max-width: 80%; word-break: break-word; border: 1px solid rgba(255,255,255,0.05); }
.friend-chat-typing { font-size: 0.72rem; color: #a78bfa; padding: 2px 4px 0; min-height: 1.1rem; font-style: italic; opacity: 0.9; }
.friend-chat-typing-dots { display: inline-block; animation: friend-chat-blink 1s ease-in-out infinite; }
@keyframes friend-chat-blink { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

/* World Maps */
#world-maps-perm-overlay { z-index: 10011; }
.world-maps-perm-popup { max-width: 420px; width: 92vw; padding: 24px 22px; border-radius: 18px; display: flex; flex-direction: column; gap: 0; text-align: center; }
.world-maps-perm-icon { font-size: 2.4rem; margin-bottom: 8px; line-height: 1; }
.world-maps-perm-title { font-weight: 800; font-size: 1.1rem; color: var(--text-primary); margin: 0 0 10px; background: linear-gradient(135deg, #ec4899, #8b5cf6); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.world-maps-perm-intro { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.55; margin: 0 0 14px; text-align: left; }
.world-maps-perm-bullets { text-align: left; margin: 0 0 14px; padding-left: 1.2rem; font-size: 0.84rem; color: var(--text-primary); line-height: 1.5; }
.world-maps-perm-bullets li { margin-bottom: 6px; }
.world-maps-perm-bullets li::marker { color: #ec4899; }
.world-maps-perm-privacy { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.5; margin: 0 0 18px; text-align: left; padding: 10px 12px; border-radius: 10px; background: rgba(236,72,153,0.08); border: 1px solid rgba(236,72,153,0.15); }
.world-maps-perm-guide { text-align: left; margin: 0 0 18px; padding-left: 1.2rem; font-size: 0.84rem; color: var(--text-primary); line-height: 1.55; }
.world-maps-perm-guide li { margin-bottom: 8px; }
.world-maps-perm-guide li::marker { color: #8b5cf6; font-weight: 700; }
.world-maps-perm-actions { display: flex; gap: 10px; }
.world-maps-perm-btn { flex: 1; padding: 12px 10px !important; font-size: 0.88rem !important; }
#world-maps-overlay { padding: 0; align-items: stretch; justify-content: stretch; }
#world-maps-overlay.show { display: flex; }
.world-maps-panel {
    display: flex; flex-direction: column; width: 100%; height: 100%; max-width: 100%; background: #0f172a;
    padding-top: var(--klife-inset-top);
    padding-left: var(--klife-inset-left);
    padding-right: var(--klife-inset-right);
    padding-bottom: var(--klife-inset-bottom);
    box-sizing: border-box;
}
.world-maps-header {
    position: relative;
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(236,72,153,0.25), rgba(190,24,93,0.15));
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.world-maps-header .world-maps-title {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-self: center;
    text-align: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 800;
    max-width: calc(100% - 96px);
    pointer-events: none;
    z-index: 0;
}
.world-maps-back-btn { grid-column: 1; grid-row: 1; justify-self: start; }
.world-maps-header .modal-header-close { grid-column: 3; grid-row: 1; justify-self: end; }
.world-maps-title { font-weight: 800; font-size: 0.95rem; color: var(--text-primary); }
.world-maps-toolbar { display: flex; flex-direction: column; padding: 8px calc(14px + var(--klife-inset-right)) 6px calc(14px + var(--klife-inset-left)); background: rgba(0,0,0,0.25); border-bottom: 1px solid rgba(255,255,255,0.05); flex-shrink: 0; gap: 6px; }
.world-maps-toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; width: 100%; }
.maps-icon-btn { width: 40px; height: 40px; padding: 0; border: none; background: transparent; cursor: pointer; border-radius: 10px; display: flex; align-items: center; justify-content: center; transition: transform 0.15s, background 0.15s; flex-shrink: 0; }
.maps-icon-btn:hover { background: rgba(236,72,153,0.12); transform: scale(1.04); }
.maps-icon-btn:active { transform: scale(0.96); }
.maps-icon-btn img { width: 36px; height: 36px; display: block; pointer-events: none; }
.maps-icon-btn.is-active { box-shadow: 0 0 0 2px rgba(52,211,153,0.45); border-radius: 10px; }
.maps-labeled-btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 6px; border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; background: rgba(255,255,255,0.04); cursor: pointer; font-family: var(--font-family); transition: transform 0.15s, background 0.15s, border-color 0.15s; flex-shrink: 0; min-width: 0; }
.maps-labeled-btn:hover { background: rgba(236,72,153,0.1); border-color: rgba(236,72,153,0.25); transform: scale(1.02); }
.maps-labeled-btn:active { transform: scale(0.97); }
.maps-labeled-btn img { width: 32px; height: 32px; display: block; pointer-events: none; flex-shrink: 0; }
.maps-labeled-btn-text { font-size: 0.72rem; font-weight: 700; color: #f9a8d4; white-space: nowrap; line-height: 1.1; }
.maps-labeled-btn.is-active { border-color: rgba(52,211,153,0.45); background: rgba(16,185,129,0.1); }
.maps-labeled-btn.is-active .maps-labeled-btn-text { color: #6ee7b7; }
.maps-overlay-status { position: absolute; top: 10px; right: 10px; z-index: 800; display: none; align-items: center; justify-content: center; gap: 6px; padding: 6px 8px; border-radius: 12px; background: rgba(15,23,42,0.72); border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 4px 14px rgba(0,0,0,0.35); pointer-events: none; }
.maps-overlay-status--loading, .maps-overlay-status--success { display: flex; }
.maps-overlay-status-loading, .maps-overlay-status-success { display: none; width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; }
.maps-overlay-status--loading .maps-overlay-status-loading {
    display: block; border: 2.5px solid rgba(236,72,153,0.2); border-top-color: #ec4899;
    animation: spin 0.85s linear infinite;
}
.maps-overlay-status--success .maps-overlay-status-success {
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 0 10px rgba(16,185,129,0.45);
}
.maps-overlay-status--success .maps-overlay-status-success::after {
    content: ''; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(45deg) translate(-1px, -1px);
}
.maps-tip-dismiss-lbl { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--text-secondary); margin: 0 0 14px; text-align: left; cursor: pointer; }
.maps-tip-dismiss-lbl input { accent-color: #ec4899; }
.world-maps-save-icon-img { display: block; margin: 0 auto 8px; }
#world-maps-visible-overlay { z-index: 10012; display: none; }
#world-maps-visible-overlay.show { display: flex; }
#world-maps-save-overlay { z-index: 10012; display: none; }
#world-maps-save-overlay.show { display: flex; }
.world-maps-save-popup { max-width: 380px; width: 92vw; padding: 22px 20px; border-radius: 18px; text-align: center; }
.world-maps-save-icon { font-size: 2rem; margin-bottom: 6px; }
.world-maps-save-title { font-weight: 800; font-size: 1.05rem; margin: 0 0 10px; color: var(--text-primary); }
.world-maps-save-intro { font-size: 0.86rem; color: var(--text-secondary); line-height: 1.55; margin: 0 0 18px; text-align: left; white-space: pre-line; }
.world-maps-save-actions { display: flex; gap: 10px; }

.world-maps-cluster-letter { display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.95rem; color: #fff; background: linear-gradient(135deg, rgba(139,92,246,0.55), rgba(99,102,241,0.35)); border: 1px solid rgba(255,255,255,0.15); }
.world-maps-container { position: relative; flex: 1; min-height: 0; width: 100%; z-index: 1; }
.klife-map-divicon { background: transparent !important; border: none !important; }
.world-maps-cluster-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: none; align-items: center; justify-content: center; z-index: 9999; padding: var(--klife-modal-pad-top) var(--klife-modal-pad-right) var(--klife-modal-pad-bottom) var(--klife-modal-pad-left); box-sizing: border-box; }
.world-maps-cluster-overlay.show { display: flex; }
.world-maps-cluster-popup { position: relative; background: linear-gradient(160deg, rgba(30,41,59,0.98), rgba(15,23,42,0.98)); border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; padding: 16px 14px 14px; width: min(380px, 94vw); max-height: 78vh; display: flex; flex-direction: column; gap: 10px; }
.world-maps-cluster-popup-title { font-weight: 800; font-size: 0.95rem; color: var(--text-primary); text-align: center; padding-right: 28px; }
.world-maps-cluster-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: min(58vh, 420px); padding-right: 2px; }
.world-maps-cluster-row { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 14px; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.07); cursor: pointer; text-align: left; width: 100%; transition: background 0.2s, border-color 0.2s; font-family: var(--font-family); }
.world-maps-cluster-row:hover, .world-maps-cluster-row:active { background: rgba(236,72,153,0.14); border-color: rgba(236,72,153,0.25); }
.world-maps-cluster-avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 2px solid rgba(255,255,255,0.12); }
.world-maps-cluster-info { flex: 1; min-width: 0; }
.world-maps-cluster-name { font-weight: 700; font-size: 0.88rem; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.world-maps-cluster-meta { font-size: 0.74rem; color: var(--text-secondary); margin-top: 2px; }
.world-maps-cluster-level { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; color: #a78bfa; }
.klife-map-cluster-icon { width: 52px; height: 52px; position: relative; cursor: pointer; filter: drop-shadow(0 3px 10px rgba(109,40,217,0.5)); }
.klife-map-cluster-icon img { width: 52px; height: 52px; display: block; pointer-events: none; }
.klife-map-cluster-badge { position: absolute; right: -2px; bottom: 0; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: linear-gradient(135deg, #f43f5e, #ec4899); border: 2px solid #1e1b4b; font-size: 0.68rem; font-weight: 800; color: #fff; display: flex; align-items: center; justify-content: center; z-index: 2; }
.world-maps-cluster-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
}
.quests-modal-panel { position: relative; }
.quests-panel-loader { position: absolute; inset: 0; z-index: 12; display: none; align-items: center; justify-content: center; background: rgba(9,13,22,0.22); border-radius: inherit; pointer-events: none; }
.quests-panel-loader.show { display: flex; pointer-events: auto; }
.quests-panel-loader-card { display: flex; flex-direction: row; align-items: center; gap: 10px; padding: 12px 16px; min-width: 0; background: linear-gradient(160deg, rgba(20,28,48,0.97), rgba(12,18,32,0.95)); border: 1px solid rgba(255,255,255,0.12); border-radius: 14px; box-shadow: 0 10px 28px rgba(0,0,0,0.4); }
.quests-panel-loader-spinner { width: 24px; height: 24px; flex-shrink: 0; border: 2.5px solid rgba(255,255,255,0.08); border-top-color: #a78bfa; border-radius: 50%; animation: spin 0.85s linear infinite; }
.quests-panel-loader-text { font-size: 0.74rem; font-weight: 700; color: rgba(226,232,240,0.92); text-align: left; }
@media (max-width: 600px) {
    .world-maps-header { padding: 8px calc(10px + var(--klife-inset-right)) 8px calc(10px + var(--klife-inset-left)); }
    .world-maps-toolbar { padding: 8px calc(14px + var(--klife-inset-right)) 8px calc(14px + var(--klife-inset-left)); gap: 8px; }
    .world-maps-toolbar-actions { align-items: center; justify-content: flex-start; }
    .maps-labeled-btn { flex: 1 1 auto; min-width: 0; justify-content: flex-start; padding: 6px 10px 6px 6px; }
    .maps-labeled-btn-text { font-size: 0.68rem; white-space: normal; text-align: left; }
    .maps-icon-btn { width: 38px; height: 38px; flex-shrink: 0; margin-left: auto; }
    .maps-icon-btn img { width: 34px; height: 34px; }
    .maps-overlay-status { top: 8px; right: calc(8px + var(--klife-inset-right)); }
    .world-maps-cluster-popup { width: min(94vw, 360px); padding: 14px 12px 12px; }
    .world-maps-cluster-row { padding: 10px; gap: 10px; }
    .world-maps-cluster-avatar { width: 38px; height: 38px; }
}

/* Leaderboard */
.leaderboard-list { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; padding-right: 4px; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.04); font-size: 0.8rem; cursor: pointer; transition: all 0.2s; }
.lb-row:hover { background: rgba(255,255,255,0.05); }
.lb-rank {
    width: 40px;
    min-width: 40px;
    min-height: 40px;
    font-weight: 800;
    font-size: 0.85rem;
    text-align: center;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}
.lb-rank-ico {
    width: 36px;
    height: 36px;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
    pointer-events: none;
}
.lb-row--podium .lb-rank-ico {
    width: 38px;
    height: 38px;
}
.lb-rank.gold { color: #f59e0b; }
.lb-rank.silver { color: #9ca3af; }
.lb-rank.bronze { color: #b45309; }
.lb-name { flex: 1; font-weight: 600; }
.lb-stat { color: var(--color-gold); font-weight: 700; font-size: 0.78rem; }
.lb-sort-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.lb-sort-btn { flex: 1; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06); color: var(--text-secondary); padding: 4px 0; border-radius: 6px; font-size: 0.7rem; font-weight: 700; cursor: pointer; font-family: var(--font-family); transition: all 0.2s; }
.lb-sort-btn.active { background: rgba(139,92,246,0.15); border-color: rgba(139,92,246,0.3); color: #a78bfa; }

/* Check-in */
.btn-checkin { background: linear-gradient(135deg, #f43f5e, #be123c); border: none; color: white; padding: 6px 12px; border-radius: 8px; font-size: 0.8rem; font-weight: 600; cursor: pointer; font-family: var(--font-family); box-shadow: 0 3px 10px rgba(244,63,94,0.3); transition: all 0.3s; display: flex; align-items: center; gap: 5px; position: relative; }
.btn-checkin:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(244,63,94,0.4); }
.btn-checkin.done { background: linear-gradient(135deg, #374151, #1f2937); box-shadow: none; cursor: default; }
.btn-checkin.done:hover { transform: none; }
.checkin-pulse { position: absolute; top: -4px; right: -4px; width: 10px; height: 10px; border-radius: 50%; background: #f59e0b; animation: pulse-dot 2s infinite; }
@keyframes pulse-dot { 0% { box-shadow: 0 0 0 0 rgba(245,158,11,0.6); } 70% { box-shadow: 0 0 0 6px rgba(245,158,11,0); } 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0); } }
.checkin-modal { max-width: min(400px, 96vw); width: 100%; text-align: center; padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 8px; min-height: 0; max-height: none; }
.checkin-modal-header {
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    align-items: center;
    flex-shrink: 0;
    margin: 0 0 2px;
}
.checkin-modal-header .checkin-modal-title {
    margin: 0;
    justify-self: center;
}
.checkin-modal-close {
    justify-self: end;
}
.checkin-modal-body { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; position: relative; gap: 8px; }
.checkin-state-loading { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 180px; max-height: 220px; }
.checkin-state-loading[hidden], .checkin-state-content[hidden] { display: none !important; }
.checkin-state-content { display: flex; flex-direction: column; gap: 10px; animation: checkin-fade-in 0.35s ease; }
@keyframes checkin-fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.checkin-loader-ring { width: 42px; height: 42px; border: 3px solid rgba(255,255,255,0.08); border-top-color: #f59e0b; border-right-color: #a78bfa; border-radius: 50%; animation: checkin-spin 0.85s linear infinite; }
@keyframes checkin-spin { to { transform: rotate(360deg); } }
.checkin-loader-text { font-size: 0.78rem; color: var(--text-secondary); font-weight: 600; }
.checkin-modal-title { font-size: clamp(1.05rem, 4vw, 1.35rem); font-weight: 800; margin: 0; background: linear-gradient(135deg,#f59e0b,#f43f5e); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.checkin-modal-subtitle { color: var(--text-secondary); font-size: clamp(0.72rem, 2.8vw, 0.85rem); margin: 0; line-height: 1.35; }
.checkin-month-bar { display: flex; justify-content: space-between; align-items: center; font-size: clamp(0.72rem, 2.6vw, 0.82rem); font-weight: 700; color: var(--color-gold); padding: 6px 4px; }
.checkin-stats { color: var(--text-secondary); font-weight: 600; font-size: clamp(0.68rem, 2.4vw, 0.78rem); }
.checkin-calendar-wrap { width: 100%; }
.checkin-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-bottom: 4px; }
.checkin-weekdays span { font-size: clamp(0.58rem, 2.2vw, 0.68rem); color: var(--text-secondary); font-weight: 700; text-align: center; }
.checkin-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: clamp(3px, 1vw, 5px); }
.checkin-day { aspect-ratio: 1; width: 100%; min-height: 0; max-height: 44px; border-radius: 8px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06); display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; font-size: clamp(0.62rem, 2.4vw, 0.72rem); font-weight: 700; color: var(--text-secondary); box-sizing: border-box; }
.checkin-day-empty { background: transparent; border-color: transparent; pointer-events: none; }
.checkin-day.checked { background: rgba(16,185,129,0.15); border-color: rgba(16,185,129,0.35); color: #6ee7b7; }
.checkin-day.today { box-shadow: 0 0 0 2px rgba(245,158,11,0.55); color: var(--color-gold); }
.checkin-milestone-section { background: linear-gradient(135deg, rgba(245,158,11,0.07), rgba(139,92,246,0.06)); border: 1px solid rgba(245,158,11,0.18); border-radius: 14px; padding: 12px 14px 10px; }
.checkin-milestone-title { font-size: clamp(0.68rem, 2.4vw, 0.78rem); font-weight: 800; color: var(--color-gold); text-align: center; margin-bottom: 8px; }
.checkin-milestone-track-v3 { width: 100%; }
.checkin-milestone-rail-area { --checkin-rail-center: 36px; position: relative; padding: 0 8px 30px; height: 78px; }
.checkin-milestone-rail-track { position: absolute; left: 20px; right: 20px; top: calc(var(--checkin-rail-center) - 4px); height: 8px; background: rgba(15,23,42,0.6); border-radius: 999px; border: 1px solid rgba(255,255,255,0.08); overflow: hidden; z-index: 0; }
.checkin-milestone-fill-v2 { height: 100%; width: 0; background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 45%, #a78bfa 100%); border-radius: 999px; transition: width 0.65s cubic-bezier(0.34, 1.2, 0.64, 1); position: relative; }
.checkin-milestone-fill-v2.checkin-fill-animate::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent); animation: checkin-shimmer 2s ease-in-out infinite; }
@keyframes checkin-shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(200%); } }
.checkin-milestone-markers-row { position: absolute; left: 20px; right: 20px; top: 0; height: 78px; z-index: 1; pointer-events: none; }
.checkin-milestone-marker { position: absolute; top: var(--checkin-rail-center); transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; cursor: pointer; pointer-events: auto; }
.checkin-milestone-marker.is-start { cursor: default; pointer-events: none; }
.checkin-milestone-marker.is-start .checkin-milestone-orb { border-style: dashed; opacity: 0.85; }
.checkin-milestone-orb { width: 40px; height: 40px; border-radius: 50%; background: radial-gradient(circle at 35% 28%, rgba(255,255,255,0.18), rgba(30,27,75,0.92)); border: 2px solid rgba(255,255,255,0.14); display: flex; align-items: center; justify-content: center; position: relative; box-shadow: 0 4px 12px rgba(0,0,0,0.35); transition: transform 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease; }
.checkin-milestone-marker:not(.is-start):hover .checkin-milestone-orb { transform: scale(1.06); border-color: rgba(245,158,11,0.45); }
.checkin-milestone-marker.reached .checkin-milestone-orb { border-color: rgba(245,158,11,0.85); box-shadow: 0 0 20px rgba(245,158,11,0.55), 0 0 40px rgba(245,158,11,0.2); transform: scale(1.08); animation: checkin-orb-pop 1.8s ease-in-out infinite; }
.checkin-milestone-marker.claimed .checkin-milestone-orb { border-color: rgba(16,185,129,0.8); box-shadow: 0 0 16px rgba(16,185,129,0.45); background: radial-gradient(circle at 35% 28%, rgba(16,185,129,0.25), rgba(30,27,75,0.92)); transform: scale(1.04); animation: none; }
.checkin-milestone-marker.claimable .checkin-milestone-orb { animation: checkin-orb-pop 1.4s ease-in-out infinite; }
@keyframes checkin-orb-pop { 0%, 100% { transform: scale(1.08); } 50% { transform: scale(1.14); } }
.checkin-milestone-egg-img { width: 24px; height: 24px; object-fit: contain; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.45)); }
.checkin-milestone-gift-icon { font-size: 1.25rem; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4)); }
.checkin-milestone-start-dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.35); }
.checkin-milestone-qty { position: absolute; bottom: -3px; right: -5px; font-size: 0.5rem; font-weight: 800; color: #fef3c7; background: rgba(0,0,0,0.6); padding: 1px 5px; border-radius: 6px; line-height: 1.2; border: 1px solid rgba(255,255,255,0.1); }
.checkin-milestone-day-lbl { position: absolute; top: calc(50% + 24px); left: 50%; transform: translateX(-50%); font-size: 0.64rem; font-weight: 800; color: var(--text-secondary); white-space: nowrap; line-height: 1; }
.checkin-milestone-marker.reached .checkin-milestone-day-lbl, .checkin-milestone-marker.claimable .checkin-milestone-day-lbl { color: #fcd34d; }
.checkin-milestone-marker.claimed .checkin-milestone-day-lbl { color: #6ee7b7; }
.checkin-milestone-modal { max-width: min(360px, 92vw); width: 100%; padding: 22px 20px; text-align: center; }
.checkin-milestone-modal-icon { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%; background: radial-gradient(circle at 35% 28%, rgba(245,158,11,0.2), rgba(30,27,75,0.9)); border: 2px solid rgba(245,158,11,0.35); display: flex; align-items: center; justify-content: center; box-shadow: 0 0 24px rgba(245,158,11,0.25); }
.checkin-milestone-modal-icon img { width: 36px; height: 36px; object-fit: contain; }
.checkin-milestone-modal-icon .gift-lg { font-size: 2rem; }
.checkin-milestone-modal-title { margin: 0 0 8px; font-size: 1.1rem; font-weight: 800; color: var(--color-gold); }
.checkin-milestone-modal-desc { margin: 0 0 12px; font-size: 0.8rem; color: var(--text-primary); line-height: 1.45; text-align: left; }
.checkin-milestone-modal-reward { background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.2); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; font-size: 0.82rem; font-weight: 700; color: #fde68a; text-align: center; }
.checkin-milestone-modal-actions { display: flex; gap: 10px; }
.checkin-milestone-modal-actions .checkin-btn-secondary { flex: 1; }
.checkin-milestone-modal-actions .checkin-btn-primary { flex: 1.4; }
.checkin-milestone-modal-actions.is-single { justify-content: center; }
.checkin-milestone-modal-actions.is-single .checkin-btn-secondary { flex: 0 1 auto; min-width: 140px; max-width: 220px; }
.checkin-egg-hatch-modal { max-width: min(340px, 90vw); width: 100%; padding: 22px 20px; text-align: center; }
.checkin-egg-hatch-img { width: 72px; height: 72px; object-fit: contain; margin-bottom: 10px; filter: drop-shadow(0 4px 12px rgba(245,158,11,0.4)); }
.checkin-egg-hatch-title { margin: 0 0 8px; font-size: 1.05rem; font-weight: 800; color: var(--color-gold); }
.checkin-egg-hatch-desc { margin: 0 0 16px; font-size: 0.8rem; color: var(--text-primary); line-height: 1.45; }
.checkin-egg-hatch-actions { display: flex; gap: 10px; }
.checkin-egg-hatch-actions .checkin-btn-secondary, .checkin-egg-hatch-actions .checkin-btn-primary { flex: 1; margin: 0; }


.checkin-day.has-giftbox:not(.checked) { background: linear-gradient(145deg, rgba(139,92,246,0.14), rgba(244,63,94,0.08)); border-color: rgba(167,139,250,0.35); }
.checkin-day.is-gold-day:not(.checked):not(.has-giftbox) { background: rgba(245,158,11,0.07); }
.checkin-day.is-exp-day:not(.checked):not(.has-giftbox) { background: rgba(99,102,241,0.07); }
.checkin-day-tappable { cursor: pointer; transition: transform 0.12s ease, box-shadow 0.12s ease; }
.checkin-day-tappable:hover { transform: scale(1.05); box-shadow: 0 0 0 1px rgba(245,158,11,0.25); }
.checkin-day-mark { position: absolute; top: 2px; right: 3px; font-size: 0.55rem; color: #6ee7b7; line-height: 1; }
.checkin-day-giftbox-icon { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); font-size: 0.72rem; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.35)); }
.checkin-day-mini { position: absolute; bottom: 1px; right: 2px; font-size: 0.48rem; line-height: 1; opacity: 0.85; }
.checkin-day-mini.gold { color: #fbbf24; }
.checkin-day-mini.exp { color: #a78bfa; }
.checkin-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; font-size: clamp(0.58rem, 2.1vw, 0.68rem); color: var(--text-secondary); }
.checkin-legend span { display: inline-flex; align-items: center; gap: 4px; }
.checkin-legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1); }
.checkin-legend-dot.checked { background: rgba(16,185,129,0.25); border-color: rgba(16,185,129,0.4); }
.checkin-legend-dot.today { box-shadow: 0 0 0 2px rgba(245,158,11,0.5); }
.checkin-legend-dot.gift { background: linear-gradient(135deg, rgba(139,92,246,0.3), rgba(244,63,94,0.2)); border-color: rgba(167,139,250,0.4); }
.checkin-legend-dot.goldday { background: rgba(245,158,11,0.25); border-color: rgba(245,158,11,0.4); }
.checkin-legend-dot.expday { background: rgba(99,102,241,0.2); border-color: rgba(99,102,241,0.35); }
.checkin-makeup-info { font-size: clamp(0.68rem, 2.4vw, 0.78rem); color: #a78bfa; font-weight: 600; text-align: center; }
/* makeup button layout: shared with .checkin-actions (same row as primary) */
.checkin-day-detail-modal { max-width: min(360px, 92vw); width: 100%; padding: 20px 18px; text-align: center; }
.checkin-day-detail-title { margin: 0 0 8px; font-size: 1.1rem; font-weight: 800; color: var(--color-gold); }
.checkin-day-detail-note { margin: 0 0 14px; font-size: 0.8rem; color: var(--text-primary); line-height: 1.45; text-align: left; }
.checkin-day-detail-section-title { font-size: 0.72rem; font-weight: 800; color: #c4b5fd; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 8px; text-align: left; }
.checkin-day-detail-actions { display: flex; gap: 10px; width: 100%; margin-top: 14px; }
.checkin-day-detail-actions .checkin-btn-secondary { flex: 1; margin: 0; }
.checkin-day-detail-actions .checkin-day-detail-btn-action { flex: 1.4; margin: 0; }
.checkin-day-detail-actions.is-single { justify-content: center; }
.checkin-day-detail-actions.is-single .checkin-btn-secondary { flex: 0 1 auto; min-width: 140px; max-width: 220px; }
.checkin-day-detail-btn-action.is-hidden-slot { display: none; }
.checkin-day-detail-btn-action.is-done { opacity: 0.65; cursor: default; filter: grayscale(0.25); }
.checkin-day-detail-btn-action:disabled:not(.is-hidden-slot) { opacity: 0.5; cursor: not-allowed; }
.checkin-reward-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-start; }
.checkin-chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.05); }
.checkin-chip-gold { border-color: rgba(245,158,11,0.35); background: rgba(245,158,11,0.1); color: #fcd34d; }
.checkin-chip-exp { border-color: rgba(167,139,250,0.35); background: rgba(167,139,250,0.1); color: #ddd6fe; }
.checkin-chip-item { border-color: rgba(255,255,255,0.12); color: var(--text-primary); }
.checkin-chip-egg { border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.08); color: #fde68a; }
.checkin-chip-egg img { width: 16px; height: 16px; object-fit: contain; }
/* Animal husbandry skeleton */
.skeleton-pulse { background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.09) 50%, rgba(255,255,255,0.04) 75%); background-size: 200% 100%; animation: skeleton-shimmer 1.2s ease-in-out infinite; border-radius: 8px; }
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.animal-grid-skeleton-card { aspect-ratio: 1; border-radius: 14px; min-height: 100px; }
.animal-detail-skeleton { display: none; flex-direction: column; gap: 12px; flex: 1; }
.animal-detail-skeleton.show { display: flex; }
.animal-detail-panel {
    max-width: 440px;
    width: 95%;
    max-height: min(88vh, 720px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    min-height: 0;
    overflow: hidden;
}
/* Desktop: use free viewport (audit: room to grow; mobile keeps scroll) */
@media (min-width: 769px) {
    .animal-detail-panel {
        max-height: min(92dvh, calc(100dvh - var(--klife-pad-top, 0px) - var(--klife-pad-bottom, 0px) - 36px));
        height: auto;
    }
    .animal-modal-list-scroll {
        max-height: min(360px, 42vh) !important;
    }
}
#farm-animal-detail-overlay { padding: 12px; align-items: center; justify-content: center; }
.animal-detail-panel .shop-header { flex-shrink: 0; margin-bottom: 0; padding-bottom: 10px; }
.animal-detail-content { display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }
.animal-detail-content.hidden { display: none; }
.animal-detail-section-label { font-weight: 700; font-size: 0.75rem; color: #a78bfa; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; flex-shrink: 0; }
.animal-modal-list-scroll { display: flex; flex-direction: column; gap: 10px; max-height: min(200px, 26vh); flex: 1 1 auto; min-height: 72px; overflow-y: auto; padding-right: 4px; overscroll-behavior: contain; }
.animal-detail-footer { display: none !important; }
.animal-detail-tycoon-row { display: flex; justify-content: flex-end; align-items: center; margin-top: 2px; gap: 10px; }
.shelter-yield-progress { display: flex; gap: 8px; width: 100%; }
.shelter-yield-progress--single .shelter-yield-segment--gold { flex: 1; }
.shelter-yield-progress--dual .shelter-yield-segment { flex: 1; min-width: 0; }
.shelter-yield-segment { display: flex; flex-direction: column; gap: 4px; }
.shelter-yield-track {
    position: relative;
    height: 22px;
    background: rgba(255,255,255,0.08);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.06);
}
.shelter-yield-fill {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 0%;
    border-radius: 5px;
    transition: width 0.35s ease;
}
.shelter-yield-segment--gold .shelter-yield-fill {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.15);
}
.shelter-yield-segment--product .shelter-yield-fill {
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.15);
}
.shelter-yield-segment.is-full .shelter-yield-track {
    border-color: rgba(245,158,11,0.45);
    box-shadow: 0 0 0 1px rgba(245,158,11,0.15);
}
.shelter-yield-segment--product.is-full .shelter-yield-track {
    border-color: rgba(59,130,246,0.45);
    box-shadow: 0 0 0 1px rgba(59,130,246,0.15);
}
.shelter-yield-tag {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 100%;
    padding: 0 8px;
    font-size: 0.68rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.55);
    white-space: nowrap;
    pointer-events: none;
}
.shelter-yield-tag .k-coin-icon,
.shelter-yield-tag img[src*="k_coin"] {
    width: 12px !important;
    height: 12px !important;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.4));
}
.shelter-yield-values {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.shelter-yield-segment.is-full .shelter-yield-values { color: #fbbf24; }
.shelter-yield-segment--product.is-full .shelter-yield-values { color: #60a5fa; }
.animal-detail-footer { margin-top: 6px; display: flex; justify-content: flex-end; flex-shrink: 0; }
.animal-detail-summary { display: flex; align-items: center; gap: 14px; background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.04); padding: 12px; border-radius: 12px; flex-shrink: 0; }
.seed-details-panel { max-width: 380px; width: 95%; max-height: min(88vh, 560px); display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
#seed-details-content { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 12px; }
.animal-detail-skel-row { display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: 12px; background: rgba(255,255,255,0.02); }
.animal-detail-skel-avatar { width: 54px; height: 54px; border-radius: 10px; flex-shrink: 0; }
.animal-detail-skel-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.animal-detail-skel-line { height: 12px; width: 70%; }
.animal-detail-skel-line.short { width: 45%; }
.animal-detail-skel-block { height: 72px; border-radius: 12px; }
.animal-detail-skel-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.animal-detail-skel-slot { aspect-ratio: 1; border-radius: 10px; min-height: 48px; }
.animals-tab-loading { position: absolute; inset: 0; z-index: 25; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(9,13,22,0.96); backdrop-filter: blur(10px); border-radius: 12px; }
.animals-tab-loading.show { display: flex; }
.animals-tab-loading-text { font-size: 0.82rem; color: var(--text-secondary); font-weight: 600; }
#animal-shelters-grid.animals-grid-loading { visibility: hidden; pointer-events: none; }

/* Animal pasture — shelter grid scales with viewport / cell size */
#farm-animals-container {
    container-type: size;
    container-name: animals-pasture;
}

.animal-shelters-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: clamp(6px, 1.6cqmin, 14px);
    padding: clamp(4px, 1.2cqmin, 10px);
    width: 100%;
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
}

.animal-shelter-card {
    container-type: size;
    container-name: shelter-card;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(2px, 2.5cqh, 8px);
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    padding: clamp(6px, 5cqmin, 14px);
    border-radius: clamp(10px, 3cqmin, 14px);
    background: rgba(20, 24, 35, 0.85);
    border: 1px solid rgba(251, 191, 36, 0.3);
    cursor: pointer;
    overflow: hidden;
    user-select: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.animal-shelter-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(251, 191, 36, 0.2);
}

.animal-shelter-card--locked {
    border-color: rgba(255, 255, 255, 0.05);
    cursor: pointer;
}

.animal-shelter-card--locked:hover {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transform: none;
}

.animal-shelter-card__icon {
    width: min(44cqw, 48cqh, 120px);
    height: min(44cqw, 48cqh, 120px);
    object-fit: contain;
    flex-shrink: 0;
}

.animal-shelter-card--locked .animal-shelter-card__icon {
    filter: grayscale(1);
    opacity: 0.4;
}

.animal-shelter-card__title {
    font-weight: 800;
    font-size: clamp(0.68rem, 7cqmin, 0.92rem);
    color: var(--text-primary);
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
}

.animal-shelter-card--locked .animal-shelter-card__title {
    color: var(--text-secondary);
}

.animal-grid-details {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-top: clamp(0px, 1cqh, 4px);
    gap: clamp(2px, 1.5cqh, 6px);
    min-width: 0;
}

.animal-shelter-card__count,
.animal-shelter-card__rate {
    font-size: clamp(0.62rem, 5.5cqmin, 0.78rem);
    text-align: center;
    line-height: 1.25;
    max-width: 100%;
}

.animal-shelter-card__count {
    color: var(--text-secondary);
}

.animal-shelter-card__rate {
    color: #10b981;
    font-weight: 700;
}

.animal-shelter-card__yield {
    display: flex;
    gap: clamp(4px, 3cqw, 8px);
    font-size: clamp(0.62rem, 5cqmin, 0.74rem);
    margin-top: clamp(2px, 1cqh, 5px);
    background: rgba(0, 0, 0, 0.4);
    padding: clamp(3px, 2cqmin, 6px) clamp(5px, 3cqmin, 8px);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: center;
}

.animal-shelter-card__yield-gold {
    color: #fbbf24;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.animal-shelter-card__yield-prod {
    color: #60a5fa;
    font-weight: bold;
}

.animal-shelter-card__yield .k-coin-icon,
.animal-shelter-card__yield img[src*="k_coin"] {
    width: clamp(10px, 4.5cqmin, 14px) !important;
    height: clamp(10px, 4.5cqmin, 14px) !important;
}

.animal-shelter-card__adopt-btn {
    margin-top: clamp(4px, 2cqh, 8px);
    width: 100%;
    padding: clamp(5px, 3cqmin, 8px);
    border-radius: 8px;
    font-weight: 800;
    font-size: clamp(0.68rem, 5.5cqmin, 0.8rem);
    border: none;
    background: linear-gradient(135deg, #fbbf24, #d97706);
    color: #fff;
    cursor: pointer;
}

.animal-shelter-card__ready-badge {
    display: none;
    position: absolute;
    top: clamp(4px, 2cqmin, 8px);
    left: clamp(4px, 2cqmin, 8px);
    background: #10b981;
    color: #fff;
    padding: clamp(2px, 1cqmin, 4px) clamp(4px, 2cqmin, 8px);
    border-radius: 10px;
    font-size: clamp(0.58rem, 4.5cqmin, 0.72rem);
    font-weight: 800;
    border: 1px solid #fff;
    z-index: 2;
    line-height: 1.2;
}

.animal-shelter-card__lock-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    border-radius: inherit;
    pointer-events: none;
}

.animal-shelter-card__lock-badge {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    color: #fff;
    padding: clamp(3px, 1.5cqmin, 5px) clamp(6px, 3cqmin, 10px);
    border-radius: 8px;
    font-size: clamp(0.56rem, 4cqmin, 0.64rem);
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.animal-grid-skeleton-card {
    aspect-ratio: unset;
    width: 100%;
    height: 100%;
    min-height: 72px;
    border-radius: clamp(10px, 3cqmin, 14px);
}

@media (min-width: 769px) {
    #farm-3d-container,
    #farm-animals-container {
        height: clamp(400px, min(52vh, 560px), 560px) !important;
    }
}
.checkin-today-box { background: linear-gradient(135deg, rgba(245,158,11,0.08), rgba(244,63,94,0.06)); border: 1px solid rgba(245,158,11,0.18); border-radius: 12px; padding: 10px 12px; text-align: left; }
.checkin-today-label { font-size: clamp(0.65rem, 2.3vw, 0.72rem); color: var(--text-secondary); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; }
.checkin-today-reward { font-size: clamp(0.75rem, 2.8vw, 0.88rem); font-weight: 700; color: var(--text-primary); line-height: 1.35; }
.checkin-actions { display: flex; gap: 10px; width: 100%; margin-top: 4px; align-items: stretch; }
.checkin-btn-primary { flex: 1.4; font-size: clamp(0.72rem, 2.8vw, 0.88rem) !important; padding: 10px 6px !important; min-width: 0; }
.checkin-btn-primary:disabled { opacity: 0.55; cursor: not-allowed; filter: grayscale(0.4); }
.checkin-btn-makeup {
    flex: 1;
    font-size: clamp(0.7rem, 2.6vw, 0.84rem) !important;
    padding: 10px 6px !important;
    min-width: 0;
    margin: 0 !important;
    width: auto !important;
    background: linear-gradient(135deg, rgba(167,139,250,0.35), rgba(124,58,237,0.28)) !important;
    border: 1px solid rgba(167,139,250,0.4) !important;
    box-shadow: none !important;
    align-items: center;
    justify-content: center;
}
.checkin-btn-makeup:disabled { opacity: 0.45; cursor: not-allowed; }

/* Harvest Particles */
.harvest-particle { position: fixed; pointer-events: none; font-weight: 800; font-size: 1.1rem; z-index: 99998; animation: floatUp 1.5s ease-out forwards; white-space: nowrap; }
@keyframes floatUp { 0% { opacity: 1; transform: translateY(0) scale(1); } 50% { opacity: 1; transform: translateY(-50px) scale(1.1); } 100% { opacity: 0; transform: translateY(-100px) scale(0.9); } }

/* Notification Badge */
.notif-badge { position: absolute; top: -6px; right: -6px; background: #ef4444; color: white; font-size: 0.62rem; font-weight: 800; padding: 1px 4px; border-radius: 8px; min-width: 16px; text-align: center; border: 1.5px solid var(--bg-color); line-height: 1.4; }
#hud-logs-wrapper { position: relative; display: inline-block; }
.k-coin-icon { display: inline-block; width: 14px; height: 14px; background-image: url('../assets/k_coin.png'); background-size: contain; background-repeat: no-repeat; vertical-align: middle; margin-right: 2px; position: relative; top: -1px; }

/* World Market Responsive */
@media (min-width: 992px) {
    #world-market-overlay .shop-modal { max-width: 950px !important; width: 95% !important; }
    #market-columns-wrapper { flex-direction: row !important; align-items: stretch !important; }
    #market-crops-list { flex: 1.1 !important; max-height: 480px; overflow-y: auto; padding-right: 4px; }
    #market-chart-container { flex: 1.4 !important; display: flex !important; margin-top: 0 !important; height: auto !important; }
}

/* Switch Control */
.switch-control input:checked + .slider { background-color: var(--color-success) !important; border-color: rgba(16,185,129,0.4) !important; }
.switch-control .slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.switch-control input:checked + .slider:before { transform: translateX(20px); }

/* Pulse Badge */
.pulse-new-badge { position: absolute; top: -5px; right: 5px; background: #ef4444; color: white; font-size: 0.58rem; font-weight: 800; padding: 1px 5px; border-radius: 10px; line-height: 1; box-shadow: 0 0 6px rgba(239,68,68,0.8); animation: badgePulse 1.5s infinite alternate; }
.farm-tab-lock-icon { font-size: 0.78rem; line-height: 1; opacity: 0.95; flex-shrink: 0; }
#farm-view-animals-btn.farm-tab-locked { opacity: 0.82; }
#farm-view-animals-btn.farm-tab-locked:not([style*="linear-gradient"]) { color: rgba(255,255,255,0.55) !important; }
@keyframes badgePulse { 0% { transform: scale(0.9); box-shadow: 0 0 4px rgba(239,68,68,0.6); } 100% { transform: scale(1.1); box-shadow: 0 0 10px rgba(239,68,68,1); } }

/* Animal Slots */
.chicken-slots-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; margin-top: 10px; }
.chicken-slot { aspect-ratio: 1; border-radius: 12px; background: rgba(255,255,255,0.02); border: 2px dashed rgba(255,255,255,0.1); display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; cursor: pointer; transition: all 0.25s cubic-bezier(0.4,0,0.2,1); overflow: hidden; }
.chicken-slot:hover { border-color: rgba(255,255,255,0.25); background: rgba(255,255,255,0.05); transform: translateY(-2px); }
.chicken-slot.occupied { border-style: solid; cursor: pointer; }
.chicken-slot.empty-plus { font-size: 1.8rem; color: rgba(255,255,255,0.3); font-weight: 300; }
.chicken-slot.empty-plus:hover { color: #fbbf24; border-color: #fbbf24; box-shadow: 0 0 12px rgba(251,191,36,0.15); }
.chicken-slot.replacement-mode { animation: slotPulseGreen 1.5s infinite alternate; border-color: #10b981 !important; cursor: pointer; }
.chicken-slot.locked-slot { border-style: solid; border-color: rgba(255,255,255,0.06); background: rgba(0,0,0,0.25); cursor: pointer; opacity: 0.65; }
.chicken-slot.locked-slot .lock-icon { font-size: 1.15rem; opacity: 0.45; }
.chicken-slot.unlock-pending { border-color: #a78bfa !important; background: rgba(139,92,246,0.1); opacity: 1; animation: slotPulsePurple 1.5s infinite alternate; }
@keyframes slotPulseGreen { 0% { box-shadow: 0 0 4px rgba(16,185,129,0.3); } 100% { box-shadow: 0 0 16px rgba(16,185,129,0.8); transform: scale(1.02); } }
@keyframes slotPulsePurple { 0% { box-shadow: 0 0 4px rgba(139,92,246,0.3); } 100% { box-shadow: 0 0 14px rgba(167,139,250,0.7); transform: scale(1.02); } }

/* ── Farm title row + décor edit (inside title chip, after text) ── */
.farm-view-title-row {
    position: relative;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
/* Pencil sits in the title chip, right of "Mảnh Vườn Cư Dân" — fixed 30×30 icon only */
.farm-view-title-chip .farm-decor-edit-btn {
    flex-shrink: 0;
    margin-left: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    padding: 0;
    border-radius: 9px;
    border: 1.5px solid rgba(251, 191, 36, 0.55);
    background: linear-gradient(145deg, rgba(251, 191, 36, 0.28), rgba(245, 158, 11, 0.18));
    color: #fde68a;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(251, 191, 36, 0.12);
}
.farm-view-title-chip .farm-decor-edit-btn:hover {
    transform: translateY(-1px) scale(1.05);
    border-color: rgba(251, 191, 36, 0.9);
    background: linear-gradient(145deg, rgba(251, 191, 36, 0.4), rgba(245, 158, 11, 0.28));
    box-shadow: 0 4px 14px rgba(251, 191, 36, 0.3);
}
.farm-view-title-chip .farm-decor-edit-btn:active { transform: scale(0.96); }
.farm-view-title-chip .farm-decor-edit-btn.is-custom {
    border-color: rgba(167, 139, 250, 0.7);
    background: linear-gradient(145deg, rgba(167, 139, 250, 0.32), rgba(124, 58, 237, 0.2));
    color: #ede9fe;
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.35);
}
.farm-view-title-chip .farm-decor-edit-btn.is-hidden,
.farm-decor-edit-btn.is-hidden {
    display: none !important;
}

/* ── Farm décor mode modal ── */
.farm-decor-overlay {
    z-index: 10020;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(6, 12, 24, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.farm-decor-modal {
    position: relative;
    width: min(440px, 94vw);
    max-height: min(88dvh, 640px);
    overflow: auto;
    padding: 22px 20px 18px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 56px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    gap: 14px;
    transform: scale(0.96);
    opacity: 0.92;
    transition: transform 0.22s cubic-bezier(0.34, 1.2, 0.64, 1), opacity 0.18s ease;
}
.farm-decor-overlay.farm-decor-overlay--in .farm-decor-modal {
    transform: scale(1);
    opacity: 1;
}
.farm-decor-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(226, 232, 240, 0.85);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}
.farm-decor-close:hover { background: rgba(255, 255, 255, 0.12); }
.farm-decor-modal__hero {
    text-align: center;
    padding: 4px 24px 2px;
}
.farm-decor-modal__hero-icon {
    display: block;
    width: 52px;
    height: 52px;
    object-fit: contain;
    margin: 0 auto 8px;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35));
}
.farm-decor-edit-btn__img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    display: block;
    pointer-events: none;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
.farm-decor-card__img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    display: block;
    margin: 2px 0 4px;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
    pointer-events: none;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
.farm-decor-modal__hero-icon {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
.farm-decor-slot__img {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
.farm-decor-modal__hero h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary, #f1f5f9);
}
.farm-decor-modal__sub {
    margin: 6px 0 0;
    font-size: 0.82rem;
    color: var(--text-secondary, #94a3b8);
    line-height: 1.4;
}
.farm-decor-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
@media (max-width: 420px) {
    .farm-decor-cards { grid-template-columns: 1fr; }
}
.farm-decor-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    text-align: left;
    padding: 14px 12px 12px;
    border-radius: 16px;
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.55);
    color: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    font-family: var(--font-family, inherit);
}
.farm-decor-card:hover {
    border-color: rgba(148, 163, 184, 0.45);
    background: rgba(30, 41, 59, 0.7);
    transform: translateY(-2px);
}
.farm-decor-card.is-active {
    border-color: rgba(52, 211, 153, 0.65);
    background: linear-gradient(160deg, rgba(16, 185, 129, 0.18), rgba(15, 23, 42, 0.75));
    box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.2), 0 8px 24px rgba(16, 185, 129, 0.12);
}
#farm-decor-card-custom.is-active {
    border-color: rgba(167, 139, 250, 0.7);
    background: linear-gradient(160deg, rgba(139, 92, 246, 0.2), rgba(15, 23, 42, 0.75));
    box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.22), 0 8px 24px rgba(124, 58, 237, 0.14);
}
.farm-decor-card__badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.25);
    color: #6ee7b7;
    border: 1px solid rgba(52, 211, 153, 0.4);
}
#farm-decor-card-custom .farm-decor-card__badge {
    background: rgba(139, 92, 246, 0.28);
    color: #ddd6fe;
    border-color: rgba(167, 139, 250, 0.45);
}
.farm-decor-card__icon {
    font-size: 1.55rem;
    line-height: 1;
    margin-bottom: 2px;
}
.farm-decor-card__title {
    font-size: 0.9rem;
    font-weight: 800;
    color: #f8fafc;
}
.farm-decor-card__desc {
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.4;
    color: #94a3b8;
}
.farm-decor-card__hint {
    margin-top: 2px;
    font-size: 0.68rem;
    font-weight: 700;
    color: #c4b5fd;
    line-height: 1.35;
}
.farm-decor-modal__note {
    margin: 0;
    text-align: center;
    font-size: 0.72rem;
    color: rgba(148, 163, 184, 0.85);
    line-height: 1.4;
}

/* ── Custom décor: 3 save slots ── */
.farm-decor-slots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
@media (max-width: 420px) {
    .farm-decor-slots { grid-template-columns: 1fr; }
}
.farm-decor-slot {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    text-align: center;
    padding: 0;
    border-radius: 16px;
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.55);
    color: inherit;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    font-family: var(--font-family, inherit);
    overflow: hidden;
}
.farm-decor-slot__main {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 14px 10px 12px;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-family: inherit;
}
.farm-decor-slot:hover {
    border-color: rgba(167, 139, 250, 0.5);
    background: rgba(30, 41, 59, 0.75);
    transform: translateY(-2px);
}
.farm-decor-slot.is-active {
    border-color: rgba(167, 139, 250, 0.75);
    background: linear-gradient(160deg, rgba(139, 92, 246, 0.22), rgba(15, 23, 42, 0.8));
    box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.25), 0 8px 22px rgba(124, 58, 237, 0.16);
}
.farm-decor-slot.is-expanded {
    border-color: rgba(167, 139, 250, 0.75);
    z-index: 2;
    transform: none;
}
/* Actions overlay ON TOP of the slot card — does not push layout */
.farm-decor-slot__actions {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 5;
    flex-direction: column;
    justify-content: center;
    gap: 7px;
    padding: 30px 10px 12px;
    background: linear-gradient(165deg, rgba(10, 14, 28, 0.94), rgba(24, 12, 40, 0.96));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: farmDecorSlotActIn 0.2s cubic-bezier(0.34, 1.2, 0.64, 1) both;
    box-sizing: border-box;
}
.farm-decor-slot__actions.is-open {
    display: flex !important; /* beat [hidden] if still present */
}
.farm-decor-slot__actions-close {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    font-size: 1.05rem;
    line-height: 1;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-family: inherit;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.farm-decor-slot__actions-close:hover {
    background: rgba(248, 113, 113, 0.2);
    border-color: rgba(248, 113, 113, 0.45);
    color: #fecaca;
}
.farm-decor-slot__actions-close:active { transform: scale(0.92); }
@keyframes farmDecorSlotActIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.farm-decor-slot__act {
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-weight: 800;
    font-size: 0.76rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.farm-decor-slot__act:active { transform: scale(0.97); }
.farm-decor-slot__act--select {
    background: linear-gradient(145deg, #a78bfa, #7c3aed);
    color: #f5f3ff;
    border-color: rgba(196, 181, 253, 0.5);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.28);
}
.farm-decor-slot__act--select:hover {
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.42);
}
.farm-decor-slot__act--edit {
    background: rgba(251, 191, 36, 0.16);
    color: #fde68a;
    border-color: rgba(251, 191, 36, 0.45);
}
.farm-decor-slot__act--edit:hover {
    background: rgba(251, 191, 36, 0.28);
}
/* Danger delete — special emphasis */
.farm-decor-slot__act--delete {
    margin-top: 2px;
    background: linear-gradient(145deg, #f87171 0%, #dc2626 55%, #991b1b 100%);
    color: #fff7f7;
    border-color: rgba(254, 202, 202, 0.55);
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.4);
    letter-spacing: 0.02em;
}
.farm-decor-slot__act--delete:hover {
    box-shadow: 0 6px 18px rgba(220, 38, 38, 0.55);
    filter: brightness(1.06);
}
.farm-decor-slot__act-ico {
    font-size: 0.9rem;
    line-height: 1;
}

/* Delete confirm popup */
.farm-decor-delete-overlay {
    z-index: 10030 !important;
}
.farm-decor-delete-modal {
    width: min(92vw, 360px);
    padding: 22px 20px 18px;
    text-align: center;
    border: 1px solid rgba(248, 113, 113, 0.35);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(248, 113, 113, 0.12);
    transform: scale(0.94);
    opacity: 0;
    transition: transform 0.22s cubic-bezier(0.34, 1.2, 0.64, 1), opacity 0.18s ease;
}
.farm-decor-delete-overlay.farm-decor-delete-overlay--in .farm-decor-delete-modal,
.farm-decor-delete-overlay.show .farm-decor-delete-modal {
    transform: scale(1);
    opacity: 1;
}
.farm-decor-delete-modal__icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 12px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    background: linear-gradient(145deg, rgba(248, 113, 113, 0.25), rgba(153, 27, 27, 0.35));
    border: 1px solid rgba(248, 113, 113, 0.4);
    box-shadow: 0 6px 18px rgba(220, 38, 38, 0.25);
}
.farm-decor-delete-modal__title {
    margin: 0 0 8px;
    font-size: 1.15rem;
    font-weight: 800;
    color: #fecaca;
}
.farm-decor-delete-modal__body {
    margin: 0 0 18px;
    font-size: 0.88rem;
    line-height: 1.45;
    color: #cbd5e1;
}
.farm-decor-delete-modal__btns {
    display: flex;
    gap: 10px;
}
.farm-decor-delete-modal__btn {
    flex: 1;
    padding: 11px 12px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.88rem;
    cursor: pointer;
    font-family: inherit;
    border: 1.5px solid transparent;
    transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.farm-decor-delete-modal__btn:active { transform: scale(0.97); }
.farm-decor-delete-modal__btn--cancel {
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.14);
}
.farm-decor-delete-modal__btn--cancel:hover {
    background: rgba(255, 255, 255, 0.1);
}
.farm-decor-delete-modal__btn--ok {
    background: linear-gradient(145deg, #f87171, #b91c1c);
    color: #fff;
    border-color: rgba(254, 202, 202, 0.45);
    box-shadow: 0 4px 16px rgba(220, 38, 38, 0.4);
}
.farm-decor-delete-modal__btn--ok:hover {
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.55);
}
.farm-decor-slot__badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.58rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(139, 92, 246, 0.3);
    color: #ddd6fe;
    border: 1px solid rgba(167, 139, 250, 0.45);
}
.farm-decor-slot__img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.3));
    pointer-events: none;
}
.farm-decor-slot__title {
    font-size: 0.88rem;
    font-weight: 800;
    color: #f8fafc;
}
.farm-decor-slot__status {
    font-size: 0.7rem;
    font-weight: 700;
    color: #94a3b8;
    line-height: 1.3;
}
.farm-decor-slot.is-empty .farm-decor-slot__status { color: #a78bfa; }
.farm-decor-slot.is-filled .farm-decor-slot__status { color: #6ee7b7; }
.farm-decor-back-btn {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: #cbd5e1;
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    font-family: var(--font-family, inherit);
}
.farm-decor-back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
}

/* ── Edit session Save / Cancel bar ── */
.farm-decor-edit-actions {
    position: absolute;
    left: 50%;
    top: 12px;
    transform: translateX(-50%);
    z-index: 86; /* above canvas — Save/Cancel must not receive map clicks under them */
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px 14px;
    padding: 8px 12px;
    border-radius: 16px;
    background: rgba(12, 18, 32, 0.92);
    border: 1px solid rgba(167, 139, 250, 0.4);
    box-shadow: 0 8px 28px rgba(0,0,0,0.45);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    max-width: min(94%, 420px);
    animation: farmDecorEditBarIn 0.28s cubic-bezier(0.34, 1.2, 0.64, 1) both;
}
.farm-decor-edit-actions.is-hidden { display: none !important; }
@keyframes farmDecorEditBarIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.farm-decor-edit-actions__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #e2e8f0;
}
.farm-decor-edit-actions__dirty {
    color: #fbbf24;
    font-weight: 800;
}
.farm-decor-edit-actions__btns {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
/* Save / Cancel — MUST NOT inherit pencil 30×30 icon sizing */
.farm-decor-edit-actions .farm-decor-edit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 4.25rem;
    height: auto;
    min-height: 2.25rem;
    padding: 0.5rem 0.95rem;
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.82rem;
    line-height: 1.15;
    white-space: nowrap;
    overflow: visible;
    box-sizing: border-box;
    cursor: pointer;
    font-family: inherit;
    border: 1.5px solid transparent;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.farm-decor-edit-actions .farm-decor-edit-btn:active { transform: scale(0.96); }
.farm-decor-edit-actions .farm-decor-edit-btn--save {
    background: linear-gradient(145deg, #34d399, #059669);
    color: #042f1e;
    border-color: rgba(167, 243, 208, 0.5);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}
.farm-decor-edit-actions .farm-decor-edit-btn--save:hover {
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.5);
}
.farm-decor-edit-actions .farm-decor-edit-btn--cancel {
    background: rgba(255,255,255,0.08);
    color: #e2e8f0;
    border-color: rgba(255,255,255,0.16);
}
.farm-decor-edit-actions .farm-decor-edit-btn--cancel:hover {
    background: rgba(248, 113, 113, 0.15);
    border-color: rgba(248, 113, 113, 0.45);
    color: #fecaca;
}
.farm-decor-slot.is-editing {
    border-color: rgba(251, 191, 36, 0.65) !important;
    box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.25);
}
.farm-decor-slot__edit-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 800;
    background: rgba(251, 191, 36, 0.25);
    color: #fde68a;
    border: 1px solid rgba(251, 191, 36, 0.45);
}
.farm-decor-slot { position: relative; }
.farm-decor-edit-btn.is-editing,
.farm-decor-edit-btn.is-custom.is-editing {
    border-color: rgba(251, 191, 36, 0.85);
}

/* ── Custom décor place toolbar (+ folders / close) ── */
.farm-decor-place-bar {
    position: absolute;
    right: 10px;
    bottom: 12px;
    z-index: 80; /* above canvas (z=1) + equipment overlays */
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    pointer-events: none;
    max-width: min(96vw, 320px);
}
.farm-decor-place-bar.is-hidden { display: none !important; }
.farm-decor-place-bar > * { pointer-events: auto; }
/* Whole place-bar captures hits while palette open (no click-through gaps) */
.farm-decor-place-bar.is-palette-open {
    pointer-events: auto;
}

.farm-decor-place-add {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    border: 2px solid rgba(167, 139, 250, 0.75);
    background: linear-gradient(145deg, rgba(124, 58, 237, 0.95), rgba(91, 33, 182, 0.92));
    color: #f5f3ff;
    box-shadow: 0 6px 20px rgba(91, 33, 182, 0.45), 0 0 0 1px rgba(255,255,255,0.08) inset;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition:
        transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1),
        box-shadow 0.2s ease,
        background 0.25s ease,
        border-color 0.25s ease,
        border-radius 0.25s ease;
}
.farm-decor-place-add:hover {
    transform: scale(1.07);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.55);
}
.farm-decor-place-add:active { transform: scale(0.94); }
.farm-decor-place-add__icon {
    font-size: 1.65rem;
    font-weight: 800;
    line-height: 1;
    display: block;
    transition: transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.18s ease;
}
.farm-decor-place-add.is-open {
    border-color: rgba(248, 113, 113, 0.75);
    background: linear-gradient(145deg, rgba(239, 68, 68, 0.95), rgba(185, 28, 28, 0.92));
    box-shadow: 0 6px 20px rgba(185, 28, 28, 0.4);
    border-radius: 50%;
}
.farm-decor-place-add.is-open .farm-decor-place-add__icon {
    transform: rotate(90deg);
    font-size: 1.55rem;
    margin-top: -2px;
}
.farm-decor-place-bar.is-placing .farm-decor-place-add:not(.is-open) {
    border-color: rgba(251, 191, 36, 0.85);
    background: linear-gradient(145deg, rgba(245, 158, 11, 0.95), rgba(217, 119, 6, 0.92));
}
/* Ghost head HUD — Cancel (X) · Delete · Rotate · Place */
.farm-decor-ghost-hud {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 85;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    will-change: transform;
}
.farm-decor-ghost-hud[hidden] { display: none !important; }
.farm-decor-ghost-hud > button {
    pointer-events: auto;
    font-family: inherit;
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
    transition: transform 0.12s ease, opacity 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
}
.farm-decor-ghost-hud__x {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(145deg, #f87171, #b91c1c);
    color: #fff;
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.farm-decor-ghost-hud__x:hover { transform: scale(1.08); }
.farm-decor-ghost-hud__x:active { transform: scale(0.94); }
.farm-decor-ghost-hud__delete {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(145deg, #fb923c, #c2410c);
    color: #fff7ed;
    font-size: 0.95rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1.5px solid rgba(254, 215, 170, 0.4) !important;
}
.farm-decor-ghost-hud__delete[hidden] { display: none !important; }
.farm-decor-ghost-hud__delete:hover { transform: scale(1.08); }
.farm-decor-ghost-hud__delete:active { transform: scale(0.94); }
.farm-decor-ghost-hud__rotate {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(145deg, #60a5fa, #2563eb);
    color: #eff6ff;
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1.5px solid rgba(191, 219, 254, 0.45) !important;
}
.farm-decor-ghost-hud__rotate:hover { transform: scale(1.08) rotate(12deg); }
.farm-decor-ghost-hud__rotate:active { transform: scale(0.94); }
.farm-decor-ghost-hud__place {
    width: 34px;
    height: 34px;
    min-width: 34px;
    padding: 0;
    border-radius: 50%;
    background: linear-gradient(145deg, #34d399, #059669);
    color: #042f1e;
    font-weight: 900;
    font-size: 1.1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid rgba(167, 243, 208, 0.45) !important;
}
.farm-decor-ghost-hud__place.is-ok {
    opacity: 1;
}
.farm-decor-ghost-hud__place.is-blocked,
.farm-decor-ghost-hud__place:disabled {
    opacity: 0.4;
    background: linear-gradient(145deg, #64748b, #475569);
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.35) !important;
    cursor: not-allowed;
}
.farm-decor-ghost-hud__place:not(:disabled):hover { transform: scale(1.08); }
.farm-decor-ghost-hud__place:not(:disabled):active { transform: scale(0.94); }

/* Edit session: hide plant/water/pest tool bar completely (no overlay on palette) */
body.farm-decor-edit-session #equipment-bar-container,
body.farm-decor-edit-session #equipment-bar,
body.farm-decor-edit-session #water-mode-toggle,
body.farm-decor-edit-session #seeding-mode-toggle,
body.farm-decor-edit-session #harvest-mode-toggle {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
}
/* Placing object: hide + button */
body.farm-decor-placing #btn-farm-decor-add {
    display: none !important;
}
body.farm-decor-placing .farm-decor-place-hint {
    display: none !important;
}

.farm-decor-place-hint {
    max-width: min(270px, 74vw);
    padding: 9px 12px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(251, 191, 36, 0.45);
    color: #fde68a;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.35;
    text-align: right;
    box-shadow: 0 4px 14px rgba(0,0,0,0.35);
    opacity: 0;
    transform: translateY(8px) scale(0.96);
    transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.34, 1.2, 0.64, 1),
        border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.farm-decor-place-hint:not([hidden]) {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.farm-decor-place-hint.is-ok {
    border-color: rgba(74, 222, 128, 0.65);
    color: #bbf7d0;
    background: rgba(6, 40, 24, 0.92);
}
.farm-decor-place-hint.is-bad {
    border-color: rgba(248, 113, 113, 0.7);
    color: #fecaca;
    background: rgba(50, 12, 12, 0.94);
}

/* Palette panel — open/close + folder nav (always above canvas; owns pointer) */
.farm-decor-palette {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(260px, 78vw);
    max-height: min(48vh, 340px);
    padding: 10px;
    border-radius: 16px;
    background: rgba(12, 18, 32, 0.97);
    border: 1px solid rgba(167, 139, 250, 0.38);
    box-shadow: 0 16px 40px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04) inset;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    transform: translateY(16px) scale(0.92);
    pointer-events: none;
    transform-origin: bottom right;
    transition:
        opacity 0.24s ease,
        transform 0.28s cubic-bezier(0.34, 1.25, 0.64, 1);
    overflow: hidden;
    z-index: 82;
    /* Solid hit-target — empty padding still blocks map underneath */
    isolation: isolate;
    touch-action: manipulation;
}
.farm-decor-palette[hidden] {
    display: none !important;
    pointer-events: none !important;
}
.farm-decor-palette.is-in {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto !important;
}
.farm-decor-palette.is-out {
    opacity: 0;
    transform: translateY(12px) scale(0.94);
    pointer-events: none !important;
}
/* While palette open: map must not steal taps under the popup */
body.farm-decor-palette-open #farm-3d-container canvas {
    pointer-events: none !important;
}
/* Entire container still receives capture listeners — chrome sits above and owns hits */
body.farm-decor-palette-open .farm-decor-place-bar,
body.farm-decor-palette-open .farm-decor-palette,
body.farm-decor-palette-open .farm-decor-palette * ,
body.farm-decor-palette-open .farm-decor-place-add,
body.farm-decor-palette-open .farm-decor-edit-actions {
    pointer-events: auto !important;
}
/* Raise place-bar above anything engine appends later */
body.farm-decor-palette-open .farm-decor-place-bar {
    z-index: 200 !important;
}
body.farm-decor-palette-open .farm-decor-palette {
    z-index: 201 !important;
    /* Opaque hit layer even on transparent gaps inside the panel */
    background: rgba(12, 18, 32, 0.98);
}
.farm-decor-palette__head {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex-shrink: 0;
}
.farm-decor-palette__back {
    align-self: flex-start;
    margin: 0 0 4px;
    padding: 5px 10px;
    border-radius: 9px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.06);
    color: #c4b5fd;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.farm-decor-palette__back:hover {
    background: rgba(167, 139, 250, 0.18);
    color: #ede9fe;
}
.farm-decor-palette__back:active { transform: scale(0.97); }
.farm-decor-palette__title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #ede9fe;
    letter-spacing: 0.01em;
}
.farm-decor-palette__sub {
    font-size: 0.72rem;
    color: #94a3b8;
    line-height: 1.35;
}
.farm-decor-palette__list {
    display: flex;
    flex-direction: column;
    gap: 7px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 2px;
    max-height: min(38vh, 280px);
    transition: opacity 0.14s ease, transform 0.14s ease;
}
.farm-decor-palette__list.is-slide-out {
    opacity: 0;
    transform: translateX(-10px);
}
.farm-decor-palette__empty {
    padding: 16px 8px;
    text-align: center;
    color: #64748b;
    font-size: 0.8rem;
}
.farm-decor-palette__item {
    display: grid;
    grid-template-columns: 34px 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 10px;
    row-gap: 2px;
    align-items: center;
    width: 100%;
    padding: 11px 11px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.045);
    color: #e2e8f0;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition:
        background 0.16s ease,
        border-color 0.16s ease,
        transform 0.16s ease,
        box-shadow 0.16s ease;
    animation: farmDecorRowIn 0.28s cubic-bezier(0.34, 1.2, 0.64, 1) both;
}
.farm-decor-palette__item:nth-child(1) { animation-delay: 0.02s; }
.farm-decor-palette__item:nth-child(2) { animation-delay: 0.06s; }
.farm-decor-palette__item:nth-child(3) { animation-delay: 0.1s; }
.farm-decor-palette__item:nth-child(4) { animation-delay: 0.14s; }
@keyframes farmDecorRowIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.farm-decor-palette__item:hover {
    background: rgba(167, 139, 250, 0.14);
    border-color: rgba(167, 139, 250, 0.45);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.farm-decor-palette__item:active { transform: scale(0.98); }
.farm-decor-palette__item.is-folder {
    border-color: rgba(129, 140, 248, 0.28);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(255,255,255,0.03));
}
.farm-decor-palette__item.is-selected {
    border-color: rgba(251, 191, 36, 0.7);
    background: rgba(251, 191, 36, 0.1);
}
.farm-decor-palette__item.is-placed {
    opacity: 0.88;
}
.farm-decor-palette__thumb {
    grid-row: 1 / span 2;
    grid-column: 1;
    width: 42px;
    height: 42px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    pointer-events: none;
    image-rendering: auto;
}
/* One icon slot only — never show emoji alongside a thumb */
.farm-decor-palette__emoji {
    grid-row: 1 / span 2;
    grid-column: 1;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    line-height: 1;
    border-radius: 10px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.farm-decor-palette__emoji[hidden],
.farm-decor-palette__item > .farm-decor-palette__emoji + .farm-decor-palette__thumb,
.farm-decor-palette__item > .farm-decor-palette__thumb + .farm-decor-palette__emoji {
    display: none !important;
}
/* If both somehow present, keep only the screenshot */
.farm-decor-palette__item:has(.farm-decor-palette__thumb) > .farm-decor-palette__emoji {
    display: none !important;
}
.farm-decor-palette__name {
    font-size: 0.82rem;
    font-weight: 800;
    color: #f1f5f9;
}
.farm-decor-palette__status {
    grid-column: 2;
    font-size: 0.65rem;
    color: #a5b4fc;
    font-weight: 600;
    line-height: 1.25;
}

/* ── Mobile scale: décor edit / palette / + / ghost HUD ── */
@media (max-width: 640px) {
    .farm-decor-edit-actions {
        top: 6px;
        gap: 4px 6px;
        padding: 4px 6px;
        max-width: min(96%, 300px);
        border-radius: 12px;
    }
    .farm-decor-edit-actions__meta {
        font-size: 0.62rem;
        max-width: 36vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .farm-decor-edit-actions__btns {
        gap: 4px;
    }
    .farm-decor-edit-actions .farm-decor-edit-btn {
        min-width: 2.4rem;
        min-height: 1.55rem;
        padding: 0.22rem 0.45rem;
        font-size: 0.65rem;
        border-radius: 8px;
        border-width: 1px;
    }
    .farm-decor-place-bar {
        right: 8px;
        bottom: 8px;
        gap: 6px;
        max-width: min(94vw, 260px);
    }
    .farm-decor-place-add {
        width: 40px;
        height: 40px;
        border-radius: 14px;
    }
    .farm-decor-place-add__icon {
        font-size: 1.4rem;
    }
    .farm-decor-place-add.is-open .farm-decor-place-add__icon {
        font-size: 1.3rem;
    }
    .farm-decor-palette {
        width: min(220px, 72vw);
        max-height: min(42vh, 280px);
        padding: 8px;
        border-radius: 14px;
        gap: 6px;
    }
    .farm-decor-palette__item {
        padding: 8px;
        border-radius: 12px;
        gap: 8px;
    }
    .farm-decor-palette__thumb {
        width: 34px;
        height: 34px;
        border-radius: 8px;
    }
    .farm-decor-palette__emoji {
        width: 28px;
        height: 28px;
        font-size: 1.05rem;
    }
    .farm-decor-palette__name {
        font-size: 0.74rem;
    }
    .farm-decor-palette__status {
        font-size: 0.6rem;
    }
    .farm-decor-palette__title {
        font-size: 0.8rem;
    }
    .farm-decor-palette__sub {
        font-size: 0.65rem;
    }
    .farm-decor-ghost-hud {
        gap: 5px;
    }
    .farm-decor-ghost-hud__x,
    .farm-decor-ghost-hud__delete,
    .farm-decor-ghost-hud__rotate,
    .farm-decor-ghost-hud__place {
        width: 30px;
        height: 30px;
        min-width: 30px;
        font-size: 1.05rem;
        padding: 0;
        border-radius: 50%;
    }
}
.farm-decor-palette__item.is-placed .farm-decor-palette__status { color: #6ee7b7; }
.farm-decor-palette__chev {
    grid-column: 3;
    grid-row: 1 / span 2;
    font-size: 1.25rem;
    font-weight: 700;
    color: #a78bfa;
    opacity: 0.85;
}
.farm-decor-palette__remove {
    grid-column: 3;
    grid-row: 1 / span 2;
    padding: 5px 9px;
    border-radius: 9px;
    background: rgba(239, 68, 68, 0.18);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: #fecaca;
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease;
}
.farm-decor-palette__remove:hover {
    background: rgba(239, 68, 68, 0.32);
}
body.farm-decor-placing #farm-3d-container canvas {
    cursor: grab !important;
}
body.farm-decor-placing.farm-decor-dragging #farm-3d-container canvas {
    cursor: grabbing !important;
}

/* Farm popups — mobile: centered card (not full-width sheet) */
@media (max-width: 600px) {
    #farm-animal-detail-overlay,
    #seed-details-overlay,
    #farm-research-overlay {
        align-items: center;
        justify-content: center;
    }
    .animal-detail-panel {
        width: min(92vw, 400px) !important;
        max-width: 400px !important;
        max-height: min(86dvh, 620px);
        border-radius: 18px;
        padding: 12px 14px !important;
        gap: 8px;
        box-shadow: 0 16px 48px rgba(0,0,0,0.5);
    }
    #farm-research-overlay .shop-modal.research-panel-modal {
        width: min(96vw, 720px);
        height: min(88dvh, calc(100dvh - var(--klife-pad-top) - var(--klife-pad-bottom) - 24px), 720px);
        max-height: min(88dvh, calc(100dvh - var(--klife-pad-top) - var(--klife-pad-bottom) - 24px), 720px);
        min-height: min(88dvh, calc(100dvh - var(--klife-pad-top) - var(--klife-pad-bottom) - 24px), 720px);
        margin: auto;
        padding: 12px 10px !important;
        border-radius: 18px;
    }
    #farm-research-overlay {
        --research-viewport-pad-y: 10px;
        --research-viewport-pad-x: 8px;
        --research-track-gap: 12px;
        --research-flow-gap: 5px;
        --research-row-gap: 5px;
        --research-row-pad-y: 4px;
        --research-node-size: 42px;
        --research-node-border: 2px;
        --research-badge-size: 14px;
        --research-badge-font: 0.5rem;
        --research-label-size: 0.58rem;
        --research-label-max: 62px;
        --research-connector-w: 20px;
        --research-connector-h: 3px;
        --research-connector-mb: 10px;
        --research-title-size: 0.62rem;
    }
    #farm-research-overlay .research-skill-circle.is-selected {
        transform: scale(1.05);
    }
    #farm-research-overlay #research-tab-intro {
        font-size: 0.68rem !important;
        margin-bottom: 2px !important;
    }
    #farm-research-overlay #research-tabbar .shop-tab-btn {
        padding: 5px 6px !important;
        font-size: 0.68rem !important;
    }
    #farm-research-overlay #research-detail-panel {
        min-height: 118px;
    }
    .animal-detail-content { gap: 10px; }
    .animal-detail-summary { padding: 10px; gap: 10px; }
    .animal-detail-summary img { width: 46px !important; height: 46px !important; }
    .animal-modal-list-scroll { max-height: none; min-height: 80px; }
    .chicken-slots-grid { gap: 5px; margin-top: 6px; }
    .chicken-slot img { width: 32px !important; height: 32px !important; }
    .chicken-slot.empty-plus { font-size: 1.4rem; }
    .animal-detail-tycoon-row {
        flex-direction: column;
        align-items: stretch;
    }
    #animal-modal-collect-btn {
        width: 100%;
        padding: 10px 14px !important;
        margin-top: 4px;
    }
    .shelter-yield-progress--dual { flex-direction: column; gap: 10px; }
    .shelter-yield-track { height: 20px; }
    .shelter-yield-tag { font-size: 0.64rem; padding: 0 6px; }
    .animal-detail-panel .k-coin-icon {
        width: 12px !important;
        height: 12px !important;
        max-width: 12px !important;
        max-height: 12px !important;
    }
    .animal-detail-panel img[src*="k_coin"] {
        width: 12px !important;
        height: 12px !important;
        max-width: 12px !important;
        max-height: 12px !important;
    }

    .seed-details-panel {
        width: min(92vw, 360px) !important;
        max-width: 360px !important;
        max-height: min(82dvh, 520px);
        border-radius: 18px;
        padding: 12px 14px !important;
        box-shadow: 0 16px 48px rgba(0,0,0,0.5);
    }
    .floating-menu:not(.floating-menu--mobile) {
        width: min(88vw, 280px) !important;
        max-width: min(88vw, 280px) !important;
        max-height: min(70dvh, 480px) !important;
        padding: 10px 12px;
        overflow-x: hidden !important;
    }
    .floating-menu-title { font-size: 0.72rem; margin-bottom: 4px; }
    .floating-seed-name { font-size: 0.8rem; }
    .floating-seed-item { padding: 7px 8px; }
    #seed-details-content { font-size: 0.78rem; }
    #seed-details-content .seed-details-hero-title { font-size: 0.92rem !important; }
}

.shelter-action-modal .shelter-cost-row { display: flex; align-items: center; gap: 12px; padding: 12px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06); border-radius: 12px; }
.shelter-action-modal .shelter-cost-icon { width: 44px; height: 44px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.shelter-action-modal .shelter-cost-icon img { width: 40px !important; height: 40px !important; }
.shelter-action-modal .shelter-cost-label { font-size: 0.88rem; font-weight: 800; color: var(--text-primary); }
.shelter-action-modal .shelter-cost-sub { font-size: 0.72rem; color: var(--text-secondary); margin-top: 2px; }
.shelter-action-modal .shelter-req-block { padding: 10px 12px; border-radius: 10px; background: rgba(139,92,246,0.08); border: 1px solid rgba(139,92,246,0.2); font-size: 0.78rem; line-height: 1.5; }
.shelter-action-modal .shelter-req-block.warn { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.25); color: #fca5a5; }
.shelter-action-modal .shelter-meat-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.shelter-action-modal .shelter-meat-card { padding: 12px; border-radius: 12px; text-align: center; }
.shelter-action-modal .shelter-meat-card.now { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.25); }
.shelter-action-modal .shelter-meat-card.later { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.25); }
.shelter-action-modal .shelter-meat-qty { font-size: 1.35rem; font-weight: 800; margin-top: 4px; }
#animal-modal-storage-upgrade-btn .storage-upgrade-inner { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
#animal-modal-storage-upgrade-btn .storage-upgrade-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; }
#animal-modal-storage-upgrade-btn .storage-material { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; font-weight: 800; }
#animal-modal-storage-upgrade-btn .storage-material img { width: 40px !important; height: 40px !important; }
#animal-modal-storage-upgrade-btn .storage-material-name { color: #fef3c7; }

/* Quality Colors */
.quality-bg-normal { background: linear-gradient(135deg, rgba(75,85,99,0.2), rgba(55,65,81,0.35)) !important; border-color: rgba(107,114,128,0.5) !important; }
.quality-bg-common { background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(5,150,105,0.3)) !important; border-color: rgba(16,185,129,0.5) !important; }
.quality-bg-rare { background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(37,99,235,0.3)) !important; border-color: rgba(59,130,246,0.5) !important; }
.quality-bg-epic { background: linear-gradient(135deg, rgba(139,92,246,0.18), rgba(124,58,237,0.32)) !important; border-color: rgba(139,92,246,0.55) !important; }
.quality-bg-legendary { background: linear-gradient(135deg, rgba(251,191,36,0.2), rgba(217,119,6,0.35)) !important; border-color: rgba(251,191,36,0.65) !important; box-shadow: 0 0 10px rgba(251,191,36,0.1); animation: legendaryGlow 2s infinite alternate; }
@keyframes legendaryGlow { 0% { box-shadow: 0 0 4px rgba(251,191,36,0.1); } 100% { box-shadow: 0 0 12px rgba(251,191,36,0.3); } }
.color-normal { color: #9ca3af; }
.color-common { color: #34d399; }
.color-rare { color: #60a5fa; }
.color-epic { color: #c084fc; }
.color-legendary { color: #fbbf24; font-weight: 800; text-shadow: 0 0 8px rgba(251,191,36,0.4); }

/* Gacha Egg */
.gacha-egg-btn { background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.06); border-radius: 14px; padding: 12px; text-align: center; cursor: pointer; transition: all 0.25s; display: flex; flex-direction: column; align-items: center; gap: 8px; position: relative; overflow: hidden; }
.gacha-egg-btn:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.15); transform: scale(1.03); }
.gacha-egg-btn.active { border-color: #fbbf24; background: rgba(251,191,36,0.04); box-shadow: 0 0 12px rgba(251,191,36,0.15); }
.gacha-egg-img { width: 60px; height: 60px; object-fit: contain; transition: transform 0.15s; }
.gacha-egg-btn:hover .gacha-egg-img { transform: scale(1.1) rotate(5deg); }
.egg-shaking { animation: eggShake 1.2s ease-in-out infinite; }
@keyframes eggShake { 0% { transform: rotate(0deg) scale(1); } 15% { transform: rotate(-10deg) scale(1.05); } 30% { transform: rotate(10deg) scale(1.05); } 45% { transform: rotate(-8deg) scale(1.08); } 60% { transform: rotate(8deg) scale(1.08); } 75% { transform: rotate(-4deg) scale(1.05); } 90% { transform: rotate(4deg) scale(1.05); } 100% { transform: rotate(0deg) scale(1); } }
.reveal-glow { animation: revealFlash 0.6s ease-out forwards; }
@keyframes revealFlash { 0% { filter: brightness(1) contrast(1); transform: scale(0.9); } 50% { filter: brightness(3) contrast(1.2); transform: scale(1.1); box-shadow: 0 0 30px #fff; } 100% { filter: brightness(1) contrast(1); transform: scale(1); } }
