:root {
    --bg: #14130f;
    --bg-panel: #1c1a15;
    --bg-panel-raised: #211f19;
    --border: #38352b;
    --text: #e4ded0;
    --text-dim: #9c9382;
    --gold: #b8934a;
    --gold-bright: #d4ac5f;
    --danger: #a83e3e;
    --success: #3f8a56;

    --f-imperium: #3b6ea5;
    --f-imperium-accent: #7fb0e0;
    --f-chaos: #9c2b2b;
    --f-chaos-accent: #e05c5c;
    --f-xr: #1f9e9e;
    --f-xr-accent: #5fe0e0;
    --f-xz: #7a3b9c;
    --f-xz-accent: #c07fe0;
    --f-none: #4a4a4a;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, 'Segoe UI', Roboto, Inter, system-ui, sans-serif;
    min-height: 100vh;
}

h1, h2, h3 {
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
    margin: 0 0 0.6rem;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; color: var(--gold-bright); }
h3 { font-size: 1rem; }

a { color: var(--gold-bright); }
a:hover { color: var(--gold); }

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.5rem;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.site-header .brand {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.01em;
}
.site-header .brand:hover { color: var(--gold-bright); }

.site-nav {
    display: flex;
    gap: 0.2rem;
    flex-wrap: wrap;
    align-items: center;
}

.site-nav a {
    color: var(--text-dim);
    text-decoration: none;
    padding: 0.4rem 0.65rem;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.88rem;
}

.site-nav a:hover, .site-nav a.active {
    color: var(--text);
    background: rgba(255,255,255,0.06);
}
.site-nav a.active { color: var(--gold-bright); }

.site-nav .divider {
    width: 1px;
    height: 1.1rem;
    background: var(--border);
    margin: 0 0.3rem;
}

main.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.6rem 1.5rem 4rem;
}

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.4rem;
    margin-bottom: 1.4rem;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1.2rem;
    border-left: 3px solid var(--gold);
    background: rgba(184,147,74,0.1);
    font-size: 0.92rem;
}
.flash.error { border-color: var(--danger); background: rgba(168,62,62,0.12); }
.flash.success { border-color: var(--success); background: rgba(63,138,86,0.12); }

label { display: block; margin: 0.8rem 0 0.3rem; font-weight: 600; color: var(--text-dim); font-size: 0.85rem; }

input, select, textarea {
    width: 100%;
    padding: 0.5rem 0.65rem;
    background: #100f0c;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); }

.btn {
    display: inline-block;
    padding: 0.55rem 1.1rem;
    background: var(--gold);
    border: 1px solid var(--gold);
    color: #1a1611;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    text-decoration: none;
    margin-top: 1rem;
}
.btn:hover { background: var(--gold-bright); border-color: var(--gold-bright); }
.btn.danger { background: transparent; border-color: var(--danger); color: #e39d9d; }
.btn.danger:hover { background: rgba(168,62,62,0.15); }
.btn.small { padding: 0.3rem 0.65rem; font-size: 0.78rem; margin-top: 0; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { color: var(--text-dim); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.74rem;
    font-weight: 600;
    color: #fff;
}
.badge.f-imperium { background: var(--f-imperium); }
.badge.f-chaos { background: var(--f-chaos); }
.badge.f-xenos_retter { background: var(--f-xr); }
.badge.f-xenos_zerstoerer { background: var(--f-xz); }
.badge.f-none, .badge.f-neutral { background: var(--f-none); }

/* --- Hex map --- */
.hex-map-wrap {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    background: #100f0c;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2rem;
    perspective: 1400px;
}
.hex-map {
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.08s ease-out;
    will-change: transform;
}
/* Zweischichtiges Hexagon: .hex ist die äußere "Rahmen"-Fläche (per
   clip-path exakt sechseckig zugeschnitten, normalerweise unsichtbar da
   padding:0), .hex-fill die innere, um den Rahmen verkleinerte Fläche mit
   Team-Farbe/Bild. So folgt ein farbiger Rand exakt der Sechseck-Kontur -
   CSS `outline`/`border` würden stattdessen ein Rechteck um die Box ziehen. */
.hex {
    position: absolute;
    width: 90px;
    height: 104px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    padding: 0;
    background: transparent;
    cursor: pointer;
    border: none;
    transition: transform 0.12s ease, filter 0.12s ease;
}
.hex:hover { transform: scale(1.05); filter: brightness(1.15); z-index: 5; }

.hex-fill {
    width: 100%;
    height: 100%;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    background-size: cover;
    background-position: center;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* Badges (Home/Strategisch/Event) laufen im normalen Textfluss in der Mitte
   des Hexagons - NICHT absolut in den Ecken, weil der clip-path das Sechseck
   oben/unten spitz zulaufen lässt und Eck-Icons dort unsichtbar abschneidet. */
.hex-icons {
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
}
.tile-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    font-size: 0.6rem;
    line-height: 1;
    border: 1px solid rgba(0,0,0,0.35);
}
.badge-home { background: var(--gold-bright); color: #2a1d05; }
.badge-strategic { background: #c9a03a; color: #2a1d05; }
.badge-event { background: #ff6a3d; color: #3a1204; }

.hex.home { padding: 3px; background: var(--gold); }
.hex.strategic { padding: 3px; background: var(--gold-bright); }
.hex.event { padding: 3px; background: #d9572f; }

.hex-label {
    pointer-events: none;
    max-width: 78px;
    hyphens: auto;
    -webkit-hyphens: auto;
    overflow-wrap: break-word;
    word-break: break-word;
    font-size: 0.64rem;
    line-height: 1.15;
}

.hex.ghost {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.03);
    border: 2px dashed var(--border);
    color: var(--text-dim);
    opacity: 0.6;
    font-size: 1.3rem;
    font-weight: 400;
}
.hex.ghost:hover { opacity: 1; border-color: var(--gold); color: var(--gold-bright); filter: none; }

.tile-form label { margin-top: 0.6rem; }
.tile-form .row2 { display: flex; gap: 1rem; }
.tile-form .row2 > div { flex: 1; }
.tile-editor-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 0.8rem; }

.legend { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-top: 1rem; }
.legend-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--text-dim); }
.legend-swatch { width: 14px; height: 14px; border-radius: 2px; }

.modal-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.65);
    align-items: center; justify-content: center;
    z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: var(--bg-panel-raised);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.5rem;
    max-width: 420px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-close { float: right; cursor: pointer; color: var(--text-dim); font-weight: 700; }

.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.stat-tile { flex: 1; min-width: 160px; background: var(--bg-panel-raised); border: 1px solid var(--border); border-radius: 6px; padding: 1rem; }
.stat-tile .num { font-size: 1.7rem; font-weight: 700; }

.win-banner {
    padding: 0.9rem 1.1rem;
    border: 1px solid var(--gold);
    border-radius: 6px;
    background: rgba(184,147,74,0.1);
    margin-bottom: 1.2rem;
    font-weight: 500;
}

footer.site-footer {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.8rem;
    padding: 2rem 1rem;
}

@media (max-width: 640px) {
    .site-header { flex-direction: column; align-items: flex-start; }
    .site-nav { gap: 0.15rem; }
    .site-nav a { padding: 0.35rem 0.5rem; font-size: 0.82rem; }
    main.container { padding: 0.8rem; }
    .panel { padding: 1rem; overflow-x: auto; }
    .hex-map-wrap { padding: 1rem; perspective: 900px; }
    .modal { max-width: 92vw; padding: 1.1rem; }
    .tile-form .row2 { flex-direction: column; }
    .stat-row { flex-direction: column; }
    .stat-tile { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .hex-map { transition: none !important; transform: none !important; }
}
