:root {
  color-scheme: light;
  --ivory: #fffbf4;
  --orange: #ff7658;
  --ink: #172236;
  --gray: #7e8795;
  --line: #f0e4d8;
  --green: #45a56f;
  --yellow: #e7a427;
  --red: #d94b45;
  --white: #fff;
  font-family: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }

[hidden] { display: none !important; }

.app-shell {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--ivory);
}

.view { min-height: 100vh; min-height: 100dvh; }

.screen-header {
  height: 72px;
  display: grid;
  place-items: center;
}

.screen-header h1,
.result-heading h1 {
  margin: 0;
  color: var(--ink);
  font-size: 25px;
  font-weight: 900;
  letter-spacing: .02em;
}

.screen-content {
  width: min(100% - 40px, 760px);
  margin: 0 auto;
}

.question-content { padding: 12px 0 28px; }

.intro { margin-bottom: 14px; }

.intro h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.35;
  font-weight: 900;
}

.intro p,
.result-heading p {
  margin: 5px 0 0;
  color: var(--gray);
  font-size: 14px;
}

#screeningForm { display: grid; gap: 14px; }

.question-card {
  min-width: 0;
  margin: 0;
  padding: 18px;
  border: 0;
  border-radius: 20px;
  background: var(--white);
  box-shadow: 0 2px 10px rgba(73, 46, 25, .08);
}

.question-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0;
  color: var(--orange);
  font-size: 17px;
  font-weight: 900;
}

.number {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: #ffeee8;
}

.question-text {
  min-height: 49px;
  margin: 12px 0 16px;
  font-size: 18px;
  line-height: 1.5;
  font-weight: 700;
}

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

.answer-button {
  height: 74px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fffaf7;
  color: var(--ink);
  cursor: pointer;
  font-size: 21px;
  font-weight: 900;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
}

.answer-button:hover { border-color: #dbcdc1; }
.answer-button:active { transform: scale(.985); }
.answer-button:focus-visible,
.submit-button:focus-visible,
.restart-button:focus-visible { outline: 3px solid rgba(255, 118, 88, .35); outline-offset: 3px; }

.answer-button[aria-pressed="true"] {
  border-color: var(--green);
  background: var(--green);
  color: var(--white);
}

.check { display: none; margin-right: 7px; }
.answer-button[aria-pressed="true"] .check { display: inline; }

.submit-button {
  width: 100%;
  height: 58px;
  border: 0;
  border-radius: 16px;
  background: var(--orange);
  color: var(--white);
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
}

.submit-button:disabled {
  background: #efc5b9;
  cursor: not-allowed;
}

.result-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 22px 0 28px;
}

.result-heading { text-align: center; }
.result-heading h1:focus { outline: none; }

.health-code {
  position: relative;
  display: grid;
  place-items: center;
  width: 220px;
  height: 220px;
  overflow: hidden;
  border-radius: 30px;
  background: var(--risk-color, var(--red));
  box-shadow: 0 8px 18px rgba(30, 24, 18, .18);
}

.code-pattern {
  position: absolute;
  inset: 18px;
  opacity: .18;
  background-image:
    linear-gradient(90deg, transparent 54%, white 54% 82%, transparent 82%),
    linear-gradient(transparent 54%, white 54% 82%, transparent 82%);
  background-size: 31px 31px;
  border-radius: 12px;
}

.code-center {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: var(--white);
  color: var(--risk-color, var(--red));
}

.result-icon { width: 43px; height: 43px; }
.code-center strong { margin-top: 4px; font-size: 25px; font-weight: 900; }

.result-card {
  width: 100%;
  padding: 22px;
  border-radius: 22px;
  background: var(--white);
  box-shadow: 0 3px 12px rgba(73, 46, 25, .1);
}

.result-message {
  margin: 0;
  color: var(--risk-color, var(--red));
  font-size: 22px;
  line-height: 1.45;
  font-weight: 900;
  text-align: center;
}

.result-answers { margin-top: 18px; }

.result-row {
  display: flex;
  align-items: center;
  padding: 7px 0;
}

.result-row > span { flex: 1; color: var(--gray); font-size: 14px; }

.answer-pill {
  min-width: 50px;
  padding: 6px 15px;
  border-radius: 999px;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
}

.answer-pill.yes { background: #ffeae3; color: var(--red); }
.answer-pill.no { background: #eaf5ee; color: var(--green); }

.medical-note {
  width: 100%;
  margin: 0;
  padding: 16px;
  border-radius: 16px;
  background: #fff2e7;
  color: #9b5a47;
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
}

.restart-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  height: 56px;
  border: 2px solid var(--line);
  border-radius: 15px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.restart-button svg { width: 22px; height: 22px; }

.result-view[data-risk="red"] { --risk-color: var(--red); }
.result-view[data-risk="yellow"] { --risk-color: var(--yellow); }
.result-view[data-risk="green"] { --risk-color: var(--green); }

@media (min-width: 900px) {
  .screen-content { width: min(100% - 64px, 820px); }
  .question-content { padding-top: 18px; }
  .question-card { padding: 20px 22px; }
}

@media (max-width: 600px) {
  #questionView,
  #resultView {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .screen-content { width: calc(100% - 20px); }

  .screen-header {
    height: clamp(44px, 7dvh, 52px);
  }

  .screen-header h1,
  .result-heading h1 { font-size: 20px; }

  .question-content {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - clamp(44px, 7dvh, 52px));
    padding: 2px 0 max(8px, env(safe-area-inset-bottom));
  }

  .intro {
    flex: none;
    margin-bottom: 5px;
  }

  .intro h2 {
    font-size: 17px;
    line-height: 1.25;
  }

  .intro p,
  .result-heading p {
    margin-top: 2px;
    font-size: 11px;
  }

  #screeningForm {
    display: grid;
    flex: 1;
    min-height: 0;
    grid-template-rows: repeat(3, minmax(0, 1fr)) 44px;
    gap: 6px;
  }

  .question-card {
    display: flex;
    min-height: 0;
    flex-direction: column;
    padding: 7px 9px 8px;
    border-radius: 14px;
    box-shadow: 0 2px 7px rgba(73, 46, 25, .07);
  }

  .question-heading {
    gap: 6px;
    font-size: 13px;
    line-height: 1;
  }

  .number {
    width: 22px;
    height: 22px;
    font-size: 12px;
  }

  .question-text {
    display: flex;
    min-height: 0;
    flex: 1;
    align-items: center;
    margin: 3px 0 5px;
    font-size: 14px;
    line-height: 1.25;
  }

  .answer-grid { gap: 8px; }

  .answer-button {
    height: 38px;
    border-width: 1.5px;
    border-radius: 10px;
    font-size: 16px;
  }

  .check { margin-right: 4px; }

  .submit-button {
    height: 44px;
    border-radius: 12px;
    font-size: 16px;
  }

  .result-content {
    height: 100dvh;
    justify-content: flex-start;
    gap: 8px;
    padding: max(8px, env(safe-area-inset-top)) 0 max(8px, env(safe-area-inset-bottom));
  }

  .result-heading { flex: none; }

  .health-code {
    width: clamp(132px, 24dvh, 170px);
    height: clamp(132px, 24dvh, 170px);
    flex: none;
    border-radius: 22px;
  }

  .code-pattern {
    inset: 12px;
    background-size: 24px 24px;
  }

  .code-center {
    width: clamp(80px, 14dvh, 102px);
    height: clamp(80px, 14dvh, 102px);
  }

  .result-icon { width: 32px; height: 32px; }
  .code-center strong { margin-top: 1px; font-size: 20px; }

  .result-card {
    padding: 11px 14px;
    border-radius: 16px;
  }

  .result-message {
    font-size: 17px;
    line-height: 1.3;
  }

  .result-answers { margin-top: 7px; }
  .result-row { padding: 3px 0; }
  .result-row > span { font-size: 12px; }

  .answer-pill {
    min-width: 42px;
    padding: 4px 12px;
    font-size: 12px;
  }

  .medical-note {
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 11px;
    line-height: 1.35;
  }

  .restart-button {
    height: 42px;
    border-radius: 12px;
    font-size: 14px;
  }

  .restart-button svg { width: 18px; height: 18px; }
}

@media (max-width: 600px) and (max-height: 620px) {
  .screen-header { height: 40px; }
  .question-content { height: calc(100dvh - 40px); }
  .screen-header h1, .result-heading h1 { font-size: 18px; }
  .intro h2 { font-size: 15px; }
  .intro p, .result-heading p { font-size: 10px; }
  #screeningForm { grid-template-rows: repeat(3, minmax(0, 1fr)) 40px; gap: 4px; }
  .question-card { padding: 5px 8px 6px; }
  .question-heading { font-size: 12px; }
  .number { width: 20px; height: 20px; font-size: 11px; }
  .question-text { margin: 2px 0 3px; font-size: 13px; line-height: 1.2; }
  .answer-button { height: 32px; font-size: 14px; }
  .submit-button { height: 40px; font-size: 15px; }
  .result-content { gap: 5px; padding-top: 5px; padding-bottom: 5px; }
  .health-code { width: 112px; height: 112px; border-radius: 18px; }
  .code-center { width: 70px; height: 70px; }
  .result-icon { width: 26px; height: 26px; }
  .code-center strong { font-size: 17px; }
  .result-card { padding: 8px 12px; }
  .result-message { font-size: 15px; }
  .result-answers { margin-top: 4px; }
  .result-row { padding: 2px 0; }
  .medical-note { padding: 6px 8px; font-size: 10px; }
  .restart-button { height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
