* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #111;
    color: #fff;
    overflow: hidden;
}

/* Main Menu Styles */
#main-menu {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(to bottom, #112233, #224466);
}

#main-menu h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.class-selection {
    width: 80%;
    max-width: 1000px;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    padding: 2rem;
    text-align: center;
}

.class-selection h2 {
    margin-bottom: 1.5rem;
}

.class-cards {
    display: flex;
    justify-content: space-around;
    margin-bottom: 2rem;
}

.class-card {
    width: 200px;
    height: 250px;
    border-radius: 10px;
    padding: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.class-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.2);
}

.class-card.selected {
    transform: translateY(-10px);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

.class-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(70%);
}

.class-card.disabled:hover {
    transform: none;
    box-shadow: none;
}

.class-card.physical {
    background: linear-gradient(to bottom, #8B0000, #4B0000);
    border: 2px solid #d92121;
}

.class-card.elemental {
    background: linear-gradient(to bottom, #003366, #001933);
    border: 2px solid #2175d9;
}

.class-card.quantum {
    background: linear-gradient(to bottom, #006644, #003322);
    border: 2px solid #21d99b;
}

.class-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

#start-game-btn {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#start-game-btn:hover:not([disabled]) {
    background-color: #367C39;
}

#start-game-btn[disabled] {
    background-color: #555;
    cursor: not-allowed;
}

/* Card Styles */
.card {
    width: 120px;
    height: 180px;
    margin: 0 10px;
    padding: 10px;
    border-radius: 8px;
    background-color: #222;
    color: white;
    border: 2px solid #444;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    user-select: none;
    position: relative;
    z-index: 10;
}

.card:hover {
    transform: translateY(-10px);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.2);
}

.card.highlighted {
    transform: translateY(-15px);
    box-shadow: 0 10px 20px rgba(255, 255, 255, 0.3);
    border-color: #ffff00;
}

.card-cost {
    position: absolute;
    top: 5px;
    left: 5px;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background-color: #444;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
}

.card-name {
    text-align: center;
    font-weight: bold;
    margin: 25px 0 10px;
    font-size: 14px;
}

.card-description {
    text-align: center;
    font-size: 12px;
    flex-grow: 1;
}

.card-stats {
    margin-top: 10px;
    font-size: 11px;
    border-top: 1px solid #444;
    padding-top: 5px;
}

/* Tower Cards */
.card.tower {
    background-color: #333344;
}

/* Buff Cards */
.card.buff {
    background-color: #443333;
}

/* Element Cards */
.card.element {
    background-color: #334433;
}

/* Class Styles */
.card.physical {
    border-color: #d92121;
}

.card.elemental {
    border-color: #2175d9;
}

.card.quantum {
    border-color: #21d99b;
}

/* Element Styles */
.card.element-fire {
    border-color: #ff4400;
}

.card.element-water {
    border-color: #0088ff;
}

.card.element-ice {
    border-color: #88ddff;
}

.card.element-lightning {
    border-color: #ffdd00;
}

.card.element-earth {
    border-color: #885522;
}

.card.element-poison {
    border-color: #88ff00;
}

.card.element-metal {
    border-color: #aaaaaa;
}

.card.element-quantum {
    border-color: #ff00ff;
}

/* Card Rarity Styles */
.card.common {
    border-width: 2px;
}

.card.uncommon {
    border-width: 3px;
}

.card.rare {
    border-width: 3px;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.card.epic {
    border-width: 3px;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.7);
}

.card.legendary {
    border-width: 3px;
    box-shadow: 0 0 12px gold;
}

/* Game Container Styles - New Layout */
#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #222;
    overflow: hidden;
}

#game-ui {
    display: grid;
    grid-template-areas:
        "left game right"
        "bottom bottom bottom";
    grid-template-columns: 1fr minmax(600px, 60vw) 1fr;
    grid-template-rows: auto 150px;
    width: 100%;
    height: 100vh;  
    max-width: 1600px;
    margin: 0 auto;
    padding: 15px;
    box-sizing: border-box;
    gap: 10px;  
    align-items: stretch;
}

#game-window {
    grid-area: game;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
    border: 3px solid #555;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 4/3;
    width: 100%;
    max-height: calc(100vh - 250px);  
}

#left-panel {
    grid-area: left;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    padding: 15px;
    gap: 15px;
    overflow-y: auto;
    height: calc(100vh - 250px);
    max-height: calc(100vh - 250px);
}

#right-panel {
    grid-area: right;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    padding: 15px;
    gap: 15px;
    overflow-y: auto;
    height: calc(100vh - 250px);
    max-height: calc(100vh - 250px);
}

#bottom-panel {
    grid-area: bottom;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    padding: 15px;
    min-height: 150px;
    max-height: 150px;
    overflow: visible;
}

#hand-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    overflow: visible;
    padding: 10px;
    max-width: 100%;
}

#resources-panel, #round-info {
    width: 100%;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    padding: 10px;
    margin-bottom: 15px;
}

.tower-info-panel {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid #555;
    border-radius: 5px;
    padding: 15px;
    min-width: 300px;
    color: white;
    z-index: 1000;
    pointer-events: auto;
    font-size: 14px;
}

.tower-info-panel h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 18px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.close-tower-info-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #444;
    color: white;
    border: none;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.close-tower-info-btn:hover {
    background-color: #555;
}

.tower-badge {
    font-size: 11px;
    padding: 2px 5px;
    border-radius: 3px;
    color: white;
}

.class-badge.physical { 
    background-color: #d92121; 
}

.class-badge.elemental { 
    background-color: #2175d9; 
}

.class-badge.quantum { 
    background-color: #21d99b; 
}

.element-badge.element-fire { 
    background-color: #ff4400; 
}

.element-badge.element-water { 
    background-color: #0088ff; 
}

.element-badge.element-ice { 
    background-color: #88ddff; 
}

.element-badge.element-lightning { 
    background-color: #ffdd00; 
    color: #333; 
}

.element-badge.element-earth { 
    background-color: #885522; 
}

.element-badge.element-poison { 
    background-color: #88ff00; 
    color: #333; 
}

.element-badge.element-metal { 
    background-color: #aaaaaa; 
    color: #333; 
}

.element-badge.element-quantum { 
    background-color: #ff00ff; 
}

.tower-stats-container {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.tower-stats-column {
    flex: 1;
}

.stat-value {
    font-weight: bold;
    color: #aaddff;
}

.tower-capabilities, .tower-upgrades, .tower-effects {
    margin-top: 10px;
    border-top: 1px solid #555;
    padding-top: 8px;
}

.upgrade-slots-container {
    display: flex;
    gap: 5px;
    margin-top: 5px;
}

.upgrade-slot {
    flex: 1;
    padding: 5px;
    text-align: center;
    border-radius: 3px;
    font-size: 12px;
}

.upgrade-slot.empty {
    background-color: #333;
    border: 1px dashed #555;
}

.upgrade-slot.filled {
    background-color: #446;
    border: 1px solid #66a;
}

/* Game speed controls */
.speed-controls {
    display: flex;
    gap: 5px;
    margin-top: 10px;
    justify-content: center;
}

.speed-btn {
    width: 40px;
    height: 30px;
    background: linear-gradient(to bottom, #444, #333);
    color: white;
    border: 1px solid #555;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.speed-btn:hover {
    background: linear-gradient(to bottom, #555, #444);
}

.speed-btn.active {
    background: linear-gradient(to bottom, #006699, #004466);
    border-color: #0088bb;
}

/* Shop Styles */
#shop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

#shop-window {
    width: 80%;
    max-width: 1000px;
    height: 80%;
    background-color: #222;
    border: 3px solid #555;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#shop-header {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, #444, #333);
    border-bottom: 2px solid #555;
}

#shop-header h2 {
    margin: 0;
    color: white;
}

#shop-resources {
    color: gold;
    font-weight: bold;
    font-size: 18px;
}

#shop-tabs {
    display: flex;
    background-color: #444;
}

.shop-tab {
    padding: 10px 20px;
    cursor: pointer;
    border-right: 1px solid #555;
    color: #CCC;
    background: linear-gradient(to bottom, #333, #222);
    transition: all 0.2s;
}

.shop-tab:hover {
    background: linear-gradient(to bottom, #444, #333);
}

.shop-tab.active {
    background: linear-gradient(to bottom, #555, #444);
}

#shop-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 15px;
}

.shop-section {
    margin-bottom: 20px;
}

.shop-section h3 {
    color: #AAA;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
    margin-bottom: 10px;
}

.shop-items {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.shop-item {
    width: 130px;
    height: 200px;
    background-color: #333;
    border-radius: 8px;
    padding: 10px;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s;
    border: 2px solid #444;
}

.shop-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.2);
}

.shop-item-cost {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background-color: gold;
    color: black;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
}

.shop-item-name {
    font-weight: bold;
    margin-bottom: 5px;
    color: white;
}

.shop-item-description {
    font-size: 12px;
    color: #CCC;
}

/* Button Styles */
.ui-button {
    padding: 10px 20px;
    margin: 5px;
    background: linear-gradient(to bottom, #444, #333);
    color: white;
    border: 2px solid #555;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.ui-button:hover:not([disabled]) {
    background: linear-gradient(to bottom, #555, #444);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.ui-button:active:not([disabled]) {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.ui-button[disabled] {
    background: linear-gradient(to bottom, #333, #222);
    color: #777;
    cursor: not-allowed;
    box-shadow: none;
}

.ui-button#open-shop-btn {
    background: linear-gradient(to bottom, #664400, #553300);
    border-color: #775500;
}

.ui-button#open-shop-btn:hover:not([disabled]) {
    background: linear-gradient(to bottom, #775500, #664400);
}

.ui-button#start-round-btn {
    background: linear-gradient(to bottom, #005500, #004400);
    border-color: #006600;
}

.ui-button#start-round-btn:hover:not([disabled]) {
    background: linear-gradient(to bottom, #006600, #005500);
}

.shop-close-btn.ui-button {
    padding: 12px 30px;
    margin: 15px auto;
    display: block;
    font-size: 16px;
}

/* Merge UI */
#merge-container {
    border-top: 1px solid #555;
    padding-top: 15px;
    margin-top: 15px;
}

.merge-slots {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    justify-content: center;
}

.merge-slot {
    width: 140px;
    height: 200px;
    background-color: #333;
    border: 2px dashed #555;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #777;
}

.merge-slot.filled {
    border: 2px solid #777;
    color: white;
}

.merge-plus {
    font-size: 24px;
    margin: 0 10px;
    color: #777;
    align-self: center;
}

.merge-result {
    width: 140px;
    height: 200px;
    background-color: #333;
    border: 2px solid #666;
    border-radius: 8px;
    margin-left: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #777;
}

.merge-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
}

.merge-btn {
    padding: 8px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.merge-btn:disabled {
    background-color: #555;
    cursor: not-allowed;
}

.tier-indicator {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 25px;
    height: 25px;
    background-color: gold;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: black;
    border: 2px solid #333;
}

/* Level Up UI */
.level-up-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1100;
}

.level-up-panel {
    background-color: #222;
    border: 3px solid #555;
    border-radius: 10px;
    padding: 20px;
    width: 80%;
    max-width: 800px;
    text-align: center;
}

.level-up-panel h2 {
    color: #FFD700;
    margin-bottom: 15px;
}

.level-up-options {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
}

.level-up-option {
    width: 200px;
    height: 250px;
    padding: 15px;
    border-radius: 10px;
    background-color: #333;
    border: 2px solid #555;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.level-up-option:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 20px rgba(255, 255, 255, 0.2);
}

.level-up-option.physical {
    border-color: #d92121;
}

.level-up-option.elemental {
    border-color: #2175d9;
}

.level-up-option.quantum {
    border-color: #21d99b;
}

.level-up-option h3 {
    margin-bottom: 10px;
    color: #fff;
}

.level-up-option p {
    font-size: 14px;
    color: #ccc;
    flex-grow: 1;
}

.rank-badge {
    color: gold;
    font-weight: bold;
    margin-left: 5px;
}

/* Victory Screen */
.victory-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1100;
}

.victory-panel {
    width: 80%;
    max-width: 600px;
    background-color: #222;
    border: 3px solid gold;
    border-radius: 10px;
    padding: 30px;
    text-align: center;
}

.victory-panel h1 {
    color: gold;
    font-size: 48px;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.victory-panel p {
    color: white;
    font-size: 18px;
    margin-bottom: 30px;
}

#new-game-btn {
    background: linear-gradient(to bottom, #cc9900, #aa7700);
    border: 2px solid gold;
    font-size: 18px;
    padding: 12px 30px;
}

#new-game-btn:hover {
    background: linear-gradient(to bottom, #eebb00, #cc9900);
}

#world-map-btn {
    background: linear-gradient(to bottom, #006699, #004466);
    border-color: #0088bb;
}

#world-map-btn:hover:not([disabled]) {
    background: linear-gradient(to bottom, #0088bb, #006699);
}

@media (max-width: 1200px) {
    #game-ui {
        grid-template-columns: 0.5fr minmax(500px, 60vw) 0.5fr;
        grid-template-rows: auto 120px;
    }
}

@media (max-width: 900px) {
    #game-ui {
        grid-template-columns: 0.3fr minmax(400px, 60vw) 0.3fr;
    }
}

@media (max-width: 600px) {
    #game-ui {
        grid-template-areas:
            "game"
            "left"
            "right"
            "bottom";
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    
    #left-panel, #right-panel {
        flex-direction: row;
        justify-content: space-around;
    }
}