:root {
    --primary-color: #9c27b0;
    --secondary-color: #ff5722;
    --accent-color: #00e676;
    --text-color: #e0e0e0;
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --success-color: #4caf50;
    --danger-color: #f44336;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Creepster', 'Segoe UI', cursive, sans-serif;
    user-select: none;
    touch-action: manipulation;
}

html {
    height: 100%;
    font-size: 16px;
}

body {
    background: radial-gradient(circle at top, #240033 0%, #0f011a 45%, #050008 100%);
    color: var(--text-color);
    min-height: 100%;
    height: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

#app-shell {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.game-header {
    background: transparent;
    border-bottom: none;
    box-shadow: none;
}

.game-brand {
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.game-title {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    letter-spacing: 1px;
}

.game-subtitle {
    font-size: clamp(0.9rem, 2.2vw, 1.1rem);
    color: rgba(255, 255, 255, 0.7);
}

.game-main {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(18px, 4vw, 48px) clamp(12px, 4vw, 36px);
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.game-footer {
    background: transparent;
    border-top: none;
    box-shadow: none;
}

#game-container {
    width: 100%;
    max-width: 900px;
    min-height: min(540px, 100%);
    height: 100%;
    max-height: 100%;
    background: transparent;
    border-radius: 24px;
    box-shadow: none;
    overflow: hidden;
    border: none;
    position: relative;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
}

#battle-area {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: transparent;
    gap: clamp(12px, 2.5vw, 22px);
    flex: 1;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
}

#battle-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(8px, 2vw, 24px);
    flex-wrap: wrap;
}

#level-indicator {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-color);
    padding: clamp(4px, 1.2vw, 10px) clamp(12px, 3vw, 22px);
    border-radius: 999px;
    font-weight: bold;
    font-size: clamp(0.95rem, 2.5vw, 1.2rem);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: clamp(6px, 1.5vw, 14px);
    min-width: 150px;
    text-align: center;
    flex: 0 1 auto;
}

.level-label {
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.85em;
    opacity: 0.85;
}

#action-buttons {
    display: flex;
    gap: clamp(6px, 1.5vw, 16px);
    align-items: center;
    flex-wrap: nowrap;
    justify-content: flex-end;
    flex: 1 1 auto;
    min-width: 0;
}

.game-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: clamp(6px, 1.5vw, 12px) clamp(16px, 3vw, 24px);
    border-radius: 10px;
    font-weight: bold;
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

#action-buttons .game-btn {
    white-space: nowrap;
    flex: 0 0 auto;
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.game-btn:active {
    transform: translateY(0);
}

.reset-btn {
    background: transparent;
    box-shadow: none;
    padding: 5px;
    font-size: 1.5rem;
    border-radius: 50%;
}

.reset-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

#boss-container {
    position: relative;
    text-align: center;
    cursor: pointer;
    transition: transform 0.1s;
    padding: 10px;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1 0 auto;
}

#boss-container:active {
    transform: scale(0.95);
}

#boss-image {
    width: clamp(180px, 32vw, 320px);
    height: clamp(180px, 32vw, 320px);
    font-size: clamp(90px, 18vw, 160px);
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    cursor: pointer;
    user-select: none;
    transition: transform 0.1s;
    pointer-events: none;
    animation: float 2s ease-in-out infinite;
    filter: drop-shadow(0 0 15px rgba(156, 39, 176, 0.5));
}

#boss-image.hit {
    transform: scale(0.9);
    filter: sepia(1) hue-rotate(-50deg) saturate(5) drop-shadow(0 0 20px red);
}

#boss-name {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-color);
    text-shadow: 0 0 10px var(--primary-color);
    margin-bottom: 10px;
}

#battle-info {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(10px, 2vw, 18px);
    margin-top: auto;
}

#battle-status {
    width: min(100%, 520px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

#health-bar-container {
    width: 100%;
    height: 15px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #555;
}

#health-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #9c27b0, #e040fb);
    width: 100%;
    transition: width 0.2s ease-out;
}

#health-text {
    margin-top: 5px;
    color: var(--text-color);
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.damage-number {
    position: absolute;
    color: white;
    font-weight: bold;
    font-size: 1.5rem;
    pointer-events: none;
    animation: floatUp 0.8s ease-out forwards;
    text-shadow: 0 0 5px red;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(-50px) scale(1.2);
        opacity: 0;
    }
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-40px);
    }

    100% {
        transform: translateY(0px);
    }
}

#stats-panel {
    margin-top: clamp(16px, 3vw, 32px);
    padding: clamp(14px, 3vw, 24px);
    background: rgba(30, 30, 30, 0.8);
    border-radius: 15px;
    border: 1px solid #333;
    width: min(100%, 420px);
    align-self: stretch;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    font-size: clamp(0.95rem, 1.6vw, 1.1rem);
    color: #bbb;
}

.stat-value {
    font-weight: bold;
    color: var(--secondary-color);
}

#energy-bar-container {
    width: 100%;
    height: 10px;
    background: #333;
    border-radius: 5px;
    overflow: hidden;
    margin-top: 5px;
}

#energy-bar-fill {
    height: 100%;
    background: var(--accent-color);
    width: 100%;
    transition: width 0.1s linear;
}

.modal-content {
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid #444;
}

.modal-header {
    border-bottom: 1px solid #444;
}

.modal-title {
    color: var(--text-color);
}

.modal-body {
    max-height: 60vh;
}

#upgrades-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.upgrade-item {
    background: #2c2c2c;
    border: 1px solid #444;
    border-radius: 10px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.upgrade-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    border-color: var(--secondary-color);
}

.upgrade-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

.upgrade-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.upgrade-name {
    font-weight: bold;
    color: var(--text-color);
}

.upgrade-cost {
    color: var(--secondary-color);
    font-weight: bold;
}

.upgrade-desc {
    font-size: 0.9rem;
    color: #888;
}

.upgrade-level {
    font-size: 0.8rem;
    color: #666;
    margin-top: 5px;
}

#skills-container {
    display: flex;
    gap: 10px;
    margin-top: 0;
    justify-content: center;
    flex-wrap: wrap;
    align-items: stretch;
    width: 100%;
}

.skill-btn {
    background: transparent;
    border: none;
    color: white;
    padding: 0;
    border-radius: 999px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    width: clamp(60px, 18vw, 120px);
    flex: 0 1 clamp(80px, 28vw, 150px);
    min-width: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.skill-btn:hover:not(.disabled) {
    transform: scale(1.05);
}

.skill-btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(1);
}

.skill-icon {
    font-size: clamp(2.2rem, 8vw, 4.2rem);
    margin: 0;
    line-height: 1;
}

.skill-name {
    display: none;
}

.skill-cooldown-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: rgba(0, 0, 0, 0.7);
    transition: height 0.1s linear;
}

.skill-timer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    font-size: 0.9rem;
    text-shadow: 0 0 5px black;
    display: none;
}

.skill-btn.disabled .skill-timer {
    display: block;
}

#golden-ghost {
    position: absolute;
    font-size: clamp(60px, 14vw, 100px);
    cursor: pointer;
    z-index: 100;
    filter: drop-shadow(0 0 15px gold);
    transition: transform 0.1s;
    user-select: none;
}

#golden-ghost.hidden {
    display: none;
}

#golden-ghost:active {
    transform: scale(0.9);
}

@keyframes floatAcross {
    0% {
        left: -100px;
        top: 20%;
    }

    25% {
        top: 40%;
    }

    50% {
        top: 10%;
    }

    75% {
        top: 60%;
    }

    100% {
        left: 120%;
        top: 30%;
    }
}

@media (max-width: 1024px) {
    .game-main {
        padding: clamp(18px, 6vw, 36px) clamp(12px, 6vw, 30px);
    }

    .game-header {
        padding: 1.25rem 0;
    }

    #game-container {
        min-height: 0;
        height: 100%;
        max-height: 100%;
    }

    #boss-image {
        width: clamp(180px, 38vw, 280px);
        height: clamp(180px, 38vw, 280px);
    }

    #health-bar-container {
        width: 80%;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 17px;
    }

    .game-header {
        text-align: center;
    }

    .game-main {
        padding: clamp(16px, 8vw, 32px) clamp(12px, 7vw, 28px);
    }

    #game-container {
        width: 100%;
        min-height: 0;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    #battle-area {
        align-items: stretch;
        gap: clamp(10px, 4vw, 18px);
    }

    #battle-info {
        width: 100%;
        gap: 8px;
    }

    #battle-status {
        width: 100%;
    }

    #battle-header {
        width: 100%;
        flex-wrap: nowrap;
        gap: 6px;
    }

    #level-indicator {
        min-width: 130px;
        font-size: 1.05rem;
        padding: 6px 14px;
    }

    #action-buttons {
        gap: 6px;
    }

    #action-buttons .game-btn {
        padding: 7px 14px;
        font-size: 1rem;
    }

    #boss-container {
        padding: 0;
        margin: 5px auto 10px;
    }

    #boss-name {
        font-size: 1.6rem;
        margin-bottom: 6px;
    }

    #boss-image {
        width: clamp(150px, 50vw, 220px);
        height: clamp(150px, 50vw, 220px);
        font-size: clamp(80px, 16vw, 140px);
    }

    #health-bar-container {
        width: 100%;
        height: 10px;
    }

    #health-text {
        font-size: 1.1rem;
        margin-top: 4px;
    }

    #skills-container {
        margin-top: 1.8rem;
        gap: 8px;
        justify-content: center;
    }

    .skill-btn {
        flex: 0 1 calc(50% - 8px);
        max-width: none;
    }

    #stats-panel {
        width: 100%;
        margin-top: 8px;
        margin-bottom: 10px;
        padding: 12px;
    }

    .stat-row {
        margin-bottom: 6px;
        font-size: 1.05rem;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    #energy-bar-container {
        height: 6px;
        margin-top: 4px;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 18px;
    }

    .game-main {
        padding: clamp(14px, 9vw, 24px) clamp(10px, 8vw, 20px);
    }

    #battle-info {
        gap: 6px;
    }

    #battle-header {
        flex-wrap: nowrap;
        gap: 0px;
    }

    #level-indicator {
        min-width: 140px;
        font-size: 1.1rem;
        padding: 7px 16px;
    }

    #action-buttons {
        gap: 0px;
    }

    #action-buttons .game-btn {
        padding: 8px 16px;
        font-size: 1.05rem;
        min-width: 80px;
    }

    .game-btn {
        font-size: 1.05rem;
    }

    #boss-name {
        font-size: 1.7rem;
    }

    #boss-image {
        width: clamp(130px, 60vw, 200px);
        height: clamp(130px, 60vw, 200px);
        font-size: clamp(70px, 18vw, 120px);
    }

    #health-text {
        font-size: 1.15rem;
    }

    .skill-btn {
        min-width: 70px;
    }

    #stats-panel {
        width: 100%;
        max-width: none;
        align-self: stretch;
        padding: 14px;
        font-size: 1.1rem;
    }

    #stats-panel .stat-value {
        font-size: 1.25rem;
    }
}