@font-face {
  font-family: "SweiSans";
  src: url("../assets/fonts/SweiSansCJKtc-Regular.ttf") format("truetype");
  font-weight: 400;
}
@font-face {
  font-family: "SweiSans";
  src: url("../assets/fonts/SweiSansCJKtc-Medium.ttf") format("truetype");
  font-weight: 500;
}

* { box-sizing: border-box; }
html, body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  font-family: "SweiSans", sans-serif;
  overflow: hidden;
  background: #ffffff;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; }
img { -webkit-user-drag: none; user-select: none; }

:root {
  --app-height: 100svh;
  --app-safe-bottom: env(safe-area-inset-bottom, 0px);
}

.app { position: relative; width: 100vw; min-height: var(--app-height); }
.screen { display: none; position: relative; width: 100vw; height: var(--app-height); overflow: hidden; }
.screen.is-active { display: block; }

.screen-loading { display: none; align-items: center; justify-content: center; background: #fff; color: #333; font-size: 20px; }
.screen-loading.is-active { display: flex; }

/* Home keeps the approved visual direction. */
.screen-home { background: #bddb3f; }
.home-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.home-start-button { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); border: 0; padding: 0; background: transparent; cursor: pointer; z-index: 10; }
.home-image { display: block; height: 112vh; max-height: none; width: auto; transition: transform 180ms ease, opacity 400ms ease; }
.home-start-button:active .home-image { transform: scale(0.98); }
@media (hover: hover) and (pointer: fine) { .home-start-button:hover .home-image { transform: scale(1.02); } }
@media (max-width: 767px) {
  .home-start-button { top: 50%; }
  .home-image { width: 257vw; max-width: none; height: auto; }
}

/* Shared fixed-stage screens */
.screen-question,
.screen-answer { background: #bddb3f; }
.fixed-stage {
  position: relative;
  overflow: hidden;
  background: #bddb3f;
  transform-origin: top center;
}
.question-layer-wrap { position: absolute; inset: 0; width: 100%; height: 100%; }
.question-layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.question-bg { z-index: 1; }
.question-logo { z-index: 2; }
.question-board { z-index: 3; }
.question-ground { z-index: 4; }
.question-rat { z-index: 5; }
.question-bottom-dots { position: absolute; z-index: 6; pointer-events: none; }
.question-progress { position: absolute; z-index: 20; height: auto; pointer-events: none; }
.question-text { position: absolute; z-index: 30; color: #333333; font-weight: 400; letter-spacing: 0; white-space: normal; word-break: break-all; overflow-wrap: anywhere; overflow: hidden; }
.question-answer-row { position: absolute; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.answer-button { border: 0; padding: 0; margin: 0; background: transparent; cursor: pointer; transition: transform 150ms ease; }
.answer-button img { display: block; height: auto; }
.answer-button.is-locked { pointer-events: none; }
.answer-button:active { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) { .answer-button:hover { transform: scale(1.02); } }

/* Desktop question layout, kept close to the current approved desktop values. */
@media (min-width: 768px) {
  .fixed-stage { width: 100vw; height: 100svh; }
  .screen-question .question-progress { top: calc(13.5% - 35px); left: 50%; transform: translateX(-50%); width: min(25.3vw, 424px); }
  .screen-question .question-board { transform: translateY(98px) scale(1.50, 1.43); transform-origin: center center; }
  .screen-question .question-ground { transform: scale(0.84); transform-origin: center bottom; }
  .screen-question .question-bottom-dots {
    left: 0;
    bottom: 0;
    width: 100%;
    height: 160px;
    max-width: none;
    object-fit: cover;
    object-position: bottom center;
    transform: none;
  }
  .screen-question .question-rat { transform: translateY(70px) scale(0.87); transform-origin: center center; }
  .screen-question .question-text {
    top: 19.8%;
    left: 50%;
    transform: translateX(-50%);
    width: 54%;
    max-width: 760px;
    height: 285px;
    min-height: 285px;
    padding-left: 14%;
    padding-right: calc(12% + 12px);
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    text-align: left;
    font-size: 30px;
    line-height: 1.15;
  }
  .screen-question .question-answer-row { left: 50%; bottom: 5.6%; transform: translateX(-50%); gap: 5px; }
  .screen-question .answer-button img { width: min(22.2vw, 433px); max-width: 433px; }
  .screen-question #answer-false-button { transform: translateY(36px) translateX(8px); }
  .screen-question #answer-true-button { margin: -5px; }
}

/* Mobile fixed stage based on 430 × 932 iPhone 17-class master layout. */
/* clean-v2-a3: mobile progress preserves aspect ratio; board/text/ground/buttons moved up; bottom dots enlarged. */
@media (max-width: 767px) {
  .screen-question,
  .screen-answer {
    display: none;
    align-items: flex-start;
    justify-content: center;
    min-height: var(--app-height);
    height: var(--app-height);
    padding-bottom: var(--app-safe-bottom);
  }
  .screen-question.is-active,
  .screen-answer.is-active { display: flex; }

  .screen-answer .fixed-stage { overflow: visible; }

  .fixed-stage {
    width: 430px;
    height: 932px;
    flex: 0 0 auto;
    transform: scale(var(--stage-scale, 1));
  }

  .screen-question .fixed-stage { overflow: visible; }

  /* clean-v2-b5: only these three decorative question layers bleed horizontally.
     The element boxes are widened while object-fit remains cover, so the source images keep their aspect ratio. */
  .screen-question .question-bg {
    left: 50%;
    right: auto;
    width: var(--stage-bleed-width, 430px);
    height: 100%;
    max-width: none;
    transform: translateX(-50%);
    object-fit: cover;
    object-position: center center;
  }

  /* Mobile Question Screen only: restore a full-width 430 × 932 stage without changing desktop. */
  .screen-question .question-progress {
    top: 90px;
    left: 50%;
    width: 82%;
    height: auto;
    transform: translateX(-50%);
  }

  .screen-question .question-board {
    transform: translateY(10px) scale(1.064, 1.04);
    transform-origin: center center;
  }

  .screen-question .question-ground {
    left: 50%;
    right: auto;
    width: var(--stage-bleed-width, 430px);
    height: 100%;
    max-width: none;
    transform: translateX(-50%) translateY(18px) scaleX(1.20) scaleY(1.40);
    transform-origin: center;
    object-fit: cover;
    object-position: center center;
  }

  .screen-question .question-rat {
    transform: translateY(5px);
    transform-origin: center center;
  }

  .screen-question .question-text {
    top: 178px;
    left: 50%;
    transform: translateX(-50%);
    width: 347px;
    height: 250px;
    min-height: 250px;
    padding-left: calc(12% - 10px);
    padding-right: calc(10% - 10px);
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    text-align: left;
    font-size: 28px;
    line-height: 1.18;
    letter-spacing: 0.5px;
  }

  .screen-question .question-answer-row {
    left: 50%;
    bottom: 96px;
    transform: translateX(-50%);
    gap: 5px;
  }

  .screen-question .answer-button img {
    width: 430px;
    max-width: none;
    transform: scale(0.75);
  }

  .screen-question #answer-false-button {
    transform: translateX(10px) translateY(75px);
  }

  .screen-question #answer-true-button {
    transform: translateX(4px) translateY(15px);
  }

  .screen-question .question-bottom-dots {
    left: 50%;
    bottom: 0;
    width: var(--stage-bleed-width, 430px);
    height: 400px;
    max-width: none;
    object-fit: cover;
    object-position: bottom center;
    transform: translateX(-50%) scale(2.16);
    transform-origin: center bottom;
  }
}


/* clean-v2-b6: iPad / tablet portrait uses the same fixed 430 × 932 stage logic as phone portrait.
   This prevents the desktop 16:9 layer composition from over-scaling vertically on 820–1024px portrait screens. */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  .screen-question,
  .screen-answer {
    display: none;
    align-items: flex-start;
    justify-content: center;
    min-height: var(--app-height);
    height: var(--app-height);
    padding-bottom: var(--app-safe-bottom);
  }
  .screen-question.is-active,
  .screen-answer.is-active { display: flex; }

  .screen-answer .fixed-stage { overflow: visible; }

  .fixed-stage {
    width: 430px;
    height: 932px;
    flex: 0 0 auto;
    transform: scale(var(--stage-scale, 1));
  }

  .screen-question .fixed-stage { overflow: visible; }

  .screen-question .question-bg {
    left: 50%;
    right: auto;
    width: var(--stage-bleed-width, 430px);
    height: 100%;
    max-width: none;
    transform: translateX(-50%);
    object-fit: cover;
    object-position: center center;
  }

  .screen-question .question-progress {
    top: 90px;
    left: 50%;
    width: 82%;
    height: auto;
    transform: translateX(-50%);
  }

  .screen-question .question-board {
    transform: translateY(10px) scale(1.064, 1.04);
    transform-origin: center center;
  }

  .screen-question .question-ground {
    left: 50%;
    right: auto;
    width: var(--stage-bleed-width, 430px);
    height: 100%;
    max-width: none;
    transform: translateX(-50%) translateY(18px) scaleX(1.20) scaleY(1.40);
    transform-origin: center;
    object-fit: cover;
    object-position: center center;
  }

  .screen-question .question-rat {
    transform: translateY(5px);
    transform-origin: center center;
  }

  .screen-question .question-text {
    top: 178px;
    left: 50%;
    transform: translateX(-50%);
    width: 347px;
    height: 250px;
    min-height: 250px;
    padding-left: calc(12% - 10px);
    padding-right: calc(10% - 10px);
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    text-align: left;
    font-size: 28px;
    line-height: 1.18;
    letter-spacing: 0.5px;
  }

  .screen-question .question-answer-row {
    left: 50%;
    bottom: 96px;
    transform: translateX(-50%);
    gap: 5px;
  }

  .screen-question .answer-button img {
    width: 430px;
    max-width: none;
    transform: scale(0.75);
  }

  .screen-question #answer-false-button {
    transform: translateX(10px) translateY(75px);
  }

  .screen-question #answer-true-button {
    transform: translateX(4px) translateY(15px);
  }

  .screen-question .question-bottom-dots {
    left: 50%;
    bottom: 0;
    width: var(--stage-bleed-width, 430px);
    height: 400px;
    max-width: none;
    object-fit: cover;
    object-position: bottom center;
    transform: translateX(-50%) scale(2.16);
    transform-origin: center bottom;
  }
}

/* Answer reveal */
.answer-overlay { position: absolute; top: 0; left: 50%; right: auto; bottom: auto; width: var(--answer-overlay-cover-width, 100%); height: var(--answer-overlay-cover-height, 100%); transform: translateX(-50%); z-index: 10; opacity: 0.95; pointer-events: none; }
.answer-overlay.is-true { background: #767f2f; }
.answer-overlay.is-false { background: #f57979; }
.answer-content { position: relative; z-index: 30; width: 100%; height: 100%; }
.answer-result-icon { position: absolute; pointer-events: none; }
.answer-result-icon[src=""] { display: none; }
.answer-heading { position: absolute; margin: 0; color: #fff; font-weight: 700; line-height: 1.1; text-align: center; }
.answer-heading:empty { display: none; }
.answer-explanation { position: absolute; margin: 0; color: #fff; font-weight: 400; text-align: left; overflow-y: auto; overflow-x: hidden; white-space: pre-line; -webkit-overflow-scrolling: touch; }
.answer-explanation:empty { display: none; }
.answer-next-button { position: absolute; border: 0; padding: 0; background: transparent; cursor: pointer; transition: transform 150ms ease; }
.answer-next-button img { display: block; height: auto; }
.answer-next-button img[src=""] { display: none; }
.answer-next-button:active { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) { .answer-next-button:hover { transform: scale(1.02); } }

@media (min-width: 768px) {
  .answer-content { padding-top: calc(11vh - 20px); display: flex; flex-direction: column; align-items: center; }
  .answer-result-icon { position: static; width: min(22vw, 300px); }
  .answer-heading { position: static; margin: calc(3vh - 20px) 0 1.2vh; font-size: 44px; }
  .answer-explanation { position: static; width: 80%; max-width: 980px; max-height: 38vh; font-size: 44px; line-height: 1.45; }
  .answer-next-button { position: static; margin-top: auto; margin-bottom: 7vh; }
  .answer-next-button img { width: min(20.5vw, 338px); }
}

@media (max-width: 767px) {
  .screen-answer .question-layer-wrap { opacity: 0.28; }

  /* clean-v2-b9: answer reveal content group moved down on phone portrait;
     Next/Result button size and position are intentionally unchanged. */
  .answer-result-icon {
    top: 140px;
    left: 50%;
    width: 96px;
    transform: translateX(-50%);
  }
  .answer-heading {
    top: 254px;
    left: 50%;
    width: 330px;
    transform: translateX(-50%);
    font-size: 32px;
  }
  .answer-explanation {
    top: 302px;
    left: 50%;
    width: 362px;
    max-height: 257px;
    transform: translateX(-50%);
    padding-left: 20px;
    padding-right: 20px;
    font-size: 28px;
    line-height: 1.45;
  }
  .answer-next-button {
    left: 50%;
    bottom: 236px; /* clean-v2-a4: move mobile Next/Result button up 180px for iPhone SE visibility */
    transform: translateX(-50%);
  }
  .answer-next-button img { width: 170px; }
}

/* clean-v2-b9: iPad 10/11/Pro portrait answer reveal uses its own controlled layout.
   Question screen and non-iPad portrait layouts are not affected. */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  .screen-answer .question-layer-wrap { opacity: 0.28; }
  .screen-answer .answer-content {
    padding-top: 0;
    display: block;
    width: 100%;
    height: 100%;
  }
  .screen-answer .answer-result-icon {
    position: absolute;
    top: 130px;
    left: 50%;
    width: 96px;
    transform: translateX(-50%);
  }
  .screen-answer .answer-heading {
    position: absolute;
    top: 244px;
    left: 50%;
    width: 330px;
    margin: 0;
    transform: translateX(-50%);
    font-size: 32px;
  }
  .screen-answer .answer-explanation {
    position: absolute;
    top: 292px;
    left: 50%;
    width: 362px;
    max-height: 257px;
    margin: 0;
    transform: translateX(-50%);
    padding-left: 20px;
    padding-right: 20px;
    font-size: 28px;
    line-height: 1.45;
  }
  .screen-answer .answer-next-button {
    position: absolute;
    left: 50%;
    bottom: 236px;
    margin: 0;
    transform: translateX(-50%);
  }
  .screen-answer .answer-next-button img { width: 170px; }
}

/* Result screen */
.screen-result {
  height: var(--app-height);
  min-height: var(--app-height);
  overflow-y: auto;
  overflow-x: hidden;
  background: #bddb3f;
  -webkit-overflow-scrolling: touch;
}
.screen-result.is-active { display: block; }
.result-page {
  position: relative;
  width: min(100vw, 430px);
  min-height: var(--app-height);
  margin: 0 auto;
  overflow: hidden;
  background-image: url("../assets/images/result/result_bg1.png");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center top;
}
.result-visual {
  position: relative;
  width: 100%;
  padding-top: 0;
  margin-top: -220px;
}
.result-mouse-image {
  position: relative;
  z-index: 2;
  display: block;
  width: 116%;
  max-width: none;
  height: auto;
  margin-left: 50%;
  transform: translateX(-50%);
}
.result-score-image {
  position: relative;
  z-index: 3;
  display: block;
  width: 88%;
  max-width: 539px;
  height: auto;
  margin: -20px auto 0;
}
.result-actions {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 24px 0 max(42px, env(safe-area-inset-bottom));
  overflow: hidden;
}
.result-txtground-image {
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 4px;
  width: 443%;
  height: auto;
  max-width: none;
  transform: translateX(-50%);
  pointer-events: none;
}
.result-download-button,
.result-share-button,
.result-suggest-button,
.result-play-button,
.result-suggest-card-link {
  position: relative;
  z-index: 1;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.result-download-button img {
  display: block;
  width: min(82vw, 330px);
  height: auto;
}
.result-share-row {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin-top: 20px;
}
.result-share-button img {
  display: block;
  width: 104px;
  height: auto;
}
.result-suggest-button { margin-top: 28px; }
.result-suggest-button img {
  display: block;
  width: min(82vw, 330px);
  height: auto;
}
.result-suggest-card-link {
  display: block;
  margin-top: 18px;
}
.result-suggest-card {
  display: block;
  width: min(86vw, 360px);
  height: auto;
  margin-top: 0;
}
.result-play-button { margin-top: 28px; }
.result-play-button img {
  display: block;
  width: min(82vw, 330px);
  height: auto;
}
@media (min-width: 768px) {
  .result-page { width: min(430px, 100vw); }
}
@media (max-width: 767px) {
  .result-page { width: 100vw; }
  .result-mouse-image { width: 116%; }
  .result-score-image { width: 88%; margin-top: -20px; }
}
.app-message { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 999; display: none; max-width: 86vw; padding: 14px 18px; border-radius: 12px; background: rgba(0,0,0,.82); color: #fff; font-size: 16px; line-height: 1.5; text-align: center; }
.app-message.is-visible { display: block; }
