:root {
  --bg: #f2f2f2;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --line: #d8d8d8;
  --card: #ffffff;
  --accent: #2b4a8b;
  --accent-fg: #ffffff;
  --gold: #c8a24a;
  --gray-layer: #b8b8b8;
  --radius: 14px;
  --maxw: 460px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html { background: #000; }
html, body {
  height: 100%;
  font-family: 'Noto Sans Thai', sans-serif;
  background: transparent;
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-x: hidden;
}

#app {
  width: 100%;
  max-width: var(--maxw);
  position: relative;
}

.section {
  display: none;
  width: 100%;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
}

.section.active {
  display: flex;
  animation: fadeIn 0.45s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

.card {
  width: 100%;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius);
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}

h1 { font-size: 24px; font-weight: 700; line-height: 1.3; }
h2 { font-size: 20px; font-weight: 600; line-height: 1.3; }
p  { font-size: 15px; color: var(--muted); line-height: 1.55; }

label {
  display: block;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
}

.field { width: 100%; text-align: left; }

input, select {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--fg);
}

input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.btn {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 14px 18px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn:active { opacity: 0.8; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-small {
  width: auto;
  font-size: 13px;
  padding: 8px 14px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.btn-test {
  width: auto;
  font-size: 12px;
  padding: 6px 12px;
  background: #eee;
  color: #444;
  border: 1px dashed #aaa;
}

.consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  font-size: 13px;
}

.consent input { width: auto; margin-top: 3px; }

.qr-box {
  width: 240px;
  height: 240px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.qr-box img, .qr-box canvas { width: 100% !important; height: 100% !important; }
.qr-box table { width: 100%; height: 100%; border-collapse: collapse; }
.qr-box #qr-canvas { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }

.photo-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #e5e5e5;
  border-radius: var(--radius);
  overflow: hidden;
}


.photo-frame .layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-frame .layer-photo {
  transition: filter 0.4s ease;
}

.photo-frame .layer-photo.grayscale {
  filter: grayscale(100%);
}

.layer-nickname {
  position: absolute;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #fff;
  font-family: 'Noto Sans Thai', sans-serif;
  font-weight: 700;
  text-shadow: 0 2px 6px rgba(0,0,0,0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.otp-wrap {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 6px 0 2px;
}

.otp-box {
  width: 48px;
  height: 58px;
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--fg);
  font-family: inherit;
}

.otp-box:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(43, 74, 139, 0.15);
}

.q-buttons {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 12px;
  width: 100%;
}

.q-btn {
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 18px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--fg);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.q-btn.answered {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
  cursor: default;
}

.q-btn.highlight {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(200, 162, 74, 0.25);
}

.choices { display: flex; flex-direction: column; gap: 10px; width: 100%; }

.choice-btn {
  font-family: inherit;
  font-size: 15px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--fg);
  cursor: pointer;
  text-align: left;
}

.choice-btn:active { background: #f0f0f0; }

.progress-text { font-size: 14px; color: var(--muted); }

.row { display: flex; gap: 10px; width: 100%; }
.row .btn { flex: 1; }

.mt-sm { margin-top: 8px; }
.hidden { display: none !important; }

#loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  font-size: 15px;
  color: var(--muted);
}

#loading.done { display: none; }

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 14px;
}

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

.loading-inner { display: flex; flex-direction: column; align-items: center; }

.choose-num {
  width: 64px;
  height: 64px;
  font-family: inherit;
  font-size: 26px;
  font-weight: 700;
  border: 2px solid var(--accent);
  border-radius: 14px;
  background: #fff;
  color: var(--accent);
  cursor: pointer;
}
.choose-num:active { background: var(--accent); color: #fff; }

.bg-stack {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: #000;
}
.bg-img {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.7s ease;
}
.bg-img.active { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .bg-img { transition: opacity 0.2s ease; }
}

.qcard {
  width: 100%;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius);
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}

.q-num {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

#cover {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(8, 10, 16, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  opacity: 0;
  transition: opacity 0.45s ease;
}
#cover[hidden] { display: none; }
#cover.show { opacity: 1; }

.cover-inner {
  max-width: 520px;
  text-align: center;
}
.cover-text {
  color: #fff;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.5;
  white-space: pre-wrap;
}
