/* games/pvz/css/style.css */
:root {
    --pvz-green: #4CAF50;
    --pvz-brown: #795548;
    --pvz-bg: #8BC34A; /* Grass Light */
    --pvz-bg-dark: #689F38; /* Grass Dark */
}

body {
    margin: 0; padding: 0; background-color: #111;
    font-family: 'Fredoka', sans-serif; min-height: 100vh;
    display: flex; justify-content: center; align-items: center;
    overflow: hidden; user-select: none;
}
.game-layout-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 20px;
}

[v-cloak] { display: none; }

#game-app {
    position: relative;
    width: 920px;
    height: 600px;
    background: #222; /* Fallback */
    overflow: hidden;
    box-shadow: 0 0 40px rgba(0,0,0,0.9);
    border: 5px solid #2E7D32;
}

/* Custom Scrollbar - Gọn và đẹp hơn */
#game-app *::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
#game-app *::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}
#game-app *::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--pvz-green), var(--pvz-bg-dark));
    border-radius: 10px;
    border: 1px solid #1B5E20;
}
#game-app *::-webkit-scrollbar-thumb:hover {
    background: #8BC34A;
}
#game-app *::-webkit-scrollbar-corner {
    background: transparent;
}
/* Ẩn các nút mũi tên thô kệch */
#game-app *::-webkit-scrollbar-button {
    display: none;
}

.game-bg {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover; background-position: center;
    z-index: 1; pointer-events: none;
}

.canvas-container {
    position: absolute; top: 0; left: 0; z-index: 10;
    width: 100%; height: 100%;
}
canvas {
    display: block; width: 100%; height: 100%; cursor: crosshair;
    image-rendering: -webkit-optimize-contrast; /* Giúp đồ họa sắc nét hơn trên phone */
}

/* Side HUD (Dọc bên trái) - Giống mẫu của sếp */
.side-hud {
    position: absolute; top: 0; left: 0; bottom: 0; width: 115px;
    background: rgba(46, 125, 50, 0.5); border-right: 4px solid #1B5E20;
    z-index: 50; display: flex; flex-direction: column; align-items: center; padding: 0;
    backdrop-filter: blur(5px);
    touch-action: pan-y;
}
.system-controls-box {
    width: 100%;
    background: #3e2723;
    padding: 6px 4px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border-bottom: 3px solid #1B5E20;
    box-sizing: border-box;
    margin-bottom: 8px;
}
.sys-btn-sm {
    width: 100%;
    min-width: auto; /* Ghi đè class cha */
    padding: 3px 2px;
    font-size: 10px;
    font-weight: bold;
    color: white;
    border: 1px solid #2e1b1b;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 2px 0 rgba(0,0,0,0.4);
    transition: transform 0.1s;
    font-family: 'Fredoka', sans-serif;
    text-align: center;
    white-space: nowrap;
}
.menu-btn-sm { 
    background: #5d4037; 
    border-color: #3e2723;
}
.btn-auto-sm { 
    background: #795548; 
    opacity: 0.7;
    pointer-events: none;
}
.btn-auto-sm.affordable {
    background: #FF9800;
    opacity: 1;
    pointer-events: auto;
    animation: pulse 1.5s infinite;
}
.btn-auto-sm.active {
    background: #4CAF50;
    opacity: 1;
    pointer-events: none;
}
.sys-btn-sm:active { transform: translateY(2px); box-shadow: none; }

.sun-box {
    background: #FFEB3B; border: 3px solid #FBC02D; border-radius: 12px;
    width: 85px; height: 85px; display: flex; flex-direction: column; justify-content: center; align-items: center;
    box-shadow: 0 4px 0 #F57F17; margin-bottom: 8px;
}
/* Fury Bar */
.fury-bar-container {
    height: 12px;
    background: rgba(0,0,0,0.5);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    border: 1px solid #ff5722;
    margin-top: 5px;
}
.fury-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff9800, #ff5722);
    transition: width 0.3s ease;
    box-shadow: 0 0 10px #ff5722;
}
.fury-text {
    position: absolute;
    top: 0; left: 0; width: 100%;
    font-size: 10px;
    color: white;
    text-align: center;
    line-height: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 2px black;
}
.frenzy {
    animation: frenzy-shimmer 0.5s infinite alternate;
}
@keyframes frenzy-shimmer {
    from { box-shadow: 0 0 5px red; border-color: #ffc107; }
    to { box-shadow: 0 0 20px red; border-color: #f44336; }
}

/* Meteor Skill */
.meteor-container {
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, #ff5722, #b71c1c);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border: 3px solid #3e2723;
    color: white;
    font-size: 24px;
    transition: all 0.2s;
    margin-bottom: 10px;
    position: relative;
}
.meteor-container:hover:not(.disabled) { transform: scale(1.1); filter: brightness(1.2); }
.meteor-container.selected { border-color: #ffeb3b; box-shadow: 0 0 15px #ffeb3b; animation: pulse 0.8s infinite; }
.meteor-container.disabled { opacity: 0.5; filter: grayscale(1); cursor: not-allowed; }
/* Selection Screen */
.selection-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 10px;
    max-height: 320px; /* Ép cứng chiều cao để hiện thanh cuộn */
    overflow-y: auto;
    padding: 5px;
    background: #4E342E; /* Nền khu vực thẻ */
    border-radius: 8px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}
.selection-item {
    background: rgba(0,0,0,0.3);
    border: 3px solid #3e2723;
    border-radius: 8px;
    padding: 10px 5px; /* Thu gọn padding cho vừa màn hình */
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}
.selection-item i { font-size: 32px; margin-bottom: 10px; }
.selection-item .name { font-size: 10px; font-weight: bold; color: #eee; }
.selection-item .cost { 
    position: absolute; top: 5px; right: 5px; 
    background: #FFEB3B; color: #333; font-size: 10px; 
    padding: 0 4px; border-radius: 5px; font-weight: bold;
}
.selection-item:hover { background: rgba(255,255,255,0.1); transform: scale(1.05); }
.selection-item.selected { border-color: #FFEB3B; box-shadow: 0 0 15px rgba(255,235,59,0.5); background: rgba(76, 175, 80, 0.2); }
.selection-item.selected::after {
    content: "\f00c"; font-family: "Font Awesome 5 Free"; font-weight: 900;
    position: absolute; top: -10px; left: -10px;
    background: #4CAF50; color: white; width: 25px; height: 25px;
    border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 14px;
}

/* Tooltip Custom Global */
.global-card-tooltip {
    position: absolute;
    width: 150px;
    background: rgba(30, 30, 30, 0.95);
    color: #FFEB3B;
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #FFEB3B;
    box-shadow: 0 4px 15px rgba(0,0,0,0.8);
    pointer-events: none; /* Không block chuột */
    z-index: 9999; /* Đảm bảo nằm trên mọi Modal */
    transition: none; /* Tọa độ chuột nhảy frame tốt hơn */
}
.global-card-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: #FFEB3B transparent transparent transparent;
}

.sun-icon-bg { font-size: 36px; color: #FBC02D; text-shadow: 0 0 10px white; }
.sun-value { font-size: 22px; font-weight: 900; color: #333; }

.seed-sidebar {
    display: flex; flex-direction: column; gap: 8px; width: 100%; align-items: center; flex: 1; overflow-y: auto;
}

.seed-slot {
    position: relative; width: 90px; height: 70px; background: #D7CCC8; border: 3px solid #5D4037;
    border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center;
    justify-content: center; box-shadow: inset 0 0 10px rgba(0,0,0,0.2); transition: 0.2s;
}
.seed-slot:not(.can-buy) { filter: grayscale(1) brightness(0.6); }
.seed-slot.active { border-color: #FFEB3B; box-shadow: 0 0 15px #FFEB3B; transform: translateX(5px); }

.slot-price { position: absolute; bottom: 2px; right: 4px; font-size: 14px; font-weight: 900; color: #000; z-index: 5; }
.slot-graphic { font-size: 35px; text-shadow: 1px 1px 2px white; z-index: 3; }
.cd-mask { position: absolute; bottom: 0; left: 0; width: 100%; height: 0; background: rgba(0,0,0,0.7); z-index: 4; }

.shovel-container {
    width: 75px; height: 75px; background: #607D8B; border: 4px solid #37474F; border-radius: 50%;
    display: flex; justify-content: center; align-items: center; font-size: 35px; color: white;
    cursor: pointer; margin-top: 15px; box-shadow: 0 5px 0 #263238; transition: 0.2s;
}
.shovel-container.selected { background: #FF5252; border-color: #B71C1C; animation: pulse-red 1s infinite; }

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(244, 67, 54, 0); }
    100% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0); }
}

.menu-btn {
    background: #5D4037; border: 3px solid #3e2723; color: white; font-weight: 800; cursor: pointer; border-radius: 8px; padding: 10px 20px; font-size: 18px; z-index: 50; box-shadow: 0 4px 0 #2e1b1b; transition: 0.2s;
}
.menu-btn:hover { background: #795548; transform: translateY(-2px); }

/* Modals */
.pvz-modal {
    position: absolute; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.7); z-index: 100;
    display: flex; justify-content: center; align-items: stretch; /* Stretching để căn padding trên dưới */
    padding: 2vh 0; box-sizing: border-box;
}
.pvz-modal-content {
    background-color: #5d4037; border: 4px solid #3e2723; border-radius: 12px;
    padding: 15px; text-align: center; color: white; min-width: 300px;
    max-width: 90vw; width: 630px; max-height: 96vh;
    display: flex; flex-direction: column; margin: auto; /* Centralize */
    box-sizing: border-box; overflow: hidden;
    transform: scale(0.85); /* Thu nhỏ toàn bộ Modal để vừa màn hình laptop */
    transform-origin: center center;
}
.pvz-modal-content h2 { margin: 0 0 10px 0; color: #ffeb3b; font-size: 24px; text-shadow: 2px 2px 0 #000; flex-shrink: 0; }
.pvz-btn {
    display: block; width: 100%; margin: 5px 0; padding: 10px; background: #8BC34A; color: white; border: 2px solid #33691E; font-size: 18px; font-weight: bold; font-family: 'Fredoka', sans-serif; border-radius: 8px; cursor: pointer; text-decoration: none; flex-shrink: 0;
}
.pvz-btn:hover { background: #7CB342; transform: scale(1.02); }
.btn-quit { background: #F44336; border-color: #b71c1c; }
.btn-quit:hover { background: #e53935; text-decoration: none; color: white; }

/* Rotate Warning - Luôn che phủ khi portrait */
.rotate-warning {
    display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; 
    background: #222; color: white; z-index: 99999; 
    flex-direction: column; justify-content: center; align-items: center; 
    font-size: 24px; text-align: center; padding: 20px; box-sizing: border-box;
}
.rotate-warning i { font-size: 60px; margin-bottom: 20px; animation: rotatePhone 2s infinite ease-in-out; }

/* Level Progress Bar */
.level-progress-container {
    position: absolute; bottom: 15px; right: 20px; z-index: 20;
    width: 350px; text-align: right;
}
.progress-text {
    font-size: 14px; color: white; margin-bottom: 5px; font-weight: bold; text-shadow: 1px 1px 2px black;
}
.progress-bar-bg {
    width: 100%; height: 20px; background: rgba(0,0,0,0.5); border: 2px solid #5d4037; border-radius: 10px; position: relative; overflow: visible;
}
.progress-bar-fill {
    height: 100%; background: linear-gradient(90deg, #4CAF50, #8BC34A); border-radius: 8px; width: 0%; transition: width 0.3s;
}
.zombie-head-icon {
    position: absolute; top: -10px; transform: translateX(-50%);
    font-size: 24px; color: #9E9E9E; text-shadow: 0 0 5px black; z-index: 2; transition: left 0.3s;
}
.boss-icon {
    position: absolute; right: -15px; top: -15px; font-size: 30px; color: #F44336; text-shadow: 0 0 5px black;
}

/* Top Right Controls */
.top-right-controls {
    position: absolute; top: 10px; right: 10px; z-index: 50; display: flex; gap: 10px; align-items: center; flex-direction: row;
}

.sys-btn {
    background: #a9834f; border: 2px solid #6c4e31; color: white; font-weight: bold; cursor: pointer; border-radius: 5px; padding: 10px 15px; font-size: 16px; box-shadow: 0 4px 6px rgba(0,0,0,0.5); transition: all 0.2s; min-width: 140px; text-align: left;
}
.sys-btn:hover { background: #bca076; }
.btn-auto { background: #5D4037; opacity: 0.6; pointer-events: none; }
.btn-auto.affordable { opacity: 1; pointer-events: auto; animation: pulse 1.5s infinite; background: #FF9800; border-color: #EF6C00;}
.btn-auto.active { background: #4CAF50; border-color: #2E7D32; opacity: 1; cursor: default; }

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 152, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0); }
}

@keyframes rotatePhone { 0% { transform: rotate(0deg); } 50% { transform: rotate(-90deg); } 100% { transform: rotate(-90deg); } }

@media (max-width: 900px) and (orientation: portrait) {
    .rotate-warning { display: flex; }
    #game-app { display: none; }
}
@media (max-width: 900px) and (orientation: landscape) {
    #game-app {
        width: 100vw; height: 100vh; box-shadow: none; border: none;
    }
    .game-layout-wrapper { gap: 0; padding: 0; }
    .leaderboard-panel { display: none; }
}
/* Leaderboard Panel Styles */
.leaderboard-panel {
    position: absolute;
    left: -235px; /* Đẩy sang trái khung Game */
    top: 50%;
    transform: translateY(-50%);
    width: 220px;
    height: 590px;
    background: #5D4037 url('../assets/wood_pattern.png'); 
    border: 6px solid #3E2723;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    z-index: 5;
    color: #ffeb3b;
    font-family: 'Fredoka', sans-serif;
}
.lb-header {
    background: #3E2723;
    padding: 15px;
    text-align: center;
    font-weight: 800;
    font-size: 18px;
    border-bottom: 4px solid #2e1b1b;
    text-shadow: 2px 2px 0 #000;
}
.lb-list {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
}
.lb-item {
    display: flex;
    align-items: center;
    padding: 10px 8px;
    background: rgba(0,0,0,0.2);
    margin-bottom: 8px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.05);
}
.lb-item.top-1 {
    background: linear-gradient(135deg, rgba(255,215,0,0.2), rgba(255,165,0,0.1));
    border-color: #FFD700;
}
.lb-rank {
    width: 25px;
    height: 25px;
    background: #2e1b1b;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 900;
    font-size: 12px;
    margin-right: 10px;
    color: #fff;
    border: 1px solid #ffeb3b;
}
.top-1 .lb-rank { background: #FFD700; color: #3e2723; }
.lb-name {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #eee;
}
.lb-score {
    font-size: 13px;
    font-weight: bold;
    color: #4CAF50;
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 4px;
}
.hide-on-mobile {
    display: flex;
}
@media (max-width: 1100px) {
    .leaderboard-panel { width: 180px; }
    .lb-name { font-size: 12px; }
}
@media (max-width: 950px) {
    .hide-on-mobile { display: none !important; }
}
/* Final Wave Banner */
.final-wave-banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    pointer-events: none;
    text-align: center;
    width: 100%;
}
.final-wave-banner h1 {
    color: #f44336;
    font-size: clamp(30px, 5vw, 60px); /* Co giãn an toàn */
    font-weight: 900;
    text-shadow: 0 0 20px black, 0 0 10px #f44336;
    margin: 0;
    background: rgba(0,0,0,0.6);
    padding: 20px 0;
    width: 100%;
}
@media (max-width: 600px) {
    .final-wave-banner h1 { font-size: 24px; padding: 10px 0; }
}
.flicker-text {
    animation: flicker 0.2s infinite alternate;
}
@keyframes flicker {
    from { opacity: 0.8; transform: scale(1); }
    to { opacity: 1; transform: scale(1.05); }
}

/* Difficulty Buttons */
.diff-btn {
    background: #3e2723; border: 2px solid #5d4037; color: #aaa;
    padding: 8px 15px; border-radius: 5px; cursor: pointer; font-weight: bold;
    transition: all 0.2s; font-family: 'Fredoka', sans-serif;
}
.diff-btn:hover { background: #5d4037; color: white; }
.diff-btn.active { background: #F44336; border-color: #ffeb3b; color: white; box-shadow: 0 0 10px #F44336; }

/* Locked Seed Slot */
.seed-slot.locked {
    filter: grayscale(1) contrast(0.5) !important;
    cursor: not-allowed;
    border-color: #424242 !important;
}
.seed-slot.locked .slot-graphic, .seed-slot.locked .slot-price {
    opacity: 0.3;
}
.lock-label {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%) rotate(-15deg);
    background: #000; color: #f44336; font-weight: 900;
    font-size: 14px; padding: 2px 10px; border: 2px solid #f44336;
    z-index: 10; pointer-events: none; white-space: nowrap;
}

/* Almanac Modal Styles */
.almanac-modal {
    padding: 2vh 0;
    align-items: center;
}
.almanac-content {
    background: #4e342e url('../assets/wood_pattern.png'); /* Pattern gỗ */
    border: 8px solid #3e2723;
    border-radius: 20px;
    width: 850px;
    height: 550px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 100px rgba(0,0,0,1);
    position: relative;
    font-family: 'Fredoka', sans-serif;
    transform: scale(0.9);
}
.almanac-header {
    height: 60px;
    background: #3e2723;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    border-bottom: 4px solid #1b5e20;
}
.almanac-tabs {
    display: flex;
    gap: 20px;
}
.alma-tab {
    padding: 8px 25px;
    background: #5d4037;
    color: #aaa;
    font-weight: 800;
    cursor: pointer;
    border: 2px solid #3e2723;
    border-radius: 8px;
    transition: all 0.2s;
}
.alma-tab:hover { color: white; background: #795548; }
.alma-tab.active { 
    background: #4CAF50; 
    color: white; 
    border-color: #ffeb3b;
    box-shadow: 0 0 10px rgba(255,235,59,0.5);
}
.close-alma {
    background: #f44336;
    border: none;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
}

.almanac-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}
.almanac-list {
    width: 280px;
    background: rgba(0,0,0,0.3);
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    align-content: start;
    overflow-y: auto;
    border-right: 4px solid #3e2723;
}
.alma-item {
    background: #d7ccc8;
    aspect-ratio: 1;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28px;
    cursor: pointer;
    border: 3px solid #5d4037;
    transition: all 0.1s;
}
.alma-item:hover { border-color: #ffeb3b; transform: scale(1.05); }
.alma-item.active { border-color: #4CAF50; background: #fff; box-shadow: 0 0 15px #4CAF50; }

.almanac-detail {
    flex: 1;
    padding: 30px;
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
    color: #3e2723;
}
.detail-portrait {
    width: 120px;
    height: 120px;
    background: white;
    border: 5px solid #3e2723;
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 60px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}
.detail-info {
    flex: 1;
}
.alma-icon-img {
    width: 80%;
    height: 80%;
    object-fit: contain;
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.2));
}
.detail-img {
    width: 90%;
    height: 90%;
    object-fit: contain;
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.3));
}
.alma-name { font-size: 32px; font-weight: 800; margin-bottom: 5px; color: #1b5e20; text-transform: uppercase; }
.alma-cost { font-weight: bold; color: #f57f17; margin-bottom: 10px; }
.alma-desc { font-style: italic; line-height: 1.5; margin-bottom: 15px; }
.alma-hr { border: none; border-top: 2px solid #3e2723; opacity: 0.2; margin: 15px 0; }
.alma-sub-info { margin-bottom: 8px; font-size: 16px; }
.alma-sub-info strong { color: #d32f2f; }

/* Custom Scrollbar for Almanac */
.custom-scrollbar::-webkit-scrollbar { width: 8px; }
.custom-scrollbar::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }
.custom-scrollbar::-webkit-scrollbar-thumb { background: #5d4037; border-radius: 4px; }
