:root {
  color-scheme: dark;
  --ink: #f7faf7;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #05090d;
  color: var(--ink);
  font-family: "Segoe UI", "Noto Sans TC", system-ui, sans-serif;
}

body.qte-test-page {
  display: block;
  padding: 0;
  margin: 0;
  min-height: 100vh;
}

.qte-noscript-msg {
  margin: 0;
  padding: 24px;
  max-width: 36rem;
  font: 600 16px system-ui, "Microsoft JhengHei", sans-serif;
  color: #f4f8ff;
  background: #0d100e;
  min-height: 100vh;
}

body.qte-active {
  padding: 0;
  display: block;
}

body.qte-active main {
  display: none;
}

.qte-test.hidden {
  display: none;
}

.qte-test {
  box-sizing: border-box;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #05090d;
  color: var(--ink);
}

.qte-test * {
  box-sizing: border-box;
}

body.qte-canvas-only {
  overflow: hidden;
  background: #05090d;
}

.qte-canvas-only .qte-test {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  padding: 0;
  overflow: hidden;
  background: #05090d;
}

.qte-full-canvas {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  image-rendering: pixelated;
}

.qte-win-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(4, 10, 18, 0.72);
  opacity: 0;
  transition: opacity 0.45s ease;
}

.qte-win-overlay.hidden {
  display: none;
}

.qte-win-overlay:not(.hidden) {
  display: flex;
}

.qte-win-overlay--visible {
  pointer-events: auto;
  opacity: 1;
}

.qte-win-ribbons {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.qte-win-ribbon {
  position: absolute;
  width: min(14vw, 110px);
  height: 4px;
  border-radius: 2px;
  top: -8%;
  left: 0;
  opacity: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 248, 220, 0),
    #fff8dc 12%,
    #ffe082 35%,
    #ffc107 55%,
    #ffb300 72%,
    #fff3c4 88%,
    rgba(255, 248, 220, 0)
  );
  box-shadow: 0 0 8px rgba(255, 200, 60, 0.35);
  animation: qteWinRibbonDrift 2.6s ease-out forwards;
}

@keyframes qteWinRibbonDrift {
  0% {
    transform: translate(0, 0) rotate(var(--rot, 12deg));
    opacity: 0;
  }

  8% {
    opacity: 0.92;
  }

  /* 接近畫面底部前仍清楚可見 */
  68% {
    opacity: 0.88;
  }

  /* 落到底部附近時快速淡出並完全消失 */
  88% {
    opacity: 0.25;
  }

  100% {
    transform: translate(var(--dx, 0), 108vh) rotate(calc(var(--rot, 12deg) + 28deg));
    opacity: 0;
    visibility: hidden;
  }
}

.qte-win-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 1.5rem 1.25rem 2rem;
  max-width: min(96vw, 520px);
}

.qte-win-sub {
  margin: 0 0 0.5rem;
  font: 800 clamp(1rem, 3.2vw, 1.35rem) system-ui, "Microsoft JhengHei", sans-serif;
  color: rgba(244, 248, 255, 0.92);
  letter-spacing: 0.06em;
  opacity: 0;
  transform: translateY(10px);
}

.qte-win-overlay--visible .qte-win-sub {
  animation: qteWinFadeUp 0.55s ease 0.12s forwards;
}

.qte-win-title {
  margin: 0;
  font: 900 clamp(2.4rem, 10vw, 4.25rem) system-ui, "Microsoft JhengHei", sans-serif;
  line-height: 1.12;
  letter-spacing: 0.04em;
  background: linear-gradient(
    118deg,
    #fffef5 0%,
    #fff3bf 14%,
    #ffd54a 32%,
    #ffb300 52%,
    #ffc947 68%,
    #ffe9a8 86%,
    #fffef0 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 28px rgba(255, 180, 40, 0.55));
  opacity: 0;
  transform: scale(0.88);
}

.qte-win-overlay--visible .qte-win-title {
  animation: qteWinTitlePop 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.08s forwards;
}

@keyframes qteWinFadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes qteWinTitlePop {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.qte-win-replay {
  margin: 2.25rem auto 0;
  padding: 0.65rem 2.4rem;
  font: 800 1.05rem system-ui, "Microsoft JhengHei", sans-serif;
  color: #0a1624;
  cursor: pointer;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #fff8e6, #ffd54a 45%, #e6a000);
  box-shadow:
    0 4px 0 #a67400,
    0 8px 28px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: filter 0.15s ease, transform 0.12s ease;
}

.qte-win-replay:hover {
  filter: brightness(1.06);
}

.qte-win-replay:active {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 #a67400,
    0 4px 16px rgba(0, 0, 0, 0.35);
}

.qte-win-overlay--replay-ready .qte-win-replay {
  animation: qteWinReplayIn 0.55s ease forwards;
  pointer-events: auto;
}

@keyframes qteWinReplayIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
