/* ===========================================================
   PULSE — Room (3D editor, sidebar layout)
   =========================================================== */

.room-view {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

/* ===========================================================
   Header — title + hint on left, all buttons + save on right
   =========================================================== */
.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0;
}
.room-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.room-header .view-title {
  margin: 0;
  font-size: var(--f-xl);
  font-weight: 700;
  line-height: 1.1;
}
.room-hint {
  font-size: 11px;
  color: var(--text-2);
  padding: 0;
  text-align: left;
  margin: 0;
}
.room-header-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.room-header-actions .clay-btn {
  padding: 8px 14px;
  font-size: var(--f-sm);
}

/* ===========================================================
   Unlock banner
   =========================================================== */
.room-unlock-banner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--clay-raised);
}
.room-unlock-banner.unlocked {
  background: linear-gradient(135deg,
    color-mix(in srgb, #22C55E 10%, var(--surface)),
    var(--surface));
}
.room-unlock-banner > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.room-unlock-banner strong {
  display: block;
  font-size: var(--f-sm);
  font-weight: 700;
  line-height: 1.3;
}
.room-unlock-banner > div > div > span {
  display: block;
  font-size: var(--f-xs);
  color: var(--text-2);
  margin-top: 2px;
}
.room-unlock-remaining {
  font-weight: 800;
  font-size: var(--f-md);
  color: var(--primary);
  flex-shrink: 0;
}
.room-unlock-bar {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--bg-2);
  overflow: hidden;
  box-shadow: var(--clay-inset);
}
.room-unlock-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  border-radius: var(--r-pill);
  transition: width 300ms var(--ease);
}

/* ===========================================================
   Layout — mobile: stacked
   =========================================================== */
.room-layout {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ===========================================================
   Sidebar
   =========================================================== */
.room-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--clay-raised);
}
.room-sidebar-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  font-weight: 700;
}
.room-category-tabs {
  display: flex;
  gap: 6px;
  padding: 0;
  flex-wrap: wrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.room-category-tabs::-webkit-scrollbar { display: none; }

.room-cat-tab {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: var(--bg-2);
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
  color: var(--text-2);
  transition: all var(--dur) var(--ease);
  cursor: pointer;
  border: none;
}
.room-cat-tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: var(--clay-raised);
}

.room-catalog { margin: 0; }
.room-catalog-empty {
  text-align: center;
  color: var(--text-2);
  font-size: var(--f-xs);
  padding: 16px;
}
.room-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 6px;
  border-radius: var(--r-md);
  background: var(--bg-2);
  border: 1px solid transparent;
  transition: all var(--dur) var(--ease);
  cursor: pointer;
}
.room-chip:active:not(:disabled) { transform: scale(0.98); }
.room-chip:hover:not(:disabled):not(.locked) { background: var(--surface); box-shadow: var(--clay-raised); }
.room-chip.placed {
  outline: 2px solid var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--bg-2));
}
.room-chip.locked { opacity: 0.5; cursor: not-allowed; }
.room-chip-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  text-align: center;
}
.room-chip-sub {
  font-size: 10px;
  color: var(--text-2);
  font-weight: 600;
  text-transform: capitalize;
}

/* ===========================================================
   Main area
   =========================================================== */
.room-main {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.room-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--r-xl);
  overflow: hidden;
  background: linear-gradient(180deg, #f5f3f0 0%, #e8e2d6 100%);
  box-shadow: var(--clay-raised);
}
.room-stage canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
  cursor: grab;
}
.room-stage canvas:active { cursor: grabbing; }

.room-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-2);
  font-size: var(--f-sm);
  z-index: 5;
}
.room-loader {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--primary) 20%, transparent);
  border-top-color: var(--primary);
  animation: roomSpin 900ms linear infinite;
}
@keyframes roomSpin { to { transform: rotate(360deg); } }

.room-editor-bar {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  box-shadow: var(--clay-raised);
  z-index: 10;
}
.room-editor-bar.visible { display: flex; }
.room-selection-label {
  font-size: var(--f-xs);
  font-weight: 700;
  color: var(--text);
  padding: 0 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-editor-buttons { display: flex; gap: 6px; }
.room-editor-buttons .clay-btn {
  padding: 8px 12px;
  font-size: var(--f-sm);
  min-width: 36px;
}

/* ===========================================================
   Desktop — sidebar + big stage
   =========================================================== */
@media (min-width: 800px) {
  .room-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
  }

  .room-sidebar {
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow: hidden;
  }

  .room-catalog {
    flex: 1;
    min-height: 0;
    max-height: calc(100vh - 260px);
    overflow-y: auto;
  }

  /* Remove aspect ratio on desktop — let the stage fill the column */
  .room-stage {
    aspect-ratio: auto;
    height: min(calc(100vh - 300px), 720px);
    min-height: 420px;
  }
}

@media (min-width: 1200px) {
  .room-layout {
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 22px;
  }
  .room-stage {
    height: min(calc(100vh - 280px), 780px);
  }
  .room-chip { padding: 12px 14px; }
  .room-chip-label { font-size: 13px; }
  .room-chip-sub { font-size: 11px; }
}

/* ===========================================================
   Property picker
   =========================================================== */
.property-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-3);
}
@media (min-width: 700px) {
  .property-grid { grid-template-columns: 1fr 1fr; }
}
.property-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--clay-raised);
  cursor: pointer;
  transition: transform var(--dur) var(--ease);
}
.property-card:active { transform: scale(0.98); }
.property-card.active { outline: 2px solid var(--primary); }
.property-card.locked { opacity: 0.6; cursor: not-allowed; }
.property-hero {
  position: relative;
  width: 100%;
  height: 120px;
  overflow: hidden;
}
.property-hero-inner { position: absolute; inset: 0; }
.property-hero-wall { position: absolute; inset: 0 0 35% 0; background: #f3ecdd; }
.property-hero-floor { position: absolute; inset: 65% 0 0 0; background: #b08a5c; }
.property-hero-window {
  position: absolute; left: 50%; bottom: 40%; transform: translateX(-50%);
  width: 40%; height: 30%; background: #b8e0ff;
  box-shadow: 0 0 0 4px #e0d3b8; border-radius: 2px;
}
.property-info {
  padding: var(--s-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.property-info strong { font-size: var(--f-md); font-weight: 800; }
.property-info > span { font-size: var(--f-xs); color: var(--text-2); }
.property-meta { margin-top: 4px; }
.property-lock { font-size: 11px; font-weight: 700; color: #ef4444; }
.property-badge {
  display: inline-block; padding: 3px 10px; border-radius: var(--r-pill);
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
}
.property-badge.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.property-badge.owned { background: var(--bg-2); color: var(--text-2); }
.property-badge.unlockable { background: linear-gradient(135deg, #84CC16, #22C55E); color: #fff; }

/* ===========================================================
   Guestbook
   =========================================================== */
.guestbook-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-top: var(--s-3);
}
.guestbook-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-2); font-weight: 700;
}
.guestbook-input-row { display: flex; gap: 8px; align-items: center; }
.guestbook-input-row .clay-input { flex: 1; border-radius: var(--r-pill); padding: 12px 18px; }
.guestbook-list { display: flex; flex-direction: column; gap: var(--s-2); margin-top: 4px; }
.guestbook-row {
  display: flex; gap: var(--s-2); padding: var(--s-3);
  border-radius: var(--r-md); background: var(--surface); box-shadow: var(--clay-raised);
}
.guestbook-body { flex: 1; min-width: 0; }
.guestbook-head { display: flex; gap: var(--s-2); align-items: baseline; margin-bottom: 2px; }
.guestbook-head strong { font-size: var(--f-sm); }
.guestbook-head span { font-size: 11px; color: var(--text-2); }
.guestbook-text { font-size: var(--f-sm); line-height: 1.4; word-break: break-word; }
.guestbook-actions { display: flex; gap: var(--s-3); margin-top: 6px; }
.guestbook-react {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--r-pill);
  background: var(--bg-2); color: var(--text-2);
  font-size: var(--f-xs); font-weight: 700;
  transition: all var(--dur) var(--ease);
}
.guestbook-react:hover { background: var(--surface); }
.guestbook-react.active { color: var(--accent-pink); }