/* Schriften lokal (keine Verbindung zu Google beim Seitenaufruf) – Lizenz: assets/fonts/LICENSE.txt */
@font-face { font-family: "Cinzel"; src: url("assets/fonts/cinzel.woff2") format("woff2"); font-weight: 400 900; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("assets/fonts/nunito.woff2") format("woff2"); font-weight: 200 1000; font-display: swap; }
@font-face { font-family: "Orbitron"; src: url("assets/fonts/orbitron.woff2") format("woff2"); font-weight: 400 900; font-display: swap; }

/* =====================================================================
   Castle Clash – UI-Stil. Themen über data-theme am <body>.
   Gleiche Stilregeln wie die Spielgrafik: flache Flächen, dunkle Kontur,
   eine Licht- und eine Schattenkante.
   ===================================================================== */
:root, [data-theme="medieval"] {
  --bg: #2a1d14;
  --panel: #f3e3c3;
  --panel-2: #e6d0a6;
  --panel-edge: #8b5a2b;
  --ink: #2b1d14;
  --ink-soft: #6b4f36;
  --accent: #c8322b;
  --accent-2: #2f5fc4;
  --gold: #e0a92e;
  --ok: #3f9a3a;
  --bad: #c8322b;
  --btn: #8b5a2b;
  --btn-top: #a5703c;
  --btn-ink: #fff6e0;
  --outline: #2b1d14;
  --font-head: "Cinzel", Georgia, serif;
  --font-body: "Nunito", "Segoe UI", sans-serif;
  --red: #d63a30; --blue: #3168d6;
  --radius: 10px;
}
[data-theme="rome"] {
  --bg: #3a2414; --panel: #fbf3e2; --panel-2: #efe0c2; --panel-edge: #b08a3e;
  --ink: #3a2414; --ink-soft: #7a5a3a; --accent: #b52a2a; --gold: #d4a73a;
  --btn: #9b3a22; --btn-top: #c4602f; --btn-ink: #fff6e0; --outline: #3a2414;
  --red: #b52a2a; --blue: #2a55b5;
}
[data-theme="space"] {
  --bg: #070a26; --panel: #161a3d; --panel-2: #20255a; --panel-edge: #4dc3ff;
  --ink: #e8ecff; --ink-soft: #9aa6d8; --accent: #ff4d6d; --gold: #ffd34d; --ok: #46e0c8; --bad: #ff4d6d;
  --btn: #2a2f6e; --btn-top: #3d44a0; --btn-ink: #e8ecff; --outline: #0d0a1e;
  --font-head: "Orbitron", "Segoe UI", sans-serif;
  --red: #ff4d6d; --blue: #4dc3ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 16px; }
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0 0 .5em; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- Screens */
.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: flex; align-items: center; justify-content: center; }
.screen.scroll.active { align-items: flex-start; overflow-y: auto; padding: 24px 16px; }

/* ---------- Panels */
.panel {
  background: var(--panel); border: 4px solid var(--outline); border-radius: var(--radius);
  box-shadow: inset 0 0 0 3px var(--panel-edge), 0 8px 0 rgba(0,0,0,.35); padding: 22px;
}
[data-theme="space"] .panel { box-shadow: inset 0 0 0 2px var(--panel-edge), 0 0 24px rgba(77,195,255,.25); }
.panel.small { padding: 8px 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }

/* ---------- Buttons */
.btn {
  background: var(--btn); color: var(--btn-ink); border: 3px solid var(--outline); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-weight: 800; box-shadow: inset 0 3px 0 var(--btn-top), 0 4px 0 var(--outline);
  transition: transform .06s, filter .1s; white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: inset 0 3px 0 var(--btn-top), 0 1px 0 var(--outline); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); box-shadow: inset 0 3px 0 rgba(255,255,255,.3), 0 4px 0 var(--outline); }
.btn-ok { background: var(--ok); box-shadow: inset 0 3px 0 rgba(255,255,255,.3), 0 4px 0 var(--outline); }
.btn-gold { background: var(--gold); color: var(--outline); box-shadow: inset 0 3px 0 rgba(255,255,255,.4), 0 4px 0 var(--outline); }
.btn-big { font-size: 1.15rem; padding: 12px 20px; width: 100%; }
.btn-icon { padding: 4px 9px; }
.btn-todo { opacity: .6; cursor: not-allowed; }
.badge { font-size: .7rem; background: var(--gold); color: var(--outline); border: 2px solid var(--outline); border-radius: 6px; padding: 0 5px; margin-left: 6px; vertical-align: middle; }
.badge.todo { background: #999; color: #fff; }
.tag { display: inline-block; font-size: .75rem; font-weight: 800; padding: 1px 7px; border-radius: 999px; border: 2px solid var(--outline); background: var(--panel-2); }
.d1 { background: #9be08a; color: #1a3a12; } .d2 { background: #ffe38a; color: #4a3a00; } .d3 { background: #ffb36b; color: #4a2000; } .d4 { background: #ff8a8a; color: #4a0000; }

/* ---------- Menü */
/* .menu-bg: siehe Ergänzungen */
.menu-box { position: relative; width: min(480px, 92vw); text-align: center; }
.logo { font-size: clamp(2.4rem, 7vw, 4rem); line-height: 1; color: var(--accent); text-shadow: 3px 3px 0 var(--outline); letter-spacing: 2px; }
.logo span { display: block; color: var(--gold); }
.tagline { font-weight: 700; color: var(--ink-soft); }
.menu-buttons { display: grid; gap: 12px; margin: 18px 0 10px; }
.menu-hint { font-size: .85rem; color: var(--ink-soft); margin: 0; }
.audio-controls { position: absolute; right: 16px; bottom: 16px; display: flex; gap: 12px; align-items: center; font-size: .85rem; font-weight: 700; }
.audio-controls input { width: 80px; vertical-align: middle; }

/* ---------- Formulare */
.creator { width: min(1100px, 100%); margin: 0 auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span, .field-label { font-weight: 800; font-size: .9rem; }
.field small { color: var(--ink-soft); }
input[type=text], input[type=number], input[type=password], select, textarea {
  background: #fffaf0; border: 3px solid var(--outline); border-radius: 7px; padding: 7px 9px; width: 100%;
}
[data-theme="space"] input[type=text], [data-theme="space"] input[type=number], [data-theme="space"] input[type=password], [data-theme="space"] select, [data-theme="space"] textarea { background: #0d1030; }
textarea { min-height: 80px; resize: vertical; }
fieldset { border: 3px solid var(--panel-edge); border-radius: 8px; padding: 12px 14px; margin: 16px 0 0; }
legend { font-family: var(--font-head); font-weight: 800; padding: 0 6px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks label { display: flex; gap: 6px; align-items: center; font-weight: 700; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.note:empty { display: none; }
.note { background: var(--panel-2); border-left: 5px solid var(--gold); padding: 8px 12px; border-radius: 6px; font-size: .9rem; margin: 8px 0; }
.error { color: var(--bad); font-weight: 800; }
.ok-text { color: var(--ok); font-weight: 800; }
.analysis { margin-top: 8px; }
.names-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.names-grid h4 { margin: 0; }
.red-text { color: var(--red); } .blue-text { color: var(--blue); }

/* ---------- Generator */
.generate-box { width: min(560px, 92vw); }
.gen-steps { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 4px; }
.gen-steps li { padding: 4px 8px; border-radius: 6px; font-weight: 700; color: var(--ink-soft); }
.gen-steps li.run { background: var(--panel-2); color: var(--ink); }
.gen-steps li.done { color: var(--ok); }
.gen-steps li.fail { color: var(--bad); }
.gen-steps li .detail { font-weight: 400; font-size: .85rem; margin-left: 6px; }

/* ---------- Vorschau */
.preview-layout { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 420px; gap: 12px; padding: 12px; }
.preview-stage { display: flex; align-items: center; justify-content: center; min-height: 0; }
.preview-side { overflow-y: auto; }
.task-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; max-height: 300px; overflow-y: auto; }
.task-list li { background: var(--panel-2); border: 2px solid var(--outline); border-radius: 6px; padding: 6px 8px; font-size: .85rem; display: flex; gap: 6px; align-items: flex-start; }
.task-list li .q { flex: 1; white-space: pre-line; }
.task-list li .acts { display: flex; gap: 4px; }
.task-list li .acts .btn { padding: 1px 6px; font-size: .8rem; }
.preview-side h3 { margin-top: 14px; }
.preview-side .kv, .online-box .kv, .doc-result .kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: .9rem; margin: 6px 0; }
.kv b { font-weight: 800; }

/* ---------- Spiel */
#screen-game.active { display: block; }
.game-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #000; }
#hud { position: absolute; inset: 0; pointer-events: none; font-weight: 800; }
#hud > * { pointer-events: auto; }
.hud-top { position: absolute; top: 8px; left: 8px; right: 8px; display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: start; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.team-card { padding: 8px 12px; display: grid; gap: 4px; font-size: .9rem; }
.team-card.blue { text-align: right; }
.team-card .name { font-family: var(--font-head); font-size: 1.05rem; }
.team-card.red .name { color: var(--red); } .team-card.blue .name { color: var(--blue); }
.team-card.active { outline: 4px solid var(--gold); }
.effects { display: flex; gap: 4px; flex-wrap: wrap; min-height: 22px; }
.team-card.blue .effects { justify-content: flex-end; }
.team-card .unlock { position: relative; height: 16px; border-radius: 4px; overflow: hidden; border: 2px solid var(--outline);
  background: repeating-linear-gradient(90deg, #6b4a2b 0 14px, #5e3f24 14px 15px); box-shadow: inset 0 2px 3px rgba(0,0,0,.35); }
.team-card .unlock i { position: absolute; inset: 0 auto 0 0; transition: width .6s;
  background: linear-gradient(180deg, #ffe28a, #e0a526 55%, #a8721a); box-shadow: inset 0 -2px 0 rgba(0,0,0,.2); }
.team-card.blue .unlock i { inset: 0 0 0 auto; }
.team-card .unlock span { position: relative; display: block; font-size: .72rem; font-weight: 800; line-height: 12px; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff8e6; text-shadow: 1px 1px 0 #2a1a0c, -1px 0 0 #2a1a0c; }
.shop-item.locked { filter: grayscale(.55) sepia(.25); opacity: .85; }
.shop-item .lockbar { height: 10px; border-radius: 3px; margin: 4px 0; overflow: hidden; border: 2px solid var(--outline);
  background: repeating-linear-gradient(90deg, #6b4a2b 0 12px, #5e3f24 12px 13px); }
.shop-item .lockbar i { display: block; height: 100%; background: linear-gradient(180deg, #ffe28a, #e0a526 55%, #a8721a); }
.shop-item .badge-new { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 10px 3px 10px 3px; font-size: .68rem; font-weight: 800; letter-spacing: .02em;
  background: radial-gradient(circle at 35% 30%, #c2332b, #8b1a17 70%); color: #ffe28a; border: 2px solid #4a0d0b; text-shadow: 1px 1px 0 #4a0d0b; box-shadow: 0 1px 0 rgba(0,0,0,.3); }
[data-theme="space"] .shop-item .badge-new { background: linear-gradient(90deg, #6a4cff, #2fd0ff); color: #fff; border-color: #1a1f4a; text-shadow: none; border-radius: 6px; }
[data-theme="space"] .team-card .unlock, [data-theme="space"] .shop-item .lockbar { background: #1a1f4a; }
[data-theme="space"] .team-card .unlock i, [data-theme="space"] .shop-item .lockbar i { background: linear-gradient(90deg, #6a4cff, #2fd0ff); }
.effects span { background: var(--panel-2); border: 2px solid var(--outline); border-radius: 6px; padding: 0 4px; font-size: .8rem; }
.center-card { text-align: center; padding: 8px 16px; min-width: 220px; }
.center-card .turn { font-family: var(--font-head); font-size: 1.05rem; }
.center-card .timer { font-size: 1.8rem; line-height: 1.1; }
.center-card .timer.warn { color: var(--bad); animation: pulse .5s infinite alternate; }
.center-card .meta { font-size: .8rem; color: var(--ink-soft); display: flex; gap: 10px; justify-content: center; }
.wind-arrow { display: inline-block; transition: transform .3s; }
@keyframes pulse { to { transform: scale(1.12); } }

.hud-bottom { position: absolute; bottom: 8px; left: 8px; right: 8px; padding: 8px 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hud-bottom .who { min-width: 130px; max-width: 170px; }
.hud-bottom .who > div:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-bottom .who .pts { font-size: 1.3rem; color: var(--gold); text-shadow: 1px 1px 0 var(--outline); }
.hud-bottom .who small { display: block; color: var(--ink-soft); font-size: .78rem; }
.weapon-sel, .ammo-sel { display: flex; gap: 4px; }
.wbtn { position: relative; background: var(--panel-2); border: 3px solid var(--outline); border-radius: 8px; padding: 2px; cursor: pointer; width: 54px; height: 54px; display: flex; align-items: center; justify-content: center; }
.wbtn img { width: 44px; height: 44px; image-rendering: auto; }
.hud-bottom.compact { gap: 8px; }
.hud-bottom.compact .wbtn { width: 44px; height: 44px; border-width: 2px; }
.hud-bottom.compact .wbtn img { width: 36px; height: 36px; }
.hud-bottom.compact .weapon-sel, .hud-bottom.compact .ammo-sel { gap: 3px; }
.wbtn.sel { outline: 3px solid var(--gold); background: #fff3c4; }
[data-theme="space"] .wbtn.sel { background: #2e3680; }
.wbtn .cnt { position: absolute; right: -4px; bottom: -6px; background: var(--outline); color: #fff; border-radius: 6px; font-size: .72rem; padding: 0 4px; }
.wbtn:disabled { opacity: .35; cursor: not-allowed; }
.aim { display: grid; gap: 2px; font-size: .8rem; min-width: 150px; }
.aim input { width: 100%; }
.hud-bottom .actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.fire-btn { font-size: 1.2rem; padding: 10px 22px; }
.bonus-toggle { display: flex; align-items: center; gap: 4px; font-size: .85rem; cursor: pointer; }
.cpu-banner { position: absolute; left: 50%; bottom: 128px; transform: translateX(-50%); padding: 8px 18px; }

/* ---------- Modals */
.modal-back { position: absolute; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal { width: min(640px, 100%); max-height: 92vh; overflow-y: auto; }
.modal.wide { width: min(980px, 100%); }
.task-q { font-size: 1.35rem; font-weight: 800; white-space: pre-line; margin: 6px 0 14px; line-height: 1.35; }
.task-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: .85rem; }
.task-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.task-opts .btn { white-space: normal; text-align: left; padding: 10px 12px; font-size: 1rem; }
.task-opts .btn.right { background: var(--ok); } .task-opts .btn.wrongpick { background: var(--bad); }
.task-input { display: flex; gap: 8px; }
.task-input input { font-size: 1.2rem; }
.feedback { margin-top: 14px; padding: 10px 12px; border-radius: 8px; border: 3px solid var(--outline); }
.feedback.ok { background: #d8f5cf; color: #1a3a12; } .feedback.bad { background: #fde0dc; color: #4a0f08; }
.feedback h3 { margin: 0 0 4px; }
.shop-tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.shop-tabs .btn.sel { background: var(--gold); color: var(--outline); }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.shop-item { background: var(--panel-2); border: 3px solid var(--outline); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.shop-item .ttl { display: flex; align-items: center; gap: 8px; font-weight: 900; }
.shop-item .ttl img { width: 40px; height: 40px; }
.shop-item .ico { font-size: 1.6rem; }
.shop-item p { margin: 0; font-size: .82rem; color: var(--ink-soft); flex: 1; }
.shop-item .stats { font-size: .78rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.shop-item .owned { color: var(--ok); font-weight: 900; }
.lvl { display: flex; gap: 3px; }

/* ---------- Ende / Statistik */
.end-box { width: min(980px, 100%); margin: 0 auto; }
.end-title { text-align: center; font-size: clamp(2rem, 6vw, 3.4rem); margin: 0; text-shadow: 3px 3px 0 var(--outline); }
.end-title.red { color: var(--red); } .end-title.blue { color: var(--blue); } .end-title.draw { color: var(--gold); }
.end-sub { text-align: center; font-weight: 800; color: var(--ink-soft); margin-bottom: 16px; }
.end-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.stat-card { background: var(--panel-2); border: 3px solid var(--outline); border-radius: 8px; padding: 12px 14px; }
.stat-card ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 3px; }
.stat-card.win { outline: 4px solid var(--gold); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th, .tbl td { border-bottom: 2px solid var(--panel-edge); padding: 5px 6px; text-align: left; }
.tbl th { font-family: var(--font-head); }
.analysis-card { background: var(--panel-2); border: 3px solid var(--outline); border-radius: 8px; padding: 12px 14px; margin-top: 10px; }
.analysis-card p { margin: 4px 0; }
.subbar { display: grid; grid-template-columns: 170px 1fr 48px; gap: 8px; align-items: center; font-size: .85rem; margin: 3px 0; }

/* ---------- Toast */
#toast-root { position: fixed; top: 90px; left: 50%; transform: translateX(-50%); display: grid; gap: 6px; z-index: 50; pointer-events: none; }
.toast { background: var(--panel); border: 3px solid var(--outline); border-radius: 8px; padding: 8px 14px; font-weight: 800; box-shadow: 0 4px 0 rgba(0,0,0,.35); animation: toast 2.6s forwards; max-width: min(640px, calc(100vw - 32px)); }
.toast.bad { background: #fde0dc; color: #4a0f08; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-10px); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }

@media (max-width: 900px) {
  .preview-layout { grid-template-columns: 1fr; grid-template-rows: 40vh 1fr; }
  .hud-top { grid-template-columns: 1fr 1fr; }
  .center-card { grid-column: 1 / -1; grid-row: 1; }
  .task-opts { grid-template-columns: 1fr; }
}

/* ---------- Ergänzungen */
.menu-bg { position: absolute; inset: auto; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.task-form { background: var(--panel-2); border: 3px solid var(--outline); border-radius: 8px; padding: 12px; }
.panel-2 { background: var(--panel-2); }

/* =====================================================================
   Balken & Regler im eigenen Design (passend zu render/bars.js)
   Mittelalter: Holzrahmen mit Nieten · Rom: Goldrahmen · Weltraum: Neon, abgeschrägt
   ===================================================================== */
:root {
  --bar-frame: linear-gradient(#a5703c, #8b5a2b 50%, #5e3a19);
  --bar-trough: #2a1a10;
  --bar-ok: linear-gradient(#9cf06e, #5ec84a 45%, #2f8a26);
  --bar-mid: linear-gradient(#ffe07a, #f0b429 45%, #b9780f);
  --bar-low: linear-gradient(#ff8f7a, #e5483b 45%, #9c1f16);
  --bar-ghost: #fff2b0;
  --bar-radius: 5px;
  --bar-seg: rgba(0,0,0,.28);
  --rivet: radial-gradient(circle at 40% 40%, #9aa4ad 0 1.2px, #5d6670 1.6px 2.6px, transparent 3px);
}
[data-theme="rome"] {
  --bar-frame: linear-gradient(#ffe9a0, #d4a73a 50%, #8a6a1f);
  --bar-trough: #5a4a3a;
  --bar-radius: 999px;
  --rivet: none;
}
[data-theme="space"] {
  --bar-frame: #0d0a1e;
  --bar-trough: #141238;
  --bar-ok: linear-gradient(#b8fff4, #46e0c8 45%, #138c7c);
  --bar-mid: linear-gradient(#fff3b0, #ffd34d 45%, #b88a00);
  --bar-low: linear-gradient(#ffb3c1, #ff4d6d 45%, #a8183a);
  --bar-ghost: rgba(255,255,255,.75);
  --bar-radius: 2px;
  --bar-seg: rgba(13,10,30,.55);
  --rivet: none;
}

.bar {
  position: relative; height: 18px; border-radius: var(--bar-radius); border: 3px solid transparent;
  /* Rahmen (Holz / Gold) als Verlauf im Rand, Rinne innen */
  background: linear-gradient(var(--bar-trough), var(--bar-trough)) padding-box, var(--bar-frame) border-box;
  box-shadow: 0 0 0 2px var(--outline), inset 0 2px 4px rgba(0,0,0,.6);
  overflow: hidden;
}
[data-theme="space"] .bar { border: 2px solid #4dc3ff; background: var(--bar-trough); box-shadow: 0 0 10px rgba(77,195,255,.45), inset 0 0 6px rgba(77,195,255,.25);
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%); }
.bar > i, .bar > .ghost { position: absolute; left: 0; top: 0; bottom: 0; display: block; border-radius: inherit; }
.bar > i { background: var(--bar-ok); transition: width .25s ease-out; z-index: 1; }
.bar > i::after { content: ""; position: absolute; left: 0; right: 0; top: 1px; height: 28%; background: rgba(255,255,255,.35); border-radius: inherit; }
.bar > .ghost { background: var(--bar-ghost); transition: width .8s ease-in .45s; }
.bar.mid > i { background: var(--bar-mid); } .bar.low > i { background: var(--bar-low); }
/* Segmente */
.bar::after { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1.5px), var(--bar-seg) calc(10% - 1.5px) 10%); }
.bar > span { position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center;
  font: 800 .78rem var(--font-head); color: #fff; text-shadow: 0 0 3px var(--outline), 1px 1px 0 var(--outline), -1px -1px 0 var(--outline); white-space: nowrap; }
/* Nieten in den Ecken (Mittelalter) */
.bar.hp { height: 24px; margin: 4px 0 4px 16px; overflow: visible; }
.bar.hp > i, .bar.hp > .ghost { overflow: hidden; }
.bar.hp::before { content: ""; position: absolute; inset: -7px; z-index: 4; pointer-events: none;
  background: var(--rivet) left top / 8px 8px no-repeat, var(--rivet) right top / 8px 8px no-repeat,
              var(--rivet) left bottom / 8px 8px no-repeat, var(--rivet) right bottom / 8px 8px no-repeat; }
/* Wappen links am Teambalken */
.bar.hp > span::before { content: ""; position: absolute; left: -26px; top: 50%; transform: translateY(-50%); width: 26px; height: 30px;
  background: var(--team, var(--red)); border: 3px solid var(--outline);
  border-radius: 4px 4px 50% 50% / 4px 4px 60% 60%; box-shadow: inset 7px 0 0 rgba(255,255,255,.25); }
.bar.hp.red { --team: var(--red); } .bar.hp.blue { --team: var(--blue); }
[data-theme="rome"] .bar.hp > span::before { border-radius: 50%; width: 28px; height: 28px; left: -28px;
  background: radial-gradient(circle, var(--team) 0 52%, #d4a73a 56% 100%); box-shadow: none; }
[data-theme="space"] .bar.hp { clip-path: none; }
[data-theme="space"] .bar.hp > span::before { clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); border: none;
  background: var(--team); box-shadow: none; width: 28px; height: 26px; left: -28px; }

/* Zeitbalken der Bonusaufgabe: läuft von Gold nach Rot */
.timer-bar { position: relative; height: 14px; margin-bottom: 8px; border-radius: var(--bar-radius); background: var(--bar-trough);
  box-shadow: 0 0 0 2px var(--outline), inset 0 2px 4px rgba(0,0,0,.6); overflow: hidden; }
.timer-bar i { display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, #e5483b, #f0b429 40%, var(--gold)); background-size: 100vw 100%; }
.timer-bar::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 9px, rgba(0,0,0,.25) 9px 10px); }

/* Generator-Fortschritt */
.bar.progress { margin: 0 0 12px; }
.bar.progress > i { background: linear-gradient(#ffe07a, var(--gold) 45%, #b9780f); }

/* Upgrade-Stufen als Edelsteine */
.lvl i { width: 14px; height: 14px; transform: rotate(45deg) scale(.8); border: 2px solid var(--outline); background: var(--bar-trough); border-radius: 2px; }
.lvl i.on { background: linear-gradient(135deg, #fff6c0, var(--gold) 50%, #a5740f); box-shadow: 0 0 6px var(--gold); }
[data-theme="space"] .lvl i.on { background: linear-gradient(135deg, #b8fff4, #46e0c8); box-shadow: 0 0 8px #46e0c8; }

/* Schieberegler (Winkel, Kraft, Lautstärke) */
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; height: 22px; cursor: pointer; --p: 50%; }
input[type=range]:disabled { opacity: .45; cursor: not-allowed; }
input[type=range]::-webkit-slider-runnable-track {
  height: 10px; border-radius: var(--bar-radius); border: 2px solid var(--outline);
  background: linear-gradient(90deg, var(--gold) 0 var(--p), var(--bar-trough) var(--p) 100%);
  box-shadow: inset 0 2px 3px rgba(0,0,0,.4); }
input[type=range]::-moz-range-track { height: 6px; border-radius: var(--bar-radius); border: 2px solid var(--outline); background: var(--bar-trough); }
input[type=range]::-moz-range-progress { height: 6px; border-radius: var(--bar-radius); background: var(--gold); border: 2px solid var(--outline); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 22px; margin-top: -8px; border: 3px solid var(--outline);
  border-radius: 4px 4px 50% 50% / 4px 4px 60% 60%; background: linear-gradient(90deg, var(--accent) 0 50%, color-mix(in srgb, var(--accent) 70%, #fff) 50%); }
input[type=range]::-moz-range-thumb {
  width: 14px; height: 16px; border: 3px solid var(--outline);
  border-radius: 4px 4px 50% 50% / 4px 4px 60% 60%; background: var(--accent); }
[data-theme="rome"] input[type=range]::-webkit-slider-thumb { border-radius: 50%; width: 20px; height: 20px; margin-top: -7px; background: radial-gradient(circle at 35% 35%, #fff2b8, #d4a73a 55%, #8a6a1f); }
[data-theme="rome"] input[type=range]::-moz-range-thumb { border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2b8, #d4a73a 55%, #8a6a1f); }
[data-theme="space"] input[type=range]::-webkit-slider-runnable-track { background: linear-gradient(90deg, #46e0c8 0 var(--p), var(--bar-trough) var(--p) 100%); box-shadow: 0 0 6px rgba(77,195,255,.4); border-color: #4dc3ff; }
[data-theme="space"] input[type=range]::-webkit-slider-thumb { border-radius: 2px; transform: rotate(45deg); width: 16px; height: 16px; margin-top: -5px; background: #4dc3ff; border-color: #0d0a1e; box-shadow: 0 0 8px #4dc3ff; }
[data-theme="space"] input[type=range]::-moz-range-progress { background: #46e0c8; }
[data-theme="space"] input[type=range]::-moz-range-thumb { border-radius: 2px; transform: rotate(45deg); background: #4dc3ff; }

/* ---------- Online-Lobby */
.online-box { width: min(1040px, 100%); margin: 0 auto; }
.online-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-bottom: 16px; }
.online-card { background: var(--panel-2); border: 3px solid var(--outline); border-radius: 8px; padding: 12px 14px; }
.online-name { display: flex; gap: 10px; align-items: flex-end; max-width: 520px; }
.code-input { font: 800 1.3rem var(--font-head); letter-spacing: 4px; text-transform: uppercase; width: 9em; }
.room-code { font-family: var(--font-head); letter-spacing: 5px; background: var(--outline); color: var(--gold); padding: 2px 12px; border-radius: 8px; }
.room-list { display: grid; gap: 6px; }
.room-row { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; background: var(--panel-2); border: 2px solid var(--outline); border-radius: 8px; padding: 6px 10px; }
.room-row .code { font-family: var(--font-head); letter-spacing: 3px; }
.room-row .btn { margin-left: auto; }
.lobby-teams { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin: 14px 0; }
.lobby-team { background: var(--panel-2); border: 3px solid var(--outline); border-radius: 8px; padding: 10px 12px; }
.lobby-team.red { border-top: 8px solid var(--red); } .lobby-team.blue { border-top: 8px solid var(--blue); } .lobby-team.spectator { border-top: 8px solid var(--gold); }
.lobby-team ul { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 3px; min-height: 2em; }
.lobby-team li.away { opacity: .55; }
.turn-flash { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); z-index: 6; pointer-events: none;
  font: 800 clamp(1.6rem, 4vw, 2.6rem) var(--font-head); color: var(--gold); text-align: center; max-width: 90vw; text-shadow: 3px 3px 0 var(--outline), 0 0 18px rgba(0,0,0,.5);
  animation: flash 1.8s forwards; }
@keyframes flash { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.8); } 15%, 75% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; } }

/* ---------- KI-Status & Dokument-Scanner */
.ai-status { padding: 6px 10px; border-radius: 6px; margin-bottom: 8px; font-size: .9rem; border: 2px solid var(--outline); background: var(--panel-2); }
.ai-status.ok { border-color: var(--ok); } .ai-status.bad { border-color: var(--bad); }
.scan-drop { border: 3px dashed var(--panel-edge); border-radius: 10px; padding: 12px; text-align: center; display: grid; gap: 8px; justify-items: center; }
.scan-drop.over { background: var(--panel-2); border-color: var(--gold); }
.scan-drop p { margin: 0; font-weight: 700; }
.scan-pages { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.scan-page { position: relative; width: 120px; background: var(--panel-2); border: 2px solid var(--outline); border-radius: 6px; padding: 4px; display: grid; gap: 2px; font-size: .7rem; }
.scan-page img { width: 100%; height: 90px; object-fit: cover; border-radius: 4px; }
.scan-page .txt { height: 90px; overflow: hidden; font-size: .65rem; line-height: 1.2; }
.scan-page .btn-icon { position: absolute; top: -8px; right: -8px; padding: 0 6px; font-size: .75rem; }
.doc-result .stars { color: var(--gold); text-shadow: 1px 1px 0 var(--outline); letter-spacing: 2px; font-size: 1.1rem; }
.doc-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.doc-cols ul { margin: 4px 0; padding-left: 18px; }
.use-doc { display: flex; gap: 6px; align-items: center; font-weight: 800; margin: 10px 0 6px; }
pre.ocr { white-space: pre-wrap; max-height: 220px; overflow: auto; font-size: .78rem; background: var(--panel); padding: 8px; border-radius: 6px; }
.camera-modal video { width: 100%; max-height: 60vh; background: #000; border-radius: 8px; border: 3px solid var(--outline); }

@media (max-width: 700px) {
  .lobby-teams { grid-template-columns: 1fr; }
  .online-name { flex-direction: column; align-items: stretch; }
}

/* ---------- Eigene Emojis (ui/emoji.js) */
img.emo { width: 1.2em; height: 1.2em; vertical-align: -0.24em; display: inline-block; margin: 0 .04em; pointer-events: none;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,.25)); }
.btn img.emo { margin-right: .12em; }
.btn-icon img.emo { width: 1.35em; height: 1.35em; margin: 0; }
.logo img.emo, h1 img.emo { width: 1em; height: 1em; }

/* ---------- QR-Code zum Beitreten */
.room-top { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; }
.qr-card { display: grid; justify-items: center; gap: 4px; background: var(--panel-2); border: 3px solid var(--outline); border-radius: 10px;
  padding: 10px; cursor: zoom-in; font: 800 .85rem var(--font-body); color: var(--ink); box-shadow: 0 4px 0 var(--outline); }
.qr-card:hover { transform: translateY(-2px); }
.qr-card .qr { width: 170px; height: 170px; }
.qr-card .qr:empty::before { content: "…"; }
.qr-card .qr svg, .qr-big .qr svg { width: 100%; height: 100%; display: block; }
.qr-card small { font-weight: 600; color: var(--ink-soft); max-width: 190px; overflow-wrap: anywhere; }
.qr-big { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; padding: 16px; cursor: zoom-out; }
.qr-big .panel { text-align: center; width: min(640px, 100%); }
.qr-big .qr { width: min(70vh, 100%); aspect-ratio: 1; margin: 0 auto 10px; }
.qr-big p { font-size: 1.1rem; }
.scan-create { margin-top: 12px; border: 2px dashed var(--panel-edge); border-radius: 8px; padding: 8px 10px; }
.scan-create summary { cursor: pointer; font-weight: 800; }
@media (max-width: 700px) { .room-top { grid-template-columns: 1fr; } .qr-card { justify-self: center; } }
.hud-bottom { gap: 8px; }
.hud-bottom img.emo { width: 1.05em; height: 1.05em; }
.hud-bottom .aim { min-width: 140px; }
/* Zielregler geben Platz ab, damit die Leiste auf breiten Bildschirmen einzeilig bleibt */
.hud-bottom .aim { flex: 1 1 110px; min-width: 100px; max-width: 220px; }
@media (min-width: 1100px) { .hud-bottom { flex-wrap: nowrap; } .hud-bottom .actions { flex-wrap: nowrap; flex-shrink: 0; } .hud-bottom .who { flex-shrink: 1; min-width: 90px; } }
[data-theme="space"] img.emo { filter: drop-shadow(0 0 1px rgba(232,236,255,.75)) drop-shadow(0 0 2px rgba(77,195,255,.35)); }

/* ---------- Lehrer-Anmeldung */
.login-back { position: fixed; z-index: 70; }
.login-modal { width: min(440px, 100%); }
.login-modal .field { margin: 10px 0; }
.ai-status .btn { padding: 2px 10px; font-size: .8rem; margin-left: 6px; }
/* Viele Waffen/Munition: Leiste kompakter, damit alles in eine Zeile passt */
.hud-bottom.compact .aim { min-width: 84px; flex-basis: 90px; }
.hud-bottom.compact .fire-btn { padding: 8px 14px; font-size: 1.1rem; }
.hud-bottom.compact .actions .btn:not(.fire-btn):not(.btn-icon) { padding-left: 10px; padding-right: 10px; }
.hud-bottom.compact .bonus-toggle { font-size: .78rem; }
.hud-bottom.compact > .btn { padding-left: 10px; padding-right: 10px; }
.shop-item .ttl .badge-new img.emo { width: 1em; height: 1em; margin: 0 2px 0 0; vertical-align: -0.12em; }
.shop-item .ttl { flex-wrap: wrap; row-gap: 2px; }
.shop-item .ttl .badge-new { white-space: nowrap; display: inline-flex; align-items: center; }

/* ============================== TURNIER */
.mode-bar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; margin: 12px 0 0; }
.seg { display: inline-flex; gap: 0; }
.seg .btn { border-radius: 0; opacity: .65; }
.seg .btn:first-child { border-radius: 8px 0 0 8px; } .seg .btn:last-child { border-radius: 0 8px 8px 0; }
.seg .btn.on { opacity: 1; background: var(--gold); color: var(--outline); }
.field.inline select { min-width: 150px; }
.btn-mini { padding: 1px 8px; font-size: .78rem; margin-left: 6px; }
.small-note { font-size: .82rem; color: var(--ink-soft); margin: 6px 0; }
.lobby-team.player { border-top: 8px solid var(--gold); }
.lobby-team.tour-plan { border-top: 8px solid var(--panel-edge); }
.lobby-team.tour-plan p { margin: 4px 0; }
.tour-view { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; }
.tour-view section { background: var(--panel-2); border: 3px solid var(--outline); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.match-list { display: grid; gap: 6px; }
.match-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; background: var(--panel); border: 2px solid var(--outline); border-radius: 8px; padding: 6px 10px; }
.match-row b { font-family: var(--font-head); font-size: .8rem; }
.match-row .tag, .match-row .btn { margin-left: auto; }
.match-row.done { opacity: .7; }
.match-row.me { box-shadow: 0 0 0 3px var(--gold); }
.tour-table { width: 100%; }
.tour-table tr.me td { background: rgba(224,169,46,.25); }
.res { display: inline-block; width: 1.4em; text-align: center; font-style: normal; font-weight: 800; font-size: .75rem; border: 2px solid var(--outline); border-radius: 4px; margin-right: 2px; }
.res.W { background: var(--ok, #46c46a); color: #fff; } .res.L { background: var(--bad, #d63a30); color: #fff; } .res.F { background: var(--gold); color: var(--outline); }
@media (max-width: 760px) { .tour-view { grid-template-columns: 1fr; } }

/* Siegerehrung */
.podium-overlay { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, #3b2a5c 0%, #140d24 70%); color: #fff6e0; opacity: 0; transition: opacity .6s; }
.podium-overlay.in { opacity: 1; }
.podium-rays { position: absolute; left: 50%; top: 38%; width: 220vmax; height: 220vmax; transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 0deg, rgba(255,211,77,.10) 0 8deg, transparent 8deg 20deg); animation: podium-spin 40s linear infinite; opacity: .4; transition: opacity 1s; }
.podium-overlay.champion .podium-rays { opacity: 1; }
@keyframes podium-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.podium-box { position: relative; width: min(860px, 100%); max-height: 100%; overflow-y: auto; text-align: center; }
.podium-title { font-size: clamp(1.8rem, 6vw, 3.4rem); color: #ffd34d; text-shadow: 0 4px 0 #2b1d14, 0 0 30px rgba(255,211,77,.6); margin-bottom: .1em;
  animation: podium-drop .8s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes podium-drop { from { transform: translateY(-60px) scale(.6); opacity: 0; } }
.podium-sub { margin: 0 0 18px; opacity: .85; }
.podium-stage { display: flex; justify-content: center; align-items: flex-end; gap: clamp(6px, 2vw, 18px); min-height: 360px; }
.podium-col { flex: 1 1 0; max-width: 240px; display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; }
.podium-block { position: relative; border: 4px solid #2b1d14; border-bottom: none; border-radius: 10px 10px 0 0; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start; padding-top: 8px; color: #2b1d14; box-shadow: inset 0 6px 0 rgba(255,255,255,.35);
  transform: scaleY(0); transform-origin: bottom; transition: transform .9s cubic-bezier(.2,1.3,.4,1); }
.podium-block span { font-family: var(--font-head); font-size: clamp(2rem, 6vw, 3.2rem); font-weight: 900; line-height: 1; }
.podium-block small { font-weight: 800; font-size: .72rem; letter-spacing: 1px; }
.place-1 .podium-block { height: 170px; background: linear-gradient(#ffe27a, #e0a92e); }
.place-2 .podium-block { height: 120px; background: linear-gradient(#f2f5f8, #a9b3bd); }
.place-3 .podium-block { height: 85px; background: linear-gradient(#f0b27a, #b86a2e); }
.podium-card { opacity: 0; transform: translateY(30px) scale(.7); transition: opacity .5s .5s, transform .7s .5s cubic-bezier(.2,1.5,.4,1); padding: 0 4px 10px; }
.podium-col.shown .podium-block { transform: scaleY(1); }
.podium-col.shown .podium-card { opacity: 1; transform: none; }
.podium-medal { font-size: clamp(2.4rem, 7vw, 3.6rem); line-height: 1; }
.podium-medal img, .podium-medal svg { width: 1em; height: 1em; }
.podium-name { font-family: var(--font-head); font-weight: 900; font-size: clamp(.95rem, 2.6vw, 1.35rem); overflow-wrap: anywhere; margin-top: 4px; }
.place-1 .podium-name { color: #ffd34d; font-size: clamp(1.1rem, 3.2vw, 1.7rem); }
.place-1.shown .podium-card { animation: podium-glow 1.6s ease-in-out 1.2s infinite alternate; }
@keyframes podium-glow { to { filter: drop-shadow(0 0 18px rgba(255,211,77,.9)); transform: scale(1.05); } }
.podium-rec { font-size: .8rem; opacity: .85; }
.podium-you { display: inline-block; margin-top: 6px; background: #ffd34d; color: #2b1d14; font-weight: 900; font-size: .75rem; padding: 2px 8px; border-radius: 999px; border: 2px solid #2b1d14; }
.podium-col.me .podium-block { box-shadow: inset 0 6px 0 rgba(255,255,255,.35), 0 0 0 4px #ffd34d; }
.podium-drum { min-height: 1.6em; font-family: var(--font-head); font-size: 1.2rem; margin: 14px 0 0; }
.podium-drum.on { animation: podium-shake .1s linear infinite; }
@keyframes podium-shake { 0% { transform: translateX(-2px); } 50% { transform: translateX(2px); } }
.podium-rest ol { display: inline-block; text-align: left; margin: 10px 0 0; padding-left: 2.2em; max-height: 9em; overflow-y: auto; }
.podium-rest li.me { color: #ffd34d; font-weight: 800; }
.podium-close { margin-top: 16px; width: auto; opacity: 0; pointer-events: none; transition: opacity .5s; }
.podium-overlay.done .podium-close { opacity: 1; pointer-events: auto; }
.podium-confetti { position: absolute; inset: 0; pointer-events: none; }
.podium-confetti i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; animation: podium-fall var(--d) var(--delay) linear forwards; }
@keyframes podium-fall { to { transform: translate(var(--x), 110vh) rotate(var(--r)); } }
@media (max-width: 520px) { .podium-stage { min-height: 300px; } .place-1 .podium-block { height: 130px; } .place-2 .podium-block { height: 95px; } .place-3 .podium-block { height: 65px; } }
@media (prefers-reduced-motion: reduce) {
  .podium-rays, .place-1.shown .podium-card, .podium-drum.on { animation: none; }
  .podium-block, .podium-card { transition-duration: .01s; transition-delay: 0s; }
}
