@font-face {
  font-family: Chen;
  src: url('/fonts/ChenYuluoyan-Thin.woff2');
}

@font-face {
  font-family: Satsuki;
  src: url('/fonts/SatsukiGendaiMincho-M.woff2');
}

.card-preview-dialog {
  margin: auto;
  width: min(100vw, 760px);
  max-width: calc(100vw - 20px);
  max-height: calc(100dvh - 20px);
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  overflow: visible;
}

.card-preview-dialog::backdrop {
  background: rgba(26, 31, 28, .58);
}

.card-preview-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-height: calc(100dvh - 20px);
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
}

.card-preview-header,
.card-preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(100%, 500px);
}

.card-preview-header h2 {
  margin: 0;
  color: #fff;
  font: normal 20px/1.3 -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans TC', sans-serif;
}

.card-preview-close {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .75);
  border-radius: 50%;
  color: #fff;
  background: transparent;
  font-size: 27px;
  line-height: 1;
  cursor: pointer;
}

.card-preview-close:focus-visible,
.card-preview-card:focus-visible,
.card-preview-edit:focus-visible,
.card-preview-retry:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

.card-preview-status {
  width: min(100%, 500px);
  min-height: 22px;
  margin: 0;
  color: rgba(255, 255, 255, .92);
  text-align: center;
}

.card-preview-stage {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 0;
  perspective: 1100px;
}

.card-preview-card {
  position: relative;
  display: block;
  width: min(calc(100vw - 32px), calc(70dvh * 675 / 1181), calc((100dvh - 170px) * 675 / 1181));
  height: auto;
  max-width: calc(100vw - 32px);
  aspect-ratio: 675 / 1181;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  transform-style: preserve-3d;
}

.card-preview-outer,
.card-preview-inner,
.card-preview-face {
  position: absolute;
  inset: 0;
  display: block;
}

.card-preview-outer {
  transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transform-style: preserve-3d;
  transition: transform 90ms linear;
}

.card-preview-inner {
  transform-style: preserve-3d;
}

.card-preview-face {
  overflow: hidden;
  border-radius: 8px;
  backface-visibility: hidden;
  background: #fff;
  outline: 1px solid rgba(100, 113, 99, .28);
}

.card-preview-front {
  transform: rotateY(0deg);
}

.card-preview-back {
  transform: rotateY(180deg);
}

.card-preview-face canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.card-preview-effect {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at var(--light-x, 35%) var(--light-y, 35%), rgba(253, 224, 214, .82), rgba(217, 229, 240, .72) 22%, rgba(223, 236, 213, .54) 40%, transparent 68%);
  mix-blend-mode: multiply;
  opacity: .30;
  mask-repeat: no-repeat;
  mask-mode: alpha;
  -webkit-mask-repeat: no-repeat;
}

.card-preview-card.is-tossing .card-preview-outer {
  transition: none;
}

.card-preview-footer {
  justify-content: center;
  min-height: 44px;
}

.card-preview-edit,
.card-preview-retry {
  min-height: 42px;
  padding: 9px 18px;
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 999px;
  color: #fff;
  background: transparent;
  font: inherit;
  line-height: 22px;
  text-decoration: none;
  cursor: pointer;
}

.card-preview-edit:hover,
.card-preview-retry:hover,
.card-preview-close:hover {
  background: rgba(255, 255, 255, .12);
}

@media (prefers-reduced-motion: reduce) {
  .card-preview-outer {
    transition: none;
  }
}

@media (max-width: 600px) {
  .card-preview-dialog {
    max-width: 100vw;
    max-height: 100dvh;
  }

  .card-preview-shell {
    max-height: 100dvh;
    gap: 6px;
  }

  .card-preview-card {
    width: min(calc(100vw - 24px), calc(70dvh * 675 / 1181), calc((100dvh - 150px) * 675 / 1181));
  }

  .card-preview-header,
  .card-preview-footer,
  .card-preview-status {
    width: min(100%, 500px);
  }
}
