/* Sojourner v0.2 — compact, gamified theme.
 * Base type ~15px with dense rows (David's review: fonts too big, too much
 * scrolling), collectible cards + stamp medallions + coin chips for game
 * feel, sticky player header, fixed bottom tab bar with a persistent ad
 * banner above it. Tap targets stay >= 44px. Vanilla CSS only.
 */
:root {
  --navy: #0b2149;
  --navy2: #12305f;
  --gold: #c9a227;
  --gold-bright: #e8c84a;
  --paper: #f7f3e8;
  --ink: #1c2430;
  --tabbar-h: 54px;
  --adbar-h: 86px;
}
* { box-sizing: border-box; }
html { overflow-x: hidden; }
html, body { height: 100%; }
body {
  /* App shell (v0.3.2): a full-height flex column — header / main / ad bar /
   * tab bar. Main is the ONLY scroller, so the ad bar and tab bar live in
   * the layout flow and can never overlap a card or a button (the v0.3.1
   * fixed bars + body padding could: the ad's real height outgrew the
   * reserved 86px and covered the second lodge card's Check in button). */
  margin: 0; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px; line-height: 1.35; color: var(--ink); background: var(--paper);
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh; overflow: hidden;
}
img, canvas, svg { max-width: 100%; }
h1, h2, h3, .serif { font-family: Georgia, 'Times New Roman', serif; }
h2 { color: var(--navy); font-size: 21px; margin: 10px 0 6px; }
h3 { color: var(--navy); font-size: 17px; margin: 14px 0 6px; }
main {
  flex: 1 1 auto; min-height: 0; width: 100%;
  max-width: 760px; margin: 0 auto; padding: 10px 12px;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
a { color: var(--navy2); }

/* ---------- sticky player header ---------- */
.playerbar {
  flex: 0 0 auto; position: relative; z-index: 45;
  display: flex; gap: 10px; align-items: center;
  background: linear-gradient(180deg, var(--navy), var(--navy2));
  color: var(--paper); padding: 7px 12px;
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 2px 8px rgba(11, 33, 73, .35);
}
.playerbar .logo-mini { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--gold); }
/* Logo = Home button (v0.3.2): the coin in the header goes to Lodges. */
.logo-home {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0; margin: 0; cursor: pointer;
  border-radius: 50%; min-width: 44px; min-height: 44px;
  -webkit-tap-highlight-color: rgba(201, 162, 39, .35);
}
.logo-home img { pointer-events: none; display: block; }
.logo-home:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 2px; }
.demo-banner { flex: 0 0 auto; }
.pb-main { flex: 1; min-width: 0; }
.pb-line1 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-line1 #pb-level { color: var(--gold-bright); font-family: Georgia, serif; font-weight: bold; }
.pb-line2 { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-progress { height: 7px; background: rgba(247, 243, 232, .25); border-radius: 99px; margin: 4px 0 2px; overflow: hidden; }
#pb-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold), var(--gold-bright)); border-radius: 99px; transition: width .6s ease; }
.pb-line3 { font-size: 11.5px; opacity: .8; }
.pb-points { text-align: center; min-width: 52px; }
.pb-points strong { display: block; font-family: Georgia, serif; font-size: 24px; color: var(--gold-bright); line-height: 1; }
.pb-points span { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; opacity: .85; }
.pb-points.bump { animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
.demo-banner, .demo-badge {
  background: #8c1d1d; color: #fff; text-align: center;
  padding: 5px 8px; font-weight: bold; letter-spacing: 1px; font-size: 13px;
}

/* ---------- bottom tab bar (in the app-shell flow, v0.3.2) ---------- */
.tabs {
  flex: 0 0 auto; position: relative; z-index: 46;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex; background: var(--navy); border-top: 3px solid var(--gold);
}
.tab {
  flex: 1; font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer;
  background: transparent; color: var(--paper); border: none; border-top: 3px solid transparent;
  min-height: 44px;
}
.tab.active { border-top-color: var(--gold); color: var(--gold-bright); background: var(--navy2); }

/* ---------- persistent ad banner (in-flow, above tabs, every view) -------
 * v0.3.2: no longer position:fixed — it occupies real layout space in the
 * app shell, so it can never cover content. Height is content-driven with
 * the copy clamped below, keeping it at the reserved ~86px. */
.ad-slot {
  flex: 0 0 auto; position: relative; z-index: 44;
  min-height: var(--adbar-h); overflow: hidden;
  background: var(--navy); color: var(--paper);
  border-top: 2px solid var(--gold); padding: 6px 12px;
}
.ad-slot .ad-eyebrow { margin: 0; font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; opacity: .7; }
.ad-slot .ad-headline { margin: 1px 0; font-size: 15.5px; font-weight: bold; color: var(--gold-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-slot .ad-body { margin: 0; font-size: 12.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ad-slot .ad-cta { margin: 1px 0 0; font-size: 12px; }
.ad-slot .ad-cta a { color: var(--gold-bright); font-weight: bold; }

/* ---------- lodge collectible cards ---------- */
.controls input[type="search"] {
  width: 100%; font: inherit; padding: 9px 11px; border: 2px solid var(--navy); border-radius: 8px;
}
.sort { border: none; margin: 6px 0; padding: 0; display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; }
.sortrow { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin: 6px 0; font-size: 14px; }
/* Collapsible Sort & filter box with tap-to-pick ordered chips (v0.2.3) */
.sortbox { border: 1.5px solid var(--gold); border-radius: 12px; background: #fffdf4; margin: 6px 0; overflow: hidden; }
.sortbox-head { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; background: none; border: none; padding: 8px 12px; cursor: pointer; font: inherit; text-align: left; }
.sortbox-title { font-family: Georgia, 'Times New Roman', serif; font-weight: bold; color: var(--navy); white-space: nowrap; }
.sortbox-summary { flex: 1; min-width: 0; font-size: 13px; color: #5a6472; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sortbox-chevron { color: var(--gold); font-size: 15px; font-weight: bold; }
.sortbox-body { padding: 0 12px 12px; }
.sort-hint { margin: 0 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.sort-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 7px 13px; border-radius: 999px; border: 1.5px solid var(--navy); background: #fff; color: var(--navy); font-size: 14px; font-weight: 600; cursor: pointer; }
.sort-chip.active { background: var(--navy); color: var(--paper); border-color: var(--gold); }
.sort-chip .ord { display: inline-flex; align-items: center; justify-content: center; width: 19px; height: 19px; border-radius: 50%; background: var(--gold); color: var(--navy); font-size: 12px; font-weight: 800; }
.sort legend { font-weight: bold; }
.sort label, .hb label, .check { cursor: pointer; padding: 3px 0; }
.card {
  display: flex; gap: 11px; align-items: flex-start;
  background: #fff; border: 2px solid var(--navy); border-radius: 12px;
  padding: 10px 12px; margin: 8px 0;
  box-shadow: 0 1px 3px rgba(11, 33, 73, .12);
}
.card-body { flex: 1; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 8px; flex-wrap: wrap; }
.card h3 { margin: 0; color: var(--navy); font-size: 16.5px; min-width: 0; overflow-wrap: break-word; }
.meta, .notes { margin: 2px 0; font-size: 13.5px; }
.notes { font-style: italic; }
.band { margin: 3px 0; font-size: 13.5px; }
.row { margin-top: 6px; }
.row.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* v0.3.1 card layout: points beside the state pill, compact right-aligned actions, expandable details */
.head-side { display: inline-flex; align-items: center; gap: 6px; flex: 0 1 auto; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.band-inline { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--navy); font-weight: 600; }
.coin.mini { min-width: 22px; height: 22px; font-size: 12px; border-width: 1.5px; padding: 0 4px; }
.btn.tiny { min-height: 32px; font-size: 12.5px; padding: 4px 10px; }
.actions-right { margin-left: auto; display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.card-details { margin-top: 8px; border-top: 1px dashed #c8cfda; padding-top: 7px; font-size: 13px; }
.card-details a { color: var(--navy); }
.d-row { display: flex; gap: 8px; margin: 3px 0; }
.d-k { flex: 0 0 108px; color: #5b6472; font-weight: 600; }
.d-v { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.d-v a { overflow-wrap: anywhere; }
.d-note { margin: 5px 0 0; font-size: 11.5px; color: #5b6472; font-style: italic; }
/* stamp medallion */
.medallion {
  flex: 0 0 auto; width: 54px; height: 54px; border-radius: 50%;
  border: 3px solid #9aa3ad; color: #6b7280; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: Georgia, serif; text-align: center; line-height: 1.05;
}
.medallion .m-num { font-size: 16px; font-weight: bold; }
.medallion .m-state { font-size: 7.5px; letter-spacing: .5px; text-transform: uppercase; }
.medallion.verified { border-color: var(--gold); color: var(--navy); background: #fdf6dd; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--gold); transform: rotate(-4deg); }
.medallion.legacy { border-color: var(--navy); color: var(--navy); background: #e8ecf3; transform: rotate(3deg); }
/* band points as a coin chip */
.coin {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 6px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-bright), var(--gold));
  color: var(--navy); font-weight: bold; font-family: Georgia, serif; font-size: 15px;
  border: 2px solid #a8861c; vertical-align: middle;
}
.chip {
  border-radius: 999px; padding: 1px 9px; font-size: 12px; white-space: nowrap;
  border: 1.5px solid var(--navy); color: var(--navy);
}
.chip.verified { background: var(--gold); border-color: var(--gold); color: var(--navy); font-weight: bold; }
.chip.legacy { background: var(--navy); color: var(--gold); }
.chip.standing { border-color: #777; color: #444; }
.chip.locked { border-color: #8c1d1d; color: #8c1d1d; font-weight: bold; }
.chip.demo { border-color: #8c6d00; color: #8c6d00; font-style: italic; }

/* ---------- buttons & forms ---------- */
.btn {
  font: inherit; font-size: 15px; min-height: 44px; padding: 8px 16px;
  border-radius: 9px; border: 2px solid var(--navy); cursor: pointer;
  background: #fff; color: var(--navy); display: inline-block; text-align: center;
}
.btn.primary { background: var(--navy); color: var(--gold-bright); font-weight: bold; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: #8c1d1d; color: #8c1d1d; }
.btn.small { min-height: 40px; font-size: 14px; padding: 6px 12px; }
.btn.big { width: 100%; margin: 8px 0; font-size: 17px; min-height: 50px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.saved { background: #1e6b2e; border-color: #1e6b2e; color: #fff; }
.save-btn { margin: 4px 0 10px; }
.file-btn input { display: none; }
.field { display: block; margin: 9px 0; font-weight: bold; font-size: 14.5px; }
.field input, .field select {
  display: block; width: 100%; font: inherit; font-weight: normal;
  padding: 9px; margin-top: 3px; border: 2px solid var(--navy); border-radius: 8px;
}
.field.inline { display: inline-block; margin: 0; }
.field.inline select { display: inline-block; width: auto; margin-left: 6px; }
.hint { font-size: 13px; font-weight: normal; opacity: .8; }
.rules {
  background: #fff3cd; border: 2px solid #8c6d00; border-radius: 10px; padding: 10px; font-weight: bold; font-size: 14px;
}

/* ---------- passport: tallies, stamps grid, ladder ---------- */
.tallies { display: flex; flex-wrap: wrap; gap: 8px; }
.tally {
  flex: 1 1 100px; background: #fff; border: 2px solid var(--navy); border-radius: 12px;
  padding: 8px 6px; text-align: center; font: inherit; cursor: pointer; color: var(--ink);
}
.tally:hover, .tally:active { border-color: var(--gold); background: #fdf6dd; }
.tally strong { display: block; font-size: 24px; color: var(--navy); font-family: Georgia, serif; }
.tally span { font-size: 12px; }
.level-line { font-size: 15.5px; margin: 8px 0; }
.stamp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(102px, 1fr)); gap: 8px; }
.stamp-tile {
  background: #fff; border: 2px solid #c7ccd4; border-radius: 10px; padding: 8px 6px;
  text-align: center; color: #6b7280;
}
.stamp-tile .st-coin { margin: 0 auto 4px; }
.stamp-tile strong { display: block; font-size: 12.5px; line-height: 1.2; }
.stamp-tile .st-date { font-size: 11px; }
.stamp-tile.collected { border-color: var(--gold); color: var(--navy); background: #fdf6dd; animation: stampIn .35s ease; }
.stamp-tile.legacy-tile { border-color: var(--navy); background: #e8ecf3; color: var(--navy); }
@keyframes stampIn { 0% { transform: scale(1.15) rotate(-2deg); } 100% { transform: scale(1) rotate(0); } }
.stamps { list-style: none; padding: 0; }
.stamps li { background: #fff; border-left: 6px solid var(--gold); padding: 8px 10px; margin: 6px 0; font-size: 14px; }
.ladder { list-style: none; padding: 0; }
.ladder li { background: #fff; border: 2px solid var(--navy); border-radius: 10px; padding: 8px 10px; margin: 6px 0; font-size: 14px; }
.ladder .btn { margin-left: 8px; vertical-align: middle; }

/* ---------- player card preview ---------- */
.playercard-box { max-width: 340px; margin: 6px 0; }
.playercard-box canvas { width: 100%; height: auto; border-radius: 12px; border: 2px solid var(--gold); box-shadow: 0 3px 10px rgba(11, 33, 73, .25); }

/* ---------- drill-down ---------- */
.drill-head { display: flex; align-items: center; gap: 10px; }
.drill-head h2 { margin: 6px 0; }
.drill-meta { font-size: 13px; margin: 2px 0; }

/* ---------- rankings ---------- */
.demo-note { color: #8c6d00; font-weight: bold; opacity: 1; }
.scope-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.scope-btn {
  font: inherit; font-size: 13.5px; font-weight: 600; min-height: 40px; padding: 6px 12px;
  border-radius: 999px; border: 2px solid var(--navy); background: #fff; color: var(--navy); cursor: pointer;
}
.scope-btn.active { background: var(--navy); color: var(--gold-bright); }
.rank-list { list-style: none; padding: 0; margin: 8px 0; }
.rank-list li {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 2px solid #c7ccd4; border-radius: 10px; padding: 7px 10px; margin: 5px 0; font-size: 14px;
}
.rank-list li.me { border-color: var(--gold); background: #fdf6dd; font-weight: bold; }
.rank-num { font-family: Georgia, serif; font-size: 18px; font-weight: bold; color: var(--navy); min-width: 30px; text-align: center; }
.rank-main { flex: 1; min-width: 0; overflow-wrap: break-word; }
.rank-sub { font-size: 12px; opacity: .75; font-weight: normal; }
.rank-pts { font-family: Georgia, serif; font-weight: bold; color: var(--navy); white-space: nowrap; }

/* ---------- paywall, toast ---------- */
.sheet-wrap {
  position: fixed; inset: 0; background: rgba(11, 33, 73, .72);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 60;
}
.sheet {
  background: var(--paper); border: 3px solid var(--gold); border-radius: 14px;
  max-width: 520px; width: 100%; padding: 18px;
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  overflow-y: auto; overflow-x: hidden;
}
.sheet h3 { margin-top: 0; color: var(--navy); font-size: 22px; }
.pw-price { font-size: 20px; font-weight: bold; color: var(--navy); }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--adbar-h) + env(safe-area-inset-bottom, 0px) + 14px); z-index: 70;
  background: #1e6b2e; color: #fff; font-weight: bold; font-size: 15px;
  padding: 10px 20px; border-radius: 999px; box-shadow: 0 3px 10px rgba(0, 0, 0, .3);
  max-width: calc(100vw - 24px); text-align: center;
}
body.adfree .toast { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 14px); }
#ci-photo-preview { width: 100%; border-radius: 10px; margin: 8px 0; }
.empty { text-align: center; padding: 18px; }
footer { font-size: 13px; opacity: .75; text-align: center; padding: 10px 0 4px; }

/* ---------- phone-width fit pass (v0.3.2, ~360–400px) ---------- */
@media (max-width: 480px) {
  main { padding: 8px 9px; }
  .playerbar { gap: 8px; padding: 6px 9px; }
  .pb-points { min-width: 44px; }
  .pb-points strong { font-size: 21px; }
  .card { gap: 8px; padding: 9px 9px; }
  .medallion { width: 48px; height: 48px; }
  .medallion .m-num { font-size: 14.5px; }
  .d-k { flex-basis: 84px; }
  .d-row { gap: 6px; }
  .sortbox-head { padding: 8px 10px; }
  .tally { flex-basis: 92px; padding: 7px 4px; }
  .tally strong { font-size: 21px; }
  .stamp-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
  .playercard-box { max-width: 100%; }
  .rank-num { min-width: 26px; font-size: 16px; }
  .rank-list li { gap: 7px; padding: 6px 8px; }
  .drill-head { flex-wrap: wrap; }
  .field.inline select { max-width: calc(100vw - 130px); }
  .ad-slot { padding: 5px 10px; }
  .tab { font-size: 13.5px; padding: 0 2px; }
  #ci-photo-preview { max-height: 50vh; object-fit: contain; }
}
