:root {
    --primary-color: #6C5CE7;
    --secondary-color: #00CEC9;
    --accent-color: #FD79A8;
    --danger-color: #FF7675;
    --boss-color: #D63031;
    --bg-dark: #2D3436;
    --text-light: #F1F2F6;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --font-main: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    user-select: none;
    /* Prevent text selection */
}

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #2d3436 0%, #1e272e 100%);
}

.game-container {
    width: 100%;
    max-width: 600px;
    height: 100vh;
    background: rgba(0, 0, 0, 0.3);
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

/* Header */
.game-header {
    height: 80px;
    padding: 10px 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 10;
}

.title-logo {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--secondary-color);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.progress-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#progress-text {
    font-size: 0.9rem;
    text-align: right;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--secondary-color), var(--primary-color));
    transition: width 0.3s ease;
}

.score-container {
    position: absolute;
    top: 10px;
    right: 20px;
    font-weight: bold;
    font-size: 1.1rem;
}

/* Battle Area */
.battle-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    /* We will use percentages for positioning enemies */
}

/* Optional grid lines for visual aid */
.grid-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-around;
    pointer-events: none;
    opacity: 0.1;
}

.grid-line {
    width: 1px;
    height: 100%;
    background: white;
}

.danger-zone {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--danger-color);
    box-shadow: 0 0 20px var(--danger-color);
    z-index: 5;
}

/* Entities */
.enemy {
    position: absolute;
    width: 80px;
    height: 80px;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    font-size: 1.1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    background: var(--primary-color);
    border-radius: 50%;
    /* Minions are circles */
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
    border: 3px solid rgba(255, 255, 255, 0.2);
    transition: top 0.5s ease-out, transform 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    /* Smooth discrete move */
    z-index: 2;
}

.enemy-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.enemy-hp-bar {
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.3);
    margin-top: 5px;
    border-radius: 2px;
    overflow: hidden;
    display: none;
    /* Hidden for minions unless damaged, but minions die in 1 hit so... */
}

.boss {
    width: 160px;
    height: 160px;
    background: var(--boss-color);
    border-radius: 20px;
    font-size: 2rem;
    box-shadow: 0 10px 30px rgba(214, 48, 49, 0.5);
    z-index: 3;
}

.boss .enemy-hp-bar {
    display: block;
    width: 80%;
}

.boss-hp-fill {
    height: 100%;
    background: #55EFA1;
    width: 100%;
    transition: width 0.2s;
}

/* Animations */
@keyframes spawn {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }

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

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

.spawn-anim {
    animation: spawn 0.5s ease-out forwards;
}

.hit-anim {
    animation: hit 0.2s ease-in-out;
}

@keyframes hit {
    0% {
        transform: translate(-50%, -50%) scale(1);
        filter: brightness(1);
    }

    50% {
        transform: translate(-50%, -50%) scale(0.9);
        filter: brightness(2) sepia(1) hue-rotate(-50deg) saturate(5);
    }

    /* Red flash */
    100% {
        transform: translate(-50%, -50%) scale(1);
        filter: brightness(1);
    }
}

/* Input Area */
.input-area {
    height: 100px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0 20px;
    border-top: 1px solid var(--glass-border);
    z-index: 20;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 400px;
}

#answer-input {
    flex: 1;
    padding: 15px;
    border-radius: 12px;
    border: 2px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.5rem;
    text-align: center;
    outline: none;
    transition: all 0.3s;
}

#answer-input:focus {
    border-color: var(--secondary-color);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 15px rgba(0, 206, 201, 0.3);
}

#answer-input.error {
    animation: shake 0.4s;
    border-color: var(--danger-color);
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.attack-btn {
    padding: 0 30px;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    background: var(--secondary-color);
    color: var(--bg-dark);
    transition: transform 0.2s, background 0.2s;
    display: none;
    /* Auto-match enabled */
}

.attack-btn:active {
    transform: scale(0.95);
    background: #01b8b4;
}

.keyboard-hint {
    margin-top: 5px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    display: none;
    /* Auto-match enabled */
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.overlay.active {
    display: flex;
}

.overlay-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    color: var(--bg-dark);
    max-width: 80%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: popIn 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes popIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.overlay h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.instructions {
    margin: 20px 0;
    text-align: left;
    background: #f1f2f6;
    padding: 15px;
    border-radius: 10px;
}

.instructions p {
    margin: 8px 0;
    font-size: 1.1rem;
}

.primary-btn {
    margin-top: 20px;
    padding: 15px 40px;
    font-size: 1.2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(108, 92, 231, 0.4);
    transition: all 0.3s;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(108, 92, 231, 0.6);
}

/* Damage Popup Text */
.damage-popup {
    position: absolute;
    color: var(--accent-color);
    font-weight: 900;
    font-size: 2rem;
    pointer-events: none;
    animation: floatUp 0.8s ease-out forwards;
    z-index: 10;
    text-shadow: 0 2px 0 white;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(-50px) scale(1.5);
        opacity: 0;
    }
}