@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=Noto+Sans+KR:wght@400;500;600;700&display=swap");

:root {
  --ink: #1d2521;
  --muted: #6d756f;
  --paper: #f3f1eb;
  --glass: rgba(247, 245, 239, 0.82);
  --line: rgba(29, 37, 33, 0.14);
  --green: #315c47;
  --orange: #e86e3e;
}

* { box-sizing: border-box; }

html, body, #app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  color: var(--ink);
  background: #d9d8d1;
  font-family: "DM Sans", "Noto Sans KR", system-ui, sans-serif;
}

button, a { font: inherit; }
button { color: inherit; }

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: none;
}

.topbar {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  height: 82px;
  padding: 18px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.topbar > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--green);
  font-size: 15px;
  font-weight: 700;
}

.brand b, .brand small { display: block; }
.brand b { font-size: 12px; letter-spacing: .08em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 10px; }

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

.mode-switch, .icon-button {
  border: 1px solid rgba(255,255,255,.7);
  box-shadow: 0 8px 30px rgba(26, 34, 30, .08);
  backdrop-filter: blur(16px);
  background: var(--glass);
}

.mode-switch { display: flex; border-radius: 999px; padding: 4px; }
.mode-button, .icon-button {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.mode-button { padding: 9px 14px; border-radius: 999px; }
.mode-button.is-active { color: white; background: var(--ink); }
.icon-button { padding: 12px 15px; border-radius: 999px; }
.icon-button[aria-pressed="true"] { color: white; background: var(--green); }

.facts {
  position: fixed;
  z-index: 10;
  left: 28px;
  top: 116px;
  width: 172px;
  padding-left: 17px;
  border-left: 2px solid var(--orange);
  pointer-events: none;
}

.eyebrow { color: var(--orange); font-size: 9px; font-weight: 700; letter-spacing: .18em; }
.facts h1 { margin: 5px 0 10px; font-size: 36px; letter-spacing: -.06em; }
.facts dl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.facts dl div { display: grid; gap: 2px; }
.facts dt { color: var(--muted); font-size: 9px; }
.facts dd { margin: 0; font-size: 11px; font-weight: 600; }
.facts p { margin: 10px 0 0; color: var(--muted); font-size: 10px; }

.build-open { color: white; background: var(--orange); }
.build-open.is-active { color: white; background: var(--green); }

.builder-panel {
  position: fixed;
  z-index: 26;
  top: 92px;
  left: 24px;
  width: 292px;
  max-height: calc(100vh - 116px);
  padding: 20px;
  border: 1px solid rgba(255,255,255,.75);
  border-radius: 20px;
  background: rgba(247,245,239,.94);
  box-shadow: 0 24px 70px rgba(29,37,33,.18);
  backdrop-filter: blur(18px);
  transform: translateX(calc(-100% - 30px));
  opacity: 0;
  visibility: hidden;
  transition: transform .28s ease, opacity .28s ease, visibility .28s ease;
  overflow-y: auto;
  scrollbar-width: thin;
}
.builder-panel.is-open { transform: translateX(0); opacity: 1; visibility: visible; }
.builder-head { display: flex; align-items: flex-start; justify-content: space-between; }
.builder-head h2 { margin: 4px 0 0; font-size: 24px; letter-spacing: -.04em; }
.builder-head button { width: 32px; height: 32px; border: 0; border-radius: 50%; background: #e8e4db; cursor: pointer; font-size: 21px; }
.builder-intro { margin: 16px 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.builder-section-title { display: block; margin: 0 0 7px 2px; color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: .12em; }
.furniture-title { margin-top: 16px; }
.builder-tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.builder-tool { min-width: 0; padding: 10px 5px; display: grid; justify-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.55); cursor: pointer; }
.builder-tool:hover, .builder-tool.is-active { border-color: var(--green); background: #e4ebe5; }
.builder-tool i { width: 30px; height: 18px; display: block; position: relative; }
.builder-tool span, .builder-tool b, .builder-tool small { display: block; }
.builder-tool b { font-size: 10px; }
.builder-tool small { margin-top: 2px; color: var(--muted); font-size: 7px; }
.tool-wall::before { content: ""; position: absolute; inset: 4px 0; border-radius: 2px; background: var(--ink); }
.tool-window { border: 3px solid var(--ink); background: rgba(119,176,188,.36); }
.tool-window::after { content: ""; position: absolute; top: -3px; bottom: -3px; left: 50%; width: 2px; background: var(--ink); }
.tool-erase { border: 5px solid var(--orange); border-radius: 4px; transform: rotate(-35deg) scale(.72); }
.builder-parts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.builder-part { min-height: 58px; padding: 7px 3px 6px; display: grid; place-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.5); cursor: pointer; }
.builder-part:hover, .builder-part.is-active { border-color: var(--orange); color: var(--orange); background: #f8e8df; }
.builder-part i { width: 25px; height: 17px; display: block; position: relative; color: currentColor; }
.builder-part span { font-size: 8px; font-weight: 700; }
.part-fridge { border: 2px solid; border-radius: 2px; }
.part-fridge::after { content: ""; position: absolute; left: 0; right: 0; top: 6px; border-top: 1px solid; }
.part-tv { border: 2px solid; border-radius: 2px; }
.part-tv::after { content: ""; position: absolute; left: 7px; right: 7px; bottom: -5px; border-top: 2px solid; }
.part-island { border: 2px solid; border-radius: 2px; transform: perspective(20px) rotateX(-8deg); }
.part-table::before { content: ""; position: absolute; left: 1px; right: 1px; top: 3px; border-top: 4px solid; }
.part-table::after { content: ""; position: absolute; left: 4px; right: 4px; bottom: 0; height: 11px; border-left: 2px solid; border-right: 2px solid; }
.part-chair { border-left: 3px solid; border-bottom: 3px solid; }
.part-chair::after { content: ""; position: absolute; left: 5px; right: 1px; bottom: 5px; border-top: 3px solid; }
.part-sofa { border: 3px solid; border-top-width: 7px; border-radius: 5px 5px 3px 3px; }
.part-bed { border: 2px solid; border-left-width: 6px; border-radius: 2px; }
.part-bed::after { content: ""; position: absolute; left: 7px; top: 3px; width: 6px; height: 5px; border: 1px solid; }
.part-storage { border: 2px solid; }
.part-storage::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; border-left: 1px solid; }
.part-light { width: 16px !important; height: 16px !important; border: 3px solid; border-radius: 50%; color: var(--orange) !important; }
.part-light::after { content: ""; position: absolute; width: 2px; height: 6px; left: 4px; bottom: -8px; background: currentColor; }
.rotation-control { margin-top: 10px; padding: 9px 11px; display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 11px; font-size: 9px; font-weight: 600; }
.rotation-control div { display: flex; align-items: center; gap: 8px; }
.rotation-control button { width: 25px; height: 25px; border: 0; border-radius: 50%; color: var(--green); background: #e4ebe5; cursor: pointer; }
.rotation-control b { width: 29px; text-align: center; color: var(--orange); font-size: 10px; }
.snap-control { margin-top: 14px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 11px; font-size: 9px; font-weight: 600; }
.snap-control select { border: 0; background: transparent; color: var(--green); font-size: 10px; font-weight: 700; outline: none; }
.builder-readout { margin-top: 10px; padding: 12px; display: flex; justify-content: space-between; align-items: center; border-radius: 11px; color: white; background: var(--ink); }
.builder-readout span { font-size: 9px; }
.builder-readout b { color: #f2a07f; font-size: 12px; }
.builder-actions { margin-top: 10px; display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 5px; }
.builder-actions button { padding: 9px 4px; border: 1px solid var(--line); border-radius: 9px; background: transparent; cursor: pointer; font-size: 8px; font-weight: 700; }
.builder-actions button:last-child { border-color: var(--green); color: white; background: var(--green); }
.builder-note { margin: 10px 2px 0; color: #838983; font-size: 8px; line-height: 1.5; }
.builder-hint { position: fixed; z-index: 25; left: 50%; top: 102px; transform: translate(-50%, -8px); padding: 9px 14px; border-radius: 999px; color: white; background: rgba(29,37,33,.88); opacity: 0; visibility: hidden; pointer-events: none; font-size: 9px; transition: .2s ease; }
.builder-hint.is-visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
body.is-building #scene { cursor: crosshair; }
body.is-building .facts { opacity: .22; }

.minimap-card {
  position: fixed;
  z-index: 10;
  right: 28px;
  top: 112px;
  width: 205px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.65);
  border-radius: 16px;
  background: rgba(247,245,239,.7);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 40px rgba(29,37,33,.09);
  pointer-events: none;
}

.minimap-head { display: flex; justify-content: space-between; font-size: 9px; font-weight: 700; letter-spacing: .08em; }
.live-dot { color: var(--orange); }
#minimap { width: 100%; height: auto; margin-top: 8px; display: block; }

.room-nav {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 6px;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 999px;
  background: var(--glass);
  box-shadow: 0 14px 40px rgba(29,37,33,.12);
  backdrop-filter: blur(16px);
}

.room-nav-label { padding: 0 10px 0 13px; color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: .14em; }
.room-nav button {
  border: 0;
  border-radius: 999px;
  padding: 10px 13px;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
}
.room-nav button:hover, .room-nav button.is-active { color: white; background: var(--green); }

.walk-help {
  position: fixed;
  z-index: 24;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) translateY(30px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  border-radius: 14px;
  color: white;
  background: rgba(25,31,28,.88);
  opacity: 0;
  pointer-events: none;
  transition: .25s ease;
}
.walk-help.is-visible { opacity: 1; transform: translate(-50%, -50%); pointer-events: auto; }
.walk-help b, .walk-help span { display: block; }
.walk-help b { font-size: 12px; }
.walk-help span { margin-top: 3px; color: rgba(255,255,255,.66); font-size: 9px; }
.mobile-walk-guide { display: none !important; }
.mouse-icon { width: 20px; height: 30px; border: 1px solid rgba(255,255,255,.7); border-radius: 10px; }
.mouse-icon::before { content: ""; display: block; width: 2px; height: 6px; margin: 5px auto; background: var(--orange); }

.compass {
  position: fixed;
  z-index: 10;
  left: 28px;
  bottom: 32px;
  width: 45px;
  height: 45px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(247,245,239,.65);
  backdrop-filter: blur(10px);
  pointer-events: none;
}
.compass span { position: absolute; top: 5px; font-size: 8px; font-weight: 700; }
.compass i { width: 1px; height: 20px; background: linear-gradient(var(--orange) 50%, var(--ink) 50%); }

.disclaimer {
  position: fixed;
  z-index: 10;
  right: 28px;
  bottom: 18px;
  color: rgba(29,37,33,.55);
  font-size: 8px;
  pointer-events: none;
}

.intro {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 8vw;
  background: linear-gradient(90deg, rgba(239,237,230,.97) 0%, rgba(239,237,230,.88) 37%, rgba(239,237,230,.08) 70%);
  transition: opacity .65s ease, visibility .65s ease;
}
.intro.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.intro-copy { width: min(460px, 42vw); }
.intro-copy h2 { margin: 14px 0 20px; font-size: clamp(38px, 5vw, 74px); line-height: .98; letter-spacing: -.065em; }
.intro-copy p { max-width: 390px; color: var(--muted); font-size: 13px; line-height: 1.75; }
.intro-copy button {
  width: 230px;
  margin-top: 25px;
  padding: 17px 18px;
  display: flex;
  justify-content: space-between;
  border: 0;
  border-radius: 3px;
  color: white;
  background: var(--green);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.intro-copy button:hover { background: #254837; }
.intro-copy small { display: block; margin-top: 11px; color: #818782; font-size: 9px; }
.intro-index { position: absolute; right: 45px; bottom: 40px; display: flex; align-items: center; gap: 9px; font-size: 9px; }
.intro-index i { width: 70px; height: 1px; background: var(--line); }

.loading {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  color: white;
  background: var(--ink);
  transition: opacity .5s ease, visibility .5s ease;
}
.loading.is-hidden { opacity: 0; visibility: hidden; }
.loading span { width: 34px; height: 34px; border: 1px solid rgba(255,255,255,.25); border-top-color: var(--orange); border-radius: 50%; animation: spin 1s linear infinite; }
.loading p { margin-top: 13px; font-size: 10px; letter-spacing: .08em; }
@keyframes spin { to { transform: rotate(1turn); } }

.plan-dialog {
  width: min(980px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 30px 90px rgba(20,28,24,.3);
}
.plan-dialog::backdrop { background: rgba(20,25,23,.62); backdrop-filter: blur(8px); }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 24px 26px 14px; }
.dialog-head h2 { margin: 4px 0 0; font-size: 24px; }
.dialog-head button { width: 34px; height: 34px; border: 0; border-radius: 50%; background: #e5e2da; cursor: pointer; font-size: 22px; }
.plan-dialog figure { margin: 0; padding: 0 26px; }
.plan-dialog img { width: 100%; display: block; border: 1px solid var(--line); background: white; }
.plan-dialog figcaption { padding: 11px 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.dialog-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; padding: 16px 26px 23px; border-top: 1px solid var(--line); }
.dialog-meta p { margin: 0; display: flex; gap: 10px; font-size: 10px; }
.dialog-meta p span { color: var(--muted); }
.dialog-meta a { color: var(--green); font-size: 10px; font-weight: 700; text-decoration: none; }

.touch-pad { display: none; user-select: none; -webkit-user-select: none; touch-action: none; }

@media (max-width: 820px) {
  .topbar { height: 70px; padding: 12px; }
  .brand small, .icon-button#wall-toggle, .facts, .disclaimer { display: none; }
  .brand b { font-size: 10px; }
  .brand-mark { width: 38px; height: 38px; }
  .mode-button { padding: 8px 10px; font-size: 10px; }
  .icon-button { padding: 10px 11px; font-size: 10px; }
  .minimap-card { top: 79px; right: 12px; width: 135px; padding: 8px; }
  .room-nav { left: 12px; right: 12px; bottom: 14px; transform: none; overflow-x: auto; justify-content: flex-start; }
  .room-nav-label { display: none; }
  .room-nav button { padding: 9px 11px; }
  .compass { left: auto; right: 58px; bottom: 224px; }
  .intro { padding: 28px; background: rgba(239,237,230,.9); }
  .intro-copy { width: 100%; }
  .intro-copy h2 { font-size: 48px; }
  .intro-copy p { max-width: 330px; }
  .dialog-meta { align-items: flex-start; gap: 14px; flex-direction: column; }
  .walk-help.is-visible { top: auto; bottom: 224px; transform: translateX(-50%); padding: 10px 13px; pointer-events: none; }
  .walk-help .mouse-icon { display: none; }
  .desktop-walk-guide { display: none !important; }
  .mobile-walk-guide { display: block !important; }
  .touch-pad.is-visible {
    position: fixed;
    z-index: 24;
    left: 18px;
    bottom: 82px;
    width: 128px;
    height: 128px;
    display: block;
    border: 1px solid rgba(255,255,255,.5);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(247,245,239,.35) 0 31%, rgba(34,43,38,.34) 32% 100%);
    box-shadow: 0 12px 34px rgba(18,25,21,.2), inset 0 0 0 8px rgba(255,255,255,.08);
    backdrop-filter: blur(10px);
  }
  .look-pad.is-visible { left: auto; right: 18px; }
  .joystick-ring { position: absolute; inset: 14px; border: 1px dashed rgba(255,255,255,.42); border-radius: 50%; }
  .joystick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 54px;
    height: 54px;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(255,255,255,.76);
    border-radius: 50%;
    background: linear-gradient(145deg, rgba(255,255,255,.95), rgba(219,225,220,.8));
    box-shadow: 0 8px 18px rgba(20,28,24,.3);
    will-change: transform;
  }
  .touch-pad.is-active .joystick-knob { box-shadow: 0 5px 13px rgba(20,28,24,.38), 0 0 0 5px rgba(232,110,62,.16); }
  .joystick-label { position: absolute; left: 50%; bottom: -18px; transform: translateX(-50%); color: rgba(29,37,33,.62); font-size: 8px; font-weight: 700; letter-spacing: .16em; }
  .builder-panel { top: 72px; left: 10px; right: 10px; width: auto; }
  #plan-open { display: none; }
  .build-open { display: inline-flex; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
