:root {
  color-scheme: dark;
  --bg: #111418;
  --panel: #1a2027;
  --panel-2: #222a33;
  --text: #f2f5f8;
  --muted: #9aa7b5;
  --line: #323c48;
  --accent: #ffbf4d;
  --accent-2: #4fc3f7;
  --danger: #ff6b6b;
  --good: #75d27e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  border-radius: 8px;
  color: #111418;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 44px;
  padding: 0 18px;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.55;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
}

.muted {
  color: var(--muted);
  margin-top: 6px;
}

.profile,
.counter,
.status {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  max-width: 220px;
  overflow: hidden;
  padding: 8px 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.primary {
  background: var(--accent);
}

.secondary {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
}

.wide {
  width: 100%;
}

.layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(320px, 0.82fr) minmax(420px, 1fr);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 220px;
  padding: 14px;
}

.panel-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.pet-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.pet-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 8px;
  min-height: 170px;
  padding: 12px;
}

.pet-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.pet-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.pet-title strong {
  overflow-wrap: anywhere;
}

.type-pill {
  background: rgba(79, 195, 247, 0.14);
  border: 1px solid rgba(79, 195, 247, 0.35);
  border-radius: 999px;
  color: var(--accent-2);
  flex: none;
  padding: 4px 8px;
}

.stats {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(4, 1fr);
}

.stat {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  padding: 7px;
  text-align: center;
}

.stat b {
  display: block;
  font-size: 13px;
}

.stat span {
  color: var(--muted);
  font-size: 11px;
}

.ability {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

.selected {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  margin-bottom: 10px;
  min-height: 48px;
  padding: 12px;
}

.combatants {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 10px 0;
}

.fighter-card {
  background: #202832;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
}

.fighter-card.attacker {
  border-color: rgba(255, 191, 77, 0.45);
}

.fighter-card.defender {
  border-color: rgba(79, 195, 247, 0.45);
}

.fighter-card.placeholder {
  min-height: 190px;
  place-content: center;
}

.fighter-role {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.fighter-empty {
  color: var(--muted);
  text-align: center;
}

.fighter-topline {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  min-width: 0;
}

.fighter-name {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.fighter-owner {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.fighter-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fighter-pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 12px;
  line-height: 1;
  padding: 6px 8px;
}

.hp-row {
  display: grid;
  gap: 6px;
}

.hp-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.hp-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.hp-value {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.hp-track {
  background: #11161c;
  border: 1px solid var(--line);
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
  position: relative;
}

.hp-fill {
  background: var(--good);
  border-radius: inherit;
  height: 100%;
  min-width: 2px;
  transition: width 220ms ease, background-color 220ms ease;
  width: 100%;
}

.hp-fill.mid {
  background: var(--accent);
}

.hp-fill.low {
  background: var(--danger);
}

.fighter-stats {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(3, 1fr);
}

.fighter-stat {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  min-width: 0;
  padding: 7px 5px;
  text-align: center;
}

.fighter-stat b {
  display: block;
  font-size: 13px;
}

.fighter-stat span {
  color: var(--muted);
  display: block;
  font-size: 10px;
  margin-top: 2px;
}

.fighter-ability,
.fighter-effects {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.fighter-effects strong,
.fighter-ability strong {
  color: var(--text);
}

.reward {
  background: rgba(117, 210, 126, 0.1);
  border: 1px solid rgba(117, 210, 126, 0.35);
  border-radius: 8px;
  color: var(--text);
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
}

.reward[hidden] {
  display: none;
}

.reward-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, 1fr);
}

.reward-actions button {
  min-width: 0;
  padding: 0 8px;
}

.battle-log {
  background: #0b0e11;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #dfe7ef;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  margin: 12px 0 0;
  max-height: 480px;
  min-height: 260px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .combatants {
    grid-template-columns: 1fr;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .reward-actions {
    grid-template-columns: repeat(2, 1fr);
  }
}
