@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700&family=IBM+Plex+Sans+Thai:wght@300;400;500;600;700&display=swap");

:root {
  --ink: #10140e;
  --paper: #f5f1e8;
  --muted: #b8b6ab;
  --line: rgba(203, 224, 141, 0.24);
  --matcha: #9fbe52;
  --matcha-dark: #597426;
  --panel: #171e13;
  --danger: #ec8c7a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--paper);
  background:
    linear-gradient(120deg, rgba(93, 119, 38, 0.16), transparent 42%),
    var(--ink);
  font-family: "IBM Plex Sans Thai", sans-serif;
}

button,
input,
select,
textarea { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

.shell {
  width: min(1180px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
}

.topbar {
  min-height: 94px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--paper);
  text-decoration: none;
  font-family: Cinzel, serif;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.brand span {
  color: var(--matcha);
  font-size: 0.62rem;
  letter-spacing: 1.5px;
  margin-left: 8px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-actions a,
.back-link,
.text-button {
  color: var(--matcha);
  text-decoration: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 0.9rem;
}

.hero {
  min-height: calc(100vh - 94px);
  max-width: 760px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 80px 0 120px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--matcha);
  font-family: Cinzel, serif;
  font-size: 0.72rem;
  letter-spacing: 1.8px;
}

h1,
h2,
h3,
p { margin-top: 0; }

h1,
h2,
h3 {
  font-family: Cinzel, "IBM Plex Sans Thai", sans-serif;
}

h1 {
  max-width: 720px;
  margin-bottom: 24px;
  font-size: clamp(2.5rem, 7vw, 5.6rem);
  line-height: 1.13;
  font-weight: 600;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.lead {
  max-width: 640px;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.9;
}

.google-button,
.primary-button {
  width: fit-content;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
  padding: 0 20px;
  color: #10140e;
  background: var(--matcha);
  border: 1px solid var(--matcha);
  border-radius: 5px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.google-button:hover,
.primary-button:hover { transform: translateY(-2px); background: #bbd96d; }

.google-button span {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: white;
  background: #4285f4;
  border-radius: 50%;
  font-weight: 700;
}

.loading-state {
  min-height: calc(100vh - 94px);
  display: grid;
  place-items: center;
}

.loader {
  width: 34px;
  height: 34px;
  border: 2px solid rgba(159, 190, 82, 0.18);
  border-top-color: var(--matcha);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

.notice,
.form-result {
  margin-top: 22px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  color: var(--paper);
  background: rgba(159, 190, 82, 0.08);
}

.member { padding: 70px 0 100px; }

.member-intro {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  align-items: end;
  padding-bottom: 54px;
  border-bottom: 1px solid var(--line);
}

.member-intro h1 { margin-bottom: 8px; font-size: clamp(2.2rem, 5vw, 4rem); }

.muted { margin: 0; color: var(--muted); }

.member-code {
  min-width: 225px;
  padding: 20px;
  border: 1px solid rgba(159, 190, 82, 0.6);
  background: rgba(159, 190, 82, 0.06);
}

.member-code span {
  display: block;
  margin-bottom: 8px;
  color: var(--matcha);
  font-family: Cinzel, serif;
  font-size: 0.65rem;
  letter-spacing: 1.5px;
}

.member-code strong {
  font-family: Cinzel, serif;
  font-size: 1.5rem;
  letter-spacing: 2px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin: 70px 0 28px;
}

.count {
  color: var(--matcha);
  font-family: Cinzel, serif;
  font-size: 0.72rem;
  letter-spacing: 1px;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.badge {
  min-height: 310px;
  display: flex;
  flex-direction: column;
  padding: 23px;
  background:
    linear-gradient(135deg, rgba(159, 190, 82, 0.14), transparent 52%),
    var(--panel);
  border: 1px solid var(--line);
}

.badge-top,
.badge-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--matcha);
  border: 1px solid var(--matcha);
  font-family: Cinzel, serif;
  font-size: 0.85rem;
  font-weight: 700;
}

.badge-level,
.badge-type,
.badge-bottom {
  color: var(--matcha);
  font-family: Cinzel, serif;
  font-size: 0.62rem;
  letter-spacing: 1.1px;
  text-transform: uppercase;
}

.badge-type { margin: 40px 0 9px; }

.badge h3 {
  margin-bottom: 12px;
  font-size: 1.45rem;
  line-height: 1.35;
}

.badge-description {
  margin-bottom: 25px;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.7;
}

.badge-bottom { margin-top: auto; color: var(--muted); }

.empty-state {
  grid-column: 1 / -1;
  padding: 46px 25px;
  border: 1px dashed var(--line);
  text-align: center;
}

.empty-state h3 { margin-bottom: 10px; font-size: 1.6rem; }
.empty-state p:last-child { margin: 0; color: var(--muted); }

.admin-wrap {
  max-width: 700px;
  padding: 72px 0 100px;
}

.admin-wrap h1 { margin-bottom: 14px; font-size: clamp(2.4rem, 5vw, 4.2rem); }

.admin-form,
.search-panel {
  margin-top: 42px;
  padding: 25px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.admin-form { display: grid; gap: 20px; }

label {
  display: grid;
  gap: 8px;
  color: var(--paper);
  font-size: 0.9rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px;
  color: var(--paper);
  background: #10140e;
  border: 1px solid rgba(245, 241, 232, 0.22);
  border-radius: 3px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus { border-color: var(--matcha); }

textarea { resize: vertical; }

.primary-button { width: 100%; margin: 0; }

.form-result { display: none; margin: 0; }
.form-result:not(:empty) { display: block; }
.form-result.success { border-color: var(--matcha); color: var(--matcha); }
.form-result.error { border-color: var(--danger); color: var(--danger); }

.search-panel { margin-top: 20px; }

.search-results {
  display: grid;
  gap: 8px;
  margin-top: 15px;
}

.user-result {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  color: var(--paper);
  background: #10140e;
  border: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
}

.user-result strong { color: var(--matcha); }
.user-result span { color: var(--muted); font-size: 0.82rem; }

@media (max-width: 760px) {
  .shell { width: min(100% - 28px, 1180px); }

  .topbar { min-height: 72px; }

  .member { padding-top: 42px; }

  .member-intro {
    display: grid;
    align-items: start;
    padding-bottom: 35px;
  }

  .member-code { width: 100%; }

  .badge-grid { grid-template-columns: 1fr; }

  .badge { min-height: 280px; }

  .section-heading { margin-top: 48px; }

  .header-actions { gap: 12px; }

  .user-result { display: grid; }
}

.profile-settings {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 35px;
  margin-top: 42px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.profile-settings h2 {
  margin-bottom: 10px;
  font-size: 1.45rem;
}

.profile-form {
  display: grid;
  align-content: start;
  gap: 9px;
}

.profile-form label {
  color: var(--muted);
  font-size: 0.82rem;
}

.profile-form-row {
  display: flex;
  gap: 10px;
}

.profile-form-row input {
  min-width: 0;
  flex: 1;
}

.profile-form-row .primary-button {
  width: auto;
  min-width: 110px;
  margin: 0;
}

.badge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.badge-share,
.badge-copy {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  color: var(--matcha);
  background: transparent;
  border: 1px solid var(--line);
  font-size: 0.78rem;
  text-decoration: none;
  cursor: pointer;
}

.badge-share:hover,
.badge-copy:hover {
  color: #10140e;
  background: var(--matcha);
  border-color: var(--matcha);
}

@media (max-width: 760px) {
  .profile-settings {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .profile-form-row {
    display: grid;
  }

  .profile-form-row .primary-button {
    width: 100%;
  }
}

.profile-settings {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
  gap: 35px;
  margin-top: 42px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.profile-settings h2 {
  margin-bottom: 10px;
  font-size: 1.45rem;
}

.profile-form {
  display: grid;
  align-content: start;
  gap: 9px;
}

.profile-form label {
  color: var(--muted);
  font-size: .82rem;
}

.profile-form-row {
  display: flex;
  gap: 10px;
}

.profile-form-row input {
  min-width: 0;
  flex: 1;
}

.profile-form-row .primary-button {
  width: auto;
  min-width: 110px;
  margin: 0;
}

.name-change-warning {
  margin: 8px 0 0;
  color: #c49a46;
  font-size: .82rem;
  line-height: 1.6;
}

.name-change-warning.exhausted {
  color: #ec8c7a;
}

.profile-form input:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.badge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.badge-share,
.badge-copy {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  color: var(--matcha);
  background: transparent;
  border: 1px solid var(--line);
  font-size: .78rem;
  text-decoration: none;
  cursor: pointer;
}

.badge-share:hover,
.badge-copy:hover {
  color: #10140e;
  background: var(--matcha);
  border-color: var(--matcha);
}

.admin-name-editor {
  display: grid;
  gap: 14px;
  margin-top: 20px;
  padding: 25px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.admin-name-editor label {
  display: grid;
  gap: 7px;
  color: var(--paper);
  font-size: .9rem;
}

.admin-name-editor .primary-button {
  width: fit-content;
}

@media (max-width: 760px) {
  .profile-settings {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .profile-form-row {
    display: grid;
  }

  .profile-form-row .primary-button {
    width: 100%;
  }
}

.hero-icon {
  width: 86px;
  height: 86px;
  margin-bottom: 28px;
  overflow: hidden;
  border: 1px solid var(--matcha);
  background: #fff;
  border-radius: 14px;
}

.hero-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  padding: 7px;
}

.member-identity {
  display: flex;
  align-items: center;
  gap: 18px;
}

.member-avatar {
  width: 66px;
  height: 66px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 50%;
}

.member-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.copy-code-button {
  margin-top: 8px;
  padding: 0;
  color: var(--matcha);
  background: transparent;
  border: 0;
  text-decoration: underline;
  cursor: pointer;
  font-size: .78rem;
}

.badge-image-wrap {
  width: 72px;
  height: 72px;
  margin-bottom: 20px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.badge-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  padding: 6px;
}

.badge .badge-top {
  margin-top: 0;
}

@media (max-width: 760px) {
  .member-identity {
    align-items: flex-start;
  }

  .member-avatar {
    width: 54px;
    height: 54px;
  }

  .badge-image-wrap {
    width: 64px;
    height: 64px;
  }
}
