:root {
  --orange: #f26a1b;
  --orange-deep: #c9500f;
  --ink: #1d1a16;
  --paper: #fbf6ec;
  --paper-2: #f1e8d6;
  --muted: #6f6556;
  --line: rgba(29, 26, 22, .12);
  --wood-1: #a8743f;
  --wood-2: #7a4f27;
  --radius: 18px;
  --display: "Bricolage Grotesque", "Futura", "Avenir Next", system-ui, sans-serif;
  --hand: "Caveat", "Marker Felt", "Bradley Hand", cursive;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --rack-h: 132px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #e9dfcc; color: var(--ink); font-family: var(--body); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; border-radius: 8px; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#fade { position: fixed; inset: 0; background: #fff8ea; opacity: 0; pointer-events: none; transition: opacity .35s ease; z-index: 5; }
#fade.on { opacity: 1; transition: opacity .18s ease; }

/* ---------- top bar ---------- */
.top { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: flex-start; gap: 16px; padding: max(12px, env(safe-area-inset-top)) 16px 0; pointer-events: none; }
.top > * { pointer-events: auto; }
.logo { font-family: var(--display); font-weight: 800; font-size: 22px; letter-spacing: -.02em; text-decoration: none; color: var(--ink); background: var(--paper); padding: 8px 12px; border-radius: 12px; box-shadow: 0 2px 0 rgba(0,0,0,.12); white-space: nowrap; }
.logo span { color: var(--orange); }
.title-block { flex: 1; min-width: 0; padding-top: 2px; text-shadow: 0 1px 0 rgba(255,255,255,.5); }
.title-block small { display: block; font-family: var(--hand); font-size: 22px; line-height: 1; color: var(--orange-deep); }
.title-block h1 { margin: 2px 0 0; font-family: var(--display); font-weight: 800; font-size: clamp(22px, 3.2vw, 40px); line-height: 1; letter-spacing: -.03em; transition: transform .3s; }
.title-block h1.pop { animation: pop .5s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop { 0% { transform: scale(.85); } 100% { transform: scale(1); } }
body.dark .title-block { color: #fff6ea; text-shadow: 0 2px 10px rgba(0,0,0,.6); }
body.dark .title-block small { color: #ffb37d; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 0; background: var(--paper); padding: 8px 12px; border-radius: 999px; box-shadow: 0 2px 0 rgba(0,0,0,.14); font-weight: 600; font-size: 14px; transition: transform .15s, background .15s; }
.chip:hover { transform: translateY(-1px); background: #fff; }
.chip:active { transform: translateY(1px); box-shadow: none; }
.chip i { font-style: normal; background: var(--orange); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; line-height: 18px; }
.chip.icon { padding: 8px 10px; }

/* ---------- side panel ---------- */
#panel { position: fixed; z-index: 9; right: 16px; top: 84px; bottom: calc(var(--rack-h) + 16px + var(--safe-b)); width: min(400px, 34vw); background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: var(--radius); box-shadow: 0 10px 40px rgba(40, 25, 10, .22); display: flex; flex-direction: column; overflow: hidden; transition: transform .35s cubic-bezier(.2,.8,.2,1); }
#sheetHandle { display: none; }
#tabs { display: flex; gap: 4px; padding: 10px 10px 0; overflow-x: auto; scrollbar-width: none; flex: none; }
#tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: transparent; padding: 8px 12px; border-radius: 10px 10px 0 0; font-weight: 700; font-size: 14px; white-space: nowrap; color: var(--muted); border-bottom: 3px solid transparent; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--orange); background: rgba(242,106,27,.08); }
#panelBody { overflow-y: auto; padding: 14px 18px 22px; flex: 1; overscroll-behavior: contain; border-top: 1px solid var(--line); }
#panelBody h2 { font-family: var(--display); font-weight: 800; font-size: 28px; letter-spacing: -.02em; margin: 2px 0 2px; line-height: 1.05; }
#panelBody .place { font-family: var(--hand); font-size: 22px; color: var(--orange-deep); margin: 0; }
#panelBody p { line-height: 1.5; margin: 8px 0; }
.tagline { font-size: 16px; }

.photos { display: flex; gap: 10px; margin: 12px 0 6px; flex-wrap: wrap; }
.polaroid { margin: 0; background: #fff; padding: 7px 7px 26px; box-shadow: 0 6px 16px rgba(0,0,0,.18); transform: rotate(var(--r, -2deg)); position: relative; border: 0; cursor: zoom-in; transition: transform .25s; width: 46%; }
.polaroid:hover { transform: rotate(0) scale(1.03); }
.polaroid img { display: block; width: 100%; aspect-ratio: 4/5; object-fit: cover; background: #ddd; }
.polaroid figcaption { position: absolute; left: 8px; right: 8px; bottom: 3px; font-family: var(--hand); font-size: 17px; line-height: 1; text-align: center; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hipstamp { position: absolute; top: 10px; right: -8px; transform: rotate(12deg); border: 2px solid var(--orange); color: var(--orange); background: rgba(255,255,255,.9); font: 800 10px/1.1 var(--display); padding: 3px 5px; border-radius: 4px; text-transform: uppercase; letter-spacing: .04em; }

.game { margin: 14px 0 4px; padding: 14px; border-radius: 14px; background: var(--paper-2); border: 1px solid var(--line); }
.game h3 { margin: 0 0 2px; font-family: var(--display); font-size: 19px; }
.game .hint { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.game .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { border: 0; border-radius: 12px; padding: 10px 14px; background: #fff; font-weight: 700; box-shadow: 0 2px 0 rgba(0,0,0,.15); transition: transform .12s, background .15s; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; font-size: 15px; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.btn:hover { background: #fffaf2; }
.btn:active, .btn.held { transform: translateY(2px); box-shadow: none; }
.btn.primary { background: var(--orange); color: #fff; }
.btn.primary:hover { background: #ff7a2c; }
.btn.big { padding: 16px 20px; font-size: 17px; }
.btn:disabled { opacity: .5; cursor: default; }
.meter { height: 14px; background: rgba(0,0,0,.08); border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.meter > div { height: 100%; width: 0; background: linear-gradient(90deg, #7ac36a, #f2c41b, #f26a1b, #d62f2f); background-size: 400px 100%; border-radius: 999px; transition: width .1s linear; }
.score { font-family: var(--display); font-weight: 700; font-size: 15px; }
.say { font-family: var(--hand); font-size: 22px; line-height: 1.15; color: var(--ink); min-height: 26px; margin: 8px 0 0; }
.say::before { content: "Tom: "; color: var(--orange-deep); }
.say:empty::before { content: ""; }
input[type="text"] { font: inherit; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; flex: 1; min-width: 0; background: #fff; }
input[type="text"]:focus { border-color: var(--orange); outline: none; }
input[type="range"] { width: 100%; accent-color: var(--orange); }
.list { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }
.list li { margin: 3px 0; }
.lesson { margin: 16px 0 0; padding: 12px 14px; border-left: 4px solid var(--orange); background: #fff; border-radius: 0 12px 12px 0; }
.lesson b { display: block; font: 800 12px var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--orange-deep); }
.lesson span { font-family: var(--hand); font-size: 24px; line-height: 1.1; }
.lesson.dare { border-left-color: #3fb5a8; margin-top: 10px; }
.lesson.dare b { color: #23857a; }
.timingbar { position: relative; height: 34px; background: rgba(0,0,0,.08); border-radius: 10px; overflow: hidden; margin: 8px 0; }
.timingbar .zone { position: absolute; top: 0; bottom: 0; background: rgba(90, 180, 90, .55); }
.timingbar .needle { position: absolute; top: 0; bottom: 0; width: 4px; background: var(--ink); border-radius: 2px; }
.beatring { width: 64px; height: 64px; border-radius: 50%; border: 4px solid var(--orange); display: grid; place-items: center; font-size: 26px; transition: transform .08s; }
.beatring.on { transform: scale(1.18); background: rgba(242,106,27,.15); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; margin: 10px 0; font-size: 13px; }
.stats div { display: flex; flex-direction: column; gap: 3px; }
.stats i { height: 6px; background: rgba(0,0,0,.08); border-radius: 9px; overflow: hidden; }
.stats i::after { content: ""; display: block; height: 100%; width: var(--v); background: var(--orange); border-radius: 9px; transition: width .6s; }
.radar { display: block; width: 210px; margin: 6px auto; }
.secret-badge { display: inline-block; background: var(--ink); color: #ffd36b; font: 800 12px var(--display); letter-spacing: .08em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px; }
.empty .suggest { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.mini { font-size: 13px; color: var(--muted); }
.makemain { margin-top: 10px; }

/* ---------- rack ---------- */
#rack { position: fixed; z-index: 11; left: 0; right: 0; bottom: 0; padding: 0 0 calc(8px + var(--safe-b)); background: linear-gradient(to top, rgba(40, 24, 10, .55), rgba(40,24,10,0)); }
.rack-head { display: flex; justify-content: center; align-items: center; gap: 12px; color: #fff; font-size: 13px; font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,.6); padding-bottom: 2px; }
.link { background: none; border: 0; color: #ffd9b8; text-decoration: underline; font-size: 13px; padding: 4px; }
.rack-scroll { position: relative; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; padding: 0 12px; scroll-snap-type: x proximity; }
.rack-scroll::-webkit-scrollbar { display: none; }
.plank { position: absolute; left: 0; right: 0; top: 10px; height: 22px; min-width: 980px; background: repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 3px, transparent 3px 11px), linear-gradient(var(--wood-1), var(--wood-2)); border-radius: 6px; box-shadow: 0 4px 0 #5a3818, 0 8px 18px rgba(0,0,0,.35); }
#rackList { position: relative; display: flex; gap: 4px; list-style: none; margin: 0 auto; padding: 0; width: max-content; }
#rackList li { scroll-snap-align: center; }
.token { position: relative; width: 70px; border: 0; background: none; padding: 26px 0 0; display: flex; flex-direction: column; align-items: center; transform-origin: 50% 20px; }
.token::before { content: ""; position: absolute; top: 14px; left: 50%; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe9a8, #b8862b 70%); box-shadow: 0 1px 2px rgba(0,0,0,.5); z-index: 2; }
.token::after { content: ""; position: absolute; top: 20px; left: 50%; width: 2px; height: 14px; margin-left: -1px; background: #4a3420; }
.token .badge { position: relative; z-index: 1; margin-top: 8px; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-size: 28px; background: radial-gradient(circle at 35% 30%, #fffaf0, #eadbc0); box-shadow: 0 3px 0 rgba(0,0,0,.25), inset 0 -3px 0 rgba(0,0,0,.08); transition: transform .2s, box-shadow .2s, background .2s; }
.token .lbl { margin-top: 5px; font-size: 11.5px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.8); white-space: nowrap; }
.token:hover .badge { transform: translateY(-3px) rotate(-6deg); }
.token[aria-pressed="true"] .badge { background: radial-gradient(circle at 35% 30%, #ffb37d, var(--orange)); box-shadow: 0 0 0 3px #fff, 0 6px 16px rgba(242,106,27,.7); transform: translateY(-6px) scale(1.06); }
.token .num { position: absolute; z-index: 3; top: 26px; right: 4px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: #fff; font: 800 11px/20px var(--display); text-align: center; opacity: 0; transform: scale(.4); transition: .2s; }
.token[aria-pressed="true"] .num { opacity: 1; transform: none; }
.token.swing { animation: swing .9s ease; }
@keyframes swing { 0% { transform: rotate(0); } 20% { transform: rotate(14deg); } 45% { transform: rotate(-9deg); } 70% { transform: rotate(5deg); } 100% { transform: rotate(0); } }
.token .new { position: absolute; z-index: 3; top: 24px; left: 6px; width: 10px; height: 10px; border-radius: 50%; background: #3fb5a8; box-shadow: 0 0 0 2px #fff; }

/* ---------- toast & burst ---------- */
#toast { position: fixed; z-index: 30; left: 50%; top: 86px; transform: translate(-50%, -20px); opacity: 0; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 600; pointer-events: none; transition: .3s; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#secretBurst { position: fixed; inset: 0; z-index: 25; pointer-events: none; display: grid; place-items: center; }
#secretBurst .card { background: var(--ink); color: #fff; padding: 18px 26px; border-radius: 18px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.4); animation: burst 2.8s cubic-bezier(.2,1.4,.4,1) forwards; max-width: 86vw; }
#secretBurst .card small { color: #ffd36b; font: 800 12px var(--display); letter-spacing: .14em; text-transform: uppercase; }
#secretBurst .card h3 { margin: 4px 0; font: 800 34px/1 var(--display); letter-spacing: -.02em; }
#secretBurst .card p { margin: 0; font-family: var(--hand); font-size: 22px; color: #ffcfa8; }
@keyframes burst { 0% { transform: scale(.3) rotate(-8deg); opacity: 0; } 12% { transform: scale(1.06) rotate(2deg); opacity: 1; } 20% { transform: scale(1) rotate(0); } 85% { opacity: 1; } 100% { opacity: 0; transform: translateY(-30px); } }
.confetti { position: fixed; z-index: 24; top: -10px; width: 9px; height: 14px; pointer-events: none; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- dialogs ---------- */
dialog { border: 0; border-radius: 22px; padding: 26px; background: var(--paper); color: var(--ink); max-width: min(640px, 94vw); max-height: 88vh; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(30, 18, 8, .55); backdrop-filter: blur(3px); }
dialog h2 { font: 800 28px/1.05 var(--display); margin: 0 0 10px; letter-spacing: -.02em; }
dialog .close { position: absolute; top: 12px; right: 12px; border: 0; background: rgba(0,0,0,.06); width: 36px; height: 36px; border-radius: 50%; font-size: 16px; }
dialog .row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
#postcardImg { width: 100%; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.2); display: block; }
.stamps { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; margin: 12px 0 18px; }
.stamp { border: 2px dashed rgba(0,0,0,.2); border-radius: 12px; padding: 8px 4px; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.stamp span { display: block; font-size: 28px; filter: grayscale(1) opacity(.35); }
.stamp.got { border: 2px solid var(--orange); color: var(--ink); background: #fff; transform: rotate(var(--r)); }
.stamp.got span { filter: none; }
.secrets { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.secrets li { padding: 8px 12px; border-radius: 10px; background: #fff; font-size: 14px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.secrets li.locked { background: rgba(0,0,0,.05); color: var(--muted); }
.secrets li b { font-family: var(--display); }
.manifesto { font-family: var(--hand); font-size: 22px; line-height: 1.25; margin: 6px 0 0; padding-left: 20px; }

#lightbox { position: fixed; inset: 0; z-index: 40; background: rgba(15, 10, 5, .88); display: grid; place-items: center; padding: 20px; cursor: zoom-out; }
#lightbox[hidden] { display: none; }
#lightbox img { max-width: 100%; max-height: 80vh; border: 10px solid #fff; border-bottom-width: 50px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
#lightbox p { color: #fff; font-family: var(--hand); font-size: 26px; margin: -46px 0 0; color: #333; position: relative; }

/* ---------- intro & loading ---------- */
#intro { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(30,18,8,.45); backdrop-filter: blur(4px); }
#intro[hidden] { display: none; }
.intro-card { background: var(--paper); border-radius: 26px; padding: 30px 28px; max-width: 480px; box-shadow: 0 30px 80px rgba(0,0,0,.35); animation: rise .6s cubic-bezier(.2,1.3,.4,1); }
@keyframes rise { from { transform: translateY(30px) scale(.96); opacity: 0; } }
.intro-card .eyebrow { margin: 0; font-family: var(--hand); font-size: 24px; color: var(--orange-deep); }
.intro-card h2 { margin: 0 0 8px; font: 800 54px/.95 var(--display); letter-spacing: -.04em; }
.intro-card h2 em { font-style: normal; color: var(--orange); }
.intro-card ol { padding-left: 20px; line-height: 1.6; }
.intro-card .row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
#loading { position: fixed; inset: 0; z-index: 60; display: grid; place-content: center; justify-items: center; background: #f4ead8; transition: opacity .5s; font-family: var(--hand); font-size: 26px; }
#loading.done { opacity: 0; pointer-events: none; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 5px solid rgba(242,106,27,.25); border-top-color: var(--orange); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; background: var(--paper); font-size: 20px; z-index: 99; margin: 0; }

/* ---------- mobile ---------- */
@media (max-width: 820px) {
  :root { --rack-h: 140px; }
  .top { flex-wrap: wrap; gap: 8px; padding-left: 10px; padding-right: 10px; }
  .logo { font-size: 17px; padding: 6px 9px; }
  .title-block { order: 3; flex-basis: 100%; }
  .title-block small { font-size: 18px; }
  .title-block h1 { font-size: 24px; }
  .actions { flex: 1; gap: 6px; }
  .chip { padding: 7px 9px; font-size: 13px; }
  .chip b { display: none; }
  #panel { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(var(--rack-h) + var(--safe-b)); height: 40vh; border-radius: 20px 20px 14px 14px; }
  #panel.collapsed { transform: translateY(calc(40vh - 86px)); }
  .polaroid { width: 40%; }
  .rack-head { font-size: 12px; }
  #sheetHandle { display: grid; place-items: center; border: 0; background: none; height: 20px; flex: none; padding: 0; }
  #sheetHandle span { width: 44px; height: 5px; border-radius: 9px; background: rgba(0,0,0,.2); }
  #tabs { padding-top: 0; }
  #panelBody { padding: 12px 14px 18px; }
  #panelBody h2 { font-size: 24px; }
  .token { width: 62px; }
  .token .badge { width: 48px; height: 48px; font-size: 24px; }
  .intro-card h2 { font-size: 44px; }
  #toast { top: auto; bottom: calc(var(--rack-h) + 50vh); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
