@property --ally-active-glow-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

:root {
  --bg: #17130c;
  --panel: #211a11;
  --panel-2: #2b2216;
  --border: #6d5429;
  --text: #f2e6cc;
  --muted: #c8af7a;
  --accent: #c89f3d;
  --accent-2: #e3bf64;
  --danger: #d27b47;
  --warn: #dfac43;
  --enemy: #d5a64f;
  --radius: 12px;
  --font: "Manrope", "DM Sans", system-ui, sans-serif;
  --font-heading: "Cinzel", "Times New Roman", serif;
  --arena-bg-image: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.45;
}

/* Keep scrolling behavior but hide scrollbar UI across browsers. */
* {
  -ms-overflow-style: none; /* IE/Edge Legacy */
  scrollbar-width: none; /* Firefox */
}

*::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none; /* Chrome/Safari/Opera */
}

body {
  padding: 1.25rem;
  max-width: 1100px;
  margin: 0 auto;
}

/* Full-viewport battle: no page scroll; only the log scrolls inside its band */
body:has(#screen-battle.active) {
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  margin: 0;
  padding: 0;
}

/* Full-viewport party select: no page scroll, only internal panes scroll. */
body:has(#screen-party.active) {
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

body:has(#screen-party.active) > header {
  flex-shrink: 0;
}

body:has(#screen-party.active) #screen-party.active {
  display: block;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

body:has(#screen-battle.active) > header,
body:has(#screen-battle.active) > footer.note {
  display: none;
}

h1 {
  font-family: var(--font-heading);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
}

h2 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--muted);
}

.screen {
  display: none;
  animation: fade 0.25s ease;
}

.screen.active {
  display: block;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tagline {
  color: var(--muted);
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
}

.grid {
  display: grid;
  gap: 0.75rem;
}

.party-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.party-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: start;
  min-height: 0;
}

body:has(#screen-party.active) .party-layout {
  height: 100%;
  align-items: stretch;
}

.party-layout-main {
  min-height: 0;
}

body:has(#screen-party.active) .party-layout-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body:has(#screen-party.active) .party-layout-main h2,
body:has(#screen-party.active) .party-layout-main .btn-primary {
  flex-shrink: 0;
}

body:has(#screen-party.active) .party-grid {
  flex: 1;
  min-height: 0;
  overflow: auto;
  align-content: start;
  padding-right: 0.2rem;
}

.party-layout-main .btn-primary {
  margin-top: 1rem;
}

@media (max-width: 820px) {
  .party-grid {
    grid-template-columns: 1fr;
  }
}


.status-panel {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text);
  overflow-wrap: anywhere;
}

.status-panel-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.status-section {
  margin-bottom: 1rem;
}

.status-section:last-child {
  margin-bottom: 0;
}

.status-section > h3 {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
}

.status-fighter {
  margin-bottom: 0.85rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgb(109 84 41 / 0.6);
}

.status-fighter:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.status-fighter h4 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  color: var(--accent-2);
}

.status-fighter.status-foe-block h4 {
  color: var(--enemy);
}

.status-fighter .role {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.status-fighter .stat-line {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 0.45rem;
}

.status-skill {
  margin-top: 0.5rem;
  padding: 0.45rem 0.5rem;
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.status-skill strong {
  display: block;
  font-size: 0.82rem;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.skill-desc {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.skill-mech {
  margin: 0;
  font-size: 0.74rem;
  color: #a5b4fc;
}

.skill-lvl {
  margin: 0.25rem 0 0;
  font-size: 0.72rem;
  color: var(--accent);
}

.cycle-block {
  margin-top: 0.65rem;
  padding: 0.5rem 0.55rem;
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid #7f1d1d44;
}

.cycle-block p {
  margin: 0.25rem 0;
  font-size: 0.74rem;
  color: var(--muted);
}

.cycle-block .cycle-next {
  color: var(--warn);
}

.cycle-block .cycle-pattern {
  color: var(--text);
  word-break: break-word;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.8), 0 4px 14px rgb(149 117 45 / 0.12);
}

.card:hover {
  border-color: var(--accent-2);
  background: var(--panel-2);
}

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

.card h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.party-card-layout {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1rem;
  min-width: 0;
}

.party-card-info {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.party-card-info h3 {
  margin: 0 0 0.35rem;
  font-size: 1.02rem;
  line-height: 1.2;
}

.party-card-info .stats-row {
  font-size: 0.78rem;
}

.party-card-skills {
  margin-top: 0.35rem;
  font-size: 0.74rem;
}

.party-card-sprite {
  width: clamp(88px, 28vw, 132px);
  height: clamp(88px, 28vw, 132px);
  border-radius: 0;
  border: none;
  background: transparent;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  align-self: center;
}

.party-card-sprite-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.party-card-sprite-fallback {
  display: none;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  padding: 0.35rem;
  text-align: center;
}

.party-card-sprite-fallback.is-visible {
  display: inline;
}

.card .role {
  font-size: 0.8rem;
  color: var(--accent-2);
  margin-bottom: 0.5rem;
}

.stats-row {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 0.55rem 1rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.75), 0 2px 8px rgb(149 117 45 / 0.14);
}

.btn:hover:not(:disabled) {
  border-color: var(--accent-2);
  background: #3a2d1a;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #d3aa4c, #9e7827);
  border-color: #b08933;
  color: #20180c;
  margin-top: 1rem;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.battle-screen.active .toolbar {
  margin-bottom: 0;
  flex-shrink: 0;
}

.round-pill {
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  max-width: 100%;
}

.mute-btn {
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
}

.speed-btn {
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
}

@media (max-width: 820px) {
  .battle-screen.active .toolbar {
    flex-wrap: nowrap;
    gap: 0.35rem;
  }

  .battle-screen.active .toolbar .round-pill {
    font-size: 0.72rem;
    padding: 0.25rem 0.45rem;
    white-space: nowrap;
  }

  .battle-screen.active .toolbar .mute-btn {
    width: 30px;
    min-width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 999px;
    font-size: 0;
    line-height: 1;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .battle-screen.active .toolbar .mute-btn::before {
    content: "🔊";
    font-size: 0.92rem;
  }

  .battle-screen.active .toolbar .mute-btn[aria-pressed="true"]::before {
    content: "🔇";
  }

  .battle-screen.active .toolbar .speed-btn {
    min-width: 64px;
    padding: 0.25rem 0.45rem;
    font-size: 0.7rem;
    line-height: 1.1;
    flex: 0 0 auto;
  }
}

.battle-screen.active {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  box-sizing: border-box;
  padding-top: max(0.5rem, env(safe-area-inset-top));
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}

.battle-screen.active > .toolbar,
.battle-screen.active > .battle-mid-scroll {
  width: 100%;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  box-sizing: border-box;
}

/* Main battle row: sprites 50% | right column (HUD or log + skills) 50% */
.battle-mid-scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
}

.battle-screen.active > .toolbar {
  padding-top: 0.35rem;
  padding-bottom: 0.5rem;
}

.battle-mid-scroll > .battle-arena {
  flex: 0 0 50%;
  width: 50%;
  max-width: 50%;
  min-width: 0;
  min-height: 0;
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.battle-right-col {
  flex: 0 0 50%;
  width: 50%;
  max-width: 50%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-top: 1px solid var(--border);
}

.battle-right-toolbar {
  flex-shrink: 0;
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.battle-view-toggle-btn {
  font-size: 0.76rem;
  padding: 0.35rem 0.65rem;
}

.battle-right-body {
  flex: 1 1 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.battle-panel {
  position: absolute;
  inset: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: none;
  box-sizing: border-box;
}

.battle-panel.is-active {
  display: flex;
}

.battle-panel-hud {
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.5rem 0.65rem 0.65rem;
}

.battle-panel-log {
  flex-direction: column;
  padding: 0;
}

.battle-log-inner {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  border-bottom: 1px solid var(--border);
}

.battle-log-inner .battle-log {
  flex: 0 0 50%;
  width: 50%;
  max-width: 50%;
  margin-top: 0;
  min-width: 0;
  min-height: 0;
  height: auto;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--border);
  font-size: 0.8rem;
  padding: 0.5rem 0.55rem;
}

.battle-log-inner .battle-status-panel {
  flex: 0 0 50%;
  width: 50%;
  max-width: 50%;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: 0;
  border: none;
  font-size: 0.78rem;
  padding: 0.5rem 0.55rem;
}

.battle-arena {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  gap: clamp(1rem, 4vw, 2.5rem);
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  min-height: clamp(108px, 20dvh, 220px);
  position: relative;
  overflow: hidden;
  background:
    var(--arena-bg-image),
    linear-gradient(180deg, #2f2315 0%, #17130c 100%);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
}

.battle-arena::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 70%, rgb(0 0 0 / 0) 0%, rgb(0 0 0 / 0.24) 72%, rgb(0 0 0 / 0.42) 100%),
    linear-gradient(180deg, rgb(0 0 0 / 0.1), rgb(0 0 0 / 0.2));
}

.battle-arena > * {
  position: relative;
  z-index: 1;
}

@keyframes arena-lines-drift {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(32px, 32px, 0);
  }
}

.arena-col {
  container-type: size;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  flex: 1 1 0;
  max-width: 50%;
  min-height: 0;
  padding-bottom: 33%;
}

.arena-col-allies,
.arena-col-foe {
  align-self: stretch;
}

.arena-sprites {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  align-content: flex-end;
  gap: clamp(0.45rem, 1.5vw, 0.85rem);
  width: 100%;
  height: 100%;
  min-height: 0;
}

.sprite-tile {
  position: relative;
  box-sizing: border-box;
  border-radius: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.74rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.15;
  padding: 0.35rem;
  color: var(--text);
  transition: opacity 0.2s, transform 0.2s;
}

.sprite-tile.has-sprite {
  padding: 0;
  overflow: hidden;
}

.sprite-tile .sprite-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 0;
  pointer-events: none;
  filter: drop-shadow(0 4px 8px rgb(0 0 0 / 0.32));
}

.sprite-tile.hero .sprite-img {
  transform: scaleX(-1);
}

.sprite-tile.hero {
  width: min(80cqh, calc((100cqi - 1rem) / 3.15));
  height: min(80cqh, calc((100cqi - 1rem) / 3.15));
  aspect-ratio: 1;
}

.sprite-tile.hero.is-active {
  transform: translateY(-2px);
}

.sprite-tile.enemy {
  width: min(80cqh, 92cqi);
  height: min(80cqh, 92cqi);
  aspect-ratio: 1;
  font-size: 0.8rem;
}

@supports not (width: 1cqh) {
  .sprite-tile.hero {
    width: clamp(80px, 18vmin, 140px);
    height: clamp(80px, 18vmin, 140px);
  }

  .sprite-tile.enemy {
    width: clamp(96px, 22vmin, 168px);
    height: clamp(96px, 22vmin, 168px);
  }
}

.sprite-tile.dead {
  opacity: 0.38;
  filter: grayscale(0.85);
  transform: none;
}

.combat-float {
  position: absolute;
  left: 50%;
  top: 34%;
  transform: translate(-50%, 0);
  font-family: Cinzel, "Palatino Linotype", Palatino, serif;
  font-size: clamp(1rem, 3.5cqh, 1.6rem);
  font-weight: 700;
  font-style: italic;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1;
  pointer-events: none;
  z-index: 8;
  animation: combat-float-rise 1.05s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  will-change: transform, opacity;
}

.combat-float-damage {
  color: #fffaf2;
  text-shadow:
    0 0 1px rgb(0 0 0 / 1),
    0 1px 0 rgb(0 0 0 / 0.95),
    0 2px 0 rgb(0 0 0 / 0.75),
    0 0 10px rgb(212 168 75 / 0.55),
    0 0 22px rgb(255 255 255 / 0.2);
  filter: drop-shadow(0 2px 3px rgb(0 0 0 / 0.85));
}

.combat-float-heal {
  color: #f0d78c;
  background: linear-gradient(
    165deg,
    #fff9e6 0%,
    #e8c56a 38%,
    #c9a03a 72%,
    #8a6a1f 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 1px 0 rgb(0 0 0 / 0.9)) drop-shadow(0 0 10px rgb(232 197 106 / 0.45));
}

@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  .combat-float-heal {
    color: #e8c56a;
    background: none;
    -webkit-text-fill-color: unset;
    text-shadow:
      0 0 1px rgb(0 0 0 / 1),
      0 2px 6px rgb(0 0 0 / 0.85),
      0 0 12px rgb(232 197 106 / 0.5);
  }
}

@keyframes combat-float-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, 12px) scale(0.72) rotate(-2deg);
  }
  10% {
    opacity: 1;
    transform: translate(-50%, -4px) scale(1.12) rotate(0deg);
  }
  22% {
    transform: translate(-50%, 0) scale(1);
  }
  68% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -42px) scale(0.96) rotate(1deg);
  }
}

.battle-right-col .skill-dock-wrap {
  flex-shrink: 0;
  padding: 0.55rem 0.65rem 0.65rem;
  max-height: min(42dvh, 480px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.enemy-hud {
  background: var(--panel-2);
  border: 1px solid #b8934b;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
}

.enemy-hud h3 {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--enemy);
}

.enemy-hud .hp-bar {
  margin-bottom: 0.25rem;
}

.enemy-hud .hp-fill {
  background: linear-gradient(90deg, #a66f25, #ddb15d);
}

.party-hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  overflow: visible;
}

.hud-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.hud-card.is-active {
  position: relative;
  z-index: 1;
  isolation: isolate;
  overflow: visible;
  border-color: transparent;
  box-shadow:
    0 0 0 1px rgb(200 159 61 / 0.45),
    0 4px 18px rgb(212 168 75 / 0.22);
}

/* Highlight travels along the card rim (conic angle animates; ring is masked, not rotated). */
.party-hud .hud-card.is-active::before {
  content: "";
  position: absolute;
  inset: -3px;
  z-index: -1;
  border-radius: 13px;
  padding: 3px;
  box-sizing: border-box;
  background: conic-gradient(
    from var(--ally-active-glow-angle),
    rgb(40 28 14 / 0) 0deg,
    rgb(40 28 14 / 0) 265deg,
    rgb(255 250 230 / 0.95) 292deg,
    rgb(232 197 106 / 1) 308deg,
    rgb(200 150  70 / 0.75) 322deg,
    rgb(40 28 14 / 0) 348deg,
    rgb(40 28 14 / 0) 360deg
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
  animation: ally-active-border-sweep 2.4s linear infinite;
  pointer-events: none;
}

@keyframes ally-active-border-sweep {
  to {
    --ally-active-glow-angle: 360deg;
  }
}

.hud-card.dead {
  opacity: 0.5;
}

.hud-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.hud-card .stats-row {
  font-size: 0.72rem;
}

.fighter-effects {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  margin-top: 0.35rem;
}

.fighter-relics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.34rem;
  margin-top: 0.35rem;
}

.relic-chip {
  position: relative;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid rgb(200 159 61 / 0.85);
  background: radial-gradient(circle at 35% 30%, #f6d07b 0%, #c89f3d 58%, #7b5a1e 100%);
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.35), 0 2px 6px rgb(0 0 0 / 0.35);
}

.relic-chip:hover::after {
  content: attr(data-relic-tip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  transform: none;
  min-width: 160px;
  max-width: 240px;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #1f170f;
  color: var(--text);
  font-size: 0.66rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  white-space: normal;
  z-index: 20;
  pointer-events: none;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.45);
}

.relic-counter {
  position: absolute;
  right: -6px;
  bottom: -6px;
  min-width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgb(109 84 41 / 0.9);
  background: #1f170f;
  color: var(--text);
  font-size: 0.58rem;
  line-height: 12px;
  text-align: center;
  padding: 0 2px;
}

.effect-chip {
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1.25;
  padding: 0.18rem 0.38rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  max-width: 100%;
  word-break: break-word;
}

.effect-buff {
  color: var(--accent-2);
  background: rgb(200 159 61 / 0.14);
  border-color: rgb(200 159 61 / 0.4);
}

.effect-status {
  color: var(--warn);
  background: rgb(181 122 20 / 0.14);
  border-color: rgb(181 122 20 / 0.38);
}

.enemy-hud .fighter-effects {
  margin-top: 0.35rem;
}

.skill-dock-wrap {
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 0;
}

.skill-dock-head {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-shrink: 0;
}

.skill-dock-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.skill-dock-title {
  margin: 0;
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.skill-repeat-btn {
  flex-shrink: 0;
  font-size: 0.72rem;
  padding: 0.3rem 0.55rem;
  white-space: nowrap;
}

.skill-repeat-btn.is-auto-armed {
  border-color: var(--accent);
  color: var(--accent-2);
  box-shadow: 0 0 0 1px rgb(200 159 61 / 0.3);
}

.skill-dock {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  min-height: 0;
  overflow: visible;
}

.skill-dock .skill-placeholder {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.5rem 0;
  margin: 0;
}

.combatant {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}

.combatant.enemy {
  border-color: #b8934b;
}

.combatant.dead {
  opacity: 0.45;
}

.combatant h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.hp-bar {
  height: 8px;
  background: #3a2d1a;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.35rem;
}

.hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #b98a28, #e3bf64);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.combatant.enemy .hp-fill {
  background: linear-gradient(90deg, #8f6121, #cf9a46);
}

.hp-text {
  font-size: 0.78rem;
  color: var(--muted);
}

.skills {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.skill-btn {
  text-align: left;
  font-size: 0.78rem;
  padding: 0.45rem 0.55rem;
  min-height: 0;
}

.skill-btn strong {
  display: block;
  color: var(--accent-2);
  margin-bottom: 0.15rem;
}

.skill-btn .skill-type {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: lowercase;
}

.skill-btn-desc {
  margin: 0.35rem 0 0;
  font-size: 0.66rem;
  line-height: 1.3;
  color: var(--muted);
  font-weight: 400;
  word-break: break-word;
}

.enemy-skills-heading {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}

.enemy-skill-blocks {
  margin: 0 0 0.35rem;
}

.enemy-skill-blocks .status-skill:first-child {
  margin-top: 0.25rem;
}

.log {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  max-height: 220px;
  overflow-y: auto;
  font-size: 0.82rem;
  margin-top: 0.75rem;
}

.battle-screen .log {
  margin-top: 0;
}

.battle-screen.active .log.battle-log {
  max-height: 100%;
}

@media (max-width: 820px) {
  .battle-mid-scroll {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .battle-mid-scroll > .battle-arena {
    flex: 0 0 auto;
    width: 100%;
    max-width: none;
    aspect-ratio: 1 / 1;
    min-height: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .battle-right-col {
    flex: 1 1 0;
    width: 100%;
    max-width: none;
    min-height: 0;
    border-top: none;
  }

  .arena-col {
    padding-bottom: 18%;
  }
}

.log p {
  margin: 0.25rem 0;
  color: var(--muted);
}

.log .player {
  color: var(--accent-2);
}

.log .enemy {
  color: var(--enemy);
}

.log .system {
  color: var(--warn);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal-backdrop.active {
  display: flex;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  max-width: 520px;
  width: 100%;
}

.modal.modal-relic-draft {
  max-width: min(1040px, 96vw);
}

.modal h2 {
  color: var(--text);
  margin-bottom: 0.75rem;
}

.upgrade-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.relic-draft-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 0.7rem;
}

.relic-draft-pool,
.relic-draft-targets {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 340px;
  max-height: min(62vh, 640px);
  overflow-y: auto;
}

.relic-draft-pool h3,
.relic-draft-targets h3 {
  margin: 0;
  font-size: 0.74rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.relic-pool-strip {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-items: flex-start;
  min-height: 30px;
}

.relic-draft-chip-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  cursor: default;
}

.relic-draft-chip-wrap:active {
  cursor: default;
}

.relic-draft-chip-wrap.is-armed {
  outline: 1px solid var(--accent-2);
  border-radius: 8px;
  background: rgb(200 159 61 / 0.12);
}

.relic-draft-chip {
  cursor: grab;
  touch-action: none;
}

.relic-draft-chip:active {
  cursor: grabbing;
}

.relic-draft-desc {
  max-width: 90px;
  font-size: 0.64rem;
  line-height: 1.2;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}

.relic-target-card {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
}

.relic-target-card h4 {
  margin: 0 0 0.3rem;
  font-size: 0.78rem;
  color: var(--accent-2);
}

.relic-target-card .fighter-relics {
  margin-top: 0;
  margin-bottom: 0.35rem;
}

.relic-drop-row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.relic-drop-zone {
  border: 1px dashed rgb(200 159 61 / 0.45);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  color: var(--muted);
  font-size: 0.74rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.relic-drop-zone strong {
  color: var(--text);
  font-size: 0.76rem;
}

.relic-drop-zone p {
  margin: 0.2rem 0 0;
  font-size: 0.7rem;
  color: var(--muted);
}

.relic-drop-zone.is-over {
  border-color: var(--accent-2);
  background: rgb(200 159 61 / 0.1);
}

.relic-drop-zone.is-disabled {
  opacity: 0.35;
  border-color: rgb(200 159 61 / 0.22);
}

.relic-drop-plus {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent-2);
}

.relic-draft-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.relic-draft-actions .btn {
  height: 42px;
  min-height: 42px;
  padding-top: 0;
  padding-bottom: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.relic-draft-actions .btn-primary {
  margin-top: 0;
}

.upgrade-btn {
  text-align: left;
}

.upgrade-btn .title {
  font-weight: 700;
  color: var(--accent);
}

.upgrade-btn .desc {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 400;
}

footer.note {
  margin-top: 2rem;
  font-size: 0.78rem;
  color: var(--muted);
}

