:root {
  --ink: #2b2723;
  --paper: rgba(250, 248, 244, 0.92);
  --line: rgba(43, 39, 35, 0.14);
  --accent: #b8823a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #e9e6e0; color: var(--ink);
  font: 14px/1.4 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }

#loader { position: fixed; inset: 0; display: grid; place-content: center; gap: 14px; justify-items: center;
  background: #efece6; z-index: 10; transition: opacity .5s; }
#loader.done { opacity: 0; pointer-events: none; }
#loader p { margin: 0; letter-spacing: .02em; }
#lbarRow { display: grid; gap: 8px; justify-items: center; }
#lbarRow .lbar { width: min(260px, 70vw); height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
#lbarRow .lbar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .25s linear; }
#lbarRow small { color: #6b645c; font-size: 12.5px; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: sp 0.9s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

.ui { position: fixed; z-index: 5; }
button, select { font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; backdrop-filter: blur(6px); }
button:hover, select:hover { border-color: rgba(43, 39, 35, 0.35); }

#topbar { top: 14px; right: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100vw - 28px); }
#topbar .legal { font-size: 12px; color: #6b645c; text-decoration: none; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
#topbar .legal:hover { color: var(--ink); }
#topbar .cta { font-size: 13px; font-weight: 600; color: #fff; background: var(--ink); text-decoration: none; border-radius: 8px; padding: 8px 12px; }
#bootRetry { margin-top: 12px; font: inherit; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--paper); }
.seg button { border: 0; border-radius: 0; background: transparent; }
.seg button.on { background: var(--ink); color: #fff; }

#minimap { top: 14px; left: 14px; width: 220px; height: 191px; background: rgba(255, 255, 255, 0.9);
  border-radius: 10px; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12); cursor: crosshair; }

#sel { left: 50%; bottom: 64px; transform: translateX(-50%); display: flex; gap: 6px; align-items: center;
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 6px 6px 6px 14px; }
#sel .name { font-weight: 600; margin-right: 6px; }

#help { left: 50%; bottom: 14px; transform: translateX(-50%); background: var(--paper); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 14px; font-size: 13px; white-space: nowrap; max-width: calc(100vw - 28px); overflow: hidden; text-overflow: ellipsis; }

#joy { display: none; left: 22px; bottom: 70px; width: 110px; height: 110px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.35); border: 1px solid rgba(255, 255, 255, 0.7); touch-action: none; }
#joy i { position: absolute; left: 35px; top: 35px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 255, 255, 0.85); }
#jumpBtn { display: none; right: 26px; bottom: 90px; width: 74px; height: 74px; border-radius: 50%; padding: 0; font-weight: 600; touch-action: none; }
#hint { left: 50%; top: 58%; transform: translateX(-50%); background: rgba(20, 18, 16, 0.62); color: #fff; padding: 6px 12px; border-radius: 8px; font-size: 13px; pointer-events: none; }
@media (pointer: coarse) { #joy, #jumpBtn { display: block; } #help { display: none; } }

#errbadge { left: 14px; bottom: 14px; background: #a3362a; color: #fff; padding: 6px 10px; border-radius: 8px; font-size: 12px; }

@media (max-width: 640px) {
  #minimap { width: 150px; height: 130px; }
  #topbar { top: 10px; right: 10px; }
}

/* the hidden attribute loses to display:flex above (reference-hidden-attribute-loses-to-css) */
[hidden] { display: none !important; }

/* screenshots for the Creator/Critic loop: canvas only */
body.shot .ui, body.shot #loader { display: none !important; }

/* generated houses: catalog panel */
.gen-panel { top: 64px; right: 14px; width: 300px; max-height: calc(100vh - 140px); overflow: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 13px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12); }
.gen-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gen-x { border: 0; background: none; font-size: 18px; line-height: 1; cursor: pointer; padding: 2px 6px; }
.gen-hint { color: #6b645c; font-size: 12px; margin: 6px 0; }
.gen-cat { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.gen-cat h4 { grid-column: 1 / -1; margin: 8px 0 0; font-size: 12px; color: #6b645c; }
.gen-item { display: flex; align-items: center; gap: 6px; text-align: left; padding: 4px; font-size: 12px; min-width: 0; }
.gen-item img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; background: #eee; flex: none; }
.gen-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gen-row { display: flex; gap: 6px; margin-top: 8px; }
.gen-row input { flex: 1; min-width: 0; }
.gen-save { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.gen-save input { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
.gen-save a { font-size: 12px; color: #6b645c; }
.gen-panel button.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.gen-toast { top: 64px; left: 50%; transform: translateX(-50%); max-width: min(520px, calc(100vw - 28px)); background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 36px 10px 14px; font-size: 13px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14); }
.gen-toast.warn { background: #fff4e3; border-color: #e3b46a; }
.gen-toast p { margin: 6px 0; color: #5d4a2c; }
.gen-toast a { font-weight: 600; color: var(--ink); }
.gen-toast .gen-x { position: absolute; top: 6px; right: 6px; }
.gen-size { margin-top: 10px; padding: 8px; border: 1px dashed rgba(184, 130, 58, 0.6); border-radius: 8px; background: rgba(255, 250, 241, 0.9); }
.gen-size b { font-size: 12px; }
.gen-size input { width: 64px; flex: none; font: inherit; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; }
.gen-size .gen-row { align-items: center; margin-top: 6px; }
.gen-size .gen-fin { display: block; margin-top: 8px; }
.gen-size .gen-row > span { width: 30px; flex: none; }
.gen-size input[type=color] { width: 44px; height: 28px; padding: 0 2px; }
.gen-size select { flex: none; }
.gen-panel button:disabled { opacity: 0.5; cursor: default; }
/* 3D wall editor (src/gen/walledit.js): buttons wrap; end buttons carry the colours of the end markers */
.wall-panel .gen-row { flex-wrap: wrap; }
.wall-panel .gen-row button { flex: 1 1 auto; font-size: 12px; padding: 6px 8px; }
.wall-panel button.end-a { border-color: #2f7bff; color: #1d55c4; }
.wall-panel button.end-b { border-color: #ff7a1a; color: #b8520c; }
.wall-panel button.on { background: #35c46a; border-color: #35c46a; color: #fff; }
.deck-side { align-items: center; margin-top: 4px !important; }
.deck-side span { flex: 0 0 64px; font-size: 12px; font-weight: 600; }
.wall-panel .deck-side button { flex: 1 1 0; }
.side-n { color: #1d55c4; border-color: #2f7bff !important; }
.side-s { color: #b8520c; border-color: #ff7a1a !important; }
.side-w { color: #157a3c; border-color: #1fae55 !important; }
.side-e { color: #6b33a3; border-color: #9b51e0 !important; }
.wall-sel { margin-top: 6px; padding: 6px 8px 8px; border: 1px dashed rgba(255, 176, 0, 0.8); border-radius: 8px; background: rgba(255, 248, 230, 0.9); }
#wallToggle.on, #genToggle.on { background: var(--ink); color: #fff; }
/* 2D floor-plan download (src/gen/drawing.js): preview sheet over the 3D view */
.gen-draw b { font-size: 12px; }
.gen-credits { margin-top: 6px; font-size: 12px; }
.gen-credits summary { cursor: pointer; color: #6b645c; }
.gen-credits input { font: inherit; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; min-width: 0; }
.gen-credits input[type=number] { width: 56px; flex: none; }
.draw-modal { top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(920px, calc(100vw - 28px)); max-height: calc(100vh - 40px); overflow: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25); z-index: 30; font-size: 13px; }
.draw-modal figure { margin: 12px 0 0; }
.draw-modal img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.draw-modal figcaption { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: #6b645c; font-size: 12px; }
.draw-modal figcaption button { padding: 4px 10px; font-size: 12px; }
@media (max-width: 700px) { .gen-panel { top: auto; bottom: 10px; right: 10px; left: 10px; width: auto; max-height: 55vh; } }
