:root {
    --bg: #07111d;
    --panel: #101b29;
    --panel-2: #152235;
    --line: rgba(255,255,255,.09);
    --text: #eef5ff;
    --muted: #91a2b7;
    --accent: #63f0c8;
    --danger: #ff6975;
    --gold: #ffc766;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button { color: inherit; }
button:disabled { opacity: .42; cursor: not-allowed !important; }
[hidden] { display: none !important; }

.game-app { min-height: 100vh; background: radial-gradient(circle at 50% -10%, #173047 0, #08121e 44%, #050c14 100%); overflow: hidden; }
.hud { min-height: 70px; display: flex; align-items: center; gap: 14px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: rgba(5,12,20,.96); backdrop-filter: blur(12px); position: relative; z-index: 40; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid rgba(99,240,200,.22); border-radius: 12px; background: linear-gradient(145deg, #213246, #0e1927); color: var(--accent); font-size: 22px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 15px; letter-spacing: .12em; }
.brand span { margin-top: 2px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .16em; }

.hud-stats { flex: 1; display: grid; grid-template-columns: repeat(6, minmax(90px, 1fr)); gap: 6px; max-width: 930px; }
.hud-stat { min-width: 0; min-height: 50px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.025); }
.hud-stat span, .hud-stat strong, .hud-stat small { display: block; }
.hud-stat span { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.hud-stat strong { margin-top: 2px; font-size: 14px; white-space: nowrap; }
.hud-stat small { margin-top: 1px; color: #72869d; font-size: 8px; }
.hud-growth strong, .hud-income strong { color: var(--accent); }
.hud-account { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.hud-account span { max-width: 150px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 12px; }
.hud-account button { min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: #142131; padding: 0 12px; cursor: pointer; }

.game-stage { position: relative; height: calc(100vh - 70px); min-height: 600px; }
.map-card { position: absolute; inset: 0; overflow: hidden; background: #06111d; }
.map-toolbar { height: 54px; display: grid; grid-template-columns: auto minmax(260px, 1fr) auto; align-items: center; gap: 12px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: rgba(7,16,26,.95); position: relative; z-index: 20; }
.world-status { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.world-status strong { color: var(--text); }
.live-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--accent); box-shadow: 0 0 0 4px rgba(99,240,200,.09); }
.toolbar-divider { opacity: .45; }
.invasion-hint { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; color: #b4c3d4; font-size: 11px; }
.invasion-hint strong { color: var(--gold); }
.map-controls { display: flex; gap: 5px; }
.map-controls button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: #142132; cursor: pointer; font-size: 19px; }
.map-controls button:hover { border-color: rgba(99,240,200,.35); background: #192b40; }
.map-viewport { position: absolute; top: 54px; right: 0; bottom: 30px; left: 0; overflow: hidden; touch-action: none; cursor: grab; }
.map-viewport:active { cursor: grabbing; }
#worldMap { display: block; width: 100%; height: 100%; user-select: none; }
.map-footer { position: absolute; z-index: 18; right: 0; bottom: 0; left: 0; height: 30px; display: flex; align-items: center; justify-content: center; gap: 22px; padding: 0 12px; border-top: 1px solid var(--line); background: rgba(6,14,24,.96); color: #7f91a6; font-size: 9px; }
.map-footer b { color: #b8c6d7; }

.territory { cursor: pointer; outline: none; }
.territory-shape { fill: #486248; stroke: transparent; stroke-width: 1; vector-effect: non-scaling-stroke; transition: fill .14s ease, filter .14s ease, opacity .14s ease; }
.territory.is-neutral .territory-shape { fill: #486248; }
.territory.is-enemy .territory-shape { filter: saturate(.9); }
.territory.is-attackable .territory-shape { filter: brightness(1.05); }
.territory:hover .territory-shape, .territory:focus-visible .territory-shape { filter: brightness(1.23); }
.territory.is-selected .territory-shape { filter: brightness(1.28); }
.territory.is-selected path { stroke: rgba(255,255,255,.9); stroke-width: 2.5; }

.territory[data-owner="p01"] .territory-shape, .ranking-row i[data-color="p01"] { background: #7e62ff; fill: #7e62ff; }
.territory[data-owner="p02"] .territory-shape, .ranking-row i[data-color="p02"] { background: #3c8df5; fill: #3c8df5; }
.territory[data-owner="p03"] .territory-shape, .ranking-row i[data-color="p03"] { background: #ef5b68; fill: #ef5b68; }
.territory[data-owner="p04"] .territory-shape, .ranking-row i[data-color="p04"] { background: #e2a33b; fill: #e2a33b; }
.territory[data-owner="p05"] .territory-shape, .ranking-row i[data-color="p05"] { background: #27a86b; fill: #27a86b; }
.territory[data-owner="p06"] .territory-shape, .ranking-row i[data-color="p06"] { background: #28a9b6; fill: #28a9b6; }
.territory[data-owner="p07"] .territory-shape, .ranking-row i[data-color="p07"] { background: #bf5bd3; fill: #bf5bd3; }
.territory[data-owner="p08"] .territory-shape, .ranking-row i[data-color="p08"] { background: #d36a3d; fill: #d36a3d; }
.territory[data-owner="p09"] .territory-shape, .ranking-row i[data-color="p09"] { background: #607fd4; fill: #607fd4; }
.territory[data-owner="p10"] .territory-shape, .ranking-row i[data-color="p10"] { background: #83a52c; fill: #83a52c; }
.territory[data-owner="p11"] .territory-shape, .ranking-row i[data-color="p11"] { background: #d64e9a; fill: #d64e9a; }
.territory[data-owner="p12"] .territory-shape, .ranking-row i[data-color="p12"] { background: #2d9a91; fill: #2d9a91; }
.territory[data-owner="p13"] .territory-shape, .ranking-row i[data-color="p13"] { background: #b67128; fill: #b67128; }
.territory[data-owner="p14"] .territory-shape, .ranking-row i[data-color="p14"] { background: #6e5ac1; fill: #6e5ac1; }
.territory[data-owner="p15"] .territory-shape, .ranking-row i[data-color="p15"] { background: #c34b42; fill: #c34b42; }
.territory[data-owner="p16"] .territory-shape, .ranking-row i[data-color="p16"] { background: #3e9b45; fill: #3e9b45; }
.territory[data-owner="p17"] .territory-shape, .ranking-row i[data-color="p17"] { background: #ab8f35; fill: #ab8f35; }
.territory[data-owner="p18"] .territory-shape, .ranking-row i[data-color="p18"] { background: #3f70a7; fill: #3f70a7; }
.territory[data-owner="p19"] .territory-shape, .ranking-row i[data-color="p19"] { background: #8f4d75; fill: #8f4d75; }
.territory[data-owner="p20"] .territory-shape, .ranking-row i[data-color="p20"] { background: #6f8f70; fill: #6f8f70; }

#borderLayer { pointer-events: none; }
.coast-line { stroke: rgba(10,22,28,.78); stroke-width: 3.4; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.front-line { stroke-width: 4.2; vector-effect: non-scaling-stroke; stroke-linecap: round; filter: drop-shadow(0 1px 1px rgba(0,0,0,.8)); }
.enemy-front-line { stroke: rgba(255,255,255,.78); stroke-width: 4.7; vector-effect: non-scaling-stroke; stroke-linecap: round; }

.building-marks { pointer-events: none; opacity: 0; transition: opacity .15s ease; }
.zoom-buildings .building-marks { opacity: 1; }
.building-mark { display: none; fill: #eff7ff; paint-order: stroke; stroke: #08121e; stroke-width: 2.5px; font-size: 12px; font-weight: 900; text-anchor: middle; }
.building-mark.is-visible { display: block; }

.territory.fx-captured .territory-shape { animation: captureFlash .72s ease; }
.territory.fx-battle .territory-shape { animation: battleFlash .55s ease; }
.territory.fx-build .territory-shape { animation: buildFlash .65s ease; }
.territory.fx-blocked .territory-shape { animation: blockedFlash .45s ease; }
.army-unit { fill: #f8fbff; filter: drop-shadow(0 2px 4px rgba(0,0,0,.72)); pointer-events: none; }
.ratio-float { fill: #ffd16c; paint-order: stroke; stroke: #06101b; stroke-width: 4px; font-size: 20px; font-weight: 950; text-anchor: middle; pointer-events: none; animation: ratioFloat .95s ease-out forwards; }
.hit-wave { fill: none; stroke: rgba(255,215,120,.95); stroke-width: 4; vector-effect: non-scaling-stroke; animation: hitWave .55s ease-out forwards; }

.territory-panel { position: absolute; z-index: 30; top: 68px; right: 12px; width: min(360px, calc(100% - 24px)); max-height: calc(100% - 118px); overflow-y: auto; border: 1px solid var(--line); border-radius: 18px; background: rgba(12,22,34,.96); box-shadow: 0 20px 65px rgba(0,0,0,.42); backdrop-filter: blur(16px); padding: 14px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.panel-head h1 { margin: 3px 0 0; font-size: 22px; }
.owner-badge { color: var(--accent); font-size: 9px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.frontier-note { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.icon-btn { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; background: #172537; cursor: pointer; font-size: 18px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-top: 13px; }
.stat-grid > div { padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.025); }
.stat-grid span, .stat-grid strong { display: block; }
.stat-grid span { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.stat-grid strong { margin-top: 3px; font-size: 14px; }
.panel-section { margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--line); }
.section-title strong, .section-title span { display: block; }
.section-title strong { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.section-title span { margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.building-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-top: 9px; }
.building-grid button { min-height: 112px; display: flex; flex-direction: column; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; background: #142132; padding: 10px; text-align: left; cursor: pointer; }
.building-grid button:hover:not(:disabled) { border-color: rgba(99,240,200,.3); background: #18283b; }
.building-grid strong { margin-top: 5px; font-size: 12px; }
.building-grid small { margin-top: 3px; min-height: 30px; color: var(--muted); font-size: 9px; line-height: 1.35; }
.building-grid em { margin-top: auto; color: var(--gold); font-size: 9px; font-style: normal; font-weight: 800; }
.building-icon { font-size: 18px; color: #dce8f7; }

.ranking-panel { position: absolute; z-index: 24; top: 68px; left: 12px; width: 225px; max-height: 310px; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: rgba(11,20,31,.88); backdrop-filter: blur(12px); box-shadow: 0 14px 45px rgba(0,0,0,.25); }
.ranking-head { display: flex; justify-content: space-between; gap: 8px; padding: 10px 11px 8px; border-bottom: 1px solid var(--line); }
.ranking-head strong { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.ranking-head span { color: var(--muted); font-size: 9px; }
.ranking-list { padding: 6px; }
.ranking-row { display: grid; grid-template-columns: 20px 10px minmax(0,1fr) auto; align-items: center; gap: 6px; min-height: 30px; padding: 3px 5px; border-radius: 8px; font-size: 10px; }
.ranking-row.me { background: rgba(99,240,200,.07); }
.ranking-row i { width: 8px; height: 8px; border-radius: 999px; }
.ranking-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-row > span:last-child { color: var(--muted); }
.rank-number { color: #6f8195; text-align: center; }
.ranking-empty { color: var(--muted); font-size: 10px; }

.attack-readout { position: absolute; z-index: 26; left: 12px; bottom: 42px; min-width: 210px; padding: 10px 12px; border: 1px solid rgba(255,199,102,.2); border-radius: 14px; background: rgba(10,18,29,.9); backdrop-filter: blur(12px); box-shadow: 0 14px 40px rgba(0,0,0,.25); }
.attack-readout span, .attack-readout strong, .attack-readout small { display: block; }
.attack-readout span { color: var(--muted); font-size: 8px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.attack-readout strong { margin-top: 2px; font-size: 20px; }
.attack-readout small { margin-top: 2px; color: var(--gold); font-size: 9px; }

.event-strip { position: fixed; z-index: 45; left: 50%; bottom: 38px; transform: translateX(-50%); width: min(600px, calc(100% - 28px)); display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(8,16,26,.9); backdrop-filter: blur(12px); box-shadow: 0 12px 38px rgba(0,0,0,.3); pointer-events: none; }
.event-icon { color: var(--accent); }
.event-strip strong { font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.event-strip p { margin: 2px 0 0; color: #b9c7d7; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast { position: fixed; z-index: 80; left: 50%; bottom: 94px; transform: translateX(-50%); max-width: min(600px, calc(100% - 30px)); padding: 11px 15px; border-radius: 12px; background: #eff7ff; color: #101820; font-size: 12px; font-weight: 800; text-align: center; box-shadow: 0 16px 45px rgba(0,0,0,.4); }
.toast.error { background: #ffd9dd; color: #3d1218; }
.victory-overlay { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; background: rgba(2,8,13,.82); backdrop-filter: blur(12px); text-align: center; }
.victory-overlay > div { width: min(520px, calc(100% - 30px)); border: 1px solid rgba(99,240,200,.25); border-radius: 24px; background: #101c2a; padding: 38px 28px; box-shadow: 0 30px 100px rgba(0,0,0,.5); }
.victory-overlay span { color: var(--accent); font-size: 10px; font-weight: 900; letter-spacing: .18em; }
.victory-overlay h2 { margin: 8px 0 6px; font-size: clamp(40px, 7vw, 72px); }
.victory-overlay p { margin: 0; color: var(--muted); }

/* Login / Registrierung */
.auth-body { min-height: 100vh; background: radial-gradient(circle at 16% 12%, rgba(79,104,178,.24), transparent 34%), radial-gradient(circle at 86% 85%, rgba(99,240,200,.08), transparent 28%), #08111c; color: var(--text); }
.auth-shell { min-height: 100vh; width: min(1160px, calc(100% - 38px)); margin: 0 auto; display: grid; grid-template-columns: minmax(260px, 1fr) minmax(350px, 510px); align-items: center; gap: clamp(30px, 7vw, 110px); padding: 38px 0; }
.auth-brand { max-width: 570px; }
.auth-mark { width: 76px; height: 76px; display: grid; place-items: center; margin-bottom: 22px; border: 1px solid var(--line); border-radius: 21px; background: linear-gradient(145deg, #24364c, #111c2a); color: var(--accent); font-size: 34px; }
.auth-brand > div:nth-child(2) span, .auth-brand > div:nth-child(2) strong { display: block; line-height: .95; }
.auth-brand > div:nth-child(2) span { color: var(--accent); font-size: clamp(18px, 3vw, 28px); font-weight: 900; letter-spacing: .18em; }
.auth-brand > div:nth-child(2) strong { margin-top: 8px; font-size: clamp(38px, 6vw, 76px); letter-spacing: -.055em; }
.auth-brand p { max-width: 520px; margin: 24px 0 0; color: #a7b6c8; line-height: 1.6; }
.auth-card { border: 1px solid var(--line); border-radius: 23px; background: rgba(15,25,38,.95); padding: clamp(24px, 4vw, 38px); box-shadow: 0 28px 90px rgba(0,0,0,.34); backdrop-filter: blur(15px); }
.auth-card-head > span { color: var(--accent); font-size: 10px; font-weight: 900; letter-spacing: .15em; }
.auth-card-head h1 { margin: 7px 0 5px; font-size: 31px; }
.auth-card-head p { margin: 0 0 21px; color: var(--muted); line-height: 1.5; }
.auth-form { display: grid; gap: 14px; }
.auth-form label > span { display: block; margin-bottom: 6px; color: #bdc9d7; font-size: 11px; font-weight: 800; }
.auth-form label > small { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; }
.auth-form input[type="text"], .auth-form input[type="email"], .auth-form input[type="password"] { width: 100%; min-height: 50px; border: 1px solid var(--line); border-radius: 12px; background: #111d2b; color: var(--text); padding: 0 13px; font-size: 16px; }
.auth-form input:focus { outline: 2px solid rgba(99,240,200,.18); border-color: rgba(99,240,200,.5); }
.remember-row { display: flex; align-items: center; gap: 8px; min-height: 34px; }
.remember-row span { margin: 0 !important; }
.remember-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.auth-primary { min-height: 52px; margin-top: 3px; border: 0; border-radius: 12px; background: linear-gradient(135deg, #63f0c8, #3cc2a4); color: #071511; font-weight: 900; cursor: pointer; }
.auth-switch { margin-top: 19px; padding-top: 17px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; text-align: center; }
.auth-switch a { color: var(--accent); font-weight: 900; text-decoration: none; }
.auth-errors { display: grid; gap: 5px; margin-bottom: 15px; padding: 11px 13px; border: 1px solid rgba(255,105,117,.25); border-radius: 11px; background: rgba(255,105,117,.08); color: #ffd3d6; font-size: 11px; }

@keyframes captureFlash { 0%,100% { filter: brightness(1); } 45% { filter: brightness(2.2) saturate(1.45); } }
@keyframes battleFlash { 0%,100% { filter: brightness(1); } 45% { filter: brightness(1.8) saturate(1.4); } }
@keyframes buildFlash { 0%,100% { filter: brightness(1); } 45% { filter: brightness(1.8); } }
@keyframes blockedFlash { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes ratioFloat { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-42px); } }
@keyframes hitWave { from { opacity: 1; r: 4; } to { opacity: 0; r: 28; } }

@media (max-width: 1180px) {
    .hud { flex-wrap: wrap; gap: 6px; padding: 6px 8px; }
    .brand { min-width: 0; flex: 1; }
    .hud-stats { order: 3; width: 100%; max-width: none; grid-template-columns: repeat(6, 1fr); }
    .hud-account span { display: none; }
    .game-stage { height: calc(100vh - 126px); min-height: 520px; }
}

@media (max-width: 760px) {
    .brand strong { font-size: 12px; }
    .brand-mark { width: 36px; height: 36px; }
    .hud-stat { min-height: 46px; padding: 5px 6px; }
    .hud-stat span { font-size: 7px; }
    .hud-stat strong { font-size: 11px; }
    .hud-stat small { font-size: 7px; }
    .hud-account button { min-height: 36px; padding: 0 8px; font-size: 10px; }
    .game-stage { height: calc(100vh - 118px); }
    .map-toolbar { height: 50px; grid-template-columns: 1fr auto; }
    .invasion-hint { position: absolute; top: 50px; left: 0; right: 0; height: 34px; display: flex; align-items: center; padding: 0 9px; background: rgba(7,16,26,.94); text-align: left; font-size: 9px; }
    .map-viewport { top: 84px; bottom: 28px; }
    .map-footer { height: 28px; justify-content: flex-start; overflow-x: auto; gap: 14px; white-space: nowrap; }
    .map-controls button { width: 36px; height: 36px; }
    .territory-panel { top: auto; right: 7px; bottom: 36px; left: 7px; width: auto; max-height: 65%; border-radius: 17px; }
    .ranking-panel { top: 92px; left: 7px; width: 165px; max-height: 210px; }
    .ranking-row { grid-template-columns: 17px 8px minmax(0,1fr) auto; font-size: 9px; }
    .building-grid button { min-height: 102px; padding: 9px; }
    .attack-readout { left: 7px; bottom: 36px; min-width: 170px; padding: 8px 10px; }
    .attack-readout strong { font-size: 16px; }
    .event-strip { bottom: 34px; }
    .auth-shell { grid-template-columns: 1fr; width: min(560px, calc(100% - 26px)); gap: 26px; padding: 26px 0; }
    .auth-brand p { font-size: 14px; }
}

@media (max-width: 500px) {
    .hud-stats { gap: 3px; grid-template-columns: repeat(3, 1fr); }
    .ranking-panel { display: none; }
    .map-footer span:nth-child(3) { display: none; }
    .territory-panel { max-height: 68%; }
    .stat-grid { gap: 5px; }
    .building-grid { gap: 5px; }
    .building-grid button { min-height: 98px; }
    .event-strip { left: 8px; transform: none; width: calc(100% - 16px); }
    .event-strip p { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
