/* Ralph's song (public/treehouse.js): the letterboard slip while "Treehouse Brown" plays. Same slip as the missing link's
   song; a Huzzah Creek stripe down the left edge (green water over pale gravel) and the film's VHS tape, reels turning.
   The whole song plays in a little 70s walnut TV under the board (YouTube's player, kept at its 200x150 size). */
.thsong { position: fixed; z-index: 36; left: 50%; top: calc(10px + env(safe-area-inset-top)); width: min(calc(100% - 24px), 380px); padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: none; text-align: left; color: var(--letter); transform: translate(-50%, calc(-100% - 20px - env(safe-area-inset-top))); transition: transform .32s cubic-bezier(.2, .9, .3, 1.2); box-shadow: 0 0 0 1px #f5f5f21f, 0 3px 0 #0000004d; visibility: hidden; -webkit-tap-highlight-color: transparent; }
.thsong.in { transform: translate(-50%, 0); visibility: visible; }
.thsong:not(.in) { transition: transform .22s ease-in, visibility 0s .22s; }
.thsong::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; z-index: 1;
  background: radial-gradient(circle at 2px 3px, #d8cfb8 0 1.2px, transparent 1.6px) 0 0 / 6px 7px, linear-gradient(#3f9a86, #24705f); }
.thsong .ts-board { position: relative; display: flex; width: 100%; border: 0; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; flex-direction: column; justify-content: center; gap: 6px; min-height: 68px; padding: 12px 92px 11px 18px; }
.thsong .ts-title { font-size: min(22px, calc((100vw - 150px) / 11)); white-space: nowrap; letter-spacing: .1em; }
.thsong .ts-title .w { display: inline-block; }
.thsong .ts-title b { display: inline-block; font-weight: inherit; }
.thsong .ts-title .sp { display: inline-block; width: .38em; }
.thsong .ts-title b.hop { animation: ts-hop .18s ease-out 1; }
@keyframes ts-hop { 40% { transform: translateY(-4px); } }
.thsong .ts-line { text-transform: none; letter-spacing: .04em; font-size: 16px; }

/* the tape: a black shell, a cream label with the title in marker, a smoked window with the two reels */
.thsong .ts-tape { position: absolute; right: 12px; top: 50%; width: 68px; height: 42px; margin-top: -21px; border-radius: 3px;
  background: linear-gradient(#26252b, #17161a); box-shadow: 0 0 0 1px #f5f5f22e, inset 0 1px 0 #ffffff1a; transform: rotate(-4deg); }
.thsong .ts-label { position: absolute; left: 6px; right: 6px; top: 4px; height: 13px; border-radius: 1px; background: #efe6cf;
  font: italic 700 9px/13px ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif; color: #24705f; text-align: center; text-shadow: none; letter-spacing: .02em; overflow: hidden; }
.thsong .ts-win { position: absolute; left: 10px; right: 10px; bottom: 5px; height: 17px; border-radius: 2px; background: #0d0c10; box-shadow: inset 0 0 0 1px #ffffff14;
  display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.thsong .ts-win i { width: 13px; height: 13px; border-radius: 50%; background:
  radial-gradient(circle, #0d0c10 0 2px, transparent 2.4px),
  conic-gradient(#cfc9bb 0 10%, #5a5650 10% 33%, #cfc9bb 33% 43%, #5a5650 43% 66%, #cfc9bb 66% 76%, #5a5650 76%); }
.thsong .ts-win i:last-child { transform: scale(.82); }
.thsong.spin .ts-win i { animation: ts-reel 1.6s linear infinite; }
.thsong.spin .ts-win i:last-child { animation-duration: 1.3s; }
@keyframes ts-reel { to { rotate: 360deg; } }
.thsong .ts-board:active { transform: translateY(1px); }

/* the TV: a walnut cabinet on the felt, a rounded black CRT bezel round the player, a brushed panel with two knobs and
   a grille. "Tap the TV to play" (phones that won't start sound by themselves) = the bezel glows creek green. */
.thsong.tv { background-color: var(--felt); background-image: repeating-linear-gradient(to bottom, transparent 0 7px, var(--felt-groove) 7px 9px); }
.thsong .ts-tv { display: none; }
.thsong.tv .ts-tv { display: flex; gap: 6px; width: max-content; margin: 0 auto 14px; padding: 8px; border-radius: 9px;
  background: linear-gradient(#ffffff14, #0000 30%, #0000 80%, #0000002e),
    repeating-linear-gradient(97deg, #6e4529 0 3px, #5b3820 3px 8px, #7a4f30 8px 10px, #62401f 10px 15px);
  box-shadow: 0 0 0 1px #2a170b, inset 0 1px 0 #ffffff26, 0 3px 0 #0000004d; transform: translateX(3px); }
.thsong .ts-glass { padding: 6px; border-radius: 16px / 13px; background: #121114; box-shadow: inset 0 0 0 1px #ffffff12, inset 0 2px 6px #000; transition: box-shadow .3s; }
.thsong .ts-screen { width: 200px; height: 150px; border-radius: 11px / 9px; overflow: hidden; background: radial-gradient(#2b3a35, #101413 75%); }
.thsong .ts-screen iframe { display: block; width: 200px; height: 150px; border: 0; }
.thsong .ts-dash { width: 30px; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 0; border-radius: 4px;
  background: linear-gradient(90deg, #b9b4aa, #e2ddd2 45%, #a8a397); box-shadow: inset 0 0 0 1px #00000040; }
.thsong .ts-knob { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #4a4540, #1d1a17 70%);
  box-shadow: 0 1px 0 #ffffff80, 0 0 0 2px #8d877b; position: relative; }
.thsong .ts-knob::after { content: ""; position: absolute; left: 8px; top: 2px; width: 2px; height: 6px; border-radius: 1px; background: #efe6cf; }
.thsong .ts-knob + .ts-knob::after { transform: rotate(130deg); transform-origin: 1px 7px; }
.thsong .ts-grille { flex: 1; width: 16px; border-radius: 2px; background: repeating-linear-gradient(#3a3631 0 2px, transparent 2px 4px); opacity: .7; }
.thsong.ask .ts-glass { box-shadow: inset 0 0 0 1px #ffffff12, 0 0 0 3px #3f9a86, 0 0 14px 2px #3f9a86aa; animation: ts-ask 1.2s ease-in-out infinite alternate; }
@keyframes ts-ask { to { box-shadow: inset 0 0 0 1px #ffffff12, 0 0 0 3px #3f9a8666, 0 0 4px 0 #3f9a8655; } }

@media (prefers-reduced-motion: reduce) {
  .thsong, .thsong:not(.in) { transition: none; }
  .thsong.spin .ts-win i, .thsong.ask .ts-glass { animation: none; }
}
