.tilly-rally {
  --tr-ink:#263b3b; --tr-cream:#ffe7ae; --tr-berry:#a53c3c; --tr-pine:#214d49;
  width:100%;height:100%;min-height:0;display:flex;flex-direction:column;
  color:var(--tr-ink);font-family:Georgia,serif;isolation:isolate;
}
.tilly-rally [hidden]{display:none!important}
.tr-view {
  position:relative;flex:1 1 auto;min-height:128px;overflow:hidden;isolation:isolate;
  border:2px solid #5f4938;border-radius:16px 7px 14px 5px;background:#e6cf9d;
  box-shadow:inset 0 0 0 3px #f9e9bd;cursor:pointer;touch-action:manipulation;
  container-type:size;
}
.tr-horizon,.tr-course,.tr-tracks {position:absolute;inset:0;pointer-events:none}
.tr-horizon {
  background:linear-gradient(180deg,transparent 18%,#f3dfbd44 36%,transparent 58%),
    url('./art/quest-tilly.webp') center 49% / cover,#518b87;
}
.tr-course {
  inset:42% -6% -5%;
  background:repeating-linear-gradient(168deg,transparent 0 18px,#966d4621 19px,transparent 20px 34px),
    linear-gradient(90deg,#b0917dcc 0%,#fff0c95d 17%,#f6e5c962 49%,#f6e9cb67 72%,#ac8784d9);
  clip-path:polygon(46% 0,53% 0,100% 100%,0 100%);
}
.tr-course i, .tr-course::before,.tr-course::after {
  content:"";position:absolute;inset:0;background:#967e5d;opacity:.65;
}
.tr-course i {clip-path:polygon(48.9% 0,49.2% 0,49.7% 100%,49.1% 100%)}
.tr-course::before {clip-path:polygon(45.8% 0,46% 0,9% 100%,8% 100%)}
.tr-course::after {clip-path:polygon(52.7% 0,53% 0,91.5% 100%,90.3% 100%)}
.tr-tracks {
  inset:43% 0 0;opacity:.56;background:repeating-linear-gradient(0deg,transparent 0 15px,#a87d52 15px 18px,transparent 18px 24px);
  clip-path:polygon(48% 0,48.5% 0,28% 100%,26% 100%,48% 0,51.5% 0,52% 0,75% 100%,73% 100%,51.5% 0);
}
.tr-player,.tr-goose,.tr-gate,.tr-finish {position:absolute;pointer-events:none}
.tr-player,.tr-goose {width:clamp(42px,24cqh,84px);aspect-ratio:1;transform:translate(-50%,-100%);z-index:4}
.tr-player {top:84%;left:28.3%}
.tr-player::before,.tr-goose::before {
  content:"";position:absolute;bottom:1%;left:7%;width:86%;height:9%;border-radius:50%;background:#53493854;
}
.tr-goose {top:66%;left:83%;transform:translate(-50%,-100%) scale(var(--goose-scale,.8));transform-origin:bottom center;z-index:3}
.tr-teacher,.tr-goose img,.tr-snowman {display:block;position:absolute;inset:0;width:100%;height:100%;object-fit:contain}
.tr-snowman::before {
  content:"";position:absolute;left:32%;top:45%;width:43%;height:39%;border:1.5px solid #705544;
  border-radius:52% 45% 49% 43%;background:radial-gradient(circle at 68% 40%,#473e34 0 4%,transparent 6%),
    radial-gradient(circle at 66% 67%,#473e34 0 4%,transparent 6%),linear-gradient(110deg,#fff1cc 18%,#dbcfb4 90%);
}
.tr-snowman .tr-sled,.tr-snowman .tr-head {position:absolute;width:100%;height:100%}
.tr-snowman .tr-sled {width:88%;height:80%;bottom:-10%;left:3%}
.tr-snowman .tr-head {width:66%;height:62%;top:0%;left:20%;transform:rotate(6deg)}
.tr-teacher,.tilly-rally[data-phase="demo"] .tr-snowman,.tilly-rally[data-phase="demo"] .tr-goose{display:none}
.tilly-rally[data-phase="demo"] .tr-teacher{display:block}
.tr-gate {width:clamp(46px,19cqh,69px);height:clamp(44px,18cqh,66px);transform:translate(-50%,-100%) scale(var(--gate-scale,1));transform-origin:center bottom;z-index:2}
.tr-bell::before {
  content:"";position:absolute;bottom:0;left:4%;width:7%;height:91%;transform:rotate(-6deg);border-radius:2px;
  background:repeating-linear-gradient(-28deg,#9a3539 0 5px,#ffe8b0 5px 10px);outline:1px solid #6a4639;
}
.tr-bell {filter:drop-shadow(0 0 3px #fdd166)}
.tr-bell i {position:absolute;left:3%;top:-4%;width:94%;height:94%}
.tr-bell::after {
  content:"";position:absolute;left:-6%;bottom:-5%;width:112%;height:12%;border-radius:50%;
  border:2px solid #f4a735;background:#ffdc6b55;
}
.tr-drift i,.tr-drift i::before,.tr-drift i::after {
  content:"";position:absolute;bottom:0;left:0;width:100%;height:40%;border-radius:55% 68% 26% 36%;
  border:2px solid #5d7374;background:repeating-linear-gradient(-32deg,#eee5c9 0 5px,#b4cdc7 6px,#eee5c9 7px 9px);
}
.tr-drift i::before {left:13%;bottom:10%;width:36%;height:100%;border-bottom:0}
.tr-drift i::after {left:49%;bottom:18%;width:31%;height:65%;border-bottom:0}
.tr-distance {
  pointer-events:none;position:absolute;left:12%;right:12%;top:8px;height:21px;z-index:6;
  border-radius:70% 13% 40% 11% / 80% 70% 50% 50%;
  border:1px solid #614734;box-shadow:0 2px 0 #59482c3f;background:#ffedbded;
}
.tr-thread {position:absolute;inset:9px 0 auto;height:2px;background:#9c7751}
.tr-pin {position:absolute;left:0;width:11px;height:11px;box-sizing:border-box;transform:translateX(-50%);border:1.5px solid #513c2f;z-index:2}
.tr-you-pin {background:#ae4247;border-radius:50%;bottom:3px;box-shadow:inset 0 0 0 1px #ffdd9c}
.tr-goose-pin {background:#2f7163;top:0;transform:translateX(-50%) rotate(45deg);width:9px;height:9px}
.tr-chequer,.tr-finish i {
  background:repeating-conic-gradient(#3f453d 0 25%,#fce8bb 0 50%) 0 0 / 8px 8px;
  border:1px solid #483f34;
}
.tr-chequer {position:absolute;right:-8px;top:-1px;width:13px;height:10px;transform:rotate(6deg)}
.tr-finish {left:8%;width:83%;height:25%;z-index:2;transform:translateY(-100%);border-left:3px solid #9a5643;border-right:3px solid #9a5643}
.tr-finish i {display:block;height:18%;min-height:6px}
.tr-callout {
  position:absolute;right:5%;bottom:5%;max-width:87%;z-index:7;border-radius:30% 12% 24% 16% / 40%;
  background:var(--tr-cream);color:#592f2c;box-shadow:1px 2px 0 var(--tr-ink);
  font:italic bold clamp(13px,5cqh,21px)/1.1 Georgia,serif;padding:.25em .6em;pointer-events:none;
}
.tr-callout:empty{display:none}
.tr-controls {display:flex;flex:none;align-items:center;justify-content:center;gap:clamp(12px,5%,36px);padding:7px 6px 2px}
.tilly-rally .tr-controls button {
  position:relative;min-height:44px;min-width:68px;max-width:164px;width:40%;margin:0;padding:5px 9px;
  border:2px solid #3f493f;border-radius:19px 8px 16px 8px;
  background:#f8e4b6;color:#293f3f;box-shadow:0 3px 0 #6d5139;
  font:700 clamp(14px,2.2vw,18px)/1.1 Georgia,serif;touch-action:manipulation;cursor:pointer;opacity:1;
}
.tilly-rally .tr-controls button[aria-pressed="true"]{background:#236055;color:#fff0c8}
.tilly-rally .tr-controls button[data-tilly-teaches]{outline:3px solid #e6ac49;outline-offset:1px}
.tilly-rally .tr-controls button[data-tilly-teaches]::after {
  content:"";position:absolute;left:calc(50% - 4px);top:-13px;width:8px;height:8px;
  border-radius:60% 60% 15% 60%;background:#ffda7a;border:1px solid #75462b;transform:rotate(45deg);
}
.tilly-rally .tr-controls button:focus-visible {outline:3px solid #efab3d;outline-offset:2px}
.tilly-rally[data-outcome="lost"] .tr-player {transform:translate(-50%,-100%) rotate(-8deg)}
.tilly-rally[data-impact="bell"][data-motion="full"] .tr-player {filter:drop-shadow(-3px 2px 1px #ffd474)}
.tilly-rally[data-impact="snow"][data-motion="full"] .tr-snowman {transform:rotate(-13deg)}
.tr-narration {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
@media(max-height:480px) and (orientation:landscape) {
  .tr-view{min-height:95px}
  .tr-controls{padding-top:3px}
  .tilly-rally .tr-controls button{min-height:44px}
  .tr-distance{top:3px;height:15px}
  .tr-thread{top:7px}
}
