:root {
  color-scheme: light;
  --ink: #1f2d2d;
  --muted: #5c6b68;
  --panel: rgba(255, 252, 245, 0.94);
  --panel-strong: #fffaf0;
  --line: rgba(31, 45, 45, 0.16);
  --teal: #0f766e;
  --teal-deep: #0b514c;
  --coral: #e96f5c;
  --coral-deep: #be4f41;
  --gold: #d69d3a;
  --good: #147a54;
  --bad: #b64242;
  --shadow: 0 18px 50px rgba(11, 31, 35, 0.22);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family:
    "Noto Sans TC",
    "PingFang TC",
    "Microsoft JhengHei",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  letter-spacing: 0;
  background: #d9ede9;
}

button,
select {
  font: inherit;
}

button {
  border: 0;
}

.app {
  min-height: 100svh;
}

.stage {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  background-color: #d7eee8;
  background-image: var(--stage-bg, url("assets/training-room-bg.png"));
  background-position: center;
  background-size: cover;
  isolation: isolate;
}

.stage-overlay {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(14, 38, 43, 0.22), transparent 34%),
    linear-gradient(90deg, rgba(7, 22, 25, 0.28), transparent 45%),
    linear-gradient(0deg, rgba(7, 22, 25, 0.62), transparent 50%);
  pointer-events: none;
}

.hud {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding-top: 22px;
  color: #fffdf7;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.36);
}

.hud h1 {
  margin: 2px 0 0;
  font-size: 1.55rem;
  line-height: 1.2;
  font-weight: 800;
}

.hud-kicker {
  margin: 0;
  color: #ffe4b8;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hud-status {
  min-width: 120px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 999px;
  padding: 9px 13px;
  background: rgba(11, 31, 35, 0.38);
  color: #fffdf7;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: center;
  backdrop-filter: blur(12px);
}

.mentor {
  position: absolute;
  z-index: 1;
  right: max(18px, calc((100vw - 1180px) / 2));
  bottom: -5vh;
  height: min(82vh, 880px);
  max-width: 48vw;
  object-fit: contain;
  filter: drop-shadow(0 24px 26px rgba(6, 29, 31, 0.24));
  transform-origin: 50% 100%;
  animation: mentorBreath 4.8s ease-in-out infinite;
  pointer-events: none;
}

.view {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  width: min(1180px, calc(100% - 32px));
  min-height: calc(100svh - 92px);
  margin: -4px auto 0;
  padding-bottom: 28px;
}

.dialogue,
.result-panel,
.error-panel {
  width: min(800px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.dialogue {
  padding: 20px;
}

.setup-layout {
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 18px;
  align-items: start;
}

.speaker {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin-bottom: 12px;
  border-radius: 999px;
  padding: 7px 14px;
  background: var(--teal);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 800;
}

.dialogue h2,
.result-panel h2,
.error-panel h2 {
  margin: 0 0 10px;
  font-size: 1.45rem;
  line-height: 1.35;
}

.dialogue p,
.result-panel p,
.error-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.selector-group {
  margin-top: 18px;
}

.selector-label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
}

.role-list,
.category-list {
  display: grid;
  gap: 8px;
}

.role-option,
.category-option,
.choice {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease;
}

.role-option:hover,
.category-option:hover,
.choice:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 118, 110, 0.45);
  background: #fffef9;
  box-shadow: 0 10px 22px rgba(11, 31, 35, 0.12);
}

.role-option[aria-pressed="true"],
.category-option[aria-pressed="true"] {
  border-color: rgba(15, 118, 110, 0.7);
  background: #e8f7f3;
  box-shadow: inset 4px 0 0 var(--teal);
}

.role-name,
.category-name,
.choice-text {
  display: block;
  font-weight: 800;
  line-height: 1.4;
}

.role-desc {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.side-note {
  border-left: 4px solid var(--gold);
  padding: 12px 0 12px 14px;
}

.side-note strong {
  display: block;
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 0.95rem;
}

.side-note ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
  list-style: none;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.primary-action,
.secondary-action {
  min-height: 46px;
  border-radius: var(--radius);
  padding: 11px 17px;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

.primary-action {
  background: var(--coral);
  color: #fff;
  box-shadow: 0 12px 28px rgba(190, 79, 65, 0.24);
}

.primary-action:hover {
  transform: translateY(-1px);
  background: var(--coral-deep);
}

.secondary-action {
  border: 1px solid rgba(15, 118, 110, 0.32);
  background: #f1fbf8;
  color: var(--teal-deep);
}

.secondary-action:hover {
  transform: translateY(-1px);
  background: #dff4ef;
}

.primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}

.vn-screen {
  position: relative;
  display: flex;
  width: 100%;
  min-height: calc(100svh - 120px);
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 22px;
  padding-top: 72px;
}

.vn-topline {
  position: absolute;
  top: 18px;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  pointer-events: none;
}

.scene-ribbon {
  display: inline-flex;
  overflow: hidden;
  align-items: stretch;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 999px;
  background: rgba(6, 24, 30, 0.52);
  color: #fffdf7;
  box-shadow: 0 14px 28px rgba(6, 24, 30, 0.22);
  backdrop-filter: blur(14px);
}

.scene-ribbon span,
.scene-ribbon strong {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.82rem;
  line-height: 1;
}

.scene-ribbon span {
  background: rgba(233, 111, 92, 0.84);
  font-weight: 900;
  text-transform: uppercase;
}

.scene-ribbon strong {
  color: #fff4d6;
  font-weight: 900;
}

.quick-menu {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.quick-menu button {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(8, 31, 38, 0.54);
  color: #fffdf7;
  font-size: 0.76rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(6, 24, 30, 0.18);
  backdrop-filter: blur(14px);
}

.quick-menu button:hover {
  background: rgba(15, 118, 110, 0.78);
}

.quick-menu button[aria-pressed="true"] {
  border-color: rgba(255, 244, 214, 0.76);
  background: rgba(233, 111, 92, 0.86);
}

.vn-choice-layer {
  position: relative;
  z-index: 4;
  display: grid;
  width: min(470px, 38vw);
  align-self: flex-start;
  gap: 10px;
  margin: auto 0 16px clamp(0px, 2vw, 42px);
}

.vn-dialogue {
  position: relative;
  z-index: 5;
  width: min(760px, 64vw);
  min-height: 172px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 250, 238, 0.68)),
    radial-gradient(circle at 12% 0%, rgba(233, 111, 92, 0.1), transparent 36%);
  box-shadow:
    0 18px 48px rgba(6, 24, 30, 0.24),
    inset 0 0 0 1px rgba(214, 157, 58, 0.16);
  backdrop-filter: blur(20px) saturate(1.12);
}

.vn-dialogue::before,
.vn-dialogue::after {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: rgba(214, 157, 58, 0.75);
  content: "";
}

.vn-dialogue::before {
  top: 10px;
  left: 10px;
  border-top: 2px solid;
  border-left: 2px solid;
}

.vn-dialogue::after {
  right: 10px;
  bottom: 10px;
  border-right: 2px solid;
  border-bottom: 2px solid;
}

.nameplate {
  position: absolute;
  top: -22px;
  left: 22px;
  min-width: 132px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  padding: 10px 18px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.96), rgba(11, 81, 76, 0.96)),
    var(--teal);
  color: #fffdf7;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 12px 26px rgba(6, 24, 30, 0.22);
}

.dialogue-body {
  padding: 28px 26px 20px;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tag {
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef8f5;
  color: var(--teal-deep);
  font-size: 0.82rem;
  font-weight: 800;
}

.question-text {
  margin: 0;
  color: var(--ink);
  font-size: 1.32rem;
  font-weight: 800;
  line-height: 1.65;
}

.scene-note {
  margin-top: 13px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.65;
}

.choice {
  position: relative;
  min-height: 54px;
  justify-content: flex-start;
  overflow: hidden;
  border-color: rgba(255, 255, 255, 0.56);
  padding: 10px 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 249, 240, 0.64)),
    rgba(255, 255, 255, 0.7);
  color: var(--ink);
  box-shadow:
    0 12px 24px rgba(6, 24, 30, 0.16),
    inset 0 0 0 1px rgba(214, 157, 58, 0.12);
  backdrop-filter: blur(18px) saturate(1.14);
}

.choice::after {
  position: absolute;
  top: 0;
  right: 0;
  width: 42px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(233, 111, 92, 0.18));
  content: "";
  opacity: 0;
  transition: opacity 150ms ease;
}

.choice:hover::after {
  opacity: 1;
}

.choice:disabled {
  cursor: default;
  transform: none;
  box-shadow: none;
}

.choice-index {
  display: inline-grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.15);
  color: var(--teal-deep);
  font-size: 0.88rem;
  font-weight: 900;
}

.choice.is-correct {
  border-color: rgba(20, 122, 84, 0.65);
  background: #e8f7ef;
  box-shadow: inset 4px 0 0 var(--good);
}

.choice.is-wrong {
  border-color: rgba(182, 66, 66, 0.62);
  background: #fff0ed;
  box-shadow: inset 4px 0 0 var(--bad);
}

.feedback-copy.good h2 {
  color: var(--good);
}

.feedback-copy.bad h2 {
  color: var(--bad);
}

.feedback-copy h2 {
  margin: 0 0 10px;
  font-size: 1.35rem;
  line-height: 1.4;
}

.feedback-copy p {
  margin: 0 0 4px;
  color: var(--ink);
  line-height: 1.7;
}

.answer-line {
  font-weight: 800;
}

.explanation-line {
  color: var(--muted);
}

.continue-cue {
  position: absolute;
  right: 24px;
  bottom: 18px;
  width: 0;
  height: 0;
  border-top: 9px solid var(--coral);
  border-right: 7px solid transparent;
  border-left: 7px solid transparent;
  animation: cuePulse 900ms ease-in-out infinite;
}

.affinity-meter {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 0 2px;
  color: #fffdf7;
  font-size: 0.78rem;
  font-weight: 900;
  text-shadow: 0 2px 10px rgba(6, 24, 30, 0.42);
}

.affinity-track {
  height: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
}

.affinity-fill {
  height: 100%;
  width: var(--progress, 0%);
  background: linear-gradient(90deg, var(--coral), var(--gold), var(--teal));
  transition: width 220ms ease;
}

@keyframes cuePulse {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.55;
  }

  50% {
    transform: translateY(4px);
    opacity: 1;
  }
}

@keyframes mentorBreath {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
    filter: drop-shadow(0 24px 26px rgba(6, 29, 31, 0.24));
  }

  50% {
    transform: translate3d(0, -7px, 0) scale(1.012);
    filter: drop-shadow(0 28px 28px rgba(6, 29, 31, 0.27));
  }
}

.result-panel,
.error-panel {
  margin-bottom: 10px;
  padding: 22px;
}

.result-score {
  display: grid;
  width: 128px;
  height: 128px;
  place-items: center;
  margin: 16px 0;
  border: 8px solid #e8f7f3;
  border-radius: 999px;
  color: var(--teal-deep);
  font-size: 1.7rem;
  font-weight: 900;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 1.3rem;
}

.review-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  margin-top: 16px;
  overflow: auto;
  padding-right: 4px;
}

.review-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.72);
}

.review-item strong {
  color: var(--ink);
}

.review-item p {
  margin-top: 5px;
  font-size: 0.92rem;
}

.loading {
  color: #fffdf7;
  font-size: 1.1rem;
  font-weight: 900;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.38);
}

:focus-visible {
  outline: 3px solid rgba(233, 111, 92, 0.85);
  outline-offset: 3px;
}

@media (max-width: 920px) {
  .mentor {
    right: -58px;
    bottom: 14vh;
    height: 58vh;
    max-width: 70vw;
    opacity: 0.82;
  }

  .view {
    width: min(100% - 22px, 760px);
    min-height: calc(100svh - 88px);
    padding-bottom: 18px;
  }

  .dialogue,
  .vn-screen,
  .result-panel,
  .error-panel {
    width: 100%;
  }

  .setup-layout {
    grid-template-columns: 1fr;
  }

  .vn-screen {
    min-height: calc(100svh - 104px);
    padding-top: 74px;
  }

  .vn-choice-layer {
    width: min(560px, 100%);
    align-self: stretch;
    margin: auto 0 14px;
  }

  .vn-dialogue {
    width: 100%;
    min-height: 176px;
  }
}

@media (max-width: 640px) {
  .hud {
    width: calc(100% - 22px);
    padding-top: 14px;
  }

  .hud h1 {
    font-size: 1.16rem;
  }

  .hud-status {
    min-width: 96px;
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  .mentor {
    right: -86px;
    bottom: 40vh;
    height: 42vh;
    max-width: 82vw;
    opacity: 0.64;
  }

  .dialogue,
  .vn-dialogue,
  .result-panel,
  .error-panel {
    padding: 14px;
  }

  .vn-screen {
    min-height: calc(100svh - 84px);
    padding-top: 58px;
  }

  .vn-topline {
    top: 8px;
  }

  .scene-ribbon span,
  .scene-ribbon strong {
    min-height: 31px;
    padding: 0 10px;
    font-size: 0.72rem;
  }

  .quick-menu button {
    min-height: 31px;
    padding: 0 8px;
    font-size: 0.68rem;
  }

  .vn-choice-layer {
    gap: 8px;
    margin-bottom: 10px;
  }

  .choice {
    min-height: 50px;
    padding: 9px 11px;
  }

  .choice-index {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
  }

  .nameplate {
    top: -18px;
    left: 16px;
    min-width: 104px;
    padding: 8px 13px;
    font-size: 0.88rem;
  }

  .dialogue-body {
    padding: 24px 14px 16px;
  }

  .dialogue h2,
  .feedback-copy h2,
  .result-panel h2,
  .error-panel h2 {
    font-size: 1.2rem;
  }

  .question-text {
    font-size: 1.05rem;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .affinity-meter {
    bottom: -4px;
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .primary-action,
  .secondary-action {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mentor,
  .continue-cue {
    animation: none;
  }
}
