* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: #222;
  background-color: #ececec;
  font-size: clamp(1rem, 2vw + 0.5rem, 2rem);
  font-family: "Cherry Bomb One", system-ui;
  overflow: hidden;
}

/* The board is the positioning context for every sticker. Its flex centring only ever
   matters for the no-JS fallback markup, where `.hello` is still in normal flow. */
#board {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.fonts-loading .sticker {
  visibility: hidden;
}

.sticker {
  /* --base is a UNITLESS number of px. Multiplying it by a vw-derived length is how the
     board scales down on narrow screens: at 1400px wide, 100vw/1400 == 1px, so --text-size
     lands exactly on --base px; below that it shrinks, floored at 55%. (A `--scale` custom
     property can't be used directly — `100vw / 1400` is a length, and clamp() refuses to
     mix a length with the unitless 0.55 and 1.) */
  --base: 100;
  --text-size: clamp(
    calc(var(--base) * 0.55px),
    calc(var(--base) * 100vw / 1400),
    calc(var(--base) * 1px)
  );

  --text-color: #ffcc33;
  --stroke-width: calc(var(--text-size) * 0.5);
  --stroke-color: #fff;
  --outline-width: 1px;
  --outline-color: var(--text-color);

  /* A no-op by default. The `filter` chain below already carries the four keyline
     drop-shadows, so overriding `filter` on .dragging would wipe them; the lift is appended
     as a variable instead. It must be a real drop-shadow() and not empty — a dangling token
     in a filter list invalidates the whole declaration. */
  --lift: drop-shadow(0 0 0 transparent);

  position: absolute;
  top: 50%;
  left: 50%;
  padding: calc(var(--stroke-width) * 0.5);
  font-size: var(--text-size);
  color: var(--text-color);
  white-space: nowrap;
  -webkit-text-stroke: var(--stroke-width) var(--stroke-color);
  paint-order: stroke fill;
  filter:
    drop-shadow(var(--outline-width) 0 var(--outline-color))
    drop-shadow(calc(var(--outline-width) * -1) 0 var(--outline-color))
    drop-shadow(0 var(--outline-width) var(--outline-color))
    drop-shadow(0 calc(var(--outline-width) * -1) var(--outline-color))
    var(--lift);

  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

@media (prefers-reduced-motion: no-preference) {
  .sticker {
    /* Deliberately not `all`: left/top must never transition, or every pointermove would
       animate and the drag would trail the cursor. */
    transition: scale 0.3s, color 0.3s, filter 0.3s;
  }

  .sticker:hover {
    scale: 1.07;
  }
}

.sticker:hover,
.sticker.dragging {
  color: transparent;
}

.sticker.dragging {
  cursor: grabbing;
  scale: 1.07;
  --lift: drop-shadow(0 12px 14px rgb(0 0 0 / 28%));
}

.sticker:focus-visible {
  outline: 3px solid #2b6cff;
  outline-offset: 8px;
}

.sticker.selected {
  outline: 3px dashed #2b6cff;
  outline-offset: 8px;
}

/* Glossy diagonal sheen, painted over the base text. */
.sticker::before {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  background: linear-gradient(
    40deg,
    var(--text-color) 30%,
    color-mix(in srgb, var(--text-color), #fff 60%) 45% 55%,
    var(--text-color) 70%
  );
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-stroke: initial;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ------------------------------------------------------------------ no-JS fallback */

.sticker.hello    { position: relative; top: 0; left: 0; }
.sticker.blueming { --text-color: #8fa0f8; --base: 50; translate: -180% -100%; rotate: -15deg; }
.sticker.palette  { --text-color: #7ec27c; --base: 45; translate: -80% -300%;  rotate: 10deg; }
.sticker.lilac    { --text-color: #f1c1ff; --base: 60; translate: 50% -230%;   rotate: 3deg; }
.sticker.love     { --text-color: #ffd6d6; --base: 50; translate: -160% 80%; }
.sticker.eight    { --text-color: #c8e7ff; --base: 50; translate: 150% 100%;   rotate: -10deg; }
.sticker.good     { --text-color: #ffae57; --base: 50; translate: 80% -50%;    rotate: 10deg; }
.sticker.friday   { --text-color: #ff9797; --base: 50; translate: -50% 150%;   rotate: -10deg; }

/* ------------------------------------------------------------------------ toolbar */

.toolbar {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 9999;
  display: flex;
  gap: 0.4rem;
  align-items: center;
  padding: 0.35rem;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 10px rgb(0 0 0 / 14%);
  opacity: 0.6;
  transition: opacity 0.2s;
}

.toolbar:hover,
.toolbar:focus-within {
  opacity: 1;
}

.toolbar button {
  padding: 0.45em 0.9em;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #555;
  /* Not `font: inherit` — that pulls Cherry Bomb One down from body and makes the UI
     chrome barely legible at 0.8rem. */
  font: 0.8rem system-ui, sans-serif;
  cursor: pointer;
}

.toolbar button:hover:not(:disabled) {
  background: #f0f0f0;
}

.toolbar button:disabled {
  color: #c4c4c4;
  cursor: default;
}

.toolbar .primary {
  background: #2b6cff;
  color: #fff;
}

.toolbar .primary:hover:not(:disabled) {
  background: #1a56dd;
}

.hint {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 9999;
  color: #999;
  font-family: system-ui, sans-serif;
  font-size: 0.75rem;
}

.sync:not(:empty)::before {
  content: " · ";
}

.sync a {
  color: #2b6cff;
}

/* ------------------------------------------------------------------------- editor */

#editor {
  border: 0;
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 12px 40px rgb(0 0 0 / 25%);
}

#editor::backdrop {
  background: rgb(0 0 0 / 25%);
}

.editor-form {
  display: grid;
  gap: 0.9rem;
  min-width: min(90vw, 22rem);
  padding: 1.25rem;
  font-family: system-ui, sans-serif;
  font-size: 0.9rem;
}

.editor-form h2 {
  margin: 0;
  font-family: "Cherry Bomb One", system-ui;
  font-size: 1.2rem;
  font-weight: normal;
}

.editor-form label {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.6rem;
  align-items: center;
  color: #555;
}

.editor-form input[type="text"] {
  padding: 0.45em 0.6em;
  border: 1px solid #ccc;
  border-radius: 7px;
  font: inherit;
}

.editor-form input[type="color"] {
  width: 100%;
  height: 2.1rem;
  padding: 0;
  border: 1px solid #ccc;
  border-radius: 7px;
  background: none;
}

.editor-form menu {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin: 0.3rem 0 0;
  padding: 0;
}

.editor-form menu button {
  padding: 0.5em 1.1em;
  border: 1px solid #ccc;
  border-radius: 999px;
  background: #fff;
  font: inherit;
  cursor: pointer;
}

.editor-form menu .primary {
  border-color: #2b6cff;
  background: #2b6cff;
  color: #fff;
}

/* Public copy: lift the hint above the portal's back links (bottom-left). */
.hint { bottom: 3.6rem; }
@media (max-width: 640px) {
  .toolbar { bottom: 3.6rem; }
  .hint { bottom: 7rem; }
}
