/* Amiga-inspired Theme - Fixed & Stable */

body {
    font-family: 'monospace', sans-serif;
    background-color: #111133;
    color: #EEEEEE;
    margin: 0;
    padding: 15px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    text-shadow: 1px 1px #000000;
}

#game-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    grid-template-rows: auto auto 1fr auto auto;
    gap: 15px;
    max-width: 1400px;
    width: 100%;
    background-color: #333366;
    border: 4px solid #6666AA;
    box-shadow: 8px 8px 0px #000000;
    padding: 15px;
    position: relative;
}

/* Header */
#header {
    grid-column: 1 / -1;
    text-align: center;
    padding: 10px;
    background-color: #000088;
    border-bottom: 4px solid #6666AA;
    box-shadow: 4px 4px 0px #000000;
}
#header h1 { color: #FFFF00; margin: 0; font-size: 2.5em; text-shadow: 2px 2px #FF00FF; letter-spacing: 3px; }
#header h2 { color: #00FFFF; margin: 5px 0 0 0; font-size: 1.2em; font-weight: normal; }

/* Sidebars */
#game-info, #player-info {
    grid-column: 1;
    background-color: #444488;
    padding: 12px;
    border: 2px solid #6666AA;
    box-shadow: inset 2px 2px 0px #222244;
}
#player-info { overflow-y: auto; max-height: 600px; }
#player-info h2 { color: #FFFF00; margin-top: 0; border-bottom: 2px solid #6666AA; }

.faction-item { padding: 8px; margin-bottom: 8px; border: 2px solid #6666AA; background-color: #222244; font-size: 0.9em; }
.faction-item.active-player { background-color: #004400; border-color: #00FF00; box-shadow: 0 0 5px #00FF00; }

/* SVG Game Board */
#game-board {
    grid-column: 2;
    grid-row: 2 / span 3;
    background-color: #222244;
    border: 3px solid #6666AA;
    box-shadow: inset 4px 4px 0px #111133;
    position: relative;
    height: 600px;
    overflow: hidden;
    transition: background-color 0.5s ease;
}

/* SVG Elements */
svg#map-svg { width: 100%; height: 100%; }
.connection-line { stroke: #00FFFF; stroke-width: 2; opacity: 0.3; }

.territory-group { cursor: pointer; }
.territory-rect { fill: #444488; stroke: #6666AA; stroke-width: 3; transition: all 0.2s ease; filter: drop-shadow(3px 3px 0px #000); }

/* Highlight Only on Hover - No Movement to prevent jumping */
.territory-group:hover .territory-rect { fill: #555599; stroke: #FFFFFF; filter: drop-shadow(0px 0px 5px #00FFFF); }

.territory-group.selected .territory-rect { stroke: #FFFF00; stroke-width: 5; fill: #225522; }
.territory-group.potential-target .territory-rect { stroke: #00FF00; stroke-dasharray: 6,4; }
.territory-group.potential-attack-target .territory-rect { stroke: #FF0000; stroke-dasharray: 6,4; fill: #552222; }
.territory-group.potential-spell-target .territory-rect { stroke: #00FF00; stroke-dasharray: 3,2; fill: #333355; }

.territory-name { font-size: 14px; font-weight: bold; fill: #FFFFFF; text-anchor: middle; pointer-events: none; text-shadow: 1px 1px 2px #000; }
.territory-units-text { font-size: 11px; fill: #CCCCCC; text-anchor: middle; pointer-events: none; }

/* Action Panels */
#unit-creation-panel, #movement-attack-panel, #spellcasting-panel { margin-top: 15px; padding: 10px; background-color: #222244; border: 2px solid #6666AA; }
.unit-type-card, .spell-card { display: inline-block; width: 45%; margin: 2%; padding: 5px; background-color: #000088; border: 2px solid #6666AA; cursor: pointer; vertical-align: top; font-size: 0.85em; }
.unit-type-card:hover, .spell-card:hover { background-color: #0000BB; }

/* Popup Menu */
#territory-action-menu { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: #000088; border: 4px solid #6666AA; box-shadow: 10px 10px 0px #000; padding: 20px; z-index: 2000; width: 300px; text-align: center; }
#territory-action-menu h3 { margin-top: 0; color: #FFFF00; border-bottom: 2px solid #6666AA; padding-bottom: 10px; }
#territory-action-menu button { display: block; width: 100%; margin: 10px 0; padding: 12px; background-color: #004400; color: #EEE; border: 2px solid #00FF00; cursor: pointer; font-family: monospace; font-weight: bold; }
#territory-action-menu button:hover { background-color: #006600; }

/* Tooltip */
#unit-tooltip { position: fixed; background-color: rgba(0, 0, 40, 0.95); border: 2px solid #6666AA; padding: 12px; color: #EEE; font-size: 0.85em; pointer-events: none; z-index: 3000; box-shadow: 4px 4px 0px #000; min-width: 180px; }

/* Faction Selection Screen */
#faction-select-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.9); display: flex; justify-content: center; align-items: center; z-index: 6000; }
#faction-select-content { text-align: center; width: 90%; max-width: 1000px; }
#faction-select-content h1 { color: #FFFF00; font-size: 2.5em; margin-bottom: 30px; text-shadow: 2px 2px #FF00FF; }
.faction-cards-container { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; }
.faction-select-card { background-color: #111133; border: 4px solid #FFF; padding: 20px; width: 250px; cursor: pointer; transition: all 0.2s; box-shadow: 5px 5px 0px #000; }
.faction-select-card:hover { transform: translateY(-5px); background-color: #222244; box-shadow: 8px 8px 0px #000; }
.faction-select-card h2 { margin-top: 0; }
.faction-select-card hr { border-color: #333366; }
#back-to-menu-btn { margin-top: 30px; background-color: #444; }

/* Controls & Logs */
#controls { grid-column: 1 / -1; text-align: center; padding-top: 15px; border-top: 2px solid #6666AA; }
button { padding: 10px 20px; margin: 0 5px; font-family: 'monospace'; font-weight: bold; color: #FFF; background-color: #000088; border: 2px solid #6666AA; cursor: pointer; box-shadow: 3px 3px 0px #000; }
button:hover:not(:disabled) { transform: translate(1px, 1px); box-shadow: 2px 2px 0px #000; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

#log { grid-column: 1 / -1; background-color: #444488; padding: 12px; border: 2px solid #6666AA; max-height: 250px; overflow-y: auto; display: flex; flex-direction: column; }
#game-messages { list-style: none; padding: 0; margin: 0; flex-grow: 1; }
#game-messages li { padding: 3px 0; border-bottom: 1px solid #333366; font-size: 0.9em; }
#combat-messages { background-color: #111133; border: 1px solid #FF0000; padding: 8px; margin-top: 10px; max-height: 100px; overflow-y: auto; color: #FFDDDD; font-size: 0.8em; }

/* Dimension Visuals */
.dimension-aetherial-plane { background-color: rgba(100, 100, 255, 0.15); }
.dimension-shadowfell { filter: grayscale(40%) brightness(75%) hue-rotate(100deg); }
.dimension-elemental-chaos { background-color: rgba(255, 120, 0, 0.15); }
.dimension-feywild { filter: hue-rotate(45deg) saturate(1.3); }
.dimension-void { background-color: rgba(30, 0, 30, 0.25); filter: brightness(70%); }
.dimension-radiant-expanse { background-color: rgba(255, 255, 150, 0.2); filter: brightness(110%); }

#game-end-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.85); display: flex; justify-content: center; align-items: center; z-index: 5000; }
#end-screen-content { background-color: #000088; border: 4px solid #6666AA; padding: 40px; text-align: center; }
.hidden { display: none !important; }