/* =========================================
   EPICA: STYLE-DOKUMENT
   ========================================= */
body, html { margin: 0; padding: 0; height: 100%; font-family: 'Segoe UI', sans-serif; overflow-x: hidden; overflow-y: auto; }
.fantasy { --primary: #d4af37; --primary-dark: #8b6508; --bg-color: #1a1510; --panel-bg: rgba(40, 30, 20, 0.85); color: #f3e5ab; }
.scifi { --primary: #00f2ff; --primary-dark: #0088aa; --bg-color: #050b14; --panel-bg: rgba(10, 20, 35, 0.85); color: #e0f7fa; }
body { background-color: var(--bg-color); background-image: radial-gradient(circle at center, rgba(255,255,255,0.05) 0%, transparent 70%); transition: all 0.5s ease; }

/* MENÜS & CONTAINERS */
#landing-page { display: flex; flex-direction: column; align-items: center; min-height: 100vh; text-align: center; padding: 20px; }
#dashboard { display: none; height: 100vh; grid-template-columns: 1fr 250px; }
.sidebar { background: var(--panel-bg); border-left: 2px solid var(--primary-dark); padding: 20px; display: flex; flex-direction: column; }
.content { padding: 30px; overflow-y: auto; position: relative; }
button { background: linear-gradient(180deg, var(--primary), var(--primary-dark)); color: #000; border: 1px solid rgba(255,255,255,0.2); padding: 12px 20px; cursor: pointer; font-weight: bold; margin: 5px 0; border-radius: 4px; width: 100%; text-transform: uppercase; transition: 0.2s; }
button:hover { filter: brightness(1.2); }
button.danger { background: linear-gradient(180deg, #e74c3c, #c0392b); color: white; }
input, select { padding: 12px; border: 1px solid var(--primary-dark); background: rgba(0,0,0,0.5); color: white; margin-bottom: 15px; width: 100%; box-sizing: border-box; border-radius: 4px; }
.box { border: 1px solid var(--primary-dark); padding: 20px; border-radius: 8px; background: var(--panel-bg); margin-bottom: 20px; }

/* HELDEN-ANSICHT & EQUIPMENT */
.hero-container { display: grid; grid-template-columns: 200px 1fr 200px; gap: 20px; align-items: center; }
.hero-stats ul { list-style: none; padding: 0; margin: 0; }
.hero-stats li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.1); }
.hero-avatar { height: 300px; border: 2px solid var(--primary); border-radius: 10px; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,0.5); box-shadow: inset 0 0 20px rgba(0,0,0,0.8); }
.equipment-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.item-slot { background: rgba(0,0,0,0.6); border: 1px dashed var(--primary-dark); height: 80px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 5px; cursor: pointer; transition: 0.2s; font-size: 12px; text-align: center; position: relative; }
.item-slot:hover { border-color: var(--primary); background: rgba(255,255,255,0.05); }
.item-slot span { color: var(--primary); font-weight: bold; margin-bottom: 5px; pointer-events: none; }
.item-slot div { pointer-events: none; }

/* MODALS & POPUPS */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); display: flex; justify-content: center; align-items: center; z-index: 9999; backdrop-filter: blur(5px); }
.modal-content { background: var(--bg-color); border: 2px solid var(--primary); width: 90%; max-width: 500px; padding: 20px; border-radius: 8px; box-shadow: 0 0 30px rgba(0,0,0,0.8); text-align: center; }
.inventory-list { max-height: 300px; overflow-y: auto; margin-top: 15px; text-align: left; }
.inventory-item { background: rgba(255,255,255,0.05); border: 1px solid var(--primary-dark); padding: 15px; margin-bottom: 10px; border-radius: 5px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; transition: 0.2s; }
.inventory-item:hover { background: rgba(255,255,255,0.1); border-color: var(--primary); }
#global-tooltip { position: fixed; background: rgba(10, 15, 20, 0.95); border: 1px solid var(--primary); padding: 10px; border-radius: 4px; pointer-events: none; z-index: 2000; box-shadow: 0 0 10px rgba(0,0,0,1); font-size: 12px; display: none; color: white; }

/* =========================================
   MODUL 3: DIE STATISCHE BRÜCKE (BURG-LAYER)
   ========================================= */
.castle-wrapper { position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: 70vh; margin: 0 auto; border: 2px solid var(--primary); border-radius: 8px; overflow: hidden; background-color: #0c120e; box-shadow: 0 0 30px rgba(0,0,0,0.8); }
.layer-1-bg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-size: cover; background-position: center; z-index: 1; transition: background-image 0.5s ease-in-out; }
/* Hintergründe */
.fantasy .layer-1-bg { background-image: url('../assets/fantasy/castle/castle_fantasy.png'); }
.scifi .layer-1-bg { background-image: url('../assets/scifi/castle/castle_scifi.png'); }
.layer-2-hotspots { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
.hotspot { position: absolute; pointer-events: auto; background: rgba(0, 0, 0, 0.4); border: 1px dashed transparent; border-radius: 5px; cursor: pointer; transition: all 0.2s ease; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.hotspot:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--primary); transform: scale(1.02); }
.hotspot strong { font-size: 1.2vw; color: var(--primary); text-shadow: 1px 1px 2px #000; }
.hotspot span { font-size: 0.9vw; color: #fff; text-shadow: 1px 1px 2px #000; margin-top: 5px; }

/* Basis-Klasse für einsetzbare Gebäude-Bilder */
.building-img { position: absolute; pointer-events: auto; background-size: contain; background-repeat: no-repeat; background-position: center bottom; cursor: pointer; transition: transform 0.2s, filter 0.2s; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 10px; }
.building-img:hover { transform: scale(1.05); filter: drop-shadow(0 0 10px var(--primary)) brightness(1.2); }
.building-img strong { font-size: 1.2vw; color: var(--primary); text-shadow: 1px 1px 3px #000, -1px -1px 3px #000; }
.building-img span { font-size: 0.9vw; color: #fff; text-shadow: 1px 1px 3px #000, -1px -1px 3px #000; background: rgba(0,0,0,0.5); padding: 2px 6px; border-radius: 4px; margin-top: 2px; }

/* GEBÄUDE: FANTASY PFADE */
.fantasy .bldg-kaserne { background-image: url('../assets/fantasy/buildings/kaserne_fantasy.png'); }
.fantasy .bldg-schmiede { background-image: url('../assets/fantasy/buildings/schmiede_fantasy.png'); }
.fantasy .bldg-taverne { background-image: url('../assets/fantasy/buildings/taverne_fantasy.png'); }
.fantasy .bldg-tower   { background-image: url('../assets/fantasy/buildings/tower_fantasy.png'); }

/* GEBÄUDE: SCI-FI PFADE */
.scifi .bldg-kaserne { background-image: url('../assets/scifi/buildings/kaserne_scifi.png'); }
.scifi .bldg-schmiede { background-image: url('../assets/scifi/buildings/schmiede_scifi.png'); }
.scifi .bldg-taverne { background-image: url('../assets/scifi/buildings/taverne_scifi.png'); }
.scifi .bldg-tower   { background-image: url('../assets/scifi/buildings/tower_scifi.png'); }

/* HUD */
.layer-3-hud { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none; display: flex; justify-content: space-between; padding: 15px; box-sizing: border-box; }
.hud-panel { pointer-events: auto; background: var(--panel-bg); border: 1px solid var(--primary-dark); padding: 10px 20px; border-radius: 5px; height: fit-content; box-shadow: 0 0 10px rgba(0,0,0,0.5); backdrop-filter: blur(5px); }

/* MODUL 4: WELTKARTE (CANVAS HEX-GRID & MINIMAP) */
#map-module-container { position: relative; width: 100%; height: 75vh; background-color: #000; border: 2px solid var(--primary); border-radius: 8px; overflow: hidden; touch-action: none; }
#world-canvas { display: block; width: 100%; height: 100%; cursor: grab; }
#world-canvas:active { cursor: grabbing; }
.map-hud { position: absolute; top: 10px; left: 10px; right: 10px; pointer-events: none; display: flex; justify-content: space-between; align-items: flex-start; z-index: 10; }
.map-hud-box { background: var(--panel-bg); border: 1px solid var(--primary); padding: 8px 15px; border-radius: 5px; color: white; font-size: 14px; pointer-events: auto; display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.map-input-coord { width: 50px; padding: 5px; margin: 0; text-align: center; border: 1px solid var(--primary-dark); background: rgba(0,0,0,0.8); color: var(--primary); font-weight: bold; }

/* DIE NEUE MINIMAP Oben Rechts */
#minimap-widget { pointer-events: auto; width: 120px; height: 120px; background: #000; border: 2px solid var(--primary); border-radius: 5px; cursor: pointer; overflow: hidden; box-shadow: 0 0 15px rgba(0,0,0,0.8); transition: transform 0.2s; }
#minimap-widget:hover { transform: scale(1.05); border-color: white; }
#minimap-canvas { width: 100%; height: 100%; image-rendering: pixelated; }

/* FULLSCREEN MAP OVERLAY */
#full-map-modal .modal-content { max-width: 800px; width: 90vw; height: 80vh; display: flex; flex-direction: column; }
#full-map-canvas-container { flex-grow: 1; background: #000; border: 1px solid var(--primary); margin-top: 15px; overflow: hidden; }
#full-map-canvas { width: 100%; height: 100%; image-rendering: pixelated; }

/* =========================================
   MOBILE & RESPONSIVE DESIGN
   ========================================= */
@media (max-width: 768px) {
  #dashboard { display: flex !important; flex-direction: column; height: 100vh; overflow: hidden; }
  .content { flex-grow: 1; padding: 10px; order: 1; }
  .sidebar { order: 2; border-left: none; border-top: 2px solid var(--primary-dark); flex-direction: row; flex-wrap: nowrap; overflow-x: auto; padding: 10px; align-items: center; background: var(--bg-color); z-index: 100; }
  .sidebar h2, .sidebar div:first-of-type { display: none; }
  .sidebar button { margin: 0 5px 0 0; padding: 10px 15px; font-size: 11px; white-space: nowrap; width: auto; flex: 0 0 auto; }
  .sidebar div:last-child { margin-top: 0 !important; display: flex; }
  .castle-wrapper { max-height: 50vh; border-radius: 4px; }
}

/* ==========================================================================
   COMBAT MODULE (HoMM Style)
   ========================================================================== */
#combat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-color);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    font-family: inherit;
    color: #fff;
}

/* Header & Log */
#combat-header {
    height: 60px;
    background: var(--panel-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    border-bottom: 2px solid var(--primary);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

#combat-log {
    flex-grow: 1;
    text-align: center;
    font-size: 1.1em;
    font-weight: bold;
    color: var(--primary);
}

#combat-close-btn {
    background: #e74c3c;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    width: auto;
}

/* Battlefield (Hexagon Grid) */
#combat-battlefield {
    flex-grow: 1;
    position: relative;
    background: radial-gradient(circle at center, var(--panel-bg) 0%, var(--bg-color) 100%);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#hex-grid {
    position: relative;
}

.hex-cell {
    position: absolute;
    width: 60px;
    height: 70px;
    background-color: rgba(255, 255, 255, 0.05);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s, transform 0.2s;
    cursor: pointer;
}

.hex-cell:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.hex-cell.active-turn {
    background-color: rgba(46, 204, 113, 0.3);
    border: 2px solid var(--primary);
}

/* Units on the field */
.combat-unit {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary);
    color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 18px;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    position: relative;
    pointer-events: none; /* Let clicks pass to the hex cell */
}

.combat-unit.enemy {
    background-color: #e74c3c;
}

.unit-hp-bar {
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 100%;
    height: 5px;
    background: #333;
    border-radius: 3px;
    overflow: hidden;
}

.unit-hp-fill {
    height: 100%;
    background: #2ecc71;
    width: 100%;
    transition: width 0.3s;
}

/* Initiative Bar & Action Bar */
#combat-footer {
    height: 120px;
    background: var(--panel-bg);
    border-top: 2px solid var(--primary);
    display: flex;
    flex-direction: column;
}

#initiative-bar {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    background: rgba(0,0,0,0.2);
    overflow-x: auto;
}

.initiative-portrait {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-color);
    border: 2px solid #555;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
}

.initiative-portrait.current {
    border-color: var(--primary);
    transform: scale(1.1);
    box-shadow: 0 0 8px var(--primary);
}

#action-bar {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 15px;
}

.combat-btn {
    padding: 10px 20px;
    background: var(--bg-color);
    color: #fff;
    border: 1px solid var(--primary);
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    width: auto;
    text-transform: none;
}

.combat-btn:hover {
    background: var(--primary);
    color: #000;
}
