/* ==========================================================
   Sky Arena – Chroniken · Stylesheet
   ========================================================== */
:root {
  --bg: #14111c;
  --bg2: #1c1828;
  --panel: #221d31;
  --panel2: #2b2440;
  --line: #3a3152;
  --text: #e8e3f5;
  --muted: #a99fc4;
  --gold: #f0b83a;
  --good: #5fd08a;
  --bad: #ef6b6b;
  --accent: #8b6bf0;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 15px;
}
body { background-image: radial-gradient(circle at 20% -10%, #2a2140 0%, #14111c 55%); min-height: 100vh; }
img.sprite, .uc-sprite, .fam-img img, .ep-card img { image-rendering: pixelated; }
h1, h2, h3 { margin: 0 0 8px; }
h1 { font-size: 26px; letter-spacing: .5px; }
h2 { font-size: 19px; color: var(--gold); }
h3 { font-size: 16px; color: #d8cdf5; }
i { color: var(--good); font-style: normal; font-size: 12px; }

#app { max-width: 1180px; margin: 0 auto; padding: 0 14px 60px; }

/* ---------- Kopfleiste ---------- */
#topbar {
  position: sticky; top: 0; z-index: 40; background: rgba(20,17,28,.96);
  backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
  padding: 8px 0 6px; margin-bottom: 14px;
}
.res { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; margin-bottom: 8px; }
.res-item { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 3px 12px; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-btn {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.nav-btn:hover { background: var(--panel2); }
.nav-btn.active { background: var(--accent); border-color: #a98cff; color: #fff; }

/* ---------- Grundelemente ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.sub-panel { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.hero { text-align: center; padding: 18px 10px 6px; }
.hero p { color: var(--muted); margin: 4px 0 0; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0; }
.hint.small { font-size: 12px; }
.hint.good { color: var(--good); }
.hint.bad { color: var(--bad); }
.hint.awakened { color: var(--gold); }
.tag { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; font-size: 11px; color: var(--muted); margin-left: 4px; }
.footer { text-align: center; color: #6a6280; font-size: 12px; margin-top: 24px; }

.btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  padding: 9px 16px; border-radius: 9px; cursor: pointer; font-size: 14px; margin: 3px;
}
.btn:hover:not(:disabled) { background: #372e52; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: #a98cff; color: #fff; }
.btn.primary:hover:not(:disabled) { background: #9a7dff; }
.btn.danger { background: #6b2b34; border-color: #944; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.big { padding: 14px 22px; font-size: 16px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.icon-btn { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.select { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.controls { display: flex; gap: 6px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.stat-cell { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: flex; justify-content: space-between; }
.stat-cell span { color: var(--muted); font-size: 13px; }

/* ---------- Balken ---------- */
.bar { position: relative; height: 14px; background: #14101f; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; margin: 3px 0; }
.bar-fill { height: 100%; transition: width .25s ease; }
.bar.hp .bar-fill { background: linear-gradient(90deg, #46c46a, #7ee39a); }
.bar.atb { height: 7px; }
.bar.atb .bar-fill { background: linear-gradient(90deg, #4a86e8, #8fc0ff); }
.bar.exp .bar-fill { background: linear-gradient(90deg, #b98cff, #e0c6ff); }
.bar-label { position: absolute; inset: 0; text-align: center; font-size: 10px; line-height: 14px; color: #fff; text-shadow: 0 1px 2px #000; }

/* ---------- Team ---------- */
.team-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.team-slot {
  position: relative; width: 118px; min-height: 140px; background: var(--bg2);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center; cursor: pointer;
}
.team-slot:hover { border-color: var(--accent); }
.ts-name { font-size: 12px; font-weight: 600; }
.ts-sub { font-size: 11px; color: var(--muted); }
.ts-empty { font-size: 40px; color: #4a4166; line-height: 72px; }
.ts-lead { position: absolute; top: 2px; left: 4px; font-size: 14px; }

/* ---------- Monsterkarten ---------- */
.mlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 10px; }
.mcard {
  position: relative; display: flex; gap: 8px; align-items: center; background: var(--bg2);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px; cursor: pointer;
}
.mcard:hover { border-color: var(--accent); background: #262038; }
.mcard.selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.mcard-info { min-width: 0; }
.mcard-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mcard-stars { color: var(--gold); font-size: 12px; letter-spacing: 1px; }
.mcard-sub, .mcard-pow { font-size: 11px; color: var(--muted); }
.mcard-badge { position: absolute; top: 4px; right: 6px; font-size: 10px; background: var(--accent); border-radius: 5px; padding: 1px 6px; }
.elem-badge { display: inline-block; width: 16px; height: 16px; line-height: 16px; text-align: center; border-radius: 50%; font-size: 10px; }

/* ---------- Beschwörung ---------- */
.summon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 10px; }
.summon-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-align: center; }
.summon-card.disabled { opacity: .55; }
.sc-icon { font-size: 42px; }
.sc-count { color: var(--gold); font-size: 13px; margin: 6px 0; }
.summon-result { text-align: center; }
.summon-glow { display: inline-block; padding: 12px; border-radius: 50%; }
.rarity-1, .rarity-2 { background: radial-gradient(circle, rgba(150,150,170,.35), transparent 70%); }
.rarity-3 { background: radial-gradient(circle, rgba(80,180,255,.35), transparent 70%); }
.rarity-4 { background: radial-gradient(circle, rgba(180,110,255,.4), transparent 70%); }
.rarity-5, .rarity-6 { background: radial-gradient(circle, rgba(255,190,60,.5), transparent 70%); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.big-stars { font-size: 26px; letter-spacing: 3px; color: var(--gold); }
.rarity-text-5, .rarity-text-6 { text-shadow: 0 0 12px var(--gold); }
.fam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.fam-row { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.fam-imgs { display: flex; gap: 4px; margin-top: 4px; }
.fam-img { background: #191426; border-radius: 8px; padding: 2px; }
.fam-img.locked img { filter: brightness(0.18); }

/* ---------- Monsterdetail ---------- */
.mdetail { display: grid; grid-template-columns: 280px 1fr; gap: 14px; }
@media (max-width: 760px) { .mdetail { grid-template-columns: 1fr; } }
.md-left { text-align: center; }
.portrait { display: inline-block; padding: 10px; border-radius: 16px; }
.md-title { font-weight: 700; margin-top: 4px; }
.md-stars { color: var(--gold); letter-spacing: 2px; }
.stats { text-align: left; margin-top: 10px; }
.srow { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 3px 2px; font-size: 13px; }
.srow span { color: var(--muted); }
.skill-row { border-top: 1px solid var(--line); padding: 8px 0; }
.skill-row:first-of-type { border-top: none; }
.sk-head { display: flex; justify-content: space-between; align-items: center; }

/* ---------- Runen ---------- */
.rune-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rune-cell {
  background: #191426; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px; text-align: center; cursor: pointer; min-height: 96px;
}
.rune-cell:hover { border-color: var(--accent); }
.rc-set { font-size: 12px; font-weight: 600; }
.rc-main { font-size: 11px; color: var(--good); }
.rc-lvl { font-size: 11px; color: var(--gold); }
.rc-slot { font-size: 22px; color: #4a4166; }
.rc-empty { font-size: 11px; color: var(--muted); }
.rune-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; margin-top: 8px; }
.rune-card {
  position: relative; display: flex; gap: 8px; background: var(--bg2);
  border: 2px solid var(--line); border-radius: 10px; padding: 8px; cursor: pointer;
}
.rune-card:hover { background: #262038; }
.r-title { font-size: 13px; font-weight: 600; }
.r-main { color: var(--good); font-size: 13px; }
.r-subs { color: var(--muted); font-size: 11px; line-height: 1.4; }
.r-equipped { position: absolute; right: 6px; bottom: 4px; font-size: 10px; color: var(--gold); }
.rune-detail { margin-bottom: 12px; }
.summary { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 8px 0; font-size: 13px; }

/* ---------- Dungeons ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab { background: var(--panel); border: 1px solid var(--line); color: var(--text); padding: 8px 16px; border-radius: 9px; cursor: pointer; }
.tab.active { background: var(--accent); border-color: #a98cff; color: #fff; }
.tab.locked, .tab:disabled { opacity: .4; cursor: not-allowed; }
.tabs.small .tab { padding: 5px 12px; font-size: 13px; }
.world-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-bottom: 12px; }
.world-btn {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  padding: 10px; border-radius: 9px; cursor: pointer; font-size: 13px; text-align: left;
}
.world-btn.active { border-color: var(--gold); background: #2e2740; }
.world-btn.locked { opacity: .35; cursor: not-allowed; }
.stage-grid, .floor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.stage-btn, .floor-btn {
  position: relative; background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  padding: 12px 8px; border-radius: 9px; cursor: pointer; text-align: center;
}
.stage-btn:hover:not(:disabled), .floor-btn:hover:not(:disabled) { border-color: var(--accent); background: #262038; }
.stage-btn.cleared, .floor-btn.cleared { border-color: #3f7a52; background: #1d2a22; }
.stage-btn.locked, .floor-btn.locked { opacity: .35; cursor: not-allowed; }
.st-n { font-weight: 600; font-size: 13px; }
.st-lvl, .floor-btn span { font-size: 11px; color: var(--muted); display: block; }
.st-mark { position: absolute; top: 3px; right: 6px; font-size: 12px; color: var(--good); }
.enemy-preview { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.ep-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; padding: 6px; width: 108px; text-align: center; }
.ep-card.boss { border-color: var(--gold); }
.ep-name { font-size: 11px; font-weight: 600; }
.ep-sub { font-size: 10px; color: var(--muted); }

/* ---------- Modal ---------- */
#modal-root { position: fixed; inset: 0; background: rgba(8,6,14,.75); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
#modal-root.open { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column; }
.modal.wide { max-width: 900px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; color: var(--gold); }
.modal-body { padding: 14px; overflow-y: auto; }
.modal-foot { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; flex-wrap: wrap; }
.save-area { width: 100%; height: 140px; background: #14101f; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-family: monospace; font-size: 11px; }
/* ---------- Finale / Abspann ---------- */
.hero.champion { border-color: var(--gold); box-shadow: 0 0 24px rgba(224,182,74,.18); }
.finale { text-align: center; }
.finale-crown { font-size: 46px; line-height: 1; margin-bottom: 6px; animation: finale-pop .8s ease-out; }
@keyframes finale-pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.finale h2 { color: var(--gold); margin: 0 0 12px; letter-spacing: .5px; }
.finale-text { color: var(--text); font-size: 13.5px; line-height: 1.6; margin: 0 auto 10px; max-width: 560px; }
.finale-team { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.ft-card { background: var(--panel2); border: 1px solid var(--gold); border-radius: 10px; padding: 8px 10px; min-width: 96px; }
.ft-name { font-size: 12px; margin-top: 4px; }
.ft-sub { font-size: 11px; color: var(--muted); }
.finale-reward { margin: 14px 0 6px; color: var(--gold); font-size: 13px; }
.finale-hint { border-left: 3px solid var(--gold); padding-left: 10px; }
.report-area { height: 420px; font-size: 11.5px; line-height: 1.45; white-space: pre; }
.help p { color: var(--muted); font-size: 13px; line-height: 1.55; }
.help b { color: var(--text); }

/* ---------- Toast ---------- */
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast-msg { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 16px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.5); transition: opacity .5s; }
.toast-msg.good { border-color: var(--good); color: var(--good); }
.toast-msg.bad { border-color: var(--bad); color: var(--bad); }
.toast-msg.fade { opacity: 0; }

/* ---------- Kampf ---------- */
#battle-root { position: fixed; inset: 0; z-index: 80; display: none; }
#battle-root.open { display: block; }
.battle-field { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 10px; overflow: hidden; }
/* z-index 6: bleibt auch über der Serien-Zwischenanzeige bedienbar */
.battle-head { display: flex; justify-content: space-between; align-items: center; color: #fff; padding: 4px 6px; position: absolute; top: 8px; left: 10px; right: 10px; z-index: 6; }
.battle-ctrls { display: flex; gap: 4px; }
.unit-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; padding: 6px 0; }
.unit-row.enemies { align-items: flex-start; margin-top: 34px; }
.unit-row.allies { align-items: flex-end; }
.ucard {
  width: 130px; background: rgba(25,20,38,.82); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px; text-align: center; transition: transform .15s;
}
.ucard.boss { width: 152px; border-color: var(--gold); }
.ucard.dead { opacity: .3; filter: grayscale(1); }
.ucard.targetable { border-color: var(--bad); cursor: crosshair; box-shadow: 0 0 12px rgba(239,107,107,.6); }
.ucard.active-turn { border-color: var(--gold); box-shadow: 0 0 14px rgba(240,184,58,.5); }
.ucard.acting { transform: translateY(-8px) scale(1.05); }
.ucard.shake { animation: shake .25s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.uc-top { display: flex; align-items: center; gap: 4px; justify-content: center; }
.uc-elem { display: inline-block; width: 16px; height: 16px; line-height: 16px; border-radius: 50%; font-size: 10px; }
.uc-name { font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-status { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; min-height: 18px; margin-top: 2px; }
.st-icon { position: relative; font-size: 11px; background: #2b2440; border-radius: 4px; padding: 0 3px; }
.st-icon.buff { box-shadow: 0 0 0 1px #4a86e8 inset; }
.st-icon.debuff { box-shadow: 0 0 0 1px #b8434a inset; }
.st-icon i { font-size: 9px; color: #fff; margin-left: 2px; }
.battle-log { text-align: center; color: #cdc4e6; font-size: 12px; min-height: 62px; padding: 4px; margin: 10px 0; }
.log-line { opacity: .8; }
.log-line:last-child { opacity: 1; color: #fff; font-weight: 600; }
.skill-bar { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; padding: 8px 0 4px; min-height: 48px; margin-top: 14px; }
.sb-actor { width: 100%; text-align: center; color: var(--gold); font-size: 13px; }
.sb-hint { width: 100%; text-align: center; color: var(--bad); font-size: 12px; }
.skill-btn {
  background: var(--panel2); border: 1px solid var(--accent); color: #fff;
  border-radius: 9px; padding: 8px 14px; cursor: pointer; min-width: 130px;
}
.skill-btn span { display: block; font-size: 10px; color: var(--muted); }
.skill-btn.disabled { border-color: var(--line); opacity: .45; cursor: not-allowed; }
.fx-layer { position: absolute; inset: 0; pointer-events: none; }
.float {
  position: absolute; transform: translateX(-50%); font-weight: 700; font-size: 17px;
  text-shadow: 0 2px 4px #000; animation: floatup 1.1s ease-out forwards; white-space: nowrap;
}
@keyframes floatup { 0% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -46px); } }
.float.dmg { color: #ffd7d7; }
.float.crit { color: #ffcf3d; font-size: 22px; }
.float.glance { color: #9fb6c9; font-size: 14px; }
.float.heal { color: #7ee39a; }
.float.buff { color: #8fc0ff; font-size: 13px; }
.float.debuff { color: #ff9ec4; font-size: 13px; }
.float.block { color: #cfc4e6; font-size: 13px; }
.float.shieldtx { color: #b6f0ff; font-size: 13px; }
.float.skillname { color: #fff; font-size: 13px; }

/* Pause zwischen zwei Kämpfen einer Wiederholungs-Serie */
.repeat-overlay {
  position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center;
  background: rgba(10,8,18,.72); backdrop-filter: blur(2px);
}
.ro-box {
  background: var(--panel); border: 1px solid var(--gold); border-radius: 14px;
  padding: 18px 26px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
.ro-title { color: var(--gold); font-size: 20px; font-weight: 700; }
.ro-sub { color: var(--text); font-size: 13px; margin-top: 6px; }
.ro-total { color: var(--muted); font-size: 12px; margin-top: 4px; }
.ro-next { color: var(--good); font-size: 12px; margin: 10px 0 6px; }
.ro-next::after { content: ''; animation: dots 1s steps(4, end) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

.session-box { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 10px; text-align: left; }
.session-box h3 { color: var(--gold); }

.result { text-align: center; }
.result h2.win { color: var(--gold); font-size: 26px; }
.result h2.lose { color: var(--bad); font-size: 26px; }
.reward-list { text-align: left; margin-top: 10px; }
.rw { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; margin: 4px 0; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.rw.good { color: var(--good); border-color: var(--good); }
