html,
body {
    margin: 0;
    height: 100%;
    background: #0e1015;
    font-family: "Poppins", sans-serif;
    font-optical-sizing: auto;
    overflow: hidden;
}

a {
    color: #fff;
}

#wrap {
    position: relative;
    width: 100%;
    height: 100%;
}

canvas {
    display: block;
    background: #1c1f25;
    image-rendering: pixelated;
}

#attackBtn {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    padding: .7rem 1.2rem;
    background: #d35400;
    border: 0;
    border-radius: 6px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
}

#playerHp {
    position: absolute;
    left: 1rem;
    top: 1rem;
    width: 180px;
    height: 18px;
    border: 2px solid #000;
    background: #333;
}

#playerHp .bar {
    height: 100%;
    background: #27ae60;
    width: 100%;
}

.popup {
    position: fixed;
    inset: 1rem;
    max-width: 600px;
    max-height: 90vh;
    margin: auto;
    background: #5b83f3;
    color: #fff;
    border: 3px solid #fff;
    border-radius: 12px;
    padding: 1rem 1.2rem;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    overflow-y: auto;
    z-index: 11000;
    display: flex;
    flex-direction: column;
}

.popup h2 {
    margin-top: 0;
    font-size: 1.4rem;
    text-align: center;
}

.popup .content {
    flex: 1;
    margin-bottom: 1rem;
    font-size: 1rem;
    line-height: 1.5;
}

.popup button.close-btn {
    align-self: center;
    background: #926af2;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    padding: 0.6rem 1.4rem;
    cursor: pointer;
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .65);
    z-index: 9998;
}

#logo img {
    position: absolute;
    top: 10px;
    left: 10px;
    height: 80px;
    display: block;
    transition: transform 0.2s ease;
}

#logo:hover img {
    transform: scale(1.05);
}

.center-top {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    padding: 1rem;
    color: #0adade;
    font-size: 2rem;
    font-family: 'Sora', sans-serif;
}

.center-top-2 {
    position: absolute;
    top: 0;
    right: 0;
    width: 150px;
    margin: 0 auto;
    padding: 1rem;
    font-size: 1.5rem;
    color: #0adade;
    font-family: 'Sora', sans-serif;
}

/* Loading overlay */
#loading-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0e1015;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    transition: opacity 0.5s;
}

#progress-bar {
    width: 300px;
    height: 20px;
    background: #333;
    border-radius: 10px;
    margin: 20px;
    overflow: hidden;
}

#progress-fill {
    width: 0%;
    height: 100%;
    background: #5b83f3;
    transition: width 0.3s ease;
}

#loading-text {
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 1.2rem;
}

/* Balloon styles */
.balloon {
    position: absolute;
    background: white;
    color: black;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    width: 200px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 10000;
    transform: translateX(-50%);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.balloon::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px 8px 0;
    border-style: solid;
    border-color: white transparent transparent;
}

/* Enemy Speech Bubbles */
.speech-balloon {
    position: absolute;
    background: rgb(243, 211, 211);
    color: black;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    width: 200px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 10000;
    transform: translateX(-50%);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.speech-balloon::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px 8px 0;
    border-style: solid;
    border-color: rgb(243, 211, 211) transparent;
}

/* Mobile optimization */
@media (max-width: 768px) {
    .speech-balloon {
        font-size: 13px;
        padding: 6px 12px;
        max-width: 160px;
    }

    #attackBtn {
        background-color: #926af2;
        right: auto;
        left: 70%;
        transform: translateX(-50%);
        bottom: 30px;
        padding: 15px 25px;
        font-size: 1.2rem;
    }
}