/* Kampfbildschirm v2 (CombatScene): Karten und Knöpfe im HUD-Stil.
   Unten gehört den Daumen: Gruppe, Ultimate-Leiste, vier große Knöpfe. */

#combat-ui {
  position: fixed;
  inset: 0;
  z-index: 2400;
  pointer-events: none;          /* Tipps auf freie Fläche gehen ans Spiel (Timing) */
  font-family: var(--font-pixel);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 10px calc(12px + env(safe-area-inset-bottom));
}

.cb-card {
  background: var(--panel);
  border: 2px solid var(--ink);
  box-shadow: inset 0 0 0 2px var(--brass-dark), 0 3px 0 rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  padding: 7px 9px;
}

.cb-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
}

.cb-lv {
  font-size: 11px;
  color: var(--gold);
}

.cb-bar {
  position: relative;
  height: 9px;
  margin-top: 5px;
  background: #0d130f;
  border: 2px solid var(--ink);
  border-radius: 4px;
  overflow: hidden;
}

.cb-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  transition: width 0.25s;
}

.cb-bar span {
  position: absolute;
  inset: 0;
  font-size: 9px;
  line-height: 9px;
  text-align: center;
  text-shadow: 0 1px 0 var(--ink);
}

.cb-hp { height: 13px; }
.cb-hp span { font-size: 10px; line-height: 13px; }
.cb-hp i { background: linear-gradient(180deg, #f06a5f 0 45%, #e0493f 45% 100%); }
.cb-player .cb-hp i { background: linear-gradient(180deg, #b4e68b 0 45%, #9bd46a 45% 100%); }
.cb-stagger { height: 6px; }
.cb-stagger i { background: var(--gold); }
.cb-gauge { height: 6px; }
.cb-gauge i { background: #9fd0ff; transition: none; }
.cb-energy { height: 5px; }
.cb-energy i { background: #c77dff; }

/* Gegner oben */
.cb-enemies {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.cb-enemy {
  width: min(360px, 100%);
}

.cb-enemy.is-boss {
  width: min(460px, 100%);
  border-color: #3a1a12;
  box-shadow: inset 0 0 0 2px #b0503a, 0 3px 0 rgba(0, 0, 0, 0.35);
}

.cb-enemy.is-stunned {
  box-shadow: inset 0 0 0 2px var(--gold), 0 0 14px rgba(242, 199, 92, 0.6);
}

.cb-intent {
  --u: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  padding: 4px 8px 4px 4px;
  border-radius: 7px;
  background: #1a221c;
  border: 2px solid var(--ink);
  font-size: 13px;
}

.cb-intent.atk { color: #ffd1c9; }
.cb-intent.warn { color: var(--gold); animation: cb-pulse 0.9s ease-in-out infinite; }
.cb-intent.danger { color: #ff8a7a; border-color: #5a1a12; animation: cb-pulse 0.6s ease-in-out infinite; }
.cb-intent.def { color: #9fd0ff; }
.cb-intent.stun { color: var(--gold); }

@keyframes cb-pulse {
  50% { filter: brightness(1.35); }
}

/* Ansage in der Mitte */
.cb-banner {
  position: fixed;
  left: 50%;
  top: 28%;
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  font-size: 34px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 3px 0 var(--ink), 0 0 12px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  transition: opacity 0.2s, transform 0.2s;
}

.cb-banner.is-on {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Unten: Log, Gruppe, Ultimate, Aktionen */
.cb-bottom {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(520px, 100%);
  margin: 0 auto;
}

.cb-hint {
  text-align: center;
  font-size: 14px;
  min-height: 20px;
  color: var(--muted);
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
}

.cb-hint.is-turn {
  color: var(--gold);
  font-weight: 700;
}

.cb-hint.is-alert {
  color: #ffd9a0;
  font-weight: 700;
  animation: cb-pulse 0.5s ease-in-out infinite;
}

.cb-log {
  font-size: 12px;
  color: var(--muted);
  text-shadow: 0 1px 2px #000;
  min-height: 30px;
}

.cb-party {
  display: flex;
  gap: 6px;
}

.cb-player {
  flex: 1;
  min-width: 0;
  padding: 5px 7px;
}

.cb-player .cb-row b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.cb-player.is-me {
  flex: 1.6;
}

.cb-player.is-ready {
  box-shadow: inset 0 0 0 2px #9fd0ff, 0 0 10px rgba(159, 208, 255, 0.5);
}

.cb-player.is-down {
  opacity: 0.45;
}

#combat-ui button {
  pointer-events: auto;
  font-family: var(--font-pixel);
  color: var(--cream);
  border: 2px solid var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.cb-actions {
  display: grid;
  /* Attack · Skill 1 · Skill 2 · Guard · Potion (Skills aus der Rolle) */
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.cb-actions button[hidden] { display: none; }

.cb-actions button {
  --u: 30px;
  position: relative;
  height: 68px;
  border-radius: 12px;
  background: #2a352c;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.3), inset 0 2px 0 rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 700;
  transition: transform 0.06s, filter 0.15s, opacity 0.15s;
}

.cb-actions button[data-a="attack"] { background: #8e3a2f; }
.cb-actions button[data-a="heavy"],
.cb-actions button[data-slot="0"] { background: #8a5a2a; }
.cb-actions button[data-slot="1"] { background: #6a4a8e; }
.cb-actions button[data-a="guard"] { background: #2f5a8e; }
.cb-actions button[data-a="potion"] { background: #3f6e3f; }

.cb-actions button:active {
  transform: translateY(2px) scale(0.97);
}

.cb-actions button:disabled,
.cb-flee:disabled {
  opacity: 0.38;
  filter: grayscale(0.6);
}

#combat-ui.my-turn .cb-actions button:not(:disabled) {
  animation: cb-ready 1.2s ease-in-out infinite;
}

@keyframes cb-ready {
  50% { box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.3), 0 0 0 2px rgba(242, 199, 92, 0.55); }
}

.cb-actions em {
  position: absolute;
  top: 4px;
  right: 6px;
  font-style: normal;
  font-size: 12px;
  color: var(--gold);
}

.ui-icon.cb-shield { --ix: 14; }

/* Ultimate: Leiste, die sich füllt; voll = leuchtet */
.cb-ult {
  position: relative;
  height: 38px;
  border-radius: 10px;
  background: #241a2e;
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.cb-ult-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, #6b3fa0, #c77dff);
  transition: width 0.3s;
}

.cb-ult-label {
  position: relative;
  text-shadow: 0 1px 0 var(--ink);
}

.cb-ult.is-full {
  animation: cb-ult 0.8s ease-in-out infinite;
}

.cb-ult:disabled .cb-ult-label {
  opacity: 0.55;
}

@keyframes cb-ult {
  50% { box-shadow: 0 0 16px rgba(199, 125, 255, 0.8); filter: brightness(1.2); }
}

.cb-flee {
  align-self: center;
  padding: 5px 18px;
  border-radius: 8px;
  background: #3a3f3a;
  font-size: 12px;
}

/* Desktop: etwas luftiger */
body:not(.touch-device) .cb-actions button {
  height: 60px;
}
