:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  color: #fff2d6;
  background: #241921;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
body { margin: 0; overflow: hidden }
button { font: inherit; color: inherit; cursor: pointer; touch-action: none }
button:focus-visible { outline: 2px solid #fff1a3; outline-offset: 4px }
#game { position: relative; isolation: isolate; width: 100vw; height: 100dvh; min-height: 320px; overflow: hidden; container-type: size; background: #342534 }
#world,.finish { position: absolute; inset: 0; width: 100%; height: 100%; display: block }
.finish { pointer-events: none; background: radial-gradient(ellipse at 61% 43%, transparent 47%, #1c141e67 100%) }
#game[data-mode="title"] .finish,
#game[data-mode="escaped"] .finish,
#game[data-mode="caught"] .finish {
  background: linear-gradient(90deg,#211721f5 0%,#2b1b27dc 23%,#24192363 49%,transparent 70%), radial-gradient(ellipse at 75% 50%, transparent 44%, #2116219b 100%);
}
.panel { position: absolute; top: 50%; left: 5.5%; width: min(43%, 470px); transform: translateY(-50%); text-shadow: 0 2px 18px #21131a }
.eyebrow { margin: 0 0 1.7cqh; color: #ffc987; letter-spacing: .25em; font-size: clamp(9px,1.52cqh,15px); font-weight: 800 }
h1,h2 { margin: 0; font: 700 clamp(45px, 13.5cqh, 125px)/.82 Georgia, serif; letter-spacing: -.072em; color: #fff0c5 }
h1 em, h2 em { color: #ffc685; font-weight: 700 }
.premise { font: 500 clamp(13px,2.5cqh,22px)/1.37 Georgia, serif; margin: 2.8cqh 0 2.8cqh; color: #ffe8c8 }
.primary { display: flex; align-items: center; justify-content: space-between; gap: 1.5em; border: 1px solid #ffe2a7; border-radius: 3px; color: #321d21; background: #f6bd70; padding: .65em .9em .67em 1em; font-size: clamp(12px,2.37cqh,20px); font-weight: 800; box-shadow: 0 4px 0 #9d5938, 0 10px 22px #1f131d80 }
.primary:hover { background: #ffdb91 }
kbd { font: 700 .85em system-ui,sans-serif; border-radius: 2px; padding: .12em .30em; background: #ffffff14; border: 1px solid #ffffff2a }
.primary kbd { background: #411f2020; border-color: #5c33333b }
.skins { display: flex; gap: .45em; margin: 2.6cqh 0 1.8cqh; flex-wrap: wrap }
.skins button,.sound { border: 1px solid #f3bd824d; background: #30202ac7; color: #f7dfbc; border-radius: 3px; font-size: clamp(9px,1.65cqh,15px); font-weight: 650; padding: .36em .56em }
.skins button::before { display: inline-block; content: ''; width: .64em; height: .64em; margin: 0 .45em .05em 0; border-radius: 50%; background: #ba6546 }
.skins button:nth-child(2)::before { background: #e6aa4d }
.skins button:nth-child(3)::before { background: #937aab }
.skins button:nth-child(4)::before { background: #bca58c }
.skins button:nth-child(5)::before { background: #51b5a4 }
.skins button[aria-pressed="true"] { color: #fff0c8; border-color: #ffcb8b; background: #724332 }
.controls { margin: 0; color: #ebcab6; font-size: clamp(9px,1.54cqh,14px); line-height: 1.9 }
.controls kbd { margin-right: .17em }
.controls kbd:not(:first-child) { margin-left: .22em }
.sound { position: absolute; right: 2.5%; bottom: 3.2%; z-index: 3; letter-spacing: .11em; font-size: clamp(9px,1.44cqh,14px) }
.hudbar {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, .86fr) auto;
  align-items: center; gap: 3vw; position: absolute; inset: 3.4% 3.3% auto;
  text-shadow: 0 2px 5px #211623, 0 1px 13px #231824eb;
}
.identity { position: relative; min-width: 0; white-space: nowrap }
.identity strong { display: block; font: 700 clamp(17px, 4.05cqh, 40px)/1.06 Georgia,serif; color: #fff0c5 }
.metertext span { color: #ffe0ac; font-size: clamp(8px,1.35cqh,13px); font-weight: 800; letter-spacing: .13em }
.metertext { display: flex; align-items: baseline; justify-content: space-between; gap: .6em; white-space: nowrap; font-size: clamp(10px,1.98cqh,17px) }
.meter { margin-top: .34em; width: 100%; height: .65cqh; min-height: 3px; background: #2115219d; border-radius: 2px; box-shadow: 0 0 0 1px #ffe0a777 }
.meter i { background: #ffd191; display: block; height: 100%; border-radius: inherit; width: 0 }
#routeMap {
  --distance: 0%;
  --elevation: 0;
  position: relative; height: max(8px, 1.45cqh); margin-top: .24em;
}
.map-track { position: absolute; inset: auto 0 0; height: 2px; background: #ffdab27a }
.map-track i { display: block; width: var(--distance); height: 100%; background: #ffd193 }
.map-bridge {
  position: absolute; left: var(--bridgeStart); right: var(--bridgeEnd); bottom: 1px; height: 5px;
  border: 1px solid #ffdab280; border-bottom: 0; border-radius: 5px 5px 0 0;
}
.map-stop {
  position: absolute; bottom: -1px; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: #aa7e68;
}
.map-stop.passed { background: #ffd193 }
.map-stop:last-child { width: 5px; height: 5px; border-radius: 1px; transform: translateX(-75%) rotate(45deg); }
.map-pin {
  position: absolute; z-index: 1; left: var(--distance); bottom: calc(-2px + 5px * var(--elevation));
  width: 6px; height: 6px; transform: translateX(-50%) rotate(45deg);
  border-radius: 1px; background: #fff0c4; box-shadow: 0 0 5px #ffb75a;
}
.counters { display: flex; align-items: center; gap: 1.25vw; justify-content: flex-end }
.counters strong { white-space: nowrap; color: #fff3cf; font-size: clamp(13px,2.9cqh,27px); font-variant-numeric: tabular-nums }
.counters strong:not(:first-child)::before { content: '◆'; color: #f4b952; margin-right: .35em; font-size: .69em }
.counters strong:last-child::before { content: 'SCORE'; color: #ffe0ac; letter-spacing: .09em; font-size: .46em }
#feathers { display: flex; gap: .32em; padding: .15em .12em }
.feather { display: inline-block; width: .46em; height: .83em; border-radius: 96% 12% 91% 18%; background: linear-gradient(110deg,#ffe2a3 49%,#ae5834 50%,#ed9e60 60%); transform: rotate(16deg); box-shadow: 0 0 4px #673a32 }
.feather.lost { opacity: .30; background: #e3b6ae }
.chase .meter i { background: #f79467 }
.chase.danger .meter i { background: #ff5148 }
.chase.danger strong { color: #ffad85 }
.run-alerts { position: absolute; top: 10.3%; right: 3.3%; display: grid; justify-items: end; gap: .28em; text-align: right; pointer-events: none }
#power { display: grid; gap: .28em; justify-items: end; color: #c0f8ff; font-size: clamp(10px,1.83cqh,17px); font-weight: 800 }
#power div, #toast, #cue { padding: .29em .50em; border-radius: 2px; border-right: 2px solid currentColor; background: #2a202be8 }
#toast { color: #ffdfae; font-size: clamp(11px,2.15cqh,20px); font-weight: 800 }
.bottom { position: absolute; bottom: 5.3%; left: 3.3%; right: 3.3%; display: flex; align-items: end; justify-content: space-between; gap: 1vw; pointer-events: none }
#mission,#hint { color: #ffecd1; font-size: clamp(8px,1.55cqh,15px); font-weight: 700; text-shadow: 0 1px 4px #201320,0 0 10px #201320 }
#mission { color: #ffc486 }
#hint { margin-right: 5vw; text-align: right }
#hint span { margin: 0 .5em }
#preview { display: grid; place-items: center; text-align: center; width: min(44%, 465px); pointer-events: auto }
#warning { color: #fff0ca; margin: 0 0 .44em; font-size: clamp(10px,1.95cqh,18px); font-weight: 850; text-shadow: 0 2px 2px #211421,0 0 10px #211421,0 0 18px #211421 }
.routes { display: flex; width: 100%; gap: .55em }
.routes button { display: flex; align-items: center; gap: .58em; min-width: 0; flex: 1; padding: .33em .42em; text-align: left; border-radius: 3px; border: 1px solid #d4ad7b95; background: #2b2029ed; font-size: clamp(10px,2.05cqh,19px) }
.routes button.active { background: #624034eb; border-color: #ffcc84 }
.routes button.watched { box-shadow: inset 0 0 0 1px #fc9d60 }
.routes button span { display: grid; gap: .1em; min-width: 0 }
.routes small { color: #ead0b5; font-size: .63em; line-height: 1.15 }
.results { display: flex; align-items: baseline; gap: .7em; font-weight: 800; color: #ffc486 }
.results strong { font: 700 clamp(26px,6.2cqh,56px)/1 Georgia,serif; color: #fff0c5 }
.results span { font-size: clamp(8px,1.5cqh,15px); letter-spacing: .17em }
.resultstats { font-size: clamp(10px,1.85cqh,18px); color: #ffdfba; margin: .45em 0 }
#restart { margin-top: 2.4cqh }
#failure { position: absolute; top: 5%; left: 5%; background: #35232f; padding: 1.2em }
.touch { display: none }
@media (pointer: coarse) {
  .touch { display: flex; gap: .65em; position: absolute; left: 3%; bottom: 12%; right: 3%; }
  .touch button { width: 2.6em; height: 2.4em; background: #302332b9; border: 1px solid #f3bd8273; border-radius: 4px }
  .touch button:nth-child(3) { margin-left: auto }
  #hint { display: none }
  #preview { width: 67% }
}
@media (max-aspect-ratio: 1/1) {
  .panel { top: 6%; left: 6%; width: 88%; transform: none }
  h1, h2 { font-size: min(16vw, 10.5cqh) }
  #game[data-mode="title"] .finish,
  #game[data-mode="escaped"] .finish,
  #game[data-mode="caught"] .finish {
    background: linear-gradient(180deg,#211721ed 0%,#241923a6 25%,#24192338 45%,transparent 64%),
      radial-gradient(ellipse at 58% 59%, transparent 48%, #21162177 100%);
  }
  .result { top: 4.3%; width: 88% }
  .result .eyebrow { margin-bottom: .92cqh }
  .result h2 { font-size: min(13.2vw, 8.2cqh) }
  .result .premise { max-width: 37ch; margin: 1.35cqh 0; font-size: clamp(13px, 1.95cqh, 19px) }
  .result .results strong { font-size: clamp(27px, 5.1cqh, 48px) }
  .result .resultstats { margin: .3em 0; font-size: clamp(11px, 1.58cqh, 15px) }
  .result #restart { margin-top: 1.26cqh; font-size: clamp(12px, 1.92cqh, 17px) }
}
#cue {
  display: flex; align-items: center; justify-content: flex-end;
  gap: .48em; color: #ffead0; font-size: clamp(9px, 1.83cqh, 17px); font-weight: 750;
}
#cue kbd { color: #ffd08c }
#game[data-mode="playing"].pressed-by-farmer .finish {
  background: radial-gradient(ellipse at 58% 45%, transparent 47%, #9c201b68 100%);
}
#game[data-mode="playing"].boosting .finish::after {
  content: ''; position: absolute; inset: 0; opacity: .5;
  background: repeating-conic-gradient(from 9deg at 54% 42%, transparent 0 11deg, #ffdb9d2b 11.15deg 11.38deg, transparent 11.5deg 19deg);
  mask-image: radial-gradient(ellipse at 54% 42%, transparent 48%, #000 94%);
}
#game[data-mode="playing"] .finish {
  box-shadow: inset 0 86px 56px -70px #221624cf;
}
#game[data-mode="playing"] .sound { bottom: 1.7% }
.routes small { font-size: .70em }
#actCard {
  position: absolute; inset: 0; left: -.32em; padding-left: .32em; pointer-events: none;
  border-left: 2px solid #ffba70;
  background: linear-gradient(90deg,#3d2530e0,#412d3100);
}
.crossing-act #act { visibility: hidden }
#actCard strong { color: #ffdfa1 }
#propCue {
  position: absolute; right: 3.3%; bottom: 16%; display: flex; align-items: center; gap: .7em;
  padding: .42em .63em; background: #33252cf0; border-left: 2px solid #f2b571; border-radius: 2px;
  color: #ffedcc; font-size: clamp(9px, 1.85cqh, 18px); pointer-events: none;
}
#propCue span { display: grid; gap: .12em }
#propCue small { color: #ffe0ab; font-size: .76em }
@media (pointer: coarse) {
  #propCue { bottom: 23% }
}
@media (max-aspect-ratio: 1/1) {
  .hudbar { grid-template-columns: 1.06fr 1fr; gap: .62em 1em; align-items: center }
  .identity strong { font-size: clamp(17px, 5.8vw, 31px) }
  .meters { grid-area: 2 / 1 }
  .chase { grid-area: 2 / 2 }
  .counters { grid-area: 1 / 2; gap: .46em }
  .counters strong { font-size: clamp(13px, 4.7vw, 21px) }
  .counters strong:last-child::before { font-size: .43em; margin-right: .2em }
  .metertext { gap: .25em; font-size: clamp(10px, 3.25vw, 16px) }
  .metertext span { font-size: clamp(8px, 2.2vw, 11px); letter-spacing: .07em }
  .run-alerts { top: 12.1%; max-width: 57% }
  #cue, #power { font-size: clamp(10px, 3.05vw, 15px) }
  #toast { font-size: clamp(11px, 3.25vw, 16px) }
  #propCue { font-size: clamp(10px, 3vw, 14px); max-width: 65% }
}
@media (prefers-reduced-motion: reduce) {
  #game[data-mode="playing"].boosting .finish::after { display: none }
}
