:root {
  color-scheme: dark;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: #18172c;
  color: #fff0d3;
  --muted: #cbc1d9;
  --gold: #ffcb78;
  --panel: #292641;
  --rim: #615374;
  --shadow: #100f23;
  --sprite-sheet: url("art/market-sprites.png");
  --ui-sprite-sheet: url("art/ui-sprites.png");
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 52% -20%, #3c2f50, #201e37 52%, #18172c 95%);
  min-height: 100svh;
  isolation: isolate;
  position: relative;
}
body::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 182px;
  background: url("art/night-skyline.png") repeat-x bottom center / 896px 182px;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: -1;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible { outline: 3px solid #ffd282; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }

.market { width: min(100% - 40px, 948px); margin: auto; padding: 34px 0 42px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 2px solid #5b4969;
  box-shadow: 0 2px #20192f;
  padding-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand h1 {
  color: #ffe0a2;
  font-size: clamp(1.55rem, 5vw, 2.35rem);
  font-weight: 900;
  letter-spacing: .075em;
  white-space: nowrap;
  text-shadow: 2px 2px #a65765, 4px 4px #221a32;
}
.lantern, .cell.wall::after, .cell .stall-icon {
  background-image: var(--sprite-sheet);
  background-repeat: no-repeat;
  background-size: 800% 400%;
  image-rendering: pixelated;
}
.lantern {
  display: block;
  width: 48px;
  aspect-ratio: 1;
  background-position: 0 0;
  filter: drop-shadow(0 0 10px #f47a5356);
}
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex: none; }
.music-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-height: 36px;
  padding: 0;
  border: 2px solid #806785;
  background: #352e4c;
  color: #ffe3aa;
  box-shadow: inset 0 -3px #211a35;
}
.music-toggle[aria-pressed="false"] { color: #a99eb3; border-color: #5e526d; background: #2a263e; }
.music-note, .home-icon {
  display: block;
  width: 16px;
  height: 16px;
  flex: none;
  background-image: var(--ui-sprite-sheet);
  background-repeat: no-repeat;
  background-size: 400% 100%;
  image-rendering: pixelated;
}
.music-note { background-position: 0 0; }
.music-toggle[aria-pressed="false"] .music-note { background-position: 33.333333% 0; }
#menu-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  padding: 0;
}
.home-icon { background-position: 66.666667% 0; }
.home {
  display: grid;
  grid-template-columns: 1fr 1.22fr;
  align-items: start;
  gap: 22px;
  padding-top: 22px;
}
.home-hero, .home-panel {
  min-width: 0;
  background: var(--panel);
  border: 2px solid var(--rim);
  box-shadow: inset 0 3px #443852, 0 4px var(--shadow);
}
.home-hero { display: flex; flex-direction: column; }
.home-scene {
  overflow: hidden;
  position: relative;
  isolation: isolate;
  min-height: 178px;
  flex: 1;
  background:
    url("art/night-skyline.png") repeat-x bottom center / 768px 156px,
    linear-gradient(#453252, #242442);
  image-rendering: pixelated;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  padding-bottom: 13px;
}
.home-scene::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 33px;
  z-index: -1;
  border-top: 3px solid #796078;
  background: #4c3a54;
}
.hero-shop {
  display: grid;
  justify-items: center;
  align-items: end;
  position: relative;
  width: min(25%, 85px);
  height: 69px;
  border: 4px solid #3c2b42;
  background: linear-gradient(#a36b66 0 20%, #51354d 20% 83%, #a36b66 83%);
  box-shadow: inset 0 -5px #593a46, 3px 3px #211d34;
}
.hero-shop::before {
  content: "";
  position: absolute;
  inset: -5px -5px auto;
  height: 22px;
  border-block: 3px solid var(--stall-border);
  background: repeating-linear-gradient(90deg, var(--awning-light) 0 12px, var(--awning) 12px 24px);
}
.hero-shop::after, .hero-bunting, .hero-visitor {
  content: "";
  background-image: var(--sprite-sheet);
  background-repeat: no-repeat;
  background-size: 800% 400%;
  image-rendering: pixelated;
}
.hero-shop::after { width: 36px; height: 36px; background-position: var(--stall-sprite) 0; }
.hero-bunting {
  position: absolute;
  top: -13px;
  left: calc(50% - 65px);
  width: 130px;
  height: 100px;
  background-position: 57.142857% 100%;
}
.hero-visitor {
  position: absolute;
  bottom: 5px;
  right: 8%;
  width: 38px;
  height: 38px;
  background-position: 0 100%;
}
.home-start { padding: 13px 16px 16px; }
.home-start p { color: var(--muted); font-size: .875rem; margin-bottom: 8px; }
.tutorial-replay {
  width: 100%;
  margin-top: 7px;
  min-height: 32px;
  border: 0;
  background: transparent;
  color: #d8c9dc;
  font-size: .78rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.home-panel { padding: 12px; }
.home-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; margin-bottom: 10px; }
.home-tabs button {
  min-height: 41px;
  border: 2px solid var(--rim);
  background: #342d4a;
  color: #e3d7e6;
  font-weight: 650;
  font-size: .85rem;
  padding: 0 2px;
}
.home-tabs button[aria-pressed="true"] { background: #684961; border-color: #e9ad79; color: #ffe9b7; }
.hero-theme { display: none; position: absolute; z-index: 3; inset: 0; overflow: hidden; }
.home[data-view="city"] .hero-theme-city, .home[data-view="album"] .hero-theme-album { display: block; }
.home:is([data-view="city"], [data-view="album"]) :is(.hero-bunting, .hero-shop, .hero-visitor) { display: none; }
.hero-theme-copy {
  position: relative;
  z-index: 2;
  display: grid;
  align-content: center;
  gap: 4px;
  width: 58%;
  height: 100%;
  padding: 14px 16px;
  background: linear-gradient(90deg, #29243ff2 0 70%, transparent);
}
.hero-theme-copy span { color: #f3b77d; font-size: .76rem; letter-spacing: .16em; }
.hero-theme-copy strong { color: #fff0cc; font-size: 1.18rem; line-height: 1.4; text-shadow: 2px 2px #4f334f; }
.hero-theme-city {
  background:
    url("art/night-skyline.png") repeat-x right bottom / 620px 126px,
    linear-gradient(135deg, #503552, #232744);
}
.hero-theme-city::after {
  content: "";
  position: absolute;
  z-index: 0;
  right: -8px;
  bottom: 19px;
  width: 57%;
  height: 18px;
  border-top: 3px dashed #e5b06e;
  transform: rotate(-5deg);
  opacity: .72;
}
.hero-theme-foods { position: absolute; z-index: 1; inset: 0; pointer-events: none; }
.hero-theme-foods .food-pixel { position: absolute; width: 61px; filter: drop-shadow(3px 4px #171426); }
.hero-theme-city .food-pixel:nth-child(1) { right: 130px; bottom: 12px; }
.hero-theme-city .food-pixel:nth-child(2) { right: 67px; top: 12px; }
.hero-theme-city .food-pixel:nth-child(3) { right: 8px; bottom: 16px; }
.hero-theme-album {
  background:
    radial-gradient(circle at 78% 34%, #9e6a856b 0 5px, transparent 6px),
    linear-gradient(135deg, #463450, #24233f);
}
.hero-theme-album::before {
  content: "";
  position: absolute;
  z-index: 0;
  right: 15px;
  bottom: 18px;
  width: 180px;
  height: 86px;
  border: 3px solid #c38a75;
  background: linear-gradient(90deg, #e1b58a 0 48%, #8e5e66 48% 52%, #d7a77f 52%);
  box-shadow: inset 0 0 0 4px #f1cc9b55, 4px 4px #181426;
  transform: perspective(140px) rotateX(5deg);
}
.hero-theme-album .food-pixel:nth-child(1) { right: 112px; bottom: 32px; }
.hero-theme-album .food-pixel:nth-child(2) { right: 34px; top: 22px; }
.districts { display: grid; gap: 6px; }
.district-button {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto 13px;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 2px 8px;
  padding: 6px 8px;
  text-align: left;
  min-height: 50px;
  border: 2px solid var(--rim);
  background: #342d4a;
}
.district-button[aria-expanded="true"] { border-color: #e9ad79; background: #503952; }
.district-button strong { grid-column: 1; color: #fff0d3; font-size: .9rem; }
.district-number { color: #e7bf9c; font-size: .72rem; }
.district-progress { grid-area: 1 / 2 / span 2; color: var(--muted); white-space: nowrap; font-size: .76rem; font-variant-numeric: tabular-nums; }
.district-button::after { content: "+"; grid-area: 1 / 3 / span 2; color: #ffdc9c; font: 700 .95rem ui-monospace, monospace; }
.district-button[aria-expanded="true"]::after { content: "−"; }
.district-levels { margin-block: 6px 9px; }
.city-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.city-card {
  --city-sky: #654860;
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 6px;
  text-align: left;
  border: 2px solid var(--rim);
  background: #332c48;
}
.city-card[data-city="wuhan"] { --city-sky: #743e55; }
.city-card[data-city="chengdu"] { --city-sky: #3b655e; }
.city-card[data-city="chongqing"] { --city-sky: #764a45; }
.city-card[data-city="xian"] { --city-sky: #74583f; }
.city-card[data-city="lanzhou"] { --city-sky: #796343; }
.city-card[data-city="nanchang"] { --city-sky: #684365; }
.city-card:hover { border-color: #edbe88; }
.city-cover {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  min-height: 70px;
  padding: 4px 6px;
  background: repeating-linear-gradient(90deg, #ffffff07 0 7px, transparent 7px 14px), var(--city-sky);
  box-shadow: inset 0 -3px #21192f, inset 0 2px #ffffff15;
}
.city-cover .food-pixel { width: 58px; }
.city-cover-label { color: #f9dfb2; font-size: .78rem; font-weight: 700; }
.city-name { color: #ffe4ab; font-size: 1.05rem; }
.city-theme { color: var(--muted); font-size: .76rem; line-height: 1.3; }
.city-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 4px;
  margin-top: 3px;
  padding-top: 5px;
  border-top: 1px solid #615374;
  color: #e9dcdf;
  font-size: .72rem;
}
.city-stats span:last-child { color: #f7cd94; }
.city-detail-heading { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.city-detail-heading h2 { font-size: 1rem; }
.city-detail-heading .quiet { padding-inline: 7px; white-space: nowrap; }
.levels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.level-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto auto;
  gap: 3px 6px;
  align-items: center;
  padding: 7px;
  text-align: left;
  min-height: 64px;
  border: 2px solid #645476;
  background: #332c48;
  box-shadow: inset 0 2px #ffffff09, 0 2px var(--shadow);
}
.level-button:hover { border-color: #ffe2a5; }
.level-button.completed { border-color: #638878; }
.level-meta { display: flex; align-items: center; gap: 5px; }
.level-index {
  display: grid;
  place-items: center;
  min-width: 18px;
  padding-inline: 2px;
  height: 18px;
  background: #4a3954;
  color: #ffe4ab;
  font-family: ui-monospace, Consolas, monospace;
  font-weight: 800;
  font-size: .73rem;
}
.level-name { font-size: .87rem; line-height: 1.22; }
.level-state, .rank-note { font-size: .79rem; color: var(--muted); }
.level-button.completed .level-state { color: #a9e5ba; }
.stars { color: #ffd183; font-size: .76rem; line-height: 1; white-space: nowrap; }
.level-stars { grid-column: 1; }
.level-preview {
  grid-area: 1 / 2 / span 3;
  align-self: center;
  display: grid;
  grid-template-columns: repeat(var(--preview-columns), minmax(0, 1fr));
  gap: 1px;
  width: 50px;
  padding: 2px;
  border: 1px solid #ae7e81;
  background: #49364f;
}
.level-preview i { aspect-ratio: 1; background: #a98192; }
.level-preview .wall { background: #554760; box-shadow: inset 0 2px #679381; }
.level-preview .entrance { background: #85d3a9; }
.level-preview .exit { background: #ffd188; }
.level-preview .stop { background: #9ecdf8; }
.level-preview .queue { background: #ffd184; }
.rank { padding: 5px 4px 2px; }
.rank-select { display: flex; align-items: center; gap: 9px; font-size: .88rem; }
.rank-select select { min-width: 0; min-height: 38px; padding: 0 7px; border: 2px solid var(--rim); background: #332c48; font: inherit; }
.catalog-note { margin: 7px 0 8px; color: var(--muted); font-size: .8rem; line-height: 1.35; }
.album-catalog-grid { margin-top: 6px; }
.album-catalog-card[data-scope="all"] { --city-sky: #6a466c; }
.album-catalog-card[data-scope="main"] { --city-sky: #4e6268; }
.album-tools { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0 8px; }
.album-filter { display: inline-flex; align-items: center; gap: 4px; min-height: 35px; font-size: .8rem; color: #eee0e8; cursor: pointer; }
.album-filter input { margin: 0; accent-color: #f7b877; }
.rank-note { margin-top: 8px; line-height: 1.4; }
.rank-list { margin: 8px 0 0; padding-left: 28px; }
.rank-list li { padding: 6px 4px; border-bottom: 1px solid var(--rim); color: #fff0c8; font-variant-numeric: tabular-nums; }
.album-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 0; padding: 0; list-style: none; }
.album-list li { min-height: 66px; display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 5px; align-items: center; border: 2px solid; padding: 5px 6px; font-size: .84rem; }
.album-list .collected { border-color: #7ec59b; background: #30463f; box-shadow: inset 3px 0 #7ec59b; }
.album-list .uncollected { border-style: dashed; border-color: #74677f; background: #2d283e; color: #ddd1e1; }
.album-card-details { display: grid; gap: 4px; }
.album-card-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 3px 5px; }
.album-card-state {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 4px;
  background: #89d4a0;
  color: #203b36;
  font-size: .72rem;
  font-weight: 750;
  white-space: nowrap;
}
.album-card-state::before { content: "✓"; line-height: 1; }
.uncollected .album-card-state { background: #493f56; color: #eadce9; }
.uncollected .album-card-state::before { content: ""; width: 7px; height: 7px; border: 1px solid currentColor; }
.album-card-kind { color: #d6c9dc; font-size: .72rem; white-space: nowrap; }
.rare .album-card-kind { color: #ffcb83; font-weight: 700; }
.food-pixel {
  display: block;
  width: 42px;
  aspect-ratio: 1;
  background-image: url("art/food-atlas.png");
  background-repeat: no-repeat;
  image-rendering: pixelated;
}
.album-list .food-pixel { background-color: #473850; box-shadow: inset 0 -2px #6c5270; }
.album-list .uncollected .food-pixel { filter: saturate(.24) brightness(.72); }
.album-list .rare strong { color: #ffe4a8; }

.game {
  display: grid;
  grid-template-columns: minmax(0, 1.23fr) minmax(0, 1fr);
  gap: 28px;
  padding-top: 24px;
  align-items: start;
}
.stage { min-width: 0; position: relative; isolation: isolate; }
.level-backdrop {
  --level-glow: #845b9b73;
  position: absolute;
  z-index: -1;
  inset: -3px 0 0;
  overflow: hidden;
  pointer-events: none;
  background: radial-gradient(ellipse at 82% 4%, var(--level-glow), transparent 58%);
}
.level-backdrop[data-city="wuhan"] { --level-glow: #ae546b70; }
.level-backdrop[data-city="chengdu"] { --level-glow: #548b767d; }
.level-backdrop[data-city="chongqing"] { --level-glow: #b3645173; }
.level-backdrop[data-city="xian"] { --level-glow: #ad804b75; }
.level-backdrop[data-city="lanzhou"] { --level-glow: #b98b547e; }
.level-backdrop[data-city="nanchang"] { --level-glow: #a160af78; }
.level-backdrop .food-pixel {
  position: absolute;
  top: 0;
  width: clamp(43px, 7vw, 67px);
  opacity: .42;
}
.level-backdrop .food-pixel:nth-child(1) { right: 69px; top: 9px; }
.level-backdrop .food-pixel:nth-child(2) { right: 135px; }
.level-backdrop .food-pixel:nth-child(3) { right: 201px; top: 12px; }
.level-backdrop .food-pixel:nth-child(4) { right: 12px; top: 21px; }
.level-info { position: relative; min-width: 0; }
.level-heading, .tray-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.level-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
#level-number { color: #efbd91; font-size: .78rem; white-space: nowrap; }
.level-heading h2 {
  font-size: clamp(1.25rem, 4vw, 1.65rem);
  line-height: 1.35;
  color: #fff0d3;
  text-shadow: 2px 2px #50374f;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.level-heading h2:focus { outline: none; }
.quiet {
  font-size: .875rem;
  min-height: 36px;
  background: #322b48;
  border: 2px solid #665579;
  padding: 0 13px;
}
.hint-button {
  display: grid;
  place-items: center;
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  min-height: 44px;
  padding: 0;
  border-color: #957081;
  box-shadow: inset 0 -3px #241b37;
}
.hint-button img { display: block; image-rendering: pixelated; }
.hint-button b {
  position: absolute;
  right: -5px;
  bottom: -5px;
  min-width: 18px;
  padding: 1px 3px;
  border: 2px solid #2b223d;
  background: #ffd173;
  color: #352541;
  font: 800 .64rem ui-monospace, monospace;
  line-height: 1.15;
}
.hint-button:hover { border-color: #ffd68f; background: #503952; }
.goal { margin: 4px 0 12px; line-height: 1.55; color: #e9d7df; }
.hint {
  position: absolute;
  z-index: 5;
  inset: 0;
  min-height: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  padding: 5px 7px 5px 10px;
  background: #342b48;
  color: #fff1ce;
  border: 2px solid #f6be7e;
  box-shadow: 0 3px #22192f;
  line-height: 1.38;
  font-size: .85rem;
}
.hint button { padding: 0 7px; min-height: 33px; flex: none; }
.map {
  padding: clamp(8px, 2vw, 13px);
  border: 3px solid #f2bc81;
  background: #755065;
  box-shadow: inset 0 0 0 3px #49364f, 0 0 0 3px #34253f, 0 6px 0 3px #151225;
}
.board { display: grid; grid-template-columns: repeat(var(--columns), minmax(0, 1fr)); gap: clamp(3px, .52vw, 5px); }
.cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid #544054;
  background:
    linear-gradient(90deg, #553f5122 50%, transparent 50%) 80% 15% / 18% 8% no-repeat,
    linear-gradient(90deg, #452d4822 50%, transparent 50%) 22% 72% / 22% 8% no-repeat,
    #ab8292;
  color: #3a243c;
  box-shadow: inset 0 3px #ffffff24, inset 0 -3px #4d354644;
}
.cell:hover:not(:disabled) { border-color: #fae5b5; }
.cell:focus-visible { z-index: 2; outline-color: #f4d49d; outline-offset: -2px; }
.cell.wall { opacity: 1; background: #554760; border-color: #4a3a53; }
.cell.wall::after { content: ""; width: 82%; aspect-ratio: 1; background-position: 14.285714% 0; }
.cell.path { --path-north: transparent; --path-south: transparent; --path-west: transparent; --path-east: transparent; }
.cell.path-north { --path-north: #58b893; }
.cell.path-south { --path-south: #58b893; }
.cell.path-west { --path-west: #58b893; }
.cell.path-east { --path-east: #58b893; }
.cell.path:not(.gate)::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle, #2a645f 0 3px, transparent 4px),
    repeating-linear-gradient(to top, var(--path-north) 0 3px, transparent 3px 6px) center top / 3px 50% no-repeat,
    repeating-linear-gradient(to bottom, var(--path-south) 0 3px, transparent 3px 6px) center bottom / 3px 50% no-repeat,
    repeating-linear-gradient(to left, var(--path-west) 0 3px, transparent 3px 6px) left center / 50% 3px no-repeat,
    repeating-linear-gradient(to right, var(--path-east) 0 3px, transparent 3px 6px) right center / 50% 3px no-repeat;
  pointer-events: none;
}
.cell.gate {
  background: repeating-linear-gradient(90deg, #353d58 0 12%, #2d334e 12% 24%);
  color: #ffedbf;
  border: 2px solid #91bca4;
  box-shadow: inset 0 4px #637a80, inset 0 -4px #25283f;
  font-weight: 800;
  font-size: clamp(.68rem, 2.65vw, .9rem);
  white-space: nowrap;
}
.cell.gate:disabled { opacity: 1; }
.cell.gate.blocked { background: #57374f; border-color: #db8584; box-shadow: inset 0 4px #8a5269, inset 0 -4px #40263d; }
.cell.stop { opacity: 1; background: #456389; border-color: #a9d4ff; color: #f5f8ff; font-weight: 750; font-size: clamp(.58rem, 2.45vw, .8rem); white-space: nowrap; }
.cell.stop::before { display: none; }
.cell.queue { opacity: 1; background: #9a6f73; border-color: #ffd184; color: #fff0bd; font-weight: 800; }
.cell.queue::before { display: none; }
.cell .stall-order {
  position: absolute;
  z-index: 3;
  top: -2px;
  left: -2px;
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border: 1px solid #7e572b;
  background: #ffd06f;
  color: #4a3028;
  font: 800 .52rem ui-monospace, monospace;
  box-shadow: 1px 1px #2a2039;
  pointer-events: none;
}
.cell.stall {
  background: repeating-linear-gradient(90deg, var(--awning-light) 0 16.66%, var(--awning) 16.66% 33.33%);
  border-color: var(--stall-border);
  box-shadow: inset 0 4px #ffffff50, inset 0 -5px var(--stall-border);
}
.cell.stall.selected { outline: 2px solid #462844; outline-offset: -2px; }
.cell.preview:not(.stall) { background: var(--awning-light); border-color: var(--stall-border); }
.cell.preview.path::before { visibility: hidden; }
.cell.landing-preview:not(.stall) { outline: 2px dashed #552b50; outline-offset: -5px; }
.cell.hint-cell, .cell.hint-blocker { box-shadow: inset 0 0 0 2px #ffe297; }
.cell.hint-blocker { box-shadow: inset 0 0 0 3px #ff9f91; }
.cell.hint-landing {
  outline: 3px dashed #fff0b3;
  outline-offset: -5px;
  box-shadow: inset 0 0 0 5px #92724e;
}
.cell.prop-valid:not(.stall) {
  outline: 3px solid #8ff0bd;
  outline-offset: -5px;
  box-shadow: inset 0 0 0 4px #376e63;
}
.cell.prop-landing {
  outline: 3px dashed #fff0a1;
  outline-offset: -6px;
  box-shadow: inset 0 0 0 4px #7d623f;
}
.cell .stall-icon { width: 65%; aspect-ratio: 1; background-position: var(--stall-sprite) 0; }
.cell .stall-icon.food-pixel { background-image: url("art/food-atlas.png"); }
.cell .window {
  position: absolute;
  z-index: 1;
  width: 49%;
  height: 6px;
  background: #a1345b;
  border: 2px solid #fff2d2;
  pointer-events: none;
}
.cell .window.connected { background: #2e8469; }
.window.south { bottom: -2px; }
.window.north { top: -2px; }
.cell .window.east, .cell .window.west { width: 6px; height: 49%; }
.window.east { right: -2px; }
.window.west { left: -2px; }
.cell.shared { background-color: #f0ce7f; border-color: #aa7351; }
.cell.shared:not(.gate)::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  background: #884564;
  box-shadow: 2px 2px #ffedb4;
}
.map-key { display: flex; flex-wrap: wrap; gap: 6px 13px; align-items: center; color: var(--muted); margin: 13px 1px 0; font-size: .875rem; }
.map-key span { display: inline-flex; align-items: center; gap: 5px; }
.map-key i { display: inline-block; }
.key-route { width: 18px; height: 3px; background: repeating-linear-gradient(90deg, #58b893 0 4px, transparent 4px 7px); }
.key-window { width: 14px; height: 6px; background: #3f967c; border: 2px solid #fff2d2; }
.key-stop { width: 8px; height: 8px; background: #a9d4ff; }
.key-queue, .key-order { display: grid !important; place-items: center; width: 16px; height: 16px; color: #39283f; font: 800 .58rem ui-monospace, monospace; }
.key-queue { background: #ffd184; border: 2px solid #8f5d5e; }
.key-order { background: #aee2c2; border: 2px solid #4b796d; }

.workbench {
  background: var(--panel);
  border: 2px solid var(--rim);
  box-shadow: inset 0 3px #443852, 0 4px var(--shadow);
  padding: 18px;
  margin-top: 3px;
}
.tray-heading h3 { font-size: 1.06rem; color: #ffe4ab; }
.count { color: var(--muted); font-size: .875rem; }
.tray-guide { margin-top: 7px; color: var(--muted); font-size: .875rem; line-height: 1.45; }
.tray { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.tray-button {
  border: 2px solid #655578;
  background: #352e4c;
  min-height: 67px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  padding: 6px 8px;
}
.tray-button[aria-pressed="true"] { background: #49374f; border-color: #ffca83; box-shadow: inset 0 -3px #795068; }
.piece-name { display: block; font-size: .875rem; font-weight: 700; white-space: nowrap; }
.piece-order {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-right: 5px;
  border: 2px solid #4b796d;
  background: #aee2c2;
  color: #253d3b;
  box-shadow: 1px 1px #221b32;
  font: 800 .62rem ui-monospace, monospace;
  vertical-align: middle;
}
.piece-state { display: block; font-size: .75rem; color: #dfd3e4; margin-top: 3px; }
.mini-piece {
  --mini-cell: 12px;
  display: grid;
  width: 42px;
  height: 42px;
  grid-template-columns: repeat(var(--mini-columns), var(--mini-cell));
  grid-auto-rows: var(--mini-cell);
  align-content: center;
  justify-content: center;
  gap: 3px;
  flex: 0 0 auto;
}
.mini-piece i.filled { background: var(--awning-light); box-shadow: inset 0 -2px var(--awning); position: relative; }
.mini-piece .landing-cell::before { content: ""; position: absolute; width: 4px; height: 4px; inset: 0; margin: auto; background: #543352; }
.mini-piece .door-cell::after {
  content: "";
  position: absolute;
  width: 75%;
  height: 3px;
  left: 12.5%;
  background: #fff;
  box-shadow: 0 0 0 1px #4e3650;
}
.mini-piece .door-cell.north::after { top: -1px; }
.mini-piece .door-cell.south::after { bottom: -1px; }
.mini-piece .door-cell.east::after, .mini-piece .door-cell.west::after { width: 3px; height: 75%; top: 12.5%; }
.mini-piece .door-cell.east::after { left: auto; right: -1px; }
.mini-piece .door-cell.west::after { left: -1px; }
.tea { --awning: #e97969; --awning-light: #ffc28f; --stall-border: #ab5263; --stall-sprite: 28.571429%; }
.noodle { --awning: #eda958; --awning-light: #ffda8d; --stall-border: #a76555; --stall-sprite: 42.857143%; }
.sweet { --awning: #d77cab; --awning-light: #ffbccf; --stall-border: #92517f; --stall-sprite: 57.142857%; }
.fish { --awning: #69b7a9; --awning-light: #b4dfb7; --stall-border: #4a7c7b; --stall-sprite: 71.428571%; }

.actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.38fr); gap: 6px; }
.actions button:not(.open-market), .win-actions button:not(.open-market) {
  border: 2px solid #685777;
  background: #39304f;
  min-height: 42px;
  padding: 0 4px;
  white-space: nowrap;
  font-size: .875rem;
}
.props {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}
.props button {
  min-width: 0;
  min-height: 42px;
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border: 2px solid #80647c;
  background: #302946;
  color: #f8e5c2;
  font-size: .76rem;
  text-align: left;
}
.props button:enabled:hover { border-color: #ffd28a; background: #493650; }
.props b { color: #a9e5ba; font: 700 .74rem ui-monospace, monospace; }
.props button.teaching { border-color: #ffd06f; background: #59405b; box-shadow: inset 0 0 0 2px #ffd06f55; }
.props button.locked { opacity: .46; filter: saturate(.35); }
.prop-icon {
  display: grid;
  place-items: center;
  width: 25px;
  aspect-ratio: 1;
  color: #32243f;
  background: #ffd173;
  border: 2px solid #fff0b3;
  box-shadow: inset 0 -4px #d77761, 2px 2px #171326;
  font: 800 1rem ui-monospace, monospace;
  image-rendering: pixelated;
}
.prop-icon.wrench { background: #9fd9c2; box-shadow: inset 0 -4px #4a9589, 2px 2px #171326; }
.prop-icon.cart { background: #f5a1aa; box-shadow: inset 0 -4px #a85676, 2px 2px #171326; }
.feedback { min-height: 2.9em; margin: 9px 0 0; color: #e4d9e4; line-height: 1.45; font-size: .875rem; }
.feedback.warning { color: #ffcb9d; }
.feedback.success { color: #a9e5ba; }
.tutorial {
  position: fixed;
  z-index: 30;
  top: 76px;
  left: 50%;
  width: min(420px, calc(100vw - 24px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  padding: 9px 10px;
  transform: translateX(-50%);
  border: 2px solid #ffc978;
  background: #332945f5;
  color: #fff0cf;
  box-shadow: 0 4px #151225, inset 0 2px #ffffff16;
}
.tutorial strong { display: block; color: #ffd58e; font-size: .86rem; }
.tutorial p { margin-top: 2px; color: #f1e5dc; font-size: .78rem; line-height: 1.35; }
.tutorial-actions { display: flex; gap: 5px; flex: none; }
.tutorial-actions button { min-height: 31px; padding: 0 7px; border: 1px solid #806785; background: #493850; font-size: .72rem; }
.tutorial-actions #tutorial-next { border-color: #e8a96d; color: #ffe2aa; }
.tutorial-target { position: relative; z-index: 12; outline: 3px solid #ffd06f !important; outline-offset: 3px; animation: tutorial-pulse .85s steps(2, end) infinite; }
#board.tutorial-target { animation: none; }
.tutorial-muted { pointer-events: none !important; opacity: .38 !important; filter: grayscale(.65) brightness(.62) !important; }
.tutorial-locked { pointer-events: none !important; }
@keyframes tutorial-pulse { 50% { filter: brightness(1.28); } }
.open-market {
  border: 2px solid #ffe2a8;
  background: var(--gold);
  color: #382641;
  box-shadow: inset 0 -4px #e3935c, 0 3px var(--shadow);
  min-height: 46px;
  width: 100%;
  font-weight: 750;
}
.open-market:enabled:hover { background: #ffe09c; }

dialog {
  width: min(380px, calc(100vw - 30px));
  padding: 23px;
  text-align: center;
  background: #322a46;
  color: #fff1d4;
  border: 3px solid #efba7c;
  box-shadow: 0 0 0 4px #62435b, 0 9px #151225;
}
dialog::backdrop { background: #131124b8; }
.win-lights { color: var(--gold); margin-bottom: 5px; }
dialog p { margin: 10px 0 17px; line-height: 1.5; }
.win-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.win-reward { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 5px; background: #473550; color: #f0e3cd; font-size: .85rem; }
.win-reward .food-pixel { width: 35px; flex: none; }
.win-reward.rare { color: #ffe1a4; box-shadow: inset 0 -2px #e6b67c; }

@media (max-width: 730px) {
  .market { max-width: 475px; width: calc(100% - 24px); padding: 4px 0 8px; }
  .topbar { gap: 6px; padding-bottom: 3px; min-height: 34px; }
  .brand { gap: 5px; }
  .brand h1 { font-size: 1.08rem; letter-spacing: .055em; text-shadow: 1px 1px #a65765, 3px 3px #221a32; }
  .lantern { width: 22px; }
  .topbar-actions { gap: 4px; }
  .music-toggle { width: 30px; min-height: 30px; }
  #menu-button { width: 30px; min-height: 30px; padding: 0; }
  .home { grid-template-columns: 1fr; gap: 11px; padding-top: 11px; }
  .home-scene { min-height: 135px; }
  .home-start { padding: 9px 12px 12px; }
  .home-panel { padding: 9px; }
  .game { grid-template-columns: 1fr; gap: 6px; padding: 3px 0 58px; }
  .game:not(.props-visible) { padding-bottom: 4px; }
  .level-heading { min-height: 29px; gap: 4px; }
  .level-heading h2 { font-size: .9rem; line-height: 1.25; }
  .hint-button { flex-basis: 33px; width: 33px; min-height: 33px; }
  .hint-button img { width: 25px; height: 25px; }
  .level-backdrop .food-pixel { width: 43px; opacity: .31; }
  .level-backdrop .food-pixel:nth-child(1) { right: 55px; top: 10px; }
  .level-backdrop .food-pixel:nth-child(2) { right: 99px; top: 4px; }
  .level-backdrop .food-pixel:nth-child(3) { right: 145px; top: 15px; }
  .level-backdrop .food-pixel:nth-child(4) { right: 8px; top: 23px; }
  .level-title { gap: 4px; }
  #level-number { font-size: .68rem; }
  #game-stars { font-size: .58rem; letter-spacing: -.04em; }
  .goal { margin: 0 0 3px; font-size: .72rem; line-height: 1.25; }
  .map {
    width: min(100%, 360px, calc(clamp(225px, 100svh - 425px, 305px) * var(--board-ratio)));
    margin: auto;
    padding: 6px;
  }
  .map-key { margin-top: 7px; gap: 4px 10px; font-size: .7rem; }
  .workbench { margin: 0; padding: 6px; }
  .tray-heading h3 { font-size: .8rem; }
  .count { font-size: .7rem; }
  .tray-guide { margin-top: 1px; font-size: .66rem; line-height: 1.25; }
  .tray { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 5px 0; gap: 4px; }
  .tray-button { height: 36px; min-height: 36px; gap: 5px; padding: 2px 5px; }
  .tray-button > span:last-child { min-width: 0; overflow: hidden; }
  .piece-name { font-size: .73rem; }
  .piece-order { width: 16px; height: 16px; margin-right: 4px; border-width: 1px; font-size: .56rem; }
  .piece-name, .piece-state { overflow: hidden; text-overflow: ellipsis; }
  .piece-state { margin-top: 1px; font-size: .61rem; white-space: nowrap; }
  .mini-piece { --mini-cell: 8px; width: 28px; height: 28px; gap: 2px; }
  .actions { gap: 4px; }
  .props {
    position: fixed;
    z-index: 10;
    left: 50%;
    bottom: max(6px, env(safe-area-inset-bottom));
    width: min(calc(100vw - 24px), 451px);
    margin: 0;
    padding: 5px;
    gap: 4px;
    transform: translateX(-50%);
    background: #262139f2;
    border: 2px solid #80647c;
    box-shadow: 0 -3px #171326, inset 0 2px #4b3b58;
  }
  .props button { min-height: 38px; padding-inline: 4px; font-size: .63rem; }
  .props b { font-size: .64rem; }
  .prop-icon { width: 22px; }
  .actions button:not(.open-market) { min-height: 38px; font-size: .72rem; }
  .actions .open-market { font-size: .8rem; }
  .actions .open-market { min-height: 40px; }
  .feedback { margin-top: 4px; min-height: 1.35em; font-size: .7rem; line-height: 1.3; }
  .tutorial { top: 42px; padding: 6px 7px; }
  .tutorial strong { font-size: .8rem; }
  .tutorial p { font-size: .72rem; }
}

@media (max-width: 730px) and (max-height: 660px) {
  .market { padding-block: 6px; }
  .topbar { min-height: 40px; padding-bottom: 4px; }
  .game { padding-top: 2px; gap: 4px; }
  .goal { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .78rem; }
  .map { width: min(100%, 330px, calc(clamp(200px, 100svh - 368px, 240px) * var(--board-ratio))); }
  .map-key { margin-top: 6px; }
  .workbench { padding: 6px; }
  .tray { margin-block: 3px; }
  .tray-button { height: 34px; min-height: 34px; }
  .mini-piece { --mini-cell: 7px; width: 25px; height: 25px; }
  .actions button:not(.open-market), .actions .open-market { min-height: 36px; }
  .game { padding-bottom: 51px; }
  .props { padding: 4px; }
  .props button { min-height: 34px; }
}

@media (max-width: 365px) {
  .brand h1 { font-size: 1.02rem; }
  .level-preview { width: 42px; }
  .album-list li { grid-template-columns: 34px minmax(0, 1fr); }
  .album-list .food-pixel { width: 34px; }
  .city-cover { min-height: 58px; padding-inline: 4px; }
  .city-cover .food-pixel { width: 44px; }
  .hero-theme-copy { padding-inline: 10px; }
  .hero-theme-copy strong { font-size: 1rem; }
  .hero-theme-foods .food-pixel { width: 48px; }
  .hero-theme-album::before { width: 145px; height: 70px; right: 7px; bottom: 12px; }
  .level-heading h2 { font-size: .84rem; }
  #level-number { font-size: .64rem; }
  .cell.gate, .cell.stop, .cell.queue { border-width: 1px; font-size: .5rem; }
  .tray-button { gap: 4px; padding-inline: 4px; }
  .mini-piece { --mini-cell: 7px; width: 25px; height: 25px; }
  .props button { grid-template-columns: 22px minmax(0, 1fr); }
  .props b { grid-area: 2 / 2; line-height: .6; }
}
