:root {
  --cream: #f8eedb;
  --paper: #fffaf0;
  --paper-2: #f3e4ca;
  --ink: #3b2a1e;
  --ink-soft: #6b4a32;
  --muted: #8b735f;
  --red: #c4553b;
  --red-deep: #9e3f2b;
  --gold: #d9a441;
  --gold-soft: #f3d28a;
  --green: #5e9e52;
  --line: rgba(59, 42, 30, 0.14);
  --shadow: 0 18px 44px rgba(30, 15, 8, 0.28);
  --serif: "Noto Serif SC", "Songti SC", "SimSun", "STSong", serif;
  --sans: "Microsoft YaHei", "Noto Sans SC", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  background: #1c130d;
  overflow-x: hidden;
}

button { font-family: inherit; }

.bg {
  position: fixed;
  inset: -4%;
  z-index: -2;
  background-image: var(--scene);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  filter: blur(4px) brightness(0.68) saturate(0.9);
  transform: scale(1.06);
}

.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(900px 520px at 50% 34%, rgba(255, 218, 150, 0.16), transparent 70%),
    linear-gradient(180deg, rgba(24, 14, 8, 0.55) 0%, rgba(24, 14, 8, 0.78) 100%);
}

.page {
  width: min(1280px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 22px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 2px 4px 4px;
  color: #fff7e7;
}

.brand { display: flex; flex-direction: column; gap: 2px; }

.brand-sub {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: #d9b98a;
}

.brand-main {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0.08em;
  color: #ffe6b0;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.5);
}

.brand-main em {
  font-style: normal;
  font-size: 18px;
  color: #f3d28a;
  opacity: 0.9;
}

.top-stats { display: flex; align-items: center; gap: 8px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 13px;
  border-radius: 999px;
  background: rgba(35, 22, 14, 0.72);
  border: 1px solid rgba(255, 230, 176, 0.24);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  color: #ffe6b0;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.pill b { color: #fff7e7; font-size: 15px; }

.pill .ico { font-size: 15px; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 230, 176, 0.24);
  background: rgba(35, 22, 14, 0.72);
  color: #ffe6b0;
  font-size: 16px;
  cursor: pointer;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 258px minmax(0, 1fr) 268px;
  gap: 16px;
  align-items: stretch;
}

.panel {
  position: relative;
  border-radius: 22px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 252, 244, 0.98), rgba(248, 238, 219, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 17px;
  border: 1px solid rgba(217, 164, 65, 0.18);
  pointer-events: none;
}

.panel > * { position: relative; z-index: 1; }

.chapter {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.level-title {
  margin-top: 4px;
  font-family: var(--serif);
  font-size: 30px;
  color: var(--red-deep);
  letter-spacing: 0.04em;
}

.level-title b { font-size: 40px; color: var(--red); }

.level-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.objective {
  margin-top: 14px;
  padding: 13px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px dashed rgba(196, 85, 59, 0.3);
}

.obj-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--red-deep);
}

.obj-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.obj-item img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 5px 6px rgba(80, 40, 20, 0.16));
}

.obj-item .emoji {
  display: none;
  width: 58px;
  height: 58px;
  align-items: center;
  justify-content: center;
  font-size: 38px;
}

.obj-item.noimg .emoji { display: flex; }
.obj-item.noimg img { display: none; }

.obj-name { display: flex; flex-direction: column; gap: 2px; }
.obj-name b { font-size: 19px; font-family: var(--serif); color: var(--ink); }
.obj-name span { font-size: 11px; color: var(--muted); }

.obj-progress {
  height: 7px;
  margin-top: 11px;
  border-radius: 999px;
  background: rgba(59, 42, 30, 0.1);
  overflow: hidden;
}

.obj-progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--red));
  transition: width 0.3s ease;
}

.obj-reward {
  margin-top: 8px;
  font-size: 11px;
  color: var(--red-deep);
  font-weight: 700;
  letter-spacing: 0.03em;
}

.obj-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
  font-size: 10px;
  color: var(--muted);
}

.obj-meta b { color: var(--ink); }

#targetState { color: var(--muted); }
#targetState.done { color: var(--green); font-weight: 700; }

.pill.warn {
  border-color: rgba(255, 107, 107, 0.55);
  color: #ffb3a3;
  background: rgba(80, 20, 12, 0.72);
}

.stars-line {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 14px;
  font-size: 24px;
  color: rgba(59, 42, 30, 0.16);
  letter-spacing: 2px;
}

.stars-line .on { color: var(--gold); text-shadow: 0 2px 8px rgba(217, 164, 65, 0.35); }

.stars-note {
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}

.level-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(59, 42, 30, 0.16);
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  box-shadow: 0 5px 12px rgba(80, 40, 20, 0.08);
}

.btn:hover { transform: translateY(-1px); background: #fff; box-shadow: 0 8px 18px rgba(80, 40, 20, 0.12); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn.primary {
  border-color: transparent;
  background: linear-gradient(180deg, #cf6448, var(--red-deep));
  color: #fff7e7;
  box-shadow: 0 8px 20px rgba(158, 63, 43, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn.primary:hover { background: linear-gradient(180deg, #d97255, #a94731); }

.btn.ghost { background: transparent; box-shadow: none; }

.btn em {
  font-style: normal;
  font-size: 10px;
  opacity: 0.7;
  font-weight: 500;
}

.board-wrap {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 18px 16px;
  border-radius: 22px;
  background:
    radial-gradient(600px 380px at 50% 12%, rgba(255, 249, 232, 0.98), rgba(248, 238, 219, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.board-head {
  width: min(100%, 560px);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.board-head b {
  font-family: var(--serif);
  font-size: 18px;
  color: var(--ink);
  letter-spacing: 0.06em;
}

.board-head span { font-size: 11px; color: var(--muted); }

.board {
  width: min(100%, 560px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 10px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(239, 224, 201, 0.8));
  border: 1px solid rgba(59, 42, 30, 0.12);
  box-shadow: inset 0 2px 8px rgba(80, 40, 20, 0.08), 0 8px 18px rgba(80, 40, 20, 0.08);
}

.cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(59, 42, 30, 0.08);
  background: rgba(255, 255, 255, 0.28);
  cursor: default;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.cell.empty {
  border: 1px dashed rgba(59, 42, 30, 0.13);
  background: rgba(59, 42, 30, 0.025);
}

.cell.filled {
  cursor: pointer;
  background: linear-gradient(180deg, #fffdf7, #f3e4ca);
  box-shadow: 0 3px 8px rgba(80, 40, 20, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.cell.filled:hover { transform: translateY(-1px); box-shadow: 0 6px 12px rgba(80, 40, 20, 0.14); }

.cell img {
  width: 85%;
  height: 85%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 4px 4px rgba(80, 40, 20, 0.14));
}

.cell .emoji {
  display: none;
  font-size: 34px;
  line-height: 1;
  pointer-events: none;
}

.cell.noimg .emoji { display: block; }
.cell.noimg img { display: none; }

.cell .tier {
  display: none;
}

.cell.chain-grain { border-color: rgba(217, 164, 65, 0.38); }
.cell.chain-snack { border-color: rgba(224, 107, 58, 0.34); }

.cell.mystery {
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 226, 162, 0.6), rgba(243, 228, 202, 0.92));
  border: 1px solid rgba(217, 164, 65, 0.55);
  box-shadow: 0 0 0 4px rgba(217, 164, 65, 0.08), 0 5px 14px rgba(80, 40, 20, 0.12);
}

.cell.mystery::after {
  content: "?";
  position: absolute;
  top: 4px;
  right: 6px;
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 700;
  color: rgba(158, 63, 43, 0.7);
}

.cell.mystery .nm {
  opacity: 1;
  color: var(--red-deep);
  font-weight: 700;
}

.cell.locked {
  background:
    repeating-linear-gradient(135deg, rgba(59, 42, 30, 0.08) 0 6px, rgba(59, 42, 30, 0.03) 6px 12px);
  border: 1px dashed rgba(59, 42, 30, 0.2);
  cursor: not-allowed;
  color: rgba(59, 42, 30, 0.35);
  font-size: 16px;
}

.cell.locked::before {
  content: "锁";
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.cell .burst {
  position: absolute;
  inset: -4px;
  border-radius: 14px;
  pointer-events: none;
  animation: burst 0.55s ease-out forwards;
}

@keyframes burst {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 209, 102, 0.85), 0 0 22px rgba(255, 209, 102, 0.8);
    opacity: 1;
  }
  100% {
    box-shadow: 0 0 0 30px rgba(255, 209, 102, 0), 0 0 0 rgba(255, 209, 102, 0);
    opacity: 0;
  }
}

.screen-flash {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background: radial-gradient(circle at 50% 45%, rgba(255, 242, 205, 0.55), rgba(255, 242, 205, 0) 62%);
  animation: screenFlash 0.28s ease-out forwards;
}

@keyframes screenFlash {
  from { opacity: 0.85; }
  to { opacity: 0; }
}

.cell .nm {
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 9px;
  color: var(--ink-soft);
  opacity: 0;
  transition: opacity 0.12s ease;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 2px;
}

.cell.filled:hover .nm { opacity: 1; }

.cell.selected {
  outline: 3px solid var(--gold);
  outline-offset: -1px;
  transform: translateY(-2px) scale(1.03);
  z-index: 2;
  box-shadow: 0 0 0 5px rgba(217, 164, 65, 0.2), 0 10px 20px rgba(80, 40, 20, 0.18);
}

.cell.hint { animation: hintPulse 1s ease-in-out infinite; }

@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 164, 65, 0.1); }
  50% { box-shadow: 0 0 0 7px rgba(217, 164, 65, 0.35); }
}

.cell.pop { animation: pop 0.22s ease-out; }

@keyframes pop {
  0% { transform: scale(0.82); }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.board-actions {
  width: min(100%, 560px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.board-actions .btn { min-height: 42px; padding: 0 4px; font-size: 11px; }

.chain-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-family: var(--serif);
  font-size: 18px;
  color: var(--ink);
  letter-spacing: 0.06em;
}

.chain-title span { font-size: 10px; font-family: var(--sans); color: var(--muted); letter-spacing: 0.08em; }

.chain {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, auto);
  grid-auto-flow: column;
  gap: 2px 3px;
  margin-top: 10px;
}

.ch-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 4px;
  border-radius: 8px;
  border: 1px solid transparent;
  opacity: 0.5;
  transition: opacity 0.2s ease, background 0.2s ease;
  min-width: 0;
}

.ch-row.found { opacity: 1; }

.ch-row.locked img { filter: brightness(0) opacity(0.62); }
.ch-row.locked .ch-name { color: var(--muted); }

.ch-row.target {
  opacity: 1;
  border-color: rgba(196, 85, 59, 0.35);
  background: rgba(196, 85, 59, 0.07);
}

.ch-row img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(80, 40, 20, 0.14));
}

.ch-row .emoji {
  display: none;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.ch-row.noimg .emoji { display: flex; }
.ch-row .emoji.show { display: flex; }
.ch-row.noimg img { display: none; }

.ch-row .ch-name {
  flex: 1;
  min-width: 0;
  font-size: 9px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ch-row.target .ch-name { color: var(--red-deep); font-weight: 700; }
.ch-row .ch-lv { display: none; }

.ch-row .ch-check { font-size: 9px; color: var(--green); }

.cat {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed rgba(59, 42, 30, 0.14);
}

.cat img {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 4px 10px rgba(80, 40, 20, 0.16);
}

.cat-tx { flex: 1; font-size: 11px; line-height: 1.5; color: var(--ink-soft); }
.cat-tx b { display: block; font-size: 12px; color: var(--red-deep); margin-bottom: 1px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 14px);
  z-index: 50;
  max-width: min(88vw, 520px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(35, 22, 14, 0.9);
  border: 1px solid rgba(255, 230, 176, 0.25);
  color: #ffe6b0;
  font-size: 13px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.3);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 10, 6, 0.68);
  backdrop-filter: blur(5px);
}

.overlay[hidden] { display: none; }

.overlay-card {
  width: min(92vw, 420px);
  border-radius: 24px;
  padding: 26px 24px 22px;
  text-align: center;
  background: linear-gradient(180deg, #fffaf0, #f3e4ca);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4), inset 0 1px 0 #fff;
}

.overlay-kicker {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.overlay-title {
  margin: 6px 0 2px;
  font-family: var(--serif);
  font-size: 30px;
  color: var(--red-deep);
}

.overlay-sub { font-size: 12px; color: var(--muted); }

.overlay-stars {
  margin: 14px 0 6px;
  font-size: 42px;
  letter-spacing: 6px;
  color: rgba(59, 42, 30, 0.14);
}

.overlay-stars .on { color: var(--gold); text-shadow: 0 3px 12px rgba(217, 164, 65, 0.4); }

.overlay-stats {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: 8px 0 16px;
  font-size: 12px;
  color: var(--ink-soft);
}

.overlay-stats b { color: var(--red-deep); }

.overlay-actions { display: flex; gap: 8px; }
.overlay-actions .btn { flex: 1; }

.build-card,
.map-card {
  width: min(94vw, 760px);
  max-height: 92vh;
  overflow: auto;
  border-radius: 24px;
  padding: 22px;
  background: linear-gradient(180deg, #fffaf0, #f3e4ca);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4), inset 0 1px 0 #fff;
}

.build-kicker {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--muted);
  text-align: center;
}

.build-title {
  margin: 4px 0 14px;
  font-family: var(--serif);
  font-size: 26px;
  color: var(--red-deep);
  text-align: center;
}

.build-image {
  position: relative;
  width: 100%;
  height: min(44vh, 340px);
  border-radius: 16px;
  overflow: hidden;
  background: #2a1a12 center / cover no-repeat;
  border: 1px solid rgba(59, 42, 30, 0.15);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.28);
}

.build-tiles {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.build-tile {
  display: grid;
  place-items: center;
  background:
    repeating-linear-gradient(135deg, rgba(28, 19, 13, 0.96) 0 10px, rgba(47, 32, 22, 0.96) 10px 20px);
  border: 1px solid rgba(255, 230, 176, 0.12);
  color: rgba(255, 230, 176, 0.55);
  font-family: var(--serif);
  font-size: 26px;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.build-tile::after { content: "？"; }

.build-tile.revealed {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}

.build-tile.revealed::after { content: ""; }

.build-progress {
  margin-top: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.build-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.build-actions .btn { flex: 1; }

.map-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.map-chapter {
  grid-column: 1 / -1;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(59, 42, 30, 0.16);
  font-family: var(--serif);
  font-size: 15px;
  color: var(--red-deep);
}

.map-node {
  position: relative;
  min-height: 64px;
  border-radius: 12px;
  border: 1px solid rgba(59, 42, 30, 0.14);
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--sans);
}

.map-node b { display: block; font-size: 17px; }
.map-node span { display: block; margin-top: 2px; font-size: 9px; color: var(--gold); letter-spacing: 1px; }
.map-node.locked { opacity: 0.35; cursor: not-allowed; background: rgba(59, 42, 30, 0.06); }
.map-node.current { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.14); }
.map-node.done { background: rgba(217, 164, 65, 0.12); }

@media (max-width: 520px) {
  .build-card, .map-card { padding: 16px; }
  .build-image { height: 220px; }
  .build-tile { font-size: 18px; }
  .map-grid { grid-template-columns: repeat(5, 1fr); gap: 5px; }
  .map-node { min-height: 52px; }
  .map-node b { font-size: 14px; }
}


.mock-tag {
  position: fixed;
  right: 18px;
  bottom: 16px;
  z-index: 20;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(35, 22, 14, 0.72);
  border: 1px solid rgba(255, 230, 176, 0.22);
  color: #d9b98a;
  font-size: 10px;
  letter-spacing: 0.12em;
}

.xp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.xp-lv {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--red-deep);
  white-space: nowrap;
}

.xp-track {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: rgba(59, 42, 30, 0.1);
  overflow: hidden;
}

.xp-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--green));
  transition: width 0.3s ease;
}

.xp-num { font-size: 9px; color: var(--muted); white-space: nowrap; }

.unlock-hint {
  margin-top: 4px;
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.unlock-hint b { color: var(--red-deep); }

.repair-box {
  margin-top: 9px;
  padding: 9px 10px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(59, 42, 30, 0.1);
}

.repair-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink);
}

.repair-head b { font-family: var(--serif); font-size: 14px; color: var(--red-deep); }
.repair-head span { color: var(--muted); font-size: 9px; }

.repair-steps {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-top: 7px;
}

.repair-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 2px;
  border-radius: 8px;
  border: 1px solid transparent;
  opacity: 0.34;
  font-size: 8px;
  color: var(--ink-soft);
  transition: all 0.3s ease;
}

.repair-step .ico {
  font-size: 17px;
  line-height: 1.1;
  filter: grayscale(1);
}

.repair-step.current {
  opacity: 1;
  border-color: rgba(196, 85, 59, 0.4);
  background: rgba(196, 85, 59, 0.06);
}

.repair-step.current .ico {
  filter: none;
  animation: repairStepPulse 1.6s ease-in-out infinite;
}

.repair-step.done {
  opacity: 1;
  background: rgba(217, 164, 65, 0.16);
}

.repair-step.done .ico { filter: none; }

.repair-step.just-fixed {
  animation: repairPop 0.5s ease-out;
}

@keyframes repairStepPulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

.repair-rule {
  margin-top: 6px;
  font-size: 9px;
  line-height: 1.45;
  color: var(--red-deep);
}

.repair-track {
  width: 100%;
  height: 5px;
  margin-top: 6px;
  border-radius: 999px;
  background: rgba(59, 42, 30, 0.1);
  overflow: hidden;
}

.repair-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--gold));
  transition: width 0.35s ease;
}

.build-note {
  margin: -6px 0 12px;
  text-align: center;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

.repair-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  font-size: 9px;
  color: var(--muted);
}

.repair-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(59, 42, 30, 0.1);
  overflow: hidden;
}

.repair-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--gold));
  transition: width 0.35s ease;
}

.repair-row b {
  color: var(--red-deep);
  font-size: 9px;
  white-space: nowrap;
}

.repair-badge {
  display: inline-flex;
  align-items: center;
  margin-top: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(217, 164, 65, 0.14);
  border: 1px solid rgba(217, 164, 65, 0.35);
  color: var(--red-deep);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.repair-badge[hidden] { display: none; }

.build-mini {
  margin-top: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px dashed rgba(196, 85, 59, 0.35);
  background: transparent;
  color: var(--red-deep);
  font-size: 9px;
  cursor: pointer;
}

.build-mini b { color: var(--gold); }

.street-scene {
  position: relative;
  width: min(100%, 560px);
  height: 132px;
  margin-bottom: 8px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background:
    linear-gradient(180deg, rgba(20, 32, 48, 0.92), rgba(42, 28, 18, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 8px 18px rgba(40, 20, 10, 0.16);
  transition: filter 0.35s ease;
}

.street-scene::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: var(--scene);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0.16;
  filter: grayscale(0.7) blur(1px);
}

.street-scene.show-before {
  filter: grayscale(1) brightness(0.62);
}

.street-moon {
  position: absolute;
  right: 13%;
  top: 12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f7df9e;
  opacity: 0.35;
  box-shadow: 0 0 20px rgba(247, 223, 158, 0.35);
  z-index: 1;
}

.street-shop { position: absolute; inset: 0; z-index: 1; }

.street-sign {
  position: absolute;
  left: 50%;
  top: 13px;
  transform: translateX(-50%) rotate(-4deg);
  padding: 4px 14px;
  border-radius: 4px;
  background: #5c4a3b;
  border: 1px solid #7a6652;
  color: #b7a58e;
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.12em;
  opacity: 0.55;
  transition: all 0.45s ease;
}

.street-sign.fixed {
  transform: translateX(-50%) rotate(0deg);
  background: linear-gradient(180deg, #f0cb78, #b9792a);
  border-color: #ffe6a8;
  color: #3a1d08;
  opacity: 1;
  box-shadow: 0 0 16px rgba(255, 205, 100, 0.5);
}

.street-lantern {
  position: absolute;
  top: 38px;
  width: 18px;
  height: 25px;
  border-radius: 50%;
  background: #3d2a20;
  border: 1px solid rgba(255, 230, 176, 0.15);
  opacity: 0.4;
  transition: all 0.45s ease;
}

.street-lantern.l { left: 15%; }
.street-lantern.r { right: 15%; }

.street-lantern.fixed {
  background: radial-gradient(circle at 35% 30%, #ff8a64, #a52d1e);
  border-color: rgba(255, 230, 176, 0.7);
  opacity: 1;
  box-shadow: 0 0 22px rgba(255, 95, 60, 0.7);
  animation: lanternSway 3.2s ease-in-out infinite;
}

@keyframes lanternSway {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}

.street-counter {
  position: absolute;
  left: 50%;
  bottom: 20px;
  width: 42%;
  height: 24px;
  transform: translateX(-50%);
  border-radius: 4px 4px 2px 2px;
  background: #3f3026;
  border: 1px solid rgba(255, 230, 176, 0.12);
  opacity: 0.5;
  transition: all 0.45s ease;
}

.street-counter.fixed {
  background: linear-gradient(180deg, #d8a766, #7c4c22);
  border-color: rgba(255, 230, 176, 0.4);
  opacity: 1;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.street-counter i {
  display: none;
  position: absolute;
  bottom: 100%;
  width: 11px;
  height: 13px;
  border-radius: 3px;
  background: #d9b16d;
  border: 1px solid rgba(255, 230, 176, 0.45);
}

.street-counter.fixed i { display: block; }
.street-counter i:nth-child(1) { left: 28%; }
.street-counter i:nth-child(2) { left: 48%; }

.street-shelf {
  position: absolute;
  left: 7%;
  bottom: 20px;
  width: 17%;
  height: 42px;
  border: 1px solid rgba(255, 230, 176, 0.12);
  background: #3b2a1e;
  opacity: 0.45;
  transition: all 0.45s ease;
}

.street-shelf.fixed {
  background: linear-gradient(180deg, #8f5a2f, #4d2b16);
  border-color: rgba(255, 230, 176, 0.35);
  opacity: 1;
}

.street-shelf i {
  display: none;
  position: absolute;
  bottom: 4px;
  width: 10px;
  height: 12px;
  border-radius: 2px;
  background: #d9a441;
}

.street-shelf.fixed i { display: block; }
.street-shelf i:nth-child(1) { left: 6px; }
.street-shelf i:nth-child(2) { left: 21px; }
.street-shelf i:nth-child(3) { left: 36px; }

.street-door {
  position: absolute;
  right: 7%;
  bottom: 20px;
  width: 17%;
  height: 56px;
  border: 1px solid rgba(255, 230, 176, 0.12);
  background: #34241a;
  opacity: 0.55;
  transition: all 0.45s ease;
}

.street-door.fixed {
  background: linear-gradient(180deg, #ffd98b, #7a3f1d);
  border-color: rgba(255, 230, 176, 0.5);
  opacity: 1;
  box-shadow: 0 0 22px rgba(255, 200, 100, 0.35);
}

.street-door span,
.street-door span::before,
.street-door span::after {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 80%;
  height: 3px;
  background: #7a6652;
  content: "";
  transform: translate(-50%, -50%) rotate(45deg);
}

.street-door span::before { transform: translate(-50%, -50%) rotate(-45deg); }
.street-door span::after { transform: translate(-50%, -50%) rotate(90deg); }
.street-door.fixed span { display: none; }

.street-caption {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 6px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #ffe6b0;
  font-size: 10px;
  letter-spacing: 0.04em;
}

.street-caption b { color: #ffd166; }

.street-compare {
  border: 1px solid rgba(255, 230, 176, 0.28);
  border-radius: 999px;
  background: rgba(35, 22, 14, 0.62);
  color: #ffe6b0;
  font-size: 9px;
  padding: 3px 8px;
  cursor: pointer;
}

.street-compare:active { transform: scale(0.97); }

@keyframes repairPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.street-sign.just-fixed,
.street-lantern.just-fixed,
.street-counter.just-fixed,
.street-shelf.just-fixed,
.street-door.just-fixed {
  animation: repairPop 0.45s ease-out;
}

.task-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 14px;
  font-family: var(--serif);
  font-size: 16px;
  color: var(--ink);
}

.task-title span { font-family: var(--sans); font-size: 10px; color: var(--muted); }

.task-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }

.task-more {
  margin-top: 5px;
  font-size: 9px;
  color: var(--muted);
  text-align: right;
}

.task-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(59, 42, 30, 0.1);
  transition: background 0.2s ease, opacity 0.2s ease;
}

.task-card.ready {
  border-color: rgba(196, 85, 59, 0.35);
  background: rgba(196, 85, 59, 0.07);
}

.task-card.done { opacity: 0.52; }

.task-ico {
  position: relative;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(59, 42, 30, 0.08);
}

.task-ico img { width: 32px; height: 32px; object-fit: contain; }
.task-ico .emoji { display: none; font-size: 25px; }
.task-ico .emoji.show { display: block; }
.task-ico.noimg .emoji { display: block; }
.task-ico.noimg img { display: none; }

.task-info { flex: 1; min-width: 0; }
.task-name { font-size: 12px; font-weight: 700; color: var(--ink); }
.task-name small { font-weight: 400; color: var(--muted); font-size: 9px; }
.task-progress {
  height: 4px;
  margin-top: 4px;
  border-radius: 999px;
  background: rgba(59, 42, 30, 0.1);
  overflow: hidden;
}
.task-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--gold);
}
.task-reward { font-size: 9px; color: var(--muted); margin-top: 2px; }

.task-btn {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid rgba(59, 42, 30, 0.16);
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.task-btn.primary {
  border-color: transparent;
  background: linear-gradient(180deg, #cf6448, var(--red-deep));
  color: #fff7e7;
}

.task-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.cell .emoji.show { display: block; }

.cell.generator {
  cursor: pointer;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 238, 190, 0.9), rgba(243, 228, 202, 0.95));
  border: 2px solid rgba(217, 164, 65, 0.55);
  box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.08), 0 6px 14px rgba(80, 40, 20, 0.12);
}

.cell.generator.depleted {
  filter: saturate(0.45);
  border-color: rgba(59, 42, 30, 0.2);
}

.cell.generator .gen-emoji {
  font-size: 30px;
  line-height: 1;
  filter: drop-shadow(0 4px 4px rgba(80, 40, 20, 0.16));
}

.cell.generator .gen-name {
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 8px;
  color: var(--ink-soft);
}

.cell.generator .gen-charge {
  position: absolute;
  top: 3px;
  left: 4px;
  padding: 1px 4px;
  border-radius: 5px;
  background: rgba(59, 42, 30, 0.7);
  color: #ffe6b0;
  font-size: 8px;
  line-height: 13px;
}

.cell.generator .gen-cool {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: 7px;
  color: var(--red-deep);
  background: rgba(255, 250, 240, 0.8);
  border-radius: 4px;
  padding: 0 2px;
}

.cell.generator .gen-cool.ready { color: var(--green); }

@media (max-width: 1080px) {
  .layout { grid-template-columns: 230px minmax(0, 1fr) 240px; gap: 12px; }
  .panel { padding: 14px; }
  .brand-main { font-size: 26px; }
}

@media (max-width: 900px) {
  body { padding: 0; }
  .page { padding: 12px 10px 20px; gap: 10px; }
  .topbar { padding: 2px 2px 0; }
  .brand-main { font-size: 23px; }
  .brand-sub { font-size: 9px; }
  .pill { height: 32px; padding: 0 9px; font-size: 11px; }
  .pill b { font-size: 13px; }
  .icon-btn { width: 32px; height: 32px; }
  .layout { display: flex; flex-direction: column; gap: 10px; }
  .level-panel {
    order: 0;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    padding: 12px 14px;
  }
  .level-panel .chapter,
  .level-panel .level-sub,
  .level-panel .stars-note { display: none; }
  .level-title { margin: 0; font-size: 20px; }
  .level-title b { font-size: 26px; }
  .xp-row, .task-title, .task-list, .task-more, .repair-row { grid-column: 1 / -1; }
  .xp-row { margin-top: 6px; }
  .task-title { margin-top: 8px; font-size: 14px; }
  .task-list { margin-top: 5px; gap: 4px; }
  .task-card { padding: 6px 7px; }
  .task-ico { width: 32px; height: 32px; flex-basis: 32px; }
  .task-ico img { width: 27px; height: 27px; }
  .task-ico .emoji { font-size: 21px; }
  .task-name { font-size: 11px; }
  .task-btn { min-height: 25px; font-size: 9px; padding: 0 6px; }
  .cell.generator .gen-emoji { font-size: 24px; }
  .cell.generator .gen-name { font-size: 7px; }
  .cell.generator .gen-charge { font-size: 7px; line-height: 11px; }
  .cell.generator .gen-cool { font-size: 6px; }
  .objective { margin: 8px 0 0; padding: 9px 10px; grid-column: 1 / -1; }
  .obj-item img, .obj-item .emoji { width: 40px; height: 40px; }
  .obj-name b { font-size: 15px; }
  .stars-line { margin: 0; font-size: 18px; justify-self: end; align-self: start; }
  .level-actions { grid-column: 1 / -1; flex-direction: row; margin: 2px 0 0; }
  .level-actions .btn { flex: 1; min-height: 38px; }
  .board-wrap { order: 1; padding: 8px; border-radius: 18px; }
  .street-scene { height: 96px; margin-bottom: 6px; border-radius: 12px; }
  .street-sign { top: 7px; font-size: 10px; padding: 3px 10px; }
  .street-lantern { top: 26px; width: 14px; height: 19px; }
  .street-counter { bottom: 14px; height: 18px; width: 46%; }
  .street-counter i { width: 8px; height: 9px; }
  .street-shelf { bottom: 14px; height: 32px; width: 18%; }
  .street-shelf i { width: 7px; height: 8px; }
  .street-shelf i:nth-child(1) { left: 4px; }
  .street-shelf i:nth-child(2) { left: 14px; }
  .street-shelf i:nth-child(3) { left: 24px; }
  .street-door { bottom: 14px; height: 42px; width: 18%; }
  .street-caption { bottom: 3px; font-size: 8px; }
  .street-compare { font-size: 8px; padding: 2px 6px; }
  .board-head { margin-bottom: 4px; }
  .board-head b { font-size: 15px; }
  .board-head span { font-size: 10px; }
  .board { gap: 3px; padding: 6px; border-radius: 14px; }
  .cell { border-radius: 8px; }
  .cell .tier { top: 2px; left: 3px; height: 12px; min-width: 12px; line-height: 12px; font-size: 8px; }
  .cell .nm { display: none; }
  .cell .emoji { font-size: 24px; }
  .board-actions { margin-top: 7px; gap: 5px; grid-template-columns: repeat(3, 1fr); }
  .board-actions .btn { min-height: 38px; font-size: 10px; border-radius: 9px; }
  .chain-panel { order: 2; padding: 12px 14px; }
  .chain-title { font-size: 15px; }
  .chain { display: grid; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(8, auto); gap: 2px 8px; }
  .ch-row { padding: 4px 5px; }
  .ch-row img, .ch-row .emoji { width: 24px; height: 24px; font-size: 16px; }
  .ch-row .ch-name { font-size: 10px; }
  .ch-row .ch-lv { display: none; }
  .cat { margin-top: 10px; padding-top: 9px; }
  .cat img { width: 42px; height: 42px; }
  .cat-tx { font-size: 10px; }
}

@media (max-width: 520px) {
  .brand-main em { display: none; }
  .brand-main { font-size: 21px; }
  .top-stats .pill:nth-child(1) { display: none; }
  .chain { grid-template-columns: 1fr 1fr; }
}
