/* Main CSS - mostly reused from user provided prototype */
@import url('https://fonts.googleapis.com/css2?family=Black+Ops+One&family=Press+Start+2P&display=swap');

body {
    margin: 0;
    padding: 0;
    background-color: #1a1a1a;
    color: white;
    font-family: 'Press Start 2P', cursive;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    user-select: none;
}

#game-wrapper {
    position: relative;
    border: 4px solid #fff;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    width: 1280px;
    height: 720px;
}

canvas {
    display: block;
    background-color: #4a854a;
    image-rendering: pixelated;
}

/* UI Layer */
#ui-layer {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-box {
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border: 2px solid #fff;
    border-radius: 4px;
    text-shadow: 2px 2px 0 #000;
}

.hp-container {
    width: 200px;
    height: 24px;
    background: #222;
    border: 2px solid #fff;
    margin-top: 5px;
    position: relative;
}

.hp-fill {
    height: 100%;
    background: #e74c3c;
    width: 100%;
    transition: width 0.1s linear;
}

/* Skill UI */
#skill-ui {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 15px;
    pointer-events: none;
}

.skill-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.skill-icon {
    width: 50px;
    height: 50px;
    background: #3498db;
    border: 3px solid #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    font-weight: bold;
    position: relative;
    margin-bottom: 5px;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s;
    overflow: hidden;
    /* Ensure image stays inside */
}

.hud-skill-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: pixelated;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
}

.skill-icon:active {
    transform: scale(0.95);
}

.skill-level-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #f1c40f;
    color: #000;
    font-size: 10px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #fff;
    z-index: 2;
}

.skill-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: rgba(0, 0, 0, 0.7);
    transition: height 0.1s linear;
}

.skill-name {
    font-size: 10px;
    text-shadow: 1px 1px 0 #000;
    background: rgba(0, 0, 0, 0.5);
    padding: 2px 4px;
    border-radius: 3px;
}

/* Text & Warnings */
#combo-display {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 20px;
    color: #ffcc00;
    text-shadow: 2px 2px 0 #000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
}

#boss-warning {
    position: absolute;
    top: 40%;
    width: 100%;
    text-align: center;
    color: #ff0000;
    font-size: 40px;
    font-family: 'Black Ops One', cursive;
    text-shadow: 4px 4px 0 #000;
    display: none;
    animation: blink 0.5s infinite;
    pointer-events: none;
}

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

    50% {
        opacity: 0.5;
        transform: scale(1.1);
    }

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

/* Screens */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#start-screen {
    background-image: radial-gradient(circle, rgba(52, 152, 219, 0.2) 0%, rgba(0, 0, 0, 0.9) 70%);
}

h1 {
    font-family: 'Black Ops One', cursive;
    font-size: 50px;
    color: #f1c40f;
    margin: 0 0 20px 0;
    text-shadow: 4px 4px 0 #000;
    text-align: center;
    line-height: 1.2;
}

/* Shop UI */
.shop-ui {
    width: 90%;
    height: 90%;
    background: #222;
    border: 4px solid #fff;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}

.shop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 2px solid #444;
    padding-bottom: 10px;
}

.shop-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.shop-tab-btn {
    background: #333;
    border: 2px solid #555;
    color: #aaa;
    padding: 10px 20px;
    cursor: pointer;
    font-family: 'Press Start 2P';
    font-size: 12px;
}

.shop-tab-btn.active {
    background: #3498db;
    color: #fff;
    border-color: #fff;
}

.shop-content {
    display: none;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    /* Fix horizontal scroll */
}

.shop-content.active {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#tab-stats.active {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
}

#tab-skills {
    flex-direction: column-reverse;
    justify-content: flex-start;
    padding-top: 20px;
}

.skill-tree-row {
    display: flex;
    justify-content: center;
    position: relative;
    padding: 20px 0;
    border: 1px dashed #444;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
}

.skill-tree-arrow {
    position: absolute;
    top: -20px;
    left: 50%;
    width: 2px;
    height: 20px;
    background: #555;
    transform: translateX(-50%);
}

.shop-item {
    background: #2c2c2c;
    border: 2px solid #444;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 120px;
    min-width: 180px;
    /* Reduced to prevent overflow */
    position: relative;
    align-items: center;
}

.shop-item:hover {
    background: #3a3a3a;
    border-color: #3498db;
}

.shop-item.locked {
    filter: grayscale(100%);
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #555;
}

.shop-item.maxed {
    border-color: #f1c40f;
    background: #332b00;
}

.shop-icon-wrapper {
    width: 48px;
    height: 48px;
    background: #222;
    border: 2px solid #555;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
    overflow: hidden;
}

.shop-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: pixelated;
}

.shop-item h3 {
    font-size: 14px;
    color: #3498db;
    margin-bottom: 8px;
}

.shop-item .desc {
    font-size: 10px;
    color: #aaa;
    margin-bottom: 10px;
    line-height: 1.4;
    flex-grow: 1;
}

.shop-item .cost {
    color: #f1c40f;
    font-size: 12px;
    margin-top: auto;
}

.shop-item .current-lv {
    font-size: 10px;
    color: #fff;
    margin-top: 5px;
}

.lock-msg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: red;
    padding: 5px;
    font-size: 10px;
    display: none;
    width: 100%;
}

.shop-item.locked:hover .lock-msg {
    display: block;
}

button.action-btn {
    padding: 15px 40px;
    font-family: 'Press Start 2P', cursive;
    font-size: 16px;
    background: #e74c3c;
    border: 4px solid #fff;
    cursor: pointer;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
}

button.action-btn:hover {
    background: #c0392b;
}

#controls {
    position: absolute;
    bottom: 10px;
    left: 20px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 1px 1px 0 #000;
    text-align: left;
}