.school-shop {
  --shop-padding: clamp(12px, 3.5vw, 24px);
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: var(--shop-padding);
  color: #eee6d2;
  text-shadow: 0 2px 4px #000, 0 0 8px #000;
  background: linear-gradient(#05070655, transparent 13%, transparent 75%, #05070645);
  container-type: inline-size;
}

.school-shop__header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: start; }
.school-shop__eyebrow { color: #d5b675; font: 700 10px/1.5 Arial, sans-serif; letter-spacing: .14em; }
.school-shop h1 { font-size: clamp(18px, 5cqw, 27px); margin: 3px 0 0; letter-spacing: -.04em; }
.school-shop__credit { margin: 0; padding: 7px 10px; text-align: right; font-size: 11px; background: #11150e38; border: 1px solid #c5b99524; }
.school-shop__credit strong { display: block; color: #eed09b; font-size: 21px; line-height: 1.35; }
.school-shop__actions { display: contents; }
.school-shop__status { position: absolute; top: calc(47% - 28px); left: var(--shop-padding); right: var(--shop-padding); margin: 0; color: #edcd98; font-size: 12px; text-align: center; }
.school-shop__status:empty { display: none; }
.school-shop.is-maintaining > .school-shop__header,
.school-shop.is-maintaining > .school-shop__actions { visibility: hidden; }
.school-shop button { font-family: inherit; cursor: pointer; touch-action: manipulation; }
.school-shop__actions button { position: absolute; left: 50%; transform: translateX(-50%); min-height: 48px; border: 1px solid #d5b67570; color: #fff2da; text-shadow: 0 2px 3px #000; background: #15191142; }
.school-shop__actions .school-shop__open { top: 47%; width: calc(100% - var(--shop-padding) * 2); max-width: 380px; padding: 12px; font-size: 22px; font-weight: 800; background: #a17a324a; border-color: #dec590a6; }
.school-shop__open span { display: block; margin-top: 4px; color: #e4d7bd; font-size: 12px; font-weight: 500; }
.school-shop__actions .school-shop__exit { bottom: var(--shop-padding); width: 150px; font-size: 14px; background: #0b100d30; border-color: #c5b99540; }
.school-shop button:focus-visible { outline: 2px solid #ffe0a1; outline-offset: 3px; }
.school-shop button:disabled { cursor: default; opacity: .5; }

.school-shop-dialog,
.school-shop-confirm {
  inset: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  color: #eee6d2;
  text-shadow: 0 1px 3px #000;
  border: 1px solid #c5b99585;
  background: #151b16dd;
  box-shadow: 0 18px 50px #0008;
  padding: 0;
  width: min(510px, calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 24px));
  max-width: none;
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px);
  margin: auto;
  overflow: hidden;
  border-radius: 10px;
}
.school-shop-dialog[open] { display: flex; flex-direction: column; animation: shop-dialog-in 160ms ease-out; }
.school-shop-dialog::backdrop { background: #04070538; }
.school-shop-confirm::backdrop { background: #0407056b; }
.school-shop-dialog__header { position: relative; padding: 14px 18px 10px; border-bottom: 1px solid #c5b99538; flex: none; }
.school-shop-dialog h2 { margin: 0; font-size: 23px; }
.school-shop-dialog__header > button { position: absolute; right: 10px; top: 10px; width: 44px; height: 44px; font-size: 27px; }
.school-shop-dialog__header p { margin: 5px 0 0; font-size: 13px; color: #cfc5ae; }
.school-shop-dialog [data-credit] { color: #eed09b; }
.school-shop-dialog button,
.school-shop-confirm button { min-height: 44px; border: 1px solid #bbae876b; border-radius: 5px; color: #eee6d2; background: #31382a85; font-family: inherit; font-weight: 700; font-size: 14px; line-height: 1.3; }
.school-shop-dialog__scroll { overflow: auto; overscroll-behavior: contain; padding: 10px 14px 14px; min-height: 0; scrollbar-width: thin; }
.school-shop-dialog__hint { margin: 0 0 10px; color: #d1c8b5; font-size: 12px; }
.school-shop-dialog__characters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.school-shop-dialog__characters button { min-width: 0; padding: 7px 3px; display: grid; justify-items: center; gap: 3px; background: #11181060; border-color: #a89f7a40; }
.school-shop-dialog__characters button[aria-pressed="true"] { border-color: #eac17e; box-shadow: inset 0 0 0 1px #eac17e; background: #90713b40; }
.school-shop-dialog__characters img { width: 44px; height: 44px; object-fit: cover; border-radius: 3px; }
.school-shop-dialog__characters strong { font-size: 12px; }
.school-shop-dialog__characters span { color: #d5b675; font-size: 10px; }
.school-shop-dialog__selected { margin: 16px 0 8px; font-size: 16px; }
.school-shop-dialog__upgrades { display: grid; gap: 7px; }
.school-shop-upgrade { display: grid; grid-template-columns: minmax(0, 1fr) 105px; gap: 10px; padding: 12px; background: #070d094f; border: 1px solid #b0a78730; border-radius: 6px; }
.school-shop-upgrade h4 { margin: 0 0 3px; font-size: 16px; }
.school-shop-upgrade p { margin: 0; color: #bfbcae; font-size: 12px; line-height: 1.45; }
.school-shop-upgrade .school-shop-upgrade__stats { margin-top: 5px; color: #e2c28d; white-space: pre-line; overflow-wrap: anywhere; }
.school-shop-upgrade__purchase { display: flex; flex-direction: column; justify-content: space-between; gap: 6px; font-size: 12px; text-align: center; }
.school-shop-upgrade progress { width: 100%; height: 5px; accent-color: #c3a464; }
.school-shop-upgrade .can-afford { color: #fff1cd; border-color: #cfb573; background: #a17a3270; }
.school-shop-dialog__footer { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 9px 14px 12px; background: #0d140bb3; border-top: 1px solid #c5b99538; }
.school-shop-dialog__status { grid-column: 1/-1; min-height: 17px; margin: 0; font-size: 12px; color: #edcd98; text-align: center; overflow-wrap: anywhere; }
.school-shop-confirm { width: min(380px, calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 32px)); padding: 22px; background: #171d16f5; overflow: auto; }
.school-shop-confirm h2 { margin: 0 0 12px; font-size: 20px; }
.school-shop-confirm p { font-size: 14px; line-height: 1.7; }
.school-shop-confirm > div { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.school-shop-confirm button { padding: 10px 22px; }
@media (hover: hover) {
  .school-shop button:not(:disabled):hover { border-color: #ffe0a1; background-color: #81663080; }
}
@media (max-width: 360px) {
  .school-shop-dialog__header { padding: 12px; }
  .school-shop-dialog__scroll { padding: 8px; }
  .school-shop-dialog__characters { gap: 5px; }
  .school-shop-upgrade { grid-template-columns: minmax(0, 1fr) 78px; padding: 9px; gap: 8px; }
  .school-shop-upgrade h4 { font-size: 14px; }
  .school-shop-upgrade p { font-size: 11px; }
  .school-shop-dialog__footer { padding: 8px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .school-shop-dialog { width: min(670px, calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 24px)); }
  .school-shop-dialog__header { padding: 7px 16px; }
  .school-shop-dialog__header .school-shop__eyebrow { display: none; }
  .school-shop-dialog__characters { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .school-shop-dialog__footer { padding: 5px 12px 8px; }
}
@keyframes shop-dialog-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .school-shop-dialog[open] { animation: none; } }
