.game-shell[data-view="map"] {
  width: 100%;
  padding-inline: 0;
  background: #4c6650;
}
.game-shell[data-view="map"] .landscape { display: none; }

.adventure-map {
  --map-control-height: 44px;
  --map-pad: clamp(10px, 3.5vw, 24px);
  --map-cream: #fff2ce;
  display: flex;
  isolation: isolate;
  background: linear-gradient(180deg, #253c35a1, transparent 16%, transparent 75%, #2b453b6b),
    url("assets/adventure/valley/valley.webp") center 42% / cover no-repeat, #699475;
}

.adventure-map :where(button) {
  -webkit-tap-highlight-color: transparent;
  border: 0;
  background-color: transparent;
}
.adventure-map button:focus-visible {
  outline: 2px solid #fff1ae;
  outline-offset: 3px;
}
.adventure-scroll:focus-visible { outline: 2px solid #fff5d0; outline-offset: -3px; }

.adventure-controls {
  position: absolute;
  z-index: 3;
  inset: var(--top) 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: min(100%, 42rem);
  container-type: inline-size;
  margin-inline: auto;
  padding-inline: max(var(--map-pad), var(--safe-left)) max(var(--map-pad), var(--safe-right));
  pointer-events: none;
}
.adventure-resources {
  display: flex;
  align-items: center;
  gap: clamp(5px, 2vw, 10px);
  font-variant-numeric: tabular-nums;
}
.adventure-controls button,
.adventure-map .adventure-return {
  min-height: var(--map-control-height);
  color: var(--map-cream);
  pointer-events: auto;
}
.adventure-back {
  display: grid;
  place-items: center;
  width: clamp(44px, 12.2vw, 53px);
  aspect-ratio: 1;
  padding: 0;
  border-radius: 36%;
  background: url("assets/adventure/valley/map-back-control.webp") center / contain no-repeat;
  filter: drop-shadow(0 2px 4px #25312673);
}
.adventure-back .icon {
  width: 20px;
  height: 20px;
  translate: -1px 2px;
  filter: drop-shadow(0 1px 1px #493e28);
}
.adventure-controls button:active { translate: 0 1px; }

.adventure-energy {
  --resource-width: clamp(90px, 27cqi, 140px);
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 5px 12px;
}
.adventure-energy .resource {
  gap: clamp(3px, 1.15cqi, 7px);
  padding-inline: clamp(4px, 1.5cqi, 9px);
}
.adventure-energy .resource img {
  width: clamp(15px, 4.65cqi, 24px);
  height: auto;
}
.adventure-energy-add {
  display: grid;
  place-items: center;
  flex: none;
  width: clamp(13px, 3.5cqi, 16px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #eed7ad;
  color: #60442c;
  font: 850 clamp(11px, 3.7cqi, 15px)/1 system-ui, sans-serif;
  text-shadow: none;
}
.adventure-chest {
  display: grid;
  justify-items: center;
  min-width: 45px;
  padding: 0 0 2px;
  border-radius: 9px;
}
.adventure-chest-art {
  display: block;
  width: clamp(36px, 10.3cqi, 50px);
  height: clamp(34px, 10cqi, 48px);
  object-fit: contain;
  filter: drop-shadow(0 2px 2px #1829189e);
}
.adventure-chest[data-ready="true"] .adventure-chest-art {
  filter: drop-shadow(0 1px 3px #412c20b8) drop-shadow(0 0 4px #dfb04e8f);
}
.adventure-chest-count {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: var(--text-label);
  line-height: 1;
  text-shadow: var(--hero-text-shadow);
}
.adventure-chest-count img { width: 13px; flex: none; }

.adventure-scroll {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden auto;
  overflow-anchor: none;
  overscroll-behavior-y: contain;
  scroll-padding-block: calc(var(--top) + var(--map-control-height) + 12px) calc(var(--bottom) + 51px);
  touch-action: pan-y;
}
.adventure-course {
  position: relative;
  isolation: isolate;
  container-type: inline-size;
  width: min(calc(100% - 2 * clamp(3px, 1.2vw, 8px)), clamp(18rem, 79dvh, 34rem));
  margin-inline: auto;
  overflow: clip;
}
.adventure-tiles { position: absolute; z-index: 0; inset: 0; isolation: isolate; }
.adventure-tile {
  position: absolute;
  inset-inline: 0;
  height: var(--adventure-tile-height);
  contain: layout style;
  pointer-events: none;
}
.adventure-terrain-art {
  position: absolute;
  inset: 0;
  background: url("assets/adventure/valley/terrain-preview.webp") var(--season-preview-x, 0%) center / 400% 100% no-repeat;
}
.adventure-terrain-boundary {
  mask-image: linear-gradient(to bottom, transparent var(--adventure-gate-cover), #000 calc(var(--adventure-gate-cover) + 6%));
}
.adventure-terrain-start {
  mask-image: linear-gradient(#000 0 76%, transparent 84%);
}
.adventure-terrain-art[data-season="1"] { --season-preview-x: 33.3333%; }
.adventure-terrain-art[data-season="2"] { --season-preview-x: 66.6667%; }
.adventure-terrain-art[data-season="3"] { --season-preview-x: 100%; }
.adventure-terrain-art[data-detail="true"] { background-size: 100% 100%; background-position: center; }
.adventure-starter {
  position: absolute;
  z-index: 1;
  inset-inline: 0;
  width: 100%;
  height: var(--adventure-starter-height);
  object-fit: contain;
  pointer-events: none;
}

.adventure-node {
  position: absolute;
  z-index: 2;
  isolation: isolate;
  left: var(--node-x);
  top: var(--node-y);
  display: grid;
  justify-items: center;
  align-content: end;
  width: 19.5%;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  transform: translate(-50%, -100%);
  border-radius: 11px;
  color: var(--map-cream);
  pointer-events: auto;
  touch-action: pan-y;
}
.adventure-node[data-state="current"] { width: 22.5%; z-index: 3; }
.adventure-node-art {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 320 / 181;
  transform-origin: 50% 96%;
}
.adventure-node[data-state="current"] .adventure-node-art {
  aspect-ratio: 320 / 257;
}
.adventure-hole {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 2px 3px #3d321956);
}
.adventure-node-art > .icon {
  position: absolute;
  inset: 43% auto auto 50%;
  width: clamp(12px, 4.2cqw, 21px);
  height: auto;
  aspect-ratio: 1;
  translate: -50% -50%;
  color: #5c5344;
  stroke-width: 2;
}
.adventure-node-number {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 2.3em;
  min-height: 20px;
  margin-top: -3px;
  padding: 1px 6px 2px;
  border: 1px solid #a9976a;
  border-top-color: #f2dba1;
  border-radius: 6px 9px;
  background: linear-gradient(150deg, #60684a, #354736);
  box-shadow: 0 2px 3px #2b351d60;
  color: inherit;
  font-size: clamp(11px, 3.5cqw, 17px);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  line-height: 1.18;
  white-space: nowrap;
}
.adventure-node[data-state="locked"] .adventure-node-number {
  color: #fff2d8;
  border-color: #b7b197;
  background: linear-gradient(142deg, #716f5d, #4e5145);
}
.adventure-node[data-state="current"] .adventure-node-number {
  min-height: 22px;
  border-color: #eec675;
  border-top-color: #fff4cd;
  background: linear-gradient(154deg, #fff0c1, #e3b877);
  box-shadow: inset 0 0 0 1px #fff4cd70, 0 2px 5px #623a166b;
  color: #553c27;
}
.adventure-node-stars {
  position: absolute;
  inset: auto 0 22%;
  display: flex;
  justify-content: center;
  gap: 1%;
  pointer-events: none;
}
.adventure-node-stars img { width: 20%; max-width: 19px; object-fit: contain; }
.adventure-node-stars .unearned { opacity: .39; filter: grayscale(1) brightness(.65); }
.adventure-node:active .adventure-node-art { transform: translateY(2px) scale(1.02, .94); }

.adventure-gate {
  position: absolute;
  z-index: 1;
  left: 4%;
  width: 92%;
  padding: 0;
  border-radius: 14px;
  pointer-events: auto;
  touch-action: pan-y;
}
.adventure-gate-motion { position: relative; display: block; transform-origin: 50% 88%; }
.adventure-hedge {
  display: block;
  width: 100%;
  aspect-ratio: 920 / 229;
  object-fit: contain;
  filter: drop-shadow(0 4px 4px #43512c77);
}
.adventure-gate[data-season="2"] .adventure-hedge { filter: sepia(.22) drop-shadow(0 4px 4px #64441c77); }
.adventure-gate[data-season="3"] .adventure-hedge { filter: saturate(.62) drop-shadow(0 4px 4px #43594777); }
.adventure-gate-lock {
  position: absolute;
  bottom: 10%;
  left: 50%;
  display: grid;
  place-items: center;
  width: clamp(20px, 6cqw, 32px);
  aspect-ratio: 1;
  translate: -50% 0;
  border: 1px solid #ffe9ad;
  border-radius: 8px;
  background: #4b3c26de;
  box-shadow: 0 2px 4px #4d392b87;
  color: var(--map-cream);
}
.adventure-gate-lock .icon { width: 62%; height: 62%; }
.adventure-gate:active .adventure-gate-motion { transform: rotate(-1.5deg); }

.adventure-map .adventure-return {
  position: absolute;
  z-index: 3;
  inset: auto auto var(--bottom) 50%;
  display: grid;
  place-items: center;
  width: clamp(146px, 43vw, 196px);
  min-height: 48px;
  max-width: calc(100% - 2 * var(--map-pad));
  padding: 7px 14px 0 37px;
  transform: translateX(-50%);
  border-radius: 20px;
  background: url("assets/adventure/valley/map-return-control.webp") center / 100% 100% no-repeat;
  filter: drop-shadow(0 2px 4px #28352373);
  text-shadow: var(--hero-text-shadow);
  font-size: var(--text-label);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.adventure-return:active { translate: 0 1px; }
@media (prefers-reduced-motion: reduce) {
  .adventure-node:active .adventure-node-art,
  .adventure-gate:active .adventure-gate-motion { transform: none; opacity: .82; }
}

.game-dialog.adventure-dialog {
  --adventure-paper: #fff8e7;
  --adventure-ink: #503a29;
  --adventure-muted: #72573c;
  --adventure-line: #d7ba876f;
  --adventure-surface: linear-gradient(145deg, #fff9ee, #eee1c7);
  --dialog-width: 28rem;
  padding: clamp(8px, 2.8vw, 14px);
  border: 1px solid #bb9968;
  border-top-color: #fff5de;
  border-radius: 12px 26px 12px 26px;
  background: radial-gradient(ellipse at 25% -15%, #fffdf4 3%, transparent 61%),
    linear-gradient(152deg, #fbf2dd, #ecdcbe);
  box-shadow: inset 0 0 0 2px #fff9e4b0, 0 4px 0 #796142, 0 15px 35px #132a2487;
  color: var(--adventure-ink);
}
.adventure-dialog::backdrop { background: #21332aa6; }
.adventure-dialog .dialog-body { padding: 0 1px 3px; color: var(--adventure-ink); }
.adventure-dialog .dialog-scroll { scroll-padding-block: 5px; }
.adventure-dialog h2 {
  color: var(--adventure-ink);
  font: 700 clamp(19px, 5.4vw, 28px)/1.2 "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  letter-spacing: .05em;
}
.game-dialog.adventure-dialog[open] .dialog-close {
  inset: 8px 8px auto auto;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid #c5a775;
  border-top-color: #fff4d7;
  border-radius: 8px 16px;
  background: linear-gradient(145deg, #fff7e7f2, #e6cfabec);
  color: #694a2e;
  box-shadow: inset 0 0 0 1px #fff8e29c, 0 2px 4px #2a281d40;
  animation: none;
}
.adventure-dialog .dialog-close .collection-close-icon { display: grid; place-items: center; }
.adventure-dialog .dialog-close .icon { width: 19px; height: 19px; }
.adventure-dialog :is(button, summary):focus-visible,
.adventure-dialog .energy-potion input:focus-visible + .energy-potion-card {
  outline: 2px solid #906c40;
  outline-offset: 2px;
}
.adventure-dialog :is(.dialog-actions, .chest-tier) .game-button {
  border: 1px solid #87744c;
  border-top-color: #d9bd82;
  border-radius: 7px 15px;
  background: radial-gradient(ellipse at 48% 0%, #ead7a32e, transparent 71%),
    linear-gradient(147deg, #596a47, #344b38);
  color: var(--adventure-paper);
  box-shadow: inset 0 0 0 1px #f6dc9b3d, 0 2px 4px #61482c37;
  font-weight: 850;
  text-shadow: 0 1px 2px #25382c;
}
.adventure-dialog .dialog-actions .game-button-alt {
  border-color: #c7a77e;
  border-top-color: #fffaf0;
  background: var(--adventure-surface);
  color: var(--adventure-ink);
  text-shadow: none;
}

.adventure-dialog.energy-dialog .dialog-emblem {
  width: clamp(45px, 13vw, 65px);
  border: 0;
  border-radius: 0;
  background: none;
}
.adventure-dialog .energy-summary {
  border-color: #b1a075;
  border-top-color: #d1bc86;
  border-radius: 8px 15px;
  background: linear-gradient(135deg, #606448, #344d3b 87%);
  box-shadow: inset 0 0 0 1px #e4cf923b;
}
.adventure-dialog .energy-summary progress,
.adventure-dialog .energy-summary progress::-webkit-progress-bar { background: #1e392ca8; }
.adventure-dialog .energy-summary progress::-webkit-progress-value {
  background: linear-gradient(90deg, #baa469, #ebd493);
}
.adventure-dialog .energy-summary progress::-moz-progress-bar {
  background: linear-gradient(90deg, #baa469, #ebd493);
}
.adventure-dialog :is(.energy-potion-card, .energy-empty, .energy-confirm dl > div) {
  border-radius: 8px 15px;
  background: var(--adventure-surface);
}
.adventure-dialog .energy-potion-card { border-color: var(--adventure-line); border-top-color: #fff9ea; }
.adventure-dialog .energy-potion input:checked + .energy-potion-card { border-color: #a2a276; background: #edf0d9; }
.adventure-dialog :is(.energy-potion-copy strong, .energy-potions-heading h3) { color: var(--adventure-ink); }
.adventure-dialog .energy-rules summary { padding-block: 6px 1px; }

.adventure-dialog .dialog-emblem:has(.adventure-gate-emblem) {
  width: min(100%, 18rem);
  height: auto;
  margin: 5px auto 4px;
  border: 0;
  border-radius: 0;
  background: none;
}
.adventure-gate-emblem { display: block; width: 100%; height: auto; }
.adventure-gate-message { text-align: center; }
.adventure-gate-message small { color: var(--adventure-muted); }
