:root {
  --brand: #1f4d3a;        /* forest green */
  --brand-ink: #fff;
  --brand-dark: #163a2b;
  --accent: #c8a24a;       /* brass */
  --bg: #f6f1e7;           /* cream */
  --panel: #fff;
  --text: #1e2420;
  --muted: #6c736e;
  --border: #e4dccb;
  --danger: #b3261e;
  --ok: #2e7d4f;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); min-height: 1.2em; font-size: 14px; }
h1, h2, h3 { line-height: 1.2; }
a { color: var(--brand); }

input, select, textarea { font: inherit; color: inherit; width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
label { display: block; margin: 12px 0; font-size: 14px; font-weight: 600; }
label > input, label > select, label > textarea { margin-top: 5px; font-weight: 400; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { width: 20px; height: 20px; flex: none; margin: 1px 0 0; accent-color: var(--brand); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }

.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: #fff; color: var(--text); border-radius: 12px; padding: 11px 16px; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #1e1a10; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 10px; font-size: 14px; border-radius: 9px; }
.btn:disabled { opacity: .55; cursor: default; }
.link { background: none; border: 0; color: var(--brand); font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stack > * + * { margin-top: 14px; }

/* ------------------------------------------------------------------ member app */
.shell { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.hero { background: var(--brand); color: var(--brand-ink); padding: 48px 24px 40px; text-align: center; }
.wordmark { font-family: Georgia, "Times New Roman", serif; font-weight: 700; letter-spacing: .02em; font-size: 40px; margin: 0; }
.wordmark small { display: block; font-family: system-ui, sans-serif; font-size: 13px; letter-spacing: .25em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin-top: 4px; }
.hero p { opacity: .9; margin: 14px 0 0; }
.pad { padding: 20px 16px; }
.topbar { background: var(--brand); color: var(--brand-ink); padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 2; }
.topbar .wordmark { font-size: 22px; }
/* Logo artwork (Foresters Arms blackletter) */
.wordmark .logo { display: block; width: min(320px, 82%); height: auto; margin: 0 auto; }
.topbar .wordmark .logo, .s-top .wordmark .logo { display: inline-block; width: auto; height: 30px; margin: 0; vertical-align: middle; }
.topbar .hi { font-size: 14px; opacity: .9; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; }
main.view { flex: 1; padding: 16px 16px 96px; }

.member-card { background: linear-gradient(145deg, var(--brand) 0%, var(--brand-dark) 100%); color: #fff; border-radius: 20px; padding: 20px; text-align: center; box-shadow: 0 8px 24px rgba(31,77,58,.25); }
.member-card .name { font-weight: 700; font-size: 18px; }
.member-card .qr { background: #fff; border-radius: 14px; padding: 12px; width: min(240px, 70vw); margin: 14px auto 10px; }
.member-card .qr img { display: block; width: 100%; height: auto; }
.member-card .qr svg { display: block; width: 100%; height: auto; }
.member-card .live { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: .15em; color: var(--accent); }
.member-card .live .dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 0 rgba(74, 222, 128, .7); animation: pulse 1.6s infinite; }
.member-card .countdown { width: 60px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.2); overflow: hidden; }
.member-card .countdown i { display: block; height: 100%; background: var(--accent); transition: width 1s linear; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); } }
@media (prefers-reduced-motion: reduce) { .member-card .live .dot { animation: none; } .member-card .countdown i { transition: none; } }
.wallet-row { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.wallet-btn { background: #000; color: #fff; border-color: #000; border-radius: 10px; padding: 10px 18px; }
.member-card .code { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .18em; font-size: 18px; color: var(--accent); }
.member-card .hint { font-size: 13px; opacity: .85; margin-top: 4px; }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 26px 0 10px; font-weight: 700; }
.stampcard .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.stampcard .head strong { font-size: 17px; }
.stamps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 14px 0 10px; }
.stamp { aspect-ratio: 1; border-radius: 50%; border: 2px dashed var(--border); display: grid; place-items: center; font-size: 22px; background: #fbf8f2; }
.stamp.on { border: 2px solid var(--brand); background: #e8f0eb; }
.stamp.goal { border-color: var(--accent); }
.stamp.pop { animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(.3); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }

.voucher { display: flex; gap: 14px; align-items: center; border: 2px dashed var(--accent); background: #fffaf0; }
.voucher .ico { font-size: 30px; }
.voucher .t { font-weight: 700; }
.badge { display: inline-block; background: var(--accent); color: #1e1a10; font-weight: 700; font-size: 12px; border-radius: 10px; padding: 1px 7px; margin-left: 4px; vertical-align: 1px; }

.special img { width: calc(100% + 36px); margin: -18px -18px 12px; border-radius: var(--radius) var(--radius) 0 0; display: block; max-height: 220px; object-fit: cover; }
.special h3 { margin: 0 0 4px; }
.special p { margin: 6px 0 0; white-space: pre-wrap; }
.pin { color: var(--accent); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--border); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 3; }
.tabbar .inner { display: flex; width: 100%; max-width: 480px; }
.tabbar button { flex: 1; background: none; border: 0; font: inherit; font-size: 12px; padding: 9px 0 10px; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabbar button .i { font-size: 21px; line-height: 1; }
.tabbar button.active { color: var(--brand); font-weight: 700; }

.history li { padding: 8px 0; border-bottom: 1px solid var(--border); list-style: none; display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.history { padding: 0; margin: 0; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: #1e2420; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 20; max-width: calc(100vw - 32px); text-align: center; font-size: 15px; }
.toast.error { background: var(--danger); }

.celebrate { position: fixed; inset: 0; background: rgba(15,30,22,.75); display: grid; place-items: center; z-index: 30; padding: 16px; }
.celebrate .card { text-align: center; max-width: 360px; animation: pop .5s ease; }
.celebrate .big { font-size: 56px; }

dialog { border: 0; border-radius: var(--radius); padding: 20px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h2 { margin-top: 0; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

.install-tip { background: #fffaf0; border: 1px solid var(--accent); border-radius: 12px; padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: center; }
.install-tip button { flex: none; }

/* ------------------------------------------------------------------ laptop / desktop layout */
@media (min-width: 900px) {
  .shell { max-width: none; }
  .toast { bottom: 32px; }

  /* Welcome, join and sign-in: split screen (logo panel left, form right) */
  .shell.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
  .shell.auth > .hero { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 100vh; padding: 48px !important; position: sticky; top: 0; }
  .shell.auth > .hero .wordmark { width: 100%; }
  .shell.auth > .hero .wordmark .logo { width: min(460px, 75%); }
  .shell.auth > .hero p { font-size: 18px; }
  .shell.auth > :not(.hero) { align-self: center; width: 100%; max-width: 460px; margin: 0 auto; padding: 48px 24px; }

  /* Signed in: tabs move into the top bar, content gets columns */
  .shell.app .topbar { padding: 0 32px; }
  .shell.app .topbar-inner { max-width: 1080px; margin: 0 auto; min-height: 72px; }
  .shell.app .topbar .wordmark .logo { height: 42px; }
  .shell.app .tabbar { position: static; background: none; border: 0; padding: 0; flex: 1; justify-content: center; }
  .shell.app .tabbar .inner { width: auto; max-width: none; gap: 4px; }
  .shell.app .tabbar button { flex: none; flex-direction: row; gap: 8px; font-size: 15px; color: rgba(255, 255, 255, .78); padding: 24px 14px 21px; border-bottom: 3px solid transparent; }
  .shell.app .tabbar button .i { font-size: 18px; }
  .shell.app .tabbar button:hover { color: #fff; }
  .shell.app .tabbar button.active { color: #fff; border-bottom-color: var(--accent); }
  main.view { width: 100%; max-width: 1080px; margin: 0 auto; padding: 32px 32px 56px; }

  .card-layout { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 40px; align-items: start; }
  .card-layout .col-a { position: sticky; top: 104px; }
  .card-layout .col-b > :first-child { margin-top: 0; }
  .card-layout .col-b .section-title:first-child { margin-top: 4px; }
  .grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
  .grid-2 > * + * { margin-top: 0; }
  .profile-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
  .profile-layout .section-first { margin-top: 0; }
  .stamps { grid-template-columns: repeat(auto-fill, 50px); gap: 8px; }
  .stamp { font-size: 19px; }
}
