/* Tiny World cart: isolated styles. */

#twCartRoot[hidden],
#twCartRoot [hidden] {
  display: none !important;
}

.tw-cart-toggle {
  position: fixed;
  left: max(14px, env(safe-area-inset-left));
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 54px;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: #5c4a9e;
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(36, 24, 72, 0.3);
}

.tw-cart-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 25px;
  height: 25px;
  padding: 0 5px;
  border-radius: 999px;
  background: #fff;
  color: #5c4a9e;
  font-size: 0.85rem;
}

.tw-cart-toast {
  position: fixed;
  left: max(14px, env(safe-area-inset-left));
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 1101;
  max-width: min(340px, calc(100vw - 28px));
  padding: 12px 16px;
  border-radius: 12px;
  background: #292236;
  color: #fff;
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.2);
}

.tw-cart-dialog {
  box-sizing: border-box;
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: #fff;
  color: #2a2737;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.3);
  overflow: auto;
  overscroll-behavior: contain;
}

.tw-cart-dialog::backdrop {
  background: rgba(20, 15, 32, 0.55);
}

.tw-cart-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid #eee9f5;
}

.tw-cart-heading h2 {
  margin: 0;
  font-size: 1.3rem;
}

.tw-cart-close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: #f3f0f8;
  color: #2a2737;
  font-size: 1.7rem;
  cursor: pointer;
}

.tw-cart-status {
  margin: 0;
  padding: 0 16px;
  color: #b42318;
  font-size: 0.9rem;
}

.tw-cart-status:not(:empty) {
  padding-top: 12px;
  padding-bottom: 8px;
}

.tw-cart-items {
  padding: 0 16px;
}

.tw-cart-item {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid #eee9f5;
}

.tw-cart-item-image {
  width: 68px;
  height: 82px;
  object-fit: contain;
  border-radius: 8px;
  background: #f7f5fb;
}

.tw-cart-item-name {
  margin: 0 0 5px;
  font-size: 0.95rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.tw-cart-item-meta,
.tw-cart-note {
  margin: 4px 0;
  color: #726a7e;
  font-size: 0.84rem;
  line-height: 1.5;
}

.tw-cart-item-price {
  margin: 8px 0;
  font-weight: 800;
}

.tw-cart-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.tw-cart-control {
  min-width: 40px;
  min-height: 40px;
  padding: 5px 10px;
  border: 1px solid #d8d0e9;
  border-radius: 8px;
  background: #fff;
  color: #5c4a9e;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.tw-cart-remove {
  color: #b42318;
  font-size: 0.82rem;
}

.tw-cart-gift {
  margin-top: 10px;
  padding: 9px;
  border-radius: 8px;
  background: #faf7ff;
}

.tw-cart-gift p {
  margin: 0 0 6px;
  font-size: 0.85rem;
}

.tw-cart-item-error {
  margin: 8px 0;
  color: #b42318;
  font-size: 0.85rem;
}

.tw-cart-empty {
  padding: 24px 0;
  text-align: center;
  color: #726a7e;
}

.tw-cart-bottom {
  padding: 16px;
}

.tw-cart-total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 1.05rem;
}

.tw-cart-bottom .btn {
  margin-top: 10px;
}

.tw-cart-add {
  background: #5c4a9e;
  color: #fff;
}

.tw-cart-dialog button:disabled,
.tw-cart-add:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.tw-cart-toggle:focus-visible,
.tw-cart-dialog button:focus-visible,
.tw-cart-add:focus-visible {
  outline: 3px solid #b9a6ec;
  outline-offset: 3px;
}

@media (prefers-reduced-motion: no-preference) {
  .tw-cart-toggle.tw-cart-added {
    animation: tw-cart-bounce 0.45s ease;
  }
}

@keyframes tw-cart-bounce {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.12); }
  70% { transform: scale(0.97); }
}

@media (max-width: 560px) {
  .tw-cart-toggle {
    min-height: 48px;
    padding: 10px 14px;
  }

  .tw-cart-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 24px);
  }
}