/* Cave appearance only. Load after styles.css/effects.css.
   Grid columns, facility art geometry, FX coordinates and resident positions stay owned
   by the existing world renderer. The terrain PNG is also used by the offline builder. */
:root {
  --cave-roof: 18px;
  --cave-rubble: 16px;
  --cave-rock: #393b34;
  --cave-earth: #211f1a;
  --cave-texture: url('assets/terrain/cavern.png');
}
.soil {
  background-color: var(--cave-earth);
  background-image:
    linear-gradient(180deg, #34372cc2, #181c1be8),
    repeating-linear-gradient(164deg, transparent 0 43px, #9d8e6f14 45px 48px, transparent 52px 107px),
    radial-gradient(ellipse at 12% 30%, #97856830, transparent 52%),
    var(--cave-texture);
  background-size: auto, 730px 310px, 900px 540px, 1200px auto;
  background-blend-mode: normal, normal, normal, soft-light;
  box-shadow: inset 0 18px 24px #0005;
  padding-top: 10px;
}
.floor-row-wrapper {
  position: relative;
  margin-bottom: 12px;
  background: linear-gradient(173deg, #76644813, transparent 45%, #090d101a);
}
.floor-caption {
  position: relative;
  z-index: 3;
  border: 0;
  background: linear-gradient(90deg, #171d1aca, #292d2478 55%, #282a200a);
  box-shadow: none;
  color: #a9b5a9;
  text-shadow: 0 2px 3px #000;
}
.floor-caption strong { color: #dedbca; }
.floor-caption > span { color: #a6b2a1; }
.floor-expand {
  background: #17231d9e;
  border-color: #96987540;
  color: #d5cda3;
}
/* One excavated opening across the entire floor, not one tile per facility. */
.floor-row,
.floor-row[data-zones="4"],
.floor-row[data-zones="6"] {
  isolation: isolate;
  padding-block: var(--cave-roof) var(--cave-rubble);
  background: transparent;
  overflow: visible;
}
.floor-row::before {
  content: "";
  position: absolute;
  z-index: -2;
  inset: 0;
  pointer-events: none;
  background-color: #28302b;
  background-image:
    linear-gradient(180deg, #060b0cb3, #15201c26 38%, #8a81602b 84%, #151b1ae8),
    radial-gradient(ellipse at 58% 72%, #c5b98425, transparent 70%),
    var(--cave-texture);
  background-size: auto, auto, 100% 100%;
  background-position: center;
  background-blend-mode: normal, normal, normal;
  clip-path: polygon(0 18%, 1.5% 11%, 4% 7%, 7% 9%, 10% 4%, 14% 6%, 18% 3%, 22% 6%, 27% 4%, 32% 7%, 37% 3%, 42% 5%, 46% 2%, 51% 5%, 56% 3%, 61% 7%, 67% 4%, 72% 6%, 77% 3%, 82% 7%, 87% 5%, 92% 8%, 97% 11%, 100% 19%, 100% 91%, 97% 95%, 92% 93%, 88% 97%, 82% 94%, 76% 96%, 70% 93%, 65% 97%, 59% 95%, 53% 98%, 47% 95%, 42% 97%, 36% 94%, 30% 96%, 24% 93%, 18% 97%, 13% 94%, 8% 96%, 3% 93%, 0 88%);
}
.floor-row::after {
  content: "";
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--cave-rubble);
  pointer-events: none;
  background-image:
    radial-gradient(ellipse at 17px 11px, #625d46 0 6px, #272e27 7px 10px, transparent 11px),
    radial-gradient(ellipse at 37px 14px, #74684b 0 4px, #363b2d 5px 8px, transparent 9px),
    linear-gradient(0deg, #22271de0, transparent);
  background-size: 93px 19px, 137px 18px, auto;
  opacity: .85;
}
/* No cell frames. Only the illustration is masked, so UI and residents stay clear.
   Container units bound an oversized cover scene to its slot without rescaling it. */
.room,
.room.empty,
.room.constructing,
.room.selected,
.room:hover,
.room.empty:hover {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}
.room { container-type: inline-size; }
.room-scene {
  z-index: 0;
  --cave-opening: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201000%20400%22%20preserveAspectRatio%3D%22none%22%3E%3Cdefs%3E%3Cfilter%20id%3D%22soft%22%3E%3CfeGaussianBlur%20stdDeviation%3D%225%22%2F%3E%3C%2Ffilter%3E%3C%2Fdefs%3E%3Cpath%20fill%3D%22white%22%20filter%3D%22url(%23soft)%22%20d%3D%22M58%20316%20L45%20281%20L53%20245%20L45%20209%20L55%20168%20L52%20139%20Q60%20128%2090%20124%20L130%20118%20L178%20121%20L224%20115%20L270%20119%20L325%20113%20L370%20117%20L424%20112%20L480%20116%20L530%20111%20L584%20118%20L630%20114%20L680%20121%20L734%20117%20L780%20122%20L824%20119%20L866%20124%20L918%20126%20Q938%20130%20947%20140%20L944%20178%20L952%20214%20L943%20260%20L950%20290%20L940%20316%20L912%20321%20L864%20317%20L808%20322%20L746%20316%20L684%20321%20L620%20315%20L558%20320%20L490%20316%20L424%20322%20L358%20316%20L290%20321%20L224%20315%20L158%20320%20L104%20315%20Z%22%2F%3E%3C%2Fsvg%3E");
  -webkit-mask-image: var(--cave-opening);
  mask-image: var(--cave-opening);
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
}
.room-scene[data-art-size="2"],
.room-scene[data-art-size="3"],
.room-scene[data-art-size="4"] {
  --cave-opening: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201000%20400%22%20preserveAspectRatio%3D%22none%22%3E%3Cdefs%3E%3Cfilter%20id%3D%22soft%22%3E%3CfeGaussianBlur%20stdDeviation%3D%225%22%2F%3E%3C%2Ffilter%3E%3C%2Fdefs%3E%3Cpath%20fill%3D%22white%22%20filter%3D%22url(%23soft)%22%20d%3D%22M25%20334%20L18%20303%20L25%20258%20L18%20210%20L22%20149%20L20%20106%20Q30%2097%2056%2094%20L104%2090%20L156%2093%20L212%2089%20L268%2093%20L324%2090%20L380%2095%20L438%2091%20L492%2094%20L550%2089%20L606%2093%20L664%2090%20L720%2095%20L776%2091%20L834%2094%20L892%2091%20L950%2096%20Q973%2099%20980%20109%20L978%20157%20L984%20199%20L978%20251%20L984%20296%20L975%20334%20L926%20339%20L868%20334%20L806%20340%20L748%20334%20L688%20339%20L626%20333%20L566%20338%20L504%20333%20L442%20339%20L380%20334%20L318%20339%20L254%20333%20L192%20338%20L130%20333%20L70%20339%20Z%22%2F%3E%3C%2Fsvg%3E");
}
@supports (width: 1cqw) {
  .room-scene {
    -webkit-mask-size: 100cqw 100%;
    mask-size: 100cqw 100%;
  }
}
/* Foreground rock is shading, never a transformed scene or equipment layer. */
.room::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 0 5%, #2b3024c2, transparent 16%),
    radial-gradient(ellipse at 100% 10%, #2e3124bd, transparent 15%),
    linear-gradient(0deg, #302f2080, transparent 14%);
}
.room::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(0deg, #0e1814a6, transparent 27%);
  border-radius: 35% 31% 8% 12% / 20% 23% 5% 7%;
}
.room-top, .room-bottom, .empty-content { z-index: 4; }
.room-bottom { align-items: flex-end; flex-wrap: wrap; gap: 3px 7px; }
.room-bottom strong {
  padding: 1px 6px;
  color: #ece7d4;
  border-radius: 4px;
  background: #101b17b3;
  text-shadow: 0 2px 3px #000;
  white-space: normal;
}
.room-bottom small { background: #101b17d9; color: #d3e3ce; }
.room-top .level-badge, .room-top .size-badge {
  background: #16231ccb;
  border-color: #a6b39a42;
  box-shadow: 0 1px 3px #0006;
}
.empty-content {
  position: relative;
  max-width: calc(100% - 20px);
  padding: 9px 10px;
  border-radius: 45% 38% 34% 40%;
  background: radial-gradient(ellipse, #25362bab, #25362b00 72%);
  text-shadow: 0 2px 4px #000;
}
.empty-content strong { color: #c4cfb7; }
.empty-content small { color: #a8b59b; }
.empty-content svg { color: #b2c8ae; opacity: .7; }
.room.empty::after {
  background: radial-gradient(ellipse at 50% 80%, #a99c6821, transparent 72%), linear-gradient(0deg, #16241966, transparent 36%);
}
/* Transient overlays preserve placement/anchor feedback without permanent gold boxes. */
.room:hover::after { background-color: #a4c39a10; }
.room.selected::after,
.room:focus-visible::after {
  background: linear-gradient(0deg, #d7b96f24, transparent 46%);
  box-shadow: inset 0 -3px 0 #e0c887b3, inset 0 -13px 20px -16px #ebd48d;
}
.room.selected .room-bottom strong { color: #ffe1a5; background: #302d1dd9; }
.room:focus-visible { outline: 2px solid #9bcdbb; outline-offset: 3px; }
.room.placement-preview, .room.placement-conflict {
  outline: none;
  border: 0;
  box-shadow: none;
}
.room.placement-preview::after {
  background: linear-gradient(0deg, #78d0ad48, #78d0ad0d 75%);
  box-shadow: inset 0 0 0 2px #92dec0ba, inset 0 -12px 25px #83d3b02b;
}
.room.placement-conflict::after {
  background: linear-gradient(0deg, #e28f7f42, #e28f7f0a 75%);
  box-shadow: inset 0 0 0 2px #e59a91ca, inset 0 -12px 25px #ce7b7130;
}
.room.constructing .empty-content strong { color: #e6d6aa; }
/* A narrow, open lift shaft cut into rock, with rails and one understated cage. */
.shared-elevator {
  height: calc(var(--floor-height) + var(--cave-roof) + var(--cave-rubble));
  min-height: 0;
  margin-block: calc(-1 * var(--cave-roof)) calc(-1 * var(--cave-rubble));
  border: 0;
  border-radius: 42% 35% 19% 25% / 8% 7% 4% 6%;
  background: linear-gradient(90deg, #4c4d32a1, #101d17 23%, #263b30 50%, #132219 76%, #4b4a3299);
  box-shadow: inset 0 0 12px #0007;
  overflow: visible;
  z-index: 1;
}
.shared-elevator::before {
  inset: 0 11px;
  border-inline: 1px solid #97a68a69;
  background: repeating-linear-gradient(0deg, transparent 0 30px, #9ba18130 30px 32px);
}
.shared-elevator::after {
  top: 38%;
  left: 10px;
  right: 10px;
  height: 48px;
  border: 1px solid #a6b19a8c;
  border-radius: 7px 7px 5px 5px;
  background: linear-gradient(90deg, #566251ae, #25382de0 44%, #93a08955 48% 52%, #3e5141bb 56%);
  box-shadow: 0 -3px 0 #b4b78860, 0 4px 8px #0007;
}
.dig-site, .dig-site.manual {
  border-top: 0;
  border-radius: 28px 39px 0 0 / 13px 19px 0 0;
  box-shadow: inset 0 8px 18px #151b1b66;
}
.bedrock {
  background: linear-gradient(180deg, #242a20cc, #131d19), repeating-linear-gradient(167deg, transparent 0 35px, #9c896817 38px 41px);
  border-top: 0;
  color: #97a48d;
}
@media (max-width: 800px) {
  :root { --cave-roof: 16px; --cave-rubble: 14px; }
}
@media (max-width: 600px) {
  :root { --cave-roof: 14px; }
  .floor-caption {
    position: sticky;
    left: 0;
    background: linear-gradient(90deg, #19231cf5, #283023ed);
    border-radius: 0 0 14px 0;
  }
  .room-bottom strong { font-size: 11px; }
  .room-bottom small { font-size: 9px; }
  .empty-content { padding-inline: 7px; }
}
