/* Snap. Tokens: values from the site's assets/rebrand/brand-tokens.css (Quiet Kernel 1.0) unless noted.
   Curves: studio Clumsy motion (land, soft). Fonts: the site's own, self-hosted in assets/rebrand/fonts.css. */
:root {
  --bg: #0B0F10;
  --surface: #111719;
  --raised: #1A1F23;
  --line: #3A4248;
  --text: #EBEAEC;
  --text-hi: #F7F6F8;                    /* hover lift for the light button; near the site's #fff hover */
  --text-2: #AEBCC2;
  --muted: #7A8FA0;
  --control: #80949A;
  --signal: #6CE5D6;
  --warm: #EF8A6B;                       /* bouncy ledges when the photo has no red of its own */
  --photo-dim: rgba(11, 15, 16, 0.36);   /* --bg over the photo so ledges read */
  --ledge-under: rgba(11, 15, 16, 0.55); /* --bg under each ledge line */
  --cloudlet: rgba(235, 234, 236, 0.88); /* --text, slightly see-through */
  --scrim: rgba(11, 15, 16, 0.72);
  --paper: #F1E4CD;                      /* the drawing pad's paper (draw.js PAPER) */
  --pen-line: #34495E;                   /* draw.js PENS.line */
  --pen-bouncy: #E2483D;                 /* draw.js PENS.bouncy: a red the level maker reads as bouncy */
  --font-display: "Inter Tight", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --land: cubic-bezier(.2, 1.35, .35, 1);
  --soft: cubic-bezier(.2, .8, .2, 1);
  --press: 120ms;
  --state: 180ms;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow-x: clip; background: var(--bg); color: var(--text); }
body { font: 400 1.0625rem/1.5 var(--font-body); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
.screen { position: fixed; inset: 0; height: 100dvh; }
.screen[hidden], [hidden] { display: none !important; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.safe-probe { position: fixed; left: 0; bottom: 0; width: 0; height: env(safe-area-inset-bottom, 0px); visibility: hidden; pointer-events: none; }
.noscript { position: fixed; inset: auto 24px 24px; margin: 0; color: var(--text-2); }

/* Buttons */
.btn {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 14px 20px; border-radius: 14px;
  border: 1px solid var(--control); background: transparent; color: var(--text);
  font: 500 1.0625rem/1.2 var(--font-body); text-align: center; cursor: pointer;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  transition: transform var(--press) var(--soft), background-color var(--state) var(--soft), border-color var(--state) var(--soft), opacity var(--state) var(--soft);
}
.btn--primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn--quiet { border-color: transparent; color: var(--text-2); }
@media (hover: hover) {
  .btn:hover { background: var(--raised); }
  .btn--primary:hover { background: var(--text-hi); border-color: var(--text-hi); }
}
.btn:active { transform: scale(.97); }
.btn:focus-visible, .btn:has(input:focus-visible) { outline: 2px solid var(--signal); outline-offset: 3px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:disabled:active { transform: none; }

/* Start */
/* Room for Puff (snap-play.md): the gap above the headline never shrinks below his standing height, so on a
   short window he stands below the top link, never over it. One headline size feeds both. */
.start {
  --title-size: clamp(2.5rem, 11vw, 4.25rem); --puff-room: calc(var(--title-size) * 1.25 + 12px);
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(var(--puff-room), 1fr) auto;
  max-width: 560px; margin: 0 auto; overflow-y: auto;
  padding: max(20px, env(safe-area-inset-top)) 24px calc(28px + env(safe-area-inset-bottom, 0px));
}
.start__puff { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; z-index: 1; }
.start__home {
  justify-self: start; display: inline-flex; align-items: center; min-height: 44px;
  color: var(--text-2); font: 500 .9375rem/1.2 var(--font-body); text-decoration: none;
}
.start__home:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; border-radius: 6px; }
@media (hover: hover) { .start__home:hover { color: var(--text); } }
.start__copy { grid-row: 3; }
.start__title {
  margin: 0 0 14px; font: 600 var(--title-size)/.98 var(--font-display);
  letter-spacing: -.025em; overflow-wrap: break-word; min-width: 0; max-width: 11ch;
}
.start__line { margin: 0 0 28px; color: var(--text-2); max-width: 30ch; }
.start__actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.start__note { margin: 16px 0 0; color: var(--muted); font-size: .875rem; }
.start__note--err { color: var(--text); }

/* No photo? The Draw tile and the ready levels (snap-sources.md) */
.start__or { margin: 24px 0 10px; color: var(--text-2); font-size: .9375rem; }
/* One row that scrolls sideways edge to edge: 76 px tiles, so at 390 four sit in view and the next one peeks. */
.start__levels {
  display: grid; grid-auto-flow: column; grid-auto-columns: 76px; gap: 10px;
  margin: 0 -24px; padding: 0 24px 4px; scroll-padding: 0 24px;
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: none;
}
.start__levels::-webkit-scrollbar { display: none; }
.start__levels .tile { scroll-snap-align: start; min-width: 0; font-size: .8125rem; }
.tile__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile {
  display: grid; gap: 6px; padding: 0; border: 0; background: none; color: var(--text-2); cursor: pointer;
  font: 500 .875rem/1.2 var(--font-body); text-align: center; -webkit-tap-highlight-color: transparent;
  transition: transform var(--press) var(--soft), color var(--state) var(--soft);
}
.tile__art {
  display: block; width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: cover;
  border: 1px solid var(--line); border-radius: 10px; background: var(--raised);
  transition: border-color var(--state) var(--soft);
}
.tile__art--paper { background: var(--paper); }
@media (hover: hover) { .tile:hover { color: var(--text); } .tile:hover .tile__art { border-color: var(--control); } }
.tile:active { transform: scale(.97); }
.tile:focus-visible { outline: none; }
.tile:focus-visible .tile__art { outline: 2px solid var(--signal); outline-offset: 3px; }
.tile__best { min-height: 1em; margin-top: -3px; color: var(--muted); font-size: .75rem; line-height: 1; font-variant-numeric: tabular-nums; }
/* Today's tile keeps its ring, hovered or not (snap-daily.md) */
.tile--today .tile__art, .tile--today:hover .tile__art { border-color: var(--signal); box-shadow: 0 0 0 1px var(--signal); }
.tile--today .tile__name { color: var(--text); }

/* Draw a level */
.draw {
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; gap: 12px;
  max-width: 560px; margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
}
.draw__top { display: flex; align-items: center; gap: 4px; min-width: 0; }
.draw__back { flex: none; min-height: 44px; padding: 10px 12px; }
.draw__hint { margin: 0; min-width: 0; color: var(--text-2); font-size: .9375rem; line-height: 1.35; }
.draw__stage { min-height: 0; display: grid; place-items: center; }
.draw__pad { display: block; border-radius: 14px; background: var(--paper); touch-action: none; cursor: crosshair; }
.draw__tools { display: flex; align-items: center; gap: 4px; min-width: 0; }
.draw__pens { display: flex; gap: 8px; margin-right: auto; }
.pen {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--text-2);
  font: 500 .9375rem/1 var(--font-body); cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform var(--press) var(--soft), background-color var(--state) var(--soft), border-color var(--state) var(--soft), color var(--state) var(--soft);
}
.pen.is-on { border-color: var(--text); background: var(--raised); color: var(--text); }
.pen:active { transform: scale(.97); }
.pen:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }
.pen__swatch { width: 18px; height: 6px; border-radius: 3px; background: var(--pen-line); }
.pen__swatch--bouncy { background: var(--pen-bouncy); }
.draw__tool { min-height: 44px; padding: 10px 12px; }

/* Play */
.play { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.play__stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hud {
  position: absolute; inset: 0 0 auto; display: flex; justify-content: space-between; align-items: baseline;
  padding: max(16px, env(safe-area-inset-top)) 20px 0; pointer-events: none;
}
.hud p { margin: 0; }
.hud__drops { color: var(--text-2); font: 500 1rem/1.2 var(--font-body); }
.hud__num { color: var(--text); font: 600 1.75rem/1 var(--font-display); font-variant-numeric: tabular-nums; }
.hud__drops .hud__num { display: inline-block; transform-origin: 50% 85%; }
.hud__num.pop { animation: pop 420ms var(--land); }
@keyframes pop { from { transform: scale(1.35); color: var(--signal); } }
.hint {
  position: absolute; left: 20px; right: 20px; top: calc(max(16px, env(safe-area-inset-top)) + 56px);
  margin: 0; color: var(--text); font: 500 1.125rem/1.3 var(--font-body); pointer-events: none;
  transition: opacity 420ms var(--soft), filter 420ms var(--soft);
}
.hint.is-gone { opacity: 0; filter: blur(8px); }

/* End */
.end {
  display: grid; align-items: end; overflow-y: auto; background: var(--scrim);
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom, 0px));
}
.end__panel {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 18px 16px;
  width: 100%; max-width: 520px; margin: 0 auto; padding: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
}
.end__gif {
  grid-row: span 1; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover;
  border-radius: 14px; background: var(--raised); display: block;
}
.end__copy { min-width: 0; align-self: end; }
.end__title { margin: 0 0 14px; font: 600 1.625rem/1.05 var(--font-display); letter-spacing: -.02em; overflow-wrap: break-word; }
.stat { margin: 0 0 6px; display: flex; align-items: baseline; gap: 8px; }
.stat__num { font: 600 2.25rem/1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat__label { color: var(--text-2); font-size: .9375rem; }
.end__new { margin: 10px 0 0; color: var(--signal); font-size: .9375rem; }
.end__best { margin: 10px 0 0; color: var(--text); font-size: .9375rem; }
.end__actions { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.end__share { grid-column: 1 / -1; }
.end__panel:not(:has(.end__gif:not([hidden]))) { grid-template-columns: minmax(0, 1fr); }

/* A challenge link's card (snap-challenge.md) */
.challenge { display: grid; place-items: center; overflow-y: auto; padding: max(24px, env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom, 0px)); }
.challenge__panel { display: grid; justify-items: center; width: 100%; max-width: 360px; text-align: center; }
.challenge__art {
  width: 168px; height: auto; aspect-ratio: 3 / 4; object-fit: cover; margin-bottom: 22px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--raised);
}
.challenge__title { margin: 0 0 8px; min-width: 0; overflow-wrap: break-word; text-wrap: balance; font: 600 clamp(1.75rem, 8vw, 2.25rem)/1.05 var(--font-display); letter-spacing: -.02em; }
.challenge__line { margin: 0 0 26px; color: var(--text-2); }
.challenge__actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; width: 100%; }

/* Arrivals (only with scripting on): Clumsy motion, land and soft */
.js .start__copy > * { animation: arrive 640ms var(--land) both; }
.js .start__copy > :nth-child(2) { animation-delay: 90ms; }
.js .start__copy > :nth-child(3) { animation-delay: 180ms; }
.js .start__copy > :nth-child(n + 4) { animation-delay: 270ms; }
.js .end:not([hidden]) .end__panel, .js .challenge:not([hidden]) .challenge__panel { animation: rise 640ms var(--land) both; }
@keyframes arrive { from { opacity: 0; transform: translateY(14px); filter: blur(8px); } }
@keyframes rise { from { opacity: 0; transform: translateY(28px); } }

@media (prefers-reduced-motion: reduce) {
  .js .start__copy > *, .js .end:not([hidden]) .end__panel, .js .challenge:not([hidden]) .challenge__panel { animation: fade 200ms var(--soft) both; }
  .btn, .hint, .tile, .pen { transition: none; }
  .tile:active, .pen:active { transform: none; opacity: .85; }
  .hud__num.pop { animation: pop-calm 420ms var(--soft); }
  @keyframes fade { from { opacity: 0; } }
  @keyframes pop-calm { from { color: var(--signal); } }
}
