/* Stickerz. The interface is made of the same stuff as the stickers: white die-cut
   vinyl, and the waxy backing paper of a sticker sheet with its printer's crop marks. */
:root {
  --cobalt: #2d5bff;
  --cobalt-deep: #2a1f9e;
  --liner: #f3f6fa;
  --liner-edge: #dbe4f0;
  --ink: #18203a;
  --ink-soft: #55607a;
  --cherry: #ff3366;
  --cherry-deep: #d81b4d;
  --sun: #ffd23f;
  --display: 'Bagel Fat One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --ui: 'Fredoka', system-ui, sans-serif;
  --vinyl-shadow: 0 2px 0 rgba(24, 32, 58, 0.1), 0 8px 22px rgba(10, 14, 40, 0.28);
  /* Crop marks on the backing, faint, every 28px. */
  --marks: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28'%3E%3Cpath d='M14 11v6M11 14h6' stroke='%23d4deeb' stroke-width='1.2'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d1230; color: var(--ink); font-family: var(--ui); }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button { font-family: var(--ui); color: inherit; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, .tool:focus-within { outline: 3px solid var(--sun); outline-offset: 2px; }

#stage { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; }
#stage.over { cursor: grab; }
body.holding #stage { cursor: grabbing; }
/* The camera video plays off to the side: the stage draws it. Kept rendered, since some
   phones stop updating a video that isn't. */
.cam { position: fixed; left: 0; top: 0; width: 2px; height: 2px; opacity: 0; pointer-events: none; }
#hands { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; pointer-events: none; z-index: 20; }

/* ---- Logo: a cherry wordmark cut out of white vinyl. ---- */
.logo { display: block; overflow: visible; filter: drop-shadow(0 6px 10px rgba(10, 14, 40, 0.35)); }
.logo text {
  font-family: var(--display); font-size: 74px; fill: var(--cherry);
  stroke: #fff; stroke-width: 16px; stroke-linejoin: round; paint-order: stroke fill;
}

/* ---- Start screen ---- */
.start {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; overflow: auto;
  background:
    radial-gradient(ellipse 70% 55% at 30% 18%, rgba(255, 255, 255, 0.16), transparent 70%),
    linear-gradient(160deg, var(--cobalt) 0%, #3346e0 55%, var(--cobalt-deep) 100%);
  transition: opacity 0.6s ease;
}
.start.hide { opacity: 0; pointer-events: none; }
.collage { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.collage img {
  position: absolute; width: clamp(110px, 17vmin, 210px); transform: translate(-50%, -50%) rotate(var(--r));
  animation: slap 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.25) both; animation-delay: calc(var(--d) + 150ms);
}
@keyframes slap {
  from { opacity: 0; transform: translate(-50%, -50%) rotate(calc(var(--r) - 14deg)) scale(1.6); filter: drop-shadow(0 30px 30px rgba(0, 0, 0, 0.35)); }
  60% { opacity: 1; }
  to { opacity: 1; transform: translate(-50%, -50%) rotate(var(--r)) scale(1); filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0)); }
}
.card {
  position: relative; width: min(100%, 520px); padding: 22px 30px 26px; text-align: center;
  background: var(--liner) var(--marks); border-radius: 30px;
  box-shadow: 0 0 0 7px #fff, 0 24px 60px rgba(8, 10, 40, 0.45);
  margin: 40px 0 16px;
}
.card .logo.big { width: min(86%, 330px); margin: -78px auto 0; transform: rotate(-5deg); }
.title { font-family: var(--display); font-weight: 400; font-size: clamp(26px, 5vw, 34px); line-height: 1.08; margin: 4px 0 16px; color: var(--ink); text-wrap: balance; }
.steps { list-style: none; counter-reset: step; margin: 0 auto 22px; padding: 0; max-width: 420px; text-align: left; display: grid; gap: 9px; }
.steps li { counter-increment: step; position: relative; padding-left: 40px; font-size: 16.5px; line-height: 1.35; color: var(--ink-soft); }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 600; font-size: 15px; color: #fff; background: var(--cherry);
  box-shadow: 0 0 0 3px #fff, 0 2px 6px rgba(10, 14, 40, 0.2);
}
.steps b { color: var(--ink); font-weight: 600; }
.actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.primary, .ghost { font-size: 17px; font-weight: 600; border-radius: 999px; padding: 13px 24px; cursor: pointer; border: 0; }
.primary { background: var(--cherry); color: #fff; box-shadow: 0 0 0 4px #fff, var(--vinyl-shadow); }
.primary:hover { background: var(--cherry-deep); }
.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.ghost:hover { background: rgba(24, 32, 58, 0.06); }
.small { font-size: 14px; padding: 8px 16px; }
button:disabled { opacity: 0.55; cursor: wait; }
.status { min-height: 1.3em; margin: 14px 0 0; font-size: 15px; color: var(--ink); }
.status.error { color: var(--cherry-deep); font-weight: 500; }
.fine { margin: 10px auto 0; max-width: 420px; font-size: 13px; line-height: 1.45; color: var(--ink-soft); }
.credit { margin: 8px 0 0; font-size: 13px; }
.card a { color: var(--ink); text-underline-offset: 2px; }

/* ---- The sticker sheet ---- */
.sheet {
  position: fixed; z-index: 10; top: 14px; right: 14px; bottom: 14px; width: clamp(150px, 15vw, 196px);
  display: flex; flex-direction: column; border-radius: 26px; overflow: hidden;
  background: var(--liner) var(--marks); box-shadow: 0 0 0 5px #fff, 0 18px 40px rgba(6, 10, 30, 0.45);
  opacity: 0; transform: translateX(30px); transition: opacity 0.5s 0.2s, transform 0.5s 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  user-select: none; -webkit-user-select: none;
}
body.playing .sheet { opacity: 1; transform: none; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 8px 8px 6px; border-bottom: 2px dashed var(--liner-edge); background: rgba(255, 255, 255, 0.6); }
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 0 4px; border: 0; border-radius: 14px;
  background: transparent; cursor: pointer; min-height: 56px;
}
.tab-icon { width: 36px; height: 36px; display: grid; place-items: center; transition: transform 0.2s; }
.tab-icon img, .tab-icon svg { width: 100%; height: 100%; object-fit: contain; }
.tab-name { font-size: 11.5px; font-weight: 500; color: var(--ink-soft); line-height: 1.1; }
.tab:hover .tab-icon { transform: scale(1.1) rotate(-4deg); }
.tab[aria-selected="true"] { background: #fff; box-shadow: 0 2px 8px rgba(24, 32, 58, 0.14); }
.tab[aria-selected="true"] .tab-name { color: var(--cherry-deep); font-weight: 600; }
.strip { flex: 1; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; touch-action: pan-y; overscroll-behavior: contain; }
.strip::-webkit-scrollbar { display: none; }
.slots { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 8px 10px; }
.slot {
  position: relative; width: 100%; max-width: 168px; aspect-ratio: 1; padding: 0; border: 0; background: none; cursor: grab;
  touch-action: pan-y;
}
.slot img { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; }
.slot .art { transition: transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.4), filter 0.18s; }
.slot:not(.ready) { background: radial-gradient(circle, rgba(219, 228, 240, 0.9) 0 34%, transparent 35%); }
.slot:hover .art, .slot.pressed .art { transform: scale(1.06) rotate(-2deg); filter: drop-shadow(0 6px 8px rgba(10, 14, 40, 0.25)); }
.slot.regrow .art { animation: regrow 0.9s both; }
@keyframes regrow {
  0%, 45% { opacity: 0; transform: scale(0.5); }
  80% { opacity: 1; transform: scale(1.07); }
  100% { opacity: 1; transform: scale(1); }
}

/* ---- Tools, top left ---- */
.toolbar {
  position: fixed; z-index: 10; top: 12px; left: 14px; display: flex; align-items: center; gap: 10px;
  opacity: 0; transition: opacity 0.5s 0.3s; pointer-events: none;
}
body.playing .toolbar { opacity: 1; pointer-events: auto; }
.toolbar .logo { width: 150px; transform: rotate(-4deg); margin-right: 6px; }
.tool {
  position: relative; display: flex; align-items: center; gap: 7px; height: 48px; padding: 0 16px 0 12px; border: 0; border-radius: 999px;
  background: #fff; color: var(--ink); font-size: 15px; font-weight: 600; cursor: pointer; box-shadow: var(--vinyl-shadow);
  transition: transform 0.15s;
}
.tool:hover { transform: translateY(-1px) rotate(-1.5deg); }
.tool:active { transform: scale(0.96); }
.tool svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool[hidden] { display: none; }
.tool select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }

/* ---- Trash: shows while a sticker is held ---- */
.trash {
  position: fixed; z-index: 11; left: 18px; bottom: 64px; width: 84px; height: 84px; border-radius: 50%;
  display: grid; place-items: center; background: #fff; color: var(--ink); box-shadow: var(--vinyl-shadow);
  opacity: 0; transform: scale(0.6); transition: opacity 0.2s, transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.4), background 0.15s; pointer-events: none;
}
body.holding .trash { opacity: 1; transform: none; }
.trash svg { width: 48px; height: 48px; fill: none; stroke: currentColor; stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.trash .lid { transform-origin: 46px 18px; transition: transform 0.2s; }
.trash.open { background: var(--cherry); color: #fff; transform: scale(1.15); }
.trash.open .lid { transform: rotate(24deg) translate(2px, -4px); }

/* ---- Hints, countdown, flash ---- */
.hint {
  position: fixed; z-index: 12; left: 16px; right: 16px; top: 16px; width: fit-content; max-width: 560px; margin: 0 auto; padding: 11px 20px;
  border-radius: 18px; background: #fff; color: var(--ink); font-size: 17px; font-weight: 500; line-height: 1.3; text-align: center; text-wrap: balance;
  box-shadow: var(--vinyl-shadow); transform: translateY(-16px); opacity: 0; transition: opacity 0.3s, transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  pointer-events: none;
}
.hint.show { opacity: 1; transform: none; }
.countdown {
  position: fixed; z-index: 25; left: 50%; top: 50%; transform: translate(-50%, -50%); font-family: var(--display); font-size: min(40vmin, 300px);
  color: var(--cherry); pointer-events: none;
  filter: drop-shadow(6px 0 0 #fff) drop-shadow(-6px 0 0 #fff) drop-shadow(0 6px 0 #fff) drop-shadow(0 -6px 0 #fff) drop-shadow(0 14px 24px rgba(0, 0, 0, 0.4));
}
.countdown.beat { animation: beat 0.9s ease-out both; }
@keyframes beat { from { transform: translate(-50%, -50%) scale(1.4); opacity: 0; } 25% { opacity: 1; transform: translate(-50%, -50%) scale(1); } to { opacity: 0; transform: translate(-50%, -50%) scale(0.9); } }
.flash { position: fixed; inset: 0; z-index: 26; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash 0.6s ease-out; }
@keyframes flash { from { opacity: 0.9; } to { opacity: 0; } }

/* ---- Corner: settings, privacy and credit, dim so they don't pull kids' eyes ---- */
.corner { position: fixed; z-index: 10; left: 14px; bottom: 12px; display: flex; align-items: center; gap: 14px; font-size: 12px; opacity: 0.5; transition: opacity 0.2s; }
.corner:hover, .corner:focus-within { opacity: 1; }
.corner a { color: #fff; text-decoration: none; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); }
.corner a:hover { text-decoration: underline; }
.gear { width: 40px; height: 40px; padding: 8px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.92); color: var(--ink); cursor: pointer; box-shadow: var(--vinyl-shadow); }
.gear svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
body:not(.playing) .corner { display: none; }

/* ---- Settings ---- */
.settings {
  position: fixed; z-index: 40; left: 14px; bottom: 64px; width: 320px; max-height: calc(100vh - 90px); overflow: auto;
  padding: 14px 16px 16px; border-radius: 20px; background: var(--liner); box-shadow: 0 0 0 4px #fff, 0 18px 40px rgba(6, 10, 30, 0.45);
  font-size: 14px; display: flex; flex-direction: column; gap: 10px;
}
.settings[hidden] { display: none; }
.settings header { display: flex; justify-content: space-between; align-items: center; }
.settings h2 { font-family: var(--display); font-weight: 400; margin: 0; font-size: 24px; color: var(--cherry); }
.settings header button { border: 0; background: none; font-size: 28px; line-height: 1; padding: 0 4px; cursor: pointer; }
.settings .row { display: flex; gap: 8px; align-items: flex-start; line-height: 1.3; }
.settings .row input { margin-top: 2px; accent-color: var(--cherry); }
.settings .col { display: flex; flex-direction: column; gap: 4px; }
.settings .col span { color: var(--cherry-deep); font-weight: 600; }
.settings select, .settings input[type=range] { width: 100%; accent-color: var(--cherry); }
.settings select { font-family: var(--ui); font-size: 14px; padding: 5px; border-radius: 10px; border: 1px solid var(--liner-edge); background: #fff; }
.readout { font-family: ui-monospace, Menlo, monospace; font-size: 12px; line-height: 1.5; white-space: pre-wrap; color: var(--ink-soft);
  background: #fff; border-radius: 10px; padding: 8px; min-height: 3em; }

/* ---- Phones held upright, and short wide screens: the sheet lies along the bottom ---- */
@media (max-aspect-ratio: 4/5), (max-width: 560px), (max-height: 430px) and (max-aspect-ratio: 3/2) {
  .sheet { top: auto; left: 10px; right: 10px; bottom: 10px; width: auto; height: auto; transform: translateY(30px); }
  .tabs { grid-template-columns: repeat(6, 1fr); padding: 6px 6px 4px; }
  .tab { min-height: 48px; padding: 4px 0 3px; }
  .tab-icon { width: 28px; height: 28px; }
  .tab-name { font-size: 10.5px; }
  .strip { overflow-x: auto; overflow-y: hidden; touch-action: pan-x; }
  .slots { flex-direction: row; padding: 4px 8px 8px; width: max-content; }
  .slot { width: 92px; touch-action: pan-x; }
  .toolbar .logo { width: 112px; }
  .tool { height: 42px; padding: 0 12px 0 10px; font-size: 14px; }
  .trash { left: auto; right: 16px; bottom: auto; top: 70px; }
  .corner { left: auto; right: 12px; bottom: auto; top: 14px; }
  body.playing .corner a { display: none; }
  .settings { left: 10px; right: 10px; width: auto; bottom: auto; top: 64px; max-height: calc(100vh - 230px); }
  .hint { top: auto; bottom: 190px; }
}
/* Short, wide screens (a phone on its side): smaller tabs without names, and hints at the
   bottom so they never cover the tools. */
@media (max-height: 500px) and (min-aspect-ratio: 3/2) {
  .tabs { padding: 4px 6px 3px; }
  .tab { min-height: 38px; padding: 3px 0; }
  .tab-icon { width: 30px; height: 30px; }
  .tab-name { display: none; }
  .toolbar .logo { width: 108px; }
  .tool { height: 40px; }
  .hint { top: auto; bottom: 14px; right: calc(clamp(150px, 15vw, 196px) + 30px); font-size: 15px; }
  .trash { width: 70px; height: 70px; bottom: 58px; }
}
@media (max-width: 420px) {
  .tool span { display: none; }
  .tool { padding: 0 12px; }
  .card { padding: 18px 18px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .collage img { animation: none; }
  .slot.regrow .art { animation-duration: 0.01s; }
  .countdown.beat { animation: none; }
  .sheet, .toolbar, .hint, .trash { transition: none; }
}
