:root {
  --ink: #1d1b26;
  --ink2: #5b5868;
  --paper: rgba(255, 255, 255, 0.86);
  --line: rgba(29, 27, 38, 0.1);
  --green: #2f7a4a;
  --gold: #e8a800;
  --red: #c5242b;
  --r: 18px;
  --shadow: 0 8px 30px rgba(20, 30, 60, 0.18);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fd0f0; overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
html, body { touch-action: pan-x pan-y; } /* pinching zooms the 3D view, never the page itself (panels still scroll) */
button, a, input, .tag { touch-action: manipulation; } /* no double-tap zoom on phones */
.toast { word-break: break-all; }
button { cursor: pointer; border: 0; }
[hidden] { display: none !important; }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

/* glass panels */
.top, .card, .sheet, .tools button, .dock, .pill, .toast {
  background: var(--paper);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  backdrop-filter: blur(16px) saturate(1.6);
  box-shadow: var(--shadow);
}

.top {
  position: fixed; top: calc(max(12px, env(safe-area-inset-top))); left: 12px; right: 12px;
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 10px 12px; border-radius: var(--r); z-index: 5;
}
.brand { display: flex; gap: 10px; align-items: center; min-width: 0; }
.brand img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; background: #fff; }
.brand h1 { font-size: 17px; margin: 0; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; }
.brand p { margin: 1px 0 0; font-size: 13px; color: var(--ink2); }
.brand p b { color: var(--ink); }
.find { display: flex; gap: 6px; flex: 1 1 260px; max-width: 360px; }
.find input {
  flex: 1; min-width: 0; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; font-size: 15px; outline: none;
}
.find input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(47, 122, 74, 0.18); }
.find button { padding: 0 16px; border-radius: 999px; background: var(--green); color: #fff; font-weight: 700; }

.pill { position: fixed; left: 50%; transform: translateX(-50%); padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; z-index: 4; pointer-events: none; white-space: nowrap; }
.hint { bottom: calc(86px + env(safe-area-inset-bottom)); transition: opacity 0.6s; }
.demo { top: calc(max(12px, env(safe-area-inset-top)) + 76px); background: #ffe9a8; }

.tools { position: fixed; right: 12px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 4; }
.tools button { width: 44px; height: 44px; border-radius: 14px; font-size: 20px; font-weight: 700; }
.tools button:hover, .dock button:hover { background: #fff; }
.tools button.on { background: var(--green); color: #fff; }

.dock {
  position: fixed; bottom: calc(max(12px, env(safe-area-inset-bottom))); left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px; padding: 5px; border-radius: 999px; z-index: 5; max-width: calc(100% - 24px);
}
.dock button, .dock a { padding: 9px 14px; border-radius: 999px; background: transparent; font-size: 14px; font-weight: 700; white-space: nowrap; text-decoration: none; color: inherit; }
.dock .cta { background: linear-gradient(135deg, #f58529, #dd2a7b 50%, #8134af); color: #fff; }

.card, .sheet {
  position: fixed; z-index: 6; border-radius: 22px; padding: 18px;
  left: 12px; bottom: calc(70px + env(safe-area-inset-bottom)); width: min(360px, calc(100% - 24px));
  animation: up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.sheet { max-height: min(70vh, 560px); overflow: auto; width: min(420px, calc(100% - 24px)); }
@keyframes up { from { transform: translateY(16px); opacity: 0; } }
/* close button: a 44 px tap area around a small visible circle */
.x { position: absolute; top: 2px; right: 2px; width: 44px; height: 44px; display: grid; place-items: center; background: transparent; z-index: 2; touch-action: manipulation; }
.x span { width: 30px; height: 30px; border-radius: 50%; background: rgba(0, 0, 0, 0.07); display: grid; place-items: center; font-size: 20px; line-height: 1; pointer-events: none; }
.card h2, .sheet h2 { margin: 0 0 2px; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; padding-right: 36px; word-break: break-word; }
.card { padding: 12px 14px; }
.card h2 { font-size: 19px; margin: 0; }
.card-head p { margin: 2px 0 0; color: var(--ink2); font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.badge { display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; background: #eee; color: var(--ink); }
.badge.gold { background: linear-gradient(135deg, #ffe17a, #e8a800); color: #4a3200; }
.badge.silver { background: linear-gradient(135deg, #ffffff, #b8c4d4); color: #2a3442; }
.badge.rainbow { background: linear-gradient(90deg, #ff5a5a, #ffb23a, #ffe94a, #5ad86a, #3aa8ff, #a05aff); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.35); }
.badge.marsh { background: var(--green); color: #fff; }
.doing { margin: 8px 0 6px; font-size: 14px; font-weight: 700; }
.doing::before { content: "Today: "; color: var(--ink2); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 10px; font-size: 12px; color: var(--ink2); }
.chips span { background: rgba(255, 255, 255, 0.75); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; }
.chips b { color: var(--ink); }
.row { display: flex; gap: 8px; }
.row button { flex: 1; padding: 9px; border-radius: 11px; font-weight: 800; font-size: 14px; background: #fff; border: 1px solid var(--line); }
.row .primary { background: var(--ink); color: #fff; border-color: var(--ink); }

.rules { padding-left: 18px; margin: 12px 0; line-height: 1.45; }
.rules li { margin-bottom: 8px; }
.small { font-size: 13px; color: var(--ink2); line-height: 1.45; }
.log { list-style: none; padding: 0; margin: 12px 0 0; }
.log li { padding: 12px 0; border-top: 1px solid var(--line); }
.log .d { font-size: 12px; font-weight: 800; color: var(--green); text-transform: uppercase; letter-spacing: 0.06em; }
.log h3 { margin: 2px 0 4px; font-size: 16px; }
.log p { margin: 0; font-size: 14px; color: var(--ink2); line-height: 1.4; }
.log a { display: inline-block; margin-top: 6px; font-weight: 700; color: #c13584; text-decoration: none; }
.coffee { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; padding: 10px 12px; border-radius: 14px; background: #29abe0; color: #fff; text-decoration: none; box-shadow: 0 3px 0 #1a86b5; }
.coffee:active { transform: translateY(2px); box-shadow: 0 1px 0 #1a86b5; }
.coffee .cup { font-size: 24px; line-height: 1; }
.coffee b { display: block; font-size: 15px; }
.coffee small { display: block; font-size: 12px; opacity: 0.92; }
.coffee .go { margin-left: auto; font-weight: 800; }
.callout { margin: 10px 0 4px; padding: 10px 12px; border-radius: 14px; background: #fff4cc; border: 2px solid #f0b400; font-size: 13px; line-height: 1.4; }
.callout b { display: block; font-size: 14px; margin-bottom: 2px; }
.callout b::before { content: "☝️ "; }
.shop-h { margin: 14px 0 0; font-size: 15px; font-weight: 800; }
.shop-h small { font-weight: 600; color: var(--ink2); font-size: 12px; }
.shop { list-style: none; padding: 0; margin: 8px 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.shop li { min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 6px 6px 8px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.shop .pv { position: relative; width: 100%; max-width: 110px; }
.shop canvas { display: block; width: 100%; aspect-ratio: 1; background: radial-gradient(circle at 50% 60%, #fff6d8, #ffffff 70%); border-radius: 10px; }
.shop .nm { font-size: 12px; font-weight: 800; line-height: 1.2; }
.shop .nm em { font-style: normal; color: var(--green); }
.shop .pr { font-size: 13px; font-weight: 800; color: var(--green); line-height: 1; }
.shop .buy { display: block; width: 100%; margin-top: auto; padding: 6px 2px; border-radius: 9px; background: var(--green); color: #fff; font-size: 11px; font-weight: 800; line-height: 1.2; text-decoration: none; white-space: normal; overflow-wrap: anywhere; }
.shop .buy.dm { background: linear-gradient(90deg, #f58529, #dd2a7b, #8134af); }
.shop li.req { background: #eef6ff; border-color: #b8d8f5; }
.shop .buy.off { background: #ecebf0; color: var(--ink2); white-space: normal; line-height: 1.2; }
/* coming soon: greyed out, dashed border, a ribbon across the picture */
.shop li.soon { background: #f4f3f7; border: 1px dashed #c4c2cc; }
.shop li.soon canvas { filter: grayscale(1); opacity: 0.45; background: #eceaf2; }
.shop li.soon .nm { color: var(--ink2); }
.ribbon { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-12deg); background: #5b5868; color: #fff; font-size: 10px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,0.2); }

#tags { position: fixed; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.tag {
  position: absolute; left: 0; top: 0; transform-origin: 50% 100%;
  padding: 2px 7px; border-radius: 7px; font-size: 12px; font-weight: 800; white-space: nowrap;
  background: rgba(255, 255, 255, 0.92); color: var(--ink); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  pointer-events: auto; cursor: pointer;
}
.tag.gold { background: linear-gradient(135deg, #fff2b8, #ffc21a); color: #4a3000; box-shadow: 0 0 0 2px #e8a000, 0 0 14px rgba(255, 194, 26, 0.85); font-size: 13px; }
.tag.silver { background: linear-gradient(135deg, #ffffff, #c8d2de); color: #2a3442; box-shadow: 0 0 0 2px #a8b4c4, 0 0 10px rgba(200, 220, 255, 0.7); }
.tag.rainbow { background: linear-gradient(90deg, #ffd6d6, #fff0c4, #d8f6dc, #d4ecff, #ead8ff); }
.tag.me { background: var(--ink); color: #fff; z-index: 3; }
.tag.marsh { background: var(--green); color: #fff; }

.toast { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 12px 18px; border-radius: 14px; font-weight: 700; z-index: 9; max-width: calc(100% - 32px); text-align: center; }
.loading { position: fixed; inset: 0; display: grid; place-items: center; background: #8fd0f0; color: #fff; font-size: 22px; font-weight: 800; z-index: 20; transition: opacity 0.5s; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); }
.loading.gone { opacity: 0; pointer-events: none; }

@media (max-width: 560px) {
  .brand h1 { font-size: 15px; }
  .find { max-width: none; }
  .tools { top: auto; bottom: calc(80px + env(safe-area-inset-bottom)); transform: none; }
  .tools button { width: 40px; height: 40px; }
  .dock button, .dock a { padding: 9px 10px; font-size: 13px; }
  .card, .sheet { left: 12px; right: 12px; width: auto; }
  .wide { display: none; }
  body.picked .find, body.picked .demo, body.picked .tools, body.picked .hint { display: none; } /* the side buttons sat right over the card's × */
  body.picked .top { padding: 8px 12px; }
  .hint { bottom: calc(130px + env(safe-area-inset-bottom)); }
  .demo { top: calc(max(12px, env(safe-area-inset-top)) + 112px); }
}

/* terms dropdown */
.terms { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.terms summary { cursor: pointer; font-weight: 800; font-size: 14px; list-style: none; display: flex; align-items: center; gap: 6px; }
.terms summary::-webkit-details-marker { display: none; }
.terms summary::after { content: "▾"; color: var(--ink2); transition: transform 0.2s; }
.terms[open] summary::after { transform: rotate(180deg); }
.terms-body { font-size: 13px; line-height: 1.45; color: var(--ink); }
.terms-body h4 { margin: 12px 0 4px; font-size: 13px; }
.terms-body p { margin: 0 0 6px; }
.terms-body ul { margin: 0 0 6px; padding-left: 18px; }
.terms-body li { margin-bottom: 4px; }
.terms-line { margin: 8px 0 0; }
.linkish { background: none; padding: 0; color: #2f6fb8; text-decoration: underline; font-weight: 700; font-size: inherit; }
.terms-body a { color: #2f6fb8; font-weight: 700; }

/* Phones: the frosted-glass blur behind the panels makes the browser re-blur the 3D view under every panel on every
   frame, which is very costly on phone graphics chips. Use solid panels instead, and plain name tags without glows. */
@media (pointer: coarse) {
  .top, .card, .sheet, .tools button, .dock, .pill, .toast { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(255, 255, 255, 0.96); }
  .tag { box-shadow: none; will-change: transform; }
  .tag.gold { box-shadow: 0 0 0 2px #e8a000; }
  .tag.silver { box-shadow: 0 0 0 2px #a8b4c4; }
}
#debug { position: fixed; left: 8px; bottom: 90px; z-index: 50; padding: 6px 8px; border-radius: 8px; background: rgba(0, 0, 0, 0.75); color: #fff; font: 600 11px/1.35 ui-monospace, Menlo, monospace; white-space: pre; pointer-events: none; }
