﻿.bag-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

.bag-hero,
.bag-game-top,
.bag-panel,
.shop-panel,
.backpack-panel {
  border: 3px solid #ffffff;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 5px #6f86c8, 7px 7px 0 rgba(111, 134, 200, 0.25);
}

.bag-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 24px;
  background:
    radial-gradient(circle at 88% 20%, rgba(255, 244, 189, 0.82) 0 28px, transparent 29px),
    linear-gradient(135deg, #fffefe, #f1e8ff 76%);
}

.bag-hero h1 {
  margin: 0;
  font-size: clamp(2.35rem, 7vw, 4.7rem);
}

.bag-game {
  position: relative;
  display: grid;
  gap: 14px;
  align-items: start;
}

.bag-game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.bag-top-actions,
.bag-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.bag-top-actions {
  justify-content: flex-end;
}

.bag-stats span {
  min-height: 34px;
  padding: 7px 9px;
  border-radius: 999px;
  background: rgba(216, 220, 255, 0.36);
  color: var(--muted);
  font-weight: 900;
}

.bag-stats strong {
  color: var(--ink);
}

.bag-panel {
  display: none;
  min-height: 520px;
  padding: 16px;
}

.bag-panel.active-view {
  display: block;
}

.bag-panel.prep-panel {
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.bag-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.bag-panel-head h2 {
  margin: 0;
}

.bag-panel-head.compact .eyebrow {
  margin-bottom: 8px;
}

.prep-layout {
  display: grid;
  grid-template-columns: minmax(270px, 360px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.shop-panel,
.backpack-panel {
  min-height: 560px;
  padding: 16px;
}

.backpack-panel {
  overflow: hidden;
}

.rotate-help,
.selection-hint,
.passive-text,
.hero-choice-note {
  margin: 0;
  color: var(--muted);
  font-weight: 900;
}

.rotate-help {
  max-width: 220px;
  font-size: 0.8rem;
  text-align: right;
}

.character-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.character-button,
.shop-item,
.bag-cell,
.speed-button,
.placed-item {
  border: 2px solid rgba(111, 134, 200, 0.38);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  font-weight: 900;
}

.character-button,
.shop-item,
.bag-cell,
.speed-button,
.placed-item,
.toast-close {
  cursor: pointer;
}

.character-button {
  display: grid;
  gap: 4px;
  min-height: 128px;
  padding: 10px;
  place-items: center;
}

.character-button.active,
.shop-item.selected,
.speed-button.active,
.placed-item.selected {
  color: #1b1728;
  background: #ffe49a;
  box-shadow: 0 0 0 3px rgba(255, 228, 154, 0.34);
}

.character-icon,
.item-icon,
.fighter-icon {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid #ffffff;
  border-radius: 14px;
  background: rgba(216, 220, 255, 0.48);
  box-shadow: 0 0 0 3px rgba(111, 134, 200, 0.25);
  font-size: 1.45rem;
}

.character-name {
  font-size: 1rem;
}

.character-meta,
.character-starts {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.25;
}

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

.shop-item {
  position: relative;
  display: grid;
  gap: 7px;
  min-height: 154px;
  padding: 10px;
  text-align: left;
}

.shop-item:disabled {
  opacity: 0.56;
  cursor: default;
}

.shop-item.sold-out {
  place-items: center;
  text-align: center;
  background:
    repeating-linear-gradient(-45deg, rgba(111, 134, 200, 0.14) 0 8px, rgba(255, 255, 255, 0.7) 8px 16px),
    rgba(255, 255, 255, 0.76);
}

.sold-label {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(111, 134, 200, 0.18);
  color: #52649d;
  font-size: 0.78rem;
}

.item-topline,
.item-meta,
.pouch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.item-name {
  font-size: 0.96rem;
}

.item-effect {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.28;
}

.price-pill,
.rarity-pill,
.pouch-head span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(216, 220, 255, 0.38);
  font-size: 0.78rem;
  font-weight: 900;
}

.sale-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #ffb7d3;
  color: #4a3342;
  font-size: 0.72rem;
  font-weight: 900;
}

.shape-mini {
  --shape-cols: 1;
  --shape-rows: 1;
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(var(--shape-cols), 8px);
  grid-template-rows: repeat(var(--shape-rows), 8px);
  gap: 2px;
  align-self: end;
}

.shape-bit {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.shape-bit.filled {
  background: #6f86c8;
}

.shape-bit.empty {
  opacity: 0;
}

.bag-board,
.battle-bag-board {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.pouch-card {
  padding: 12px;
  border: 2px solid rgba(111, 134, 200, 0.3);
  border-radius: var(--radius);
  background:
    linear-gradient(45deg, rgba(159, 200, 238, 0.14) 25%, transparent 25% 75%, rgba(159, 200, 238, 0.14) 75%),
    linear-gradient(45deg, rgba(255, 183, 211, 0.1) 25%, transparent 25% 75%, rgba(255, 183, 211, 0.1) 75%),
    rgba(255, 255, 255, 0.72);
  background-position: 0 0, 16px 16px, 0 0;
  background-size: 32px 32px;
}

.pouch-card p {
  margin: 7px 0 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.pouch-grid {
  --cols: 6;
  --rows: 2;
  --cell: 48px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  grid-template-rows: repeat(var(--rows), var(--cell));
  gap: 5px;
  width: max-content;
  max-width: 100%;
  padding: 8px;
  overflow: auto;
  border: 2px solid rgba(111, 134, 200, 0.3);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.5);
}

.bag-cell {
  width: var(--cell);
  height: var(--cell);
  min-width: 0;
  padding: 0;
  border-style: dashed;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.54);
}

.bag-cell:disabled {
  cursor: default;
}

.bag-cell::after {
  content: "+";
  color: rgba(111, 134, 200, 0.38);
  font-size: 1rem;
}

.placed-item {
  position: relative;
  z-index: 2;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  gap: 2px;
  padding: 5px;
  overflow: hidden;
  border-color: #ffffff;
  border-radius: 12px;
  background: #fff7fb;
  box-shadow: 0 0 0 3px rgba(111, 134, 200, 0.22);
  text-align: center;
}

.placed-item.cooling::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(31, 28, 45, 0.45);
  transform: scaleY(calc(1 - var(--cooldown-progress, 1)));
  transform-origin: top;
  transition: transform 90ms linear;
  pointer-events: none;
}

.placed-icon,
.placed-name {
  position: relative;
  z-index: 1;
}

.placed-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.placed-name {
  max-width: 100%;
  overflow: hidden;
  color: inherit;
  font-size: 0.68rem;
  line-height: 1.05;
  text-overflow: ellipsis;
}

.rarity-common { box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.45); }
.rarity-rare { box-shadow: inset 0 0 0 3px rgba(159, 200, 238, 0.7); }
.rarity-epic { box-shadow: inset 0 0 0 3px rgba(201, 183, 255, 0.8); }
.rarity-legendary { box-shadow: inset 0 0 0 3px rgba(255, 228, 154, 0.9); }

.item-inspector {
  min-height: 112px;
  margin-top: 12px;
  padding: 12px;
  border: 2px solid rgba(111, 134, 200, 0.38);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
}

.item-inspector strong,
.item-total-line {
  display: block;
  color: #52649d;
  font-weight: 900;
}

.item-inspector p {
  margin: 8px 0 0;
}

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

.fighter-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(216, 220, 255, 0.25);
}

.enemy-card {
  background: rgba(255, 183, 211, 0.22);
}

.hp-bar {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(31, 28, 45, 0.18);
}

.hp-bar span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #97d79b, #ffe49a);
  transition: width 160ms ease;
}

.enemy-card .hp-bar span {
  background: linear-gradient(90deg, #ff74a6, #ffe49a);
}

.battle-log {
  min-height: 150px;
  max-height: 190px;
  overflow: auto;
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  padding: 10px;
  border-radius: var(--radius);
  background: rgba(216, 220, 255, 0.22);
  color: var(--muted);
  font-weight: 800;
}

.speed-row {
  display: inline-flex;
  gap: 6px;
}

.speed-button {
  min-width: 42px;
  min-height: 34px;
}

.wide-button {
  width: 100%;
}

.bag-new-game-row {
  display: flex;
  justify-content: center;
}

.battle-countdown[hidden],
.result-toast[hidden] {
  display: none;
}

.battle-countdown {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(31, 28, 45, 0.46);
  color: #fff8ff;
  text-align: center;
  backdrop-filter: blur(4px);
}

.battle-countdown span,
.battle-countdown strong {
  position: relative;
  display: block;
  width: min(340px, calc(100% - 32px));
  padding: 0 16px;
  text-shadow: 0 3px 0 rgba(31, 28, 45, 0.24);
}

.battle-countdown span {
  align-self: end;
  margin-bottom: -18px;
  font-weight: 900;
}

.battle-countdown strong {
  align-self: start;
  color: #ffe49a;
  font-size: clamp(4.5rem, 20vw, 9rem);
  line-height: 1;
}

.result-toast {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 41;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100% - 36px));
  padding: 18px;
  border: 3px solid #fffefe;
  border-radius: 18px;
  background:
    radial-gradient(circle at 88% 18%, rgba(255, 244, 189, 0.95) 0 18px, transparent 19px),
    #fff7fb;
  color: var(--ink);
  box-shadow: 0 0 0 6px rgba(111, 134, 200, 0.86), 8px 8px 0 rgba(255, 183, 211, 0.28);
  text-align: center;
  transform: translate(-50%, -50%);
  animation: artifactToastPop 260ms cubic-bezier(.2, .8, .2, 1) both;
}

.result-toast strong {
  padding: 0 32px;
  color: #52649d;
  font-size: 1.35rem;
  line-height: 1.1;
}

.result-toast p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.4;
}

.toast-close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 2px solid rgba(111, 134, 200, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #52649d;
  font-weight: 900;
}

body[data-theme="dark"] .bag-hero,
body[data-theme="dark"] .bag-game-top,
body[data-theme="dark"] .bag-panel,
body[data-theme="dark"] .shop-panel,
body[data-theme="dark"] .backpack-panel {
  border-color: rgba(216, 220, 255, 0.36);
  background: rgba(31, 28, 45, 0.92);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.08), 6px 6px 0 rgba(0, 0, 0, 0.34);
}

body[data-theme="dark"] .bag-panel.prep-panel {
  background: transparent;
  box-shadow: none;
}

body[data-theme="dark"] .shop-item,
body[data-theme="dark"] .character-button,
body[data-theme="dark"] .fighter-card,
body[data-theme="dark"] .speed-button,
body[data-theme="dark"] .pouch-card,
body[data-theme="dark"] .bag-cell,
body[data-theme="dark"] .placed-item {
  color: #fff8ff;
  border-color: rgba(216, 220, 255, 0.28);
  background: rgba(216, 220, 255, 0.12);
}

body[data-theme="dark"] .pouch-grid,
body[data-theme="dark"] .battle-log,
body[data-theme="dark"] .item-inspector {
  color: #d8cdea;
  border-color: rgba(216, 220, 255, 0.28);
  background: rgba(216, 220, 255, 0.1);
}

body[data-theme="dark"] .item-effect,
body[data-theme="dark"] .selection-hint,
body[data-theme="dark"] .passive-text,
body[data-theme="dark"] .rotate-help,
body[data-theme="dark"] .battle-log,
body[data-theme="dark"] .pouch-card p {
  color: #d8cdea;
}

body[data-theme="dark"] .item-inspector strong,
body[data-theme="dark"] .item-total-line {
  color: #ffe49a;
}

@keyframes artifactToastPop {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 12px)) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@media (max-width: 850px) {
  .prep-layout {
    grid-template-columns: 1fr;
  }

  .shop-panel,
  .backpack-panel {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .bag-shell {
    width: min(100% - 20px, 1180px);
  }

  .bag-hero,
  .bag-panel-head,
  .bag-panel-head.compact,
  .bag-game-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .bag-stats,
  .bag-top-actions {
    width: 100%;
  }

  .bag-top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .character-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .pouch-grid {
    --cell: 42px;
  }

  .rotate-help {
    max-width: none;
    text-align: left;
  }
}
