.treasure-game {
  --ink: #27584b;
  --soft: #e0edce;
  background: #f4f2e7;
  color: #234d41;
}
.treasure-game main { max-width: 1250px; margin: auto; padding: 18px 22px 30px; }
.treasure-game .game-top { gap: 12px; align-items: center; }
.treasure-game .game-top h1 { font-size: clamp(25px, 3vw, 34px); margin: 3px 0 8px; }
.treasure-game .game-layout { display: block; }
.treasure-game .stage { padding: 0; border: 0; background: transparent; box-shadow: none; overflow: visible; }
.treasure-game .score-strip { margin-bottom: 14px; font-size: 16px; background: #e5ebd9; border: 1px solid #cedcc2; }
.treasure-game .helper-panel { margin: 18px 0 0; padding: 16px 20px; text-align: left; background: #fffdf5; border: 1px solid #d9dfc8; }
.treasure-game .helper-monkey, .treasure-game #helper-name, .treasure-game .learning-note, .treasure-game #feedback:not(.good) { display: none; }
.treasure-game #instruction { margin: 0 0 8px; line-height: 1.5; }
.treasure-game #task-info { display: flex; flex-wrap: wrap; gap: 7px; }
.treasure-game .keyboard-tip { font-size: 16px; line-height: 1.5; }
.treasure-game .lobby-art { border-radius: 30px; overflow: hidden; background: #265c50; }
.treasure-game .lobby-art #scene { object-fit: cover; width: 100%; height: 100%; min-height: 350px; }
.treasure-game .lobby-monkey { filter: drop-shadow(0 8px 6px #173d4044); }
.treasure-game .game-buttons button, .treasure-game .header button { min-height: 44px; }

.trail-world-picker { border: 0; padding: 0; margin: 16px 0 18px; }
.trail-world-picker legend { font-weight: 800; margin-bottom: 7px; }
.trail-world-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.trail-world-choice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border: 2px solid #becab3;
  border-radius: 13px;
  padding: 9px;
  min-height: 60px;
  background: #fffdf3;
  color: #27483e;
  cursor: pointer;
}
.trail-world-choice:has(input:checked) { border-color: #3b7555; background: #e2eed1; box-shadow: inset 0 0 0 1px #3b7555; }
.trail-world-choice:focus-within { outline: 3px solid #155c86; outline-offset: 2px; }
.trail-world-choice input { flex: none; width: 17px; height: 17px; accent-color: #326c51; margin: 3px 0 0; }
.trail-world-choice b, .trail-world-choice small { display: block; line-height: 1.3; }
.trail-world-choice small { font-size: .88rem; font-weight: 600; color: #475c50; margin-top: 3px; }

.trail-expedition { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(310px, 1fr); gap: 19px; align-items: start; text-align: left; }
.trail-expedition * { box-sizing: border-box; }
.trail-expedition button {
  font: inherit;
  font-size: 1rem;
  line-height: 1.15;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  border: 2px solid #cad7c0;
  border-radius: 11px;
  min-height: 44px;
  padding: 8px 10px;
  background: #fffef5;
  color: #23493f;
  box-shadow: 0 2px 0 #bac8b0;
}
.trail-expedition button:hover:enabled { background: #f5edcf; }
.trail-expedition button:focus-visible { outline: 3px solid #155e8b; outline-offset: 2px; }
.trail-expedition button:disabled, .trail-expedition button[aria-disabled="true"] { opacity: .55; cursor: default; box-shadow: none; }

.trail-landscape {
  --sky-top: #abdba2;
  --sky-bottom: #3d8168;
  --world-rim: #214f47;
  --tile-light: #e1e9a1;
  --tile-dark: #a4c278;
  --tile-stroke: #eaf4ba;
  --tile-edge: #55754c;
  --tile-line: #426949;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 3px solid var(--world-rim);
  border-radius: 24px;
  background: linear-gradient(155deg, var(--sky-top), var(--sky-bottom));
  box-shadow: 0 6px 0 var(--world-rim), 0 12px 28px #2c5c4022;
}
.trail-world--temple {
  --sky-top: #f4d9a6; --sky-bottom: #a87866; --world-rim: #61434b;
  --tile-light: #fae6b7; --tile-dark: #d4ac7b; --tile-stroke: #fff1c7; --tile-edge: #9d725b; --tile-line: #694c44;
}
.trail-world--canopy {
  --sky-top: #c9e9d7; --sky-bottom: #529387; --world-rim: #335952;
  --tile-light: #f5d69d; --tile-dark: #c89e64; --tile-stroke: #fbe6b2; --tile-edge: #916547; --tile-line: #67472e;
}
.trail-location {
  position: relative;
  z-index: 2;
  margin: 15px 17px 0;
  padding: 10px 13px;
  border: 1px solid #fff4cd60;
  border-radius: 14px;
  background: #172f29ef;
  color: #fffbe8;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 12px;
}
.trail-mission { grid-column: 1 / -1; font-size: .77rem; letter-spacing: .11em; font-weight: 900; color: #f8e29e; }
.trail-location b { font-size: clamp(1.23rem, 2.4vw, 1.85rem); line-height: 1.12; }
.trail-live-command { color: #fff1af; font-weight: 800; font-size: .92rem; text-align: right; }
.trail-map { display: block; position: relative; width: min(100%, clamp(365px, 100svh - 400px, 510px)); height: auto; margin: -11px auto -13px; z-index: 1; }
.trail-grid-bed { fill: #183d32; opacity: .76; }
.trail-tile-grain { pointer-events: none; }
.trail-world--canopy .trail-tile-grain { opacity: .36; stroke-width: 2; }
.trail-camp-mark { font-size: 15px; font-weight: 900; fill: var(--tile-line); }
.trail-boost text { font-size: 49px; font-weight: 900; fill: #265b5b; }
.trail-vine-tile text { fill: #23553a; }
.trail-canopy { position: absolute; width: 108%; height: 100%; inset: 0 -4%; pointer-events: none; z-index: -1; }
.trail-canopy-far { opacity: .82; animation: trail-parallax-far 17s ease-in-out infinite alternate; }
.trail-canopy-near { opacity: .95; animation: trail-parallax-near 10s ease-in-out infinite alternate; }
.trail-map-footer {
  position: relative;
  margin: 0 17px 7px;
  padding: 6px 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: #203e35f2;
  color: #fff8df;
  border-radius: 10px;
  font-weight: 800;
  font-size: .95rem;
}
.trail-banana-count { display: inline-flex; align-items: center; gap: 4px; font-size: 1.19rem; white-space: nowrap; }
.trail-banana-count svg { width: 26px; height: 26px; }
.trail-message {
  position: relative;
  z-index: 2;
  padding: 9px 11px;
  margin: 6px 17px 0;
  min-height: 43px;
  background: #fff6d7;
  color: #2d473b;
  border-radius: 10px;
  font-size: 1rem;
  line-height: 1.35;
  font-weight: 650;
  border-inline-start: 4px solid #d6ae4e;
}
.trail-message.trail-needs-fix { background: #ffedd6; color: #6b3227; border-inline-start-color: #a34436; }
.trail-map-key { margin: 0 17px 13px; color: #fff9df; background: #1e3e36f2; border-radius: 10px; padding: 6px 11px; line-height: 1.45; }
.trail-map-key summary { display: list-item; padding: 4px 0; font-weight: 800; cursor: pointer; }
.trail-map-key p { margin: 7px 0; font-size: 1rem; }
.trail-board-controls { display: none; }

#trail-position { transition: transform var(--trail-step-time, 0ms) cubic-bezier(.26,.78,.35,1); }
.trail-pose { transform-box: fill-box; transform-origin: 50% 72%; animation: trail-breathe 3.2s ease-in-out infinite; }
.trail-pose.trail-ready { animation: trail-ready .22s ease both; }
.trail-pose.trail-swing { animation: trail-swing var(--trail-step-time, 320ms) ease-in-out both; }
.trail-pose.trail-flip { animation: trail-backflip .42s cubic-bezier(.4,0,.3,1) both; }
.trail-pose.trail-shrug { animation: trail-shrug .58s ease-in-out 2; }
.trail-pose.trail-cheer { animation: trail-cheer .47s ease-in-out infinite alternate; }
.trail-pose.trail-gust { animation: trail-gust var(--trail-step-time, 320ms) ease both; }
.trail-vine-drawing { stroke-dasharray: 170; animation: trail-draw .35s ease-out both; }
.trail-fruit { transform-box: fill-box; transform-origin: center; animation: trail-fruit-bob 2.9s ease-in-out infinite; }
.trail-tile:nth-of-type(3n) .trail-fruit { animation-delay: -1.2s; }
.trail-fruit-ring { fill: #ffea9d; stroke: #8e5d18; stroke-width: 4; opacity: 0; }
.trail-fruit-needed .trail-fruit-ring { opacity: 1; }
.trail-collected { visibility: hidden; }
.trail-chest-spark { transform-box: fill-box; transform-origin: center; animation: trail-spark 2.5s ease-in-out infinite; }
.trail-chest-needed { filter: drop-shadow(0 0 8px #fff49c) drop-shadow(0 0 4px #ab6620); }
#trail-target circle { fill: #d57450; fill-opacity: .27; stroke: #a63d31; stroke-width: 7; stroke-dasharray: 8 6; }
#trail-target path { fill: none; stroke: #762b23; stroke-width: 7; stroke-linecap: round; paint-order: stroke; }
#trail-burst { transform-origin: center; animation: trail-celebrate 1.1s ease-out infinite; }

.trail-workbench { padding: 17px; background: #fffdf3; border: 2px solid #dcdcc8; box-shadow: 0 5px 0 #e0dbc1; border-radius: 22px; min-width: 0; }
.trail-workbench-head .trail-eyebrow { font-size: .81rem; letter-spacing: .12em; color: #486b52; font-weight: 900; }
.trail-workbench h2 { font-size: clamp(1.35rem, 2.4vw, 1.9rem); line-height: 1.12; margin: 4px 0 6px; color: #285746; }
.trail-workbench-head p { margin: 0 0 14px; color: #465b50; font-size: 1rem; }
.trail-program-head { display: flex; justify-content: space-between; gap: 7px; align-items: center; margin-bottom: 6px; font-size: .88rem; letter-spacing: .06em; }
.trail-program-head span { font-weight: 900; letter-spacing: 0; color: #73501d; }
#trail-queue { max-height: 238px; overflow: auto; overscroll-behavior: contain; border-radius: 12px; }
.trail-list { display: flex; flex-wrap: wrap; gap: 7px; min-height: 63px; align-items: flex-start; padding: 8px; background: #f0eedf; border: 2px dashed #c9c6ae; border-radius: 12px; }
.trail-list-target { border-color: #437c5f; background: #ebf0da; }
.trail-drop-over { outline: 3px solid #427c66; outline-offset: -3px; }
.trail-empty { color: #4f5949; font-size: 1rem; line-height: 1.35; margin: 4px; pointer-events: none; }
.trail-node { position: relative; max-width: 100%; border: 2px solid #aac3af; background: #e3eee4; box-shadow: 0 2px 0 #afc2ab; border-radius: 9px; }
.trail-node-line { display: flex; flex-wrap: wrap; align-items: stretch; }
.trail-node button { box-shadow: none; border: 0; background: transparent; min-height: 44px; }
.trail-node .trail-code { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; padding: 6px 8px; }
.trail-code small { background: #f8fbefc0; border-radius: 12px; padding: 2px 5px; color: #365d46; font-size: .8rem; }
.trail-code b { font-size: 1.63rem; line-height: 1; }
.trail-code span { font-size: .91rem; text-transform: capitalize; }
.trail-code[aria-pressed=true] { background: #d1e6c7; }
.trail-node .trail-remove { font-size: 1.3rem; min-width: 40px; padding: 4px 8px; border-inline-start: 1px solid #a8bbac; }
.trail-node.selected { border-color: #236583; box-shadow: 0 0 0 2px #9bd1e5; }
.trail-node.executing { border-color: #8a5b10; background: #ffe596; box-shadow: 0 0 0 2px #fae0a3; }
.trail-node.executing .trail-code small::before { content: '▶ '; }
.trail-node.executing .trail-code:disabled { opacity: 1; }
.trail-node.trail-error { border-color: #aa4635; background: #ffdec6; box-shadow: 0 0 0 2px #e9ac8f; }
.trail-node.trail-error .trail-code small::before { content: '× '; }
.trail-repeat { width: 100%; background: #e9e1f3; border-color: #b7a6cb; }
.trail-repeat .trail-code { flex: 1; justify-content: flex-start; }
.trail-repeat.trail-loop-active { border-color: #766199; }
.trail-pass { align-self: center; font-size: .83rem; color: #432c66; background: #fcf6ff; font-weight: 850; padding: 4px 6px; border-radius: 6px; }
.trail-pass[hidden] { display: none; }
.trail-node .trail-count { color: #4c386c; background: #f4edff; min-width: 42px; }
.trail-repeat-body { border-inline-start: 4px solid #9885b1; margin: 0 7px 8px 8px; padding-inline-start: 5px; }
.trail-repeat-body .trail-list { background: #f6f0fb; min-height: 38px; padding: 5px; }
.trail-repeat-body .trail-add-inside { color: #503872; margin-top: 3px; font-size: .95rem; }
.trail-repeat-body .trail-add-inside[aria-pressed=true] { background: #e0d1f5; }
.trail-edit-bar, .trail-small-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.trail-edit-bar button, .trail-small-tools button { font-size: .9rem; padding: 6px 8px; }
.trail-edit-bar [aria-pressed=true] { background: #e5edce; }
.trail-edit-tip { font-size: .97rem; line-height: 1.3; color: #465a4b; margin: 9px 0; }
.trail-palette { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.trail-palette button { display: grid; justify-items: center; gap: 2px; background: #e0ebcd; border-color: #a8c19d; min-height: 64px; padding: 5px; }
.trail-palette b { font-size: 1.95rem; line-height: 1; }
.trail-palette span { font-size: .91rem; text-transform: capitalize; }
.trail-expedition .trail-loop-tool { display: flex; align-items: center; gap: 7px; width: 100%; margin-top: 8px; background: #eee7f9; border-color: #c5b2dc; }
.trail-loop-tool b { font-size: 1.4rem; }
.trail-loop-tool small { font-size: .82rem; font-weight: 650; margin-inline-start: auto; }
.trail-run-tools { display: grid; grid-template-columns: 1.25fr 1fr; gap: 7px; margin: 10px 0 3px; }
.trail-expedition .trail-go { background: #286950; border-color: #1d543f; color: #fffdf2; box-shadow: 0 2px 0 #1b483b; }
.trail-expedition .trail-go:hover:enabled { background: #347b5e; }

@keyframes trail-parallax-far { from { transform: translateX(-1%); } to { transform: translateX(2%); } }
@keyframes trail-parallax-near { from { transform: translateX(1%) rotate(.45deg); } to { transform: translateX(-1%) rotate(-.45deg); } }
@keyframes trail-breathe { 50% { transform: translateY(-2px) rotate(1deg); } }
@keyframes trail-ready { 50% { transform: scale(.94,1.04); } }
@keyframes trail-swing { 0%, 100% { transform: rotate(0); } 45% { transform: translateY(-19px) rotate(-15deg); } 75% { transform: translateY(-8px) rotate(7deg); } }
@keyframes trail-draw { from { stroke-dashoffset: 132; opacity: .48; } to { stroke-dashoffset: 0; opacity: 1; } }
@keyframes trail-backflip { 0% { transform: rotate(0); } 47% { transform: translateY(-26px) rotate(-175deg); } 100% { transform: rotate(-360deg); } }
@keyframes trail-shrug { 25% { transform: translateY(-7px) rotate(-9deg) scale(1.09,.95); } 65% { transform: translateY(-4px) rotate(9deg); } }
@keyframes trail-cheer { from { transform: rotate(-6deg); } to { transform: translateY(-14px) rotate(6deg); } }
@keyframes trail-gust { 35% { transform: rotate(16deg) translateY(-12px); } 76% { transform: rotate(-5deg); } }
@keyframes trail-fruit-bob { 50% { transform: translateY(-4px) rotate(5deg); } }
@keyframes trail-spark { 50% { opacity: .35; transform: scale(.7) rotate(60deg); } }
@keyframes trail-celebrate { from { opacity: 1; transform: scale(.7); } to { opacity: 0; transform: scale(1.13); } }
.reduce-motion .trail-expedition * { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  .trail-expedition * { animation: none !important; transition: none !important; }
}
@media (max-width: 820px) {
  .treasure-game main { padding-inline: 13px; }
  .trail-workbench { padding: 13px; }
  .trail-expedition { gap: 13px; }
  .trail-location { grid-template-columns: 1fr; }
  .trail-live-command { text-align: left; }
}
@media (max-width: 720px) {
  .trail-expedition { grid-template-columns: minmax(0, 1fr); gap: 17px; }
  .trail-landscape { width: min(100%, 520px); margin-inline: auto; }
  .trail-map { width: min(100%, 405px); }
  .trail-location { scroll-margin-top: 10px; }
  .trail-board-controls { display: grid; grid-template-columns: 1.25fr 1fr; gap: 7px; margin: 0 17px 10px; }
  .treasure-game .header, .treasure-game .header nav, .treasure-game .game-top { flex-wrap: wrap; }
  .treasure-game .score-strip { gap: 6px; }
}
@media (max-width: 360px) {
  .trail-world-choices { grid-template-columns: minmax(0, 1fr); }
  .trail-map-footer { align-items: flex-start; }
}

/* The route journal and the logic blocks share the map's paper-and-ink palette. */
.trail-expedition > .trail-journey { grid-column: 1 / -1; }
#trail-journey-lobby { margin: .85rem 0 1rem; }
.trail-journey {
  min-width: 0;
  padding: .65rem .8rem;
  color: #274d40;
  background: repeating-linear-gradient(165deg, transparent 0 25px, #a7b98a26 26px 27px), #f8f0d8;
  border: 1px solid #d3c49d;
  border-radius: 13px;
}
.trail-journey-title { display: flex; justify-content: space-between; gap: .35rem 1rem; flex-wrap: wrap; }
.trail-journey-title b { font-size: 1rem; }
.trail-journey-title span { font-size: .85rem; font-weight: 750; }
.trail-journey ol {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  list-style: none;
  gap: .2rem;
  margin: .55rem 0 0;
  padding: 0;
}
.trail-journey ol::before {
  content: '';
  position: absolute;
  top: 16px;
  inset-inline: 8%;
  border-top: 2px dashed #9e885d;
}
.trail-journey li { position: relative; display: grid; justify-items: center; gap: .12rem; text-align: center; }
.trail-journey li span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #aa986b;
  background: #fffaf0;
}
.trail-journey li b { font-size: .78rem; }
.trail-journey .is-current span { background: #ffe398; border: 2px solid #7a532b; }
.trail-journey .is-cleared span { background: #286950; color: #fff9e9; border-color: #1c5541; }
.trail-journey .is-locked span { background: #ded8c4; filter: grayscale(1); }
.trail-journal-tools { display: grid; gap: .45rem; margin-top: .5rem; }
.trail-journal-tools label { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; font-weight: 750; }
.trail-journal-tools select { min-height: 44px; max-width: 100%; }
.trail-journal-tools summary { width: fit-content; min-height: 44px; padding: .58rem .1rem; cursor: pointer; font-weight: 750; }
.trail-shortcuts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(145px, 100%), 1fr)); gap: .4rem; }
.trail-shortcuts button { padding: .45rem; color: #284e43; background: #f4efdb; }
.trail-shortcuts button:disabled { color: #4a574c; }
.trail-shortcuts small { display: block; font-size: .82rem; }
.trail-logic-palette { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .55rem; }
.trail-logic-palette button { flex: 1 1 105px; background: #eaf5e8; border-color: #9dc2a5; }
.trail-logic-palette button b { font-size: 1.08rem; }
.trail-if > .trail-node-line .trail-code { flex: 1; justify-content: flex-start; }
.trail-branch-arm { margin: .18rem 0 .32rem .35rem; padding: .34rem .4rem; border-left: 3px solid #afc0a7; background: #ecf4e8; border-radius: 7px; }
.trail-branch-arm > strong { display: block; font-size: .84rem; }
.trail-branch-arm.trail-branch-taken { border-color: #1a7258; background: #ccebd6; }
.trail-patrol { transition: transform 280ms ease-in-out; }
@media (max-width: 540px) {
  .trail-journey { padding-inline: .55rem; }
  .trail-journey li b { font-size: .72rem; }
  .trail-journey li span { width: 31px; height: 31px; }
}
.treasure-game #next.round-quick-next { bottom: calc(80px + env(safe-area-inset-bottom)) !important; }
