:root {
  color-scheme: dark;
  --background: #050402;
  --foreground: #f8fafc;
  --gold: #d8ad55;
  --glass: rgba(12, 9, 6, 0.72);
  --border: rgba(255, 255, 255, 0.18);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--background);
}

body { color: var(--foreground); }

button { font: inherit; }

.display {
  position: relative;
  isolation: isolate;
  width: 100vw;
  height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(216, 173, 85, 0.1), transparent 48%),
    #050402;
  user-select: none;
}

.display:not(.is-ui-visible) { cursor: none; }

.ambient {
  position: absolute;
  inset: -5%;
  z-index: -1;
  background: center / cover no-repeat;
  filter: blur(54px) saturate(0.82) brightness(0.28);
  opacity: 0.8;
  transform: scale(1.08);
  transition: background-image 900ms ease, opacity 450ms ease;
}

.ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.slides,
.slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  overflow: hidden;
}

.slide {
  opacity: 0;
  transform: scale(1.018);
  transition: opacity 850ms ease, transform 1.15s cubic-bezier(.2,.75,.25,1);
  pointer-events: none;
}

.slide.is-active {
  z-index: 1;
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.slide img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  -webkit-user-drag: none;
  filter: drop-shadow(0 24px 60px rgba(0, 0, 0, 0.5));
}

.progress {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  transition: opacity 250ms ease;
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #9d6b22, #f0cf7b);
  box-shadow: 0 0 16px rgba(240, 207, 123, 0.65);
}

.progress span.is-running { animation: timer var(--slide-duration) linear forwards; }

@keyframes timer { to { width: 100%; } }

.controls {
  position: absolute;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--glass);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(18px);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.display.is-ui-visible .controls {
  opacity: 1;
  transform: translateY(0);
}

.counter {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 74px;
  padding: 0 10px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.counter span:first-child { color: #fff; font-weight: 700; }
.counter i { width: 18px; height: 1px; background: var(--gold); }

.icon-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: transparent;
  cursor: pointer;
  transition: color 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.icon-button:hover { color: #171009; background: var(--gold); }
.icon-button:active { transform: scale(0.92); }
.icon-button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.icon-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-button .play-icon { display: none; fill: currentColor; stroke: none; }
.icon-button.is-paused .pause-icon { display: none; }
.icon-button.is-paused .play-icon { display: block; }

.hint {
  position: absolute;
  left: 50%;
  bottom: max(32px, env(safe-area-inset-bottom));
  z-index: 4;
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.74);
  background: rgba(5, 4, 2, 0.68);
  font-size: 12px;
  letter-spacing: 0.06em;
  backdrop-filter: blur(12px);
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 220ms ease, transform 220ms ease;
  pointer-events: none;
}

.display.is-ui-visible .hint { opacity: 1; transform: translate(-50%, 0); }

@media (orientation: portrait) {
  .ambient { opacity: 0.35; }
  .slide img { width: 100vw; height: 100svh; }
}

@media (prefers-reduced-motion: reduce) {
  .slide,
  .ambient,
  .controls,
  .hint { transition-duration: 1ms; }
}
