/* Mixling Trick or Treat. The street is night-coloured in both themes;
   Mixlings sit on light cards (their plum outlines need it). */

.tt { max-width: 72rem; }
.tt .bar { display: flex; align-items: center; gap: 0.5rem 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.tt .bar .crumb { width: 100%; margin: 0; font-size: 0.8rem; color: var(--ink-soft); }
.tt .bar h1 { margin: 0; font-size: 1.6rem; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tt h2 { font-size: var(--step-1); margin: 0.6rem 0 0.4rem; }

/* ---------- dressing up ---------- */
.tt-dress { display: grid; gap: 1rem 1.5rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 52rem) { .tt-dress { grid-template-columns: minmax(16rem, 2fr) 3fr; align-items: start; } .tt-left { position: sticky; top: 0.5rem; } }
.tt-preview {
  border-radius: var(--radius); border: 2px solid var(--rule); box-shadow: var(--shadow);
  background: radial-gradient(circle at 70% 18%, #fff3c4 0 7%, transparent 7.5%), linear-gradient(#2a2350, #5a3f78);
  display: flex; justify-content: center; padding: 0.5rem;
}
.tt-preview svg { width: min(100%, 22rem); height: auto; max-height: 52vh; filter: drop-shadow(0 0 1.2rem rgb(255 230 160 / 0.35)); }
.tt-who { display: flex; align-items: center; justify-content: center; gap: 0.75rem; margin: 0.6rem 0 0; }
.tt-name { font: 600 var(--step-1) var(--font-display); }
.tt-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.6rem, 1fr)); gap: 0.5rem; }
.tt-tile {
  display: grid; justify-items: center; gap: 0.1rem; padding: 0.3rem 0.2rem 0.4rem; border-radius: 1rem;
  background: #fffafd; color: #4a2545; font: 500 0.85rem var(--font-display); border: 3px solid transparent;
}
.tt-tile svg { width: 100%; height: auto; aspect-ratio: 340 / 445; }
.tt-tile[aria-checked='true'] { border-color: var(--candyfloss-deep); background: #fff0f7; }
.tt-colours { display: grid; gap: 0.6rem; }
.tt-colour h3 { margin: 0 0 0.3rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); }
.tt-swatches { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.tt-swatch, .tt-any {
  width: 2.2rem; height: 2.2rem; min-height: 0; padding: 0; border-radius: 50%; background: var(--c);
  border: 2px solid #4a2545; box-shadow: none; cursor: pointer;
}
.tt-swatch[aria-pressed='true'] { outline: 3px solid var(--candyfloss-deep); outline-offset: 2px; }
.tt-any { position: relative; display: grid; place-items: center; background: conic-gradient(#ff8fc7, #f2c94c, #6cbf84, #5b8fd6, #9c86e8, #ff8fc7); }
.tt-any span { font: 700 1.2rem var(--font-display); color: #4a2545; pointer-events: none; }
.tt-any input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.tt-go { margin-top: 1rem; font-size: var(--step-1); padding: 0.7rem 1.4rem; background: var(--candyfloss); color: #4a2545; }
.tt-best { color: var(--ink-soft); margin: 0.6rem 0 0; }

/* ---------- the street ---------- */
.tt-night { display: grid; justify-items: center; gap: 0.5rem; }
.tt-stage {
  position: relative; width: 100%; max-width: calc((100vh - 11rem) * 800 / 520); max-width: calc((100dvh - 11rem) * 800 / 520);
  min-width: min(100%, 20rem); aspect-ratio: 800 / 520;
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 2px solid #3d2f66; background: #1c1638;
}
.fs.full .tt-stage { max-width: calc((100vh - 9rem - 2 * var(--edge-y, 0.5rem)) * 800 / 520); }
.tt-scene { display: block; width: 100%; height: 100%; }
.tt-scene .street { transition: transform 1.7s ease-in-out; }
.tt-scene .door { transition: transform 0.6s ease; transform-box: view-box; }
.tt-scene .door.open { transform: scaleX(0.14); }
.tt-scene .knocker { transform-box: fill-box; transform-origin: 50% 0; }
.tt-scene .knocker.knock { animation: tt-knock 0.36s ease 2; }
@keyframes tt-knock { 40% { transform: rotate(-35deg) scale(1.15); } }
.tt-scene .tw { animation: tt-twinkle 3s ease-in-out infinite alternate; }
@keyframes tt-twinkle { to { opacity: 0.25; } }
.tt-scene .flap { animation: tt-flap 0.5s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 30%; }
@keyframes tt-flap { to { transform: scaleY(0.45); } }
.tt-scene .bats { animation: tt-drift 14s ease-in-out infinite alternate; }
@keyframes tt-drift { to { transform: translate(60px, 20px); } }
.tt-scene.walking .me-body { animation: tt-walk 0.42s ease-in-out infinite alternate; }
@keyframes tt-walk { from { transform: translateY(0) rotate(-2deg); } to { transform: translateY(-10px) rotate(2deg); } }

.tt-bubbles { position: absolute; inset: 0; pointer-events: none; }
.tt-bubble {
  position: absolute; transform: translate(-50%, -100%); max-width: 46%; width: max-content;
  background: #fffafd; color: #4a2545; border: 2px solid #4a2545; border-radius: 1rem;
  padding: 0.35em 0.75em; font: 600 clamp(0.75rem, 2.1vw, 1.05rem) / 1.25 var(--font-display); text-align: center;
  animation: tt-pop 0.25s ease-out;
}
.tt-bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -0.55em; width: 0.8em; height: 0.8em; background: inherit;
  border: inherit; border-width: 0 2px 2px 0; transform: translateX(-50%) rotate(45deg);
}
@keyframes tt-pop { from { transform: translate(-50%, -80%) scale(0.6); opacity: 0; } }
.tt-bag { position: absolute; top: 2%; right: 1.5%; width: 15%; text-align: center; transform-origin: 50% 90%; }
.tt-bag svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 0 0.6rem rgb(255 210 140 / 0.35)); }
.tt-bag.bump { animation: tt-bump 0.3s ease-out; }
@keyframes tt-bump { 50% { transform: scale(1.08, 0.94); } }
.tt-count {
  display: inline-block; margin-top: -0.4em; min-width: 2em; padding: 0.05em 0.5em; border-radius: 1em;
  background: #f4a259; color: #2b1d36; font: 700 clamp(0.8rem, 2vw, 1.1rem) var(--font-display); border: 2px solid #2b1d36;
}
.tt-counter {
  position: absolute; top: 3%; left: 2%; padding: 0.15em 0.7em; border-radius: 1em; background: rgb(28 22 56 / 0.7);
  color: #fff3c4; font: 600 clamp(0.75rem, 1.8vw, 1rem) var(--font-display);
}
.tt-fly { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; pointer-events: none; z-index: 2; }
.tt-fly.go { transition: transform 0.75s cubic-bezier(0.4, -0.35, 0.6, 1); }
.tt-status { margin: 0; min-height: 1.5em; text-align: center; color: var(--ink-soft); font-family: var(--font-display); }
.tt-controls { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; min-height: 3rem; }
.tt-knock, .tt-treat, .tt-next { font-size: var(--step-1); padding: 0.6rem 1.4rem; }
.tt-knock { background: var(--peach); color: #4a2545; }
.tt-treat { background: var(--candyfloss); color: #4a2545; animation: tt-pulse 1.2s ease-in-out infinite alternate; }
@keyframes tt-pulse { to { transform: scale(1.06); } }
.tt-next { background: var(--mint); color: #4a2545; }

/* ---------- the end ---------- */
.tt-end {
  position: relative; overflow: hidden; text-align: center; padding: 1rem 1rem 1.5rem; border-radius: var(--radius);
  background: linear-gradient(#2a2350, #5a3f78); color: #fff3c4; box-shadow: var(--shadow);
}
.tt-end h2 { font-size: var(--step-4); margin: 0.2rem 0; color: #ffd36b; position: relative; }
.tt-end-pic { display: flex; justify-content: center; align-items: flex-end; gap: 0; position: relative; }
.tt-end-pic > svg { width: min(16rem, 48%); height: auto; }
.tt-end-bag { width: min(9rem, 28%); margin-left: -2rem; margin-bottom: 1rem; }
.tt-end-bag svg { width: 100%; height: auto; }
.tt-haul { font: 600 var(--step-2) var(--font-display); margin: 0.5rem 0 0.2rem; position: relative; }
.tt-doors { margin: 0 0 0.8rem; position: relative; }
.tt-kinds { list-style: none; padding: 0; margin: 0 auto 1rem; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; max-width: 44rem; position: relative; }
.tt-kinds li {
  display: grid; justify-items: center; gap: 0.1rem; padding: 0.4rem 0.6rem; min-width: 5.5rem;
  background: rgb(255 250 253 / 0.92); color: #4a2545; border-radius: 1rem; font: 500 0.8rem var(--font-display);
}
.tt-kinds b { font-size: 1.2rem; }
.tt-again { display: flex; gap: 0.6rem; justify-content: center; align-items: center; flex-wrap: wrap; position: relative; }
.tt-again .tt-go { margin: 0; }
.tt-rain { position: absolute; inset: 0; pointer-events: none; }
.tt-rain span { position: absolute; top: -3rem; animation: tt-fall linear infinite; opacity: 0.85; }
@keyframes tt-fall { to { transform: translateY(46rem) rotate(540deg); } }

/* ---------- choosing a Mixling ---------- */
dialog.tt-choose {
  width: min(34rem, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto;
  padding: 1rem 1.2rem 1.4rem; border: 2px solid var(--rule); border-radius: var(--radius);
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow);
}
dialog.tt-choose::backdrop { background: rgb(74 37 69 / 0.35); }
.tt-choose .head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.tt-choose h2 { margin: 0; font-size: var(--step-1); }
.tt-choose h3 { margin: 1.1rem 0 0.4rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); }
.tt-choose .msg { margin: 0.4rem 0; color: var(--candyfloss-deep); font-family: var(--font-display); }
.tt-choose .tiles .msg { color: var(--ink-soft); grid-column: 1 / -1; }
.tt-choose .tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); gap: 0.5rem; }
.tt-choose button.opt {
  display: grid; gap: 0.1rem; justify-items: center; padding: 0.3rem; border-radius: 1rem;
  background: #fffafd; color: #4a2545; font: 500 0.8rem var(--font-display);
}
.tt-choose button.opt svg { width: 100%; height: auto; aspect-ratio: 340 / 445; }
.tt-choose button.opt span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-choose .code { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.8rem; }
.tt-choose .code label { font-family: var(--font-display); color: var(--ink-soft); }
.tt-choose .hint { color: var(--ink-soft); font-size: var(--step--1); margin: 1rem 0 0; }

@media (prefers-reduced-motion: reduce) {
  .tt-scene .street, .tt-scene .door, .tt-fly.go { transition-duration: 0s !important; }
  .tt-scene .tw, .tt-scene .flap, .tt-scene .bats, .tt-scene.walking .me-body, .tt-treat, .tt-bubble, .tt-bag.bump, .tt-scene .knocker.knock { animation: none; }
}
.tt-end .small { color: #4a2545; background: #fffafd; }
