
:root {
    --farm-green: #398b43;
    --farm-dark: #246b35;
    --farm-light: #e9f8dc;
    --farm-yellow: #ffca55;
    --farm-cream: #fffaf0;
    --farm-border: #e8d9b5;
    --farm-text: #3d4935;
    font-family: Arial, sans-serif;
    color: #203026;
    background: #f4f8f3;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: #edf7e5;
    color: #3d4935;
    font-family: Arial, sans-serif;
}

.dark { background: #17221b; color: #e8f2e9; }
.dark .panel, .dark input, .dark select, .dark textarea { background: #243329; color: #eef; }
.dark a { color: #b8e5b9; }

header {
    background: linear-gradient(135deg, #42a34b, #28743a);
    border-bottom: 5px solid #f5c85b;
    box-shadow: 0 4px 12px #244d2525;
    color: white;
    padding: 14px 4%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

header a { color: white; text-decoration: none; margin-right: 12px; }
.brand { font-size: 25px; font-weight: 900; letter-spacing: .3px; }

main {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 16px;
}

.panel, .stat {
    background: var(--farm-cream);
    border: 2px solid var(--farm-border);
    border-radius: 18px;
    box-shadow: 0 4px 10px #496d3020;
    padding: 18px;
    margin: 12px 0;
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat strong { font-size: 27px; display: block; color: #398b43; }
h1, h2, h3 { color: inherit; }
label { display: block; margin: 10px 0 5px; }

input, select, textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #dce5cf;
    border-radius: 11px;
    background: #fffefa;
    color: #203026;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #70b85a;
    box-shadow: 0 0 0 3px #70b85a25;
}

button, .btn {
    background: linear-gradient(#66bd50, #388d3e);
    color: white;
    border: 2px solid #2d7735;
    padding: 11px 17px;
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    margin: 4px 2px;
    font-weight: bold;
    box-shadow: 0 3px 0 #286b32;
    transition: transform .15s, filter .15s;
}

button:hover, .btn:hover { filter: brightness(1.06); transform: translateY(-2px); }
button:active, .btn:active { transform: translateY(1px); box-shadow: 0 1px 0 #286b32; }
button.secondary, .btn.secondary { background: linear-gradient(#9ca99a, #718071); border-color: #687668; box-shadow: 0 3px 0 #596759; }

.notice { padding: 12px; border-radius: 7px; margin: 12px 0; background: #e5f5e8; }

.notice.error {
    background: #fff0ed;
    color: #a43c35;
    border: 2px solid #f2aaa0;
    border-bottom: 5px solid #df776b;
    border-radius: 15px;
    padding: 16px 18px;
    font-weight: 800;
}

table { width: 100%; border-collapse: collapse; background: white; color: #203026; border-radius: 12px; overflow: hidden; }
td, th { padding: 10px; border-bottom: 1px solid #e6eadc; text-align: left; }
th { background: #e5f3d9; color: #315f32; font-weight: bold; }
footer { text-align: center; padding: 30px; color: #71836a; }
small, .muted { color: #78857a; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.animal { font-size: 36px; }
.ad-slot { border: 1px dashed #9aa99c; padding: 12px; text-align: center; margin: 14px 0; color: #778; }

.badge {
    display: inline-block;
    padding: 6px 11px;
    border-radius: 20px;
    background: #fff0bd;
    color: #80551a;
    border: 1px solid #f0d17c;
    font-size: 12px;
    font-weight: bold;
    align-self: center;
}

.dark .badge { background: #314b39; color: #d7f2dc; }
.link-button { background: transparent; color: white; padding: 0; margin: 0 12px 0 0; border: 0; border-radius: 0; text-decoration: none; font: inherit; cursor: pointer; }

.spin-wheel {
    width: min(270px, 75vw);
    height: min(270px, 75vw);
    border-radius: 50%;
    margin: 20px auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    place-items: center;
    border: 10px solid #f3c64e;
    background: conic-gradient(#f7df8c 0 60deg, #fff2c8 60deg 120deg, #a8dca7 120deg 180deg, #e6f3d7 180deg 240deg, #f6d1a5 240deg 300deg, #d5e9ff 300deg);
    box-shadow: 0 5px 18px #0002;
    font-size: 36px;
}

.lucky-spin { text-align: center; }
.lucky-spin form { display: flex; justify-content: center; }
.lucky-spin button { font-size: 17px; padding: 13px 24px; }
.progress { height: 16px; background: #dcebd1; border: 1px solid #c9dfbb; border-radius: 99px; overflow: hidden; margin: 14px 0; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, #80ce50, #369444); border-radius: 99px; transition: width .2s ease; }

.farm-showcase { position: relative; overflow: hidden; min-height: 150px; background: linear-gradient(135deg, #e4f5d6, #a8d98c); border: 3px solid #d1e7b7; border-radius: 18px; box-shadow: 0 4px 12px #496d3020; }
.farm-bg-sunrise { background: linear-gradient(135deg, #ffe6b0, #f5b6a0); }
.farm-bg-orchard { background: linear-gradient(135deg, #d5f0d2, #83c78b); }
.farm-bg-lavender { background: linear-gradient(135deg, #eee2ff, #c7b6ed); }
.farm-decor { font-size: clamp(20px, 4vw, 34px); white-space: nowrap; overflow: hidden; padding: 14px; opacity: .9; }
.table-wrap { max-width: 100%; overflow-x: auto; }
nav { max-width: 100%; }
nav a, nav button { white-space: nowrap; }

/* Daily Rewards dropdown */
.daily-rewards-dropdown { display: inline-block; position: relative; vertical-align: middle; }
.daily-rewards-dropdown summary { display: inline-block; cursor: pointer; list-style: none; color: white; background: #347d3c; border: 1px solid #78bd70; border-radius: 12px; padding: 10px 13px; margin: 3px; font-weight: bold; }
.daily-rewards-dropdown summary::-webkit-details-marker { display: none; }
.daily-rewards-dropdown summary:hover { background: #4a9b4d; }
.daily-rewards-menu { position: absolute; top: calc(100% + 5px); left: 0; min-width: 205px; z-index: 1000; padding: 9px; background: #fffaf0; border: 2px solid #e8d9b5; border-radius: 14px; box-shadow: 0 8px 22px #0002; }
.daily-rewards-menu a { display: block; color: #365d35; padding: 10px 12px; margin: 3px 0; border-radius: 9px; text-decoration: none; }
.daily-rewards-menu a:hover { background: #e8f5dc; }

/* Dark theme */
.dark { background: #17291d; color: #edf5e8; }
.dark .panel, .dark .stat { background: #243b2a; border-color: #456349; color: #edf5e8; }
.dark .panel h2, .dark .panel h3 { color: #c7efb4; }
.dark table { background: #243b2a; color: #edf5e8; }
.dark th { background: #34523a; color: #edf5e8; }
.dark .daily-rewards-menu { background: #243b2a; border-color: #456349; }
.dark .daily-rewards-menu a { color: #e5f5dc; }
.dark .daily-rewards-menu a:hover { background: #34523a; }

/* Cartoon dashboard */
.cartoon-dashboard {
    --farm-green: #43b95b;
    --farm-dark: #247c3b;
    --farm-cream: #fff9e9;
    --farm-ink: #34452f;
    --farm-shadow: 0 6px 0 rgba(70, 95, 48, .10);
    color: var(--farm-ink);
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 12px 12px;
}

.cartoon-dashboard * { box-sizing: border-box; }
.cartoon-dashboard a { text-decoration: none; }

.cartoon-welcome {
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 210px;
    padding: 28px 32px;
    margin-bottom: 18px;
    border-radius: 26px;
    color: white;
    background: linear-gradient(120deg, #39b85d, #83d66b);
    box-shadow: 0 7px 0 #2e9848;
}

.welcome-copy { position: relative; z-index: 2; }
.cartoon-label, .cartoon-reward-banner > div:nth-child(2) > span, .section-kicker { display: inline-block; font-size: 11px; font-weight: 900; letter-spacing: 1.4px; }
.cartoon-welcome h1 { margin: 10px 0 7px; font-size: clamp(25px, 4vw, 38px); font-weight: 900; color: white; }
.cartoon-welcome p { margin: 0 0 20px; color: rgba(255,255,255,.95); }
.cartoon-play-button { display: inline-block; padding: 12px 22px; border-radius: 13px; color: #287b39 !important; background: #fff5c9; font-size: 13px; font-weight: 900; box-shadow: 0 4px 0 #e7c96e; }
.cartoon-play-button:hover { transform: translateY(-2px); }
.welcome-character { position: relative; width: 210px; height: 150px; flex-shrink: 0; }
.welcome-sun { position: absolute; top: 0; right: 25px; font-size: 52px; }
.welcome-chicken { position: absolute; bottom: -8px; left: 25px; font-size: 95px; filter: drop-shadow(0 5px 2px rgba(0,0,0,.12)); }
.welcome-flower { position: absolute; right: 5px; bottom: 0; font-size: 54px; }

/* Farm scene */
.cartoon-farm { position: relative; min-height: 410px; overflow: hidden; margin-bottom: 30px; border: 5px solid white; border-radius: 27px; background: linear-gradient(#8ddcf7 0%, #d7f5ff 53%, #a8e37d 54%, #65c85d 100%); box-shadow: 0 7px 0 rgba(58,105,45,.15); }
.farm-sky { position: absolute; inset: 0 0 40% 0; overflow: hidden; }
.farm-sun { position: absolute; top: 22px; right: 9%; font-size: 54px; }
.farm-cloud { position: absolute; font-size: 42px; opacity: .9; }
.cloud-a { top: 45px; left: 15%; }
.cloud-b { top: 100px; right: 28%; }
.farm-bird { position: absolute; top: 35px; left: 48%; font-size: 25px; }
.farm-scene-heading { position: relative; z-index: 2; padding: 25px 20px 0; text-align: center; }
.farm-scene-heading > span { display: inline-block; padding: 7px 15px; border-radius: 20px; color: #397b3d; background: #fff5d4; font-size: 11px; font-weight: 900; }
.farm-scene-heading h2 { margin: 8px 0 3px; color: #315d31; font-size: clamp(23px, 4vw, 34px); font-weight: 900; text-shadow: 0 2px white; }
.farm-scene-heading p { margin: 0; color: #467b47; font-size: 13px; font-weight: 700; }
.farm-land { position: absolute; inset: 165px 0 37px; background: linear-gradient(170deg, #9cdd6d, #53b94e); }
.farm-house { position: absolute; z-index: 2; top: -36px; left: 44%; width: 100px; text-align: center; }
.house-roof { display: block; height: 28px; color: #b75a36; font-size: 39px; line-height: 28px; }
.house-body { display: block; font-size: 72px; line-height: 75px; }
.scene-tree { position: absolute; z-index: 2; font-size: 55px; filter: drop-shadow(0 4px 1px rgba(0,0,0,.1)); }
.tree-a { top: -25px; left: 8%; }
.tree-b { top: 22px; right: 9%; }
.tree-c { bottom: 5px; right: 25%; }
.scene-animals { position: absolute; z-index: 3; left: 16%; right: 16%; bottom: 33px; display: flex; justify-content: space-around; align-items: center; }
.scene-animals span { display: inline-block; font-size: clamp(29px, 5vw, 47px); filter: drop-shadow(0 4px 1px rgba(0,0,0,.12)); animation: farm-bob 2.5s ease-in-out infinite; }
.scene-animals span:nth-child(even) { animation-delay: .5s; }
.scene-crops { position: absolute; bottom: 4px; left: 5%; display: flex; flex-direction: column; gap: 1px; font-size: 20px; }
.scene-fence { position: absolute; right: 3%; bottom: 0; font-size: 21px; white-space: nowrap; }
.farm-scene-footer { position: absolute; z-index: 4; right: 0; bottom: 0; left: 0; display: flex; justify-content: space-around; padding: 10px; color: #397a38; background: rgba(255,255,255,.83); font-size: 11px; font-weight: 900; }
@keyframes farm-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* Dashboard sections */
.cartoon-section { margin: 28px 0; }
.cartoon-section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.cartoon-section-title h2 { margin: 5px 0 0; color: #344b32; font-size: 23px; font-weight: 900; }
.section-kicker { color: #76a36b; }
.section-decoration { font-size: 30px; }

/* Activity cards */
.cartoon-action-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 15px; }
.cartoon-action { position: relative; display: flex; min-height: 160px; flex-direction: column; align-items: flex-start; overflow: hidden; padding: 18px; border: 2px solid rgba(40,70,30,.06); border-radius: 21px; color: #344b32 !important; background: white; box-shadow: 0 5px 0 rgba(70,95,48,.10); transition: transform .18s ease, box-shadow .18s ease; }
.cartoon-action:hover { transform: translateY(-4px); box-shadow: 0 9px 0 rgba(70,95,48,.10); }
.action-emoji { display: grid; place-items: center; width: 53px; height: 53px; margin-bottom: 12px; border-radius: 17px; background: rgba(255,255,255,.75); font-size: 31px; }
.cartoon-action strong { font-size: 17px; font-weight: 900; }
.cartoon-action small { margin-top: 4px; color: #71806b; font-size: 11px; }
.action-arrow { position: absolute; right: 14px; bottom: 14px; font-size: 10px; font-weight: 900; }
.action-farm { background: #e5f8d9; }
.action-animals { background: #fff0d6; }
.action-market { background: #dff4ff; }
.action-upgrade { background: #eee8ff; }
.action-tasks { background: #ffe6e2; }
.action-friends { background: #e0f5ed; }

/* Reward banner */
.cartoon-reward-banner { display: flex; align-items: center; gap: 18px; padding: 20px; margin: 28px 0; border-radius: 23px; background: #fff0bf; box-shadow: 0 5px 0 #ebd78e; }
.reward-character { display: grid; place-items: center; width: 68px; height: 68px; flex-shrink: 0; border-radius: 20px; background: white; font-size: 39px; }
.cartoon-reward-banner > div:nth-child(2) { flex: 1; }
.cartoon-reward-banner > div:nth-child(2) > span { color: #a47a24; }
.cartoon-reward-banner h2 { margin: 5px 0; color: #70531b; font-size: 19px; font-weight: 900; }
.cartoon-reward-banner p { margin: 0; color: #8d713d; font-size: 12px; }
.cartoon-reward-banner > a { padding: 12px 15px; border-radius: 12px; color: white !important; background: #d99b2e; font-size: 11px; font-weight: 900; white-space: nowrap; }

/* Inventory */
.inventory-count { padding: 7px 12px; border-radius: 20px; color: #4d8b48; background: #e7f6df; font-size: 11px; font-weight: 900; }
.cartoon-inventory-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.inventory-card { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 13px; border: 1px solid #e8eddf; border-radius: 16px; background: white; }
.inventory-emoji { display: grid; place-items: center; width: 43px; height: 43px; flex-shrink: 0; border-radius: 13px; background: #eff8e8; font-size: 23px; }
.inventory-card > div { flex: 1; min-width: 0; }
.inventory-card strong, .inventory-card small { display: block; overflow-wrap: anywhere; }
.inventory-card strong { font-size: 13px; }
.inventory-card small { margin-top: 3px; color: #899282; font-size: 10px; }
.inventory-card > b { color: #398d43; font-size: 13px; white-space: nowrap; }

/* Empty state */
.cartoon-empty { padding: 28px 15px; border: 2px dashed #d7e8ca; border-radius: 19px; text-align: center; background: #fbfff7; }
.cartoon-empty > span { display: block; margin-bottom: 8px; font-size: 38px; }
.cartoon-empty strong { display: block; color: #456d3c; }
.cartoon-empty p { color: #7d8a75; font-size: 12px; }
.cartoon-empty a { display: inline-block; padding: 10px 15px; border-radius: 11px; color: white !important; background: #48ad55; font-size: 11px; font-weight: 900; }

/* Wallet */
.cartoon-wallet-grid, .cartoon-price-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.wallet-card, .price-card { display: flex; flex-direction: column; gap: 7px; padding: 18px; border-radius: 18px; background: white; box-shadow: var(--farm-shadow); }
.wallet-card > span { font-size: 28px; }
.wallet-card strong { color: #344b32; font-size: 21px; overflow-wrap: anywhere; }
.earning-card { border-left: 5px solid #48b85b; }
.pending-card { border-left: 5px solid #e8ad43; }
.cartoon-account-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.cartoon-account-links a { padding: 11px 15px; border-radius: 12px; color: #397b3d !important; background: #eaf6e4; font-size: 12px; font-weight: 800; }

/* Crypto prices */
.price-card { border: 1px solid #e9efdf; }
.price-card span { color: #77856d; font-size: 12px; font-weight: 800; }
.price-card strong { color: #3d9b4c; font-size: 21px; }
.price-card small, .cartoon-note { color: #899282; font-size: 10px; overflow-wrap: anywhere; }
.cartoon-note { margin-top: 12px; }

/* FARMZONE - GAME SIDEBAR NAVIGATION */
.hf-topbar {
    position: sticky;
    top: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 76px;
    padding: 12px 22px;
    background: #ffffff;
    border-bottom: 1px solid #e6eddf;
    box-shadow: 0 3px 12px rgba(35,75,35,.07);
}

.hf-topbar .brand { color: #328e43; font-size: 21px; font-weight: 900; text-decoration: none; }
.hf-top-actions { display: flex; align-items: center; gap: 9px; margin-left: auto; }
.hf-top-button { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 8px 12px; border: 1px solid #e3ebdc; border-radius: 10px; color: #426c3d; background: #f7fbf3; font-size: 12px; font-weight: 800; text-decoration: none; cursor: pointer; }
.hf-menu-toggle, .hf-sidebar-close { display: none; }

.hf-sidebar {
    position: fixed;
    z-index: 950;
    top: 76px;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    width: 255px;
    overflow: hidden;
    background: #f3e2c3;
    border-right: 2px solid #c9a477;
    box-shadow: 4px 0 12px rgba(91,60,30,.14);
}

.hf-sidebar-heading { display: flex; align-items: center; gap: 11px; padding: 19px 15px; border-bottom: 3px solid #bd9564; background: #dfbd8d; box-shadow: 0 3px 5px rgba(80,50,20,.12); }
.hf-sidebar-avatar { display: grid; place-items: center; width: 43px; height: 43px; flex-shrink: 0; border-radius: 10px; background: #fff2d9; border: 2px solid #cba777; box-shadow: 0 2px 0 #b78d5d; font-size: 25px; }
.hf-sidebar-heading strong, .hf-sidebar-heading small { display: block; overflow-wrap: anywhere; }
.hf-sidebar-heading strong { color: #56371f; font-size: 13px; font-weight: 900; }
.hf-sidebar-heading small { margin-top: 3px; color: #795a3b; font-size: 10px; }
.hf-sidebar-content { flex: 1; overflow-y: auto; padding: 12px 11px 22px; }
.hf-menu-label { display: block; padding: 17px 10px 7px; color: #89633d; border-bottom: 1px solid #d3b58b; margin-bottom: 5px; font-size: 10px; font-weight: 900; letter-spacing: 1px; }

.hf-side-link {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 43px;
    padding: 9px 12px;
    margin: 5px 0;
    border-radius: 8px;
    color: #63472d !important;
    background: #f9eedb;
    border: 1px solid #dfc49b;
    border-bottom: 3px solid #d0ae7e;
    font-size: 12px;
    font-weight: 750;
    text-decoration: none !important;
    box-shadow: 0 2px 3px rgba(90,60,30,.08);
    transition: background .15s ease, box-shadow .15s ease;
}

.hf-side-link:hover { color: #4c2e17 !important; background: #edcf9f; border-color: #c49a65; border-bottom-color: #a87947; transform: none; box-shadow: 0 2px 4px rgba(90,60,30,.15); }
.hf-side-link > span { flex: 1; }
.hf-notification-count { display: inline-grid; place-items: center; min-width: 21px; height: 21px; padding: 0 5px; border-radius: 20px; color: white; background: #b84b35; font-size: 10px; }
.hf-sidebar-logout { margin: 16px 4px 4px; }
.hf-sidebar-logout button { width: 100%; min-height: 43px; border: 1px solid #794a2b; border-bottom: 4px solid #6f4126; border-radius: 8px; color: #fff8ed; background: #98613c; font-size: 12px; font-weight: 900; cursor: pointer; box-shadow: 0 2px 4px rgba(70,40,20,.15); }
.hf-sidebar-logout button:hover { background: #ad754b; transform: none; }

/* MAIN CONTENT */
.hf-main-with-sidebar {
    display: flow-root;
    width: auto;
    min-width: 0;
    min-height: calc(100vh - 80px);
    margin: 0 0 0 255px !important;
    padding: 0 20px 20px !important;
}

.hf-main-with-sidebar > :first-child {
    margin-top: 0 !important;
}

.hf-main-with-sidebar > .cartoon-dashboard {
    width: 100%;
    margin: 0 auto !important;
    padding-top: 0 !important;
}

.hf-sidebar-overlay { display: none; }
.hf-guest-nav, .hf-admin-nav { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.hf-guest-nav a, .hf-admin-nav a { color: #4b7142; font-size: 12px; font-weight: 800; text-decoration: none; }
.hf-admin-nav form { display: inline; }

/* MOBILE SIDEBAR */
@media(max-width: 850px) {
    .hf-topbar { min-height: 65px; padding: 9px 12px; }
    .hf-topbar .brand { font-size: 18px; }
    .hf-menu-toggle { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 40px; padding: 0; margin: 0; border: 2px solid #d6b17b; border-radius: 10px; background: #f8e8c8; color: #674324; font-size: 23px; cursor: pointer; }
    .hf-sidebar { top: 0; bottom: 0; left: 0; width: min(285px, 85vw); z-index: 1200; visibility: hidden; pointer-events: none; transform: translateX(-105%); transition: transform .25s ease; box-shadow: 8px 0 30px rgba(0,0,0,.14); }
    body.hf-sidebar-open .hf-sidebar { visibility: visible; pointer-events: auto; transform: translateX(0); }
    .hf-sidebar-close { display: inline-grid; place-items: center; width: 30px; height: 30px; margin-left: auto; border: 0; border-radius: 9px; color: #52704a; background: #e4f1dc; font-size: 23px; cursor: pointer; }
    .hf-sidebar-overlay { display: none; position: fixed; z-index: 1150; inset: 0; background: rgba(20,35,20,.45); pointer-events: none; }
    body.hf-sidebar-open .hf-sidebar-overlay { display: block; pointer-events: auto; }
    .hf-main-with-sidebar { width: 100%; min-height: calc(100vh - 70px); margin: 0 !important; padding: 0 12px 12px !important; }
    .hf-guest-nav, .hf-admin-nav { gap: 8px; }
}

/* DARK THEME COMPATIBILITY */
body.dark .hf-sidebar { background: #202e23; border-color: #3a4b3b; }
body.dark .hf-sidebar-heading { background: #293c2b; border-color: #3a4b3b; }
body.dark .hf-sidebar-heading strong, body.dark .hf-side-link { color: #e0edda !important; }
body.dark .hf-sidebar-heading small, body.dark .hf-menu-label { color: #a3b49c; }
body.dark .hf-sidebar-avatar { background: #354837; }
body.dark .hf-side-link { background: #293c2b; border-color: #405441; border-bottom-color: #526b53; box-shadow: none; }
body.dark .hf-side-link:hover { background: #344c36; }
body.dark .hf-sidebar-logout button { background: #49302d; color: #ffc1b7; }
body.dark .hf-main-with-sidebar { color: #e5eee0; }

/* Success and error notifications */
.notice:not(.error) {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    margin: 16px 0;
    overflow-wrap: anywhere;
    background: #e2f5ff;
    color: #17628a;
    border: 2px solid #73c9ed;
    border-bottom: 5px solid #45a9d4;
    border-radius: 15px;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.6;
    box-shadow: 0 3px 0 rgba(45,145,190,.10);
    animation: farmNoticePop .3s ease-out;
}

.notice:not(.error)::before, .notice.error::before {
    content: "✓";
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 11px;
    background: #43b5df;
    color: white;
    font-size: 20px;
    font-weight: 900;
}

.notice.error::before { content: "!"; background: #e8796c; }

@keyframes farmNoticePop {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

body.dark .notice:not(.error) { background: #193d50; color: #c8efff; border-color: #367e9d; border-bottom-color: #45a9d4; }
body.dark .notice.error { background: #492a29; color: #ffd3ce; border-color: #a95a52; border-bottom-color: #df776b; }
.dark input, .dark select, .dark textarea { border-color: #405441; }

/* FARMZONE - 2D WOODEN HEADER */
.hf-topbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 1200 !important;
    isolation: isolate;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 12px;
    width: 100%;
    height: 80px;
    min-height: 80px;
    max-height: 80px;
    padding: 15px 22px 8px !important;

    background:
        radial-gradient(ellipse at 12% 35%, rgba(255,220,160,.16) 0 2px, transparent 3px),
        radial-gradient(ellipse at 72% 65%, rgba(65,32,13,.18) 0 3px, transparent 4px),
        repeating-linear-gradient(0deg, transparent 0 16px, rgba(73,38,18,.16) 17px 18px, transparent 19px 35px),
        repeating-linear-gradient(90deg, transparent 0 105px, rgba(255,221,170,.12) 106px 108px, transparent 109px 210px),
        linear-gradient(180deg, #d09a5e 0%, #b77b45 22%, #a66a3a 58%, #89532e 100%) !important;
    border: 0 !important;
    border-top: 4px solid #e8c58f !important;
    border-bottom: 5px solid #70452a !important;
    border-radius: 0 !important;
    box-shadow: inset 0 3px 0 rgba(255,255,255,.22), inset 0 -6px 0 rgba(65,35,15,.28), 0 5px 14px rgba(52,39,22,.28) !important;
}

.hf-topbar::before {
    content: "";
    position: absolute;
    z-index: 1;
    pointer-events: none;
    top: 0;
    left: 0;
    width: 100%;
    height: 19px;
    background:
        repeating-linear-gradient(78deg, transparent 0 5px, #4e9c2d 6px 8px, transparent 9px 12px),
        repeating-linear-gradient(105deg, transparent 0 7px, #a7df51 8px 10px, transparent 11px 15px),
        linear-gradient(180deg, #75bd3c 0%, #3d862a 100%);
    clip-path: polygon(0 0, 100% 0, 100% 65%, 97% 45%, 94% 90%, 91% 50%, 88% 85%, 85% 40%, 82% 90%, 79% 48%, 76% 95%, 73% 45%, 70% 85%, 67% 40%, 64% 90%, 61% 45%, 58% 85%, 55% 40%, 52% 95%, 49% 45%, 46% 85%, 43% 40%, 40% 90%, 37% 45%, 34% 90%, 31% 42%, 28% 88%, 25% 45%, 22% 90%, 19% 40%, 16% 85%, 13% 45%, 10% 90%, 7% 40%, 4% 85%, 0 50%);
}

.hf-topbar::after { content: none !important; display: none !important; }
.hf-topbar > * { position: relative; z-index: 4; }

.hf-topbar .brand {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 17px;
    border: 3px solid #f0d09a;
    border-radius: 9px;
    background: repeating-linear-gradient(0deg, transparent 0 12px, rgba(85,43,19,.10) 13px 14px), linear-gradient(180deg, #f8dfb0, #e0b77b 55%, #c58c51);
    color: #56351e !important;
    font-size: 23px;
    font-weight: 900;
    text-decoration: none !important;
    text-shadow: 0 1px 0 rgba(255,255,255,.5);
    box-shadow: 0 4px 0 #633c20, inset 0 2px 0 rgba(255,255,255,.5);
    transition: transform .2s, box-shadow .2s;
}

.hf-topbar .brand:hover { transform: translateY(-2px); box-shadow: 0 6px 0 #633c20, inset 0 2px 0 rgba(255,255,255,.5); }
.hf-top-actions { display: flex !important; align-items: center !important; justify-content: flex-end; flex-wrap: nowrap; gap: 9px !important; margin-left: auto; }

.hf-topbar .hf-top-button, .hf-topbar .hf-top-actions a {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 39px;
    padding: 8px 14px !important;
    border: 2px solid #f0d09a !important;
    border-radius: 8px !important;
    background: linear-gradient(180deg, #fff0ce, #e0b77b) !important;
    color: #58391f !important;
    font-size: 13px !important;
    font-weight: 900 !important;
    text-decoration: none !important;
    box-shadow: 0 3px 0 #603b20, inset 0 1px 0 rgba(255,255,255,.6) !important;
    cursor: pointer;
    transition: transform .15s, filter .15s;
}

.hf-topbar .hf-top-button:hover, .hf-topbar .hf-top-actions a:hover { filter: brightness(1.08); transform: translateY(-2px); }

.hf-topbar .hf-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 43px;
    min-height: 41px;
    padding: 5px 10px;
    margin: 0;
    border: 2px solid #f0d09a;
    border-radius: 8px;
    background: linear-gradient(180deg, #fff0ce, #e0b77b);
    color: #58391f;
    font-size: 22px;
    box-shadow: 0 3px 0 #603b20;
    cursor: pointer;
}

.hf-topbar .hf-menu-toggle:hover { transform: translateY(-2px); }

.hf-topbar .hf-guest-nav, .hf-topbar .hf-admin-nav { display: flex; align-items: center; flex-wrap: nowrap; gap: 8px; }
.hf-topbar .hf-guest-nav a, .hf-topbar .hf-admin-nav a, .hf-topbar .hf-admin-nav .link-button { padding: 8px 12px; border: 2px solid #e4c18d; border-radius: 8px; background: linear-gradient(180deg, #f6dfb3, #d3a66b); color: #57371e !important; font-size: 12px; font-weight: 900; text-decoration: none; box-shadow: 0 3px 0 #603b20; }

body.dark .hf-topbar, .dark .hf-topbar {
    background: repeating-linear-gradient(0deg, transparent 0 18px, rgba(0,0,0,.12) 19px 20px, transparent 21px 38px), linear-gradient(180deg, #755238, #5c3d29 55%, #422c20) !important;
    border-bottom: 5px solid #70452a !important;
}

body.dark .hf-topbar .brand, .dark .hf-topbar .brand { background: linear-gradient(180deg, #e7c28b, #bd8952); color: #402819 !important; }
body.dark .hf-topbar .hf-top-button, body.dark .hf-topbar .hf-top-actions a, body.dark .hf-topbar .hf-menu-toggle, .dark .hf-topbar .hf-top-button, .dark .hf-topbar .hf-top-actions a { background: linear-gradient(180deg, #dfbd8b, #b98b58) !important; color: #402819 !important; border-color: #e4c18d !important; }

/* SIDEBAR ALIGNED EXACTLY BELOW THE DESKTOP HEADER */
@media(min-width: 851px) {
    .hf-sidebar {
        top: 80px !important;
        bottom: 0 !important;
        height: calc(100vh - 80px) !important;
    }
}

@media(max-width: 850px) {
    .hf-topbar {
        height: auto;
        min-height: 70px;
        max-height: none;
        flex-wrap: wrap;
        padding: 12px 12px 8px !important;
        gap: 8px;
    }

    .hf-topbar .brand { padding: 7px 10px; font-size: 18px; }
    .hf-top-actions { gap: 6px !important; flex-wrap: wrap; }
    .hf-topbar .hf-top-button, .hf-topbar .hf-top-actions a { min-height: 35px; padding: 6px 9px !important; font-size: 11px !important; }
    .hf-topbar .hf-menu-toggle { min-width: 38px; min-height: 36px; font-size: 20px; }
    .hf-topbar .hf-guest-nav, .hf-topbar .hf-admin-nav { flex-wrap: wrap; }
    .hf-sidebar { top: 0 !important; height: 100vh !important; }
    .hf-topbar::before { height: 16px; }
    .hf-topbar::after { content: none !important; display: none !important; }
}

@media(max-width: 380px) {
    .hf-topbar { gap: 6px; padding-left: 8px !important; padding-right: 8px !important; }
    .hf-topbar .brand { font-size: 15px; padding: 7px 8px; }
    .hf-topbar .hf-top-button, .hf-topbar .hf-top-actions a { padding: 6px 7px !important; font-size: 10px !important; }
}

/* Activation box */
.fz-home-activation { width: 100%; max-width: 680px; margin: 25px auto 0; padding: 25px 22px; text-align: center; background: linear-gradient(135deg, #f7fbea, #eaf5df); border: 2px solid #cfe4bd; border-bottom: 5px solid #a9cf8f; border-radius: 18px; box-shadow: 0 5px 14px rgba(60, 105, 45, .10); }
.fz-home-activation .fz-home-heading { margin: 0 0 13px; color: #315f35; font-size: 22px; font-weight: 900; }
.fz-home-one-time { display: inline-block; margin: 0 0 13px; padding: 7px 16px; border: 1px solid #b8dca8; border-radius: 30px; background: #e1f2d7; color: #347443; font-size: 12px; font-weight: 900; letter-spacing: .4px; }
.fz-home-activation h3 { margin: 0 0 10px; color: #285c38; font-size: 23px; font-weight: 900; }
.fz-home-activation p { max-width: 560px; margin: 0 auto; color: #68786a; font-size: 14px; line-height: 1.8; }
body.dark .fz-home-activation { background: linear-gradient(135deg, #243b2a, #2d4932); border-color: #456349; border-bottom-color: #638b58; }
body.dark .fz-home-activation .fz-home-heading, body.dark .fz-home-activation h3 { color: #c7efb4; }
body.dark .fz-home-one-time { background: #314b39; border-color: #567a51; color: #d7f2dc; }
body.dark .fz-home-activation p { color: #c1d2bd; }

/* FARM MARKETPLACE */
.farm-marketplace { width: 100%; max-width: 1200px; margin: 0 auto; color: #344b32; }
.farm-marketplace .panel { background: #ffffff; border: 1px solid #d9e3d5; border-radius: 6px; box-shadow: none; padding: 18px; margin: 16px 0; }
.farm-marketplace .stat { background: #ffffff; border: 1px solid #d9e3d5; border-radius: 6px; box-shadow: none; padding: 15px; margin: 0; }
.farm-marketplace .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.farm-marketplace h1 { font-size: 25px; margin-bottom: 18px; color: #315d38; }
.farm-marketplace h2 { font-size: 19px; margin-top: 0; color: #315d38; border-bottom: 1px solid #e5ebe2; padding-bottom: 10px; }
.farm-marketplace h3 { font-size: 16px; margin: 8px 0; color: #344b32; }
.farm-marketplace .animal { font-size: 30px; margin-bottom: 8px; }
.farm-marketplace input, .farm-marketplace select, .farm-marketplace textarea { border: 1px solid #cbd8c7; border-radius: 4px; padding: 10px; background: #ffffff; box-shadow: none; }
.farm-marketplace input:focus, .farm-marketplace select:focus, .farm-marketplace textarea:focus { border-color: #398b43; box-shadow: none; }
.farm-marketplace button, .farm-marketplace .btn { background: #398b43; color: #ffffff; border: 1px solid #287438; border-radius: 4px; box-shadow: none; padding: 10px 14px; font-size: 13px; font-weight: 700; transition: background .15s ease; }
.farm-marketplace button:hover, .farm-marketplace .btn:hover { background: #287438; transform: none; filter: none; }
.farm-marketplace button.secondary, .farm-marketplace .btn.secondary { background: #68766b; border-color: #59665c; box-shadow: none; }
.farm-marketplace table { border: 1px solid #d9e3d5; border-radius: 4px; box-shadow: none; }
.farm-marketplace th { background: #edf4e9; color: #315d38; }
.farm-marketplace td, .farm-marketplace th { padding: 11px; border-bottom: 1px solid #e5ebe2; }
.farm-marketplace .notice { border-radius: 4px; box-shadow: none; }
.farm-marketplace .muted { color: #78857a; font-size: 12px; }
.farm-marketplace .table-wrap { overflow-x: auto; max-width: 100%; }
body.dark .farm-marketplace { color: #e5eee0; }
body.dark .farm-marketplace .panel, body.dark .farm-marketplace .stat { background: #243b2a; border-color: #456349; color: #edf5e8; }
body.dark .farm-marketplace h1, body.dark .farm-marketplace h2, body.dark .farm-marketplace h3 { color: #c7efb4; }
body.dark .farm-marketplace input, body.dark .farm-marketplace select, body.dark .farm-marketplace textarea { background: #17291d; color: #edf5e8; border-color: #456349; }
body.dark .farm-marketplace table { background: #243b2a; color: #edf5e8; }
body.dark .farm-marketplace th { background: #34523a; color: #edf5e8; }
body.dark .farm-marketplace td, body.dark .farm-marketplace th { border-color: #456349; }

/* RESPONSIVE LAYOUT */
@media(max-width: 640px) {
    header nav { display: flex; gap: 7px; flex-wrap: wrap; }
    header nav a { margin: 2px 5px; }
    .panel { padding: 14px; }
    table { display: block; overflow-x: auto; }
    .brand { font-size: 21px; }
    .panel, .stat { border-radius: 14px; padding: 14px; }
    .daily-rewards-dropdown { position: static; }
    .daily-rewards-menu { position: absolute; left: 10px; right: 10px; min-width: 0; }
}

@media(max-width: 700px) {
    header { align-items: flex-start; }
    nav { display: flex; flex-wrap: wrap; gap: 7px; }
    header a { margin: 0 7px 0 0; }

    main { margin: 14px auto; padding: 0 10px; }

    .grid { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 9px; }
    .stat { padding: 13px; }
    .stat strong { font-size: 21px; }
    .cartoon-dashboard { padding: 0 8px 8px; }
    .cartoon-welcome { min-height: 185px; padding: 20px; border-radius: 21px; }
    .cartoon-welcome h1 { font-size: 25px; }
    .cartoon-welcome p { max-width: 230px; font-size: 12px; }
    .welcome-character { position: absolute; right: 0; bottom: 0; width: 125px; height: 125px; opacity: .85; }
    .welcome-chicken { left: 0; font-size: 69px; }
    .welcome-sun { right: 12px; font-size: 36px; }
    .welcome-flower { right: 0; font-size: 34px; }
    .cartoon-stats { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
    .cartoon-stat { padding: 11px; gap: 8px; border-radius: 15px; }
    .stat-picture { width: 39px; height: 39px; font-size: 22px; }
    .cartoon-stat strong { font-size: 15px; }
    .cartoon-stat small { font-size: 9px; }
    .cartoon-farm { min-height: 365px; }
    .farm-land { top: 155px; }
    .farm-house { left: 39%; transform: scale(.8); }
    .scene-animals { left: 5%; right: 5%; bottom: 35px; }
    .scene-tree { font-size: 43px; }
    .scene-crops { font-size: 15px; }
    .scene-fence { font-size: 15px; }
    .cartoon-action-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
    .cartoon-action { min-height: 145px; padding: 13px; }
    .cartoon-action strong { font-size: 15px; }
    .cartoon-reward-banner { flex-wrap: wrap; gap: 12px; padding: 15px; }
    .reward-character { width: 52px; height: 52px; font-size: 29px; }
    .cartoon-reward-banner h2 { font-size: 16px; }
    .cartoon-reward-banner > a { width: 100%; text-align: center; }
    .cartoon-inventory-grid { grid-template-columns: 1fr; }
    .cartoon-section-title h2 { font-size: 19px; }
    .fz-home-activation { margin-top: 20px; padding: 21px 15px; border-radius: 15px; }
    .fz-home-activation .fz-home-heading { font-size: 20px; }
    .fz-home-activation h3 { font-size: 21px; }
    .fz-home-activation p { font-size: 13px; }
    .farm-marketplace .panel { padding: 13px; }
    .farm-marketplace .grid { grid-template-columns: 1fr; }
}

@media(max-width: 380px) {
    .cartoon-action-grid { gap: 8px; }
    .cartoon-action { padding: 11px; }
    .cartoon-wallet-grid, .cartoon-price-grid { grid-template-columns: 1fr; }
    .cartoon-stat { padding: 9px; }
}

@media(prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}

/* FINAL LAYOUT GAP FIX */
.hf-main-with-sidebar {
    display: flow-root !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.hf-main-with-sidebar > :first-child {
    margin-top: 0 !important;
}

.hf-main-with-sidebar > .cartoon-dashboard {
    display: block;
    margin: 0 auto !important;
    padding-top: 0 !important;
}

@media(min-width: 851px) {
    .hf-topbar {
        height: 80px !important;
        min-height: 80px !important;
        max-height: 80px !important;
        flex-wrap: nowrap !important;
    }

    .hf-sidebar {
        top: 80px !important;
        height: calc(100vh - 80px) !important;
    }
}

@media(max-width: 850px) {
    .hf-topbar {
        height: auto !important;
        min-height: 70px !important;
        max-height: none !important;
        flex-wrap: wrap !important;
    }

    .hf-main-with-sidebar {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    .hf-main-with-sidebar > .cartoon-dashboard {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
}


/* FINAL SPACING: small gap below the top navigation bar */
.hf-main-with-sidebar {
    padding-top: 12px !important;
}

@media (max-width: 850px) {
    .hf-main-with-sidebar {
        padding-top: 12px !important;
    }
}
