:root {
  color-scheme: dark;
  --bg: #151923;
  --ink: #f7f1df;
  --muted: #b7c1c0;
  --panel: #202737;
  --panel-2: #263246;
  --line: rgba(255, 255, 255, 0.14);
  --shadow: rgba(0, 0, 0, 0.35);
  --gold: #f2b84b;
  --teal: #64c4b0;
  --coral: #ec6f5d;
  --violet: #a983d8;
  --green: #7dbd62;
  --blue: #6ea8e6;
  --stone: #46526a;
  --floor-height: 124px;
  --shaft-left: 96px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 15% 12%, rgba(100, 196, 176, 0.16), transparent 28%),
    radial-gradient(circle at 92% 22%, rgba(236, 111, 93, 0.13), transparent 24%),
    linear-gradient(145deg, #111620 0%, #1c2230 48%, #172018 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  overflow: hidden;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  padding: 14px clamp(14px, 2.5vw, 30px);
  border-bottom: 1px solid var(--line);
  background: rgba(18, 24, 34, 0.92);
  backdrop-filter: blur(16px);
  box-shadow: 0 14px 34px var(--shadow);
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: clamp(20px, 2vw, 28px);
  letter-spacing: 0;
  line-height: 1;
}

.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.crest {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.16);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.crest svg,
.icon-btn svg,
.control-btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.crest svg {
  width: 38px;
  height: 38px;
  stroke: none;
}

.resources {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.resource {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 82px;
  justify-content: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.res-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  position: relative;
}

.res-icon.coin {
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #ffe89a 0 20%, #f2b84b 22% 66%, #b77a2c 68%);
  box-shadow: 0 0 0 2px rgba(242, 184, 75, 0.24);
}

.res-icon.gem {
  clip-path: polygon(50% 0, 95% 28%, 72% 100%, 28% 100%, 5% 28%);
  background: linear-gradient(140deg, #b7fff1, #51b8e9 48%, #7b70d8);
}

.res-icon.pop {
  border-radius: 50% 50% 42% 42%;
  background: linear-gradient(#ffe3bd 0 42%, #6ea8e6 43%);
}

.res-icon.pop::before,
.res-icon.pop::after {
  content: "";
  position: absolute;
  bottom: 1px;
  width: 7px;
  height: 10px;
  border-radius: 50% 50% 42% 42%;
  background: linear-gradient(#ffd6ad 0 42%, #ec6f5d 43%);
}

.res-icon.pop::before {
  left: -5px;
}

.res-icon.pop::after {
  right: -5px;
  background: linear-gradient(#ffe0b8 0 42%, #7dbd62 43%);
}

.res-icon.joy {
  border-radius: 50%;
  background: var(--green);
}

.res-icon.joy::before,
.res-icon.joy::after {
  content: "";
  position: absolute;
  top: 6px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #122116;
}

.res-icon.joy::before {
  left: 5px;
}

.res-icon.joy::after {
  right: 5px;
}

.res-icon.joy span {
  display: none;
}

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

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  cursor: pointer;
  transition:
    transform 0.12s ease,
    background 0.12s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}

.icon-btn.danger:hover {
  background: rgba(236, 111, 93, 0.2);
}

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(440px, 1fr) minmax(310px, 360px);
  gap: 18px;
  padding: 18px clamp(14px, 2.5vw, 30px) 22px;
}

.stage-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 72px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.01)),
    #121820;
  box-shadow: 0 22px 44px var(--shadow);
}

.cave-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 24% 20%, rgba(100, 196, 176, 0.18), transparent 22%),
    radial-gradient(circle at 75% 12%, rgba(242, 184, 75, 0.16), transparent 20%),
    radial-gradient(circle at 48% 86%, rgba(169, 131, 216, 0.13), transparent 28%);
}

.kingdom-scroll {
  position: absolute;
  inset: 0;
  overflow: auto;
  padding: 18px 18px 28px;
  scrollbar-color: rgba(255, 255, 255, 0.26) transparent;
}

.kingdom {
  position: relative;
  min-height: 100%;
  width: min(840px, 100%);
  margin: 0 auto;
  padding: 4px 0 14px;
}

.floor {
  position: relative;
  display: grid;
  grid-template-columns: 72px 34px minmax(0, 1fr);
  gap: 12px;
  min-height: var(--floor-height);
  margin-bottom: 8px;
  isolation: isolate;
}

.floor::before {
  content: "";
  position: absolute;
  left: 7px;
  right: 0;
  bottom: -6px;
  height: 10px;
  background:
    linear-gradient(90deg, transparent 0 74px, rgba(0, 0, 0, 0.36) 74px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 14px, transparent 14px 28px);
  border-radius: 3px;
  opacity: 0.7;
}

.floor.selected .room {
  outline: 2px solid var(--gold);
  box-shadow:
    0 0 0 4px rgba(242, 184, 75, 0.14),
    0 18px 32px rgba(0, 0, 0, 0.25);
}

.floor-index {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #10151f;
  font-weight: 800;
  border-radius: 8px;
  align-self: stretch;
  background: linear-gradient(180deg, #d4dde3, #8a99aa);
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.24);
}

.shaft {
  position: relative;
  width: 34px;
  align-self: stretch;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.18), transparent 18%, transparent 82%, rgba(255, 255, 255, 0.14)),
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0 4px, transparent 4px 14px),
    #202837;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.elevator-car {
  position: absolute;
  left: 84px;
  top: 0;
  width: 58px;
  height: 78px;
  transform: translateY(24px);
  border-radius: 8px;
  border: 2px solid #ffe49c;
  background:
    linear-gradient(90deg, transparent 47%, rgba(255, 255, 255, 0.25) 48% 52%, transparent 53%),
    linear-gradient(160deg, #f2b84b 0%, #c78039 54%, #684f42 100%);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.38),
    inset 0 4px 0 rgba(255, 255, 255, 0.2);
  z-index: 6;
  transition: transform 0.08s linear;
}

.elevator-car::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 10px;
  right: 10px;
  height: 16px;
  border-radius: 5px;
  background: rgba(39, 51, 76, 0.74);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.16);
}

.elevator-car .mini-person {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
}

.room {
  min-width: 0;
  position: relative;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  overflow: hidden;
  background: var(--room-bg, #263246);
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.room::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 36px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 42%);
  opacity: 0.72;
  pointer-events: none;
}

.floor[data-type="lobby"] .room {
  --room-bg: linear-gradient(160deg, #324c72, #24314b);
}

.floor[data-type="dwelling"] .room {
  --room-bg: linear-gradient(160deg, #4f7690, #2d5362);
}

.floor[data-type="food"] .room {
  --room-bg: linear-gradient(160deg, #a9554e, #6e3c50);
}

.floor[data-type="service"] .room {
  --room-bg: linear-gradient(160deg, #657f4f, #38594e);
}

.floor[data-type="craft"] .room {
  --room-bg: linear-gradient(160deg, #8f7544, #574660);
}

.floor[data-type="entertainment"] .room {
  --room-bg: linear-gradient(160deg, #7f5ea2, #3f4b76);
}

.floor[data-type="kingdom"] .room {
  --room-bg: linear-gradient(160deg, #b78642, #476f78);
}

.floor.constructing .room {
  --room-bg: linear-gradient(160deg, #596170, #334050);
}

.room-content {
  position: relative;
  z-index: 1;
  height: 100%;
  min-height: calc(var(--floor-height) - 6px);
  padding: 12px 14px 10px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
}

.room-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.room-title {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.type-token {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.type-token svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.room-title strong {
  display: block;
  font-size: 16px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-title small {
  display: block;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-width: 54px;
  justify-content: center;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  color: #121820;
  background: #fff1c0;
  font-weight: 800;
}

.room-scene {
  position: relative;
  min-height: 36px;
  display: flex;
  align-items: end;
  gap: 7px;
  padding-left: 4px;
}

.fixture {
  position: absolute;
  right: 12px;
  bottom: 2px;
  width: 92px;
  height: 42px;
  opacity: 0.92;
}

.fixture::before,
.fixture::after {
  content: "";
  position: absolute;
}

.fixture.dwelling::before {
  left: 0;
  bottom: 0;
  width: 76px;
  height: 25px;
  border-radius: 8px 8px 4px 4px;
  background: #f4d79d;
  box-shadow: 16px -10px 0 #5eb7a6;
}

.fixture.dwelling::after {
  left: 7px;
  bottom: 18px;
  width: 28px;
  height: 10px;
  border-radius: 6px;
  background: #f8f1dd;
}

.fixture.food::before {
  right: 8px;
  bottom: 0;
  width: 54px;
  height: 30px;
  border-radius: 7px 7px 2px 2px;
  background: #f3ca62;
  box-shadow: -34px 9px 0 #e8efe7;
}

.fixture.food::after {
  right: 18px;
  bottom: 30px;
  width: 26px;
  height: 10px;
  border-radius: 14px 14px 0 0;
  background: #ec6f5d;
}

.fixture.service::before {
  right: 4px;
  bottom: 0;
  width: 64px;
  height: 31px;
  border-radius: 6px;
  background: #dbe8ef;
  box-shadow: -38px 5px 0 #64c4b0;
}

.fixture.service::after {
  right: 15px;
  bottom: 9px;
  width: 30px;
  height: 6px;
  background: #334050;
}

.fixture.craft::before {
  right: 6px;
  bottom: 0;
  width: 68px;
  height: 21px;
  border-radius: 4px;
  background: #8a6440;
  box-shadow: -25px -13px 0 #f2b84b;
}

.fixture.craft::after {
  right: 55px;
  bottom: 16px;
  width: 24px;
  height: 24px;
  clip-path: polygon(50% 0, 62% 35%, 100% 38%, 68% 60%, 80% 100%, 50% 75%, 20% 100%, 32% 60%, 0 38%, 38% 35%);
  background: #f7f1df;
}

.fixture.entertainment::before {
  right: 14px;
  bottom: 0;
  width: 70px;
  height: 12px;
  border-radius: 6px 6px 0 0;
  background: #2d3454;
  box-shadow: 0 -18px 0 -5px #ec6f5d;
}

.fixture.entertainment::after {
  right: 33px;
  bottom: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 5px solid #f2b84b;
}

.fixture.kingdom::before {
  right: 2px;
  bottom: 0;
  width: 72px;
  height: 40px;
  clip-path: polygon(0 100%, 0 25%, 13% 25%, 13% 0, 25% 0, 25% 25%, 46% 25%, 46% 0, 59% 0, 59% 25%, 80% 25%, 80% 0, 93% 0, 93% 25%, 100% 25%, 100% 100%);
  background: #f2b84b;
}

.fixture.kingdom::after {
  right: 30px;
  bottom: 0;
  width: 16px;
  height: 23px;
  border-radius: 8px 8px 0 0;
  background: #27334c;
}

.lobby-queue {
  display: flex;
  align-items: end;
  gap: 9px;
  min-height: 44px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.visitor,
.resident-dot,
.mini-person {
  width: 28px;
  height: 34px;
  position: relative;
  flex: 0 0 auto;
  border-radius: 50% 50% 9px 9px;
  background: var(--person-color, #6ea8e6);
  box-shadow:
    inset 0 8px 0 rgba(255, 255, 255, 0.18),
    0 5px 10px rgba(0, 0, 0, 0.22);
}

.visitor {
  cursor: pointer;
  transform-origin: bottom;
  animation: bob 1.8s ease-in-out infinite;
}

.visitor:hover {
  transform: translateY(-2px);
}

@keyframes bob {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -3px;
  }
}

.visitor::before,
.resident-dot::before,
.mini-person::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 5px;
  top: -9px;
  border-radius: 50%;
  background: #ffd9ad;
  box-shadow: inset -3px -4px 0 rgba(132, 72, 42, 0.12);
}

.visitor::after,
.resident-dot::after,
.mini-person::after {
  content: "";
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  left: 10px;
  top: -2px;
  background: #1f2737;
  box-shadow: 8px 0 0 #1f2737;
}

.visitor .wish {
  position: absolute;
  left: 17px;
  top: -28px;
  min-width: 26px;
  max-width: 68px;
  height: 23px;
  padding: 2px 6px;
  border-radius: 8px 8px 8px 2px;
  display: grid;
  place-items: center;
  color: #15202d;
  background: #f8f1dd;
  border: 1px solid rgba(0, 0, 0, 0.16);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  z-index: 3;
}

.visitor.vip .wish {
  background: #dff8ff;
}

.resident-row,
.worker-row {
  display: flex;
  gap: 6px;
  align-items: center;
  min-height: 36px;
}

.resident-dot {
  width: 25px;
  height: 30px;
  animation: none;
}

.resident-dot.unemployed {
  filter: grayscale(0.3);
  opacity: 0.72;
}

.mini-person {
  width: 23px;
  height: 28px;
  animation: none;
}

.room-foot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.meter {
  height: 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.24);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.28);
}

.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  transition: width 0.2s ease;
}

.status-chip {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
}

.construction-frame {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
}

.hammer {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.14);
}

.hammer svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.build-slot .room {
  border: 1px dashed rgba(255, 255, 255, 0.26);
  background: rgba(255, 255, 255, 0.06);
}

.build-room {
  height: 104px;
  display: grid;
  place-items: center;
  padding: 14px;
}

.build-room button {
  min-height: 50px;
  padding: 0 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f2b84b, #ec6f5d);
  color: #141923;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
}

.side-panel {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
}

.panel-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(32, 39, 55, 0.9);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.22);
  padding: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1;
}

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

.passenger-box {
  min-height: 60px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.passenger-copy strong,
.floor-detail strong {
  display: block;
  font-size: 14px;
}

.passenger-copy span,
.floor-detail span,
.floor-detail p {
  color: var(--muted);
  font-size: 12px;
  margin: 3px 0 0;
  line-height: 1.4;
}

.elevator-controls {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  gap: 8px;
  margin-top: 10px;
}

.control-btn,
.wide-btn,
.detail-btn {
  min-height: 42px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.13);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  transition:
    transform 0.12s ease,
    background 0.12s ease;
}

.control-btn:hover,
.wide-btn:hover,
.detail-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.15);
}

.control-btn.primary,
.detail-btn.primary {
  background: linear-gradient(135deg, #64c4b0, #6ea8e6);
  color: #101923;
}

.wide-btn {
  width: 100%;
  margin-top: 10px;
}

.floor-jump {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.floor-jump button {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.floor-jump button.active {
  color: #111820;
  background: var(--gold);
}

.floor-detail {
  display: grid;
  gap: 10px;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  min-height: 58px;
  padding: 9px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
}

.stat b {
  display: block;
  font-size: 17px;
}

.stat span {
  margin-top: 2px;
}

.resident-list {
  display: grid;
  gap: 7px;
}

.resident-list.empty {
  min-height: 38px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.resident-card {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 7px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.resident-card strong,
.resident-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resident-card strong {
  font-size: 13px;
}

.resident-card small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.skill-pill {
  padding: 5px 7px;
  border-radius: 999px;
  color: #111820;
  background: #dff8ff;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.quests {
  display: grid;
  gap: 8px;
}

.quest {
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.quest.done {
  border-color: rgba(125, 189, 98, 0.55);
  background: rgba(125, 189, 98, 0.12);
}

.quest-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 800;
}

.quest small {
  display: block;
  color: var(--muted);
  margin-top: 5px;
}

.compact-log {
  min-height: 150px;
}

.log {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 190px;
  overflow: auto;
  padding-right: 4px;
}

.log-entry {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  padding: 7px 8px;
  border-left: 3px solid rgba(100, 196, 176, 0.6);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 0 6px 6px 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 18px;
  background: rgba(8, 12, 18, 0.66);
  backdrop-filter: blur(8px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(820px, 100%);
  max-height: min(720px, 90vh);
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #202737;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.48);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(32, 39, 55, 0.96);
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.build-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.build-option {
  min-height: 142px;
  text-align: left;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  transition:
    transform 0.12s ease,
    border-color 0.12s ease,
    background 0.12s ease;
}

.build-option:hover {
  transform: translateY(-2px);
  border-color: rgba(242, 184, 75, 0.52);
  background: rgba(255, 255, 255, 0.09);
}

.build-option:disabled {
  filter: grayscale(0.4);
}

.build-option h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.build-option p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.42;
}

.option-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.option-meta span {
  padding: 4px 7px;
  border-radius: 999px;
  color: #111820;
  background: #f8f1dd;
  font-size: 12px;
  font-weight: 800;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 140%);
  z-index: 30;
  max-width: min(460px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #121820;
  background: #f8f1dd;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.32);
  font-weight: 800;
  transition: transform 0.22s ease;
}

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

@media (max-width: 920px) {
  body {
    overflow: auto;
  }

  .app {
    min-height: 100vh;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .resources {
    justify-content: start;
  }

  .top-actions {
    position: absolute;
    right: 14px;
    top: 16px;
  }

  .layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .stage-panel {
    height: min(64vh, 640px);
  }

  .side-panel {
    overflow: visible;
  }
}

@media (max-width: 620px) {
  :root {
    --floor-height: 118px;
  }

  .layout {
    padding: 12px;
    gap: 12px;
  }

  .floor {
    grid-template-columns: 46px 28px minmax(0, 1fr);
    gap: 8px;
  }

  .elevator-car {
    left: 58px;
    width: 46px;
    height: 68px;
  }

  .floor-index {
    font-size: 13px;
  }

  .room-content {
    padding: 10px;
  }

  .fixture {
    width: 68px;
    transform: scale(0.8);
    transform-origin: right bottom;
  }

  .build-grid {
    grid-template-columns: 1fr;
  }

  .detail-actions,
  .stat-grid {
    grid-template-columns: 1fr;
  }
}
