.shop-dialog {
  width: min(980px, calc(100vw - 24px));
  max-height: min(900px, calc(100svh - 24px));
  overflow: auto;
}
.shop-dialog > header { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; padding-right: 64px; }
.shop-dialog > header h2, .shop-dialog > header p { margin: 0; }
.shop-dialog > header strong { margin-left: auto; }
.shop-tabs { display: flex; gap: 8px; margin: 18px 0 12px; }
.shop-tabs button {
  border: 7px solid transparent !important;
  border-image: url('../skins/illustrated-fleet/button-pen-frame-clean-blue.svg') 22 30 22 22 / 9px 11px 9px 9px / 0 stretch !important;
  background-color: #fffaf0 !important;
  background-image: url('../skins/illustrated-fleet/button-pen-wash-blue.svg') !important;
  background-position: center !important;
  background-size: cover !important;
  background-repeat: no-repeat !important;
  box-shadow: none !important;
}
.shop-tabs button:first-child { min-width: 92px; padding-inline: 20px; }
.shop-tabs [aria-pressed="true"] { background: #173e80; color: #fff; }
.shop-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 14px; }
.shop-card {
  --rarity-glow: #29468e55;
  display: grid;
  grid-template-rows: auto 112px auto;
  gap: 8px;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 9px;
  border: 2px solid #29468e;
  background: #fffaf0;
  box-shadow: 3px 4px 0 #29468e28;
  transform: translateZ(0);
  transition: transform .28s cubic-bezier(.2,.8,.2,1), box-shadow .28s ease, filter .28s ease;
}
.shop-card.equipped { border-color: #258052; box-shadow: 0 0 0 3px #25805233; }
.shop-card.rarity-rare {
  --rarity-glow: #d53b4770;
  border-color: #b52f36;
  box-shadow: 3px 4px 0 #b52f362b;
}
.shop-card.rarity-rare small { color: #b52f36; }
.shop-card button {
  border: 7px solid transparent !important;
  border-image: url('../skins/illustrated-fleet/button-pen-frame-clean-blue.svg') 22 30 22 22 / 9px 11px 9px 9px / 0 stretch !important;
  background-color: #fffaf0 !important;
  background-image: url('../skins/illustrated-fleet/button-pen-wash-blue.svg') !important;
  background-position: center !important;
  background-size: cover !important;
  background-repeat: no-repeat !important;
  color: #29468e !important;
  box-shadow: none !important;
}
.shop-card.rarity-rare button {
  color: #b52f36;
  border-image-source: url('../skins/illustrated-fleet/button-pen-frame-clean-red.svg') !important;
  background-image: url('../skins/illustrated-fleet/button-pen-wash-red.svg') !important;
  color: #b52f36 !important;
}
.shop-card.rarity-rare.equipped { border-color: #258052; box-shadow: 0 0 0 3px #25805233; }
.shop-card.rarity-epic {
  --rarity-glow: #efb51f80;
  border-color: #c38a16;
  background: #fff9df;
  box-shadow: 3px 4px 0 #c38a1633;
}
.shop-card.rarity-epic small { color: #9b6900; }
.shop-card.rarity-epic button {
  border-image-source: url('../skins/illustrated-fleet/button-pen-frame-clean-orange.svg') !important;
  background-image: url('../skins/illustrated-fleet/button-pen-wash-orange.svg') !important;
  color: #9b6900 !important;
}
.shop-card.rarity-epic.equipped { border-color: #258052; box-shadow: 0 0 0 3px #25805233; }
.shop-card img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  object-position: center;
  background: #fffaf0;
  border-radius: 4px;
  transition: transform .45s cubic-bezier(.2,.8,.2,1), filter .35s ease;
}
.shop-card h3 { margin: 0; font-size: 18px; line-height: 1.1; }
.shop-card-copy {
  display: grid;
  grid-template-rows: minmax(0, 3.3em) 1.25em 1.25em;
  align-content: start;
  gap: 4px;
  min-width: 0;
}
.shop-card-copy h3 {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.shop-card-copy > span {
  overflow: hidden;
  color: #29468e;
  font-size: 13px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shop-card small { text-transform: uppercase; color: #73508e; }
.shop-card button { min-height: 44px; }
.shop-empty { grid-column: 1 / -1; text-align: center; padding: 40px; }
.shop-dialog > .player-error { margin: 12px 0 0; }
#shop-close {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 2;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  line-height: 1;
  font-family: Arial, sans-serif;
  font-size: 27px;
  border: 7px solid transparent !important;
  border-image: url('../skins/illustrated-fleet/button-pen-frame-clean-red.svg') 22 30 22 22 / 9px / 0 stretch !important;
  background-color: #fffaf0 !important;
  background-image: url('../skins/illustrated-fleet/button-pen-wash-red.svg') !important;
  background-position: center !important;
  background-size: cover !important;
  background-repeat: no-repeat !important;
  box-shadow: none !important;
}
.shop-confirm {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(7, 18, 28, .7);
  backdrop-filter: blur(3px);
}
.shop-confirm[hidden] { display: none; }
.shop-confirm > section {
  width: min(520px, 100%);
  padding: 28px;
  text-align: center;
  color: #173e80;
  background: #fffaf0;
  border: 8px solid transparent;
  border-image: url('../skins/illustrated-fleet/button-pen-frame-orange.svg') 22 30 22 22 / 10px / 0 stretch;
  box-shadow: 0 20px 60px #0008;
}
.shop-confirm-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 10px;
  border: 3px double #c38a16;
  border-radius: 50%;
  color: #9b6900;
  background: #fff1a8;
  font: 700 36px/1 Arial, sans-serif;
}
.shop-confirm h3 { margin: 0 0 12px; }
.shop-confirm p { margin: 0 auto 22px; max-width: 420px; line-height: 1.4; }
.shop-confirm section > div:last-child { display: flex; justify-content: center; gap: 12px; }
.shop-confirm section > div:last-child button { min-width: 150px; }
.shop-confirm [data-shop-confirm-accept] { color: #9b6900; border-color: #c38a16; }
@media (max-width: 480px) {
  .shop-confirm > section { padding: 22px 16px; }
  .shop-confirm section > div:last-child { flex-direction: column-reverse; }
  .shop-confirm section > div:last-child button { width: 100%; }
}
@media (hover: hover) and (pointer: fine) {
  .shop-card::after {
    content: "";
    position: absolute;
    z-index: 3;
    inset: -45% -70%;
    pointer-events: none;
    background: linear-gradient(108deg, transparent 38%, rgba(255,255,255,.08) 45%, rgba(255,255,255,.72) 50%, rgba(255,255,255,.12) 55%, transparent 62%);
    transform: translateX(-65%) rotate(-7deg);
    opacity: 0;
  }
  .shop-card:hover {
    z-index: 2;
    transform: perspective(900px) translateY(-8px) rotateX(1.5deg) scale(1.018);
    box-shadow: 0 0 0 2px var(--rarity-glow), 0 11px 0 -5px var(--rarity-glow), 0 22px 38px -17px var(--rarity-glow);
    filter: saturate(1.08);
  }
  .shop-card:hover::after { opacity: 1; animation: shop-card-shine .85s cubic-bezier(.2,.65,.2,1) both; }
  .shop-card:hover img { transform: scale(1.035); filter: contrast(1.03) saturate(1.07); }
  .shop-card:hover h3 { text-shadow: 0 2px 12px var(--rarity-glow); }
  .shop-card:focus-within { box-shadow: 0 0 0 3px var(--rarity-glow), 0 16px 32px -18px var(--rarity-glow); }
}
@keyframes shop-card-shine {
  from { transform: translateX(-65%) rotate(-7deg); }
  to { transform: translateX(65%) rotate(-7deg); }
}
@media (prefers-reduced-motion: reduce) {
  .shop-card, .shop-card img { transition: none; }
  .shop-card:hover, .shop-card:hover img { transform: none; }
  .shop-card:hover::after { animation: none; opacity: 0; }
}
@media (max-width: 900px) {
  .shop-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 650px) {
  .shop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .shop-card h3 { font-size: 15px; }
  .shop-card { grid-template-rows: auto 98px auto; }
  .shop-card-copy > span { font-size: 11px; }
  .shop-card button { font-size: 13px; padding: 7px 4px; }
  .shop-dialog { padding: 18px 14px; }
  .shop-dialog > header { padding-right: 58px; }
  .shop-dialog > header strong { margin-left: 0; width: 100%; }
  #shop-close { top: 12px; right: 12px; width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
}
@media (max-width: 390px) {
  .shop-grid { grid-template-columns: minmax(0, 1fr); }
}
