@font-face {
  font-family: "Bodoni Moda";
  src: url("assets/fonts/bodoni-moda.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Archivo";
  src: url("assets/fonts/archivo.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --cream: #FFF7F0;
  --blush: #FFDCE7;
  --peach: #FFCDB2;
  --coral: #FF6F91;
  --mint: #6FD8B4;
  --lilac: #C3AEF0;
  --sun: #FFB627;
  --green: #34C98A;

  --plum: #4A2B41;
  --muted: #9A7488;

  --edge: rgba(74, 43, 65, 0.10);
  --panel: rgba(255, 255, 255, 0.62);
  --panel-lift: rgba(255, 255, 255, 0.9);

  --lift: 0 10px 26px rgba(180, 100, 130, 0.22);
  --lift-sm: 0 4px 12px rgba(180, 100, 130, 0.18);

  --display: "Bodoni Moda", "Didot", "Times New Roman", serif;
  --body: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  --r: 20px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; height: 100%; overscroll-behavior: none; }

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--plum);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.5;
  background-color: var(--cream);
  background-image:
    radial-gradient(105% 75% at 6% -8%, #FFD3E4 0%, rgba(255, 211, 228, 0) 58%),
    radial-gradient(95% 70% at 102% 8%, #FFE0C4 0%, rgba(255, 224, 196, 0) 55%),
    radial-gradient(100% 75% at 88% 104%, #C9F2E2 0%, rgba(201, 242, 226, 0) 58%),
    radial-gradient(85% 60% at 10% 100%, #E4D9FB 0%, rgba(228, 217, 251, 0) 60%),
    linear-gradient(165deg, #FFF3EA 0%, #FFF7F0 100%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

body, button { -webkit-user-select: none; user-select: none; }

#app {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: calc(var(--safe-t) + 22px) 22px 8px;
  min-height: 0;
}

.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.display {
  font-family: var(--display);
  font-optical-sizing: auto;
  font-weight: 500;
  font-size: clamp(2.1rem, 12vw, 3.4rem);
  line-height: 1.04;
  letter-spacing: -0.01em;
  margin: 0;
  text-wrap: balance;
}

.line { margin: 0 auto; font-size: 17px; max-width: 26ch; color: var(--muted); }

/* --- start --- */

.start {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 24px;
  padding-bottom: 8dvh;
}
.start .display { max-width: 11ch; margin-inline: auto; }

/* --- buttons --- */

.btn {
  font-family: var(--body);
  font-size: 17px;
  font-weight: 600;
  color: #FFFFFF;
  background: linear-gradient(180deg, #FF87A3 0%, #FF6F91 100%);
  border: 0;
  border-radius: 999px;
  padding: 16px 34px;
  min-height: 52px;
  min-width: 44px;
  box-shadow: 0 8px 20px rgba(255, 111, 145, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 130ms ease, box-shadow 130ms ease, opacity 130ms ease;
}

.btn:active { transform: translateY(2px) scale(0.985); box-shadow: var(--lift-sm); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

.btn-quiet {
  background: var(--panel);
  color: var(--plum);
  border: 1px solid var(--edge);
  box-shadow: none;
  font-weight: 500;
}

.btn-plain {
  font-family: var(--body);
  font-size: 15px;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 14px 10px;
  min-height: 44px;
  cursor: pointer;
  touch-action: manipulation;
}

.row { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; }

.screen > .btn { align-self: center; }

/* --- hidden reset --- */

#footer {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  padding-bottom: calc(var(--safe-b) + 6px);
  flex: none;
}

#dot {
  width: 44px; height: 44px; padding: 0; border: 0;
  background: transparent; cursor: default;
  display: grid; place-items: center;
  touch-action: manipulation;
}

#dot::after {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--plum);
  opacity: 0.16;
}

/* Development only - main.js never appends this off localhost. */
.dev-reset {
  position: fixed;
  right: 12px;
  bottom: calc(var(--safe-b) + 12px);
  font-family: var(--body);
  font-size: 13px;
  color: var(--plum);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--edge);
  border-radius: 999px;
  padding: 9px 15px;
  min-height: 36px;
  cursor: pointer;
  opacity: 0.7;
  touch-action: manipulation;
  z-index: 20;
}

/* --- shelf --- */

.shelf {
  gap: 20px;
  justify-content: center;
  text-align: center;
  padding-bottom: 6dvh;
}
.shelf-line { flex: none; }
.usolve-line { flex: none; }

.shelf-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  flex: none;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
}

.slot {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: var(--r);
  border: 1px solid var(--edge);
  background: var(--panel);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 140ms ease, background 140ms ease;
}

.slot.is-filled { background: var(--panel-lift); box-shadow: var(--lift-sm); cursor: default; }
.slot:not(.is-filled):active { transform: scale(0.96); background: var(--panel-lift); }

.slot-plus { font-size: 26px; font-weight: 300; line-height: 1; color: var(--muted); opacity: 0.6; }

.box { width: 62%; height: 62%; display: block; overflow: visible; }

.box-body { fill: var(--coral); }
.box-top  { fill: #FF98AF; }
.box-band { fill: rgba(255, 255, 255, 0.55); }

.box.is-open .box-body { fill: var(--blush); }
.box.is-open .box-top  { fill: var(--peach); }

.box-letter {
  font-family: var(--display);
  font-size: 52px;
  font-weight: 600;
  fill: var(--plum);
}

.slot.is-new .box { animation: drop 520ms cubic-bezier(0.18, 1.3, 0.4, 1); }
.slot.is-popping .box { animation: pop 380ms cubic-bezier(0.2, 1.5, 0.4, 1); }

@keyframes drop {
  0%   { transform: translateY(-70%) rotate(-8deg); opacity: 0; }
  100% { transform: translateY(0) rotate(0); opacity: 1; }
}

@keyframes pop {
  0%   { transform: scale(0.7); }
  60%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* --- a game --- */

.game { gap: 14px; }
.game-line { flex: none; width: 100%; max-width: none; text-align: center; }

.stage {
  flex: 1;
  min-height: 0;
  position: relative;
  touch-action: none;
  overflow: hidden;
  border-radius: var(--r);
  border: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.55);
  box-shadow: var(--lift-sm);
}

.canvas { display: block; touch-action: none; }

.pips { position: absolute; top: 12px; right: 12px; display: flex; gap: 5px; pointer-events: none; z-index: 3; }

.pip {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(74, 43, 65, 0.16);
  transition: background 160ms ease, transform 160ms ease;
}

.pip.is-on { background: var(--coral); transform: scale(1.3); }

.restart {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 40px;
  color: var(--plum);
  background: rgba(255, 247, 240, 0.78);
  pointer-events: none;
  z-index: 4;
  animation: fadeout 800ms ease-out forwards;
}

@keyframes fadeout {
  0% { opacity: 0; } 22% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; }
}

/* --- whack-a-mole --- */

.mole-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 10px;
  padding: 10px;
}

.hole {
  position: relative;
  border: 0;
  padding: 0;
  background: #F1DFE8;
  border-radius: 50% / 26%;
  overflow: hidden;
  cursor: pointer;
  touch-action: manipulation;
  display: grid;
  place-items: end center;
  box-shadow: inset 0 6px 12px rgba(74, 43, 65, 0.16);
}

.mole {
  font-size: clamp(28px, 9vw, 44px);
  line-height: 1;
  transform: translateY(115%);
  transition: transform 110ms ease-out;
  padding-bottom: 4%;
}

.hole.is-up .mole { transform: translateY(0); }
.hole.is-hit { background: #CFF3E4; }

/* --- find the odd one --- */

.pair-grid {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 8px;
  padding: 12px;
}

.pair-cell {
  border: 0;
  padding: 0;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  font-size: clamp(20px, 6.5vw, 34px);
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: var(--lift-sm);
  transition: transform 120ms ease, background 160ms ease;
}

.pair-cell:active { transform: scale(0.93); }
.pair-cell.is-yes { background: var(--green); }
.pair-cell.is-no { background: #FFD2DE; }

/* --- unscramble: drag, snap, go green --- */

.unscramble {
  gap: 24px;
  justify-content: center;
  text-align: center;
  padding-bottom: 6dvh;
}

.usolve {
  position: relative;
  flex: none;
  width: 100%;
  max-width: 330px;
  margin: 0 auto;
}

.uslots, .uhomes {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 330px;
  margin: 0 auto;
}

/* The empty word sits below the tray - she drags down into it. */
.uslots { margin-top: 52px; }

.uslot, .uhome {
  aspect-ratio: 4 / 5;
  border-radius: 12px;
}

.uslot {
  border: 2px dashed rgba(74, 43, 65, 0.22);
  background: rgba(255, 255, 255, 0.4);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.uslot.is-near {
  border-color: var(--coral);
  background: rgba(255, 111, 145, 0.12);
  transform: scale(1.06);
}

.uslot.is-filled { border-style: solid; border-color: transparent; background: transparent; }

.uhome { border: 0; background: transparent; }

.utile {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 25px;
  font-weight: 600;
  line-height: 1;
  color: var(--plum);
  background: #FFFFFF;
  border-radius: 12px;
  box-shadow: var(--lift-sm);
  cursor: grab;
  touch-action: none;
  z-index: 2;
  transition: transform 240ms cubic-bezier(0.2, 1.1, 0.35, 1),
              background 200ms ease, color 200ms ease, box-shadow 200ms ease;
}

.utile.is-dragging {
  transition: background 200ms ease, color 200ms ease, box-shadow 200ms ease;
  cursor: grabbing;
  z-index: 5;
  box-shadow: 0 14px 30px rgba(180, 100, 130, 0.35);
}

.utile.is-locked {
  background: var(--green);
  color: #FFFFFF;
  cursor: default;
  box-shadow: 0 6px 16px rgba(52, 201, 138, 0.4);
}

.utile.is-refused { animation: shrug 320ms ease-in-out; }

@keyframes shrug {
  0%, 100% { transform: var(--home) translateX(0); }
  25%      { transform: var(--home) translateX(-7px); }
  75%      { transform: var(--home) translateX(7px); }
}

.usolve.is-solved .utile { animation: cheer 620ms cubic-bezier(0.2, 1.4, 0.4, 1); }

@keyframes cheer {
  0%   { transform: var(--home) scale(1); }
  45%  { transform: var(--home) scale(1.16); }
  100% { transform: var(--home) scale(1); }
}

.usolve-line.is-done { color: var(--green); font-weight: 600; }

/* --- reveal --- */

.reveal {
  justify-content: center;
  text-align: center;
  gap: 18px;
  padding-bottom: 5dvh;
}

.reveal .line { margin-inline: auto; }

/* --- the reveal artwork --- */

.reveal-art {
  width: 100%;
  max-width: 340px;
  margin: 0 auto 2px;
  flex: 0 1 auto;
  min-height: 0;
}

.reveal-art svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 30dvh;
  overflow: visible;
}

.a-land {
  fill: #FFD2DE;
  stroke: var(--coral);
  stroke-width: 2.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.a-isle circle { fill: var(--coral); opacity: 0.75; }

.a-pin { fill: var(--coral); }
.a-pin-halo { fill: var(--coral); opacity: 0.2; }

.a-fish-body { fill: var(--coral); }
.a-fish-tail { fill: var(--peach); }
.a-fin { fill: none; stroke: rgba(255, 255, 255, 0.85); stroke-width: 2.6; stroke-linecap: round; }
.a-eye { fill: var(--plum); }
.a-eye-light { fill: #FFFFFF; }

.a-prawn { fill: none; stroke: #FF8FA6; stroke-width: 7.5; stroke-linecap: round; }
.a-thin { fill: none; stroke: #FF8FA6; stroke-width: 2.6; stroke-linecap: round; }

.a-shell { fill: var(--sun); }
.a-shell-lines path { fill: none; stroke: rgba(255, 255, 255, 0.75); stroke-width: 2; stroke-linecap: round; }

.a-lemon { fill: #FFE066; }
.a-leaf { fill: var(--mint); }

.a-wave path { fill: none; stroke: var(--mint); stroke-width: 2.6; stroke-linecap: round; opacity: 0.8; }
.a-bubble circle { fill: var(--mint); opacity: 0.45; }

.reveal > *:not(.is-in) { opacity: 0; transform: translateY(12px); }

.reveal > .is-in {
  opacity: 1;
  transform: none;
  transition: opacity 1000ms ease-out, transform 1000ms cubic-bezier(0.2, 0.8, 0.3, 1);
}

.word {
  font-size: clamp(2.8rem, 17vw, 4.8rem);
  font-weight: 700;
  color: var(--coral);
  letter-spacing: 0.03em;
}

.reveal-dates {
  font-family: var(--display);
  font-size: 32px;
  font-weight: 500;
  margin: 0;
  line-height: 1.15;
}

.her-half {
  position: relative;
  max-width: 27ch;
  padding-top: 20px;
  font-size: 18px;
  color: var(--plum);
}

.her-half::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 2px;
  background: var(--coral);
}

.reveal-foot { margin-top: 18px; }

.again {
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-color: rgba(154, 116, 136, 0.45);
  padding-left: 0;
}

@media (max-height: 700px) {
  .reveal-art svg { max-height: 24dvh; }
  .word { font-size: clamp(2.4rem, 14vw, 3.6rem); }
  .reveal-dates { font-size: 27px; }
  .reveal { gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .slot, .pip, .mole, .uslot, .pair-cell { transition: none; }
  .utile { transition: background 200ms ease, color 200ms ease; }
  .slot.is-new .box,
  .slot.is-popping .box,
  .utile.is-refused,
  .usolve.is-solved .utile { animation: none; }
  .restart { animation: none; opacity: 1; }
  .reveal > .is-in { transition: none; }
  .reveal > *:not(.is-in) { transform: none; }
}
