:root {
  --paper: #f4f0e6;
  --ink: #1e1c17;
  --soft: #5d584c;
  --rule: #d4ccba;
  --rust: #8b3d24;
  --serif: 'Alegreya', Georgia, 'Times New Roman', serif;
  --sans: 'Alegreya Sans', 'Gill Sans', 'Trebuchet MS', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #14150f; color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; touch-action: none; -webkit-user-select: none; user-select: none; }
button { touch-action: manipulation; }
#card, #guide { touch-action: pan-y; -webkit-user-select: text; user-select: text; }
canvas#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
canvas#view.dragging { cursor: grabbing; }
canvas#view.over { cursor: pointer; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }

/* loading */
#loading { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: #14150f; color: #e9e4d6; transition: opacity 1.4s ease; }
#loading.done { opacity: 0; pointer-events: none; }
.loading-inner { width: min(320px, 78vw); }
#loading h1 { font-family: var(--serif); font-weight: 700; font-size: 44px; line-height: 1; margin: 0 0 6px; }
#loading p { margin: 0; font-size: 18px; color: #b9b3a2; }
#loading .bar { height: 2px; background: #33342b; margin: 26px 0 10px; }
#loading .bar i { display: block; height: 100%; width: 0; background: #e9e4d6; transition: width .3s ease; }
#loading .small { font-size: 15px; color: #8d8878; }

/* top line */
#top { position: fixed; left: 0; right: 0; top: 0; z-index: 3; display: flex; justify-content: space-between; align-items: flex-start; padding: max(18px, env(safe-area-inset-top)) 22px 0; pointer-events: none; color: #fbf8ef; text-shadow: 0 1px 10px rgba(0, 0, 0, .55); }
#top .place strong { display: block; font-family: var(--serif); font-weight: 700; font-size: 26px; line-height: 1.05; }
#top .place span { font-size: 16px; opacity: .92; }
.top-buttons { display: flex; gap: 8px; pointer-events: auto; }
#fs { width: 38px; height: 38px; display: grid; place-items: center; background: var(--paper); color: var(--ink); border-radius: 3px; box-shadow: 0 2px 14px rgba(0, 0, 0, .3); }
#fs svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#guide-open { pointer-events: auto; font-size: 17px; font-weight: 500; padding: 8px 14px; background: var(--paper); color: var(--ink); border-radius: 3px; text-shadow: none; box-shadow: 0 2px 14px rgba(0, 0, 0, .3); }
#guide-open:hover, #guide-open:focus-visible { background: #fff; }

#hint { position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 3; margin: 0; padding: 0 16px; width: max-content; max-width: 92vw; text-align: center; font-size: 17px; color: #fbf8ef; text-shadow: 0 1px 10px rgba(0, 0, 0, .7); pointer-events: none; transition: opacity .8s ease; }
#hint.gone { opacity: 0; }

#tip { position: fixed; z-index: 4; pointer-events: none; padding: 4px 9px; background: var(--paper); color: var(--ink); font-size: 15px; font-weight: 500; border-radius: 2px; box-shadow: 0 2px 10px rgba(0, 0, 0, .35); white-space: nowrap; transform: translate(14px, 16px); }

#pin { position: fixed; z-index: 2; left: 0; top: 0; pointer-events: none; display: flex; align-items: center; gap: 8px; will-change: transform; }
#pin i { width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; border-radius: 50%; background: var(--paper); box-shadow: 0 0 0 2px rgba(30, 28, 23, .55), 0 1px 8px rgba(0, 0, 0, .5); }
#pin span { margin-top: -6px; padding: 2px 8px; background: var(--paper); font-size: 15px; font-weight: 500; border-radius: 2px; box-shadow: 0 2px 10px rgba(0, 0, 0, .35); white-space: nowrap; }

/* specimen card */
#card { position: fixed; z-index: 5; left: 22px; bottom: 22px; width: min(390px, calc(100vw - 44px)); max-height: min(74vh, 640px); overflow: auto; padding: 20px 22px 18px; background: var(--paper); border-radius: 3px; box-shadow: 0 10px 40px rgba(0, 0, 0, .42); animation: rise .28s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
#card-close, #guide-close { float: right; font-size: 15px; color: var(--soft); text-decoration: underline; text-underline-offset: 3px; padding: 4px 0 4px 12px; }
#card-close:hover, #guide-close:hover { color: var(--ink); }
#card .tag { margin: 0 0 4px; font-size: 15px; color: var(--rust); font-weight: 500; }
#card h2 { margin: 0 0 10px; font-family: var(--serif); font-weight: 700; font-size: 30px; line-height: 1.08; }
#card-text p { margin: 0 0 10px; font-size: 17.5px; line-height: 1.42; }
#card dl { margin: 14px 0 0; padding: 0; border-top: 1px solid var(--rule); }
#card dl div { display: flex; justify-content: space-between; gap: 18px; padding: 7px 0; border-bottom: 1px solid var(--rule); font-size: 16px; }
#card dt { color: var(--soft); flex: none; }
#card dd { margin: 0; text-align: right; font-weight: 500; }

/* field guide */
#guide { position: fixed; z-index: 6; top: 0; right: 0; bottom: 0; width: min(340px, 100vw); overflow: auto; padding: max(20px, env(safe-area-inset-top)) 22px 24px; background: var(--paper); box-shadow: -10px 0 40px rgba(0, 0, 0, .4); animation: slide .26s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.guide-head h2 { display: inline-block; margin: 0; font-family: var(--serif); font-weight: 700; font-size: 28px; }
.guide-count { margin: 4px 0 6px; font-size: 15px; color: var(--soft); }
#guide h3 { margin: 18px 0 2px; font-size: 15px; font-weight: 500; color: var(--rust); }
#guide ul { list-style: none; margin: 0; padding: 0; }
#guide li button { display: flex; justify-content: space-between; align-items: baseline; width: 100%; padding: 8px 0; border-bottom: 1px solid var(--rule); font-size: 18px; text-align: left; }
#guide li button:hover, #guide li button:focus-visible { color: var(--rust); }
#guide li button small { font-size: 14px; color: var(--soft); }
#guide li button.seen small::before { content: 'Seen'; }
.credits { margin: 22px 0 0; font-size: 14px; line-height: 1.4; color: var(--soft); }

/* walking stick for touch screens: bottom left, small */
#stick { position: fixed; z-index: 3; left: max(18px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom)); width: 104px; height: 104px; border-radius: 50%; background: rgba(244, 240, 230, .16); box-shadow: inset 0 0 0 1.5px rgba(244, 240, 230, .7), 0 2px 14px rgba(0, 0, 0, .25); touch-action: none; display: grid; place-items: center; }
#stick i { width: 44px; height: 44px; border-radius: 50%; background: var(--paper); box-shadow: 0 2px 10px rgba(0, 0, 0, .35); pointer-events: none; }
#stick.on i { transition: none; }
#stick:not(.on) i { transition: transform .18s ease-out; }
#stick span { position: absolute; bottom: -22px; left: 0; right: 0; text-align: center; font-size: 14px; color: #fbf8ef; text-shadow: 0 1px 8px rgba(0, 0, 0, .7); pointer-events: none; }
#stick.used span { display: none; }

@media (max-width: 640px) {
  #top { padding-left: 16px; padding-right: 16px; }
  #top .place strong { font-size: 22px; }
  #card { left: 0; right: 0; bottom: 0; width: 100%; max-height: 52vh; border-radius: 10px 10px 0 0; padding: 18px 18px max(16px, env(safe-area-inset-bottom)); }
  #card h2 { font-size: 26px; }
  #card-text p { font-size: 16.5px; }
  #hint { font-size: 15px; bottom: max(150px, calc(env(safe-area-inset-bottom) + 150px)); }
  #tip { display: none; }
}
@media (prefers-reduced-motion: reduce) { #card, #guide { animation: none; } }

/* five-star card (gus-pulse r.js): above the walk stick on a phone, above the hint line elsewhere */
@media (pointer: coarse) and (max-width: 640px) { [data-gus-rate] { bottom: calc(max(18px, env(safe-area-inset-bottom)) + 122px) !important; } }
@media (min-width: 641px) { [data-gus-rate] { bottom: calc(max(22px, env(safe-area-inset-bottom)) + 62px) !important; } }
