@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700;800&display=swap');

:root {
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  color: #182725;
  background: #f3f6f5;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #249666;
  outline-offset: 4px;
}

header {
  height: 86px;
  padding: 0 4%;
  background: white;
  border-bottom: 1px solid #e0e7e4;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  text-decoration: none;
  color: inherit;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: grid;
  place-items: center;
  background: #182725;
  color: #83efbd;
  border-radius: 12px;
  width: 40px;
  height: 40px;
  font-size: 26px;
}

.header-note {
  color: #63726d;
  font-size: 14px;
}

main {
  max-width: 1600px;
  margin: auto;
  padding: 40px 4% 0;
}

.heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 32px;
}

.eyebrow {
  color: #56816d;
  font-size: 12px;
  letter-spacing: 2px;
  font-weight: 700;
  margin: 0 0 12px;
}

h1 {
  font-size: clamp(26px, 2.8vw, 38px);
  letter-spacing: -1.2px;
  margin: 0;
  font-weight: 700;
}

.secondary {
  background: white;
  border: 1px solid #d2dcd7;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  color: #273d33;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(240px, 290px) minmax(360px, 1fr) minmax(
      210px,
      260px
    );
  gap: 22px;
  align-items: start;
}

.setup,
.history {
  background: white;
  border: 1px solid #dfe7e3;
  border-radius: 18px;
  padding: 24px;
}

.section-label {
  display: flex;
  gap: 10px;
  align-items: center;
}

.section-label > span,
.question-label > span:first-child {
  font-size: 12px;
  font-weight: 700;
  color: #5c7b6b;
  background: #edf3ef;
  padding: 6px;
  border-radius: 6px;
}

h2,
h3 {
  margin: 0;
}

.section-label h2 {
  font-size: 16px;
}

.muted {
  color: #738179;
  font-size: 14px;
  line-height: 1.6;
  margin: 12px 0 24px;
}

.import-box {
  border: 1px dashed #b8cbbf;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.import-box > label {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 6px;
  font-size: 14px;
}

.import-box small {
  grid-column: 2;
  color: #7c8982;
  font-size: 12px;
}

.file-icon {
  grid-row: span 2;
  font-size: 26px;
  color: #44845d;
}

.import-box > input {
  font-size: 12px;
  width: 100%;
  margin-top: 14px;
}

.file-info {
  font-size: 12px;
  line-height: 1.6;
  color: #558169;
  margin: 12px 0 0;
  overflow-wrap: anywhere;
}

.config {
  margin-top: 14px;
}

.config label {
  display: block;
  font-size: 12px;
  margin-top: 10px;
  color: #576e60;
}

.config select {
  width: 100%;
  padding: 7px;
  border: 1px solid #d5dfd9;
  border-radius: 6px;
  background: white;
  font-size: 14px;
  margin-top: 4px;
}

.config .check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.privacy {
  font-size: 12px;
  line-height: 1.8;
  color: #75827a;
  margin: 22px 0 10px;
}

.text-button {
  border: 0;
  background: transparent;
  padding: 6px 0;
  color: #28724e;
  text-decoration: underline;
  font-size: 14px;
}

#error {
  font-size: 14px;
  color: #ad3838;
  line-height: 1.6;
  white-space: pre-line;
}

.play {
  background: white;
  border: 1px solid #dfe7e3;
  border-radius: 20px;
  padding: 26px;
  overflow: hidden;
}

.play-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.session-label {
  font-size: 12px;
  font-weight: 600;
  color: #6f8076;
  letter-spacing: 1px;
}

.badge {
  font-size: 12px;
  background: #edf6f0;
  padding: 7px 10px;
  border-radius: 30px;
  color: #377054;
}

.picker {
  position: relative;
  min-height: 285px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  isolation: isolate;
  padding: 28px 8px;
}

.orbit {
  position: absolute;
  z-index: -1;
  width: 245px;
  height: 245px;
  border: 1px solid #e6eee8;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    #eefbf4 0%,
    #f7fcf9 64%,
    transparent 65%
  );
}

.orbit:after {
  content: '';
  position: absolute;
  inset: 19px;
  border: 1px dashed #d2e4d8;
  border-radius: 50%;
}

.spark {
  position: absolute;
  color: #60b88a;
  font-size: 26px;
}

.s1 {
  left: 12%;
  top: 25%;
}

.s2 {
  right: 12%;
  bottom: 24%;
  font-size: 16px;
}

.picker > p:first-of-type {
  font-size: 14px;
  color: #587462;
  margin: 0 0 14px;
}

.picker h2 {
  font-size: clamp(28px, 3.1vw, 44px);
  letter-spacing: -1.3px;
  line-height: 1.35;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.picker > p:last-child {
  color: #7e8b82;
  font-size: 12px;
  line-height: 1.7;
  margin: 14px 0 0;
}

.primary {
  border: 0;
  border-radius: 12px;
  background: #182f26;
  color: #b4f6d5;
  padding: 17px 24px;
  font-weight: 600;
  font-size: 16px;
}

#spin {
  display: block;
  width: 100%;
  box-shadow: 0 4px 0 #0e1f17;
}

#spin span {
  margin-right: 8px;
  font-size: 22px;
}

.spin-note {
  text-align: center;
  font-size: 12px;
  line-height: 1.8;
  color: #7c8881;
  margin: 16px 0 26px;
}

.question {
  background: #f2f8f4;
  border: 1px solid #dfede3;
  border-radius: 14px;
  padding: 20px;
}

.question-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.question-label h3 {
  font-size: 14px;
}

.question-label #questionNo {
  margin-left: auto;
  font-size: 12px;
  color: #778a7b;
}

.question > p {
  font-size: 17px;
  line-height: 1.8;
  margin: 16px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.stats {
  display: flex;
  justify-content: space-around;
  padding-top: 24px;
  margin-top: 24px;
  border-top: 1px solid #e6ebe8;
  gap: 10px;
}

.stats > div {
  text-align: center;
  flex: 1;
}

.stats strong {
  display: block;
  font-size: 28px;
  font-weight: 600;
}

.stats span {
  display: block;
  font-size: 12px;
  color: #7b8a81;
  margin-top: 7px;
}

.history {
  min-height: 350px;
}

.empty {
  text-align: center;
  color: #79887e;
  padding: 30px 0;
}

.empty > span {
  font-size: 38px;
  color: #c9d7ce;
}

.empty p {
  font-size: 14px;
}

.empty small {
  font-size: 12px;
  line-height: 1.7;
}

.history-row {
  padding: 16px 0;
  border-bottom: 1px solid #edf1ee;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.history-row > span {
  flex-shrink: 0;
  background: #edf6f0;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 12px;
  color: #598568;
}

.history-row strong {
  font-size: 14px;
  line-height: 1.6;
  display: block;
  overflow-wrap: anywhere;
}

.history-row small {
  color: #8a988e;
  font-size: 12px;
  display: block;
  margin-top: 4px;
}

#history {
  max-height: 560px;
  overflow: auto;
}

footer {
  text-align: center;
  font-size: 12px;
  line-height: 1.8;
  color: #89958d;
  padding: 28px 0;
}

dialog {
  border: 0;
  padding: 28px;
  border-radius: 18px;
  max-width: 460px;
  width: calc(100% - 40px);
  color: #182725;
}

dialog::backdrop {
  background: #142c2566;
}

dialog h2 {
  font-size: 22px;
}

dialog p {
  font-size: 16px;
  line-height: 1.8;
  color: #64786a;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.rolling .orbit {
  animation: turn 2s linear infinite;
}

.rolling #name {
  color: #2d7855;
}

@keyframes turn {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 260px 1fr;
  }

  .history {
    grid-column: 1 / -1;
    min-height: 0;
  }

  #history {
    max-height: 260px;
  }

  .empty {
    padding: 10px;
  }
}

@media (max-width: 680px) {
  header {
    height: 70px;
  }

  .header-note {
    display: none;
  }

  main {
    padding: 28px 16px 0;
  }

  .heading {
    align-items: flex-start;
  }

  .heading .secondary {
    padding: 10px;
    white-space: nowrap;
    font-size: 12px;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .setup,
  .play,
  .history {
    width: 100%;
    padding: 20px;
  }

  .picker {
    min-height: 260px;
  }

  .stats span {
    font-size: 12px;
  }

  .section-label h2 {
    font-size: 16px;
  }

  h1 {
    font-size: 26px;
  }

  .heading {
    gap: 12px;
  }

  .play-top {
    flex-wrap: wrap;
  }

  .dialog-actions {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rolling .orbit {
    animation: none;
  }
}

#questionDialog {
  max-width: 800px;
  padding: 32px;
  width: calc(100% - 32px);
  max-height: 85vh;
  overflow: auto;
}

#questionDialog::backdrop {
  background: #102a23b3;
  backdrop-filter: blur(5px);
}

.popup-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
}

.popup-top .eyebrow {
  margin: 0;
}

.popup-close {
  border: 1px solid #d5e2d9;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  background: white;
  color: #354c40;
  font-size: 28px;
  line-height: 1;
}

#popupTitle {
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.popup-question {
  margin: 24px 0;
  background: #f0f8f3;
  border: 1px solid #dcece2;
  border-radius: 14px;
  padding: 24px;
}

.popup-question .eyebrow {
  font-size: 12px;
}

#popupQuestion {
  font-size: clamp(20px, 3vw, 26px);
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #182725;
  margin: 12px 0 0;
  overflow-x: auto;
  padding: 8px 0;
}

#continueQuestion {
  width: 100%;
}

@media (max-width: 680px) {
  #questionDialog {
    padding: 22px;
  }

  .popup-question {
    padding: 18px;
  }
}

.answer-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.format-note {
  font-size: 12px;
  line-height: 1.7;
  color: #637b6d;
  margin-bottom: 0;
}

.answer-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}

.answer-option {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 18px;
  border: 1px solid #cddbd2;
  border-radius: 12px;
  background: white;
  color: #243e30;
  flex-wrap: wrap;
  min-width: 0;
  font-size: 18px;
}

.answer-option:hover:not(:disabled) {
  background: #f2faf5;
  border-color: #51a676;
}

.answer-letter {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #edf4ef;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.answer-content {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.answer-result {
  display: none;
  width: 100%;
  font-size: 14px;
  font-weight: 600;
}

.answer-option:disabled {
  opacity: 1;
  cursor: default;
}

.answer-option.is-correct {
  background: #e3f8eb;
  border-color: #22944e;
  color: #145f30;
}

.answer-option.is-wrong {
  background: #fff0f0;
  border-color: #dc7777;
  color: #a32b2b;
}

.answer-option.is-selected {
  border-width: 3px;
  padding: 16px;
}

.answer-option.is-correct .answer-letter {
  background: #198547;
  color: white;
}

.answer-option.is-wrong .answer-letter {
  background: #c24545;
  color: white;
}

.answer-option.is-correct .answer-result,
.answer-option.is-wrong .answer-result {
  display: block;
}

.answer-feedback {
  font-size: 16px;
  line-height: 1.7;
  color: #64786a;
  margin: 16px 0;
}

.feedback-correct {
  color: #18733b;
  font-weight: 600;
}

.feedback-wrong {
  color: #ac3232;
  font-weight: 600;
}

.math-warning {
  font-size: 14px;
  line-height: 1.6;
  color: #a76b18;
}

#questionText .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px 0;
}

.katex-display {
  margin: 0.5em 0;
}

.answer-content .katex {
  font-size: 1.15em;
}

@media (max-width: 600px) {
  .answer-options,
  .answer-columns {
    grid-template-columns: 1fr;
  }

  .answer-option {
    font-size: 18px;
  }
}

.correct-answer-summary {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid #c8e2d1;
  color: #176d37;
}

.correct-answer-summary[hidden] {
  display: none;
}

.correct-answer-summary strong {
  display: block;
  font-size: 16px;
  margin-bottom: 10px;
}

#correctAnswerContent {
  font-size: 20px;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow-x: auto;
}

#correctAnswerContent .katex-display {
  overflow-x: auto;
  padding: 8px 0;
}

.exhausted-notice {
  background: #fff7df;
  border: 1px solid #e8d29a;
  border-radius: 10px;
  color: #745115;
  font-size: 16px;
  line-height: 1.7;
  padding: 16px;
  margin: 0 0 20px;
}

.exhausted-notice[hidden] {
  display: none;
}
