.farm-panel {
    position: absolute;
    inset: 0;
    z-index: 100;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: #2fa8b7;
}

.farm-close-btn {
    position: absolute;
    width: 32px;
    height: 32px;
    border: none;
    padding: 0;
    background: transparent;
    z-index: 2000;
    cursor: pointer;
    top: 8px;
    right: 8px;
}
.farm-close-btn img { width: 100%; height: 100%; object-fit: contain; }

.farm-rank-btn {
    position: absolute;
    width: 42px;
    height: 42px;
    border: none;
    padding: 0;
    background: transparent;
    z-index: 2000;
    cursor: pointer;
    top: 48px;
    right: 8px;
}
.farm-rank-btn img { width: 100%; height: 100%; object-fit: contain; }

.farm-record-btn {
    position: absolute;
    width: 42px;
    height: 42px;
    border: none;
    padding: 0;
    background: transparent;
    z-index: 2000;
    cursor: pointer;
    top: 102px;
    right: 8px;
}
.farm-record-btn img { width: 100%; height: 100%; object-fit: contain; }

.farm-dog-btn {
    position: absolute;
    width: 42px;
    height: 42px;
    border: none;
    padding: 0;
    background: transparent;
    z-index: 2000;
    cursor: pointer;
    top: 156px;
    right: 8px;
}
.farm-dog-btn img { width: 100%; height: 100%; object-fit: contain; }

.farm-main-view {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 100;
}

.farm-crop-select-view {
    position: absolute;
    inset: 0;
    z-index: 2000;
    display: none;
    background: rgb(0 0 0 / 80%);
    overflow: hidden;
    touch-action: none;
    overscroll-behavior: none;
    align-items: center;
    justify-content: center;
}

/* ===== Top Bar ===== */
.farm-top-bar {
    position: absolute;
    top: 20px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 2000;
    pointer-events: none;
}

.farm-top-stat {
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    background-color: #000000a3;
    padding: 2px 8px;
    border-radius: 4px;
    pointer-events: auto;
    white-space: nowrap;
}

.farm-top-stat.gold { color: #ffd54f; }

.farm-other-top-bar {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    pointer-events: none;
    white-space: nowrap;
    background-color: #000000cf;
    padding: 5px 15px;
    border-radius: 6px;
}
.farm-other-player-name {
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    text-shadow: 0 0 8px #00000080;
}

.farm-body {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.farm-wrap {
    position: absolute;
    inset: 0;
    overflow: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    overscroll-behavior: none;
}
.farm-wrap::-webkit-scrollbar { display: none; }

.farm-map {
    position: relative;
}

.farm-cell {
    position: absolute;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.farm-cell-bg {
    pointer-events: none;
    display: block;
}

.farm-cell-lock {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    z-index: 3;
    pointer-events: none;
}

.farm-cell-dog {
    position: absolute;
    top: 0px;
    right: 36px;
    height: 58px;
    width: auto;
    z-index: 4;
    pointer-events: none;
    object-fit: contain;
}

.farm-cell-overlay {
    position: absolute;
    width: 70%;
    bottom: 60%;
    left: 50%;
    z-index: 2;
    pointer-events: none;
    object-fit: contain;
    transform: translateX(-50%);
}

.farm-cell.s3{
    animation: diamondPulse 2s ease-in-out infinite;
}

@keyframes diamondPulse { 0%,100%{filter:brightness(1.3)saturate(1)} 50%{filter:brightness(0.7)saturate(1)} }

.farm-progress-bar {
    position: absolute;
    bottom: 50%;
    left: 30%;
    width: 40%;
    height: 6px;
    background: #333;
    border-radius: 3px;
    overflow: hidden;
    z-index: 5;
}

.farm-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4caf50, #8bc34a);
    border-radius: 3px;
    transition: width 0.3s;
}

.farm-cell.s0 {
    filter: brightness(0.7) saturate(1);
    cursor: pointer;
}
.farm-cell.s1 { filter: brightness(1) saturate(1); cursor: pointer; }
.farm-cell.s2 { filter: brightness(1) saturate(1); }
.farm-cell.s3 { filter: brightness(1) saturate(1); cursor: pointer; }

/* ===== Footer Toolbar ===== */
.farm-footer {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 10px;
    bottom: 35px;
    z-index: 1000;
    left: 0;
    right: 0;
    flex-wrap: wrap;
}

.farm-bottom-btn {
    width: 54px;
    height: 54px;
    border: none;
    padding: 0;
    background: transparent;
    cursor: pointer;
    transition: transform 0.15s;
}
.farm-bottom-btn:active { transform: scale(0.9); }
.farm-bottom-btn img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }

.farm-cooldown-text {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    text-align: center;
    color: #ffd54f;
    font-size: 12px;
    font-weight: 700;
    background-color: #000000a3;
    padding: 2px 0px;
    border-radius: 4px;
    display: none;
    z-index: 1001;
    pointer-events: none;
}
.farm-cooldown-text.visible { display: block; }

/* ===== Crop Select View ===== */
.farm-crop-list {
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 16px;
    scrollbar-width: none;
    touch-action: pan-y;
    overscroll-behavior: contain;
}
.farm-crop-list::-webkit-scrollbar { display: none; }

.farm-crop-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding:15px;
}

.farm-crop-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    border-radius: 10px;
    background: #2d1f14c9;
    border: 2px solid rgb(212 163 0);
    cursor: pointer;
    transition: border-color 0.2s;
}
.farm-crop-item:active { border-color: #ffd700; }
.farm-crop-item.locked { position: relative; }
.farm-crop-item.locked .farm-crop-icon-big { filter: brightness(0.7) saturate(1); }

.farm-crop-icon-big {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin-bottom: 6px;
}

.farm-crop-name {
    font-size: 16px;
    font-weight: 700;
    color: #ffe7a8;
    text-align: center;
}

.farm-crop-adv {
    font-size: 13px;
    color: #81c784;
    text-align: center;
}

.farm-crop-lock-info {
    font-size: 12px;
    color: #e57373;
    text-align: center;
    margin-top: 2px;
}

.farm-crop-lock-icon {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 24px;
    height: 24px;
    z-index: 5;
    pointer-events: none;
}

/* ===== Build View ===== */
.farm-build-view {
    position: absolute;
    inset: 0;
    z-index: 500;
    padding: 60px 25px 45px 25px;
    background-color: #00000085;
    backdrop-filter: blur(10px);
    flex-direction: column;
}

.farm-build-tabs {
    flex: 0 0 40px;
    display: flex;
    margin-top: 10px;
    gap: 6px;
}

.farm-build-tab-btn {
    flex: 1;
    border: none;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    height: 80%;
    position: relative;
    max-height:32px;
}
.farm-build-tab-btn.btn_on {
}
.farm-build-tab-btn.btn_off {
}
.farm-build-tab-btn.btn_off:active { background: #5a4018; }

.farm-build-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}

.farm-build-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0px 0px 6px 0px;
    border-radius: 8px;
    background: #6f4500c9;
    border: 1px solid rgb(241 194 0 / 0%);
    cursor: pointer;
    transition: border-color 0.2s;
    gap: 2px;
    position: relative;
}
.farm-build-item:active { border-color: #ffd700; }
.farm-build-item.disabled { cursor: not-allowed; filter: brightness(0.5); }
.farm-build-item.disabled:active { border-color: rgb(212 163 0 / 60%); }

.farm-build-item-icon {
    width: 54px;
    height: 54px;
    object-fit: contain;
}

.farm-build-item-name {
    font-size: 14px;
    font-weight: 700;
    color: #ffe7a8;
    text-align: center;
    width: 100%;
    background-color: #0000003d;
    border-top-right-radius: 6px;
    border-top-left-radius: 6px;
}

.farm-build-item-info {
    font-size: 11px;
    color: #aed581;
    text-align: center;
}

.farm-build-lock-icon {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    z-index: 5;
    pointer-events: none;
}

/* ===== Detail View (共用于建设/集市/记录) ===== */
.farm-build-detail-view {
    position: absolute;
    inset: 0;
    z-index: 2500;
    display: none;
    background: rgba(0,0,0,0.85);
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.farm-build-body {
    flex: 1;
    overflow-y: auto;
    padding: 0px 10px;
    scrollbar-width: none;
    overscroll-behavior: contain;
    touch-action: pan-y;
}
.farm-build-body::-webkit-scrollbar { display: none; }

.farm-build-detail-body {
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow-y: auto;
    padding: 60px 30px 30px 30px;
    scrollbar-width: none;
}
.farm-build-detail-body::-webkit-scrollbar { display: none; }

.farm-detail-top-info {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    padding: 12px;
    border-radius: 8px;
    background: #2d1f14c9;
    border: 1px solid rgb(212 163 0 / 40%);
}

.farm-detail-top-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}

.farm-detail-top-icon {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.farm-detail-top-name {
    font-size: 16px;
    font-weight: 700;
    color: #ffe7a8;
}

.farm-detail-top-right {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.farm-detail-top-stat {
    font-size: 13px;
    color: #e0d5c1;
}

.farm-detail-section {
    margin-bottom: 15px;
    padding: 0px 0px 5px 5px;
    border-radius: 8px;
    background: #2d1f14c9;
    border: 1px solid rgb(212 163 0 / 40%);
}

.farm-detail-section-title {
    font-size: 15px;
    font-weight: 700;
    color: #ffbf18;
    margin-bottom: 10px;
    text-align: left;
    background-color: #00000033;
    padding: 4px;
    border-radius: 4px;
}

.farm-detail-split {
    display: flex;
    gap: 2px;
}

.farm-detail-left {
    flex: 5;
}

.farm-detail-right {
    flex: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.farm-detail-stat-row {
    font-size: 13px;
    color: #e0d5c1;
    padding: 3px 0;
}

.farm-detail-stat-label {
    color: #c4ad7a;
}

.farm-detail-stat-value {
    color: #ffffff;
    font-weight: 700;
}

.farm-detail-stat-next {
    color: #4caf50;
    font-weight: 700;
}

.farm-detail-cost-row {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    color: #e0d5c1;
}

.farm-detail-cost-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
}
.farm-detail-btn.btn_off {
    border: 0;
}

.farm-detail-cost-num {
    color: #ffffff;
    font-weight: 700;
}

.farm-detail-btn {
    border: none;
    padding: 3px 0px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s;
    width: 100%;
    text-align: center;
    max-width: 70px;
    min-width: 60px;
}
.farm-detail-btn:active { transform: scale(0.95); }
.fd-btn-disabled {
    filter: brightness(0.5) grayscale(0.6);
    cursor: not-allowed;
    color: #888;
}

.farm-detail-checkbox-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 13px;
    color: #e0d5c1;
    justify-content: center;
}
.farm-detail-checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ===== 市场/排行榜/记录列表 ===== */
.farm-rank-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.farm-rank-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 6px;
    background: #2d1f14c9;
    border: 1px solid rgb(212 163 0 / 30%);
    font-size: 13px;
    color: #e0d5c1;
}
.farm-rank-rank {
    color: #ffbf18;
    font-weight: 700;
    min-width: 30px;
}
.farm-rank-name {
    flex: 1;
    margin-left: 8px;
}
.farm-rank-score {
    color: #ffffff;
    font-weight: 700;
}

/* ===== 协助/偷菜按钮 ===== */
.farm-assist-btn, .farm-steal-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s;
}
.farm-assist-btn { background: #4caf50; color: #fff; }
.farm-steal-btn { background: #f44336; color: #fff; }
.farm-assist-btn:active, .farm-steal-btn:active { transform: scale(0.95); }

/* ===== 记录列表 ===== */
.farm-record-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0;
}
.farm-record-item {
    display: flex;
    padding: 8px 12px;
    border-radius: 6px;
    background: #2d1f14c9;
    border: 1px solid rgb(212 163 0 / 30%);
    font-size: 13px;
    color: #e0d5c1;
    position: relative;
    min-height: 56px;
}
.farm-record-left {
    flex: 0 0 25%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.farm-record-right {
    flex: 0 0 75%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-left: 8px;
    box-sizing: border-box;
    position: relative;
}
.farm-record-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}
.farm-record-avatar-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #333;
}
.farm-record-frame {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    pointer-events: none;
    object-fit: cover;
}
.farm-record-text {
    flex: 1;
    min-width: 0;
    padding-right: 70px;
}
.farm-record-time {
    color: #c4ad7a;
    font-size: 11px;
    margin-top: 2px;
}
.farm-record-steal-btn.btn_off {
    position: absolute;
    bottom: 6px;
    right: 8px;
    border: 0;
    cursor: pointer;
}

/* ===== 狗窝列表 ===== */
.farm-dog-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 15px 0;
}

.farm-dog-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0px;
    border-radius: 10px;
    background: #2d1f14c9;
    border: 1px solid rgb(212 163 0 / 40%);
    gap: 4px;
    position: relative;
}

.farm-dog-icon-wrap {
    width: 72px;
    height: 72px;
    cursor: pointer;
    position: relative;
    padding:6px;
}

.farm-dog-icon-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.farm-dog-name {
    font-size: 14px;
    font-weight: 700;
    color: #ffe7a8;
    text-align: center;
}

.farm-dog-level {
    font-size: 11px;
    color: #81c784;
    text-align: center;
}

.farm-dog-stat-row {
    font-size: 11px;
    color: #e0d5c1;
    text-align: center;
    width: 100%;
}

.farm-dog-stat-label {
    color: #c4ad7a;
}

.farm-dog-upgrade-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    width: 100%;
    margin-top: 2px;
}

.farm-dog-upgrade-cost-icon {
    height: 18px;
    object-fit: contain;
}

.farm-dog-upgrade-cost-text {
    font-size: 10px;
    color: #e0d5c1;
}

.farm-dog-upgrade-btn {
    border: 0;
    padding: 2px 0px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    min-width: 40px;
    text-align: center;
}

/* 狗描述提示框 */
.farm-dog-desc-tip {
    position: fixed;
    z-index: 9999;
    max-width: 200px;
    padding: 8px 12px;
    border-radius: 8px;
    background: #1a1a1a;
    border: 1px solid rgb(212 163 0 / 50%);
    color: #e0d5c1;
    font-size: 12px;
    line-height: 1.5;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

/* ===== 市场/建设/记录 弹框覆盖层拉伸保护 ===== */
#farm-market-view, #farm-build-view, #farm-record-view,
#farm-market-detail-view, #farm-build-detail-view {
    overflow: hidden;
    touch-action: none;
    overscroll-behavior: none;
}
/* 记录弹框内部列表允许纵向滑动，防止事件冒泡到底层 */
#farm-record-view .farm-rank-body {
    touch-action: pan-y;
    overscroll-behavior: contain;
}

/* ===== 市场详情头像网格 ===== */
.fmd-avatar-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
    max-width: 180px;
}
.fmd-avatar-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgb(212 163 0 / 40%);
}

/* ===== 详情导航按钮 ===== */
.farm-detail-nav {
    position: absolute;
    bottom: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    z-index: 160;
}
.farm-detail-nav img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    display: block;
}
.farm-detail-nav-left {
    left: 2px;
}
.farm-detail-nav-left img {
    transform: rotate(180deg);
}
.farm-detail-nav-right {
    right: 2px;
}
