:root {
  color-scheme: light;
  --ink: #152028;
  --muted: #687782;
  --line: #dbe4e8;
  --panel: #ffffff;
  --bg: #f4f7f6;
  --green: #17795a;
  --green-soft: #e7f5ef;
  --red: #b83131;
  --red-soft: #fdecec;
  --blue: #245f93;
  --blue-soft: #e9f2fb;
  --shadow: 0 18px 50px rgba(22, 38, 50, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(233, 242, 251, 0.8), rgba(244, 247, 246, 0) 320px),
    var(--bg);
  font-family:
    "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", "Segoe UI", Arial, sans-serif;
}

button,
select {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 14px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.15;
}

h2 {
  font-size: 24px;
  line-height: 1.5;
}

.stats,
.review-panel,
.controls,
.question-panel {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(72px, 1fr)) 44px;
  align-items: center;
  min-width: 240px;
  border-radius: 8px;
  overflow: hidden;
}

.stats div {
  padding: 12px 14px;
  border-right: 1px solid var(--line);
}

.stats span,
.review-panel strong {
  display: block;
  font-size: 24px;
  font-weight: 800;
}

.stats small,
.review-panel span {
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  width: 44px;
  height: 100%;
  min-height: 58px;
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-size: 23px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 14px;
  align-items: end;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font-weight: 750;
}

button:hover {
  filter: brightness(0.97);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary {
  color: var(--blue);
  background: #fff;
  border-color: var(--line);
}

.question-panel {
  position: relative;
  border-radius: 8px;
  padding: 28px;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
  user-select: none;
  will-change: transform, opacity;
}

.question-panel.slide-next {
  animation: slideInFromRight 420ms cubic-bezier(0.22, 0.8, 0.2, 1);
}

.question-panel.slide-previous {
  animation: slideInFromLeft 420ms cubic-bezier(0.22, 0.8, 0.2, 1);
}

.swipe-hint {
  display: none;
}

.swipe-zone {
  display: none;
}

.language-toggle {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 4;
  min-width: 42px;
  min-height: 36px;
  padding: 0 10px;
  border-color: var(--line);
  color: var(--blue);
  background: #fff;
  box-shadow: 0 8px 20px rgba(22, 38, 50, 0.08);
}

.language-toggle:disabled {
  display: none;
}

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

.question-meta span {
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: #f1f5f6;
  font-size: 13px;
  font-weight: 700;
}

.options {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.option {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px 10px 8px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  font-weight: 600;
}

.option .letter {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--blue);
  background: var(--blue-soft);
  font-weight: 900;
}

.option.correct {
  border-color: rgba(23, 121, 90, 0.35);
  background: var(--green-soft);
}

.option.correct .letter {
  color: #fff;
  background: var(--green);
}

.option.wrong {
  border-color: rgba(184, 49, 49, 0.35);
  background: var(--red-soft);
}

.option.wrong .letter {
  color: #fff;
  background: var(--red);
}

.result {
  margin-top: 20px;
  border-left: 4px solid var(--green);
  border-radius: 6px;
  padding: 14px 16px;
  background: #f8fbfa;
  line-height: 1.7;
}

.result.is-wrong {
  border-left-color: var(--red);
}

.result.is-notice {
  border-left-color: var(--blue);
  background: var(--blue-soft);
}

.result strong {
  display: block;
  margin-bottom: 6px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.actions button {
  flex: 0 1 auto;
}

.review-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  border-radius: 8px;
  margin-top: 16px;
  background: var(--line);
}

.review-panel div {
  padding: 15px 18px;
  background: #fff;
}

@keyframes slideInFromRight {
  0% {
    opacity: 0;
    transform: translateX(72px) scale(0.985);
  }
  55% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes slideInFromLeft {
  0% {
    opacity: 0;
    transform: translateX(-72px) scale(0.985);
  }
  55% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .question-panel.slide-next,
  .question-panel.slide-previous {
    animation-duration: 1ms;
  }
}

/* legacy keyframe names kept above for the card transition */
@keyframes oldSlideInFromRight {
  from {
    opacity: 0.2;
    transform: translateX(34px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes oldSlideInFromLeft {
  from {
    opacity: 0.2;
    transform: translateX(-34px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 18px;
  }

  .topbar,
  .controls {
    grid-template-columns: 1fr;
    display: grid;
  }

  .stats {
    width: 100%;
  }

  .question-panel {
    padding: 20px;
  }

  .swipe-hint {
    display: block;
    margin: -2px 54px 12px 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-align: right;
  }

  .swipe-zone {
    display: block;
    position: absolute;
    inset: 0 0 auto;
    height: min(42%, 260px);
    z-index: 1;
    background: transparent;
    pointer-events: none;
    touch-action: pan-y pinch-zoom;
  }

  .question-meta,
  .question-panel h2 {
    position: relative;
    z-index: 2;
  }

  h2 {
    font-size: 20px;
  }

  .review-panel {
    grid-template-columns: 1fr;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
