:root {
  color-scheme: dark;
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
  background: #090a08;
  color: #d4b16a;
  -webkit-tap-highlight-color: transparent;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #090a08;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.landscape,
.portrait {
  min-height: 100vh;
  min-height: 100dvh;
}

.landscape {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.landscape-card {
  align-self: center;
  width: min(calc((100dvh - 62px) * 1.666667), calc(100vw - 24px), 1200px);
  aspect-ratio: 5 / 3;
  box-shadow: 0 16px 50px rgb(0 0 0 / 38%);
}

.landscape-card img,
.card-slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.icp {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 8px;
  color: #8f8b7e;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 12px;
  line-height: 1.5;
  text-decoration: none;
}

.icp:hover,
.icp:focus-visible {
  color: #d4b16a;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.icp:focus-visible,
.flip-control:focus-visible,
.page-dot:focus-visible,
.card-viewport:focus-visible {
  outline: 2px solid #d4b16a;
  outline-offset: 4px;
}

.portrait {
  display: none;
}

@media (orientation: portrait) {
  .landscape {
    display: none;
  }

  .portrait {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto auto;
    place-items: center;
    height: 100vh;
    height: 100dvh;
    padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .portrait-stage {
    display: grid;
    place-items: center;
    width: 100%;
    min-height: 0;
  }

  .card-viewport {
    display: flex;
    width: min(calc((100dvh - 142px) * 0.6), calc(100vw - 24px));
    max-width: 540px;
    aspect-ratio: 3 / 5;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    scrollbar-width: none;
    touch-action: pan-x;
    cursor: pointer;
    box-shadow: 0 14px 42px rgb(0 0 0 / 42%);
  }

  .card-viewport::-webkit-scrollbar {
    display: none;
  }

  .card-slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  .portrait-controls {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding-top: 10px;
  }

  .flip-control {
    min-width: 112px;
    min-height: 36px;
    padding: 7px 18px;
    border: 1px solid #75623c;
    border-radius: 2px;
    background: #11120f;
    color: #d4b16a;
    font-size: 14px;
    letter-spacing: 0.08em;
    cursor: pointer;
  }

  .flip-control:hover {
    border-color: #d4b16a;
    background: #181812;
  }

  .pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 18px;
    gap: 9px;
  }

  .page-dot {
    width: 18px;
    height: 18px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    position: relative;
  }

  .page-dot::after {
    content: "";
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    background: #59594f;
    transition: background-color 160ms ease, transform 160ms ease;
  }

  .page-dot.is-active::after {
    background: #d4b16a;
    transform: scale(1.35);
  }

  .page-status {
    min-width: 38px;
    margin-left: 3px;
    color: #8f8b7e;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card-viewport {
    scroll-behavior: auto;
  }

  .page-dot::after {
    transition: none;
  }
}
