/* Blue Wave Baseball - Bag v2 (bag.js). A medium dialog over the square,
   a world panel or the quick menu: your batter and gear slots on the left,
   compact tiles on the right, the picked item's actions underneath.
   Above the world panels (57) and the account chips (60), below the other
   dialogs (70+), which never open from inside the bag. */

.bag-layer {
  --bag-line: rgba(67, 177, 230, 0.42);
  --bag-inset: rgba(1, 29, 58, 0.66);
  --bag-dim: rgba(255, 255, 255, 0.66);
  --edge-common: #9fb2c2;
  --edge-rare: #4f9dff;
  --edge-epic: #a66cff;
  --edge-legendary: #ff8a28;
  --edge-skin: #20b4c8;
  position: fixed;
  inset: 0;
  z-index: 66;
  display: grid;
  place-items: center;
  padding: max(0.9rem, env(safe-area-inset-top)) max(0.9rem, env(safe-area-inset-right)) max(0.9rem, env(safe-area-inset-bottom)) max(0.9rem, env(safe-area-inset-left));
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #fffaf0;
}

.bag-layer[hidden] { display: none; }

.bag-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 18, 34, 0.55);
  animation: bag-dim 0.18s ease;
}

.bag-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(54rem, 100%);
  height: min(34rem, 100%);
  overflow: hidden;
  border: 1px solid rgba(243, 199, 68, 0.82);
  border-radius: 0.6rem;
  background: rgba(2, 42, 78, 0.97);
  box-shadow: 0 24px 80px rgba(0, 18, 42, 0.55);
  animation: bag-in 0.2s ease;
}

.bag-head {
  display: flex;
  flex: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid rgba(105, 193, 238, 0.36);
}

.bag-title { display: flex; align-items: center; gap: 0.5rem; }
.bag-title svg { width: 1.2rem; height: 1.2rem; fill: #f3c744; }
.bag-title strong { color: #f3c744; font: 800 1.15rem/1.1 "Playfair Display", Georgia, serif; }

.bag-cash {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  padding: 0.3rem 0.7rem 0.3rem 0.34rem;
  border: 1px solid rgba(243, 199, 68, 0.55);
  border-radius: 999px;
  background: var(--bag-inset);
  font-size: 0.82rem;
  font-weight: 800;
}

.bag-cash i {
  display: grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: #f3c744;
  color: #082b45;
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 900;
}

.bag-close {
  width: 2rem;
  height: 2rem;
  border: 1px solid rgba(255, 250, 240, 0.35);
  border-radius: 50%;
  background: rgba(1, 29, 58, 0.7);
  color: #fffaf0;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.bag-close:hover, .bag-close:focus-visible { border-color: #f3c744; }
.bag-close:focus-visible { outline: 2px solid #f3c744; outline-offset: 2px; }

.bag-body {
  display: grid;
  grid-template-columns: 15.5rem minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
}

.bag-loading { grid-column: 1 / -1; display: grid; place-items: center; gap: 0.6rem; min-height: 16rem; color: var(--bag-dim); }

/* ---- left: you --------------------------------------------------- */

.bag-me {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 0;
  padding: 0.85rem;
  border-right: 1px solid rgba(105, 193, 238, 0.24);
  background: linear-gradient(180deg, rgba(6, 74, 115, 0.35), rgba(1, 29, 58, 0.35));
  overflow-y: auto;
}

.bag-preview {
  position: relative;
  border: 1px solid var(--bag-line);
  border-radius: 0.5rem;
  background: radial-gradient(circle at 50% 38%, #1a5b87, #0c3a5d 62%);
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.bag-preview-pic {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
}

.bag-preview-pic canvas { display: block; width: 100%; height: 100%; }
.bag-preview-pic.is-3d { cursor: grab; }
.bag-preview.dragging .bag-preview-pic { cursor: grabbing; }

.bag-preview-art {
  display: block;
  width: 86%;
  height: 92%;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.45));
}

.bag-preview-sprite {
  display: block;
  width: 94%;
  aspect-ratio: 1;
  background-repeat: no-repeat;
  background-size: 300% 100%;
  background-position: 0 0;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.45));
}

.bag-preview-bat {
  position: absolute;
  right: 0.45rem;
  bottom: 0.45rem;
  width: 3.2rem;
  height: 3.2rem;
  padding: 0.2rem;
  border: 1px solid rgba(243, 199, 68, 0.6);
  border-radius: 0.4rem;
  background: rgba(1, 29, 58, 0.85);
}

.bag-preview-bat img { width: 100%; height: 100%; object-fit: contain; }

.bag-preview-note {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  margin: 0;
  padding: 0.35rem 0.5rem;
  background: linear-gradient(180deg, rgba(2, 20, 36, 0.75), transparent);
  color: var(--bag-dim);
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
}

.bag-preview-note b { color: #f3c744; }


.bag-slots {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.3rem;
}

.bag-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--bag-dim);
  font: 700 0.56rem/1.1 Inter, system-ui, sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.bag-slot-art {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid var(--edge, rgba(158, 216, 247, 0.55));
  border-radius: 0.4rem;
  background: var(--bag-inset);
}

.bag-slot-art img { width: 100%; height: 100%; object-fit: contain; }
.bag-slot-art svg { width: 58%; height: 58%; fill: rgba(158, 216, 247, 0.85); }
.bag-slot.later .bag-slot-art { border-style: dashed; border-color: rgba(158, 216, 247, 0.4); background: transparent; }
.bag-slot.later .bag-slot-art svg { fill: rgba(158, 216, 247, 0.35); }
.bag-slot em { color: rgba(243, 199, 68, 0.75); font-size: 0.5rem; font-style: normal; }
.bag-slot.picked .bag-slot-art { box-shadow: 0 0 0 2px #f3c744; }
.bag-slot:focus-visible { outline: none; }
.bag-slot:focus-visible .bag-slot-art { outline: 2px solid #f3c744; outline-offset: 2px; }

.bag-bonus {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.5rem;
  margin: 0;
  padding: 0.5rem 0.6rem;
  border: 1px solid rgba(243, 199, 68, 0.4);
  border-radius: 0.4rem;
  background: var(--bag-inset);
}

.bag-bonus small { color: var(--bag-dim); font-size: 0.62rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.bag-bonus em { flex-basis: 100%; color: var(--bag-dim); font-size: 0.62rem; font-style: normal; }
.bag-fx { display: inline-flex; gap: 0.5rem; font-size: 0.8rem; font-weight: 700; }
.bag-fx b { color: #f3c744; }

/* ---- right: the tiles -------------------------------------------- */

.bag-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.bag-tabs {
  display: flex;
  flex: none;
  gap: 0.35rem;
  padding: 0.7rem 0.9rem 0;
}

.bag-tabs button {
  padding: 0.4rem 0.95rem;
  border: 1px solid var(--bag-line);
  border-radius: 999px;
  background: var(--bag-inset);
  color: rgba(255, 255, 255, 0.78);
  font: 700 0.78rem/1 Inter, system-ui, sans-serif;
  cursor: pointer;
}

.bag-tabs button.active { background: #f3c744; border-color: #f3c744; color: #082b45; }
.bag-tabs button em { margin-left: 0.25rem; color: inherit; font-size: 0.6rem; font-style: normal; opacity: 0.75; text-transform: uppercase; }
.bag-tabs button:focus-visible { outline: 2px solid #f3c744; outline-offset: 2px; }

.bag-scroll {
  flex: 1 1 auto;
  min-height: 9rem;
  padding: 0.3rem 0.9rem 0.6rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.bag-group {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0.55rem 0 0.4rem;
  color: #9ed8f7;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.bag-group small { color: var(--bag-dim); font-size: 0.64rem; letter-spacing: 0.04em; text-transform: none; }
.bag-group small.full { color: #ffb4a6; }

.bag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 52px);
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bag-tile {
  position: relative;
  display: block;
  width: 52px;
  height: 52px;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--edge, var(--bag-line));
  border-radius: 0.4rem;
  background: radial-gradient(circle at 50% 35%, rgba(158, 216, 247, 0.22), rgba(1, 29, 58, 0.92) 72%);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.bag-tile img { display: block; width: 100%; height: 100%; object-fit: contain; }
.bag-tile-glove svg { width: 58%; height: 58%; margin: auto; display: block; fill: rgba(190, 150, 100, 0.95); }
.bag-detail-glove { display: flex; align-items: center; justify-content: center; }
.bag-detail-glove svg { width: 56%; height: 56%; fill: rgba(190, 150, 100, 0.95); }
.bag-tile img.outfit, .bag-detail-art img.outfit { object-fit: cover; object-position: 28% 30%; }
.bag-tile:hover { transform: translateY(-1px); }
.bag-tile.picked { box-shadow: 0 0 0 2px #f3c744, 0 0 12px rgba(243, 199, 68, 0.45); }
.bag-tile:focus-visible { outline: 2px solid #fffaf0; outline-offset: 2px; }

.edge-common { --edge: var(--edge-common); }
.edge-rare { --edge: var(--edge-rare); }
.edge-epic { --edge: var(--edge-epic); }
.edge-legendary { --edge: var(--edge-legendary); }
.edge-skin { --edge: var(--edge-skin); }
.edge-skin.skin-common { --edge: var(--edge-common); }
.edge-skin.skin-rare { --edge: var(--edge-rare); }
.edge-skin.skin-epic { --edge: var(--edge-epic); }
.edge-skin.skin-legendary { --edge: var(--edge-legendary); }

.bag-count,
.bag-worn,
.bag-listed {
  position: absolute;
  padding: 0.05rem 0.22rem;
  border-radius: 0.25rem;
  font-size: 0.56rem;
  font-weight: 900;
  line-height: 1.2;
}

.bag-count { right: 2px; bottom: 2px; background: rgba(2, 20, 36, 0.85); color: #fffaf0; }
.bag-worn { left: 2px; top: 2px; background: #298b68; color: #fff; }
.bag-listed { right: 2px; top: 2px; background: #e85f4b; color: #fff; }

.bag-note, .bag-empty { margin: 0.45rem 0; color: var(--bag-dim); font-size: 0.72rem; line-height: 1.4; }
.bag-note { padding: 0.45rem 0.6rem; border: 1px dashed rgba(243, 199, 68, 0.5); border-radius: 0.35rem; }

/* ---- the detail strip -------------------------------------------- */

.bag-detail {
  display: grid;
  flex: none;
  grid-template-columns: 3.9rem minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  margin: 0 0.9rem 0.9rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid rgba(243, 199, 68, 0.55);
  border-radius: 0.5rem;
  background: linear-gradient(135deg, rgba(6, 74, 115, 0.55), rgba(1, 29, 58, 0.85));
}

.bag-detail.empty { display: block; color: var(--bag-dim); font-size: 0.78rem; text-align: center; }
.bag-detail.empty p { margin: 0; }

.bag-detail-art {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid var(--edge, var(--bag-line));
  border-radius: 0.4rem;
  background: radial-gradient(circle at 50% 35%, rgba(158, 216, 247, 0.25), rgba(1, 29, 58, 0.9) 70%);
}

.bag-detail-art img { width: 100%; height: 100%; object-fit: contain; }
.bag-detail-art.later { border-style: dashed; border-color: rgba(158, 216, 247, 0.45); }
.bag-detail-art svg { width: 60%; height: 60%; fill: rgba(158, 216, 247, 0.5); }

.bag-detail-info { min-width: 0; }
.bag-detail-info h4 { margin: 0.25rem 0 0.15rem; font: 800 1rem/1.15 "Playfair Display", Georgia, serif; }
.bag-does { margin: 0; font-size: 0.76rem; line-height: 1.35; }
.bag-meta { margin: 0.2rem 0 0; color: var(--bag-dim); font-size: 0.68rem; line-height: 1.35; }
.bag-warn { margin: 0.2rem 0 0; color: #ffb4a6; font-size: 0.68rem; font-weight: 700; }

.bag-detail-act { display: flex; flex-direction: column; gap: 0.3rem; min-width: 8.5rem; }

.bag-btn,
.bag-sell {
  padding: 0.55rem 0.9rem;
  border-radius: 0.4rem;
  font: 900 0.8rem/1 Inter, system-ui, sans-serif;
  cursor: pointer;
}

.bag-btn { border: 0; background: #f3c744; color: #082b45; }
.bag-btn.is-worn { background: rgba(41, 139, 104, 0.9); color: #fff; }
.bag-btn:disabled:not(.is-worn) { background: rgba(255, 255, 255, 0.14); color: rgba(255, 255, 255, 0.6); }
.bag-btn:disabled { cursor: default; }
.bag-sell { border: 1px solid rgba(255, 180, 166, 0.7); background: transparent; color: #ffb4a6; }
.bag-sell.armed { background: #e85f4b; border-color: #e85f4b; color: #fff; }
.bag-sell:disabled { border-color: rgba(255, 255, 255, 0.2); color: rgba(255, 255, 255, 0.4); cursor: default; }
.bag-btn:focus-visible, .bag-sell:focus-visible { outline: 2px solid #fffaf0; outline-offset: 2px; }

/* ---- the Food tab (M4b fills it) --------------------------------- */

.bag-food { display: grid; place-items: center; }

.bag-soon {
  max-width: 24rem;
  padding: 1.2rem;
  text-align: center;
}

.bag-soon h4 { margin: 0.6rem 0 0.35rem; font: 800 1.05rem/1.2 "Playfair Display", Georgia, serif; color: #f3c744; }
.bag-soon p { margin: 0; color: var(--bag-dim); font-size: 0.78rem; line-height: 1.45; }

/* a pastechi, drawn in CSS: a golden half-moon with a crimped edge */
.bag-soon-art {
  display: inline-block;
  width: 4.2rem;
  height: 2.2rem;
  border-radius: 4.2rem 4.2rem 0.5rem 0.5rem;
  background: radial-gradient(circle at 50% 110%, #f7c56b, #e8a947 60%, #c98428);
  box-shadow: 0 0.25rem 0 #b87522, 0 0.6rem 1rem rgba(0, 0, 0, 0.35);
}

@keyframes bag-in { from { opacity: 0; transform: translateY(0.5rem) scale(0.99); } to { opacity: 1; transform: none; } }
@keyframes bag-dim { from { opacity: 0; } to { opacity: 1; } }

/* The quick menu's Team management: the Bag button where the Gear tab was. */
.manage-tabs .manage-bag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.manage-tabs .manage-bag svg { width: 0.95rem; height: 0.95rem; fill: currentColor; }

@media (max-width: 760px) {
  .bag-panel { height: auto; max-height: 100%; }
  /* A phone: the bag fills the screen. */
  body.hub-phone .bag-panel { width: 100%; height: 100%; max-height: 100%; border-radius: 0; border-inline: 0; }
  /* One column that scrolls as a whole: nothing in it may shrink to fit the
     panel's height (that made the parts overlap on a phone). */
  .bag-body { display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .bag-me, .bag-main { flex: none; min-height: auto; }
  .bag-tabs, .bag-detail, .bag-bonus, .bag-slots { flex-shrink: 0; }
  .bag-me { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid rgba(105, 193, 238, 0.24); overflow: visible; }
  .bag-preview { width: 9rem; }
  .bag-slots, .bag-bonus { flex: 1 1 12rem; }
  .bag-scroll { overflow: visible; }
  .bag-detail { grid-template-columns: 3.4rem minmax(0, 1fr); }
  .bag-detail-act { grid-column: 1 / -1; flex-direction: row; }
}

@media (prefers-reduced-motion: reduce) {
  .bag-panel, .bag-backdrop { animation: none; }
  .bag-tile { transition: none; }
}

/* ---- the Food tab (M4b: the pastechi) ------------------------------ */

.bag-layer { --edge-food: #e8a947; }
.edge-food { --edge: var(--edge-food); }
.shop-chip.chip-food { background: #e8a947; color: #2b1300; }

.bag-fed {
  margin: 0.55rem 0 0.2rem;
  padding: 0.5rem 0.65rem;
  border: 1px dashed rgba(232, 169, 71, 0.55);
  border-radius: 0.45rem;
  background: rgba(1, 29, 58, 0.55);
}

.bag-fed.on { border-style: solid; border-color: #e8a947; background: linear-gradient(90deg, rgba(232, 169, 71, 0.22), rgba(1, 29, 58, 0.6) 75%); }
.bag-fed small { display: block; color: #f3c744; font-size: 0.6rem; font-weight: 900; letter-spacing: 0.12em; text-transform: uppercase; }
.bag-fed p { margin: 0.15rem 0 0; font-size: 0.82rem; font-weight: 700; }
.bag-fed p.none { color: var(--bag-dim); font-weight: 600; }
.bag-fed em { display: block; color: var(--bag-dim); font-size: 0.66rem; font-style: normal; font-weight: 600; }

.bag-bonus.fed { border-color: #e8a947; }
.bag-bonus.fed small { color: #f3c744; }

/* The Food tab's strip is a single line: art, name + effect, Eat. */
.bag-detail.food { grid-template-columns: 3.2rem minmax(0, 1fr) auto; gap: 0.7rem; padding: 0.5rem 0.65rem; }
.bag-detail.food h4 { margin: 0.15rem 0 0.05rem; }

/* One bag for bats and outfits: the shared space line */
.bag-space { display: flex; align-items: baseline; gap: 0.5rem; margin: 0.1rem 0 0.35rem; color: var(--bag-dim); font-size: 0.72rem; letter-spacing: 0.04em; }
.bag-space b { color: #fff; font-size: 0.8rem; }
.bag-space small { font-size: 0.64rem; letter-spacing: 0.04em; }
.bag-space.full b { color: #ffb4a6; }
