/* Biến nội bộ */
.animal-neo-wrapper {
    --bg-white: #ffffff;
    --border-ink: 3px solid #111111;
    --shadow-solid: 5px 5px 0px #111111;
    --shadow-push: 2px 2px 0px #111111;
    
    --clr-water: #00b4d8;    
    --clr-water-dark: #0077b6; 
    --clr-highlight: #ffca3a;
    --clr-finish: #ef233c;   
    --clr-bg: #f8f9fa;

    max-width: 900px;
    margin: 0 auto;
    font-family: system-ui, -apple-system, sans-serif;
    color: #111111;
    background: var(--clr-bg);
    padding: 20px;
    border: var(--border-ink);
    border-radius: 16px;
    box-shadow: 8px 8px 0px #111;
}

.animal-neo-wrapper * { box-sizing: border-box; }

.animal-neo-header { background: var(--clr-water-dark); color: #fff; border: var(--border-ink); box-shadow: var(--shadow-solid); padding: 20px; border-radius: 12px; text-align: center; margin-bottom: 25px; }
.animal-neo-header h2 { margin: 0 0 10px 0; font-size: 1.8rem; font-weight: 900; text-transform: uppercase; text-shadow: 2px 2px 0px #111;}
.animal-neo-header p { margin: 0; font-weight: 800; font-size: 0.95rem; }

/* Bảng điều khiển */
.animal-controls { margin-bottom: 20px; }
.animal-group { display: flex; flex-direction: column; gap: 10px; }
.animal-group label { font-weight: 900; font-size: 1.05rem; color: #111; }

.input-with-select { display: flex; flex-wrap: nowrap; align-items: stretch; border: var(--border-ink); border-radius: 12px; box-shadow: 4px 4px 0px #111; background: #fff; overflow: hidden; width: 100%; }
.input-with-select input { border: none !important; box-shadow: none !important; flex: 1 1 50%; min-width: 80px; padding: 16px 15px !important; font-size: 1.3rem !important; font-weight: 900; color: #111; outline: none; }
.input-with-select select { border: none; border-left: 3px solid #111; font-size: 1.1rem; background: #e9ecef; color: #111; flex: 0 0 auto; padding: 0 15px; font-weight: 900;}
.input-with-select input:focus { background: #e0fbfc; }

/* Grid nhập tên */
.animal-names-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; background: #e9ecef; padding: 15px; border-radius: 12px; border: 2px dashed #111;}
.name-input-box { display: flex; align-items: center; background: #fff; border: 2px solid #111; border-radius: 8px; overflow: hidden;}
.name-icon { background: #111; color: #fff; padding: 8px; font-size: 1.1rem; display: inline-block; transform: scaleX(-1); }
.name-input-box input { border: none; padding: 8px 10px; font-weight: 800; width: 100%; outline: none; font-size: 0.95rem; }
.name-input-box input:focus { background: #fff3cc; }

/* Nút bấm */
.animal-neo-btn { padding: 18px; font-size: 1.2rem; font-weight: 900; background: #111; color: #fff; border: var(--border-ink); border-radius: 12px; box-shadow: 5px 5px 0px var(--clr-finish); cursor: pointer; text-transform: uppercase; transition: all 0.1s;}
.animal-neo-btn:active { box-shadow: 2px 2px 0px var(--clr-finish); transform: translate(3px, 3px); }
.animal-neo-btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; transform: none; }

.animal-neo-btn-secondary { padding: 12px 20px; font-size: 1.1rem; font-weight: 900; background: #111; color: #fff; border: var(--border-ink); border-radius: 8px; box-shadow: 4px 4px 0px #111; cursor: pointer; text-transform: uppercase; margin-top: 15px; transition: all 0.1s;}
.animal-neo-btn-secondary:active { box-shadow: 1px 1px 0px #111; transform: translate(3px, 3px); }

/* ĐƯỜNG ĐUA & SÓNG NƯỚC */
.animal-track-wrapper { position: relative; background-color: var(--clr-water); border: var(--border-ink); border-radius: 12px; box-shadow: inset 0px 5px 15px rgba(0,0,0,0.3); overflow: hidden; padding: 10px 0;}
.water-waves {
    background-image: 
        repeating-linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.15) 75%, rgba(255,255,255,0.15)), 
        repeating-linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.15) 75%, rgba(255,255,255,0.15));
    background-position: 0 0, 20px 20px;
    background-size: 40px 40px;
    animation: flowWater 1.5s linear infinite;
}
@keyframes flowWater { 100% { background-position: -40px 0, -20px 20px; } }

.finish-line { position: absolute; right: 0; top: 0; width: 40px; height: 100%; background: repeating-linear-gradient(45deg, #111, #111 10px, #fff 10px, #fff 20px); border-left: var(--border-ink); z-index: 1; opacity: 0.9;}
.animal-track { display: flex; flex-direction: column; gap: 5px; position: relative; z-index: 2;}
.animal-lane { display: flex; align-items: center; position: relative; height: 60px; border-bottom: 2px dashed rgba(255,255,255,0.3); }
.animal-lane:last-child { border-bottom: none; }

/* CÁC TAY ĐUA */
.animal-racer { position: absolute; left: 10px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; padding-bottom: 5px; transition: transform 0.1s; will-change: transform; filter: drop-shadow(2px 2px 0px rgba(0,0,0,0.4)); z-index: 3;}
.racer-emoji { font-size: 2.2rem; display: inline-block; transform: scaleX(-1); line-height: 1;}
.racer-name-tag { font-size: 0.75rem; font-weight: 900; background: #fff; color: #111; padding: 2px 6px; border: 2px solid #111; border-radius: 8px; margin-top: -5px; white-space: nowrap; max-width: 80px; overflow: hidden; text-overflow: ellipsis; text-align: center; position: relative; z-index: 4;}

/* HIỆU ỨNG TRẠNG THÁI (Status Bubble) CẬP NHẬT CÓ CHỮ */
.status-bubble { 
    position: absolute; 
    top: -30px; /* Đẩy lên cao hơn một chút để không che mất thú */
    font-size: 0.85rem; 
    font-weight: 900;
    color: #111;
    background: #fff; 
    border: 2px solid #111; 
    border-radius: 12px; /* Đổi thành hình bo góc thay vì hình tròn */
    padding: 4px 10px;
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 4px;
    box-shadow: 2px 2px 0px #111; 
    opacity: 0; 
    white-space: nowrap; /* Tránh chữ bị rớt dòng */
    transition: opacity 0.2s; 
    z-index: 5; 
    pointer-events: none;
}
.status-bubble.show { opacity: 1; animation: popUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes popUp { 0% { transform: translateY(10px) scale(0); } 100% { transform: translateY(0) scale(1); } }

/* Kết quả chung */
.animal-neo-result { margin-top: 25px; padding: 25px; background: #fff; border: var(--border-ink); border-radius: 12px; box-shadow: var(--shadow-solid); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px;}
.animal-neo-result h3 { margin: 0; font-size: 1.5rem; font-weight: 900; color: var(--clr-water-dark);}
.winner-box { display: flex; align-items: center; justify-content: center; gap: 15px; background: var(--clr-highlight); padding: 15px 30px; border: var(--border-ink); border-radius: 12px; box-shadow: 4px 4px 0px #111;}
.winner-icon { font-size: 3.5rem; display: inline-block; animation: bounceFlip 0.5s infinite alternate; }
.winner-box .val-text { font-size: 1.8rem; font-weight: 900; color: #111; text-transform: uppercase;}

/* BẢNG XẾP HẠNG */
.leaderboard-box { margin-top: 20px; width: 100%; border-top: 3px dashed #ccc; padding-top: 20px;}
.leaderboard-box h4 { margin: 0 0 15px 0; font-size: 1.2rem; font-weight: 900; color: #111; text-transform: uppercase;}
.leaderboard-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; text-align: left; max-height: 250px; overflow-y: auto; padding-right: 5px;}
.lb-item { display: flex; align-items: center; justify-content: flex-start; gap: 15px; padding: 12px 20px; border: 2px solid #111; border-radius: 8px; font-weight: 900; font-size: 1.05rem; background: #fff; box-shadow: 2px 2px 0px #111; transition: transform 0.1s;}
.lb-item:hover { transform: translateX(5px); }
.lb-rank { font-size: 1.4rem; width: 40px; text-align: center; }
.lb-info { flex: 1; display: flex; align-items: center; gap: 10px; }
.lb-emoji { font-size: 1.8rem; display: inline-block; transform: scaleX(-1); filter: drop-shadow(-1px 1px 0px #111); }
.lb-name { text-transform: uppercase; font-size: 1.1rem; }

/* Highlight Top 3 */
.lb-top-1 { background: #ffca3a; }
.lb-top-2 { background: #e9ecef; }
.lb-top-3 { background: #f4a261; }

@keyframes bounceFlip { 
    0% { transform: scaleX(-1) translateY(0); } 
    100% { transform: scaleX(-1) translateY(-10px); } 
}

@media (max-width: 600px) {
    .animal-names-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}