* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
    background: #87CEEB;
    color: #2c3e50;
    touch-action: manipulation;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
}

.hidden { display: none !important; }

#loading-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, #87CEEB 0%, #98D8E8 50%, #B0E0A8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s;
}

.loading-content {
    text-align: center;
    padding: 30px;
    max-width: 90%;
}

.loading-logo {
    font-size: 80px;
    margin-bottom: 20px;
    animation: bounce 1.5s infinite;
    filter: drop-shadow(2px 4px 4px rgba(0,0,0,0.2));
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.loading-title {
    font-size: 42px;
    color: #2c5530;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(255,255,255,0.5);
    font-weight: 900;
    letter-spacing: 1px;
}

.loading-subtitle {
    font-size: 16px;
    color: #555;
    margin-bottom: 25px;
}

.loading-bar-container {
    width: 280px;
    max-width: 100%;
    height: 18px;
    background: rgba(255,255,255,0.4);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    margin: 0 auto;
}

.loading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4CAF50, #66BB6A, #81C784);
    border-radius: 20px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.loading-percent {
    margin-top: 12px;
    font-size: 14px;
    color: #2c5530;
    font-weight: bold;
}

#game-container {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
}

#game-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

#hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
}

.hud-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    pointer-events: auto;
    background: linear-gradient(180deg, rgba(0,0,0,0.4), transparent);
}

.hud-balance, .hud-username {
    background: rgba(255,255,255,0.95);
    border-radius: 25px;
    padding: 10px 18px;
    font-weight: bold;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    border: 2px solid #FFD700;
    color: #2c5530;
}

.hud-username {
    border-color: #4CAF50;
}

.hud-icon { font-size: 20px; }

.hud-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    padding: 10px 8px 18px;
    pointer-events: auto;
    background: linear-gradient(0deg, rgba(0,0,0,0.5), transparent);
}

.hud-btn {
    background: linear-gradient(180deg, #66BB6A, #4CAF50);
    color: white;
    border-radius: 18px;
    padding: 10px 14px;
    min-width: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-weight: bold;
    font-size: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.3);
    transition: transform 0.1s, box-shadow 0.1s;
    border: 2px solid rgba(255,255,255,0.3);
}

.hud-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.hud-btn.active {
    background: linear-gradient(180deg, #FFD700, #FFA500);
    color: #2c5530;
}

.hud-btn-icon { font-size: 22px; }

#modal-container {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 20px;
    padding: 25px;
    max-width: 400px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    border: 3px solid #FFD700;
    animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
    from { transform: scale(0.7); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-title {
    font-size: 24px;
    color: #2c5530;
    margin-bottom: 15px;
    text-align: center;
    font-weight: 900;
}

.modal-text {
    color: #555;
    line-height: 1.5;
    margin-bottom: 20px;
}

.modal-input {
    width: 100%;
    padding: 14px;
    border: 2px solid #ddd;
    border-radius: 12px;
    font-size: 16px;
    margin-bottom: 12px;
    transition: border-color 0.2s;
    font-family: inherit;
}

.modal-input:focus {
    outline: none;
    border-color: #4CAF50;
}

.modal-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(180deg, #66BB6A, #4CAF50);
    color: white;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: transform 0.1s;
}

.modal-btn:active { transform: translateY(2px); }

.modal-btn.secondary {
    background: linear-gradient(180deg, #BDBDBD, #9E9E9E);
}

.modal-btn.danger {
    background: linear-gradient(180deg, #EF5350, #E53935);
}

.modal-btn.gold {
    background: linear-gradient(180deg, #FFD700, #FFA500);
    color: #2c5530;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    background: #f0f0f0;
    border-radius: 50%;
    font-size: 20px;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
}

#toast-container {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: rgba(44, 85, 48, 0.95);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    animation: toastIn 0.3s ease-out;
    max-width: 90vw;
    text-align: center;
    border: 2px solid rgba(255,215,0,0.5);
}

.toast.success { background: rgba(76, 175, 80, 0.95); }
.toast.error { background: rgba(244, 67, 54, 0.95); }
.toast.warning { background: rgba(255, 152, 0, 0.95); }

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

.toast.fadeOut { animation: toastOut 0.3s ease-out forwards; }

@keyframes toastOut {
    to { transform: translateY(-30px); opacity: 0; }
}

.animal-card {
    background: linear-gradient(180deg, #FFF9E6, #FFF3D6);
    border-radius: 16px;
    padding: 12px;
    margin-bottom: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
    border: 2px solid #FFD700;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.animal-card-img {
    width: 70px;
    height: 70px;
    background: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    border: 2px solid #E0E0E0;
}

.animal-card-info { flex: 1; }
.animal-card-name { font-weight: bold; font-size: 16px; color: #2c5530; }
.animal-card-price { color: #E65100; font-weight: bold; font-size: 14px; }
.animal-card-income { color: #2E7D32; font-size: 13px; }

@media (max-height: 600px) {
    .hud-btn { min-width: 60px; padding: 8px 10px; }
    .hud-btn-icon { font-size: 18px; }
    .hud-btn-label { font-size: 11px; }
}
