/* INZONE Run Club — ธีมหน้าเว็บ (มือถือเป็นหลัก, ใช้ในเว็บวิว LINE)
   ปรับสีแบรนด์ได้ที่ --accent ตัวเดียว */
:root {
  --bg: #0d0f12;
  --bg-soft: #161a1f;
  --card: #1c2128;
  --line: #2a313a;
  --text: #f2f5f8;
  --muted: #9aa5b1;
  --accent: #16d3a0;        /* สีแบรนด์หลัก — เปลี่ยนที่นี่ */
  --accent-ink: #05231b;
  --danger: #ff6b6b;
  --gold: #ffce54;
  --radius: 18px;
  --pad: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans Thai', 'Helvetica Neue', sans-serif;
  min-height: 100vh; line-height: 1.5; font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 480px; margin: 0 auto; padding: var(--pad); padding-bottom: 40px; }

/* ---- แถบบน ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: .3px; flex: 1; justify-content: center; }
.brand .brand-logo { height: 24px; width: auto; display: block; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.icon-btn {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  background: var(--bg-soft); border: 1px solid var(--line); color: var(--text);
  font-size: 22px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { transform: scale(.94); }
/* กันแถบเบี้ยว: ปุ่มภาษามีความกว้างขั้นต่ำเท่าปุ่มกลม */
.topbar .lang-btn { flex: 0 0 auto; min-width: 44px; }
.lang-btn {
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.lang-btn:active { transform: scale(.96); }

/* ---- การ์ด ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--pad); margin-bottom: 16px; }
.card-hero {
  background: radial-gradient(120% 140% at 0% 0%, rgba(22,211,160,.22), transparent 55%), var(--card);
  border-color: rgba(22,211,160,.35);
}

.hello { color: var(--muted); font-size: 14px; }
.name { font-size: 20px; font-weight: 800; margin-top: 2px; }

.km-big { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 4px; }
.km-big .num { font-size: 54px; font-weight: 900; line-height: 1; letter-spacing: -1px; }
.km-big .unit { font-size: 18px; color: var(--muted); font-weight: 700; }
.tier-pill {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 6px;
  background: var(--accent); color: var(--accent-ink); font-weight: 800;
  border-radius: 999px; padding: 5px 14px; font-size: 14px;
}

/* ---- progress ---- */
.progress { margin-top: 16px; }
.progress .track { height: 12px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress .fill { height: 100%; background: linear-gradient(90deg, var(--accent), #4ff0c6); border-radius: 999px; transition: width .6s ease; }
.progress .label { margin-top: 8px; font-size: 14px; color: var(--muted); }
.progress .label b { color: var(--text); }

/* ---- ตรา ---- */
.section-title { font-size: 14px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 10px; }
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.badge { text-align: center; font-size: 12px; }
.badge .badge-ring {
  width: 62px; height: 62px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 26px; margin: 0 auto 6px;
}
.badge.earned .badge-ring { background: rgba(255,206,84,.15); border: 2px solid var(--gold); }
.badge.earned span { color: var(--text); }
.badge.empty .badge-ring { background: var(--bg-soft); border: 2px dashed var(--line); color: var(--muted); }
.badge.empty span { color: var(--muted); }

/* ---- ประวัติ ---- */
.history-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.history-item:last-child { border-bottom: 0; }
.history-item .r { font-size: 15px; }
.history-item .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.history-item .k { font-weight: 800; color: var(--accent); }

/* ---- ฟอร์ม ---- */
label.field { display: block; margin-bottom: 16px; }
label.field .lbl { display: block; font-size: 14px; font-weight: 700; margin-bottom: 7px; }
input, select {
  width: 100%; background: var(--bg-soft); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; font-size: 16px; font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.row-2 { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }

.consent { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--muted); margin: 6px 0 18px; }
.consent input { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 1px; }
.consent a { color: var(--accent); }

/* ---- ปุ่ม ---- */
.btn {
  width: 100%; background: var(--accent); color: var(--accent-ink); border: 0;
  border-radius: 14px; padding: 16px; font-size: 17px; font-weight: 800; cursor: pointer;
  font-family: inherit;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn + .btn { margin-top: 10px; }

/* ---- สถานะ / ผลลัพธ์ ---- */
.result { text-align: center; padding: 30px 0; }
.result .emoji { font-size: 64px; }
.result .big { font-size: 26px; font-weight: 900; margin: 12px 0 6px; }
.result .sub { color: var(--muted); }
.tierup {
  margin-top: 16px; background: rgba(255,206,84,.12); border: 1px solid var(--gold);
  color: var(--gold); border-radius: 12px; padding: 12px; font-weight: 700; text-align: center;
}

/* ---- toast / loading ---- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120%);
  max-width: 90%; padding: 13px 18px; border-radius: 12px; font-size: 14px; font-weight: 600;
  transition: transform .3s ease; z-index: 50; text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.info { background: var(--bg-soft); border: 1px solid var(--line); color: var(--text); }
.toast.error { background: #3a1d1f; border: 1px solid var(--danger); color: #ffd5d5; }
.toast.success { background: #10352a; border: 1px solid var(--accent); color: #c9ffee; }

#loading {
  position: fixed; inset: 0; background: rgba(13,15,18,.8); display: none;
  align-items: center; justify-content: center; z-index: 60;
}
.spinner { width: 42px; height: 42px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- modal สถานะ ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5,7,10,.72); z-index: 70;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .25s ease; padding: 0;
}
.modal-overlay.show { opacity: 1; }
.modal {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 22px 22px 0 0; padding: 24px 20px 30px; width: 100%; max-width: 480px;
  position: relative; transform: translateY(100%); transition: transform .3s cubic-bezier(.2,.9,.3,1);
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal-x {
  position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg-soft); border: 1px solid var(--line); color: var(--muted);
  font-size: 15px; cursor: pointer;
}
@media (min-width: 520px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 22px; }
}
ul.perks { list-style: none; display: flex; flex-direction: column; gap: 10px; }
ul.perks li {
  position: relative; padding-left: 26px; font-size: 15px; color: var(--text);
}
ul.perks li::before {
  content: '✓'; position: absolute; left: 0; top: 0;
  color: var(--accent); font-weight: 900;
}

/* ---- หน้าสิทธิ์แต่ละระดับ ---- */
.tier-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px; position: relative; overflow: hidden;
}
.tier-card.locked { opacity: .62; }
.tier-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tier-card .thead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.tier-card .tname { font-size: 19px; font-weight: 800; }
.tier-card .treq { font-size: 13px; color: var(--muted); font-weight: 700; }
.tier-card .badge-you {
  display: inline-block; background: var(--accent); color: var(--accent-ink);
  font-size: 12px; font-weight: 800; border-radius: 999px; padding: 3px 10px; margin-bottom: 10px;
}
.tier-card .status-need {
  font-size: 12px; font-weight: 700; color: var(--gold); margin-bottom: 8px;
}
.tier-card ul.perks { margin-top: 8px; }

.center-min { min-height: 70vh; display: flex; flex-direction: column; justify-content: center; }
.muted { color: var(--muted); }
.pop { animation: pop .5s cubic-bezier(.2,1.4,.5,1); }
@keyframes pop { 0% { transform: scale(.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
