@charset "UTF-8";

/* Adventure V2 is an additive layer over the original warm town theme. */
.adventure-hero,
.adventure-entry,
.chapter-nav,
.adventure-progress,
.mission-map,
.mission-head,
.mission-layout,
.passport-strip,
.mission-footer {
  min-width: 0;
  --adventure-teal: #287e79;
  --adventure-ink: #24454d;
  --adventure-muted: #567073;
  --adventure-line: #d8e4da;
  --adventure-mint: #eaf4ee;
  --adventure-paper: #fffdf8;
  --adventure-orange: #f4b268;
  --adventure-peach: #fff0dd;
  --adventure-blue: #6086a6;
}

.adventure-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(190px, .85fr);
  gap: 24px;
  align-items: center;
  padding: 25px 30px;
  margin: 10px 0 22px;
  border: 1px solid #dfdfca;
  border-radius: 27px;
  background: #f4efe5;
  overflow: hidden;
}
.adventure-hero-copy { min-width: 0; }
.adventure-hero-copy > button { max-width: 100%; }
.adventure-hero h1 { margin: 7px 0 13px; font-size: clamp(27px, 4vw, 39px); line-height: 1.25; letter-spacing: -.035em; }
.adventure-hero p { max-width: 540px; margin: 0 0 12px; color: #567073; font-size: 16px; line-height: 1.75; }
.adventure-hero .eyebrow { margin-bottom: 0; font-size: 12px; color: #287e79; }
.adventure-hero-art { display: grid; place-items: center; min-width: 0; max-height: 180px; }
.adventure-hero-art img { width: 100%; max-height: 180px; object-fit: contain; }
.adventure-hero-art > svg { display: block; width: 100%; height: auto; max-height: 180px; }
.adventure-entry {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 23px 26px;
  margin: 20px 0;
  color: #24454d;
  text-align: left;
  text-decoration: none;
  border: 1px solid #b9d7c8;
  border-radius: 24px;
  background: linear-gradient(115deg, #e7f2e8 0%, #eef5e9 70%, #f8efd9 100%);
  box-shadow: 0 5px 0 #d6e4d6;
}
.adventure-entry h2 { margin: 3px 0 7px; font-size: clamp(21px, 3vw, 27px); }
.adventure-entry p { max-width: 660px; margin: 0; color: #48656a; font-size: 15px; line-height: 1.7; font-weight: 400; }
.adventure-entry .badge { margin-bottom: 5px; background: #fff8e7; color: #795c31; }
.adventure-entry > img { flex: 0 0 90px; width: 90px; height: 88px; object-fit: contain; }
.adventure-entry > span:last-child:not(.badge) { flex-shrink: 0; font-size: 27px; }
.adventure-title { margin: 25px 0 13px; font-size: 22px; line-height: 1.4; }
.chapter-description { margin: 0 0 19px; color: #567073; font-size: 15px; line-height: 1.7; }
.chapter-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; margin: 18px 0 15px; }
.chapter-tab { min-width: 0; min-height: 56px; padding: 12px 15px; color: #36565a; border: 1px solid #d5dfd6; border-radius: 16px; background: #fffdf8; font-size: 16px; line-height: 1.45; text-align: center; }
.chapter-tab[aria-pressed="true"] { color: #fffdf8; border-color: #287e79; background: #287e79; box-shadow: 0 3px 0 #1e625f; }
.chapter-tab small { display: block; margin-top: 3px; font-size: 12px; line-height: 1.4; font-weight: 400; opacity: .86; }
.adventure-progress { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 9px 16px; padding: 2px 1px; margin: 13px 0 19px; color: #567073; font-size: 14px; }
.adventure-progress strong { color: #24454d; font-size: 15px; }
.adventure-progress progress { flex: 1 1 120px; width: auto; height: 8px; min-width: 80px; max-width: 420px; overflow: hidden; border: none; border-radius: 8px; background: #e0e9dc; accent-color: #287e79; }
.adventure-progress progress::-webkit-progress-bar { background: #e0e9dc; border-radius: 8px; }
.adventure-progress progress::-webkit-progress-value { background: #287e79; border-radius: 8px; }
.adventure-progress progress::-moz-progress-bar { background: #287e79; border-radius: 8px; }
.adventure-progress .progress-track { flex: 1 1 120px; height: 8px; overflow: hidden; border-radius: 8px; background: #e0e9dc; }
.adventure-progress .progress-fill { height: 100%; border-radius: inherit; background: #287e79; transition: width .25s ease; }
.mission-map { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0 0 22px; }
.mission-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  min-height: 211px;
  padding: 20px;
  color: #24454d;
  text-align: left;
  text-decoration: none;
  border: 1px solid #d9e2d6;
  border-radius: 23px;
  background: #fffdf8;
  box-shadow: 0 5px 0 #e8e9dd;
  transition: transform .17s ease, box-shadow .17s ease, border-color .17s ease;
}
.mission-card.complete { border-color: #a7cdb9; background: #f1f8ef; box-shadow: 0 5px 0 #d8e7d6; }
.mission-card .mission-number { position: absolute; top: 17px; right: 17px; display: grid; place-items: center; min-width: 27px; height: 27px; padding: 0 5px; border: 1px solid #d7dfd5; border-radius: 50%; color: #5a7371; background: #fffdf8; font-size: 13px; line-height: 1; font-weight: 600; }
.mission-icon { display: grid; place-items: center; width: 55px; height: 55px; margin-bottom: 16px; color: #287e79; border-radius: 17px; background: #eaf4ee; font-size: 29px; line-height: 1; }
.mission-icon img, .mission-icon svg { width: 42px; height: 42px; object-fit: contain; }
.mission-card.bridge .mission-icon { color: #507896; background: #eaf0f5; }
.mission-card.route .mission-icon { color: #956d34; background: #fff0dd; }
.mission-card .mission-title { margin: 0 0 7px; font-size: 19px; line-height: 1.45; font-weight: 700; }
.mission-card .mission-summary { margin: 0 0 14px; color: #567073; font-size: 14px; line-height: 1.65; font-weight: 400; }
.mission-meta { display: flex; flex-wrap: wrap; gap: 5px 8px; margin-top: auto; color: #567073; font-size: 12px; line-height: 1.6; font-weight: 400; }
.mission-meta > span { padding: 3px 7px; border-radius: 7px; background: #f0f3e9; }
.mission-stamp { display: inline-flex; align-items: center; gap: 5px; margin-top: 10px; color: #287e79; font-size: 13px; line-height: 1.45; font-weight: 650; }
.mission-card.complete .mission-stamp::before { content: "✓"; display: grid; place-items: center; width: 20px; height: 20px; color: #fffdf8; border-radius: 50%; background: #287e79; font-size: 12px; }
.mission-card:disabled { opacity: .55; box-shadow: none; }

.passport-strip { display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 14px; padding: 16px 19px; margin: 20px 0; border: 1px solid #e2dbc7; border-radius: 20px; background: #f7f1e3; }
.passport-strip > p { flex-basis: 100%; margin: 0; text-align: center; color: #6b6b54; font-size: 14px; }
.progress-stamp { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 94px; min-height: 81px; padding: 10px 13px; color: #73816f; border: 2px dashed #c8cfba; border-radius: 16px; font-size: 13px; line-height: 1.4; text-align: center; background: #fbf8ee; }
.progress-stamp.complete, .progress-stamp.is-earned, .progress-stamp[data-earned="true"] { color: #287e79; border-style: solid; border-color: #84b49a; background: #e8f1df; }
.progress-stamp > span:first-child { font-size: 25px; line-height: 1.2; }

.mission-head { display: flex; align-items: center; gap: 15px; max-width: 1050px; margin: 12px auto 18px; }
.mission-head .back-btn { flex-shrink: 0; min-height: 46px; padding: 10px 13px; font-size: 16px; }
.mission-titleblock { flex: 1; min-width: 0; }
.mission-titleblock h1 { margin: 3px 0 0; font-size: clamp(25px, 3.7vw, 35px); line-height: 1.35; }
.mission-titleblock p { margin: 3px 0 0; color: #567073; font-size: 14px; line-height: 1.5; }
.mission-titleblock .eyebrow { margin-bottom: 0; font-size: 12px; }
.mission-counter { flex-shrink: 0; padding: 7px 11px; border: 1px solid #d5dfd3; border-radius: 12px; color: #567073; background: #fffdf8; font-size: 14px; line-height: 1.4; font-variant-numeric: tabular-nums; }
.mission-taskbar { max-width: 1050px; margin-left: auto; margin-right: auto; }
.mode-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; color: #287e79; border-radius: 7px; background: #e6f0e6; font-size: 12px; line-height: 1.4; }
.mission-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; align-items: start; gap: 25px; width: 100%; max-width: 1050px; margin: 0 auto; }
.mission-layout > .studio { width: 100%; min-width: 0; }
.mission-tools { display: flex; flex-direction: column; gap: 17px; min-width: 0; padding: 20px; border: 1px solid #d8e4da; border-radius: 23px; background: #fffdf8; box-shadow: 0 8px 26px rgb(36 69 77 / 5%); }
.mission-tools > h2, .mission-tools > h3 { margin: 0; font-size: 18px; }
.mission-canvas { position: relative; width: 100%; min-width: 0; max-width: 540px; margin: 0 auto; }
.mission-canvas .build-board { max-width: 540px; }
.mission-canvas .build-board .board-cell { min-height: 0; }
.terrain-layer { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.terrain-water { position: absolute; background: linear-gradient(180deg, #d8ebf0, #bcdce8); box-shadow: inset 0 3px 0 rgb(255 255 255 / 35%); }
.terrain-water::after { content: ""; position: absolute; inset: 8px 4px; opacity: .45; background: repeating-linear-gradient(0deg, transparent 0 21px, #92bccb 21px 23px, transparent 23px 28px); border-radius: 13%; }
.terrain-bank { position: absolute; background: #dce5c7; border-top: 4px solid #91ac7e; box-shadow: inset 0 -7px 0 rgb(133 155 109 / 12%); }
.terrain-pier { position: absolute; border: 2px solid #899c95; border-radius: 4px 4px 0 0; background: repeating-linear-gradient(0deg, #b6c2b8 0 20px, #a1afa5 20px 22px); box-shadow: inset 3px 0 0 rgb(255 255 255 / 21%); }
.deck-guide { position: absolute; z-index: 1; border: 2px dashed #b48b4c; border-radius: 5px; background: rgb(244 178 104 / 11%); pointer-events: none; }
.deck-guide > span { position: absolute; left: 5px; top: 4px; color: #7b6136; font-size: 12px; line-height: 1.3; }
.bridge-car { position: absolute; left: 0; z-index: 3; width: 25%; height: 16.25%; pointer-events: none; }
.bridge-car img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; filter: drop-shadow(0 2px 0 rgb(36 69 77 / 9%)); }
.bridge-car.bridge-drive { animation: cross-town-bridge 1.8s ease-in-out both; }
.bridge-boat { position: absolute; left: 38%; bottom: 2%; z-index: 1; display: grid; place-items: center; width: 24%; height: 27%; font-size: clamp(32px, 6vw, 65px); line-height: 1; pointer-events: none; }
.bridge-car.bridge-drive ~ .bridge-boat { animation: sail-under-bridge 2.1s ease-in-out both; }
@keyframes cross-town-bridge { from { left: 0; } to { left: 75%; } }
@keyframes sail-under-bridge { from { transform: translateX(-30%); } to { transform: translateX(30%); } }
.build-tool-tray { display: flex; flex-direction: column; gap: 13px; min-width: 0; }
.build-tool-tray .toolgroup { min-width: 0; }
.build-tool-tray .label { margin: 0 0 8px; color: #567073; font-size: 14px; line-height: 1.45; }
.build-tool-tray .pieces { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.build-tool-tray .piece-choice { min-height: 71px; padding: 10px 7px; font-size: 16px; }
.build-tool-tray .colors { gap: 9px; }
.build-tool-tray .toolbar { gap: 7px; }
.build-tool-tray .selection-label { margin: 0; font-size: 13px; }
.goal-list { display: flex; flex-direction: column; gap: 8px; padding: 0; margin: 0; list-style: none; }
.goal-item { display: flex; align-items: flex-start; gap: 9px; padding: 9px 11px; border-radius: 11px; color: #4b6468; background: #f1f3ea; font-size: 14px; line-height: 1.55; }
.goal-item::before { content: ""; display: block; flex: 0 0 17px; width: 17px; height: 17px; margin-top: 2px; border: 1.5px solid #a2b4a8; border-radius: 50%; background: #fffdf8; }
.goal-item.is-met { color: #286952; background: #e8f3e5; }
.goal-item.is-met::before { content: "✓"; display: grid; place-items: center; color: #fffdf8; border-color: #287e79; background: #287e79; font-size: 11px; line-height: 1; font-weight: 700; }
.route-destinations { flex-direction: row; flex-wrap: wrap; gap: 7px; max-width: 540px; margin: 14px auto 0; }
.route-destinations > .goal-item { flex: 1 1 138px; padding: 8px 10px; font-size: 13px; }
.mission-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; min-width: 0; }
.mission-actions > button { flex: 1 1 112px; min-height: 48px; font-size: 16px; }
.mission-actions > .primary { flex-basis: 100%; min-height: 52px; }
.mission-status { padding: 13px 16px; margin: 15px 0 0; border-radius: 14px; background: #fff0dd; color: #4f5e53; font-size: 15px; line-height: 1.65; overflow-wrap: anywhere; }
.mission-status:empty { display: none; }
.mission-status.status-success { color: #286952; background: #e8f3e5; }
.mission-result { padding: 18px; border: 1px solid #d6e2d4; border-radius: 18px; background: #f5f6ed; color: #365b52; }
.mission-result:empty { display: none; }
.mission-result.is-complete { border-color: #a6c7ac; background: #e7f2de; box-shadow: 0 4px 0 #d6e5cf; }
.mission-result h2, .mission-result h3 { margin: 0 0 9px; color: #286c54; font-size: 22px; }
.mission-result p { margin: 0 0 12px; font-size: 15px; line-height: 1.7; }
.mission-result p:last-child { margin-bottom: 0; }
.success-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.success-actions > button { flex: 1 1 115px; min-height: 46px; font-size: 16px; }
.hint-box { padding: 14px 15px; border: 1px dashed #b7cbd1; border-radius: 14px; background: #eef4f5; color: #42616a; font-size: 14px; line-height: 1.75; }
.hint-box:empty { display: none; }
.hint-box summary { cursor: pointer; font-weight: 650; }
.hint-box p { margin: 8px 0 0; }
.hint-box > button { margin-top: 8px; font-size: 16px; }
.hint-level { display: inline-block; padding: 3px 7px; margin: 0 0 7px; border-radius: 7px; background: #fff9e8; color: #7c673d; font-size: 12px; line-height: 1.4; }
.mission-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 14px; margin: 12px 0 0; color: #567073; font-size: 13px; line-height: 1.6; }
.mission-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.mission-footer { max-width: 1050px; margin: 22px auto 0; color: #567073; font-size: 14px; line-height: 1.75; }
.mission-footer > p { margin-bottom: 10px; }
.challenge-home-link { min-height: 44px; padding: 9px 13px; color: #42666a; border-color: transparent; background: transparent; font-size: 16px; }

.mission-route-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--grid-size, 5), minmax(0, 1fr));
  grid-template-rows: repeat(var(--grid-size, 5), minmax(0, 1fr));
  gap: 0;
  aspect-ratio: 1;
  width: 100%;
  min-width: 0;
  max-width: 540px;
  padding: 0;
  margin: 0 auto;
  border: 0;
  border-radius: 22px;
  background: #e1e9dd;
  box-shadow: 0 0 0 1px #cedccc, 0 4px 0 #d4dfce;
  overflow: hidden;
  isolation: isolate;
}
.mission-route-board > .mission-route-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 3px;
  overflow: hidden;
  color: #426164;
  border: 3px solid #e1e9dd;
  border-radius: 13px;
  background: #fffdf8;
  box-shadow: 0 2px 0 rgb(104 132 105 / 8%);
  font-size: 16px;
  line-height: 1.2;
}
.mission-route-board > .mission-route-cell.obstacle { background: #cbd4cc; color: #50645c; }
.mission-route-board > .mission-route-cell.water { background: #bfdde6; color: #477d96; }
.mission-route-board > .mission-route-cell.goal { background: #d4eacb; color: #2c7053; box-shadow: inset 0 0 0 2px #96be91; }
.mission-route-board > .mission-route-cell.start { background: #fff0d8; color: #88652d; }
.mission-route-board > .mission-route-cell.key { background: #fff1ba; color: #846127; }
.mission-route-board > .mission-route-cell.door { background: #efd7b5; color: #795b38; }
.mission-route-board > .mission-route-cell.collected { background: #edf3e7; color: #6f816e; }
.mission-route-cell.collected .tile-icon { opacity: .35; }
.mission-route-cell .tile-icon { display: block; max-width: 100%; font-size: clamp(22px, 4vw, 35px); line-height: 1.15; }
.mission-route-cell .tile-icon img, .mission-route-cell .tile-icon svg { display: block; width: 32px; height: 32px; object-fit: contain; }
.mission-route-cell .tile-label { display: block; max-width: 100%; font-size: 12px; font-weight: 600; line-height: 1.25; text-align: center; white-space: nowrap; }
.mission-runner { position: absolute; z-index: 3; display: grid; place-items: center; width: calc(100% / var(--grid-size, 5)); height: calc(100% / var(--grid-size, 5)); padding: 4px; pointer-events: none; transition: left .21s ease, top .21s ease; }
.mission-runner img { width: 79%; height: 94%; object-fit: contain; filter: drop-shadow(0 3px 0 rgb(36 69 77 / 12%)); }
.route-controls { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.route-controls > .label { margin: 0; color: #567073; font-size: 14px; line-height: 1.45; }
.route-controls .direction-buttons { gap: 7px; }
.route-controls .direction-button { min-height: 55px; font-size: 29px; }
.repeat-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; min-width: 0; }
.repeat-picker > span, .repeat-picker > label { color: #567073; font-size: 14px; margin-right: 2px; }
.repeat-picker > button { flex: 1 1 40px; min-width: 44px; min-height: 44px; padding: 8px 9px; color: #36585c; font-size: 16px; border-radius: 12px; background: #f4f5ec; }
.repeat-picker > button[aria-pressed="true"] { color: #fffdf8; border-color: #287e79; background: #287e79; box-shadow: 0 2px 0 #1f6660; }
.mission-program { display: flex; flex-wrap: wrap; align-items: flex-start; align-content: flex-start; gap: 7px; min-width: 0; min-height: 88px; padding: 11px; margin: 0; list-style: none; border: 1px dashed #becfbd; border-radius: 16px; background: #f4f7ee; }
.mission-program:empty::after { content: "选方向，把指令放在这里"; display: block; width: 100%; margin: auto; color: #698074; font-size: 14px; text-align: center; }
.program-token { position: relative; display: grid; place-items: center; flex: 0 0 61px; width: 61px; min-width: 0; min-height: 67px; padding: 15px 12px 16px; color: #36585b; border: 1px solid #ccdccb; border-radius: 12px; background: #fffdf8; font-size: 28px; font-weight: 600; line-height: 1; }
.program-token .step-index { position: absolute; top: 5px; left: 6px; color: #738377; font-size: 12px; line-height: 1; font-weight: 400; }
.program-token .repeat-badge { position: absolute; right: 5px; bottom: 5px; padding: 2px 4px; border-radius: 5px; color: #6e5a33; background: #ffedc9; font-size: 12px; line-height: 1.15; font-weight: 600; }
.program-token.executing { color: #fffdf8; border-color: #287e79; background: #287e79; box-shadow: 0 0 0 2px #a8cbb8; }
.program-token.executing .step-index { color: #e5f3e9; }
.program-token.failed { color: #755a3d; border-color: #d69766; background: #fff0dd; box-shadow: 0 0 0 2px #f0d5b6; }
.program-token.failed .step-index { color: #755a3d; }
.program-token.is-selected { outline: 2px solid #6086a6; outline-offset: 2px; }
.program-token:disabled { opacity: .72; }
.program-token.executing:disabled { opacity: 1; }
.program-editor { min-width: 0; padding: 13px; border: 1px solid #aec5d3; border-radius: 14px; background: #edf3f6; }
.program-editor > span { display: block; margin-bottom: 9px; color: #42616a; font-size: 14px; font-weight: 650; }
.program-editor .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.program-editor .toolbar > button { min-width: 0; min-height: 44px; padding: 9px 6px; font-size: 15px; }
.program-meter { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 5px 11px; min-width: 0; color: #567073; font-size: 13px; line-height: 1.6; font-variant-numeric: tabular-nums; }
.program-meter strong { color: #365b53; font-weight: 650; }
.program-meter progress { width: 100%; height: 7px; overflow: hidden; border: 0; border-radius: 7px; background: #e0e9dc; accent-color: #287e79; }
.program-meter progress::-webkit-progress-bar { background: #e0e9dc; border-radius: 7px; }
.program-meter progress::-webkit-progress-value { background: #287e79; border-radius: 7px; }
.program-meter progress::-moz-progress-bar { background: #287e79; border-radius: 7px; }

.adventure-entry:focus-visible,
.chapter-tab:focus-visible,
.mission-card:focus-visible,
.mission-layout button:focus-visible,
.challenge-home-link:focus-visible {
  outline: 3px solid #24454d;
  outline-offset: 4px;
}

@media (hover: hover) and (pointer: fine) {
  .mission-card:not(:disabled):hover { transform: translateY(-3px); border-color: #a8c6b2; box-shadow: 0 8px 0 #e0e6d6; }
  .mission-card.complete:not(:disabled):hover { box-shadow: 0 8px 0 #cde0c9; }
  .adventure-entry:hover { border-color: #8db5a3; transform: translateY(-2px); }
  .chapter-tab:not([aria-pressed="true"]):hover { background: #edf4e9; }
  .program-token:not(.executing):hover { border-color: #90b49c; background: #ecf4e7; }
}

@media (max-width: 950px) {
  .mission-layout { grid-template-columns: minmax(0, 1fr) 270px; gap: 19px; }
  .mission-tools { padding: 17px; }
  .mission-map { gap: 12px; }
  .mission-card { padding: 17px; }
  .mission-card .mission-title { font-size: 18px; }
}

@media (max-width: 760px) {
  .adventure-hero { grid-template-columns: minmax(0, 1fr) 165px; gap: 16px; padding: 21px; }
  .adventure-hero-art, .adventure-hero-art img { max-height: 150px; }
  .mission-map { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mission-card { min-height: 199px; padding: 18px; }
  .mission-layout { grid-template-columns: 1fr; gap: 17px; max-width: 540px; }
  .mission-head { flex-wrap: wrap; gap: 10px; margin-top: 7px; }
  .mission-titleblock { flex: 1 1 160px; }
  .mission-titleblock h1 { font-size: 27px; }
  .mission-counter { align-self: flex-start; font-size: 13px; }
  .mission-tools { padding: 18px; }
  .build-tool-tray .pieces { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .build-tool-tray .piece-choice { min-height: 69px; padding: 8px 4px; font-size: 16px; }
  .build-tool-tray .piece-choice .mini-brick { width: calc(var(--preview-w, 2) * 10px); height: calc(var(--preview-h, 1) * 10px); }
  .build-tool-tray .colors { gap: 9px; }
  .build-tool-tray .toolbar { gap: 8px; }
  .mission-canvas .build-board { border-radius: 12px; }
  .mission-route-board { border-radius: 18px; }
  .mission-route-board > .mission-route-cell { border-radius: 11px; padding: 2px; }
  .mission-route-cell .tile-icon { font-size: 28px; }
  .mission-runner { padding: 4px; }
  .mission-legend { margin-top: 10px; font-size: 12px; }

  /* Building missions: select a piece above the board; try it below. */
  .mission-layout.mission-builder { grid-template-columns: 1fr; gap: 12px; }
  .mission-builder > .mission-tools { display: contents; }
  .mission-builder > .mission-tools > .build-tool-tray { order: 1; }
  .mission-builder > .studio { order: 2; }
  .mission-builder > .mission-tools > .mission-status { order: 3; margin: 0; }
  .mission-builder > .mission-tools > .mission-actions { order: 4; }
  .mission-builder > .mission-tools > .goal-list { order: 5; }
  .mission-builder > .mission-tools > .mission-result { order: 6; }
  .mission-builder > .mission-tools > .hint-box { order: 7; }
  .mission-builder > .mission-tools > .mission-footer { order: 8; }
  .mission-builder > .mission-tools > .challenge-home-link { order: 9; }
  .mission-builder .build-tool-tray { display: grid; grid-template-columns: minmax(0, 1fr) 108px; gap: 8px 12px; padding: 0; }
  .mission-builder .build-tool-tray > .toolgroup:first-child { grid-column: 1 / -1; }
  .mission-builder .build-tool-tray > .toolgroup:nth-child(2) { grid-column: 1; align-self: center; }
  .mission-builder .build-tool-tray > .toolbar { grid-column: 2; display: grid; grid-template-columns: 1fr; gap: 6px; align-self: end; }
  .mission-builder .build-tool-tray > .toolbar > button { min-height: 44px; padding: 8px 6px; font-size: 16px; }
  .mission-builder .build-tool-tray > .selection-label { grid-column: 1 / -1; margin: 0; }
  .mission-builder .build-tool-tray .label { margin-bottom: 6px; font-size: 13px; }
  .mission-builder .build-tool-tray .colors { gap: 6px; }
  .mission-builder .build-tool-tray .color-choice { width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
  .mission-builder .goal-list { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .mission-builder .goal-item { flex: 1 1 145px; padding: 8px 9px; gap: 7px; font-size: 13px; line-height: 1.5; }
  .mission-builder .goal-item::before { flex-basis: 15px; width: 15px; height: 15px; margin-top: 2px; }
  .mission-builder .mission-actions > .primary { min-height: 52px; }
  .mission-builder .mission-status { margin-top: 11px; }

  /* Keep the map and its controls together before the longer delivery checklist. */
  .mission-layout.mission-delivery { gap: 12px; }
  .mission-delivery > .studio,
  .mission-delivery > .mission-tools,
  .mission-delivery > .mission-tools > .route-controls { display: contents; }
  .mission-delivery .mission-route-board { order: 1; }
  .mission-delivery .mission-legend { order: 2; margin: 0; }
  .mission-delivery .route-controls > .label { order: 3; margin: 2px 0 0; }
  .mission-delivery .repeat-picker { order: 4; }
  .mission-delivery .direction-buttons { order: 5; }
  .mission-delivery .program-meter { order: 6; }
  .mission-delivery .mission-program { order: 7; }
  .mission-delivery .program-editor { order: 8; }
  .mission-delivery .mission-actions { order: 9; }
  .mission-delivery .mission-status { order: 10; margin: 0; }
  .mission-delivery .route-destinations { order: 11; width: 100%; margin: 0; }
  .mission-delivery .route-controls > .toolbar { order: 12; }
  .mission-delivery [data-adventure-action="restore-program"] { order: 13; }
  .mission-delivery .mission-result { order: 14; }
  .mission-delivery .hint-box { order: 15; }
  .mission-delivery .challenge-home-link { order: 16; }
  .route-controls { gap: 11px; }
  .route-controls .direction-button { min-height: 54px; }
  .repeat-picker { gap: 6px; }
  .mission-program { gap: 7px; min-height: 80px; padding: 9px; }
  .program-token { flex-basis: 59px; width: 59px; min-height: 64px; }
  .mission-status { font-size: 14px; padding: 12px 14px; }
  .mission-footer { font-size: 13px; margin-top: 17px; }
}

@media (max-width: 480px) {
  .adventure-hero { grid-template-columns: minmax(0, 1fr) 88px; gap: 10px; padding: 18px; border-radius: 22px; margin: 6px 0 18px; }
  .adventure-hero h1 { font-size: 27px; line-height: 1.3; margin-bottom: 9px; }
  .adventure-hero p { font-size: 14px; line-height: 1.7; margin-bottom: 8px; }
  .adventure-hero .eyebrow { font-size: 12px; }
  .adventure-hero-art, .adventure-hero-art img { max-height: 108px; }
  .adventure-hero-art img { width: 100%; }
  .adventure-entry { gap: 12px; padding: 18px; border-radius: 20px; margin: 17px 0; }
  .adventure-entry h2 { font-size: 22px; }
  .adventure-entry p { font-size: 14px; }
  .adventure-entry > img { flex-basis: 62px; width: 62px; height: 74px; }
  .adventure-entry > span:last-child:not(.badge) { font-size: 23px; }
  .chapter-nav { gap: 7px; margin: 14px 0; }
  .chapter-tab { min-height: 79px; padding: 9px 7px; border-radius: 13px; font-size: 15px; }
  .chapter-tab > span { display: block; margin-bottom: 4px; font-size: 23px; line-height: 1.1; }
  .chapter-tab small { font-size: 12px; }
  .adventure-title { margin-top: 21px; font-size: 20px; }
  .adventure-progress { font-size: 13px; gap: 8px 10px; }
  .mission-map { gap: 12px 10px; }
  .mission-card { min-height: 193px; padding: 15px; border-radius: 20px; }
  .mission-card .mission-number { top: 14px; right: 13px; width: 25px; min-width: 25px; height: 25px; font-size: 12px; }
  .mission-icon { width: 48px; height: 48px; border-radius: 15px; font-size: 26px; margin-bottom: 13px; }
  .mission-icon img, .mission-icon svg { width: 36px; height: 36px; }
  .mission-card .mission-title { font-size: 18px; line-height: 1.4; }
  .mission-card .mission-summary { font-size: 13px; line-height: 1.6; margin-bottom: 11px; }
  .mission-meta { gap: 4px; font-size: 12px; }
  .mission-meta > span { padding: 3px 5px; }
  .passport-strip { gap: 9px; padding: 14px 10px; border-radius: 17px; }
  .progress-stamp { min-width: 89px; min-height: 76px; padding: 9px 10px; font-size: 12px; border-radius: 14px; }
  .mission-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
  .mission-head .back-btn { justify-self: start; padding: 9px 10px; }
  .mission-titleblock { grid-column: 1 / -1; grid-row: 2; }
  .mission-titleblock h1 { font-size: 25px; }
  .mission-titleblock p { font-size: 13px; }
  .mission-counter { grid-column: 2; grid-row: 1; padding: 6px 8px; font-size: 12px; margin-left: auto; }
  .mission-taskbar { display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: start; gap: 9px 10px; padding: 14px; }
  .mission-taskbar > img { width: 32px; height: 36px; }
  .mission-taskbar > .task-copy { grid-column: 2; font-size: 16px; line-height: 1.65; }
  .mission-taskbar > .listen { grid-column: 2; justify-self: end; margin: 0; min-height: 44px; }
  .mission-route-cell .tile-icon { font-size: clamp(19px, 6vw, 24px); }
  .mission-route-cell .tile-label { font-size: clamp(10px, 2.8vw, 12px); }
  .mission-runner { padding: 3px; }
  .mission-result { padding: 16px; }
  .mission-result h2, .mission-result h3 { font-size: 21px; }
  .success-actions { gap: 7px; }
  .hint-box { padding: 13px; font-size: 14px; }
}

@media (max-width: 360px) {
  .adventure-hero { grid-template-columns: minmax(0, 1fr); }
  .adventure-hero-art { display: none; }
  .chapter-tab { padding-left: 5px; padding-right: 5px; }
  .mission-builder .build-tool-tray { grid-template-columns: minmax(0, 1fr) 98px; gap: 8px 10px; }
  .mission-builder .build-tool-tray .colors { gap: 5px; }
  .route-destinations > .goal-item { flex-basis: 125px; }
}

@media (min-width: 480px) and (max-width: 760px) {
  .mission-builder .build-tool-tray { grid-template-columns: minmax(0, 1fr) 174px; }
  .mission-builder .build-tool-tray > .toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .adventure-entry,
  .mission-card,
  .mission-runner,
  .adventure-progress .progress-fill,
  .mission-layout *,
  .mission-layout *::before,
  .mission-layout *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
