/* Tickle Monster — "They're Ticklish". Everything is scoped under .tm / .tm-page. */

.tm-page {
  --tm-bg: #0b0908;
  --tm-ink: #e6dec9;
  --tm-dim: #8a8070;
  --tm-faint: #4a4339;
  --tm-red: #a3261c;
  --tm-tape: #d8ceaa;
  --tm-hand: #e2ddd2;
  --tm-hand-line: #231d19;
  --tm-vein: #7b8fa6;
  --tm-type: 'Special Elite', 'Courier New', Courier, monospace;
  --tm-serif: 'IM Fell English SC', 'Times New Roman', serif;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--tm-bg);
  color: var(--tm-ink);
  font-family: var(--tm-type);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.tm {
  box-sizing: border-box;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  align-items: center;
  gap: 10px;
  padding: max(14px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
}
.tm *, .tm *::before, .tm *::after { box-sizing: border-box; }

/* ---------- headline ---------- */
.tm-top { text-align: center; min-height: 3.6em; display: grid; align-content: end; gap: 2px; }
.tm-headline {
  margin: 0;
  font-size: clamp(17px, 3.4vw, 26px);
  letter-spacing: 0.14em;
  color: var(--tm-ink);
  text-shadow: 1px 0 0 rgba(163, 38, 28, 0.45), -1px 0 0 rgba(80, 140, 150, 0.25);
  transition: opacity 1.2s ease, color 1.2s ease;
}
.tm-sub {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--tm-dim);
  transition: opacity 0.8s ease;
}
.tm:not([data-phase="idle"]) .tm-sub { opacity: 0; }
/* the headline eggs you on; each new line types itself in */
.tm-headline.is-new { animation: tm-type 0.7s steps(6) both; }
@keyframes tm-type {
  0% { opacity: 0; letter-spacing: 0.3em; }
  40% { opacity: 1; }
  100% { opacity: 1; letter-spacing: 0.14em; }
}
.tm[data-stage="3"] .tm-headline { color: #e8d2b4; }
.tm[data-stage="4"] .tm-headline { color: #e7b9a6; text-shadow: 1px 0 0 rgba(163, 38, 28, 0.8), -1px 0 0 rgba(80, 140, 150, 0.4); }
.tm[data-stage="5"] .tm-headline { color: #9c9283; letter-spacing: 0.22em; }
.tm[data-motion="reduced"] .tm-headline.is-new { animation: none; }

/* ---------- frame ---------- */
.tm-frame {
  position: relative;
  width: min(100%, calc((100vh - 150px) * 2 / 3));
  width: min(100%, calc((100dvh - 150px) * 2 / 3));
  max-width: 620px;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: #000;
  border: 1px solid #2a231d;
  box-shadow: 0 0 0 6px #120f0c, 0 30px 80px rgba(0, 0, 0, 0.8);
  isolation: isolate;
}
.tm-scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transform-origin: 50% 40%;
}
.tm[data-phase="auto"] .tm-scene,
.tm[data-phase="stopping"] .tm-scene { animation: tm-push 24s linear forwards; }
@keyframes tm-push { from { transform: scale(1); } to { transform: scale(1.07); } }

/* artwork styling */
.tm-ink { stroke: #1a1410; stroke-width: 1.6; stroke-linejoin: round; }
.tm-skin { fill: #d6c4b0; stroke: #2a1f19; stroke-width: 1.6; stroke-linejoin: round; }
.tm-sweater { fill: url(#tm-stripes); stroke: #1a1410; stroke-width: 1.8; stroke-linejoin: round; }
.tm-trousers { fill: #39424a; stroke: #14181b; stroke-width: 1.8; stroke-linejoin: round; }
.tm-hair { fill: #2c211b; stroke: #120c09; stroke-width: 1.4; stroke-linejoin: round; }
.tm-strand { fill: none; stroke: #4a382c; stroke-width: 1.4; stroke-linecap: round; }
.tm-sock-a { fill: #aaa59a; stroke: #1d1a16; stroke-width: 1.6; }
.tm-sock-b { fill: #8c4a3e; stroke: #1d1a16; stroke-width: 1.6; }
.tm-fold { fill: none; stroke: #2a2214; stroke-width: 1.3; stroke-linecap: round; opacity: 0.55; }
.tm-seam { fill: none; stroke: #1b2126; stroke-width: 1.2; stroke-dasharray: 3 3; opacity: 0.7; }
.tm-crease { fill: none; stroke: #7d6555; stroke-width: 1; stroke-linecap: round; }
.tm-wrinkle path, .tm-wrinkle-in { fill: none; stroke: #8f8466; stroke-width: 1.6; stroke-linecap: round; opacity: 0.55; }

/* face */
.tm-eye-white { fill: #e4ddcb; }
.tm-iris { fill: #4d5c54; }
.tm-pupil { fill: #0d0a09; }
.tm-glint { fill: #fffbef; }
.tm-lid { fill: none; stroke: #20150f; stroke-width: 1.9; stroke-linecap: round; }
.tm-lid-low { fill: none; stroke: #6b4c3f; stroke-width: 1; stroke-linecap: round; opacity: 0.7; }
.tm-brow { fill: none; stroke: #2a1f18; stroke-width: 3.2; stroke-linecap: round; }
.tm-under { fill: none; stroke: #7d5e57; stroke-width: 3.4; stroke-linecap: round; }
.tm-mouth { fill: #3a1b1b; stroke: #6a3631; stroke-width: 1.7; stroke-linejoin: round; }
.tm-mouth.is-closed { fill: none; }
.tm-teeth { fill: #e4dcc8; }
.tm-tongue { fill: #8c4744; }
.tm-tear { fill: none; stroke: #d7e6ea; stroke-width: 2.3; stroke-linecap: round; }
.tm-sweat { fill: #e9f0f0; stroke: #9fb0b2; stroke-width: 0.6; }
.tm-nose { fill: none; stroke: #7d5f4f; stroke-width: 1.3; stroke-linecap: round; }
.tm-nostril { fill: #4e3a31; }

/* hands */
.tm-hand-skin { fill: var(--tm-hand); stroke: var(--tm-hand-line); stroke-width: 1.5; stroke-linejoin: round; }
.tm-hand-vein { fill: none; stroke: var(--tm-vein); stroke-width: 1.15; stroke-linecap: round; opacity: 0.6; }
.tm-hand-nail { fill: #cdbfa6; stroke: #5e5244; stroke-width: 0.8; }
.tm-hand-crease { fill: none; stroke: #8b8172; stroke-width: 0.9; stroke-linecap: round; }
.tm[data-stage="3"] { --tm-hand: #dcdad0; --tm-vein: #6f86a2; }
.tm[data-stage="4"] { --tm-hand: #d6d8cd; --tm-vein: #66809f; }
.tm[data-stage="5"] { --tm-hand: #d1d6ca; --tm-vein: #5f7b9e; }

/* hotspots */
.tm-hot { fill: rgba(0, 0, 0, 0); stroke: none; cursor: pointer; pointer-events: all; outline: none; }
.tm-hot:focus-visible { stroke: rgba(230, 222, 201, 0.7); stroke-width: 2; stroke-dasharray: 5 6; }
.tm[data-phase="auto"] .tm-hot,
.tm[data-phase="stopping"] .tm-hot,
.tm[data-phase="frozen"] .tm-hot { cursor: default; }

/* pass it on */
.tm-spread { display: grid; justify-items: center; gap: 6px; margin-top: 26px; }
.tm-spread-line { margin: 0; color: #e9e1cb; letter-spacing: 0.14em; font-size: clamp(15px, 3vw, 19px); }
.tm-spread-sub { margin: 0; color: var(--tm-dim); letter-spacing: 0.14em; font-size: 13px; }
.tm-pass {
  margin-top: 10px;
  font-family: var(--tm-type);
  font-size: 17px;
  letter-spacing: 0.2em;
  color: #2a1a12;
  background: var(--tm-tape);
  border: 0;
  padding: 12px 22px 10px;
  min-height: 46px;
  transform: rotate(-1.5deg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  cursor: pointer;
}
.tm-pass:hover { background: #e4dab6; }
.tm-pass:focus-visible { outline: 2px dashed var(--tm-ink); outline-offset: 5px; }
.tm-linkbox { display: flex; gap: 8px; align-items: stretch; margin-top: 12px; width: min(440px, 90vw); }
.tm-linkfield {
  flex: 1;
  min-width: 0;
  font: 13px/1 var(--tm-type);
  letter-spacing: 0.04em;
  color: var(--tm-ink);
  background: #14110e;
  border: 1px solid var(--tm-faint);
  padding: 10px 12px;
}
.tm-linkfield:focus-visible { outline: 2px dashed var(--tm-ink); outline-offset: 2px; }
.tm-linkbox .tm-pass { margin-top: 0; white-space: nowrap; transform: rotate(-1deg); }
.tm-share-native { margin-top: 4px; }
.tm-share-native[hidden] { display: none; }
.tm-yours { margin: 16px 0 0; color: #e9e1cb; letter-spacing: 0.06em; font-size: clamp(13px, 3.6vw, 15px); text-wrap: balance; max-width: 92vw; }
.tm-count { margin: 2px 0 0; color: var(--tm-dim); letter-spacing: 0.12em; font-size: 13px; }
.tm-yours[hidden], .tm-count[hidden] { display: none; }
.tm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tm-carrier { margin: 4px 0 0; color: var(--tm-faint); letter-spacing: 0.22em; font-size: 11px; min-height: 1.4em; word-break: break-all; max-width: 90vw; }

/* ---------- overlays ---------- */
.tm-grain {
  position: absolute;
  inset: -40%;
  pointer-events: none;
  opacity: 0.2;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1.4 -0.2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: tm-grain 0.6s steps(5) infinite;
}
@keyframes tm-grain {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-7%, 4%); }
  40% { transform: translate(5%, -6%); }
  60% { transform: translate(-3%, -9%); }
  80% { transform: translate(8%, 3%); }
  100% { transform: translate(0, 0); }
}
.tm-tint {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 48% 30%, #c9c4a6 0%, #9c9a80 55%, #6f6f5c 100%);
  mix-blend-mode: multiply;
  opacity: 0.55;
}
.tm-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 52%, rgba(0, 0, 0, 0.55) 100%);
}
.tm[data-stage="4"] .tm-vignette,
.tm[data-stage="5"] .tm-vignette { animation: tm-breathe-dark 3.1s ease-in-out infinite; }
@keyframes tm-breathe-dark {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.78; }
}

/* caption: sound described in words, also for muted / hard-of-hearing visitors */
.tm-caption {
  position: absolute;
  left: 50%;
  bottom: 5.5%;
  transform: translateX(-50%);
  margin: 0;
  width: max-content;
  max-width: 88%;
  padding: 4px 10px;
  font-size: clamp(12px, 2.4vw, 15px);
  letter-spacing: 0.06em;
  color: #efe6cf;
  background: rgba(8, 6, 5, 0.62);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.tm-caption.is-on { opacity: 1; }

/* STOP: a strip of tape, not a UI button */
.tm-stop {
  position: absolute;
  left: 50%;
  top: 60%;
  transform: translate(-50%, -50%) rotate(-4deg);
  min-width: 150px;
  min-height: 64px;
  padding: 10px 26px 8px;
  border: 0;
  border-radius: 2px;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.08) 0 3%, transparent 3% 97%, rgba(0,0,0,0.08) 97%),
    var(--tm-tape);
  color: var(--tm-red);
  font-family: var(--tm-type);
  font-size: 40px;
  letter-spacing: 0.18em;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.55);
  clip-path: polygon(0 6%, 4% 0, 9% 5%, 15% 1%, 22% 4%, 31% 0, 40% 3%, 52% 0, 61% 4%, 70% 1%, 79% 5%, 88% 0, 95% 4%, 100% 1%, 99% 94%, 94% 100%, 86% 95%, 77% 99%, 66% 96%, 55% 100%, 45% 95%, 35% 99%, 25% 95%, 15% 100%, 7% 96%, 0 99%);
  z-index: 5;
}
.tm-stop:focus-visible { outline: 2px dashed var(--tm-ink); outline-offset: 6px; }
.tm-stop.is-pressed {
  transform: translate(-50%, -48%) rotate(-4deg) scale(0.96);
  color: #5e140e;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.6);
  cursor: default;
}

/* ---------- controls ---------- */
.tm-controls {
  width: min(100%, 620px);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}
.tm-toggle {
  font: inherit;
  letter-spacing: 0.14em;
  color: var(--tm-ink);
  background: transparent;
  border: 1px solid var(--tm-faint);
  padding: 9px 12px 7px;
  min-height: 40px;
  cursor: pointer;
}
.tm-toggle:hover { border-color: var(--tm-dim); }
.tm-toggle:focus-visible { outline: 2px dashed var(--tm-ink); outline-offset: 3px; }
#tm-sound[aria-pressed="false"] { color: var(--tm-dim); text-decoration: line-through; text-decoration-color: var(--tm-red); }
.tm-meta { color: var(--tm-faint); letter-spacing: 0.18em; text-align: center; }

/* ---------- ending ---------- */
.tm-black { position: fixed; inset: 0; background: #000; z-index: 50; }
.tm-end {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  padding: 24px 16px;
  text-align: center;
  background: #000;
  animation: tm-fade 2.4s ease forwards;
}
.tm-end[hidden], .tm-black[hidden], .tm-stop[hidden] { display: none; }
@keyframes tm-fade { from { opacity: 0; } to { opacity: 1; } }
.tm-logo {
  margin: 0;
  font-family: var(--tm-serif);
  font-weight: 400;
  font-size: clamp(42px, 11vw, 116px);
  line-height: 0.92;
  letter-spacing: 0.06em;
  color: #e9e1cb;
  text-shadow: 2px 0 0 rgba(163, 38, 28, 0.55), -2px 0 0 rgba(70, 120, 130, 0.25);
}
.tm-logo span { display: block; }
.tm-logo span + span { letter-spacing: 0.02em; }
.tm-tag { margin: 0; color: var(--tm-dim); letter-spacing: 0.16em; font-size: clamp(13px, 2.6vw, 16px); }
.tm-end-actions { display: flex; flex-wrap: wrap; gap: 10px 26px; justify-content: center; margin-top: 18px; }
.tm-link {
  font: inherit;
  font-size: 14px;
  letter-spacing: 0.16em;
  color: var(--tm-ink);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--tm-faint);
  padding: 8px 2px 4px;
  min-height: 40px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
}
.tm-link:hover { border-bottom-color: var(--tm-red); }
.tm-link:focus-visible { outline: 2px dashed var(--tm-ink); outline-offset: 4px; }
.tm-noscript { position: fixed; inset: auto 0 40% 0; text-align: center; }

/* ---------- small screens ---------- */
@media (max-width: 520px) {
  .tm { gap: 8px; }
  .tm-frame { width: min(100%, calc((100dvh - 132px) * 2 / 3)); }
  .tm-meta { display: none; }
  .tm-stop { font-size: 34px; min-width: 132px; }
}

/* ---------- reduced motion ---------- */
.tm[data-motion="reduced"] .tm-grain { animation: none; }
.tm[data-motion="reduced"] .tm-scene { animation: none !important; }
.tm[data-motion="reduced"] .tm-vignette { animation: none !important; }
.tm[data-motion="reduced"] .tm-end { animation-duration: 0.6s; }
/* The OS preference is read in JS (data-motion), so the on-page toggle can override it. */
