body, input, select, textarea, button {
  font-family: "Kanit", sans-serif;
}

body {
  background: linear-gradient(135deg, #f0f4f8, #e3f2fd);
  padding: 20px;
}

.container {
  max-width: 650px;
  margin: auto;
  background: #fff;
  padding: 30px;
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}

.form-header {
  text-align: center;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: #f0f4ff;    /* ฟ้าอ่อน */
  border-radius: 12px;
}

.form-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0;
  color: #222;
}

.form-header h2 {
  font-size: 1.2rem;
  font-weight: 500;
  margin: 0;
  color: #1976d2;         /* ฟ้าเข้ม เน้นชื่อหน่วยงาน */
}

.form-header p {
  font-size: 1rem;
  font-weight: 500;
  margin: 0.3rem 0 0;
}

h1 {
  text-align: center;
  margin-bottom: 30px;
  color: #1976D2;
  font-size: 24px;
  font-weight: 600;
}

/* ให้ทุก input, select, textarea มีความกว้างเท่ากัน */
input[type="text"],
textarea,
select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 1rem;
}

.label {
  font-weight: 600;
  margin-bottom: 10px;
  display: block;
  color: #333;
}

.question {
  margin-bottom: 30px;
  line-height: 1.6;
}

/* Q1 options layout */
.options {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
}

.option {
  min-width: 0;
  text-align: center;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 28px;   /* ขยาย emoji/icon */
  color: #333;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  height: 90px;      /* เพิ่มความสูงให้สมดุลกับ icon */
}

.option span {
  font-size: 16px;   /* ขยายข้อความใต้ icon */
  margin-top: 4px;
}

/* สีพื้น Q1 */
.option-5 { background-color: #d0f0d6; }
.option-4 { background-color: #e6f7c9; }
.option-3 { background-color: #fff9c4; }
.option-2 { background-color: #ffe0b2; }
.option-1 { background-color: #ffcdd2; }

/* ปุ่ม hover */
.option:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}

/* ปุ่ม active */
.option.active {
  box-shadow: 0 0 0 3px #1976D2, 0 4px 12px rgba(0,0,0,0.15);
  transform: scale(1.08);
}

.option.active span {
  font-weight: bold;
}

.option.active::first-line {
  font-size: 1.3em;
}

/* Responsive บนจอเล็ก */
@media (max-width: 480px) {
  .option {
    font-size: 22px;  /* emoji เล็กลงนิดหน่อย */
    height: 75px;
  }

  .option span {
    font-size: 14px;
  }

    .form-header h1 {
    font-size: 1.4rem;
    }
  
}

/* Q2 radio options ให้เรียงแนวตั้ง */
#q2Options label {
  display: block;
  margin-bottom: 8px;
}

/* Q2 "อื่นๆ" inline */
#q2Options .inline-other {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ช่อง input ของ Q2 (อื่นๆ) */
#q2Other {
  flex: 1;
  padding: 15px;
  border-radius: 12px;
  border: 1px solid #ccc;
  font-size: 16px;
  box-sizing: border-box;
  transition: border-color 0.3s, box-shadow 0.3s;
}

#q2Other:focus {
  border-color: #1976D2;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.2);
  outline: none;
}

select, textarea {
  width: 100%;
  padding: 15px;
  border-radius: 12px;
  border: 1px solid #ccc;
  margin-top: 8px;
  font-size: 16px;
  box-sizing: border-box;
  transition: border-color 0.3s, box-shadow 0.3s;
}

textarea:focus, select:focus, input:focus {
  border-color: #1976D2;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.2);
  outline: none;
}

textarea {
  resize: vertical;
}

button {
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  background: #1976D2;
  color: white;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.3s, transform 0.2s;
}

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

button:hover:not(:disabled) {
  background: #0D47A1;
  transform: translateY(-2px);
}

.hidden { display: none; }

/* Thank you page */
#thankYou {
  text-align: center;
  padding: 30px;
}

#thankYou h2 {
  color: #1976D2;
  margin-bottom: 10px;
}

#thankYou p {
  margin-bottom: 20px;
  color: #444;
}

#thankYou button {
  margin: 5px;
  min-width: 140px;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.3s;
}

#againBtn {
  background: #1976D2;
  color: #fff;
}

#againBtn:hover {
  background: #0D47A1;
}

form button[type="submit"] {
  display: block;
  margin: 20px auto 0 auto; /* ด้านบน 20px ด้านซ้าย-ขวา auto → กลาง */
}

/* ทำ animation เวลาเลือก Q1 */
.option.active {
  box-shadow: 0 0 0 3px #1976D2, 0 4px 12px rgba(0,0,0,0.15);
  transform: scale(1.08);
  animation: pop 0.25s ease;
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1.08); }
}

.error {
  color: #d32f2f;
  font-size: 14px;
  margin-top: 6px;
}
.hidden {
  display: none;
}


/* ===============
    q0 
  ================*/
select {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 14px;
  margin-bottom: 8px;
}

select:focus {
  border-color: #0055aa;
  outline: none;
  box-shadow: 0 0 5px rgba(0,85,170,0.3);
}

#q0Other {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 14px;
  margin-top: 6px;
}

#q0Other:focus {
  border-color: #0055aa;
  outline: none;
  box-shadow: 0 0 5px rgba(0,85,170,0.3);
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); color: #1976D2; }
  100% { transform: scale(1); }
}

#countdown {
  display: inline-block;
  font-weight: bold;
  color: #1976D2;
  transition: color 0.2s;
}

#countdown.animate {
  animation: pop 0.4s ease;
}


/* ===== qUser: ultra-compact, 2 คอลัมน์ ===== */
#qUserOptions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;                 /* ช่องไฟเล็กลง */
  margin-top: 6px;
}

#qUserOptions .choice-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;                 /* ระยะห่างข้อความกับ radio */
  padding: 6px 8px;         /* ลด padding */
  border: 1px solid #d9e3f0;
  border-radius: 8px;       /* มุมน้อยลง → ดูเล็กลง */
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  cursor: pointer;
  user-select: none;
  transition: border-color .2s, box-shadow .2s, transform .05s;
  min-height: 34px;         /* ↓ จาก 40px */
  font-size: 0.9rem;        /* ↓ จาก 0.95rem */
  line-height: 1.2;         /* ลด line-height */
  white-space: normal;      /* อนุญาตให้ตัดบรรทัด */
}

#qUserOptions .choice-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

/* hover/active/focus/checked (เดิม) */
#qUserOptions .choice-card:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
#qUserOptions .choice-card:active { transform: translateY(1px); }
#qUserOptions .choice-card:focus-within { outline: 3px solid rgba(25,118,210,0.18); outline-offset: 2px; }
#qUserOptions .choice-card:has(input[type="radio"]:checked) {
  border-color: #1976D2;
  box-shadow: 0 0 0 2px rgba(25,118,210,0.12);
  background: #f6faff;
  font-weight: 600;
}

/* จอแคบมาก → 1 คอลัมน์ */
@media (max-width: 340px) {
  #qUserOptions { grid-template-columns: 1fr; }
}
/* ===== qUser: Grid การ์ดเลือกผู้รับบริการ ===== */


/* --- Q1: ให้อีโมจิใหญ่ขึ้น แต่คำบรรยายเล็กลง --- */
/* กล่องตัวเลือก */
#q1Options .option {
  height: 96px;
  padding: 14px 8px;
  line-height: 1.05;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  /* ทำให้อีโมจิใหญ่เป็นค่า default */
  font-size: 3.4rem;   /* ← ขนาดอีโมจิ */
}

/* คำบรรยายใต้ไอคอนให้เล็กลง */
#q1Options .option span {
  /* ตัดบรรทัด */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;

  /* layout */
  margin-top: 6px;
  line-height: 1.2;
  min-height: 2.4em;   /* 2 บรรทัด → สูงเท่ากันทุกปุ่ม */
  text-align: center;
  word-break: break-word;

  /* ขนาดตัวหนังสือ (ทับค่าอีโมจิ) */
  font-size: 0.9rem;
}

/* มือถือ */
@media (max-width: 480px) {
  #q1Options .option {
    height: 88px;
    padding: 12px 6px;
    font-size: 2.8rem;     /* ← อีโมจิเล็กลงนิด */
  }
  #q1Options .option span {
    font-size: 0.8rem;
    line-height: 1.2;
    min-height: 2.4em;
  }
}


/* 2 ภาษา */
.lang-switch {
  display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 10px;
}
/* ปุ่มภาษา: ปกติพื้นขาว ขอบเทา */
.lang-btn {
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;          /* พื้นขาว */
  color: #1f2937;            /* ตัวอักษรเทาเข้ม */
  cursor: pointer;
  font-size: 0.95rem;
  transition: background .2s, color .2s, border-color .2s, box-shadow .2s;
}

/* hover: พื้นน้ำเงิน ตัวอักษรขาว */
.lang-btn:hover {
  background: #1976D2;
  color: #fff;
  border-color: #1976D2;
}

/* focus: มีเส้นเงาย้ำโฟกัส (สำหรับคีย์บอร์ด) */
.lang-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(25,118,210,.25);
}

/* สถานะเลือกอยู่ (active) = พื้นน้ำเงินถาวร */
.lang-btn.active {
  background: #1976D2;
  color: #fff;
  border-color: #1976D2;
  box-shadow: 0 0 0 2px rgba(25,118,210,.15);
}

/* ถ้าอยากให้ active แล้วยัง hover ต่อ ก็คงสีน้ำเงินไว้ */
.lang-btn.active:hover {
  background: #1565c0; /* น้ำเงินเข้มลงนิด */
  border-color: #1565c0;
}

.lang-switch.hidden { display: none !important; }

#thankTitle { white-space: pre-line; }
