:root {
  --bg: #f1f1ef;
  --card: #ffffff;
  --ink: #26262b;
  --muted: #8b8b93;
  --line: #e6e6e3;
  --hover: #f3f3f1;
  --accent: #26262b;
  --shadow: 0 6px 24px rgba(20, 20, 30, 0.1), 0 1px 3px rgba(20, 20, 30, 0.08);
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font: 13px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; }
canvas#game { position: fixed; inset: 0; display: block; cursor: crosshair; touch-action: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:disabled { opacity: 0.35; cursor: default; }
svg { width: 20px; height: 20px; display: block; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; top: 12px; left: 0; right: 0; display: flex; justify-content: center; pointer-events: none; }
.brand { position: absolute; left: 18px; top: 7px; font-size: 15px; letter-spacing: -0.01em; color: #55555c; }
.brand b { color: var(--ink); }
#counters { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 999px; padding: 7px 16px;
  box-shadow: var(--shadow); font-variant-numeric: tabular-nums; }
.cnt { display: flex; align-items: center; gap: 6px; }
.cnt i { width: 10px; height: 10px; border-radius: 50%; background: var(--tc); display: block; }
.cnt b { font-weight: 650; min-width: 18px; }
.hud-sep { width: 1px; height: 16px; background: var(--line); }
.hud-time { font-weight: 600; min-width: 36px; text-align: center; }
.hud-status { color: var(--muted); }
.hud-status.live { color: #2c9a57; }
.hud-status.live::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%;
  background: currentColor; vertical-align: 1px; animation: pulse 1.2s infinite; }
.hud-perf { color: var(--muted); font-size: 11px; }
@keyframes pulse { 50% { opacity: 0.25; } }

/* ---------- Werkzeugleiste ---------- */
#toolbar { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); background: var(--card); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 6px 8px 8px; max-width: calc(100vw - 16px); }
.tb-row { display: flex; align-items: center; }
.tb-top { gap: 8px; padding: 0 2px 6px; border-bottom: 1px solid var(--line); margin-bottom: 7px; }
.spacer { flex: 1; min-width: 12px; }
.seg { display: flex; gap: 2px; }
.seg-btn { display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 8px; color: var(--muted); font-weight: 550; white-space: nowrap; }
.seg-btn svg { width: 16px; height: 16px; }
.seg-btn:hover { background: var(--hover); color: var(--ink); }
.seg-btn.on { background: var(--ink); color: #fff; }
.seg.small .seg-btn { padding: 4px 9px; font-size: 12px; }
#formations { padding-left: 8px; margin-left: 4px; border-left: 1px solid var(--line); }
#formations .seg-btn svg { width: 15px; height: 15px; }
.tb-main { gap: 6px; }
.sep { width: 1px; align-self: stretch; background: var(--line); margin: 2px 4px; }
.sep.slim { margin: 6px 2px; }
#palette { display: flex; gap: 3px; overflow-x: auto; scrollbar-width: none; }
#palette::-webkit-scrollbar { display: none; }
.unit-btn { width: 50px; height: 50px; flex: 0 0 auto; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  border: 1.5px solid transparent; transition: background 0.12s, border-color 0.12s, transform 0.12s; }
.unit-btn canvas { width: 44px; height: 44px; display: block; }
.unit-btn:hover { background: var(--hover); transform: translateY(-1px); }
.unit-btn.on { border-color: var(--ink); background: #fafaf8; }
#teams { display: flex; gap: 6px; padding: 0 2px; }
#teams.disabled { opacity: 0.3; pointer-events: none; }
.team-btn { width: 24px; height: 24px; border-radius: 50%; background: var(--tc); box-shadow: inset 0 0 0 2px rgba(255,255,255,0.0);
  transition: transform 0.12s, box-shadow 0.12s; }
.team-btn:hover { transform: scale(1.1); }
.team-btn.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--tc); }
#tools, #controls { display: flex; align-items: center; gap: 2px; }
.icon-btn { width: 38px; height: 38px; border-radius: 9px; display: flex; align-items: center; justify-content: center; color: #4a4a52; }
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.icon-btn.on { background: var(--ink); color: #fff; }
.icon-btn.speed { font-weight: 700; font-size: 12px; width: 40px; font-variant-numeric: tabular-nums; }
.size { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 42px; height: 42px; gap: 1px; cursor: ns-resize; }
.size-dot { border-radius: 50%; border: 1.5px solid var(--ink); background: rgba(38,38,43,0.06); }
.size-val { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.play-btn { display: flex; align-items: center; gap: 7px; height: 38px; padding: 0 16px 0 12px; border-radius: 10px; background: var(--ink); color: #fff;
  font-weight: 650; margin-right: 4px; min-width: 96px; justify-content: center; }
.play-btn:hover { background: #3a3a41; }
.play-btn svg { width: 16px; height: 16px; }
.play-btn.running { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }

/* ---------- Tooltip ---------- */
#tooltip { position: fixed; z-index: 30; width: 256px; background: var(--card); border-radius: 12px; box-shadow: var(--shadow);
  padding: 11px 13px 12px; pointer-events: none; }
.tip-name { font-weight: 700; font-size: 14px; }
.tip-desc { color: #5d5d65; margin: 3px 0 9px; }
.tip-stats { display: grid; gap: 4px; }
.tip-row { display: grid; grid-template-columns: 74px 1fr 52px; align-items: center; gap: 8px; font-size: 12px; }
.tip-row span { color: var(--muted); }
.tip-row b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar { height: 5px; background: #efefec; border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ink); border-radius: 3px; }
.tip-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 9px; }
.tip-tags span { font-size: 11px; background: #f1f1ee; border-radius: 6px; padding: 2px 7px; color: #55555c; }
.tip-dps { margin-top: 7px; font-size: 11px; color: var(--muted); }

/* ---------- Toast ---------- */
#toast { position: fixed; top: 62px; left: 50%; transform: translate(-50%, -8px); background: var(--ink); color: #fff; padding: 8px 14px;
  border-radius: 10px; opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none; max-width: calc(100vw - 32px); text-align: center; z-index: 20; }
#toast.show { opacity: 0.94; transform: translate(-50%, 0); }

/* ---------- Panels ---------- */
.panel { position: fixed; right: 14px; top: 60px; width: 380px; max-height: calc(100vh - 220px); overflow: auto; background: var(--card);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px; z-index: 15; }
#help { width: 360px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.panel-head span { font-weight: 500; font-size: 12px; color: var(--muted); }
.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; }
kbd { font: 600 11px/1 system-ui, sans-serif; background: #f3f3f0; border-radius: 6px; padding: 5px 7px; color: #44444b; white-space: nowrap; }
.help-note { color: #5d5d65; margin: 12px 0 0; }
.empty { color: var(--muted); padding: 8px 0; }
table.st { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.st th { text-align: right; font-weight: 700; padding: 4px 6px; font-size: 12px; }
table.st td { padding: 5px 6px; border-top: 1px solid #f0f0ed; text-align: right; }
table.st td:first-child { text-align: left; color: #5d5d65; }
table.st small { color: var(--muted); }
.mvp { display: flex; gap: 10px; margin-top: 12px; }
.mvp-col { flex: 1; min-width: 0; }
.mvp-t { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.mvp-row { display: flex; align-items: center; gap: 6px; padding: 1px 0; }
.mvp-row canvas { width: 28px; height: 28px; }
.mvp-row span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mvp-row b { font-variant-numeric: tabular-nums; }
.mvp-none { color: var(--muted); }
canvas.chart { width: 100%; height: auto; margin-top: 12px; display: block; }

/* ---------- Siegesdialog ---------- */
#modal { position: fixed; inset: 0; background: rgba(240, 240, 238, 0.62); backdrop-filter: blur(2px); display: flex; align-items: center;
  justify-content: center; z-index: 40; animation: fade 0.25s; }
.modal-card { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); overflow: auto; background: var(--card); border-radius: 18px;
  box-shadow: 0 20px 60px rgba(20,20,30,0.18); padding: 24px 26px 22px; animation: pop 0.3s cubic-bezier(.2,1.3,.5,1); }
.v-title { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; text-align: center; }
.v-sub { text-align: center; color: #5d5d65; margin: 4px 0 16px; }
.v-actions { display: flex; gap: 8px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.btn { padding: 9px 15px; border-radius: 10px; background: #f1f1ee; font-weight: 600; }
.btn:hover { background: #e8e8e4; }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: #3a3a41; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(0.94); opacity: 0; } }

@media (max-width: 980px) {
  .seg-btn span { display: none; }
  .seg.small .seg-btn span { display: inline; }
  .brand { display: none; }
  .unit-btn { width: 44px; height: 44px; }
  .unit-btn canvas { width: 38px; height: 38px; }
  .tb-main { flex-wrap: wrap; justify-content: center; }
  #palette { max-width: calc(100vw - 40px); }
}

/* ---------- Duell ---------- */
.unit-btn { position: relative; }
.unit-btn .cost { display: none; position: absolute; right: 1px; bottom: 1px; font-size: 9px; font-weight: 700; line-height: 1; padding: 2px 3px;
  border-radius: 4px; background: #fff; color: #55555c; box-shadow: 0 0 0 1px #e4e4e0; font-variant-numeric: tabular-nums; }
body.duel .unit-btn .cost { display: block; }
.duel-hud { display: flex; align-items: center; gap: 10px; }
.duel-hud b { color: var(--tc); }
.duel-bar { width: 140px; height: 7px; border-radius: 4px; background: #efefec; overflow: hidden; }
.duel-bar i { display: block; height: 100%; background: var(--tc); border-radius: 4px; transition: width 0.15s; }
.duel-hud span { font-weight: 600; font-variant-numeric: tabular-nums; }
.duel-tag { font-weight: 650; color: #55555c; }
.duel-card .v-sub { margin-bottom: 14px; }
.duel-label { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: #77777f; margin-bottom: 6px; text-align: center; }
.duel-budgets { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.duel-check { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 14px 0 6px; font-weight: 600; cursor: pointer; }
.duel-check span { font-weight: 400; color: #77777f; }
.duel-rules { margin: 12px auto 6px; padding-left: 22px; max-width: 420px; color: #44444b; }
.duel-rules li { margin: 3px 0; }
.duel-hint { text-align: center; color: #77777f; font-size: 12px; max-width: 420px; margin: 0 auto; }
.tip-cost { margin-top: 6px; font-size: 12px; color: #44444b; }
#countdown { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(0.6); font-size: 120px; font-weight: 850; color: var(--ink);
  letter-spacing: -0.04em; opacity: 0; pointer-events: none; z-index: 45; text-shadow: 0 6px 30px rgba(255,255,255,0.9); }
#countdown.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#countdown.pop { animation: cd 0.9s cubic-bezier(.2,1.4,.4,1); }
@keyframes cd { 0% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; } 30% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1); } }
.play-btn span { white-space: nowrap; }

/* ======================= Feldherr ======================= */
body.rts #toolbar, body.rts #hud, body.rts #stats-panel, body.rts #help, body.rts #tooltip { display: none !important; }
#rts-ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#rts-ui > * { pointer-events: auto; }
#rts-top { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; background: var(--card);
  border-radius: 999px; padding: 5px 8px; box-shadow: var(--shadow); white-space: nowrap; max-width: calc(100vw - 16px); overflow: hidden; }
.rts-btn { padding: 6px 11px; border-radius: 999px; background: #f1f1ee; font-weight: 650; font-size: 12px; }
.rts-btn:hover { background: #e6e6e2; }
.rts-chip { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 6px; border-radius: 999px; background: color-mix(in srgb, var(--tc) 12%, white); }
.rts-chip i { width: 12px; height: 12px; border-radius: 50%; background: var(--tc); display: block; }
.rts-chip b { color: var(--tc); }
.rts-stat { display: flex; align-items: baseline; gap: 4px; padding: 0 6px; font-variant-numeric: tabular-nums; position: relative; }
.rts-stat b { font-size: 14px; font-weight: 750; }
.rts-stat small { color: var(--muted); font-size: 11px; }
.rts-stat.gold small { color: #2c9a57; font-weight: 600; }
.rts-stat small.paused { color: #e0463c; font-weight: 700; }
.rts-stat .rts-prog { position: absolute; left: 6px; right: 6px; bottom: -4px; }
.coin, i.coin { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2a8, #e5b02a 60%, #a87810); box-shadow: 0 0 0 1px #9a6e04 inset; vertical-align: -1px; margin-right: 2px; }
.rts-prog { height: 4px; background: #ecece8; border-radius: 3px; overflow: hidden; }
.rts-prog.big { height: 7px; margin: 6px 0 2px; }
.rts-prog i { display: block; height: 100%; background: #2c9a57; }
#rts-banner { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); background: var(--card); padding: 9px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; }
#rts-banner small { color: var(--muted); font-weight: 500; }
#rts-bottom { position: fixed; left: 10px; right: 10px; bottom: 10px; display: flex; gap: 10px; align-items: flex-end; pointer-events: none; }
#rts-bottom > * { pointer-events: auto; }
#rts-panel { flex: 1; max-width: 860px; margin: 0 auto; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 9px 12px 10px; min-height: 86px; }
#rts-mini-wrap { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 6px; line-height: 0; }
#rts-mini { border-radius: 8px; cursor: pointer; display: block; }
.rts-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 7px; }
.rts-head b { font-size: 14px; }
.rts-head span { color: var(--muted); font-size: 12px; }
.rts-info { display: flex; flex-direction: column; gap: 3px; }
.rts-info b { font-size: 14px; }
.rts-info span, .rts-hint { color: #5d5d65; font-size: 12px; }
.rts-hint { margin-top: 6px; }
.rts-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.rts-item { display: flex; flex-direction: column; align-items: center; gap: 1px; width: 74px; padding: 4px 2px 5px; border-radius: 10px; border: 1.5px solid transparent; }
.rts-item:hover { background: var(--hover); }
.rts-item.on { border-color: var(--ink); background: #fafaf8; }
.rts-item.small { width: 52px; }
.rts-item .nm { font-size: 11px; font-weight: 650; }
.rts-item .pr { font-size: 10px; color: #6b5a1a; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rts-item.poor { opacity: 0.55; }
.rts-item.poor .pr { color: #b8322a; }
.rts-item.locked { opacity: 0.32; filter: grayscale(1); }
.rts-item.locked .pr { color: var(--muted); }
.rts-queue, .rts-sel { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; align-items: center; min-height: 34px; }
.rts-queue .empty { color: var(--muted); font-size: 12px; }
.rts-q { position: relative; display: flex; flex-direction: column; align-items: center; padding: 3px; border-radius: 8px; background: #f4f4f1; min-width: 34px; }
.rts-q:hover { background: #e8e8e4; }
.rts-q b { position: absolute; right: 2px; bottom: 0; font-size: 11px; font-variant-numeric: tabular-nums; }
.rts-q .rts-prog { width: 26px; margin-top: 2px; }
.rts-cmds, .rts-forms { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; align-items: center; }
.rts-forms span { color: var(--muted); font-size: 12px; margin-right: 4px; }
.rts-cmd { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 9px; background: #f1f1ee; font-weight: 600; font-size: 12px; }
.rts-cmd:hover { background: #e6e6e2; }
.rts-cmd.on { background: var(--ink); color: #fff; }
.rts-cmd kbd { padding: 2px 5px; font-size: 10px; }
.rts-research { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.rts-research .btn small { opacity: 0.8; margin-left: 6px; font-weight: 500; }
.rts-research .unlock { color: #5d5d65; font-size: 12px; }
.rts-research .btn.poor { opacity: 0.6; }
#rts-help { right: 14px; top: 60px; width: 420px; z-index: 30; }
.rts-setup .rts-names { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px auto 4px; max-width: 420px; }
.rts-setup .rts-names label { display: flex; align-items: center; gap: 6px; background: #f6f6f3; border-radius: 9px; padding: 5px 8px; }
.rts-setup .rts-names i { width: 12px; height: 12px; border-radius: 50%; background: var(--tc); flex: 0 0 auto; }
.rts-setup input { font: inherit; border: 0; background: transparent; outline: none; width: 100%; font-weight: 600; }
.rts-setup .rts-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 12px 0 10px; }
.rts-setup .rts-seed { width: 80px; background: #f1f1ee; border-radius: 10px; padding: 8px 10px; text-align: center; font-variant-numeric: tabular-nums; }
.modal-card.wide { width: min(760px, calc(100vw - 24px)); }
.rts-btn.alert { background: #ff3b30; color: #fff; animation: pulse 1s infinite; }

#rts-goals { position: fixed; left: 12px; top: 64px; background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 8px 12px; max-width: 300px; font-size: 12px; cursor: pointer; }
#rts-goals b { display: block; font-size: 12px; margin-bottom: 3px; }
#rts-goals div { color: #77777f; margin-top: 2px; }
#rts-goals div.next { color: var(--ink); font-weight: 650; }

/* ---------- Netzwerkspiel ---------- */
body.mp [data-a=switch] { display: none; }
.net-card { max-width: 560px; }
.net-card .net-name { width: 100%; font: inherit; font-size: 16px; padding: 9px 12px; border-radius: 10px; border: 1.5px solid #dcdcd6; margin: 4px 0 6px; }
.net-err { background: #fff0ee; color: #b8322a; border-radius: 10px; padding: 8px 12px; margin: 8px 0; font-size: 13px; }
.net-steps { text-align: left; font-size: 14px; line-height: 1.5; padding-left: 20px; margin: 10px 0; }
.net-steps code, .net-addr { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; background: #f2f2ee; padding: 1px 6px; border-radius: 6px; user-select: all; }
.net-players { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 8px; }
.net-pl { display: flex; align-items: center; gap: 8px; background: #f6f6f3; border-radius: 10px; padding: 7px 10px; flex-wrap: wrap; }
.net-pl i { width: 12px; height: 12px; border-radius: 50%; background: var(--tc); flex: none; }
.net-pl small { font-size: 11px; color: #77777f; background: #fff; border-radius: 6px; padding: 1px 6px; }
.net-pl small.you { color: #fff; background: var(--tc); }
.net-grp { margin-left: auto; font-size: 12px; color: #66666e; display: flex; align-items: center; gap: 4px; }
.btn.mini { padding: 3px 9px; min-width: 0; font-size: 12px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.net-code-big { font-size: 15px; margin: 2px 0 4px; color: #55555c; text-align: center; }
.net-code-big b { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 30px; letter-spacing: 6px; color: #1d1d22; display: block; user-select: all; }
