/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Canvas */
#game-canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 0;
    cursor: crosshair;
}

/* Screen Styles */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: auto;
    align-items: center;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.8);
}

.hidden {
    display: none !important;
}

/* Loading Screen */
#loading-screen {
    background: linear-gradient(to bottom, #000000, #1a1a2e);
}

#loading-screen h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
    color: #ffd700;
    text-shadow: 0 0 10px #ffaa00;
}

.loading-bar {
    width: 60%;
    max-width: 500px;
    height: 20px;
    background-color: #333;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #444;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.loading-progress {
    width: 0%;
    height: 100%;
    background: linear-gradient(to right, #ff4500, #ff8c00);
    border-radius: 8px;
    transition: width 0.3s ease;
}

.loading-text {
    margin-top: 1rem;
    font-size: 1rem;
    color: #ccc;
}

/* Login Screen */
#login-screen {
    background-image: url('/assets/menu/gameBG.png');
    background-position: center 15%;
    background-repeat: no-repeat;
    background-size: cover;
    /* position: absolute;
    top: 0;
    left: 0;
    z-index: 1; */
    width: 100%;
    height: 100%;
    background-color: #000;
}

.login-container {
    width: 90%;
    max-width: 400px;
    padding: 2rem;
    background-color: rgba(20, 20, 40, 0.85);
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.login-container h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: #ffd700;
    text-shadow: 0 0 10px #ffaa00;
}

/* Login screen loading bar */
.login-loading-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 1.5rem;
}

.login-loading-bar {
    width: 100%;
    height: 15px;
    background-color: #333;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #444;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.login-loading-progress {
    width: 0%;
    height: 100%;
    background: linear-gradient(to right, #ff4500, #ff8c00);
    border-radius: 7px;
    transition: width 0.3s ease;
}

.login-loading-text {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #ccc;
    text-align: center;
}

button:disabled {
    background-color: #555 !important;
    color: #888;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

button:disabled:hover {
    background-color: #555 !important;
    transform: none;
    box-shadow: none;
}

.guest-login,
#account-login {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1.5rem;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 0.8rem;
    margin-bottom: 1rem;
    border: none;
    border-radius: 5px;
    background-color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
}

button {
    padding: 0.8rem 1.5rem;
    margin: 0.5rem 0;
    border: none;
    border-radius: 5px;
    background-color: #4a5568;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 150px;

    @media (max-width: 400px) {
        min-width: 90px;
    }
}

button:hover {
    background-color: #2d3748;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

#enter-game-btn,
#login-btn {
    background-color: #e53e3e;
}

#enter-game-btn:hover,
#login-btn:hover {
    background-color: #c53030;
}

#account-btn {
    background-color: #3182ce;
}

#account-btn:hover {
    background-color: #2b6cb0;
}

#buy-menu-btn {
    background-color: #38a169;
}

#buy-menu-btn:hover {
    background-color: #2f855a;
}

#forgot-password {
    color: #90cdf4;
    text-decoration: none;
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

#forgot-password:hover {
    text-decoration: underline;
}

/* Character Selection Screen */
#character-select-screen {
    background-image: url('/assets/menu/gameBG.png');
    background-position: center center;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background-color: #000;
    padding: 2rem;

}

#character-select-screen h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: #ffd700;
    text-shadow: 0 0 10px #ffaa00;
}

.character-options {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    width: 100%;
}

.character-option {
    background-color: rgba(20, 20, 40, 0.85);
    border-radius: 10px;
    padding: 1.5rem;
    width: 300px;
    text-align: center;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.character-option:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.7);
}

.character-preview {
    width: 150px;
    height: 150px;
    margin: 0 auto 1rem;
    border-radius: 10px;
    background-color: #2d3748;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

.barbarianPreview {
    background-image: url('/assets/models/characters/barbarian.png');
}

.magePreview {
    background-image: url('/assets/models/characters/mage.png');
}

.knightPreview {
    background-image: url('/assets/models/characters/knight.png');
}

.roguePreview {
    background-image: url('/assets/models/characters/rogue.png');
}

.character-option h2 {
    color: #ffd700;
    margin-bottom: 1rem;
}

.character-option ul {
    text-align: left;
    margin-bottom: 1.5rem;
    list-style-position: inside;
}

.character-option li {
    margin-bottom: 0.5rem;
    color: #cbd5e0;
}

.select-character-btn {
    background-color: #e53e3e;
    width: 100%;
}

.select-character-btn:hover {
    background-color: #c53030;
}

/* Game UI */
#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

.game-ui {
    width: 100%;
    height: 100%;
    position: relative;
    pointer-events: none;
}

/* Health Bar */
.health-bar,
.xp-bar {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 300px;
    height: 40px;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

.xp-bar {
    top: 80px;
}

.bar-label {
    font-size: 0.8rem;
    color: white;
    margin-bottom: 2px;
    text-shadow: 1px 1px 2px black;
}

.bar-container {
    width: 100%;
    height: 20px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.bar-fill {
    height: 100%;
    transition: width 0.3s ease;
}

.health-fill {
    background-color: #00cc00;
}

.xp-fill {
    background-color: #3182ce;
}

.bar-value {
    font-size: 0.8rem;
    color: white;
    text-align: right;
    margin-top: 2px;
    text-shadow: 1px 1px 2px black;
}

/* Boss Health Bar */
.boss-health-bar {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 500px;
    height: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.boss-name {
    font-size: 1rem;
    color: white;
    margin-bottom: 5px;
    text-shadow: 1px 1px 2px black;
}

.boss-health-fill {
    background-color: #e53e3e;
}

/* Inventory */
.inventory {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.inventory-slot {
    width: 60px;
    height: 60px;
    background-color: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.inventory-slot:hover {
    border-color: rgba(255, 255, 255, 0.5);
}

.inventory-slot.active {
    border-color: #ffd700;
    box-shadow: 0 0 10px #ffd700;
}

.key-hint {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    background-color: #4a5568;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: white;
}

/* Mobile Controls */
.joystick-container {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    pointer-events: auto;
}

.joystick-outer {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.joystick-inner {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.5);
}

.action-buttons {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    pointer-events: auto;
    z-index: 1000;
}

.attack-button {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: #e53e3e;
    color: white;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.attack-button:active {
    transform: scale(0.95);
    background-color: #c53030;
}

/* Mobile Optimization */
.mobile input[type="text"],
.mobile input[type="password"] {
    font-size: 16px;
    /* Prevents iOS zoom on focus */
    height: 44px;
}

/* Responsive Design */
@media (max-width: 1312px) {
    .screen {
        justify-content: flex-start;
    }
}

/* @media (max-width: 350px) {
    .joystick-container{
        left: 20px;
    }

    .rotate-buttonRight, .rotate-buttonLeft{
        right: 10px;
        width: 50px;
        height: 50px;
    }
    
    .rotate-buttonLeft{
        right: 65px;
    } 
} */

@media only screen and (max-width: 768px) {

    .health-bar,
    .xp-bar {
        width: 200px !important;
    }

    .boss-health-bar {
        width: 300px;
    }

    #loading-screen h1,
    .login-container h1,
    #character-select-screen h1 {
        font-size: 2rem;
    }

    .character-option {
        width: 250px;
    }
}

@media only screen and (max-width: 480px) {

    .health-bar,
    .xp-bar {
        width: 110px !important;
        left: 10px !important;
    }

    .boss-health-bar {
        width: 250px;
    }

    .inventory-slot {
        width: 50px;
        height: 50px;
    }

    .character-options {
        gap: 0.5rem;
    }
}

/* Game Notification Styles */
.game-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    font-size: 24px;
    font-weight: bold;
    z-index: 1000;
    text-align: center;
    animation: notification-appear 0.5s ease-out;
}

.wave-start {
    color: #33cc33;
    border: 2px solid #33cc33;
    text-shadow: 0 0 10px #33cc33;
}

.wave-end {
    color: #3399ff;
    border: 2px solid #3399ff;
    text-shadow: 0 0 10px #3399ff;
}

.boss-spawn {
    color: #ff3333;
    border: 2px solid #ff3333;
    text-shadow: 0 0 10px #ff3333;
    animation: boss-notification 0.5s ease-out, boss-pulse 2s infinite;
}

.xp-gain {
    color: #ffcc00;
    font-size: 18px;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 8px 15px;
    animation: xp-float 2s ease-out;
}

.fade-out {
    animation: fade-out 1s forwards;
}

@keyframes notification-appear {
    0% {
        transform: translate(-50%, -30%);
        opacity: 0;
    }

    100% {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}

@keyframes boss-notification {
    0% {
        transform: translate(-50%, -30%) scale(0.8);
        opacity: 0;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes boss-pulse {
    0% {
        box-shadow: 0 0 10px #ff3333;
    }

    50% {
        box-shadow: 0 0 20px #ff3333;
    }

    100% {
        box-shadow: 0 0 10px #ff3333;
    }
}

@keyframes xp-float {
    0% {
        transform: translate(-50%, 0);
        opacity: 0;
    }

    20% {
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50px);
        opacity: 0;
    }
}

@keyframes fade-out {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* Wave UI Styles */
.wave-info {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 100;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.8);
}

.wave-header {
    font-size: 24px;
    font-weight: bold;
    color: #ffcc00;
    margin-bottom: 5px;
}

.wave-enemies {
    font-size: 18px;
}

.wave-countdown {
    margin-top: 5px;
    font-size: 16px;
    color: #ff9933;
}

/* Boss Health Bar Styles */
.boss-health-bar {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 500px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 10px;
    border-radius: 5px;
    z-index: 100;
}

.boss-name {
    font-size: 20px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 5px;
    color: #ff3333;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.boss-health-fill {
    background-color: #ff3333;
}

/* Wave Control Buttons */
.start-wave-btn,
.sync-enemies-btn {
    position: absolute;
    bottom: 20px;
    padding: 8px 15px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px solid #666;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    z-index: 100;
}

.start-wave-btn:hover,
.sync-enemies-btn:hover {
    background-color: rgba(51, 51, 51, 0.8);
}

.start-wave-btn {
    right: 20px;
}

.sync-enemies-btn {
    right: 150px;
}

/* Mobile Adjustments */
@media (max-width: 1050px) {
    .wave-info {
        top: 20px !important;
        padding: 8px 15px !important;
        right: 10px !important;
        left: unset !important;
        transform: unset !important;
        min-width: unset !important;
    }
}

@media (max-width: 768px) {
    .wave-header {
        font-size: 18px;
    }

    .wave-enemies {
        font-size: 14px;
    }

    .game-notification {
        font-size: 18px;
        padding: 10px 20px;
    }

    .start-wave-btn,
    .sync-enemies-btn {
        bottom: 10px;
        padding: 6px 12px;
        font-size: 12px;
    }

    .start-wave-btn {
        right: 10px;
    }

    .sync-enemies-btn {
        right: 110px;
    }
}

@media (max-width: 480px) {
    .wave-header {
        font-size: 15px !important;
    }

    .wave-countdown {
        font-size: 12px !important;
    }
}

/* UI Container for development */
#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 10px;
    color: white;
}

#ui-container.hidden {
    display: none;
}