body {
    margin: 0;
    font-family: sans-serif;
    background-color: #222;
    display: flex;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
}

#game-container {
    width: 100%;
    max-width: 450px;
    background-color: #4a8c38; /* Gräsplan */
    position: relative;
    display: flex;
    flex-direction: column;
    border: 2px solid #000;
}

/* --- TORN POSITIONERING --- */
.tower-area {
    height: 100%; /* Täcker hela ytan logiskt för positionering */
    pointer-events: none; /* Klick går igenom */
    position: absolute;
    width: 100%;
    top: 0;
    left: 0;
}

.tower {
    position: absolute;
    text-align: center;
    font-size: 2.5rem;
    pointer-events: auto;
    width: 60px;
    z-index: 5;
}

/* Fiende Torn */
#e-tower-left { left: 15%; top: 60px; transform: translateX(-50%); }
#e-tower-king { left: 50%; top: 20px; transform: translateX(-50%); }
#e-tower-right { left: 85%; top: 60px; transform: translateX(-50%); }

/* Spelare Torn */
#p-tower-left { left: 15%; bottom: 160px; transform: translateX(-50%); }
#p-tower-king { left: 50%; bottom: 120px; transform: translateX(-50%); }
#p-tower-right { left: 85%; bottom: 160px; transform: translateX(-50%); }

.tower span {
    display: block;
    font-size: 0.8rem;
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 2px;
    border-radius: 4px;
}

/* --- SPELPLAN --- */
#battlefield {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.unit {
    position: absolute;
    font-size: 2rem;
    /* Centrera gubben på sin koordinat */
    transform: translate(-50%, -50%);
    will-change: top, left, transform;
    z-index: 10;
}

.health-bar {
    position: absolute;
    top: -10px; left: 0;
    width: 100%; height: 4px;
    background: red;
}
.health-bar-inner {
    height: 100%; background: #0f0; width: 100%;
}

/* --- UI --- */
#ui-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 20;
}

#top-bar {
    position: absolute;
    top: 10px;
    width: 100%;
    display: flex;
    justify-content: center;
}

#game-timer {
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 5px 10px;
    border-radius: 5px;
    font-weight: bold;
    font-size: 1.2rem;
    border: 1px solid white;
}

#elixir-bar {
    position: absolute;
    bottom: 120px;
    left: 10px;
    background: rgba(0,0,0,0.8);
    color: #d442f5;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 1.5rem;
    font-weight: bold;
    border: 2px solid #d442f5;
}

#elixir-mult {
    color: yellow;
    font-size: 0.8em;
    margin-left: 5px;
}

#deck {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 100px;
    background: #222;
    display: flex;
    justify-content: space-around;
    align-items: center;
    pointer-events: auto;
    border-top: 3px solid #000;
}

.card {
    width: 60px; height: 80px;
    background: #444;
    border: 2px solid #888;
    border-radius: 5px;
    display: flex; justify-content: center; align-items: center;
    font-size: 2rem;
    cursor: pointer;
    position: relative;
}
.card.disabled { opacity: 0.4; pointer-events: none; }
.card-cost {
    position: absolute; top: -8px; left: -8px;
    background: #d442f5; color: white;
    font-size: 0.9rem; border-radius: 50%;
    width: 24px; height: 24px;
    display: flex; justify-content: center; align-items: center;
    border: 2px solid #fff;
}

#message-box {
    position: absolute;
    top: 40%; width: 100%;
    text-align: center;
    color: gold;
    font-size: 2rem;
    text-shadow: 2px 2px 0 #000;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s;
}