/* Kronenkrieg – Oberfläche */
:root {
  --bg: #15110d; --panel: rgba(28, 22, 17, 0.94); --panel2: #2a2119; --line: #5b4630; --gold: #e2b13c; --gold2: #f5d27a;
  --text: #f1e7d2; --soft: #c9b99b; --muted: #9a8a70; --red: #e0563f; --green: #6fbf5a; --blue: #5aa6e0;
  --radius: 10px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; -webkit-tap-highlight-color: transparent; }
#app { position: fixed; inset: 0; }
#gl, #ov { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#ov { touch-action: none; cursor: grab; }
#ov:active { cursor: grabbing; }
.hidden { display: none !important; }
.ico { display: inline-block; vertical-align: middle; line-height: 0; flex: none; }
h1, h2, h3 { font-family: "Space Grotesk", system-ui, sans-serif; margin: 0 0 8px; letter-spacing: 0.01em; }
h2 { font-size: 20px; color: var(--gold2); }
h3 { font-size: 16px; color: var(--gold2); }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.bad { color: var(--red); }
.good { color: var(--green); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* Knöpfe */
.btn { appearance: none; border: 1px solid var(--line); background: linear-gradient(#3a2d20, #2a2017); color: var(--text); border-radius: 8px; padding: 9px 14px; font: 600 14px system-ui, sans-serif; cursor: pointer; min-height: 40px; touch-action: manipulation; }
.btn:hover { border-color: #8a6a44; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.gold { background: linear-gradient(#f0c75a, #c9922a); color: #2a1a08; border-color: #8a5f12; }
.btn.red { background: linear-gradient(#d0583f, #9c3426); border-color: #6a2216; }
.btn.blue { background: linear-gradient(#4f8fc4, #2f6694); border-color: #224b6e; }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.x { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 50%; padding: 0; font-size: 18px; min-height: 0; }

/* HUD oben */
#hud { position: absolute; left: 0; right: 0; top: 0; padding: calc(6px + var(--safe-t)) 8px 6px; display: flex; gap: 6px; align-items: center; pointer-events: none; z-index: 5;
  background: linear-gradient(rgba(10, 8, 6, 0.85), rgba(10, 8, 6, 0)); }
#hud > * { pointer-events: auto; }
.res { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; min-width: 0; }
.res .r { display: flex; align-items: center; gap: 4px; background: rgba(28, 22, 17, 0.82); border: 1px solid var(--line); border-radius: 20px; padding: 3px 9px 3px 5px; font-weight: 700; font-size: 13px; white-space: nowrap; }
.res .r small { color: var(--muted); font-weight: 500; font-size: 11px; }
.pill { background: rgba(28, 22, 17, 0.85); border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; font-weight: 700; font-size: 13px; white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.pill.phase { color: var(--gold2); }
.pill.warn { border-color: var(--red); color: #ffb3a4; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { background: rgba(120, 30, 20, 0.85); } }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; padding: 0; min-height: 0; display: grid; place-items: center; font-size: 18px; }

/* Warteschlangen links */
#queues { position: absolute; left: 8px; top: calc(52px + var(--safe-t)); display: flex; flex-direction: column; gap: 4px; z-index: 4; width: 210px; max-width: 46vw; }
.q { background: rgba(28, 22, 17, 0.82); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; font-size: 12px; cursor: pointer; position: relative; overflow: hidden; }
.q .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--gold); }
.q.idle { color: var(--muted); border-style: dashed; }

/* Leiste unten */
#bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 8px calc(6px + var(--safe-b)); display: flex; gap: 6px; justify-content: center; z-index: 5;
  background: linear-gradient(rgba(10, 8, 6, 0), rgba(10, 8, 6, 0.9)); pointer-events: none; }
#bar > * { pointer-events: auto; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 62px; padding: 5px 6px; font-size: 11px; border-radius: 10px; }
.tab b { font-size: 18px; line-height: 1; }
.tab.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.badge { position: absolute; transform: translate(18px, -6px); background: var(--red); color: #fff; border-radius: 10px; font-size: 10px; padding: 0 5px; }

/* Minikarte */
#mini { position: absolute; right: 8px; bottom: calc(70px + var(--safe-b)); width: 150px; height: 150px; border: 2px solid var(--line); border-radius: 50%; z-index: 4; background: #10202e; cursor: pointer; }

/* Meldungen */
#toasts { position: absolute; left: 50%; transform: translateX(-50%); top: calc(54px + var(--safe-t)); display: flex; flex-direction: column; gap: 4px; align-items: center; z-index: 8; pointer-events: none; width: min(92vw, 460px); }
.toast { background: rgba(28, 22, 17, 0.93); border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 8px; padding: 6px 12px; font-size: 13px; animation: tin 0.25s ease-out; pointer-events: auto; }
.toast.bad { border-left-color: var(--red); }
.toast.good { border-left-color: var(--green); }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } }

/* Fenster (unten als Blatt, am PC rechts) */
#sheet { position: absolute; z-index: 10; left: 0; right: 0; bottom: 0; max-height: 72vh; overflow: auto; background: var(--panel); border-top: 2px solid var(--line); border-radius: 16px 16px 0 0;
  padding: 14px 14px calc(14px + var(--safe-b)); box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5); }
@media (min-width: 900px) and (min-height: 500px) {
  #sheet { left: auto; top: calc(56px + var(--safe-t)); bottom: 76px; right: 10px; width: 420px; max-height: none; border: 2px solid var(--line); border-radius: 14px; }
}
.sec { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.cost { display: flex; gap: 8px; flex-wrap: wrap; font-weight: 700; font-size: 13px; }
.cost span { display: flex; align-items: center; gap: 3px; }
.list { display: flex; flex-direction: column; gap: 6px; }
.item { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.item.sel { border-color: var(--gold); }
.item.dim { opacity: 0.6; }
.tabs { display: flex; gap: 4px; margin: 6px 0; flex-wrap: wrap; }
.tabs .btn.on { border-color: var(--gold); color: var(--gold2); }
.slider { width: 100%; accent-color: var(--gold); }
.prog { height: 6px; background: #000; border-radius: 3px; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--gold); }
.hero { display: flex; gap: 10px; align-items: center; }
.portrait { width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 800; font-size: 18px; color: #1b130b; border: 2px solid #000; }
.portrait.img { padding: 2px; border: none; overflow: hidden; }
.portrait.img img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.portrait.big { width: 64px; height: 64px; }
.portrait.small { width: 38px; height: 38px; font-size: 14px; }
.bio { color: var(--muted); margin: 4px 0; line-height: 1.4; }
.bio i { color: var(--gold2); }
.locked-heroes { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; }
.locked-heroes .lh { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--muted); text-align: center; }
.locked-heroes .portrait img { filter: grayscale(0.85) brightness(0.65); }
.wap { width: 20px; height: 24px; object-fit: contain; vertical-align: -6px; margin-right: 4px; }
.rar0 { background: #b9b2a5; } .rar1 { background: #6fb2e6; } .rar2 { background: #b98ae8; } .rar3 { background: linear-gradient(135deg, #ffe08a, #e0a020); }
.troops { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 8px; align-items: center; }
.troops input[type=number] { width: 78px; background: #120e0a; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px; font: inherit; }
select, input[type=text] { background: #120e0a; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px; font: inherit; }

/* Menüs */
#menu { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto;
  background: radial-gradient(ellipse at 50% 30%, rgba(60, 40, 18, 0.55), rgba(10, 8, 6, 0.96)), url() center/cover; }
.mbox { width: min(560px, 100%); background: var(--panel); border: 2px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); margin: auto; }
.mbox.wide { width: min(860px, 100%); }
.logo { text-align: center; margin-bottom: 10px; }
.logo .t { font: 800 clamp(38px, 9vw, 64px)/1 "Space Grotesk", Georgia, serif; letter-spacing: 0.04em; background: linear-gradient(#ffe7a3, #d29a2a 60%, #8a5a10); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2); }
.logo .s { color: var(--soft); margin-top: 4px; }
.mbtns { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.mbtns .btn { min-height: 48px; font-size: 16px; }
.volk { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.volk .item { cursor: pointer; }
.volk .item b { display: block; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; font-size: 13px; color: var(--soft); }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg .btn.on { border-color: var(--gold); color: var(--gold2); background: #3d2f1f; }

/* Zwischenfilme */
#cine { position: absolute; inset: 0; z-index: 30; background: #000; display: flex; align-items: center; justify-content: center; }
#cine canvas, #cine video { width: 100%; height: 100%; object-fit: cover; }
@media (orientation: portrait) { #cine video { object-fit: contain; } }
#cine .winner { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); width: min(900px, 94vw); text-align: center; opacity: 0; pointer-events: none; }
#cine .winner img { width: clamp(44px, 7vw, 80px); height: auto; display: block; margin: 0 auto 6px; filter: drop-shadow(0 2px 6px #000); }
#cine .winner .wn { font: 800 clamp(28px, 6vw, 64px)/1.1 "Space Grotesk", Georgia, serif; color: #ffe7a3; }
#cine .winner .ws { font: 600 clamp(14px, 2.4vw, 22px)/1.3 Georgia, serif; color: #f3e6c4; text-shadow: 0 2px 6px #000; margin-top: 4px; }
#cine .skip { position: absolute; right: 16px; bottom: calc(16px + var(--safe-b)); z-index: 2; }
#cine .sub { position: absolute; left: 50%; bottom: calc(70px + var(--safe-b)); transform: translateX(-50%); width: min(900px, 92vw); text-align: center; font: 600 clamp(16px, 2.6vw, 24px)/1.35 Georgia, serif; color: #fff4d8; text-shadow: 0 2px 6px #000, 0 0 2px #000; }

/* Ladebildschirm */
#boot { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; background: #0d0a07; }
#boot .boot-in { text-align: center; }
#boot .bar { width: 220px; height: 6px; background: #2a2017; border-radius: 3px; margin: 14px auto 6px; overflow: hidden; }
#boot .bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width 0.2s; }

/* Kampf-/Statistik-Tabelle */
table.stats { width: 100%; border-collapse: collapse; font-size: 13px; }
table.stats td, table.stats th { padding: 4px 6px; border-bottom: 1px solid #3a2c1e; text-align: right; }
table.stats td:first-child, table.stats th:first-child { text-align: left; }

/* Navigation/Footer von Player 0o5 nur in Menüs */
body.playing .s05-dock { display: none !important; }
.title-box .s05-dock, .pause-box .s05-dock, .end-box .s05-dock { margin-top: 14px; }

/* Handy hochkant: oben zwei Reihen – Rohstoffe + Menü, darunter Macht/Zeit/Phase */
@media (max-width: 620px) {
  #hud { flex-wrap: wrap; row-gap: 4px; gap: 4px; padding-left: 6px; padding-right: 6px; }
  #hud .res { order: 1; flex: 1 1 calc(100% - 48px); flex-wrap: nowrap; gap: 3px; }
  #hud .res .r { flex: 1 1 0; min-width: 0; justify-content: center; padding: 2px 4px; font-size: 12px; gap: 2px; }
  #hud .res .r svg { width: 15px; height: 15px; flex: none; }
  #hud .res .r small { display: none; }
  #hud .iconbtn { order: 2; width: 36px; height: 36px; }
  #hud .pill { order: 3; padding: 2px 8px; font-size: 12px; }
  #hud .pill.phase { flex: 1 1 auto; justify-content: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  #queues { top: calc(76px + var(--safe-t)); width: 138px; }
  .q { font-size: 11px; padding: 3px 6px; }
  #toasts { top: calc(76px + var(--safe-t)); left: 150px; right: 6px; width: auto; transform: none; align-items: stretch; }
  .toast { font-size: 12px; padding: 5px 9px; }
  .tab { min-width: 50px; font-size: 10px; padding: 4px 4px; }
  #mini { width: 110px; height: 110px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  #hud .res { flex-wrap: nowrap; }
  #hud .res .r { padding: 2px 7px 2px 4px; font-size: 12px; }
  #hud .res .r small { display: none; }
  #hud .pill { padding: 3px 8px; font-size: 12px; }
  #hud .iconbtn { width: 36px; height: 36px; }
  #queues { top: 48px; width: 170px; }
  .q { font-size: 11px; padding: 3px 6px; }
  #toasts { top: 48px; }
  #sheet { left: auto; right: 0; top: 0; bottom: 0; width: min(420px, 60vw); max-height: none; border-radius: 14px 0 0 14px; }
  #mini { width: 110px; height: 110px; bottom: 62px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
