/* =====================================================================
   Trash Sorter: shared visual system (see DESIGN.md)
   ---------------------------------------------------------------------
   1. Tokens: type, colours, radii, motion, layers
   2. Worlds: day (kitchen) · paper (noticeboard) · night (bin shelter)
   3. Shell: desk backdrop, phone stage, side panel, layers
   4. Components: screen, buttons, icon buttons, chips, pills, cards,
      item art, bins (can / tile / orb), sheets, toasts, stars, Campus Club
   5. Utilities + reduced motion
   ===================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  /* Type: Fredoka (display) and Nunito (UI) everywhere. Fraunces is only for the Today's 10 masthead and score. */
  --font-display: 'Fredoka', 'Baloo 2', ui-rounded, system-ui, sans-serif;
  --font-body: 'Nunito', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-editorial: 'Fraunces', 'Iowan Old Style', Georgia, serif;

  --fs-2xs: 10px; /* kickers, key caps */
  --fs-xs: 12px; /* meta, Finnish bin names */
  --fs-sm: 13.5px; /* secondary copy */
  --fs-md: 15px; /* body */
  --fs-lg: 18px; /* buttons, item names */
  --fs-xl: 22px; /* screen titles */
  --fs-2xl: 28px; /* sheet titles */
  --fs-3xl: 40px; /* hero numbers */

  /* Brand + feedback colours (same in every world) */
  --c-tomato: #e5573f;
  --c-mustard: #e3ae1f;
  --c-plum: #2c2433;
  --c-mint: #5cffc4;
  --c-violet: #8b5cff;
  --c-good: #3f9a5b;
  --c-warn: #e0ae2e;
  --c-bad: #d65148;
  --c-wa: #25d366;
  --c-wa-ink: #08361b;
  --c-club: #1f5fa8;
  /* Night accents */
  --c-coral: #ff5470;
  --c-sun: #ffd84d;
  --c-sky: #5aa9ff;
  --c-night-ink: #0b1030;
  /* The JS palette (js/core/palette.js) mirrors these values for canvas drawing.
     Bin colours have one source, rules.js BINS: core/bins.js writes them as --bin-<id> at boot. */

  /* Shape */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 30px;
  --r-pill: 999px;

  /* Motion */
  --ease-spring: cubic-bezier(0.3, 1.5, 0.5, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.3, 1);
  --dur-1: 120ms; /* press feedback */
  --dur-2: 220ms; /* small state changes */
  --dur-3: 380ms; /* sheets, cards, throws */
  --dur-4: 600ms; /* celebrations */

  /* Layers. Within a screen: decor < content < the item < feedback < HUD < covers.
     The stage stacks #app < #fxLayer < #overlayLayer (sheets, toasts). */
  --z-below: -1; /* behind its parent's content */
  --z-raised: 1; /* lifted above its siblings */
  --z-float: 2; /* lids, bins on the night arc, flyers */
  --z-above: 3; /* key hints, pop text, tutorial ghost */
  --z-label: 4; /* NEW tags, title cards, challenge banners */
  --z-item: 5; /* the item in play */
  --z-feedback: 8; /* screen flashes, the kitchen mistake card */
  --z-message: 9; /* night mistake card and combo banners, toasts */
  --z-hud: 10; /* headers and HUD */
  --z-cover: 20; /* end screens over the play field */
  --z-drag: 30; /* an item being dragged */
  --z-tutorial: 40; /* the ghost hand */
  --z-fx: 50; /* #fxLayer */
  --z-overlay: 60; /* #overlayLayer */

  /* Safe areas */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  /* Stage size (phone frame on desktop) */
  --stage-w: 440px;
  --stage-h: min(calc(100dvh - 48px), 900px);
}

/* ---------- 2. Worlds ----------
   The router sets data-world on <html> AND on each screen root.
   Every component below reads only these semantic tokens. */
:root,
[data-world='day'] {
  --bg: #fff3df; /* screen background */
  --surface: #fffbf3; /* cards, tiles */
  --surface-2: #f8e4c3; /* recessed buttons, tracks */
  --ink: #2c2433;
  --ink-2: #5a4e63;
  --muted: #8a7e8f;
  --line: #ebd2ab;
  --accent: var(--c-tomato);
  --accent-ink: #fff;
  --accent-2: var(--c-mustard);
  --focus: var(--c-tomato);
  --scrim: rgba(30, 22, 36, 0.55);
  --shadow-1: 0 3px 0 rgba(44, 36, 51, 0.1);
  --shadow-2: 0 10px 0 rgba(44, 36, 51, 0.1), 0 14px 30px rgba(44, 36, 51, 0.22);
  --press: inset 0 -4px 0 rgba(44, 36, 51, 0.14);
  --backdrop: #2a2132;
  --backdrop-glow-1: rgba(227, 174, 31, 0.18);
  --backdrop-glow-2: rgba(229, 87, 63, 0.16);
  --desk-ink: #f4e6cf;
  --title-font: var(--font-display);
  color-scheme: light;
}
[data-world='paper'] {
  --bg: #f3efe6;
  --surface: #fffdf8;
  --surface-2: #ece6d9;
  --ink: #151413;
  --ink-2: #3c3934;
  --muted: #77716a;
  --line: #e3ddd0;
  --accent: #151413;
  --accent-ink: #f3efe6;
  --accent-2: var(--c-good);
  --focus: #151413;
  --scrim: rgba(20, 16, 10, 0.42);
  --shadow-1:
    0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 1px 2px rgba(40, 30, 10, 0.07), 0 4px 10px -4px rgba(40, 30, 10, 0.14);
  --shadow-2:
    0 1px 2px rgba(40, 30, 10, 0.06), 0 10px 28px -8px rgba(40, 30, 10, 0.2), 0 30px 60px -30px rgba(40, 30, 10, 0.24);
  --press: inset 0 0 0 1.5px #d6cfbf;
  --backdrop: #1e1c19;
  --backdrop-glow-1: rgba(243, 239, 230, 0.08);
  --backdrop-glow-2: rgba(63, 154, 91, 0.12);
  --desk-ink: #ede7da;
  --title-font: var(--font-display);
  color-scheme: light;
}
[data-world='night'] {
  --bg: #0e1440;
  --surface: rgba(255, 255, 255, 0.08);
  --surface-2: rgba(255, 255, 255, 0.14);
  --ink: #f4f2ff;
  --ink-2: rgba(244, 242, 255, 0.82);
  --muted: rgba(244, 242, 255, 0.62);
  --line: rgba(255, 255, 255, 0.16);
  --accent: var(--c-mint);
  --accent-ink: var(--c-night-ink);
  --accent-2: var(--c-sun);
  --focus: var(--c-mint);
  --scrim: rgba(5, 7, 24, 0.66);
  --shadow-1: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 24px 60px rgba(0, 0, 0, 0.55);
  --press: inset 0 -4px 0 rgba(0, 0, 0, 0.3);
  --backdrop: #070a1f;
  --backdrop-glow-1: rgba(92, 255, 196, 0.1);
  --backdrop-glow-2: rgba(139, 92, 255, 0.16);
  --desk-ink: #dcd8ff;
  --title-font: var(--font-display);
  color-scheme: dark;
}

/* ---------- 3. Shell ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--fs-md);
  line-height: 1.4;
  color: var(--ink);
  background-color: var(--backdrop);
  background-image:
    radial-gradient(circle at 20% 10%, var(--backdrop-glow-1), transparent 42%),
    radial-gradient(circle at 85% 90%, var(--backdrop-glow-2), transparent 46%),
    linear-gradient(rgba(255, 255, 255, 0.03) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 2px, transparent 2px);
  background-size:
    auto,
    auto,
    44px 44px,
    44px 44px;
  transition: background-color var(--dur-4) var(--ease-out);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
button {
  font: inherit;
  color: inherit;
}
img {
  -webkit-user-drag: none;
}
a {
  color: inherit;
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.desk {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 56px;
}
.stage {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  /* contain: makes the stage the containing block for any position:fixed descendant,
     so nothing (flyers, toasts, particles) can ever paint outside the phone frame. */
  contain: layout paint;
  background: var(--bg);
  transition: background-color var(--dur-3) var(--ease-out);
}
/* Phone frame: only for a mouse-driven desktop browser. Touch tablets get the full screen (below). */
@media (hover: hover) and (pointer: fine) and (min-width: 600px) and (min-height: 720px) {
  .stage {
    width: var(--stage-w);
    height: var(--stage-h);
    border-radius: 44px;
    box-shadow:
      0 0 0 10px #18121d,
      0 0 0 12px #4a3d55,
      0 40px 80px rgba(0, 0, 0, 0.5);
  }
  [data-world='night'] .stage {
    box-shadow:
      0 0 0 10px #05071a,
      0 0 0 12px #2a2f66,
      0 40px 120px rgba(0, 0, 0, 0.6),
      0 0 90px rgba(92, 255, 196, 0.1);
  }
  [data-world='paper'] .stage {
    box-shadow:
      0 0 0 10px #0e0d0c,
      0 0 0 12px #3a3633,
      0 40px 80px rgba(0, 0, 0, 0.5);
  }
}
.app {
  position: absolute;
  inset: 0;
}
.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-fx);
  overflow: hidden;
}
.overlay-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-overlay);
}
.overlay-layer > * {
  pointer-events: auto;
}
.noscript {
  padding: 40px 24px;
  text-align: center;
}

.desk-panel {
  display: none;
  width: 280px;
  flex: none;
  color: var(--desk-ink);
  order: -1;
}
@media (hover: hover) and (pointer: fine) and (min-width: 1040px) and (min-height: 720px) {
  .desk-panel {
    display: block;
  }
}
/* Keyboard hints in the side panel make no sense on touch screens. */
@media (pointer: coarse) {
  .desk-panel__keys {
    display: none;
  }
}
/* Landscape touch tablets: a full-height portrait column beside the side panel, no bezel. */
@media (pointer: coarse) and (orientation: landscape) and (min-width: 900px) and (min-height: 600px) {
  .stage {
    width: min(100vw, calc(100dvh * 0.7));
  }
  .desk-panel {
    display: block;
  }
}
.desk-panel__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.desk-panel__mark {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.desk-panel__logo {
  width: 44px;
  height: auto;
  background: #fff3df;
  border-radius: 13px;
  padding: 6px;
}
.desk-panel__kicker {
  margin: 22px 0 6px;
  font: 900 var(--fs-xs)/1.2 var(--font-body);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-mustard);
}
[data-world='night'] .desk-panel__kicker {
  color: var(--c-mint);
}
[data-world='paper'] .desk-panel__kicker {
  color: #9fd4ae;
}
.desk-panel__title {
  font: 700 48px/0.95 var(--title-font);
  margin: 0 0 14px;
  color: #fff;
  letter-spacing: -0.01em;
}
.desk-panel__lede,
.desk-panel__keys,
.desk-panel__foot {
  font: 600 15px/1.5 var(--font-body);
  opacity: 0.84;
  margin: 0 0 12px;
}
.desk-panel__foot a {
  color: #fff;
}
kbd {
  font: 800 12px var(--font-body);
  background: rgba(127, 127, 127, 0.18);
  border-radius: 6px;
  padding: 1px 7px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.25);
}

/* ---------- 4. Components ---------- */

/* Screen: every route renders into one .screen (router creates it). */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  animation: screenIn var(--dur-3) var(--ease-out) both;
}
.screen.is-leaving {
  animation: screenOut var(--dur-2) var(--ease-out) both;
  pointer-events: none;
}
@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
}
@keyframes screenOut {
  to {
    opacity: 0;
  }
}
.screen--scroll {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.screen-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-t) + 10px) 14px 6px;
  position: relative;
  z-index: var(--z-above);
}
.screen-head__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font: 700 var(--fs-xl)/1.1 var(--title-font);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.screen-head__kicker {
  display: block;
  font: 900 11px/1.2 var(--font-body);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
[data-world='paper'] .screen-head__kicker {
  color: var(--muted);
}

.kicker {
  font: 900 11px/1.2 var(--font-body);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Buttons */
.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 18px;
  font: 600 var(--fs-lg)/1.1 var(--font-display);
  color: var(--ink);
  background: var(--surface-2);
  border-radius: 18px;
  box-shadow: var(--press);
  text-decoration: none;
  text-align: center;
  transition:
    transform var(--dur-1) var(--ease-out),
    filter var(--dur-2);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.btn:active {
  transform: translateY(2px) scale(0.98);
}
.btn[disabled] {
  opacity: 0.5;
  cursor: default;
  transform: none;
}
.btn svg {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.2);
}
.btn--gold {
  background: var(--c-mustard);
  color: var(--c-plum);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.16);
}
.btn--ghost {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--line);
}
.btn--wa {
  background: var(--c-wa);
  color: var(--c-wa-ink);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.16);
}
.btn--block {
  width: 100%;
}
.btn--grow {
  flex: 1;
}
.btn--sm {
  min-height: 40px;
  padding: 8px 14px;
  font-size: 15px;
  border-radius: 14px;
}
[data-world='paper'] .btn {
  border-radius: var(--r-pill);
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 16px;
}
[data-world='paper'] .btn--primary {
  box-shadow: none;
}
[data-world='night'] .btn {
  box-shadow: inset 0 0 0 1px var(--line);
}
[data-world='night'] .btn--primary {
  box-shadow:
    0 0 24px rgba(92, 255, 196, 0.35),
    inset 0 -4px 0 rgba(0, 0, 0, 0.18);
}

.icon-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: var(--surface-2);
  color: var(--ink);
  box-shadow: var(--press);
  transition:
    transform var(--dur-1) var(--ease-out),
    background var(--dur-2);
  touch-action: manipulation;
}
.icon-btn:active {
  transform: scale(0.92);
}
.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn.is-on {
  background: var(--c-mustard);
  color: var(--c-plum);
}
.icon-btn--clear {
  background: rgba(255, 255, 255, 0.18);
  box-shadow: none;
  color: #fff;
}
[data-world='paper'] .icon-btn {
  border-radius: 50%;
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--line);
}
[data-world='night'] .icon-btn {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
.sound-btn .s-on {
  display: none;
}
.sound-btn.is-on .s-on {
  display: inline;
}
.sound-btn.is-on .s-off {
  display: none;
}

.link-btn {
  appearance: none;
  background: none;
  border: 0;
  padding: 8px;
  cursor: pointer;
  font: 800 var(--fs-xs) var(--font-body);
  color: var(--muted);
  text-decoration: underline;
}

/* Chips: a bin label. Always: icon + English name (+ optional Finnish). */
.chip {
  --c: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--c);
  color: #fff;
  font: 600 14px/1.1 var(--font-display);
  padding: 3px 10px 3px 6px;
  border-radius: var(--r-pill);
  white-space: nowrap;
  vertical-align: middle;
}
.chip svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chip__fi {
  font: 800 11px var(--font-body);
  opacity: 0.85;
}
.chip--sm {
  font-size: 12px;
  padding: 2px 8px 2px 4px;
  gap: 4px;
}
.chip--sm svg {
  width: 13px;
  height: 13px;
}
.chip--soft {
  background: color-mix(in srgb, var(--c) 16%, var(--surface));
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 40%, transparent);
}
.chip--soft svg {
  color: var(--c);
}

/* Pills: neutral counters / status */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  color: var(--ink-2);
  font: 800 var(--fs-xs)/1.2 var(--font-body);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-1);
}
.pill b {
  font: 600 15px var(--font-display);
  color: var(--ink);
}
.tag-again {
  display: inline-block;
  flex: none;
  font: 900 10px/1.3 var(--font-body);
  letter-spacing: 0.06em;
  background: var(--c-mustard);
  color: var(--c-plum);
  padding: 2px 6px;
  border-radius: var(--r-pill);
}
.tag-new {
  font: 700 11px var(--font-display);
  letter-spacing: 0.05em;
  background: var(--c-tomato);
  color: #fff;
  border: 2px solid #fff;
  padding: 1px 7px;
  border-radius: 8px;
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-1);
}

/* Item art: one family (assets/items/, docs/item-art.md) shown as die-cut stickers.
   Sizes come from --art-size in px, never %, so a fixed/absolute copy can't balloon. */
.art {
  --art-size: 64px;
  width: var(--art-size);
  height: var(--art-size);
  display: block;
  object-fit: contain;
  flex: none;
  pointer-events: none;
}
.art--sticker {
  filter: drop-shadow(2.5px 0 0 #fff) drop-shadow(-2.5px 0 0 #fff) drop-shadow(0 2.5px 0 #fff)
    drop-shadow(0 -2.5px 0 #fff) drop-shadow(0 6px 5px rgba(44, 36, 51, 0.22));
}
.art--locked {
  filter: brightness(0);
  opacity: 0.12;
}

/* Bins. One markup (core/bins.js binButton), three skins:
   .bin--can (day kitchen), .bin--tile (paper noticeboard), .bin--orb (night).
   Inline style sets --c to the bin colour. State classes are shared. */
.bin {
  --c: #888;
  --cd: color-mix(in srgb, var(--c) 72%, #120c18);
  position: relative;
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  font: inherit;
  text-align: center;
  outline: none;
  isolation: isolate;
  transition:
    transform 0.16s var(--ease-spring),
    opacity var(--dur-2),
    filter var(--dur-2);
  -webkit-user-select: none;
  user-select: none;
}
.bin__icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}
.bin__name {
  font: 600 clamp(12px, 3.7vw, 16px)/1.05 var(--font-display);
}
.bin__fi {
  font: 800 clamp(8.5px, 2.4vw, 10.5px)/1.1 var(--font-body);
  opacity: 0.82;
  letter-spacing: 0.02em;
}
.bin__key {
  display: none;
  position: absolute;
  top: 18%;
  right: 6%;
  z-index: var(--z-above);
  font: 800 10px var(--font-body);
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  border: 0;
  border-radius: 5px;
  padding: 1px 5px;
}
.bin__new {
  position: absolute;
  top: -6px;
  right: -2px;
  z-index: var(--z-label);
  transform: rotate(8deg);
}
.bin__pips {
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 3px;
}
.bin__pips i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
}
.bin__pips i.on {
  background: var(--c-tomato);
  box-shadow: 0 0 0 1.5px #fff;
}
/* Key hints show with a mouse, or once a hardware keyboard is used (ui.watchKeyboard sets .has-keyboard). */
@media (hover: hover) and (pointer: fine) {
  .bin__key {
    display: block;
  }
}
.has-keyboard .bin__key {
  display: block;
}
.bin:focus-visible .bin__body {
  box-shadow: inset 0 0 0 3px #fff;
}

/* -- can (day) -- */
.bin--can {
  height: 100%;
  max-height: 176px;
}
.bin--can .bin__lid {
  height: 15%;
  min-height: 11px;
  max-height: 20px;
  margin: 0 -4%;
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 85%, #fff), var(--cd));
  transform-origin: 6% 100%;
  transition: transform 0.2s var(--ease-spring);
  position: relative;
  z-index: var(--z-float);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
}
.bin--can .bin__lid::after {
  content: '';
  position: absolute;
  left: 38%;
  right: 38%;
  top: -5px;
  height: 6px;
  border-radius: 4px 4px 0 0;
  background: var(--cd);
}
.bin--can .bin__body {
  flex: 1;
  margin-top: 3px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: #fff;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.07) 0 3px, transparent 3px 14px),
    linear-gradient(180deg, var(--c), var(--cd));
  clip-path: polygon(0 0, 100% 0, 94% 100%, 6% 100%);
  border-radius: 4px 4px 16px 16px;
  padding: 4px 6px 14px;
}
.bin--can .bin__icon {
  width: clamp(24px, 34%, 40px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  padding: 5px;
}
.bin--can .bin__name {
  margin-top: 3px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}
.bin--can .bin__body::after {
  /* contamination grime, driven by data-contam="0..3" */
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  background:
    radial-gradient(circle at 20% 70%, rgba(70, 55, 20, 0.5) 0 7%, transparent 8%),
    radial-gradient(circle at 78% 35%, rgba(70, 55, 20, 0.45) 0 6%, transparent 7%),
    radial-gradient(circle at 60% 82%, rgba(70, 55, 20, 0.4) 0 5%, transparent 6%);
}
.bin--can[data-contam='1'] .bin__body::after {
  opacity: 0.5;
}
.bin--can[data-contam='2'] .bin__body::after,
.bin--can[data-contam='3'] .bin__body::after {
  opacity: 1;
}
@media (hover: hover) and (pointer: fine) {
  .bin--can:hover {
    transform: translateY(-3px);
  }
  .bin--can:hover .bin__lid {
    transform: rotate(-14deg) translateY(-2px);
  }
}
.bin--can.is-hot .bin__lid,
.bin--can.is-open .bin__lid,
.bin--can.is-reveal .bin__lid {
  transform: rotate(-38deg) translate(-2px, -6px);
}

/* -- tile (paper) -- */
.bin--tile {
  height: clamp(72px, 10.8dvh, 94px);
  border-radius: 20px;
  background: color-mix(in srgb, var(--c) 9%, var(--surface));
  box-shadow:
    var(--shadow-1),
    inset 0 0 0 1px color-mix(in srgb, var(--c) 16%, transparent);
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding-top: 6px;
  overflow: hidden;
  color: var(--ink);
}
.bin--tile .bin__lid {
  position: absolute;
  top: 0;
  left: 18%;
  right: 18%;
  height: 5px;
  border-radius: 0 0 6px 6px;
  background: var(--c);
  transition: transform 0.25s var(--ease-spring);
}
.bin--tile .bin__body {
  display: contents;
}
.bin--tile .bin__icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: var(--c);
  display: grid;
  place-items: center;
  padding: 7px;
  margin-bottom: 3px;
  transition: transform 0.2s var(--ease-spring);
}
.bin--tile .bin__name {
  font: 800 14px/1.1 var(--font-body);
}
.bin--tile .bin__fi {
  font-weight: 600;
  color: var(--muted);
  opacity: 1;
}
.bin--tile .bin__key {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  top: 8px;
  right: 8px;
}
.bin--tile:active {
  transform: scale(0.95);
}
.bin--tile.is-hot {
  transform: scale(1.06);
  box-shadow:
    var(--shadow-1),
    inset 0 0 0 2.5px var(--c);
}
.bin--tile.is-hot .bin__icon {
  transform: translateY(-3px) scale(1.08);
}
.bin--tile.is-right,
.bin--tile.is-reveal {
  background: color-mix(in srgb, var(--c) 18%, var(--surface));
  box-shadow:
    var(--shadow-1),
    inset 0 0 0 3px var(--c),
    0 0 0 4px color-mix(in srgb, var(--c) 22%, transparent);
}
.bin--tile.is-wrong::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.7;
  background: linear-gradient(
    to top right,
    transparent calc(50% - 1.2px),
    var(--c-bad) calc(50% - 1.2px),
    var(--c-bad) calc(50% + 1.2px),
    transparent calc(50% + 1.2px)
  );
}
@media (hover: hover) and (pointer: fine) {
  .bin--tile:hover {
    transform: translateY(-2px);
  }
}

/* -- orb (night) -- */
.bin--orb {
  align-items: center;
  gap: 3px;
  color: #fff;
}
.bin--orb .bin__lid {
  display: none;
}
.bin--orb .bin__body {
  display: contents;
}
.bin--orb .bin__icon {
  width: clamp(48px, 15vw, 64px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 22%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 55%, #fff), var(--c) 55%, var(--cd));
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.14),
    0 8px 22px color-mix(in srgb, var(--c) 55%, transparent);
  transition:
    transform 0.2s var(--ease-back),
    box-shadow 0.2s;
}
.bin--orb .bin__name {
  font-size: 13px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
.bin--orb .bin__fi {
  font-size: 10px;
  opacity: 0.7;
}
.bin--orb.is-hot .bin__icon,
.bin--orb.is-reveal .bin__icon {
  transform: scale(1.14);
  box-shadow:
    0 0 0 4px #fff,
    0 0 30px color-mix(in srgb, var(--c) 80%, transparent);
}

/* -- shared states -- */
.bin--can.is-hot,
.bin--orb.is-hot {
  transform: translateY(-6px) scale(1.04);
}
.bin.is-gulp {
  animation: binGulp 0.36s var(--ease-spring);
}
.bin.is-shake {
  animation: binShake 0.42s ease;
}
.bin.is-dim {
  opacity: 0.38;
  filter: saturate(0.5);
}
.bin.is-reveal {
  opacity: 1;
  filter: none;
}
.bin--can.is-reveal,
.bin--orb.is-reveal {
  transform: translateY(-6px) scale(1.06);
}
.bin.is-new {
  animation: binDrop 0.6s var(--ease-spring) both;
}
.bin.is-reveal::before,
.bin.is-hint::before {
  content: '';
  position: absolute;
  inset: -6px -8px -4px;
  border-radius: 18px;
  z-index: var(--z-below);
  border: 3px solid var(--ring, #fff);
  animation: ringPulse 1s ease-in-out infinite;
}
[data-world='paper'] .bin {
  --ring: var(--ink);
}
@keyframes binGulp {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.08, 0.9);
  }
  70% {
    transform: scale(0.96, 1.05);
  }
  100% {
    transform: none;
  }
}
@keyframes binShake {
  0%,
  100% {
    transform: none;
  }
  20% {
    transform: translateX(-7px) rotate(-3deg);
  }
  40% {
    transform: translateX(6px) rotate(2deg);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(3px);
  }
}
@keyframes binDrop {
  0% {
    transform: translateY(-120%) scale(0.8);
    opacity: 0;
  }
  100% {
    transform: none;
    opacity: 1;
  }
}
@keyframes ringPulse {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.98);
  }
  50% {
    opacity: 1;
    transform: scale(1.03);
  }
}
.bin .bin__new {
  animation: tagPulse 1.4s ease-in-out infinite;
}
@keyframes tagPulse {
  50% {
    transform: rotate(8deg) scale(1.12);
  }
}

/* Sheets (core/ui.js openSheet). Live in #overlayLayer, so always inside the stage. */
.sheet-scrim {
  position: absolute;
  inset: 0;
  z-index: var(--z-raised);
  background: var(--scrim);
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease-out);
}
.sheet-scrim.is-open {
  opacity: 1;
}
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-float);
  max-height: 92%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: 0 -20px 50px -20px rgba(0, 0, 0, 0.35);
  transform: translateY(105%);
  transition: transform var(--dur-3) var(--ease-spring);
}
.sheet.is-open {
  transform: none;
}
.sheet__grab {
  width: 44px;
  height: 5px;
  border-radius: 99px;
  background: var(--line);
  margin: 10px auto 2px;
  flex: none;
}
.sheet__close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: var(--z-float);
  width: 38px;
  height: 38px;
  border-radius: 50%;
}
.sheet__body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 18px calc(18px + var(--safe-b));
  -webkit-user-select: text;
  user-select: text;
}
.sheet__title {
  font: 700 var(--fs-2xl)/1.08 var(--title-font);
  margin: 8px 44px 6px 0;
  letter-spacing: -0.01em;
}
.sheet__lede {
  margin: 0 0 14px;
  color: var(--ink-2);
  font-size: var(--fs-sm);
}
.sheet--center {
  /* modal variant for celebrations */
  left: 16px;
  right: 16px;
  bottom: auto;
  top: 50%;
  border-radius: var(--r-xl);
  transform: translateY(-40%) scale(0.92);
  opacity: 0;
  transition:
    transform var(--dur-3) var(--ease-spring),
    opacity var(--dur-2);
}
.sheet--center.is-open {
  transform: translateY(-50%);
  opacity: 1;
}

/* Toast (core/ui.js toast): bottom of the stage by default; .toast--top is placed by JS over a play field. */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  z-index: var(--z-message);
  max-width: calc(100% - 32px);
  width: max-content;
  transform: translate(-50%, 160%);
  background: var(--c-plum);
  color: #fff;
  padding: 11px 16px;
  border-radius: 14px;
  font: 700 14px/1.3 var(--font-body);
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transition:
    transform var(--dur-3) var(--ease-spring),
    opacity var(--dur-2);
  pointer-events: none;
}
.toast.is-open {
  transform: translate(-50%, 0);
}
.toast__kicker {
  display: block;
  font: 800 11px var(--font-body);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--toast-accent, var(--c-mustard));
}
.toast--top {
  bottom: auto;
  opacity: 0;
  transform: translate(-50%, -12px);
}
.toast--top.is-open {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast--accent {
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.25),
    inset 0 0 0 1.5px color-mix(in srgb, var(--toast-accent) 70%, transparent);
}
[data-world='night'] .toast {
  background: rgba(11, 16, 48, 0.92);
  color: #f4f2ff;
  font-weight: 800;
}

/* Stars */
.stars {
  display: inline-flex;
  gap: 1px;
}
.stars svg {
  width: 17px;
  height: 17px;
  fill: var(--line);
}
.stars svg.on {
  fill: var(--c-mustard);
}

/* Campus Club card (core/ui.js clubCard) */
.cc-card {
  position: relative;
  overflow: hidden;
  background: var(--c-plum);
  color: #fff;
  border-radius: var(--r-lg);
  padding: 16px;
  display: grid;
  gap: 10px;
}
.cc-card__top {
  display: flex;
  gap: 12px;
  align-items: center;
}
.cc-card__logo {
  width: 52px;
  height: auto;
  background: #fff3df;
  border-radius: 14px;
  padding: 6px;
  flex: none;
}
.cc-card h3 {
  font: 600 19px/1.15 var(--font-display);
  margin: 0;
}
.cc-card p.cc-card__sub {
  margin-top: 2px;
  font: 800 var(--fs-xs)/1.2 var(--font-body);
  opacity: 0.7;
}
.cc-card p {
  margin: 0;
  font: 700 13.5px/1.4 var(--font-body);
  opacity: 0.85;
}
.cc-card__site {
  color: var(--c-mustard);
  font: 800 13px var(--font-body);
  text-align: center;
  text-decoration: underline;
  padding: 4px;
}
[data-world='night'] .cc-card {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px var(--line);
}
[data-world='paper'] .cc-card {
  background: #151413;
}

/* Share card: a pre-rendered result image (core/cards.js) next to its share buttons.
   <div class="share-card"><button class="share-card__thumb" data-act="share"><img></button><div class="share-card__btns">…</div></div> */
.share-card {
  display: flex;
  gap: 12px;
  align-items: stretch;
}
.share-card__thumb {
  flex: none;
  width: 104px;
  aspect-ratio: 4 / 5;
  padding: 0;
  border: 0;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  background: var(--surface-2);
  box-shadow: var(--shadow-1);
  transform: rotate(-2deg);
  transition: transform var(--dur-2) var(--ease-spring);
}
.share-card__thumb:hover,
.share-card__thumb:focus-visible {
  transform: rotate(0) scale(1.03);
}
.share-card__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease-out);
}
.share-card__thumb img.is-ready {
  opacity: 1;
}
.share-card__btns {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}
.share-card__btns .btn {
  width: 100%;
}
.share-card__hint {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--muted);
  text-align: center;
}

/* A share button waiting for its card image (core/result-card.js sets aria-disabled + .is-pending). */
.is-pending {
  cursor: progress;
}
.btn.is-pending {
  opacity: 0.7;
}
.btn.is-pending > svg {
  display: none;
}
.btn.is-pending::before {
  content: '';
  width: 16px;
  height: 16px;
  flex: none;
  border-radius: 50%;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}
.share-card__thumb.is-pending {
  transform: none;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Share sheet (desktop fallback of core/share.js shareImage) */
.share-sheet__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-top: 6px;
}
.share-sheet__img {
  width: min(240px, 62%);
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 16px;
  box-shadow: var(--shadow-2);
}
.share-sheet__side {
  width: 100%;
}
.share-sheet__side .sheet__title {
  margin-right: 0;
  text-align: center;
}
.share-sheet__side .sheet__lede {
  text-align: center;
}
.share-sheet__actions {
  display: grid;
  gap: 8px;
}

/* ---------- 5. Utilities ---------- */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.flyer {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  will-change: transform;
  z-index: var(--z-float);
}
.pop-text {
  position: absolute;
  z-index: var(--z-above);
  pointer-events: none;
  white-space: nowrap;
  font: 700 20px var(--font-display);
  color: #fff;
  text-shadow:
    0 2px 0 var(--c-plum),
    0 0 6px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, 0);
  animation: floatUp 0.8s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}
.pop-text--big {
  font-size: 26px;
  color: var(--c-mustard);
}
@keyframes floatUp {
  0% {
    opacity: 0;
    transform: translate(-50%, 10px) scale(0.7);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -46px) scale(1);
  }
}
/* Night pops: bigger, coloured by --c, a faster rise */
[data-world='night'] .pop-text {
  font: 700 26px/1 var(--font-display);
  color: var(--c, #fff);
  text-shadow:
    0 3px 0 rgba(0, 0, 0, 0.4),
    0 0 12px rgba(0, 0, 0, 0.25);
  animation: popNight 0.85s var(--ease-out) forwards;
  will-change: transform, opacity;
}
[data-world='night'] .pop-text--big {
  font-size: 32px;
  color: var(--c, #fff);
}
.pop-text--small,
[data-world='night'] .pop-text--small {
  font: 900 16px/1 var(--font-body);
}
@keyframes popNight {
  0% {
    opacity: 0;
    transform: translate(-50%, 0) scale(0.5);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -16px) scale(1.15);
  }
  30% {
    transform: translate(-50%, -24px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -70px) scale(0.95);
  }
}

/* PWA install (core/pwa.js): the button hides itself via [hidden]; iOS steps sheet */
.pwa-install[hidden] {
  display: none;
}
.pwa-steps {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 10px;
}
.pwa-steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  font-size: var(--fs-md);
}
.pwa-steps__n {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  font: 700 15px var(--font-display);
}
.pwa-glyph {
  width: 20px;
  height: 20px;
  vertical-align: -4px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Reduced motion: keep meaning (glows, colours), drop movement. JS also checks ui.reducedMotion(). */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-1: 1ms;
    --dur-2: 1ms;
    --dur-3: 1ms;
    --dur-4: 1ms;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .bin.is-reveal::before,
  .bin.is-hint::before {
    animation: none !important;
    opacity: 1;
  }
  [data-world='night'] .pop-text {
    animation: none !important;
    transform: translate(-50%, -24px);
  }
}
