/* ============================================
   GRIM DARK FANTASY - Style Sheet
   Palette:
   - Background: Deep Charcoal #1A1C1E
   - Panels: Dark Oak Wood #2D241E
   - Gold Border: Aged Gold #A68966
   - Buttons: Leather/Clay #5D2E2E
   - Button Text: Parchment #E3D5B8
   - Mana: Deep Sapphire #2B527E
   - Text: Parchment #E3D5B8
   ============================================ */

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: #1A1C1E;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #E3D5B8;
}

/* ============================================
   MAIN GAME LAYOUT
   ============================================ */

#game-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Left and Right Side Panels */
#left-panel,
#right-panel {
    width: 200px;
    min-width: 200px;
    background: #2D241E;
    border: 2px solid #A68966;
    display: flex;
    flex-direction: column;
    padding: 15px;
    gap: 15px;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
}

#left-panel {
    border-left: none;
    border-top: none;
    border-bottom: none;
    transform: translateX(0);
}

#right-panel {
    border-right: none;
    border-top: none;
    border-bottom: none;
    transform: translateX(0);
}

/* Collapsed state for panels */
#left-panel.collapsed {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
}

#right-panel.collapsed {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
}

/* Panel Toggle Buttons */
.panel-toggle {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 60px;
    background: #2D241E;
    border: 2px solid #A68966;
    color: #E3D5B8;
    font-size: 18px;
    cursor: pointer;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease-in-out;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
}

.panel-toggle.left {
    left: 0;
    border-left: none;
    border-radius: 0 8px 8px 0;
}

.panel-toggle.right {
    right: 0;
    border-right: none;
    border-radius: 8px 0 0 8px;
}

.panel-toggle:hover {
    background: #3D342E;
    box-shadow: 0 0 15px rgba(166, 137, 102, 0.4);
}

/* Move toggle buttons when panels are visible */
#left-panel:not(.collapsed) ~ #left-toggle,
#left-panel:not(.hidden) ~ #left-toggle {
    left: 200px;
}

#right-panel:not(.collapsed) ~ #right-toggle,
#right-panel:not(.hidden) ~ #right-toggle {
    right: 200px;
}

/* When panels are collapsed, buttons sit at the edge */
#left-panel.collapsed ~ #left-toggle {
    left: 0;
}

#right-panel.collapsed ~ #right-toggle {
    right: 0;
}

/* When panels are hidden (pregame/placement), hide toggles too */
#left-panel.hidden ~ #left-toggle,
#right-panel.hidden ~ #right-toggle {
    display: none;
}

/* Panel Sections */
.panel-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.panel-section.flex-grow {
    flex: 1;
    overflow-y: auto;
}

/* Right Panel Content Area (scrollable) */
.panel-content-area {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Right Panel Toggle Section (fixed at bottom) */
.panel-toggle-section {
    padding-top: 10px;
    border-top: 1px solid #5D4E3E;
    margin-top: 0;
    flex-shrink: 0;
}

/* Initiative and Combat Log views */
#initiative-view,
#combat-log-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#initiative-view.hidden,
#combat-log-view.hidden {
    display: none;
}

#initiative-queue {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 5px;
    background: #1A1C1E;
    border: 1px solid #5D4E3E;
    border-radius: 4px;
    min-height: 0;
}

#combat-log-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    font-size: 12px;
    line-height: 1.5;
    color: #B8A896;
    font-family: monospace;
    background: #1A1C1E;
    border: 1px solid #5D4E3E;
    border-radius: 4px;
    min-height: 0;
}

.panel-title {
    font-weight: bold;
    color: #A68966;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid #5D4E3E;
    padding-bottom: 5px;
    margin-bottom: 5px;
}

/* Game Container (Center) */
#game-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1A1C1E;
    overflow: hidden;
    position: relative;
    text-align: center;
}

#game-container canvas {
    display: inline-block !important;
    margin: auto !important;
    position: relative !important;
    left: auto !important;
    top: auto !important;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ============================================
   INITIATIVE QUEUE (Vertical in Right Panel)
   ============================================ */

#initiative-queue {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #5D4E3E #1A1C1E;
}

#initiative-queue::-webkit-scrollbar {
    width: 6px;
}

#initiative-queue::-webkit-scrollbar-track {
    background: #1A1C1E;
}

#initiative-queue::-webkit-scrollbar-thumb {
    background: #5D4E3E;
    border-radius: 3px;
}

.initiative-unit {
    width: 100%;
    height: 50px;
    background: #1A1C1E;
    border: 2px solid #5D4E3E;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s;
    flex-shrink: 0;
}

.initiative-unit.active {
    border-color: #A68966;
    background: #3D342E;
    box-shadow: 0 0 10px rgba(166, 137, 102, 0.4);
    transform: scale(1.02);
}

.initiative-unit .unit-emoji {
    font-size: 28px;
    line-height: 1;
}

/* Temporal Shift - Animated border for extra turns */
.initiative-unit.temporal-shift {
    border: 2px solid transparent;
    background: linear-gradient(135deg, #2D241E 0%, #3D2A1E 100%);
    animation: temporal-shift-glow 2s ease-in-out infinite;
}

@keyframes temporal-shift-glow {
    0%, 100% {
        border-color: #8B5B9B;
        box-shadow: 0 0 8px rgba(139, 91, 155, 0.4), inset 0 0 6px rgba(139, 91, 155, 0.2);
    }
    50% {
        border-color: #D4A574;
        box-shadow: 0 0 16px rgba(212, 165, 116, 0.6), inset 0 0 10px rgba(212, 165, 116, 0.3);
    }
}

/* Combined active + temporal shift state */
.initiative-unit.active.temporal-shift {
    background: linear-gradient(135deg, #3D342E 0%, #4D3A2E 100%);
    animation: temporal-shift-active-glow 1.5s ease-in-out infinite;
}

@keyframes temporal-shift-active-glow {
    0%, 100% {
        border-color: #A68966;
        box-shadow: 0 0 12px rgba(166, 137, 102, 0.5), 0 0 20px rgba(139, 91, 155, 0.3);
    }
    50% {
        border-color: #D4A574;
        box-shadow: 0 0 20px rgba(212, 165, 116, 0.7), 0 0 30px rgba(139, 91, 155, 0.5);
    }
}

/* ============================================
   UI PANELS & BUTTONS
   ============================================ */

/* Mana Display */
.mana-display {
    padding: 8px 12px;
    background: #2B527E;
    border: 2px solid #4A729E;
    border-radius: 4px;
    color: #B8D5E8;
    font-weight: bold;
    font-size: 14px;
    text-align: center;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.mana-display.low {
    background: #7E2B2B;
    border-color: #9E4A4A;
    color: #E8B8B8;
}

/* Buttons - Leather/Clay Style */
.spell-button {
    padding: 10px 16px;
    background: #5D2E2E;
    border: 2px solid #7D4E4E;
    border-radius: 4px;
    color: #E3D5B8;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 13px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    text-align: center;
}

.spell-button:hover:not(:disabled) {
    background: #7D3E3E;
    border-color: #9D6E6E;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.spell-button:active:not(:disabled) {
    background: #4D1E1E;
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.5);
    transform: translateY(1px);
}

.spell-button:disabled {
    background: #3D3D3D;
    border-color: #555;
    color: #777;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Unit Info Panel (now inside right panel) */
#unit-info {
    background: #1A1C1E;
    border: 1px solid #5D4E3E;
    border-radius: 4px;
    padding: 10px;
    color: #E3D5B8;
    font-size: 13px;
    line-height: 1.5;
    min-height: 100px;
}

/* Magic Buffs List */
#magic-buffs-list {
    background: #1A1C1E;
    border: 1px solid #5D4E3E;
    border-radius: 4px;
    padding: 10px;
    font-size: 12px;
    min-height: 80px;
}

/* Placement Bar */
#placement-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    background: #2D241E;
    border: 2px solid #A68966;
    border-radius: 4px;
    color: #E3D5B8;
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5), 0 4px 15px rgba(0, 0, 0, 0.6);
    z-index: 150;
}

#placement-bar .placement-title {
    font-weight: bold;
    color: #A68966;
}

#placement-bar .placement-hint {
    color: #B8A896;
    font-size: 14px;
}

#placement-bar #placement-info {
    color: #E3D5B8;
    font-weight: bold;
}

/* ============================================
   MODALS & SCREENS
   ============================================ */

/* Victory/Defeat Screen */
.victory-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 28, 30, 0.97);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    z-index: 1000;
    overflow-y: auto;
    padding: 40px 20px;
    box-sizing: border-box;
}

.victory-screen h2 {
    color: #A68966;
    font-size: 48px;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px #000;
}

/* Spellbook Modal */
.spellbook-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 28, 30, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spellbook-content {
    background: #2D241E;
    border: 2px solid #A68966;
    border-radius: 4px;
    padding: 25px;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7);
}

.spellbook-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #5D4E3E;
}

.spellbook-header h2 {
    color: #A68966;
    margin-bottom: 10px;
}

.spell-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.spellbook-close {
    display: block;
    margin: 0 auto;
    padding: 12px 40px;
    background: #5D2E2E;
    border: 2px solid #7D4E4E;
    border-radius: 4px;
    color: #E3D5B8;
    font-weight: bold;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.15s;
}

.spellbook-close:hover {
    background: #7D3E3E;
    border-color: #9D6E6E;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Pre-game screen styles */
#pregame-screen {
    background: rgba(26, 28, 30, 0.98);
    padding: 20px;
}

#pregame-screen h2 {
    color: #A68966;
}

/* Two-step pregame layout */
.pregame-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
}

.pregame-step.hidden {
    display: none !important;
}

/* Map Selection Buttons */
.map-select-btn {
    width: 280px;
    padding: 25px;
    background: #2D241E;
    border: 3px solid #5D4E3E;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.map-select-btn:hover {
    border-color: #A68966;
    background: #3D342E;
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.map-select-btn.selected {
    border-color: #4a7c59;
    box-shadow: 0 0 20px rgba(74, 124, 89, 0.4);
}

.map-preview {
    font-size: 64px;
    line-height: 1;
}

.map-name {
    color: #A68966;
    font-size: 20px;
    font-weight: bold;
}

.map-stats {
    color: #B8A896;
    font-size: 14px;
    line-height: 1.6;
    text-align: center;
}

/* Compact Unit Grid for Step 2 */
.compact-unit-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    max-width: 1200px;
    width: 100%;
    padding: 0 20px;
}

@media (max-width: 1200px) {
    .compact-unit-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .compact-unit-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.unit-card.compact {
    background: #2D241E;
    border: 2px solid #5D4E3E;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.unit-card.compact.specialist {
    border-color: #8B5B9B;
    background: linear-gradient(135deg, #2D241E 0%, #302438 100%);
}

.unit-card.compact.legendary {
    border-color: #ff8c00;
    background: linear-gradient(135deg, #2D241E 0%, #3D2814 100%);
}

.unit-header {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
}

.unit-emoji {
    font-size: 24px;
}

.unit-name {
    color: #A68966;
    font-weight: bold;
    font-size: 14px;
    flex: 1;
}

.unit-card.compact.specialist .unit-name {
    color: #9B6BAB;
}

.unit-card.compact.legendary .unit-name {
    color: #ff8c00;
}

.unit-cost {
    color: #E3D5B8;
    font-size: 12px;
    font-weight: bold;
}

.unit-stats {
    color: #B8A896;
    font-size: 11px;
    line-height: 1.4;
}

.unit-skills {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid rgba(166, 137, 102, 0.2);
}

.unit-skills .passive {
    color: #8B9A6B;
    font-size: 10px;
    font-style: italic;
}

.unit-skills .active {
    color: #6B8BDB;
    font-size: 10px;
    font-weight: bold;
}

.unit-card.compact.specialist .unit-skills .passive {
    color: #9B6BAB;
}

.unit-card.compact.legendary .unit-skills .passive {
    color: #D4A574;
}

.unit-card.compact.legendary .unit-skills .active {
    color: #FFA500;
}

.unit-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 4px;
}

.unit-controls .spell-button {
    padding: 4px 12px;
    font-size: 14px;
    min-width: 32px;
}

.unit-count {
    font-size: 18px;
    font-weight: bold;
    min-width: 25px;
    color: #A68966;
    text-align: center;
}

/* ============================================
   CARDS & REWARDS
   ============================================ */

/* Spell Card */
.spell-card {
    background: #1A1C1E;
    border: 2px solid #5D4E3E;
    border-radius: 4px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    color: #E3D5B8;
    display: flex;
    flex-direction: column;
    min-height: 220px;
}

.spell-card .card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.spell-card:hover:not(.disabled) {
    background: #2A241E;
    border-color: #A68966;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

.spell-card.selected {
    border-color: #4A729E;
    background: #1E2A3E;
}

.spell-card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.spell-card .spell-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.spell-card .spell-name {
    color: #A68966;
    font-weight: bold;
    margin-bottom: 5px;
}

.spell-card .spell-type {
    font-size: 12px;
    color: #888;
    margin-bottom: 5px;
}

.spell-card .spell-desc {
    font-size: 12px;
    color: #B8A896;
    margin-bottom: 8px;
    line-height: 1.3;
}

.spell-card .spell-cost {
    color: #4A729E;
    font-weight: bold;
    font-size: 14px;
}

.spell-card .spell-cost.too-expensive {
    color: #9E4A4A;
}

/* Unit Select Card (for buff target selection) */
.unit-select-card {
    background: #1A1C1E;
    border: 2px solid #5D4E3E;
    border-radius: 4px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.15s;
    color: #E3D5B8;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 120px;
    text-align: center;
}

.unit-select-card:hover {
    background: #2A241E;
    border-color: #A68966;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Perk/Reward Cards */
.perk-card {
    background: #2D241E;
    border: 2px solid #A68966;
    border-radius: 4px;
    padding: 20px;
    margin: 10px;
    cursor: pointer;
    transition: all 0.15s;
    color: #E3D5B8;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.perk-card:hover {
    background: #3D342E;
    border-color: #B69976;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

.reward-card {
    user-select: none;
    display: flex;
    flex-direction: column;
}

.reward-card:hover {
    border-color: #A68966 !important;
}

#confirm-rewards:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   RARITY SECTIONS & STYLES
   ============================================ */

.rarity-section {
    width: 100%;
    margin-bottom: 25px;
    padding: 15px;
    background: rgba(45, 36, 30, 0.4);
    border-radius: 8px;
    border: 1px solid rgba(166, 137, 102, 0.2);
}

.rarity-title {
    color: #A68966;
    font-size: 18px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 15px;
    text-align: center;
    border-bottom: 1px solid rgba(166, 137, 102, 0.3);
    padding-bottom: 8px;
}

/* Legendary glow animation */
@keyframes legendary-glow {
    0%, 100% {
        box-shadow: 0 0 3px #ff8c00, 0 0 6px rgba(255, 140, 0, 0.6), inset 0 0 4px rgba(255, 140, 0, 0.2);
        border-color: #ff8c00;
    }
    50% {
        box-shadow: 0 0 5px #ff8c00, 0 0 10px rgba(255, 140, 0, 0.8), inset 0 0 6px rgba(255, 140, 0, 0.3);
        border-color: #ffa500;
    }
}

.legendary-card {
    animation: legendary-glow 2.5s ease-in-out infinite;
    border: 2px solid #ff8c00 !important;
    background: linear-gradient(135deg, #2D241E 0%, #3D2814 100%) !important;
}

.legendary-card:hover {
    animation: legendary-glow 1.5s ease-in-out infinite;
    border-color: #ffa500 !important;
}

/* Specialist glow animation */
@keyframes specialist-glow {
    0%, 100% {
        box-shadow: 0 0 2px #8B5B9B, 0 0 4px rgba(139, 91, 155, 0.4), inset 0 0 3px rgba(139, 91, 155, 0.15);
        border-color: #8B5B9B;
    }
    50% {
        box-shadow: 0 0 4px #8B5B9B, 0 0 6px rgba(139, 91, 155, 0.5), inset 0 0 4px rgba(139, 91, 155, 0.2);
        border-color: #9B6BAB;
    }
}

.specialist-card {
    animation: specialist-glow 3s ease-in-out infinite;
    border: 2px solid #8B5B9B !important;
    background: linear-gradient(135deg, #2D241E 0%, #302438 100%) !important;
}

.specialist-card:hover {
    animation: specialist-glow 2s ease-in-out infinite;
    border-color: #9B6BAB !important;
}

/* Mythic glow animation */
@keyframes mythic-glow {
    0%, 100% {
        box-shadow: 0 0 4px #e50000, 0 0 8px rgba(229, 0, 0, 0.5), inset 0 0 5px rgba(229, 0, 0, 0.3);
        border-color: #cc0000;
    }
    50% {
        box-shadow: 0 0 8px #ff1a1a, 0 0 12px rgba(255, 26, 26, 0.8), inset 0 0 8px rgba(255, 26, 26, 0.5);
        border-color: #ff3333;
    }
}

.mythic-card {
    animation: mythic-glow 2s ease-in-out infinite;
    border: 2px solid #e50000 !important;
    background: linear-gradient(135deg, #2D1A1A 0%, #3D0000 100%) !important;
}

.mythic-card:hover {
    animation: mythic-glow 1s ease-in-out infinite;
    border-color: #ff1a1a !important;
}

/* Stage Selection Buttons */
.stage-btn {
    transition: all 0.2s ease;
    border: 2px solid #5D4E3E;
}

.stage-btn:hover {
    border-color: #A68966;
    transform: translateY(-2px);
}

.stage-btn.active {
    border-color: #4a7c59;
    box-shadow: 0 0 10px rgba(74, 124, 89, 0.5);
}

/* ============================================
   FACTION SELECTION STYLES
   ============================================ */

.faction-select-btn {
    width: 280px;
    padding: 25px;
    background: #2D241E;
    border: 3px solid #5D4E3E;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.faction-select-btn:hover {
    border-color: #A68966;
    background: #3D342E;
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.faction-select-btn.selected {
    border-color: #d94a4a;
    box-shadow: 0 0 20px rgba(217, 74, 74, 0.4);
}

.faction-preview {
    width: 120px;
    height: 120px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: #1A1C1E;
    border: 2px solid #5D4E3E;
}

.faction-preview.random-preview {
    font-size: 64px;
    background: linear-gradient(135deg, #3D342E 0%, #2D3838 100%);
}

.faction-preview.greenskin-preview {
    background: linear-gradient(135deg, #2D3D2E 0%, #3D4D3E 100%);
}

.faction-preview.dungeon-preview {
    background: linear-gradient(135deg, #2D2D3E 0%, #3D3D4E 100%);
}

.faction-preview.cultist-preview {
    background: linear-gradient(135deg, #3D1E1E 0%, #4D2E2E 100%);
}

.faction-unit-img {
    position: absolute;
    image-rendering: pixelated;
}

.faction-unit-img.main {
    width: 80px;
    height: 80px;
    z-index: 2;
}

.faction-unit-img.sub1 {
    width: 50px;
    height: 50px;
    top: 5px;
    right: 5px;
    z-index: 1;
    opacity: 0.9;
}

.faction-unit-img.sub2 {
    width: 50px;
    height: 50px;
    bottom: 5px;
    left: 5px;
    z-index: 1;
    opacity: 0.9;
}

.faction-name {
    color: #A68966;
    font-size: 20px;
    font-weight: bold;
}

.faction-description {
    color: #B8A896;
    font-size: 14px;
    line-height: 1.6;
    text-align: center;
}

/* Faction specific accent colors for selected state */
.faction-select-btn[data-faction="random"].selected {
    border-color: #A68966;
    box-shadow: 0 0 20px rgba(166, 137, 102, 0.4);
}

.faction-select-btn[data-faction="greenskin"].selected {
    border-color: #4a7c59;
    box-shadow: 0 0 20px rgba(74, 124, 89, 0.4);
}

.faction-select-btn[data-faction="dungeon"].selected {
    border-color: #8B5B9B;
    box-shadow: 0 0 20px rgba(139, 91, 155, 0.4);
}

.faction-select-btn[data-faction="cultist"].selected {
    border-color: #d94a4a;
    box-shadow: 0 0 20px rgba(217, 74, 74, 0.4);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.hidden {
    display: none !important;
}

.text-gold {
    color: #A68966;
}

.text-parchment {
    color: #E3D5B8;
}

.text-wood {
    color: #B8A896;
}

.bg-charcoal {
    background: #1A1C1E;
}

.bg-wood {
    background: #2D241E;
}

.border-gold {
    border-color: #A68966;
}

.action-divider {
    width: 2px;
    height: 30px;
    background: #5D4E3E;
    margin: 0 5px;
}

/* Confirm placement button states */
#confirm-placement:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #3D3D3D !important;
    border-color: #555 !important;
}

#confirm-placement:not(:disabled) {
    background: #2E5D2E !important;
    border-color: #4E7D4E !important;
}

#confirm-placement:not(:disabled):hover {
    background: #3E7D3E !important;
    border-color: #5E9D5E !important;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 1024px) {
    #left-panel,
    #right-panel {
        width: 170px;
        min-width: 170px;
        padding: 10px;
    }
    
    #left-panel:not(.collapsed) ~ #left-toggle,
    #left-panel:not(.hidden) ~ #left-toggle {
        left: 170px;
    }

    #right-panel:not(.collapsed) ~ #right-toggle,
    #right-panel:not(.hidden) ~ #right-toggle {
        right: 170px;
    }
    
    #left-panel.collapsed ~ #left-toggle {
        left: 0;
    }

    #right-panel.collapsed ~ #right-toggle {
        right: 0;
    }
    
    .spell-button {
        padding: 8px 12px;
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    #game-layout {
        flex-direction: column;
    }
    
    #left-panel,
    #right-panel {
        width: 100%;
        min-width: auto;
        max-height: 120px;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 10px;
        border: none;
        border-top: 2px solid #A68966;
        transform: translateY(0) !important;
    }
    
    #left-panel.collapsed,
    #right-panel.collapsed {
        transform: translateY(-100%) !important;
    }
    
    #left-panel {
        order: 2;
        border-bottom: 2px solid #A68966;
    }
    
    #right-panel {
        order: 3;
    }
    
    #game-container {
        order: 1;
        flex: 1;
    }
    
    .panel-section.flex-grow {
        flex: 0 0 auto;
        min-width: 150px;
    }
    
    .panel-toggle {
        display: none;
    }
}


/* ============================================
   LANGUAGE TOGGLE SWITCH
   ============================================ */

.lang-toggle-switch {
    position: relative;
    width: 80px;
    height: 32px;
    background: #2D241E;
    border: 2px solid #A68966;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    overflow: hidden;
}

.lang-toggle-switch:hover {
    border-color: #B69976;
    box-shadow: 0 0 15px rgba(166, 137, 102, 0.3);
}

.lang-toggle-switch:active {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.lang-label {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #8B7355;
    z-index: 2;
    transition: color 0.3s ease;
    pointer-events: none;
}

.lang-label.left {
    margin-right: auto;
    padding-left: 4px;
}

.lang-label.right {
    margin-left: auto;
    padding-right: 4px;
}

.lang-label.active {
    color: #E3D5B8;
}

.lang-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 36px;
    height: 24px;
    background: linear-gradient(135deg, #A68966 0%, #8B7355 100%);
    border-radius: 12px;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    z-index: 1;
}

/* When Russian is active, slide to the right */
.lang-toggle-switch.ru .lang-slider {
    transform: translateX(36px);
}

.lang-toggle-switch.ru .lang-label.left {
    color: #8B7355;
}

.lang-toggle-switch.ru .lang-label.right {
    color: #E3D5B8;
}

/* When English is active (default) */
.lang-toggle-switch:not(.ru) .lang-label.left {
    color: #E3D5B8;
}

.lang-toggle-switch:not(.ru) .lang-label.right {
    color: #8B7355;
}

#lang-toggle-container {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hide language toggle on game screens */
#game-layout ~ #lang-toggle-container,
#game-layout:not(.hidden) ~ #lang-toggle-container {
    display: none;
}
