/* ---------------- the toy's furniture ---------------- */
#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  font-family: 'Chakra Petch', sans-serif;
  color: var(--cream);
}
#ui button {
  pointer-events: auto;
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#ui svg {
  width: 1.5em;
  height: 1.5em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brand {
  position: absolute;
  left: calc(var(--u) * 1.6 + env(safe-area-inset-left));
  top: calc(var(--u) * 1.2 + env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  line-height: 1;
}
.brand .b1 {
  font: 600 calc(var(--u) * 2.3) Fraunces, Georgia, serif;
  color: var(--gold);
  letter-spacing: 0.04em;
  text-shadow: 0 2px 0 #6b3d0c, 0 0 18px rgba(255, 200, 90, 0.35);
}
.brand .b2 {
  font: 500 calc(var(--u) * 0.95) 'Chakra Petch', sans-serif;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-top: calc(var(--u) * 0.35);
}
.spotBtn {
  position: absolute;
  right: calc(var(--u) * 1.4 + env(safe-area-inset-right));
  top: calc(var(--u) * 1.2 + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.5em 0.9em 0.5em 0.7em;
  border-radius: 999px;
  border: 2px solid rgba(255, 211, 107, 0.65);
  background: linear-gradient(180deg, rgba(70, 30, 34, 0.85), rgba(36, 14, 20, 0.85));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  font-size: calc(var(--u) * 1.15) !important;
  font-weight: 700 !important;
  color: var(--gold) !important;
}
.spotBtn.bump {
  animation: bump 0.6s cubic-bezier(0.3, 1.8, 0.5, 1);
}
@keyframes bump {
  30% {
    transform: scale(1.35) rotate(-6deg);
  }
}
.bar {
  position: absolute;
  left: 50%;
  bottom: calc(var(--u) * 1.3 + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 0.5);
  padding: calc(var(--u) * 0.45);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(64, 28, 32, 0.78), rgba(30, 12, 18, 0.82));
  border: 1px solid rgba(255, 211, 107, 0.35);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: auto;
}
.bar button {
  display: flex;
  align-items: center;
  gap: 0.4em;
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 0.55em 1em 0.55em 0.8em;
  font-size: calc(var(--u) * 1.1) !important;
  font-weight: 600 !important;
  letter-spacing: 0.04em;
  transition: background 0.15s, transform 0.12s;
  touch-action: none;
}
.bar button:hover {
  background: rgba(255, 211, 107, 0.18);
}
.bar button:active,
.bar button.on {
  transform: scale(0.94);
  background: rgba(255, 211, 107, 0.3);
}
.bar button.big {
  background: linear-gradient(180deg, #ffd96e, #e59a2a);
  color: #3a1706 !important;
  box-shadow: 0 3px 0 #9a5a12, 0 6px 14px rgba(229, 154, 42, 0.35);
}
.bar button.big.on {
  animation: jiggle 0.12s linear infinite;
}
@keyframes jiggle {
  25% {
    transform: translate(-2px, 1px) rotate(-3deg) scale(0.96);
  }
  75% {
    transform: translate(2px, -1px) rotate(3deg) scale(0.96);
  }
}
.bar button.sm {
  padding: 0.55em;
}
.bar .sep {
  width: 1px;
  align-self: stretch;
  margin: 0.3em 0.15em;
  background: rgba(255, 255, 255, 0.15);
}
.hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--u) * 6.4 + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: calc(var(--u) * 1.1);
  padding: 0.5em 1.1em;
  border-radius: 999px;
  background: rgba(20, 8, 12, 0.55);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  transition: opacity 1s, transform 1s;
  animation: hintIn 1.2s 1s both;
}
.hint b {
  color: var(--gold);
}
.hint.gone {
  opacity: 0;
  transform: translate(-50%, 10px);
}
@keyframes hintIn {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
}
.pops {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.pop,
.shout {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(calc(-50% + var(--x, 0px)), -50%) rotate(var(--r, 0deg));
  font: 400 calc(var(--u) * 3) 'Russo One', sans-serif;
  color: #fff;
  -webkit-text-stroke: calc(var(--u) * 0.18) #3a1706;
  paint-order: stroke fill;
  text-shadow: 0 calc(var(--u) * 0.35) 0 #3a1706, 0 0 24px rgba(255, 220, 120, 0.6);
  white-space: nowrap;
  animation: popUp 1.5s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
.pop.gold {
  color: var(--gold);
}
@keyframes popUp {
  0% {
    opacity: 0;
    scale: 0.2;
  }
  14% {
    opacity: 1;
    scale: 1.15;
  }
  24% {
    scale: 1;
  }
  75% {
    opacity: 1;
    translate: 0 -4vh;
  }
  100% {
    opacity: 0;
    translate: 0 -12vh;
  }
}
.shout {
  top: 30%;
  font-size: calc(var(--u) * 5.2);
  color: #bfe8ff;
  animation: shout 2.2s cubic-bezier(0.2, 1.7, 0.4, 1) both;
}
.shout.storm {
  color: #fff;
  text-shadow: 0 calc(var(--u) * 0.4) 0 #12325a, 0 0 36px rgba(140, 210, 255, 0.85);
  -webkit-text-stroke-color: #12325a;
}
.shout.too {
  font-size: calc(var(--u) * 7);
  color: #ff5a6e;
  -webkit-text-stroke-color: #3a0610;
  text-shadow: 0 calc(var(--u) * 0.45) 0 #3a0610, 0 0 40px rgba(255, 80, 100, 0.7);
  animation: shout 2.2s cubic-bezier(0.2, 1.7, 0.4, 1) both, wobble 0.18s 0.3s 6 ease-in-out;
}
@keyframes shout {
  0% {
    opacity: 0;
    scale: 2.6;
  }
  12% {
    opacity: 1;
    scale: 0.9;
  }
  20% {
    scale: 1.05;
  }
  26% {
    scale: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    scale: 1.08;
  }
}
@keyframes wobble {
  50% {
    rotate: 4deg;
  }
}
.toasts {
  position: absolute;
  left: 50%;
  top: calc(var(--u) * 7 + env(safe-area-inset-top));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5em;
}
.toast {
  font-size: calc(var(--u) * 1.2);
  padding: 0.55em 1.2em;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(70, 30, 34, 0.92), rgba(36, 14, 20, 0.92));
  border: 1px solid rgba(255, 211, 107, 0.4);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
  animation: toastIn 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both;
  transition: opacity 0.5s, transform 0.5s;
}
.toast.out {
  opacity: 0;
  transform: translateY(-12px);
}
.toast b {
  color: var(--gold);
}
.toast em {
  font-style: normal;
  opacity: 0.7;
  margin-left: 0.3em;
}
.toast i {
  font-style: normal;
  color: var(--gold);
}
.toast.spot {
  border-color: var(--gold);
  box-shadow: 0 0 24px rgba(255, 211, 107, 0.35), 0 6px 20px rgba(0, 0, 0, 0.35);
}
.toast.night {
  background: linear-gradient(180deg, rgba(24, 30, 70, 0.92), rgba(12, 14, 36, 0.92));
  border-color: rgba(160, 190, 255, 0.5);
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-16px) scale(0.8);
  }
}
.book {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 4, 8, 0.55);
  pointer-events: auto;
  transition: opacity 0.3s;
}
.book.hidden {
  opacity: 0;
  pointer-events: none;
}
.bookIn {
  width: min(92vw, 620px);
  max-height: 86vh;
  overflow: auto;
  padding: calc(var(--u) * 1.6);
  border-radius: calc(var(--u) * 1.4);
  background: linear-gradient(180deg, #fff6e0, #f1dfb8);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), inset 0 0 0 3px #c98a24, inset 0 0 0 6px #fff6e0, inset 0 0 0 7px #c98a24;
  transform: rotate(-1deg);
}
.bookHd {
  display: flex;
  align-items: center;
  gap: 1em;
}
.bookHd b {
  font: 600 calc(var(--u) * 2) Fraunces, Georgia, serif;
  color: #8a2a1a;
}
.bookHd span {
  flex: 1;
  font-weight: 600;
  opacity: 0.7;
}
.bookHd .x {
  border: 0;
  background: none;
  font-size: calc(var(--u) * 1.4);
  color: var(--ink) !important;
}
.bookSub {
  font-size: calc(var(--u) * 1.05);
  opacity: 0.75;
  margin: 0.3em 0 1em;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(calc(var(--u) * 10), 1fr));
  gap: calc(var(--u) * 0.8);
}
.stk {
  aspect-ratio: 1.15;
  border-radius: calc(var(--u) * 0.9);
  border: 2px dashed rgba(42, 20, 8, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
  text-align: center;
  padding: 0.5em;
  font-size: calc(var(--u) * 0.95);
  font-weight: 600;
  color: rgba(42, 20, 8, 0.45);
  transform: rotate(var(--r));
}
.stk i {
  font-style: normal;
  font: 400 calc(var(--u) * 2.2) 'Russo One', sans-serif;
}
.stk.found {
  border: 0;
  background: linear-gradient(160deg, #ff6b6b, #c2253a);
  color: #fff;
  box-shadow: 0 3px 0 #7a1020, 0 6px 14px rgba(0, 0, 0, 0.25), inset 0 0 0 3px rgba(255, 255, 255, 0.6);
}
.stk.found:nth-child(3n + 1) {
  background: linear-gradient(160deg, #57d38c, #1f8a50);
  box-shadow: 0 3px 0 #0d5a30, 0 6px 14px rgba(0, 0, 0, 0.25), inset 0 0 0 3px rgba(255, 255, 255, 0.6);
}
.stk.found:nth-child(3n + 2) {
  background: linear-gradient(160deg, #6fb7ff, #2a62c9);
  box-shadow: 0 3px 0 #173a80, 0 6px 14px rgba(0, 0, 0, 0.25), inset 0 0 0 3px rgba(255, 255, 255, 0.6);
}
.stk.found i {
  color: #ffd36b;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}
@media (max-width: 640px) {
  .bar button span {
    display: none;
  }
  .bar button {
    padding: 0.6em;
  }
  .hint {
    white-space: normal;
    width: 86vw;
    text-align: center;
  }
  .brand .b2 {
    display: none;
  }
  .toast {
    white-space: normal;
    text-align: center;
    max-width: 70vw;
  }
}
@media (max-height: 480px) {
  .bar button span {
    display: none;
  }
  .bar button {
    padding: 0.5em;
  }
  .hint {
    display: none;
  }
}

/* phone motion: the opt-in card */
.motionCard {
  position: absolute;
  left: 50%;
  bottom: calc(var(--u) * 9 + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(92vw, 26em);
  font-size: max(14px, calc(var(--u) * 1.15));
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4em 0.9em;
  padding: 1em 1.1em;
  border-radius: 1.1em;
  background: linear-gradient(180deg, rgba(70, 30, 34, 0.96), rgba(36, 14, 20, 0.96));
  border: 1px solid rgba(255, 211, 107, 0.55);
  box-shadow: 0 0 30px rgba(255, 211, 107, 0.2), 0 10px 30px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  animation: toastIn 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both;
  z-index: 5;
}
.motionCard.hidden {
  display: none;
}
.mcIcon svg {
  width: 2.2em;
  height: 2.2em;
  fill: none;
  stroke: var(--gold);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mcText {
  line-height: 1.35;
}
.mcText b {
  display: block;
  color: var(--gold);
  font-size: 1.12em;
  margin-bottom: 0.2em;
}
.mcText i {
  font-style: normal;
  color: var(--gold);
}
.mcBtns {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.6em;
  justify-content: flex-end;
  margin-top: 0.3em;
}
.mcBtns button,
.mcBtns a {
  font: inherit;
  color: #fff;
  text-decoration: none;
  padding: 0.55em 1.1em;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}
#ui .mcBtns .mcYes,
#ui .mcBtns .mcGo {
  color: #2a1208;
  font-weight: 700;
  border-color: transparent;
  background: linear-gradient(180deg, #ffe39a, #f0b43c);
}

/* ---------------- The Workshop: the clock badge, the stop-watch and time standing still ---------------- */
.clockBadge {
  position: absolute;
  left: 50%;
  top: calc(var(--u) * 0.9 + env(safe-area-inset-top));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  column-gap: calc(var(--u) * 0.7);
  align-items: center;
  padding: calc(var(--u) * 0.45) calc(var(--u) * 1.1) calc(var(--u) * 0.45) calc(var(--u) * 0.45);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(26, 62, 44, 0.88), rgba(12, 32, 22, 0.9));
  border: 2px solid rgba(255, 211, 107, 0.7);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: border-color 0.4s, box-shadow 0.4s, background 0.4s;
}
.cbFace {
  grid-row: 1 / 3;
  width: calc(var(--u) * 4.2);
  height: calc(var(--u) * 4.2);
}
.cbFace svg {
  width: 100% !important;
  height: 100% !important;
}
.cbFace .rim {
  fill: #c98a24;
  stroke: #ffe39a;
  stroke-width: 2;
}
.cbFace .dial {
  fill: #fff6e0;
  stroke: #7a4a10;
  stroke-width: 1.5;
}
.cbFace .ticks line {
  stroke: #2a1408;
  stroke-width: 3;
}
.cbFace .hh {
  stroke: #2a1408;
  stroke-width: 5.5;
}
.cbFace .mh {
  stroke: #b01c22;
  stroke-width: 3.5;
}
.cbFace .pin {
  fill: #c98a24;
  stroke: none;
}
.cbTime {
  font: 400 calc(var(--u) * 2.4) 'Russo One', sans-serif;
  color: var(--gold);
  line-height: 1;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 0 #3a1706;
  font-variant-numeric: tabular-nums;
}
.cbSub {
  font: 600 calc(var(--u) * 0.85) 'Chakra Petch', sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.8;
}
.clockBadge.late {
  border-color: #ff8a5a;
  animation: latePulse 1.2s ease-in-out infinite;
}
.clockBadge.late .cbTime {
  color: #ffb08a;
}
@keyframes latePulse {
  50% {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 0 28px rgba(255, 110, 70, 0.55);
  }
}
.clockBadge.midnight {
  background: linear-gradient(180deg, rgba(90, 18, 24, 0.92), rgba(40, 6, 12, 0.92));
  border-color: #fff1b8;
  animation: none;
}
.clockBadge.midnight .cbTime {
  color: #fff1b8;
}
.clockBadge.bong {
  animation: bongShake 0.5s cubic-bezier(0.3, 1.8, 0.5, 1);
}
@keyframes bongShake {
  20% {
    transform: translateX(-50%) scale(1.14) rotate(-4deg);
  }
  45% {
    transform: translateX(-50%) scale(1.04) rotate(3deg);
  }
}
.clockBadge.stopped {
  border-color: #cfe6ff;
  box-shadow: 0 0 26px rgba(190, 225, 255, 0.55);
}
.bongN {
  position: absolute;
  left: 50%;
  top: 24%;
  transform: translate(-50%, -50%);
  font: 400 calc(var(--u) * 9) 'Russo One', sans-serif;
  color: #fff1b8;
  -webkit-text-stroke: calc(var(--u) * 0.22) #3a1706;
  paint-order: stroke fill;
  text-shadow: 0 calc(var(--u) * 0.5) 0 #3a1706, 0 0 46px rgba(255, 210, 110, 0.85);
  animation: bongIn 0.9s cubic-bezier(0.2, 1.6, 0.4, 1) both;
  white-space: nowrap;
}
.bongN.last {
  font-size: calc(var(--u) * 7.2);
  animation: shout 2.6s cubic-bezier(0.2, 1.7, 0.4, 1) both;
}
@keyframes bongIn {
  0% {
    opacity: 0;
    scale: 2.2;
  }
  18% {
    opacity: 1;
    scale: 0.95;
  }
  30% {
    scale: 1;
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    scale: 0.9;
  }
}
.shout.freeze {
  color: #e8f4ff;
  -webkit-text-stroke-color: #1c3350;
  text-shadow: 0 calc(var(--u) * 0.4) 0 #1c3350, 0 0 40px rgba(200, 230, 255, 0.9);
}
.shout.xmas {
  color: #ffe07a;
  -webkit-text-stroke-color: #6a0c12;
  text-shadow: 0 calc(var(--u) * 0.4) 0 #6a0c12, 0 0 40px rgba(255, 90, 90, 0.7);
}
.bar button.watch {
  background: linear-gradient(180deg, rgba(255, 217, 110, 0.28), rgba(229, 154, 42, 0.22));
  color: var(--gold) !important;
  box-shadow: inset 0 0 0 1px rgba(255, 211, 107, 0.55);
}
.bar button.watch.on {
  transform: none;
  background: linear-gradient(180deg, #eaf4ff, #a9c8ea);
  color: #14284a !important;
  box-shadow: 0 0 22px rgba(200, 230, 255, 0.8);
}
.frozenTag {
  position: absolute;
  left: 50%;
  bottom: calc(var(--u) * 6.4 + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 0.5em 1.2em;
  border-radius: 999px;
  background: rgba(16, 30, 54, 0.72);
  border: 1px solid rgba(200, 230, 255, 0.5);
  color: #e8f4ff;
  font-size: calc(var(--u) * 1.05);
  letter-spacing: 0.04em;
  white-space: nowrap;
  opacity: 0;
  translate: 0 8px;
  transition: opacity 0.4s, translate 0.4s;
}
#ui.frozen .frozenTag {
  opacity: 1;
  translate: 0 0;
}
#ui.frozen .bar {
  border-color: rgba(200, 230, 255, 0.6);
}
@media (max-width: 640px) {
  .clockBadge {
    top: calc(var(--u) * 5.2 + env(safe-area-inset-top));
  }
  .frozenTag {
    white-space: normal;
    width: 80vw;
    text-align: center;
  }
}

/* ---------------- the toy kit pass: big, clear buttons on touch screens ----------------
   Every button is at least 48px to a finger, with a 24px icon. The toolbar stays one row, clear of the kit's Wishing
   Tree and Calendar buttons, while it fits; on a portrait phone, or wherever it would not fit beside them, ui.js turns
   on #ui.dock: a two-row dock, the toy's actions with their names on top and the little buttons under them. */
@media (pointer: coarse), (max-width: 700px) {
  #ui .bar button {
    min-width: 48px;
    min-height: 48px;
    justify-content: center;
  }
  #ui .bar svg {
    width: 24px;
    height: 24px;
  }
  .spotBtn,
  .mcBtns button,
  .mcBtns a {
    min-height: 44px;
  }
}
#ui.dock {
  --dock: calc(130px + env(safe-area-inset-bottom));
}
#ui.dock .bar {
  flex-wrap: wrap;
  justify-content: center;
  box-sizing: border-box;
  width: calc(100vw - 16px);
  max-width: 440px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  gap: 4px;
  padding: 6px;
  border-radius: 28px;
}
#ui.dock .bar .sep {
  flex-basis: 100%;
  width: auto;
  height: 0;
  margin: 0;
}
#ui.dock .bar button {
  flex: 1 1 0;
  min-width: 0;
  max-width: 92px;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-height: 58px;
  padding: 6px 2px;
  font-size: 11.5px !important;
  letter-spacing: 0.02em;
}
#ui.dock .bar button span {
  display: block !important;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#ui.dock .bar button.sm {
  flex: 0 0 52px;
  width: 52px;
  height: 48px;
  min-height: 48px;
  padding: 0;
}
#ui.dock .bar svg {
  width: 24px;
  height: 24px;
}
#ui.dock .motionCard,
#ui.dock .frozenTag {
  bottom: calc(var(--dock) + 8px);
}
/* the kit's home buttons take about 260px at the bottom left on anything but a portrait phone: keep the toolbar's
   left end past them (--half is half the toolbar's width, from ui.js) */
@media not all and (max-width: 700px) and (orientation: portrait) {
  body.tk-home #ui:not(.dock) .bar {
    left: max(50%, calc(270px + var(--half, 0px)));
  }
  body.tk-home #ui.dock .bar {
    left: max(50%, calc(270px + min(50vw - 8px, 220px)));
  }
}
@media (max-width: 700px) and (orientation: portrait) {
  /* the clock badge sits right of the kit's two home buttons */
  .clockBadge {
    left: calc(50% + 28px);
  }
}
/* the kit's intro card: the words to try, in gold */
.tkCard li span strong {
  color: var(--gold);
  font-weight: 700;
}
