* {
  box-sizing: border-box;
}

:root {
  --navy: #14274E;
  --blue: #1B5DB8;
  --sky: #3FC1E0;
  --orange: #FF7A3D;
  --orange-dark: #E85D1F;
  --bg: #F2F7FC;
  --card-bg: #FFFFFF;
  --text-muted: #6B7A99;
  --line-green: #06C755;
  --stripe: linear-gradient(90deg, var(--navy), var(--blue), var(--sky), var(--orange));
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 10% -10%, rgba(63, 193, 224, 0.16), transparent 45%),
    radial-gradient(circle at 110% 10%, rgba(255, 122, 61, 0.12), transparent 40%);
  font-family: 'Sarabun', -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--navy);
  padding: 32px 0;
}

h1,
h2,
.font-display {
  font-family: 'Kanit', 'Sarabun', sans-serif;
}

/* ---------- การ์ดหลัก (ใช้ทุกหน้า) ---------- */
/* ---------- แถบโลโก้พันธมิตร (แสดงในกรอบการ์ดเดียวกัน ด้านบนสุด) ---------- */
.partner-logos {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px dashed rgba(20, 39, 78, 0.12);
}

.partner-logos img {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 32px 26px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 16px 36px rgba(20, 39, 78, 0.10);
  position: relative;
  border-top: 6px solid transparent;
  background-image: linear-gradient(var(--card-bg), var(--card-bg)), var(--stripe);
  background-origin: border-box;
  background-clip: padding-box, border-box;
}

.card h1 {
  margin: 4px 0 12px;
  font-size: 23px;
  font-weight: 700;
  color: var(--navy);
}

.card p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 20px;
}

/* ---------- ปุ่ม LINE (คงสีเขียวแบรนด์ LINE ไว้ตามเดิม) ---------- */
.btn-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--line-green);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  padding: 13px 20px;
  border-radius: 12px;
  width: 100%;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.btn-line:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
}

/* ---------- ปุ่มหลัก (สีส้ม ใช้กับ action สำคัญ: ส่ง/แลก/ยืนยัน) ---------- */
.btn-primary {
  display: block;
  width: 100%;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  font-family: 'Kanit', sans-serif;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.btn-primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background: #cfd6e3;
  cursor: not-allowed;
  transform: none;
}

/* ---------- ปุ่มรอง (สีน้ำเงิน โครงเส้น ใช้กับลิงก์นำทาง) ---------- */
.btn-secondary {
  display: block;
  margin-top: 10px;
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding: 11px;
  border-radius: 10px;
  border: 1.5px solid rgba(27, 93, 184, 0.25);
  background: rgba(27, 93, 184, 0.04);
  transition: background 0.15s ease;
}

.btn-secondary:hover {
  background: rgba(27, 93, 184, 0.09);
}

/* ---------- ปุ่มลัด 3 ช่อง แบบสี่เหลี่ยมจัตุรัส (หน้าแรก) ---------- */
.action-grid {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.action-tile {
  flex: 1;
  position: relative;
  display: block;
  text-decoration: none;
  color: var(--blue);
  border: 1.5px solid rgba(27, 93, 184, 0.25);
  background: rgba(27, 93, 184, 0.04);
  border-radius: 14px;
  transition: background 0.15s ease, transform 0.15s ease;
}

.action-tile:hover {
  background: rgba(27, 93, 184, 0.09);
  transform: translateY(-1px);
}

/* เทคนิคบังคับให้เป็นสี่เหลี่ยมจัตุรัสเสมอ ไม่ว่าจอจะกว้างแค่ไหน:
   padding-top เป็น % จะคำนวณจากความกว้างของกล่องเสมอ ทำให้สูง=กว้างพอดี */
.action-tile::before {
  content: '';
  display: block;
  padding-top: 100%;
}

.action-tile-inner {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px;
  text-align: center;
}

.action-icon {
  font-size: 26px;
  line-height: 1;
}

.action-label {
  font-weight: 600;
  font-size: 12px;
  line-height: 1.3;
  font-family: 'Kanit', sans-serif;
}

.avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 16px;
  border: 3px solid var(--sky);
  box-shadow: 0 0 0 4px rgba(63, 193, 224, 0.15);
}

.name {
  font-weight: 700;
  font-size: 17px;
  margin: 4px 0;
  font-family: 'Kanit', sans-serif;
}

.uid code {
  background: var(--bg);
  color: var(--blue);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  word-break: break-all;
}

/* ---------- แถบยอดสะสม (เหรียญ) ---------- */
.balance-box {
  background: linear-gradient(135deg, var(--navy), var(--blue));
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  color: #fff;
  margin-bottom: 20px;
}

.balance-box .label {
  font-size: 13px;
  opacity: 0.85;
  font-family: 'Sarabun', sans-serif;
}

.balance-box .amount {
  font-size: 42px;
  font-weight: 800;
  margin: 4px 0;
  font-family: 'Kanit', sans-serif;
  color: var(--orange);
  text-shadow: 0 2px 12px rgba(255, 122, 61, 0.35);
}

.balance-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(27, 93, 184, 0.06);
  border: 1px solid rgba(27, 93, 184, 0.2);
  border-radius: 12px;
  padding: 13px 18px;
  margin-bottom: 20px;
  font-weight: 600;
  font-size: 14px;
  color: var(--navy);
}

.balance-strip .amount {
  color: var(--orange);
  font-size: 19px;
  font-family: 'Kanit', sans-serif;
}

/* ---------- ประวัติ (เหรียญ / รายการ) ---------- */
.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px dashed rgba(20, 39, 78, 0.12);
}

.history-row:last-child {
  border-bottom: none;
}

.history-reason {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  text-align: left;
}

.history-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  text-align: left;
}

.history-amount {
  font-size: 16px;
  font-weight: 700;
  font-family: 'Kanit', sans-serif;
}

/* ---------- การ์ดของรางวัล ---------- */
.reward-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px dashed rgba(20, 39, 78, 0.12);
}

.reward-card:last-child {
  border-bottom: none;
}

.reward-icon {
  font-size: 30px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(63, 193, 224, 0.18), rgba(27, 93, 184, 0.10));
  border-radius: 12px;
  flex-shrink: 0;
}

.reward-info {
  flex: 1;
  text-align: left;
}

.reward-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
}

.reward-cost {
  font-size: 12.5px;
  color: var(--orange-dark);
  font-weight: 700;
  margin-top: 2px;
}

.redeem-btn {
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Kanit', sans-serif;
  cursor: pointer;
  flex-shrink: 0;
}

.redeem-btn:disabled {
  background: #d7dce6;
  color: #8a93a6;
  cursor: not-allowed;
}

/* ---------- หน้าถ่ายรูป: ปุ่มเลือกไฟล์ ---------- */
.capture-preview {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 14px;
  margin-bottom: 16px;
  display: none;
  border: 1px solid rgba(20, 39, 78, 0.08);
}

.picker-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.picker-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 2px dashed var(--sky);
  border-radius: 14px;
  padding: 20px 8px;
  color: var(--blue);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  background: rgba(63, 193, 224, 0.06);
  transition: border-color 0.15s ease, background 0.15s ease;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
}

.picker-btn .icon {
  font-size: 26px;
}

/* ---------- กล้องสด (getUserMedia) ตอนกดปุ่ม "เปิดกล้องถ่ายภาพ" ---------- */
.camera-modal {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-modal video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-modal-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 0 20px;
}

.camera-modal-actions .btn-secondary,
.camera-modal-actions .btn-primary {
  width: auto;
  margin-top: 0;
  padding: 13px 24px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.camera-modal-actions .btn-secondary {
  background: rgba(255, 255, 255, 0.92);
}

/* ---------- แบนเนอร์เตือนตอนเปิดผ่านเบราว์เซอร์ในแอป (Messenger/FB/IG ฯลฯ) ---------- */
.inapp-browser-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
  background: #FFF3E0;
  color: #7A3E00;
  font-size: 12.5px;
  line-height: 1.5;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  text-align: center;
  border-bottom: 1px solid rgba(232, 93, 31, 0.3);
}

.picker-btn.has-file {
  border-style: solid;
  border-color: var(--orange);
  background: rgba(255, 122, 61, 0.08);
  color: var(--orange-dark);
}

input[type="file"] {
  display: none;
}

textarea {
  width: 100%;
  border: 1.5px solid rgba(20, 39, 78, 0.12);
  border-radius: 12px;
  padding: 11px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 60px;
  margin-bottom: 16px;
  box-sizing: border-box;
  background: var(--bg);
}

textarea:focus {
  outline: none;
  border-color: var(--sky);
}

/* ---------- แจ้งเตือนสำเร็จแบบ badge ---------- */
.result-badge {
  font-size: 20px;
  font-weight: 800;
  color: var(--orange);
  margin: 16px 0;
  font-family: 'Kanit', sans-serif;
}

.result-badge .sub {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 400;
  font-family: 'Sarabun', sans-serif;
}

.claim-note {
  background: rgba(255, 122, 61, 0.08);
  border: 1px dashed var(--orange);
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  color: var(--orange-dark);
  margin-top: 16px;
}

/* ---------- แถบมุมขวาบน (รวมกระดิ่งแจ้งเตือน + ปุ่มออกจากระบบไว้ด้วยกัน กันซ้อนทับ) ---------- */
.topbar {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- กระดิ่งแจ้งเตือน ---------- */
.notif-bell-wrap {
  position: relative;
}

.notif-bell {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #fff;
  box-shadow: 0 6px 18px rgba(20, 39, 78, 0.18);
  font-size: 19px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notif-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--orange);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  font-family: 'Kanit', sans-serif;
}

.notif-panel {
  position: fixed;
  top: 68px;
  right: 16px;
  left: auto;
  width: min(300px, calc(100vw - 32px));
  max-height: 380px;
  overflow-y: auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 16px 36px rgba(20, 39, 78, 0.2);
  padding: 8px;
  z-index: 600;
}

.notif-panel-header {
  font-family: 'Kanit', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--navy);
  padding: 8px 10px;
  border-bottom: 1px solid rgba(20, 39, 78, 0.08);
  margin-bottom: 4px;
}

.notif-item {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  text-align: left;
}

.notif-item-unread {
  background: rgba(63, 193, 224, 0.09);
}

.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.notif-msg {
  font-size: 12.5px;
  color: var(--navy);
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: break-word;
}

.notif-date {
  font-size: 10.5px;
  color: #8a93a6;
  margin-top: 3px;
}

/* ---------- ปุ่มออกจากระบบ (อยู่ใน .topbar ร่วมกับกระดิ่ง) ---------- */
.logout-btn {
  background: #fff;
  border: 1.5px solid rgba(232, 93, 31, 0.35);
  color: #E85D1F;
  font-family: 'Kanit', sans-serif;
  font-weight: 600;
  font-size: 12.5px;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(20, 39, 78, 0.12);
}

.logout-btn:hover {
  background: rgba(232, 93, 31, 0.06);
}

/* ---------- แถบเมนูแอดมิน มุมซ้ายบน (ใช้ร่วมกันทุกหน้าโซนแอดมิน) ---------- */
.admin-nav {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 500;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  max-width: calc(100vw - 32px);
}

.admin-nav-link {
  background: #fff;
  border: 1.5px solid rgba(27, 93, 184, 0.3);
  color: var(--blue);
  font-family: 'Kanit', sans-serif;
  font-weight: 600;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 999px;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(20, 39, 78, 0.12);
  white-space: nowrap;
}

.admin-nav-link-active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* ---------- popup กรอกข้อมูลจัดส่งตอนแลกของรางวัล ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 39, 78, 0.5);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: #fff;
  border-radius: 18px;
  padding: 24px;
  max-width: 360px;
  width: 100%;
  text-align: left;
}

.modal-box h2 {
  font-family: 'Kanit', sans-serif;
  font-size: 17px;
  margin: 0 0 4px;
  color: var(--navy);
}

.modal-box .modal-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.modal-box label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 4px;
}

.modal-box textarea,
.modal-box input {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid rgba(20, 39, 78, 0.15);
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 14px;
  background: var(--bg);
}

.modal-box textarea:focus,
.modal-box input:focus {
  outline: none;
  border-color: var(--sky);
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .btn-secondary,
.modal-actions .btn-primary {
  margin-top: 0;
}

/* ---------- ไอคอนสีฟ้า (แทนอีโมจิ) ---------- */
.ico {
  width: 1.15em;
  height: 1.15em;
  object-fit: contain;
  vertical-align: -0.2em;
  margin-right: .3em;
  flex-shrink: 0;
}

.card h1 .ico {
  width: 1.2em;
  height: 1.2em;
  margin-right: 8px;
  vertical-align: -0.22em;
}

.btn-primary img.ico {
  filter: brightness(0) invert(1);
}

/* ปุ่มส้ม: ไอคอนขาว */
.notif-bell .ico {
  width: 22px;
  height: 22px;
  margin: 0;
  vertical-align: middle;
}

.notif-panel-header .ico {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
}

.logout-btn .ico {
  width: 16px;
  height: 16px;
  margin-right: 4px;
}

.reward-icon .ico {
  width: 30px;
  height: 30px;
  margin: 0;
}

.modal-box h2 .ico {
  width: 1.1em;
  height: 1.1em;
  margin-right: 6px;
}

.my-photo-status .ico {
  width: 13px;
  height: 13px;
  margin-right: 3px;
  vertical-align: -2px;
}

.vf label.proof-btn .pi .ico {
  width: 48px;
  height: 48px;
  margin: 0;
}

/* ---------- ขนาดไอคอนรูปภาพชุดใหม่ (img/icons/*.png) ---------- */
.action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-icon .ico {
  width: 52px;
  height: 52px;
  margin: 0;
  vertical-align: middle;
}

.picker-btn .icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.picker-btn .ico {
  width: 64px;
  height: 64px;
  margin: 0;
  vertical-align: middle;
}

.balance-strip .ico {
  width: 30px;
  height: 30px;
}

.balance-box .label .ico {
  width: 28px;
  height: 28px;
}

.result-badge .ico {
  display: block;
  width: 110px;
  height: 110px;
  margin: 0 auto 8px;
}

.btn-secondary .ico {
  width: 22px;
  height: 22px;
}

.history-row .ico {
  width: 28px;
  height: 28px;
  margin: 0 8px 0 0;
}