/* --- THEME & RESET --- */
body {
    font-family: 'Crimson Pro', serif;
    background-color: #1a1a1a;
    color: #000;
    margin: 0;
    display: flex;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
    background: radial-gradient(#3e2b14, #1a1005); 
}

h1, h2, h3, button, .deck-stack, .stats-bar, .deck-label, .die {
    font-family: 'MedievalSharp', cursive;
}

#game-container {
    background: rgba(0, 0, 0, 0.2);
    width: 1000px;
    height: 98vh;
    display: grid;
    /* Fixed small CPU, Fixed Middle, Player gets the rest */
    grid-template-rows: 140px 280px 1fr; 
    gap: 10px;
    padding: 10px;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    margin-top: 1vh;
    border: 1px solid #5c4033;
    border-radius: 8px;
}

/* --- PLAYER ZONES --- */
.player-zone {
    border: 3px double #8b5a2b;
    padding: 5px;
    display: flex;
    flex-direction: column;
    background-color: #f4e4bc;
    background-image: linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0.2));
    box-shadow: inset 0 0 30px rgba(139, 69, 19, 0.2);
    border-radius: 4px;
    overflow: hidden; 
}

/* CPU Specific Styles (Rotation Removed for Readability) */
#cpu-zone {
    /* transform: rotate(180deg);  <-- REMOVED */
    padding: 2px;
}
#cpu-zone .stats-bar {
    /* transform: rotate(180deg); <-- REMOVED */
    padding: 2px 5px;
    font-size: 11px;
    margin-bottom: 2px;
}
#cpu-zone .board-layout {
    gap: 5px;
}
#cpu-zone .chart-column {
    gap: 1px;
    padding: 1px;
    min-width: 100px;
}
#cpu-zone .slot {
    font-size: 10px; /* Slightly increased for readability */
}

/* General Stats Bar */
.stats-bar {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    background: #4a3b2a;
    color: #fceeb5;
    padding: 5px 10px;
    margin-bottom: 5px;
    font-size: 14px;
    border-radius: 2px;
    border: 1px solid #2a2015;
    text-shadow: 1px 1px 0 #000;
}

.board-layout { display: flex; flex-grow: 1; gap: 10px; height: 100%; overflow: hidden; }

/* --- THE CHART (60% Width) --- */
.chart-grid { 
    display: flex; 
    justify-content: flex-start; 
    gap: 5px;
    width: 60%; 
    flex-shrink: 0;
    height: 100%; 
    overflow-x: auto;
    padding-bottom: 5px;
}
.chart-grid::-webkit-scrollbar { height: 8px; }
.chart-grid::-webkit-scrollbar-thumb { background: #8b5a2b; border-radius: 4px; }

.chart-column {
    min-width: 130px; 
    width: 130px;
    border: 2px dashed #a67c52;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 3px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    height: 100%;
    flex-shrink: 0; 
}

.slot {
    border: 1px solid #8b6b4b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    text-align: center;
    white-space: pre-wrap; 
    box-shadow: inset 1px 1px 4px rgba(0,0,0,0.1);
    border-radius: 2px;
    transition: all 0.2s;
    width: 100%;
}

.slot.imp { height: 25%; background: rgba(230, 230, 250, 0.6); } 
.slot.fort { height: 25%; background: rgba(255, 228, 225, 0.6); } 
.slot.land { 
    height: 40%; 
    font-weight: bold; 
    font-family: 'MedievalSharp';
    text-shadow: 1px 1px 0 rgba(255,255,255,0.5);
    border: 2px solid #555;
    flex-grow: 1;
} 

.slot.valid-target {
    background-color: rgba(144, 238, 144, 0.5) !important;
    border: 2px solid #228b22;
    box-shadow: 0 0 10px #228b22;
    cursor: copy;
}

.slot.purchasable { cursor: pointer; }
.slot.purchasable:hover {
    background-color: rgba(255, 215, 0, 0.3) !important; 
    border-color: #d4af37;
    box-shadow: 0 0 5px #d4af37;
}

.hand-card[draggable="true"] { cursor: grab; }
.hand-card[draggable="true"]:active { cursor: grabbing; }

.hand-card.clickable-treasure:hover {
    border-color: #00ff00 !important;
    transform: translateY(-10px);
}

.attacking-unit {
    border: 3px solid #ff0000 !important;
    box-shadow: 0 0 10px #ff0000;
    transform: translateY(-5px);
    z-index: 20;
}

.targetable-land {
    cursor: crosshair !important;
    border: 3px solid #ff4500 !important;
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0% { background-color: rgba(255, 0, 0, 0.1); }
    50% { background-color: rgba(255, 0, 0, 0.3); }
    100% { background-color: rgba(255, 0, 0, 0.1); }
}

.war-cost-indicator {
    position: absolute;
    top: -15px;
    right: 0;
    background: #8b0000;
    color: white;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 4px;
    font-weight: bold;
    z-index: 20;
}

/* ARMY CONTAINER (40% Width) */
.army-container {
    width: 40%; 
    flex-shrink: 0;
    background: #228b22;
    background-image: linear-gradient(rgba(255,255,255,0.1), transparent);
    border: 2px solid #006400;
    border-radius: 4px;
    padding: 5px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-content: flex-start;
    overflow-y: auto;
    position: relative;
}
.army-container.valid-army-target { box-shadow: inset 0 0 15px 5px #adff2f; }

.army-container .hand-card { width: 45px; height: 60px; font-size: 8px; }
.army-container .card-name { margin-top: 15px; font-size: 7px; }

/* --- HAND AREA --- */
.hand-container {
    display: flex;
    flex-direction: row;
    gap: 5px;
    overflow-x: auto; 
    padding: 5px;
    background: linear-gradient(#5c4033, #3e2b14);
    border: 2px solid #2a1d0e;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
    height: 100px; 
    align-items: center;
    border-radius: 4px;
    margin-top: 5px;
}
.hand-container::-webkit-scrollbar { height: 6px; }
.hand-container::-webkit-scrollbar-thumb { background: #8b5a2b; border-radius: 4px; }

/* --- CARDS --- */
.hand-card {
    min-width: 60px;
    width: 60px;
    height: 80px;
    border: 2px solid #333;
    border-radius: 6px;
    background: white;
    display: flex;
    flex-direction: column;
    font-size: 10px;
    position: relative;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.5);
    cursor: pointer;
    flex-shrink: 0; 
    transition: transform 0.2s, box-shadow 0.2s;
}

.hand-card:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 10px 15px rgba(0,0,0,0.5);
    border-color: #ffd700;
    z-index: 10;
}

.card-combat {
    position: absolute;
    top: -2px;
    left: -2px;
    font-weight: bold;
    font-size: 12px;
    border: 1px solid #333;
    width: 16px;
    height: 16px;
    text-align: center;
    line-height: 16px;
    background: #fff;
    z-index: 2;
    border-radius: 50%;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.card-ability {
    position: absolute;
    top: 2px;
    right: 2px;
    font-weight: bold;
    font-size: 11px;
    color: #000;
    text-shadow: 0px 0px 2px white;
    z-index: 2;
    font-family: monospace;
}

.card-name {
    margin-top: 18px;
    text-align: center;
    line-height: 1.1;
    padding: 0 2px;
    font-weight: bold;
    font-size: 9px;
    color: #222;
}

.card-type {
    margin-top: auto; 
    text-align: center;
    background: rgba(255,255,255,0.7);
    padding: 2px;
    border-top: 1px solid rgba(0,0,0,0.1);
    font-weight: bold;
    letter-spacing: 0.5px;
}

.card-back {
    border: 2px solid #ffd700 !important;
    background: #1a1a4a !important;
    background-image: 
        radial-gradient(circle at center, #2a2a6a 2px, transparent 3px),
        repeating-linear-gradient(45deg, rgba(255,215,0,0.1) 0, rgba(255,215,0,0.1) 2px, transparent 2px, transparent 6px) !important;
}

/* --- MIDDLE TABLE --- */
#middle-table {
    background: none;
    display: grid;
    grid-template-columns: 1fr 3fr 1fr; 
    align-items: center;
    padding: 5px 10px;
    color: #fceeb5;
}

.deck-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.deck-stack {
    width: 70px;
    height: 90px;
    border: 2px solid #d4c4a8;
    box-shadow: 5px 5px 10px rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 5px;
    border-radius: 6px;
    text-shadow: 1px 1px 2px black;
    transition: transform 0.1s;
}
.deck-stack:active { transform: scale(0.95); }

.land-deck-style { background: #3e4c28; background-image: repeating-linear-gradient(135deg, rgba(255,255,255,0.1) 0, rgba(255,255,255,0.1) 10px, transparent 10px, transparent 20px); }
.play-deck-style { background: #5c1818; background-image: radial-gradient(circle, rgba(255,215,0,0.2) 2px, transparent 3px); background-size: 15px 15px; }

.deck-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #fceeb5; background: rgba(0,0,0,0.5); padding: 2px 6px; border-radius: 4px; }

#controls-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: 100%;
    background: radial-gradient(closest-side, rgba(255,215,0,0.1), transparent);
    width: 100%;
    gap: 10px;
    padding-top: 10px;
}

#control-row { display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 20px; margin-bottom: 0px; width: 100%; }
#action-group { display: flex; flex-direction: column; align-items: center; }
#dice-box { display: flex; gap: 10px; }

.die {
    width: 35px;
    height: 35px;
    background-color: white;
    border: 1px solid #999;
    border-radius: 6px;
    box-shadow: 2px 2px 0px #ccc, 3px 3px 5px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    color: #000;
}

button {
    padding: 8px 25px;
    font-size: 16px;
    cursor: pointer;
    background: linear-gradient(to bottom, #fce38a, #d4af37 50%, #b8860b);
    border: 2px solid #8b6b4b;
    border-radius: 4px;
    font-weight: bold;
    color: #3e2b14;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
    box-shadow: 0 4px 0 #8b5a2b, 0 5px 10px rgba(0,0,0,0.5);
    transition: all 0.1s;
}
button:active { box-shadow: 0 1px 0 #8b5a2b, 0 2px 5px rgba(0,0,0,0.5); transform: translateY(3px); }

#phase-display { margin-top: 5px; color: #ffd700; font-weight: bold; font-family: 'MedievalSharp'; font-size: 1.0rem; text-shadow: 2px 2px 4px black; background: rgba(0,0,0,0.6); padding: 2px 10px; border-radius: 10px; border: 1px solid #d4af37; }

/* EVENT LOG */
#event-log {
    width: 95%;
    height: 45px; 
    background-color: #fffacd; 
    border: 2px solid #b8860b;
    border-radius: 4px;
    padding: 4px;
    font-size: 13px;
    color: #8b0000;
    overflow-y: auto;
    font-weight: bold;
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.3);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
}

/* BANK AREA */
.bank-area { text-align: center; width: 100%; color: #d4c4a8; display: flex; flex-direction: column; align-items: center; }
.bank-line { border-top: 2px solid #8b5a2b; width: 60%; margin: 0 auto 5px auto; box-shadow: 0 1px 0 rgba(255,255,255,0.1); }

/* Bank Grid - Single Row */
.bank-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    justify-content: center;
    margin-top: 5px;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 5px;
}

.bank-card {
    min-width: 42px;
    width: 42px;
    height: 58px;
    background: #e6e6fa;
    border: 2px solid #4169e1; 
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    color: #000;
    cursor: pointer;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.5);
    flex-shrink: 0;
}
.bank-card:hover { transform: scale(1.1); z-index: 100; border-color: gold; }
.bank-card .combat-val { font-weight: bold; font-size: 10px; border: 1px solid #333; border-radius: 50%; width: 14px; height: 14px; text-align: center; background: white; margin-bottom: 2px; }
.bank-card .name { text-align: center; line-height: 1; padding: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 38px; }

/* Guide Link */
.guide-link {
    margin-top: 8px;
    color: #d4af37;
    text-decoration: none;
    font-family: 'MedievalSharp', cursive;
    font-size: 12px;
    opacity: 0.8;
    transition: 0.2s;
    border-bottom: 1px dotted transparent;
}
.guide-link:hover {
    color: #fff;
    opacity: 1;
    text-decoration: none;
    border-bottom: 1px solid #fff;
    text-shadow: 0 0 5px #ffd700;
}