:root {
  --navy: #082338;
  --blue: #0b69c7;
  --cyan: #12a8b3;
  --green: #19a974;
  --gold: #d5a72e;
  --ink: #152737;
  --muted: #657789;
  --paper: #ffffff;
  --line: #dce7ee;
  --soft: #eef6fa;
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
  font-size: 17px;
  color: var(--ink);
  background: #f5f9fb;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 15% 5%, #dff4f5 0, transparent 26%), #f5f9fb; }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.site-header { height: 92px; display: flex; align-items: center; justify-content: space-between; max-width: 1320px; margin: auto; padding: 0 28px; }
.brand { display: flex; gap: 12px; align-items: center; color: var(--navy); text-decoration: none; }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 15px; color: white; background: linear-gradient(145deg, var(--blue), var(--cyan)); font: 800 27px/1 Georgia, serif; box-shadow: 0 8px 22px rgba(11,105,199,.24); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.15rem; letter-spacing: .02em; }
.brand small { color: var(--muted); margin-top: 2px; }
.secure-badge { display: flex; align-items: center; gap: 9px; padding: 10px 16px; border: 1px solid #bde6d7; border-radius: 999px; background: #edfbf5; color: #087c52; font-size: .92rem; font-weight: 700; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #1bb97d; box-shadow: 0 0 0 4px rgba(27,185,125,.12); }

.app-shell { max-width: 1320px; min-height: calc(100vh - 158px); margin: auto; padding: 54px 28px 76px; }
.screen { animation: appear .35s ease both; }
@keyframes appear { from { opacity: 0; transform: translateY(10px); } }
.welcome-screen { display: grid; grid-template-columns: 1.18fr .82fr; gap: clamp(48px, 6vw, 90px); align-items: center; }
.eyebrow { margin: 0 0 16px; color: var(--blue); font-size: .86rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.welcome-copy h1 { margin: 0; color: var(--navy); font-size: clamp(2.8rem, 4.2vw, 4.5rem); line-height: 1.08; letter-spacing: -.045em; }
.welcome-copy h1 span { display: inline-block; color: var(--blue); white-space: nowrap; }
.lead { max-width: 720px; margin: 30px 0 36px; color: #546b7d; font-size: 1.16rem; line-height: 1.8; }
.feature-list { display: flex; gap: 12px; }
.feature-list div { min-width: 128px; padding: 18px 20px; border-left: 4px solid var(--cyan); background: rgba(255,255,255,.78); }
.feature-list strong, .feature-list span { display: block; }
.feature-list strong { color: var(--navy); font-size: 1.5rem; }
.feature-list span { margin-top: 4px; color: #5d7284; font-size: .9rem; }
.feature-list .certificate-feature strong { font-size: 1.08rem; line-height: 1.45; white-space: nowrap; }
.feature-list .certificate-feature span { white-space: nowrap; }

.participant-card, .question-card, .result-card { border: 1px solid rgba(197,217,228,.85); border-radius: 24px; background: rgba(255,255,255,.9); box-shadow: 0 28px 70px rgba(19,62,91,.12); }
.participant-card { padding: 42px; }
.card-icon { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 17px; color: white; background: linear-gradient(145deg, var(--blue), var(--cyan)); font-size: 1.55rem; }
.participant-card h2 { margin: 23px 0 5px; color: var(--navy); font-size: 1.6rem; }
.participant-card > p { margin: 0 0 24px; color: var(--muted); }
.participant-card label { display: block; margin: 19px 0 8px; color: #263f53; font-size: .96rem; font-weight: 800; }
.participant-card label span { color: #d8344a; }
.participant-card input { width: 100%; min-height: 54px; padding: 15px 17px; border: 1px solid #b9cfdd; border-radius: 12px; outline: none; background: white; font-size: 1rem; transition: .2s; }
.participant-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(11,105,199,.1); }
.primary-button, .secondary-button { min-height: 54px; padding: 14px 22px; border-radius: 12px; border: 0; font-size: 1rem; font-weight: 800; transition: transform .18s, box-shadow .18s, background .18s; }
.primary-button { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; margin-top: 24px; color: white; background: linear-gradient(135deg, var(--blue), #058fa9); box-shadow: 0 10px 24px rgba(11,105,199,.2); }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(11,105,199,.28); }
.secondary-button { color: #345067; border: 1px solid #cbdbe4; background: white; }
.secondary-button:hover { background: var(--soft); }
.field-error, .quiz-message { min-height: 1.3em; margin: 9px 0 0 !important; color: #ca3047 !important; font-size: .86rem; }

.quiz-screen { max-width: 960px; margin: auto; }
.quiz-topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.quiz-topbar h2 { margin: 0; color: var(--navy); font-size: 1.35rem; }
.score-rule { padding: 8px 13px; border-radius: 10px; color: var(--muted); background: white; font-size: .9rem; }
.score-rule strong { color: var(--green); }
.progress-track { height: 8px; margin: 20px 0 28px; overflow: hidden; border-radius: 999px; background: #dce9ef; }
.progress-track span { display: block; height: 100%; width: 10%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--cyan)); transition: width .28s ease; }
.question-card { min-height: 400px; padding: clamp(26px, 5vw, 48px); }
.question-text { margin: 0 0 28px; color: var(--navy); font-size: clamp(1.25rem, 2.4vw, 1.7rem); font-weight: 800; line-height: 1.55; }
.answer-list { display: grid; gap: 12px; }
.answer-option { display: flex; align-items: center; gap: 14px; padding: 15px 17px; border: 1px solid #d6e2e9; border-radius: 13px; background: #fbfdfe; cursor: pointer; transition: .18s; }
.answer-option:hover { border-color: #87bbdf; background: #f4faff; }
.answer-option.selected { border-color: var(--blue); background: #eaf5ff; box-shadow: inset 0 0 0 1px var(--blue); }
.answer-option input { position: absolute; opacity: 0; pointer-events: none; }
.answer-letter { flex: 0 0 34px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #547086; background: #e9f0f4; font-weight: 800; }
.answer-option.selected .answer-letter { color: white; background: var(--blue); }
.answer-label { line-height: 1.5; }
.quiz-actions { display: flex; justify-content: space-between; margin-top: 22px; }
.quiz-actions .primary-button { width: auto; margin: 0; }
.compact { min-width: 150px; }

.result-screen { max-width: 1000px; margin: auto; }
.result-card { padding: 42px; text-align: center; }
.result-icon { width: 68px; height: 68px; display: grid; place-items: center; margin: 0 auto 20px; border-radius: 50%; font-size: 2rem; }
.result-card.passed .result-icon { color: #087c52; background: #dff8ed; }
.result-card.failed .result-icon { color: #bd5a13; background: #fff0df; }
.result-card h2 { margin: 0; color: var(--navy); font-size: 2rem; }
.result-summary { max-width: 560px; margin: 10px auto 24px; color: var(--muted); line-height: 1.7; }
.score-ring { width: 160px; height: 160px; display: grid; align-content: center; margin: 24px auto; border: 12px solid #dcecf3; border-radius: 50%; background: white; box-shadow: inset 0 0 0 1px #c9dce7; }
.score-ring strong, .score-ring span { display: block; }
.score-ring strong { color: var(--blue); font-size: 2.25rem; }
.score-ring span { color: var(--muted); font-size: .8rem; }
.result-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.result-actions .primary-button { width: auto; margin: 0; }

.certificate { position: relative; margin-top: 36px; padding: 14px; color: #182a3a; background: #f6efd7; box-shadow: 0 25px 70px rgba(19,62,91,.18); }
.certificate-border { position: relative; min-height: 620px; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; padding: 55px 75px 38px; border: 3px double #b58a21; background: radial-gradient(circle at center, rgba(255,255,255,.96), rgba(255,253,245,.9)), repeating-linear-gradient(45deg, transparent, transparent 9px, rgba(181,138,33,.04) 10px); text-align: center; }
.certificate-logo { width: 72px; height: 72px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--navy); border: 5px solid #e0bd5c; font: 800 17px Georgia, serif; letter-spacing: .06em; }
.certificate-type { margin: 20px 0 2px; color: #a07410; font-family: Georgia, "Th Sarabun New", serif; font-size: 3.3rem; font-weight: 700; letter-spacing: .04em; }
.certificate-intro { margin: 5px 0; color: #6e6552; }
.certificate h2 { min-width: 70%; margin: 10px 0 4px; padding: 0 20px 7px; color: var(--navy); border-bottom: 1px solid #c7a551; font-size: 2.35rem; }
.certificate-org { min-height: 1.4em; margin: 3px 0 10px; color: #596a76; }
.certificate-copy { margin: 9px 0 24px; color: #4d5860; font-size: 1.08rem; line-height: 1.75; }
.certificate-copy strong { color: var(--navy); }
.certificate-footer { width: 100%; display: grid; grid-template-columns: 1fr 100px 1fr; align-items: end; gap: 25px; margin-top: 10px; }
.certificate-footer > div { display: grid; gap: 5px; }
.certificate-footer span { padding-bottom: 5px; border-bottom: 1px solid #8d897e; font-weight: 700; }
.certificate-footer small { color: #777064; }
.seal { width: 86px; height: 86px; align-content: center; justify-self: center; border: 2px solid #b58a21; border-radius: 50%; color: #9b7315; }
.seal span { border: 0; font-size: 1.7rem; }
.seal small { font-size: .62rem; letter-spacing: .1em; }
.certificate-id { margin: 24px 0 0; color: #938a77; font: .72rem monospace; }
.certificate-corner { position: absolute; width: 95px; height: 95px; border-color: #b58a21; }
.top-left { top: 15px; left: 15px; border-top: 3px solid; border-left: 3px solid; }
.top-right { top: 15px; right: 15px; border-top: 3px solid; border-right: 3px solid; }
.bottom-left { bottom: 15px; left: 15px; border-bottom: 3px solid; border-left: 3px solid; }
.bottom-right { right: 15px; bottom: 15px; border-right: 3px solid; border-bottom: 3px solid; }

.site-footer { padding: 24px; color: #788b99; text-align: center; font-size: .82rem; }

@media (max-width: 860px) {
  :root { font-size: 16px; }
  .app-shell { padding-top: 24px; }
  .welcome-screen { grid-template-columns: 1fr; gap: 38px; }
  .welcome-copy h1 { font-size: clamp(2.5rem, 10vw, 4rem); }
  .welcome-copy h1 span { white-space: normal; }
  .feature-list { flex-wrap: wrap; }
  .feature-list div { flex: 1; }
  .question-card { min-height: 430px; }
  .certificate-border { min-height: 560px; padding: 45px 30px 30px; }
  .certificate h2 { font-size: 1.7rem; }
}

@media (max-width: 520px) {
  .site-header { height: 74px; padding: 0 18px; }
  .secure-badge { display: none; }
  .app-shell { padding-left: 16px; padding-right: 16px; }
  .participant-card, .question-card, .result-card { border-radius: 18px; padding: 24px; }
  .quiz-topbar { align-items: flex-start; }
  .score-rule { display: none; }
  .quiz-actions { gap: 10px; }
  .quiz-actions button { flex: 1; padding-inline: 10px; }
  .certificate { display: none; }
}

@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body { background: white; }
  body > * { display: none !important; }
  body.printing .app-shell, body.printing #result-screen, body.printing #certificate { display: block !important; }
  body.printing .app-shell { min-height: 0; max-width: none; padding: 0; }
  body.printing #result-card { display: none !important; }
  .certificate { width: 100%; margin: 0; padding: 8px; box-shadow: none; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .certificate-border { min-height: 185mm; }
}
