body {
    margin: 0;
    font-family: 'Courier New', Courier, monospace;
    background-color: #1a1a1a;
    color: #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden; /* Prevent scroll on feedback animation */
    transition: background-color 0.5s ease; /* Smooth transition for map themes */
}

/* Map Themes */
body.forest_theme { background-color: #2e7d32; } /* Dark Green */
body.winter_theme { background-color: #2196f3; } /* Blue */
body.beach_theme { background-color: #ffeb3b; }  /* Yellow */
body.volcano_theme { background-color: #d32f2f; } /* Dark Red */
body.heaven_theme { background-color: #9c27b0; } /* Purple */


/* Game Container */
#game-container {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
    position: relative; /* For positioning menu buttons */
}

/* HUD */
.hud {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 15px 20px;
    background-color: rgba(42, 42, 42, 0.8); /* Slightly transparent */
    border-bottom: 2px solid #ffc107;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    font-size: 1.3em;
    margin-bottom: 20px;
    border-radius: 5px;
    backdrop-filter: blur(5px); /* Frosted glass effect */
}

.hud div {
    padding: 0 10px;
}

.gem-counter {
    color: #00bcd4; /* Cyan color for gems */
    font-weight: bold;
}

/* Game Area */
.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    width: 100%;
    text-align: center;
    margin-bottom: 30px;
}

#target-word {
    font-size: 4em;
    font-weight: bold;
    color: #ffc107;
    margin-bottom: 30px;
    word-break: break-word; /* For very long words */
}

.typing-area {
    position: relative; /* For positioning the pet display */
    width: 80%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

#active-pet-display {
    font-size: 4rem; /* Large emoji size */
    margin-bottom: 10px;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
    height: 4rem; /* Fixed height to prevent layout shifts */
    line-height: 1; /* Adjust line height to center vertically */
    z-index: 2; /* Ensure pet is above input for visual pop */
}


#word-input {
    width: 100%;
    padding: 15px 20px;
    font-size: 1.8em;
    text-align: center;
    border: 3px solid #4caf50;
    border-radius: 8px;
    background-color: #333;
    color: #e0e0e0;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    z-index: 1; /* Ensure input is behind pet */
}

#word-input:focus {
    border-color: #ffc107;
    box-shadow: 0 0 15px rgba(255, 193, 7, 0.5);
}

/* Feedback message for coins */
.feedback-message {
    position: absolute;
    font-size: 2em;
    font-weight: bold;
    color: #ffeb3b; /* Amber color for better readability */
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7); /* Add text shadow for contrast */
    opacity: 0;
    transform: translateY(0);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
    pointer-events: none; /* Allow clicks to pass through */
    z-index: 5; /* Ensure it's above other elements */
}

.feedback-message.show {
    opacity: 1;
    transform: translateY(-50px);
}

/* Feedback message for gems */
.gem-drop {
    color: #00bcd4; /* Cyan for gem drops */
    font-size: 2.2em; /* Slightly larger than coin feedback */
}


/* Shop Section */
.shop-section {
    width: 100%;
    background-color: rgba(42, 42, 42, 0.8); /* Slightly transparent */
    padding: 20px;
    border-top: 2px solid #ffc107;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    backdrop-filter: blur(5px);
}

.shop-section h2 {
    color: #ffc107;
    text-align: center;
    margin-bottom: 25px;
    font-size: 2em;
}

.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); /* Adjusted for smaller items */
    gap: 25px;
    justify-content: center;
}

.shop-item {
    background-color: #333;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #555;
    text-align: center;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.shop-item:hover {
    transform: translateY(-5px);
}

.shop-item h3 {
    color: #4caf50;
    margin-bottom: 10px;
    font-size: 1.5em;
}

.shop-item p {
    margin-bottom: 5px;
    font-size: 1.1em;
}

.shop-item button {
    background-color: #ffc107;
    color: #1a1a1a;
    border: none;
    padding: 10px 20px;
    font-size: 1.1em;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    margin-top: 15px;
    font-weight: bold;
}

.shop-item button:hover {
    background-color: #e0a800;
    transform: translateY(-2px);
}

.shop-item button:disabled {
    background-color: #555;
    cursor: not-allowed;
}

/* Menu Buttons */
.menu-buttons {
    width: 100%; /* Take full width of parent */
    display: flex;
    justify-content: flex-end; /* Align buttons to the right */
    gap: 10px;
    margin-top: 10px; /* Space from HUD */
    margin-bottom: 20px;
    padding: 0 20px; /* Padding to match HUD */
    box-sizing: border-box;
    z-index: 10;
}

.menu-buttons button {
    background-color: #00bcd4; /* Cyan for menu buttons */
    color: #1a1a1a;
    border: none;
    padding: 12px 25px;
    font-size: 1.1em;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.menu-buttons button:hover {
    background-color: #0097a7;
    transform: translateY(-2px);
}

/* Modals (Overlays) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    display: none; /* Hidden by default */
    backdrop-filter: blur(8px); /* Frosted glass effect for modals */
}

.modal-content {
    background-color: #2a2a2a;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 700px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.7);
    position: relative;
    max-height: 80vh; /* Limit height for scrollable content */
    overflow-y: auto; /* Enable scrolling for modal content */
    border: 1px solid #ffc107;
}

.modal-content h2 {
    color: #ffc107;
    text-align: center;
    margin-bottom: 20px;
    font-size: 2.2em;
}

.close-button {
    position: absolute;
    top: 10px;
    right: 20px;
    color: #e0e0e0;
    font-size: 2.5em;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-button:hover {
    color: #ffc107;
}

/* Auth Card for Login Overlay (Removed from HTML, but keeping styles for consistency with template) */
.auth-card {
    background-color: #2a2a2a;
    padding: 30px 40px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    border: 1px solid #ffc107;
}

#google-signin-btn {
    background-color: #4caf50;
    color: #fff;
    border: none;
    padding: 15px 30px;
    font-size: 1.2em;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#google-signin-btn:hover {
    background-color: #43a047;
}


/* Pet Card Styles for Inventory and Shop */
.pet-card {
    background-color: #333;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #555;
    text-align: center;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
}

.pet-card:hover {
    transform: translateY(-5px);
    border-color: #00bcd4; /* Highlight on hover */
}

.pet-card.equipped-pet {
    border: 3px solid #ffc107; /* Gold border for equipped pet */
    box-shadow: 0 0 15px rgba(255, 193, 7, 0.7);
}

.pet-card .emoji {
    font-size: 3em;
    margin-bottom: 5px;
    line-height: 1;
}

.pet-card .pet-name {
    font-size: 1.2em;
    font-weight: bold;
    color: #e0e0e0;
    margin-bottom: 5px;
}

.pet-card .pet-rarity {
    font-size: 0.8em;
    color: #bbb;
}

/* Specific button style for buying eggs */
.egg-card button, .map-card button { /* Apply to map card buttons as well */
    background-color: #4caf50; /* Green for buy buttons */
    color: #fff;
    border: none;
    padding: 8px 15px;
    font-size: 1em;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    margin-top: 10px;
}

.egg-card button:hover, .map-card button:hover {
    background-color: #43a047;
}

/* Map Card Styles */
.map-card.locked {
    opacity: 0.5;
    pointer-events: none; /* Disable interaction */
    filter: grayscale(100%);
}

.map-card.active-map {
    border: 3px solid #00bcd4; /* Cyan border for active map */
    box-shadow: 0 0 15px rgba(0, 188, 212, 0.7);
}

/* Boss Arena Styles */
.boss-arena-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 600px;
}

.boss-arena-content h2 {
    font-size: 3em;
    margin-bottom: 0;
}

.boss-image {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: 8px;
    border: 2px solid #ffc107;
    box-shadow: 0 0 15px rgba(255, 193, 7, 0.5);
}

.boss-hp-container {
    width: 90%;
    background-color: #555;
    border-radius: 15px;
    height: 30px;
    position: relative;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.boss-hp-bar {
    width: 100%;
    height: 100%;
    background-color: #d32f2f; /* Red base for HP bar */
    border-radius: 15px;
}

.boss-hp-bar-fill {
    height: 100%;
    width: 100%; /* Will be adjusted by JS */
    background-color: #4caf50; /* Green fill for HP */
    border-radius: 15px;
    transition: width 0.3s ease-out; /* Smooth HP bar animation */
}

.boss-hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-weight: bold;
    font-size: 1.1em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.boss-timer {
    font-size: 2.5em;
    font-weight: bold;
    color: #ffc107;
    text-shadow: 1px 1px 5px rgba(0, 0, 0, 0.7);
}

.boss-target-word {
    font-size: 3em;
    font-weight: bold;
    color: #e0e0e0;
    margin-top: 10px;
}

.boss-word-input {
    width: 80%;
    max-width: 400px;
    padding: 12px 15px;
    font-size: 1.5em;
    text-align: center;
    border: 3px solid #00bcd4;
    border-radius: 8px;
    background-color: #333;
    color: #e0e0e0;
    outline: none;
    margin-top: 20px;
}

.boss-word-input:focus {
    border-color: #ffc107;
    box-shadow: 0 0 15px rgba(255, 193, 7, 0.5);
}

/* Boss Shake Animation */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
    20%, 40%, 60%, 80% { transform: translateX(10px); }
}

.shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Jump Animation */
@keyframes jump {
    0% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
    100% { transform: translateY(0); }
}

.jump {
    animation: jump 0.2s ease-out; /* Animation duration for jump */
}


/* Responsiveness */
@media (max-width: 768px) {
    .hud {
        flex-direction: column;
        align-items: center;
        font-size: 1.1em;
    }

    .hud div {
        margin-bottom: 10px;
    }

    #target-word {
        font-size: 2.8em;
    }

    #word-input {
        font-size: 1.5em;
        width: 90%;
    }

    .shop-grid {
        grid-template-columns: 1fr;
    }

    .menu-buttons {
        flex-direction: row;
        width: 90%;
        justify-content: space-around;
        bottom: 10px;
        left: 5%;
        right: 5%;
        margin-top: 0; /* Override margin-top for mobile */
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }
}

/* Bestiary Button */
#bestiary-btn {
    background-color: #9C27B0; /* Purple */
    color: white;
}

#bestiary-btn:hover {
    background-color: #7B1FA2;
}

/* Bestiary Modal */
.bestiary-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.bestiary-map-section {
    background-color: #333;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #555;
}

.bestiary-map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #555;
}

.bestiary-map-header h3 {
    margin: 0;
    color: #ffc107;
    font-size: 1.6em;
}

.bestiary-map-header .progress-counter {
    font-size: 1.2em;
    color: #ccc;
}

.mastery-banner {
    text-align: center;
    padding: 8px;
    margin-bottom: 15px;
    border-radius: 5px;
    font-weight: bold;
    color: #aaa;
    background-color: #424242;
}

.mastery-banner.unlocked {
    color: #1a1a1a;
    background-color: #ffeb3b; /* Gold/Yellow */
    text-shadow: 0 0 5px #fff;
}

.bestiary-pet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}

/* Override for pet cards inside bestiary for smaller size */
.bestiary-pet-grid .pet-card {
    padding: 10px;
    cursor: default; /* Not clickable */
}

.bestiary-pet-grid .pet-card:hover {
    transform: none; /* No hover effect */
    border-color: #555;
}

.bestiary-pet-grid .pet-card .emoji {
    font-size: 2.5em;
}

.bestiary-pet-grid .pet-card .pet-name {
    font-size: 1em;
}

.bestiary-pet-grid .pet-card.locked {
    background: #3a3a3a;
    border-color: #555;
}
.bestiary-pet-grid .pet-card.locked .emoji {
    color: #888;
    text-shadow: none;
}
.bestiary-pet-grid .pet-card.locked .pet-name,
.bestiary-pet-grid .pet-card.locked .pet-rarity {
    color: #888;
    visibility: visible; /* Ensure rarity text like '???' is visible */
}

/* Golden Word (Critical Hit) Styles */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.golden-word {
    color: #FFD700;
    text-shadow: 0 0 10px #FFD700, 0 0 20px #FFA500;
    animation: pulse 1s infinite;
}

.feedback-golden {
    font-size: 2.5em; /* Larger than normal feedback */
    font-weight: bold;
    color: #FFD700;
    text-shadow: 0 0 8px #FFD700, 0 0 15px #FFA500;
}

/* --- Merchant & Combat Consumables --- */

/* Traveling Merchant NPC */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

#merchant-npc {
    position: absolute;
    font-size: 3rem;
    cursor: pointer;
    z-index: 50;
    display: none; /* Hidden by default */
    animation: float 3s ease-in-out infinite;
    text-shadow: 0 5px 15px rgba(0,0,0,0.5);
    transition: transform 0.3s ease;
}

#merchant-npc:hover {
    transform: scale(1.2);
}

/* Boss Fight Hotbar */
.hotbar {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}

.hotbar-slot {
    width: 70px;
    height: 70px;
    border: 2px solid #888;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 5px;
    position: relative;
    user-select: none;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.hotbar-slot:hover {
    border-color: #ffc107;
    background: rgba(255, 193, 7, 0.1);
}

.hotbar-slot.on-cooldown {
    background: #555;
    cursor: not-allowed;
    opacity: 0.6;
}

.hotbar-icon {
    font-size: 2em;
    line-height: 1;
}

.hotbar-count {
    position: absolute;
    bottom: 2px;
    right: 5px;
    font-size: 0.9em;
    font-weight: bold;
    color: #fff;
    background: rgba(0, 0, 0, 0.7);
    padding: 1px 4px;
    border-radius: 4px;
}

.hotbar-key {
    position: absolute;
    top: 2px;
    left: 5px;
    font-size: 0.9em;
    color: #ccc;
}

/* Visual Feedback for Item Effects */
.boss-image.double-damage {
    filter: drop-shadow(0 0 15px #d32f2f); /* Red glow */
    transition: filter 0.2s;
}

.boss-timer.time-added {
    color: #4caf50; /* Green */
    transform: scale(1.2);
    transition: color 0.2s, transform 0.2s;
}

@keyframes violent-shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.violent-shake {
    animation: violent-shake 0.5s;
    animation-iteration-count: infinite;
}
