:root {
    --forest-950: #102b24;
    --forest-900: #183b31;
    --forest-800: #24473a;
    --forest-700: #315f4e;
    --forest-100: #dce9e2;
    --paper: #f7f4ec;
    --paper-2: #eee8dc;
    --ink: #23302b;
    --muted: #65736d;
    --gold: #bd8640;
    --coral: #b85b4c;
    --white: #fff;
    --line: #d9ded9;
    --success: #247a54;
    --danger: #a9423a;
    --shadow: 0 12px 36px rgba(16, 43, 36, .10);
    font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
    color: var(--ink);
    background: var(--paper);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, .button { cursor: pointer; }

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 14px 14px 14px 5px;
    background: var(--gold);
    color: var(--white);
    font-family: serif;
    font-size: 1.35rem;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}

.public-header {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 14px clamp(18px, 5vw, 72px);
    color: var(--white);
    background: rgba(16, 43, 36, .94);
    backdrop-filter: blur(12px);
}
.public-brand, .admin-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}
.public-brand strong, .public-brand small,
.admin-brand strong, .admin-brand small { display: block; }
.public-brand small, .admin-brand small { margin-top: 2px; opacity: .72; font-size: .72rem; letter-spacing: .12em; }
.public-header nav { display: flex; gap: 24px; }
.public-header nav a { color: rgba(255,255,255,.88); text-decoration: none; font-size: .92rem; }
.public-header nav a:hover { color: var(--white); }
.public-footer {
    padding: 42px 20px;
    text-align: center;
    color: rgba(255,255,255,.72);
    background: var(--forest-950);
}
.public-footer p { margin: 6px; }

.hero {
    position: relative;
    overflow: hidden;
    min-height: 560px;
    display: grid;
    place-items: center;
    padding: 90px 24px;
    color: var(--white);
    background:
        radial-gradient(circle at 80% 20%, rgba(189,134,64,.28), transparent 25%),
        linear-gradient(135deg, rgba(16,43,36,.97), rgba(49,95,78,.87));
}
.hero.has-image::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--hero-image) center/cover;
    opacity: .3;
    mix-blend-mode: luminosity;
}
.hero-media {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: .26;
    filter: saturate(.7);
}
.hero-content { position: relative; width: min(1060px, 100%); }
.hero .eyebrow { color: #e5c28d; }
.hero h1 {
    max-width: 780px;
    margin: 16px 0;
    font-family: "Noto Serif TC", "Microsoft JhengHei", serif;
    font-size: clamp(2.5rem, 7vw, 5.6rem);
    line-height: 1.04;
    letter-spacing: -.03em;
}
.hero .lead { max-width: 680px; font-size: clamp(1rem, 2vw, 1.25rem); line-height: 1.8; color: rgba(255,255,255,.82); }
.hero-meta { display: flex; flex-wrap: wrap; gap: 10px; margin: 28px 0; }
.hero-meta span { padding: 9px 14px; border: 1px solid rgba(255,255,255,.23); border-radius: 999px; background: rgba(255,255,255,.08); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.button.accent { color: #18372e; background: #e4bd81; }
.button.accent:hover { background: #efd19f; }
.button.glass { border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.1); }
.liff-status { min-height: 1.5em; margin: 14px 0 0; color: rgba(255,255,255,.82); }
.error-text { color: #ffbeb8 !important; }

.public-section { width: min(1160px, calc(100% - 36px)); margin: 0 auto; padding: 72px 0; }
.intro-section { display: grid; grid-template-columns: minmax(240px, .8fr) minmax(300px, 1.2fr); gap: clamp(32px, 8vw, 100px); align-items: start; }
.intro-section h2, .prize-band h2 { margin: 8px 0; font-family: serif; font-size: clamp(2rem, 4vw, 3.4rem); line-height: 1.15; }
.prose { color: var(--muted); line-height: 1.9; }
.preserve-lines { white-space: pre-line; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.section-heading h2 { margin: 6px 0 0; font-size: clamp(1.8rem, 4vw, 3rem); font-family: serif; }
.eyebrow { margin: 0; color: var(--forest-700); font-size: .75rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.route-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.route-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: rgba(255,255,255,.72);
    box-shadow: var(--shadow);
}
.route-cover { min-height: 190px; display: grid; place-items: center; overflow: hidden; color: rgba(255,255,255,.35); background: linear-gradient(145deg, var(--forest-800), var(--forest-700)); font-family: serif; font-size: 4rem; }
.route-cover img { width: 100%; height: 190px; object-fit: cover; }
.route-body { padding: 24px; }
.route-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.route-code { color: var(--gold); font-size: .78rem; font-weight: 800; letter-spacing: .12em; }
.route-card h3 { margin: 8px 0; font-size: 1.45rem; }
.route-card p { color: var(--muted); line-height: 1.7; }
.route-card .route-venue { margin: 6px 0; color: var(--forest-700); }
.stamp-list { display: flex; gap: 10px; margin-top: 18px; }
.stamp-chip { flex: 1; padding: 12px; border-radius: 14px; background: var(--paper); font-size: .86rem; }
.stamp-chip strong, .stamp-chip small { display: block; }
.stamp-chip small { margin-top: 4px; color: var(--muted); }
.route-facts { display: flex; flex-wrap: wrap; gap: 10px 20px; margin: 18px 0; }
.route-facts div { display: flex; gap: 7px; }
.route-facts dt { color: var(--muted); }
.route-facts dd { margin: 0; font-weight: 700; }
.prize-band { display: grid; grid-template-columns: minmax(220px, .7fr) minmax(300px, 1.3fr); gap: 40px; align-items: center; margin-bottom: 72px; padding: 38px; border-radius: 28px; color: var(--white); background: var(--forest-900); }
.prize-band img { width: 100%; max-height: 320px; object-fit: cover; border-radius: 20px; }
.prize-band p { color: rgba(255,255,255,.76); line-height: 1.8; }
.prize-band a { color: #efcf9f; }
.policy-page { width: min(860px, calc(100% - 36px)); min-height: 70vh; margin: auto; padding: 72px 0; }
.policy-page h1 { font-family: serif; font-size: clamp(2rem, 5vw, 3.7rem); }
.policy-content { white-space: pre-wrap; line-height: 1.9; padding: 28px; border-radius: 20px; background: var(--white); box-shadow: var(--shadow); }
.policy-summary { display: grid; grid-template-columns: auto 1fr; gap: 8px 20px; margin: 24px 0; padding: 20px; border-left: 4px solid var(--gold); background: rgba(255,255,255,.65); }
.policy-summary span { color: var(--muted); }
.contact-card { display: grid; gap: 6px; margin-top: 22px; padding: 20px; border-radius: 16px; background: var(--forest-100); }
.error-page { text-align: center; }
.stamp-page { width: min(700px, calc(100% - 36px)); min-height: 76vh; margin: auto; padding: 54px 0; text-align: center; }
.stamp-page .stamp-visual { width: min(360px, 86vw); aspect-ratio: 3 / 4; margin: 24px auto; padding: 16px; border: 1px solid #ddd8ca; border-radius: 24px; background: #fffdf7; display: grid; place-items: center; overflow: hidden; box-shadow: var(--shadow); }
.stamp-page .stamp-visual img { width: 100%; height: 100%; object-fit: contain; transition: filter .25s ease, opacity .25s ease, transform .25s ease; }
.stamp-page .stamp-visual img:not(.is-collected) { filter: grayscale(1) contrast(.9); opacity: .62; }
.stamp-page .stamp-visual img.is-collected { filter: grayscale(0) saturate(1.06); }
.stamp-fallback { display: grid; place-items: center; width: 76%; aspect-ratio: 1; border: 5px double var(--forest-700); border-radius: 50%; color: var(--forest-700); font-family: serif; font-size: 7rem; }
.stamp-page blockquote { margin: 22px auto; color: var(--forest-800); font-family: serif; font-size: 1.4rem; line-height: 1.7; }
.stamp-page .liff-status { color: var(--muted); }
.line-test-page { width: min(880px, calc(100% - 36px)); }
.line-test-page > .alert { line-height: 1.7; }
.test-steps { display: grid; gap: 18px; }
.test-step { display: grid; grid-template-columns: 46px 1fr; gap: 16px; align-items: start; padding: 18px; border-radius: 16px; background: #f5f7f4; }
.test-step > span { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: var(--white); background: var(--forest-700); font-weight: 800; }
.test-step h2 { margin: 0 0 8px; font-size: 1.2rem; }
.test-step p { margin: 0 0 14px; color: var(--muted); line-height: 1.7; }
.test-step .button { margin: 4px 6px 4px 0; }
.consent-page details { margin-top: 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.65); }
.consent-page summary { cursor: pointer; padding: 18px; font-weight: 800; }
.policy-content.compact { max-height: 320px; overflow-y: auto; border-radius: 0 0 16px 16px; box-shadow: none; }
.consent-form { display: grid; gap: 14px; }
.member-hero { display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 80px max(18px, calc((100% - 1160px) / 2)); color: var(--white); background: linear-gradient(130deg, var(--forest-950), var(--forest-700)); }
.member-hero h1 { margin: 8px 0; font-family: serif; font-size: clamp(2.2rem, 5vw, 4rem); }
.member-hero .eyebrow { color: #e8d7b8; }
.progress-ring { width: 150px; aspect-ratio: 1; flex: 0 0 auto; display: grid; place-items: center; align-content: center; border: 12px solid rgba(255,255,255,.14); border-top-color: #e4bd81; border-radius: 50%; }
.progress-ring strong { font-size: 2rem; }
.progress-ring span { font-size: .75rem; color: rgba(255,255,255,.64); }
.member-section { padding-top: 40px; }
.progress-track { width: 100%; height: 12px; overflow: hidden; margin-bottom: 24px; border: 0; border-radius: 999px; background: #dce4df; }
.progress-track::-webkit-progress-bar { border-radius: 999px; background: #dce4df; }
.progress-track::-webkit-progress-value { border-radius: 999px; background: linear-gradient(90deg, var(--forest-700), var(--gold)); }
.progress-track::-moz-progress-bar { border-radius: 999px; background: linear-gradient(90deg, var(--forest-700), var(--gold)); }
.member-collection-card { overflow: hidden; border: 1px solid #bdd6c9; border-radius: 24px; background: #fffdf7; box-shadow: 0 16px 42px rgba(24, 59, 49, .1); }
.member-collection-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 20px 22px 18px; color: var(--white); background: linear-gradient(125deg, #174d41, #2f8061); }
.member-collection-header h2 { margin: 5px 0 0; font-size: 1.18rem; }
.member-collection-header .route-code { color: rgba(255, 255, 255, .7); }
.member-collection-header > strong { flex: 0 0 auto; color: #f6d894; font-size: clamp(1.35rem, 4vw, 1.9rem); }
.member-stamp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 16px; background: radial-gradient(circle at 50% 0, rgba(231, 242, 236, .82), transparent 42%), #fffdf7; }
.member-stamp-card { min-width: 0; margin: 0; }
.member-stamp-frame { position: relative; overflow: hidden; aspect-ratio: 1; padding: 5px; border: 1px solid #d8d5c8; border-radius: 18px; background: #fff; box-shadow: 0 7px 18px rgba(23, 77, 65, .08); }
.member-stamp-frame::after { position: absolute; inset: 5px; z-index: 2; border: 1px solid rgba(255, 255, 255, .76); border-radius: 13px; content: ""; pointer-events: none; }
.member-stamp-art { width: 100%; height: 100%; display: block; border-radius: 13px; object-fit: contain; transition: filter .25s ease, opacity .25s ease, transform .25s ease; }
.member-stamp-card.collected .member-stamp-art { filter: grayscale(0) saturate(1.05); }
.member-stamp-card.collected:hover .member-stamp-art { transform: scale(1.025); }
.member-stamp-card.locked .member-stamp-art { filter: grayscale(1) contrast(.88); opacity: .48; }
.member-stamp-placeholder { display: grid; place-items: center; color: #fff4d2; background: radial-gradient(circle at 28% 20%, #f1cf83, transparent 24%), linear-gradient(145deg, #3d8a68, #163f34 64%, #b4853c); }
.member-stamp-placeholder span { display: grid; width: 58%; aspect-ratio: 1; place-items: center; border: 2px solid currentColor; border-radius: 50%; font: 800 clamp(2rem, 6vw, 4.5rem)/1 serif; box-shadow: inset 0 0 0 5px rgba(255, 244, 210, .13); }
.member-stamp-state { position: absolute; right: 10px; bottom: 10px; z-index: 3; padding: 6px 9px; border-radius: 999px; color: #fff; background: rgba(20, 104, 69, .92); font-size: .68rem; font-weight: 800; line-height: 1; box-shadow: 0 3px 10px rgba(0, 0, 0, .16); }
.member-stamp-card.locked .member-stamp-state { background: rgba(62, 69, 66, .82); }
.member-reward-state { display: flex; flex-direction: column; gap: 5px; min-height: 72px; padding: 12px 5px; text-align: center; color: #725522; line-height: 1.45; }
.member-reward-state strong { font-size: clamp(.88rem, 3.5vw, 1.15rem); font-weight: 800; }
.member-reward-state span { color: #6f6558; font-size: .85rem; }
.member-stamp-card.locked .member-reward-state { color: #73716e; }
.member-redemption-code { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 0 16px; padding: 24px 14px 30px; border-top: 1px solid #e3ddd0; text-align: center; color: #55412b; }
.member-redemption-code h2, .member-redemption-code p { margin: 0; }
.member-redemption-code img { max-width: 100%; height: auto; border-radius: 12px; background: #fff; }
.member-code-text { font-family: ui-monospace, Consolas, monospace; font-size: 2rem; letter-spacing: .14em; line-height: 1.4; }
.prize-status-card { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-top: 24px; padding: 28px; border-radius: 22px; color: var(--white); background: var(--forest-900); }
.prize-status-card h2 { margin: 8px 0; font-family: serif; font-size: 2rem; }

.admin-shell { background: #f1f3ef; }
.admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
    width: 250px;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    color: var(--white);
    background: var(--forest-950);
}
.admin-brand { padding: 0 8px 26px; color: var(--white); }
.admin-menu { min-width: 0; }
.admin-menu-toggle { display: none; }
.admin-menu-toggle:focus-visible { outline: 3px solid #e5c28d; outline-offset: 2px; }
.admin-nav { display: grid; gap: 5px; }
.admin-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    color: rgba(255,255,255,.76);
    text-decoration: none;
}
.admin-nav a:hover { color: var(--white); background: rgba(255,255,255,.08); }
.admin-nav span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: rgba(255,255,255,.1); font-size: .78rem; }
.admin-user { margin-top: auto; padding: 16px 10px 4px; border-top: 1px solid rgba(255,255,255,.12); }
.admin-user > div { margin-bottom: 8px; }
.admin-user strong, .admin-user small { display: block; }
.admin-user small { margin-top: 4px; color: rgba(255,255,255,.5); }
.link-button { padding: 0; border: 0; color: #e5c28d; background: transparent; }
.admin-main { margin-left: 250px; min-height: 100vh; }
.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 26px clamp(20px, 4vw, 48px);
    border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,.72);
}
.admin-topbar h1 { margin: 4px 0 0; font-size: clamp(1.4rem, 3vw, 2rem); }
.admin-content { padding: 28px clamp(18px, 4vw, 48px) 72px; }
.admin-quick-nav {
    position: fixed;
    z-index: 50;
    left: calc(50% + 125px);
    bottom: max(16px, env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    display: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 8px;
    width: min(760px, calc(100% - 286px));
    padding: 8px;
    border: 1px solid #c2d2c8;
    border-radius: 22px;
    color: var(--forest-900);
    background: var(--white);
    box-shadow: 0 8px 30px rgba(16, 43, 36, .18);
}
.admin-quick-nav__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    min-height: 66px;
    padding: 9px 8px;
    border: 2px solid transparent;
    border-radius: 15px;
    text-align: center;
    text-decoration: none;
    font-size: .875rem;
    font-weight: 700;
    line-height: 1.4;
    overflow-wrap: anywhere;
    touch-action: manipulation;
}
.admin-quick-nav__link svg { display: block; width: 24px; height: 24px; flex: 0 0 24px; }
.admin-quick-nav__link:hover { background: var(--forest-100); }
.admin-quick-nav__link.is-current { color: var(--white); background: var(--forest-900); }
.admin-quick-nav__link.is-current span { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.admin-quick-nav__link:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat-card, .panel {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--white);
    box-shadow: 0 5px 18px rgba(16,43,36,.04);
}
.stat-card { padding: 20px; }
.stat-card small { color: var(--muted); }
.stat-card strong { display: block; margin-top: 8px; font-size: 1.8rem; }
.stat-card .delta { margin-top: 8px; color: var(--forest-700); font-size: .8rem; }
.panel { margin-top: 20px; padding: 24px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.panel-header h2, .panel-header h3 { margin: 0; }
.status-row { display: flex; flex-wrap: wrap; gap: 10px; }
.status-pill, .badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.status-pill.good, .badge.good { color: #12633f; background: #dff3e8; }
.status-pill.warn, .badge.warn { color: #885712; background: #fff0cf; }
.status-pill.bad, .badge.bad { color: #8f332f; background: #f9dfdc; }
.badge.neutral { color: #53605b; background: #edf0ed; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 12px; border-bottom: 1px solid #e9ece9; text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: var(--muted); font-size: .78rem; letter-spacing: .05em; }
td.wrap { white-space: normal; min-width: 220px; }
.actions { display: flex; gap: 8px; align-items: center; }
.button, button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 11px;
    color: var(--white);
    background: var(--forest-800);
    text-decoration: none;
    font-weight: 700;
}
.button:hover { background: var(--forest-700); }
.button.secondary { color: var(--forest-800); border-color: #b9c8c1; background: transparent; }
.button.secondary:hover { background: var(--forest-100); }
.button.danger { background: var(--danger); }
.button.small { min-height: 34px; padding: 6px 11px; font-size: .82rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 7px; font-weight: 700; font-size: .88rem; }
.field input:not([type=checkbox]), .field select, .field textarea, .search-box {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #bcc8c1;
    border-radius: 10px;
    color: var(--ink);
    background: var(--white);
}
.field textarea { min-height: 130px; resize: vertical; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 3px solid rgba(49,95,78,.16); border-color: var(--forest-700); }
.field small { display: block; margin-top: 6px; color: var(--muted); }
.checkbox-row { display: flex; align-items: center; gap: 9px; min-height: 44px; }
.validation-summary-errors, .field-validation-error { color: var(--danger); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.alert { margin-bottom: 18px; padding: 13px 16px; border-radius: 12px; }
.alert.success { color: #155e3f; background: #daf1e4; border: 1px solid #b8dfc9; }
.alert.error { color: #8a332e; background: #f8dfdd; border: 1px solid #eebfba; }
.media-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.media-card { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--white); }
.media-preview { aspect-ratio: 4/3; background: #e8ece8; }
.media-preview img { width: 100%; height: 100%; object-fit: cover; }
.media-info { padding: 14px; }
.media-info h3 { margin: 6px 0; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-info p { margin: 4px 0; color: var(--muted); font-size: .78rem; }
.rich-menu-built-in { display: grid; grid-template-columns: minmax(280px, 1.25fr) minmax(260px, .75fr); gap: 24px; align-items: center; }
.rich-menu-built-in img { width: 100%; border: 1px solid var(--line); border-radius: 14px; background: #f4efe5; }
.rich-menu-tabs-preview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.rich-menu-tabs-preview figure { margin: 0; }
.rich-menu-tabs-preview figcaption { margin-top: 7px; color: var(--muted); font-size: .78rem; text-align: center; }
.qr-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.qr-card { padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: #f7f9f6; }
.qr-card h3 { margin: 8px 0 16px; }
.qr-card img { display: block; width: min(240px, 100%); aspect-ratio: 1; margin: 0 auto 14px; image-rendering: pixelated; }
.qr-card .field { margin-bottom: 12px; }
.scan-page { width: min(760px, calc(100% - 32px)); margin: 54px auto 80px; }
.scan-page > h1 { margin-bottom: 12px; }
.scan-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 20px;
    padding: 24px;
    margin: 28px 0 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
}
.scan-card h2, .scan-card p { margin: 0; }
.scan-icon {
    display: grid;
    width: 64px;
    height: 64px;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: var(--forest-900);
    font-size: 34px;
    font-weight: 700;
}
.liff-shell {
    min-height: 100vh;
    min-height: 100dvh;
    color: #fff;
    background:
        radial-gradient(circle at 15% 12%, rgba(212, 167, 96, .28), transparent 26%),
        linear-gradient(165deg, #17392f 0%, #0f2b24 60%, #081d18 100%);
}
.liff-scan-page {
    position: fixed;
    z-index: 0;
    inset: 0;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    background: #071913;
}
.scan-privacy-notice {
    position: absolute;
    right: 20px;
    bottom: max(24px, env(safe-area-inset-bottom));
    left: 20px;
    margin: 0;
    color: #d6e5de;
    text-align: center;
    line-height: 1.8;
}
.scan-privacy-notice a { color: inherit; text-underline-offset: 4px; }
.scan-privacy-link {
    display: inline-block;
    margin-top: 18px;
    padding: 8px;
    color: #315b48;
    text-underline-offset: 4px;
}
.scan-privacy-link[hidden] { display: none; }
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}
.scan-promo-sequence[hidden] { display: none; }
.scan-promo-sequence {
    position: fixed;
    z-index: 2000;
    inset: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    place-items: center;
    overflow: hidden;
    background: #06150f;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.scan-promo-sequence img {
    display: block;
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #06150f;
}
.scan-promo-controls {
    position: absolute;
    top: 75%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: max-content;
    max-width: calc(100% - 32px);
    text-align: center;
}
.scan-promo-controls p,
.scan-promo-close {
    margin: 0;
    padding: 10px 16px;
    border: 1px solid rgba(255, 255, 255, .65);
    border-radius: 999px;
    background: rgba(6, 21, 15, .9);
    color: #fff;
    font-size: 16px;
    line-height: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}
.scan-promo-close {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
}
.scan-promo-controls [hidden] { display: none; }
.scan-promo-close span { font-size: 24px; }
.scan-promo-close:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 4px;
}
.scan-promo-close:disabled { cursor: wait; }
.scan-promo-progress {
    position: absolute;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    left: max(18px, env(safe-area-inset-left));
    display: grid;
    grid-template-columns: 1fr;
}
.scan-promo-progress span {
    position: relative;
    height: 5px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, .38);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .24);
}
.scan-promo-progress span::after {
    position: absolute;
    inset: 0;
    content: "";
    background: #fff;
    transform: scaleX(0);
    transform-origin: left;
}
.scan-promo-sequence[data-stage="1"] .scan-promo-progress span:first-child::after {
    animation: scan-promo-fill var(--scan-promo-duration, 60s) linear forwards;
}
body.scan-promo-open { overflow: hidden; }
@keyframes scan-promo-fill {
    to { transform: scaleX(1); }
}
.liff-bootstrap-page {
    position: fixed;
    inset: 0;
    background: #06150f;
}
.liff-scan-question[hidden] { display: none; }
.liff-scan-question {
    position: fixed;
    z-index: 900;
    inset: 0;
    display: grid;
    padding:
        max(18px, env(safe-area-inset-top))
        16px
        max(18px, env(safe-area-inset-bottom));
    place-items: center;
    overflow-y: auto;
}
.liff-scan-question-card {
    position: relative;
    width: min(430px, 100%);
    max-height: calc(100vh - 36px);
    max-height: calc(100dvh - 36px);
    padding: 28px 24px 24px;
    overflow-y: auto;
    border: 1px solid rgba(243, 213, 141, .7);
    border-radius: 26px;
    color: #17392f;
    background:
        radial-gradient(circle at 90% 0, rgba(217, 179, 104, .28), transparent 34%),
        #fffaf0;
    box-shadow: 0 28px 80px rgba(0, 0, 0, .38);
    text-align: center;
    animation: liff-modal-enter .2s ease-out;
}
.liff-scan-question-card .eyebrow {
    margin: 12px 0 3px;
    color: #9b7132;
}
.scan-question-route {
    margin: 0;
    color: #365a4d;
    font-size: .92rem;
    font-weight: 800;
}
.scan-question-topic {
    display: inline-flex;
    margin: 10px 0 12px;
    padding: 5px 10px;
    border-radius: 999px;
    color: #76531f;
    background: #f5e4bc;
    font-size: .82rem;
    font-weight: 800;
}
.liff-scan-question-card h2 {
    margin: 0;
    font-size: 1.45rem;
}
.scan-question-prompt {
    margin: 12px 0 20px;
    color: #33473f;
    font-size: 1.06rem;
    font-weight: 700;
    line-height: 1.7;
    text-align: left;
    white-space: pre-line;
}
.scan-question-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.scan-question-option {
    display: grid;
    min-height: 90px;
    padding: 10px;
    place-items: center;
    gap: 2px;
    border: 2px solid #b8c8c1;
    border-radius: 18px;
    color: #24483b;
    background: rgba(255, 255, 255, .72);
}
.scan-question-option strong {
    font-size: 2.2rem;
    line-height: 1;
}
.scan-question-option:hover,
.scan-question-option:focus-visible {
    border-color: #9b7132;
    outline: none;
    box-shadow: 0 0 0 3px rgba(217, 179, 104, .28);
}
.scan-question-option.is-correct {
    border-color: #2e7959;
    color: #1b6347;
    background: #e2f3e9;
}
.scan-question-option.is-wrong {
    border-color: #a94740;
    color: #8b332e;
    background: #f9e3e0;
}
.scan-question-option:disabled { cursor: default; opacity: .7; }
.scan-question-option.is-correct:disabled { opacity: 1; }
.scan-question-feedback {
    min-height: 1.5em;
    margin: 14px 0 12px;
    color: #63736c;
    font-size: .88rem;
    line-height: 1.55;
}
.scan-question-feedback.success {
    color: #1b6347;
    font-weight: 800;
}
.scan-location-action { width: 100%; }
.scan-location-action:disabled {
    cursor: not-allowed;
    opacity: .48;
}
body.scan-question-open { overflow: hidden; }
.liff-scan-modal[hidden] { display: none; }
.liff-scan-modal {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: grid;
    padding:
        max(22px, env(safe-area-inset-top))
        20px
        max(22px, env(safe-area-inset-bottom));
    place-items: center;
}
.liff-scan-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 20, 16, .76);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.liff-scan-modal-card {
    position: relative;
    width: min(410px, 100%);
    max-height: calc(100vh - 44px);
    max-height: calc(100dvh - max(22px, env(safe-area-inset-top)) - max(22px, env(safe-area-inset-bottom)));
    padding: 34px 26px 26px;
    overflow: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid rgba(243, 213, 141, .7);
    border-radius: 26px;
    color: #17392f;
    background:
        radial-gradient(circle at 90% 0, rgba(217, 179, 104, .28), transparent 34%),
        #fffaf0;
    box-shadow: 0 28px 80px rgba(0, 0, 0, .38);
    text-align: center;
    animation: liff-modal-enter .2s ease-out;
}
.liff-scan-modal-card .eyebrow { margin: 14px 0 4px; color: #9b7132; }
.liff-scan-modal-card h2 { margin: 0; font-size: 1.55rem; }
.liff-scan-modal-card > p:last-of-type {
    margin: 13px 0 22px;
    color: #51635c;
    line-height: 1.75;
    white-space: pre-line;
}
.liff-scan-modal-close {
    position: absolute;
    top: 13px;
    right: 15px;
    display: grid;
    width: 36px;
    height: 36px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 50%;
    color: #52655d;
    background: rgba(24, 59, 49, .08);
    font-size: 1.45rem;
    line-height: 1;
}
.liff-scan-modal-icon {
    display: grid;
    width: 62px;
    height: 62px;
    margin: 0 auto;
    place-items: center;
    border-radius: 20px;
    color: #17392f;
    background: #f3d58d;
    box-shadow: 0 10px 28px rgba(160, 117, 48, .22);
    font-size: 1.75rem;
    font-weight: 800;
}
.liff-scan-modal[data-tone="success"] .liff-scan-modal-icon {
    color: #fff;
    background: #2e7959;
}
.liff-scan-modal[data-tone="error"] .liff-scan-modal-icon {
    color: #fff;
    background: #a94740;
}
.liff-scan-modal-actions { display: grid; gap: 10px; }
.liff-scan-modal-action { width: 100%; }
.liff-scan-modal-action[hidden] { display: none; }
body.scan-modal-open { overflow: hidden; }
@keyframes liff-modal-enter {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
    .liff-scan-modal-card,
    .liff-scan-question-card { animation: none; }
}
.test-session-grid { display: grid; gap: 16px; }
.test-session-card { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: start; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: #f7f9f6; }
.test-session-card h3 { margin: 10px 0 6px; }
.test-session-card p { margin: 6px 0; }
.test-session-actions { display: grid; gap: 8px; justify-items: stretch; width: 190px; }
.test-session-actions img { width: 190px; aspect-ratio: 1; background: var(--white); }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 80% 20%, rgba(189,134,64,.25), transparent 25%), var(--forest-950); }
.auth-card { width: min(460px, 100%); padding: 34px; border-radius: 24px; background: var(--paper); box-shadow: 0 30px 80px rgba(0,0,0,.28); }
.auth-card .admin-brand { padding: 0 0 26px; color: var(--forest-950); }
.auth-card h1 { margin: 0 0 8px; }
.auth-card > p { color: var(--muted); line-height: 1.6; }
.auth-card .field { margin-top: 16px; }
.auth-card .button { width: 100%; margin-top: 20px; }
.empty-state { padding: 50px 20px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.code { padding: 3px 7px; border-radius: 7px; background: #edf0ed; font-family: Consolas, monospace; font-size: .82rem; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin: 24px 0 0; }
.detail-grid div { padding: 15px; border-radius: 12px; background: #f5f7f4; }
.detail-grid .full { grid-column: 1 / -1; }
.detail-grid dt { margin-bottom: 6px; color: var(--muted); font-size: .78rem; }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; }
.log-filter { margin-top: 22px; }
.log-path { display: block; width: min(640px, 52vw); margin-top: 5px; overflow: hidden; text-overflow: ellipsis; }
.log-json {
    max-height: 520px;
    padding: 18px;
    overflow: auto;
    border: 1px solid #d8ded9;
    border-radius: 12px;
    color: #e8f2ec;
    background: #102b24;
    font: .84rem/1.65 Consolas, "Courier New", monospace;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 24px; color: var(--muted); }

@media (max-width: 1050px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .media-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .public-header nav { display: none; }
    .hero { min-height: 500px; padding-top: 70px; }
    .route-grid { grid-template-columns: 1fr; }
    .intro-section, .prize-band { grid-template-columns: 1fr; }
    .stamp-list { overflow-x: auto; }
    .stamp-chip { min-width: 130px; }
    .member-hero { align-items: flex-start; }
    .progress-ring { width: 110px; }
    .member-collection-header { padding: 17px 16px; }
    .member-stamp-grid { gap: 10px; padding: 12px; }
    .member-stamp-frame { border-radius: 16px; }
    .prize-status-card { align-items: stretch; flex-direction: column; }
    .admin-sidebar { position: static; width: auto; padding: 14px; }
    .admin-brand { padding-bottom: 14px; }
    .admin-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        min-height: 44px;
        padding: 9px 12px;
        border: 1px solid rgba(255,255,255,.22);
        border-radius: 10px;
        color: var(--white);
        font-size: .875rem;
        font-weight: 700;
        cursor: pointer;
        list-style: none;
    }
    .admin-menu-toggle::-webkit-details-marker { display: none; }
    .admin-menu-toggle svg { width: 20px; height: 20px; flex: 0 0 20px; }
    .admin-menu[open] .admin-menu-toggle svg { transform: rotate(180deg); }
    .admin-menu[open] .admin-nav { margin-top: 10px; }
    .admin-nav { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); overflow-x: auto; }
    .admin-nav a { min-width: 76px; flex-direction: column; gap: 5px; padding: 8px 4px; text-align: center; font-size: .7rem; }
    .admin-user { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding-top: 12px; }
    .admin-user > div { margin-bottom: 0; min-width: 0; overflow-wrap: anywhere; }
    .admin-user .link-button { min-height: 44px; padding: 8px; white-space: nowrap; }
    .admin-main { margin-left: 0; }
    .admin-topbar { padding: 18px; }
    .admin-content { padding: 18px 14px 60px; }
    .has-admin-quick-nav .admin-content { padding-bottom: calc(10rem + env(safe-area-inset-bottom, 0px)); }
    .has-admin-quick-nav .admin-content :is(a, button, input, select, textarea) { scroll-margin-bottom: calc(10rem + env(safe-area-inset-bottom, 0px)); }
    .admin-quick-nav {
        display: grid;
        left: max(10px, env(safe-area-inset-left, 0px));
        right: max(10px, env(safe-area-inset-right, 0px));
        bottom: max(10px, env(safe-area-inset-bottom, 0px));
        transform: none;
        width: auto;
        gap: 4px;
        padding: 6px;
        border-radius: 20px;
    }
    .admin-quick-nav__link { min-height: 76px; padding: 7px 5px; font-size: .8125rem; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: auto; }
    .detail-grid { grid-template-columns: 1fr; }
    .detail-grid .full { grid-column: auto; }
    .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .rich-menu-built-in { grid-template-columns: 1fr; }
    .qr-grid, .test-session-card, .scan-card { grid-template-columns: 1fr; }
    .test-session-actions { width: min(240px, 100%); }
    .test-session-actions img { width: 100%; }
}
@media (max-width: 480px) {
    .member-hero { gap: 12px; padding: 40px 18px; }
    .member-hero h1 { font-size: clamp(1.55rem, 6vw, 1.8rem); }
    .progress-ring { width: 90px; border-width: 8px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 15px; }
    .stat-card strong { font-size: 1.35rem; }
    .media-grid { grid-template-columns: 1fr; }
    .admin-topbar .button { display: none; }
}

/* Keep permission wrappers from changing the existing editor layout. */
.admin-permission-fields { border: 0; margin: 0; padding: 0; min-inline-size: 0; }

/* Keep role and account controls within narrow screens while their tables scroll. */
.role-management { min-width: 0; }
.role-management .panel-header, .role-management .form-actions { flex-wrap: wrap; }
.role-management .panel-header .form-actions { margin-top: 0; }
.role-management .table-wrap { min-width: 0; max-width: 100%; }
.role-management .field { min-width: 0; }
.role-management .validation-summary-valid { display: none; }
@media (max-width: 480px) {
    .role-management.panel { padding: 16px; }
    .role-management .panel-header { align-items: flex-start; }
    .role-management .panel-header h2 { flex-basis: 100%; }
    .role-management .form-actions { justify-content: flex-start; }
    .role-management .form-actions .button { max-width: 100%; white-space: normal; }
}
