:root {
  --cream: #FBF7EF;
  --white: #FFFFFF;
  --green: #418C5D;
  --green-dark: #2F6A45;
  --green-light: #E6F2EA;
  --lime: #E3E96A;
  --lime-light: #F7F9D9;
  --orange: #EC6E0C;
  --orange-text: #B85407;
  --orange-light: #FDEBDD;
  --text: #3A3326;
  --text-2: #7A6F5C;
  --border: #E3D9C4;
  --danger: #B5523B;
  --radius-card: 14px;
  --radius-pill: 20px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--cream);
  color: var(--text);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; display: block; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wrap { width: min(960px, 100% - 32px); margin-inline: auto; }

/* ---------- Top bar ---------- */
.topbar { padding: 14px 0; }
.topbar .wrap { display: flex; align-items: center; gap: 12px; }
.topbar img { width: 44px; height: 44px; flex: none; }
.topbar strong { display: block; font-size: 20px; font-weight: 700; color: var(--green-dark); line-height: 1.3; }
.topbar small { display: block; font-size: 13px; color: var(--text-2); }
.topbar .logout { margin-left: auto; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 22px;
  border-radius: var(--radius-pill); border: 1px solid var(--border);
  background: var(--white); color: var(--text);
  font-weight: 500; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--green); }
.btn:active { transform: scale(.98); }
.btn:focus-visible, .field:focus-visible, .choice:focus-within { outline: 3px solid var(--lime); outline-offset: 2px; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); min-height: 36px; padding: 4px 12px; font-size: 14px; }
.btn-ghost:hover { color: var(--green-dark); border-color: transparent; }
.btn-block { width: 100%; }

.field {
  width: 100%; min-height: 48px; padding: 10px 18px;
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: var(--white); outline: none;
}
.field::placeholder { color: #A69A83; }
.field:focus { border-color: var(--green); }

.label { display: block; font-size: 14px; color: var(--text-2); margin: 0 0 6px 4px; }
.error { color: var(--danger); font-size: 14px; margin: 8px 4px 0; min-height: 1.2em; }

/* ---------- Gate ---------- */
.gate { padding: 8px 0 48px; }
.gate-card {
  max-width: 460px; margin: 0 auto; padding: 24px;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-card);
  text-align: center;
}
.gate-art { position: relative; margin: -4px auto 12px; max-width: 360px; }
.gate-art .kids { position: absolute; left: 50%; bottom: 4%; width: 40%; transform: translateX(-50%); }
.gate-card h1 { font-size: 22px; margin: 0; color: var(--green-dark); }
.gate-card p { margin: 4px 0 16px; color: var(--text-2); }
.gate-form { display: flex; gap: 8px; }
.gate-form .field { text-align: center; letter-spacing: .3em; font-size: 20px; }
.gate-form .btn { flex: none; white-space: nowrap; }

/* ---------- Hero ---------- */
.hero { position: relative; border-radius: var(--radius-card); overflow: hidden; border: 1px solid var(--border); }
.hero picture img { width: 100%; height: 300px; object-fit: cover; object-position: 60% 70%; }
.hero-text { position: absolute; left: 32px; top: 32px; max-width: 46%; }
.hero-text h1 { margin: 0; font-size: 30px; line-height: 1.35; color: var(--green-dark); }
.hero-text p { margin: 8px 0 0; color: var(--text); }
.hero .boy { position: absolute; right: 23%; bottom: 44px; height: 180px; width: auto; }

/* ---------- Panel ---------- */
.panel {
  position: relative; margin: -36px 16px 0; padding: 24px;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-card);
}
.panel h2 { font-size: 18px; margin: 0 0 12px; color: var(--green-dark); }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--text-2); }
.search-box .field { padding-left: 48px; font-size: 17px; }

.suggest { list-style: none; margin: 12px 0 0; padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.suggest li + li { border-top: 1px solid var(--border); }
.suggest button {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 10px 16px; background: none; border: 0; cursor: pointer;
}
.suggest button:hover, .suggest button:focus-visible { background: var(--green-light); outline: none; }
.suggest .s-main { flex: 1; min-width: 0; }
.suggest .s-name { font-weight: 500; }
.suggest .s-addr { display: block; font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest .s-fee { flex: none; font-weight: 700; color: var(--orange-text); }
.suggest mark { background: var(--lime); color: inherit; border-radius: 3px; padding: 0 1px; }

.google-cta { margin-top: 12px; padding: 14px 16px; border-radius: 12px; background: var(--lime-light); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.google-cta p { margin: 0; flex: 1; min-width: 200px; font-size: 14px; color: var(--text); }

.empty { position: relative; text-align: center; padding-top: 8px; }
.empty .girl { height: 180px; width: auto; margin: 0 auto -52px; position: relative; z-index: 1; }
.empty .grass { width: 100%; max-width: 520px; margin: 0 auto; }
.empty p { margin: 8px 0 0; color: var(--text-2); font-size: 14px; }
.empty strong { color: var(--text); font-size: 16px; display: block; }

/* ---------- Candidates ---------- */
.notice { margin: 0 0 14px; padding: 10px 14px; border-radius: 12px; background: var(--orange-light); color: var(--orange-text); font-size: 14px; }
.choices { display: grid; gap: 10px; margin: 0 0 16px; }
.choice {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px;
  border: 1px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--white);
}
.choice:hover { border-color: var(--green); }
.choice input { margin-top: 6px; accent-color: var(--green); width: 18px; height: 18px; flex: none; }
.choice.is-checked { border-color: var(--green); background: var(--green-light); }
.choice .c-name { font-weight: 500; }
.choice .c-addr { display: block; font-size: 13px; color: var(--text-2); }
.tag { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 10px; font-size: 12px; background: var(--green); color: #fff; vertical-align: 2px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* ---------- Loading ---------- */
.loading { text-align: center; padding: 24px 0 8px; }
.road { position: relative; height: 90px; max-width: 420px; margin: 0 auto; overflow: hidden; }
.road::after { content: ""; position: absolute; left: 0; right: 0; bottom: 10px; border-bottom: 3px dashed var(--border); }
.road img { position: absolute; bottom: 12px; width: 110px; animation: drive 2.4s linear infinite; }
@keyframes drive { from { left: -120px; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .road img { animation: none; left: calc(50% - 55px); } }
.loading p { color: var(--text-2); margin: 8px 0 0; }

/* ---------- Not found ---------- */
.notfound { display: flex; align-items: flex-end; justify-content: center; gap: 0; }
.notfound .boy { height: 200px; width: auto; margin-right: -18px; position: relative; z-index: 1; }
.notfound .sign { height: 220px; width: auto; }
.notfound-text { text-align: center; }
.notfound-text strong { display: block; font-size: 18px; color: var(--green-dark); }
.notfound-text p { margin: 4px 0 0; color: var(--text-2); font-size: 14px; }

/* ---------- Result ---------- */
.result { position: relative; padding-top: 8px; }
.result .leaf { position: absolute; right: -26px; top: -18px; width: 118px; pointer-events: none; }
.result .calc, .result .amount { position: relative; z-index: 1; }
.result .calc { width: calc(100% - 64px); }
.result .girl { position: absolute; right: 30px; top: -128px; height: 150px; width: auto; pointer-events: none; }
.result h2 { margin: 0; font-size: 22px; padding-right: 150px; }
.result .addr { margin: 2px 0 16px; font-size: 14px; color: var(--text-2); padding-right: 150px; }
.calc { width: 100%; border-collapse: collapse; }
.calc th, .calc td { padding: 8px 4px; border-bottom: 1px dashed var(--border); text-align: left; font-weight: 400; }
.calc th { color: var(--text-2); width: 40%; }
.calc td { text-align: right; }
.calc small { color: var(--text-2); }
.amount {
  margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--green-light);
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.amount > span { color: var(--green-dark); font-weight: 500; }
.amount strong { font-size: 32px; color: var(--orange-text); line-height: 1.2; }
.amount strong small { font-size: 16px; margin-left: 4px; }
.meta { margin: 10px 0 0; font-size: 13px; color: var(--text-2); }

/* ---------- All places ---------- */
.all { margin: 24px 16px 0; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-card); }
.all summary { padding: 14px 20px; cursor: pointer; font-weight: 500; color: var(--green-dark); }
.all .table-wrap { padding: 0 20px 16px; overflow-x: auto; }
.all table { width: 100%; border-collapse: collapse; font-size: 14px; }
.all th, .all td { padding: 8px 6px; border-top: 1px solid var(--border); text-align: left; white-space: nowrap; }
.all th { color: var(--text-2); font-weight: 400; }
.all td.num, .all th.num { text-align: right; }
.all td a { color: var(--green-dark); }

/* ---------- Footer ---------- */
footer { padding: 28px 0 40px; text-align: center; font-size: 13px; color: var(--text-2); }
footer p { margin: 2px 0; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .topbar strong { font-size: 18px; }
  .hero picture img { height: 220px; object-position: 50% 80%; }
  .hero-text { left: 18px; top: 16px; max-width: 80%; }
  .hero-text h1 { font-size: 22px; }
  .hero-text p { display: none; }
  .hero .boy { display: none; }
  .panel { margin: -24px 0 0; padding: 18px 16px; }
  .all { margin: 20px 0 0; }
  .result .girl { height: 110px; top: -96px; right: 12px; }
  .result .leaf { display: none; }
  .result .calc { width: 100%; }
  .calc th { width: auto; white-space: nowrap; }
  .calc small { display: block; }
  .result h2, .result .addr { padding-right: 90px; }
  .notfound .boy { height: 150px; }
  .notfound .sign { height: 170px; }
  .gate-form { flex-direction: column; }
  .actions .btn { flex: 1; }
}
