* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #1a1420;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

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

.hidden { display: none !important; }

/* ---- start screen ---- */
.panel-wrap {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 8, 18, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 20;
}

.panel {
  width: min(340px, 88vw);
  background: rgba(30, 22, 40, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 28px;
  text-align: center;
  color: #f3ecdf;
}

.panel h1 { font-size: 2.2rem; letter-spacing: 0.03em; }
.panel .sub { color: #b9a8cf; margin: 6px 0 22px; font-size: 0.95rem; }

.panel button {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  color: #241a10;
  background: #ffd076;
  padding: 13px 18px;
}

.panel button.big { display: block; width: 100%; margin-bottom: 12px; font-size: 1.05rem; }

.panel button.alt {
  background: rgba(255, 255, 255, 0.12);
  color: #f3ecdf;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.panel button:active { transform: scale(0.98); }

.join-row { display: flex; gap: 10px; }

.join-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1.1rem;
  letter-spacing: 0.35em;
  text-align: center;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  color: #f3ecdf;
  padding: 12px 8px;
}

.join-row input:focus { outline: 2px solid #ffd076; }

.note { margin-top: 16px; font-size: 0.85rem; color: #9d8bb5; }

/* ---- HUD ---- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

.hud-top, .hud-bottom {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
}

.hud-top { top: 0; padding-top: max(14px, env(safe-area-inset-top)); }
.hud-bottom { bottom: 0; justify-content: center; padding-bottom: max(14px, env(safe-area-inset-bottom)); }

.hud-btn {
  pointer-events: auto;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #f3ecdf;
  background: rgba(20, 14, 28, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 11px 16px;
  cursor: pointer;
  text-decoration: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.hud-btn:active { transform: scale(0.96); }

#btn-rotate { font-size: 1.35rem; line-height: 1; padding: 8px 16px; }

.hud-btn.gold { background: #ffd076; color: #241a10; }

#room-badge {
  pointer-events: auto;
  margin-left: auto;
  color: #cbbfe0;
  background: rgba(20, 14, 28, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 0.9rem;
}

#room-badge span { color: #ffd076; font-weight: 700; letter-spacing: 0.15em; }

/* ---- instruction booklet (styled like a real brick-set manual) ---- */
#booklet {
  position: absolute;
  top: max(64px, calc(env(safe-area-inset-top) + 54px));
  right: 14px;
  width: min(340px, calc(100vw - 28px));
  pointer-events: auto;
  background: #ffffff;
  color: #1a1a1a;
  border-radius: 8px;
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  font-size: 0.92rem;
  font-family: "Futura", "Trebuchet MS", -apple-system, sans-serif;
}

.bk-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px 9px 10px;
  background: #ffffff;
  border-bottom: 4px solid #ffcf00;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.bk-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: none;
  background: #d01012;
  color: #fff;
  font-weight: 900;
  font-size: 0.86rem;
  border-radius: 6px;
  border: 2px solid #ffcf00;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
  text-shadow: 1px 1px 0 #000;
}

.bk-logo i { font-style: normal; font-size: 0.7em; margin: 0 1px; }

#bk-title { flex: 1; font-size: 1.02rem; }

#bk-close {
  font: inherit;
  font-size: 1.3rem;
  line-height: 1;
  border: none;
  background: none;
  color: #999;
  cursor: pointer;
  padding: 2px 10px;
}

.bk-page-wrap { position: relative; }

#bk-stepnum {
  position: absolute;
  top: 8px;
  left: 10px;
  color: #0d69ab;
  font-size: 1.9rem;
  font-weight: 900;
}

#bk-img { display: block; width: 100%; height: auto; }

#bk-note {
  padding: 8px 14px 2px;
  line-height: 1.35;
  color: #444;
  font-size: 0.88rem;
}

#bk-parts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  background: #eef3f8;
  border-top: 1px solid #d8e2ec;
  min-height: 20px;
}

.bk-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid #c3d2e0;
  border-radius: 6px;
  padding: 4px 9px 4px 6px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.bk-chip i {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.3);
}

.bk-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: #0d69ab;
}

.bk-foot button {
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  width: 40px;
  padding: 5px 0;
  border: none;
  border-radius: 50%;
  background: #ffffff;
  color: #0d69ab;
  font-weight: 900;
  cursor: pointer;
}

.bk-foot button:active { transform: scale(0.95); }

#bk-page { color: #ffffff; font-weight: 800; letter-spacing: 0.08em; }

@media (max-width: 560px) {
  #booklet {
    top: auto;
    bottom: max(74px, calc(env(safe-area-inset-bottom) + 66px));
    right: 50%;
    transform: translateX(50%);
  }
}

/* ---- set picker ---- */
#sets-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }

.set-choice {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}

.set-choice .set-emoji { font-size: 1.7rem; }

.set-choice .set-meta small { display: block; font-weight: 400; color: #b9a8cf; margin-top: 2px; }

/* ---- cuddle break ---- */
#cuddle-ui {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  z-index: 12;
}

#cuddle-ui button {
  font: inherit;
  font-weight: 600;
  color: #f3ecdf;
  background: rgba(20, 14, 28, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 11px 20px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#memory-float {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
}

#memory-float img {
  width: min(24vw, 260px);
  border: 8px solid #fdfaf2;
  border-bottom-width: 30px;
  border-radius: 3px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  display: block;
}

#scrapbook {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 7, 14, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.sb-card {
  position: relative;
  background: #fdfaf2;
  border-radius: 6px;
  padding: 14px 14px 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  max-width: min(86vw, 640px);
}

.sb-card img {
  display: block;
  max-width: 100%;
  max-height: 62vh;
  border-radius: 3px;
}

#sb-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #2b2331;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

.sb-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 4px 6px;
}

.sb-title {
  font-family: "Great Vibes", "Snell Roundhand", "Brush Script MT", cursive;
  font-size: 1.35rem;
  color: #4a3b28;
}

.sb-title i { font-style: normal; font-family: inherit; font-size: 0.8em; color: #9b8a72; margin-left: 10px; }

.sb-foot button {
  font-size: 1.5rem;
  width: 42px;
  padding: 4px 0;
  border: 1px solid #d9cdb2;
  border-radius: 10px;
  background: #fff;
  color: #4a3b28;
  cursor: pointer;
}

/* ---- toasts ---- */
#toasts {
  position: fixed;
  top: max(70px, calc(env(safe-area-inset-top) + 56px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 30;
  pointer-events: none;
}

.toast {
  background: rgba(20, 14, 28, 0.88);
  color: #f3ecdf;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.92rem;
  animation: toast-in 0.25s ease, toast-out 0.4s ease 3s forwards;
}

@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to { opacity: 0; } }

/* ---- scrapbook: adding photos ---- */
#sb-add {
  position: absolute;
  top: -14px;
  left: -14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #c9a227;
  color: #241a10;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
#sb-add:active { transform: scale(0.94); }
#sb-add.busy { opacity: 0.6; cursor: default; }

.sb-who {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 0 0 10px;
  font-size: 0.85rem;
  color: #6d5b43;
}

.sb-who-btn {
  font: inherit;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  color: #4a3b28;
  background: #f0e7d4;
  border: 1px solid #d9cbb0;
}
.sb-who-btn:active { transform: scale(0.97); }

.sb-empty {
  display: grid;
  place-content: center;
  min-height: 220px;
  text-align: center;
  color: #6d5b43;
  font-size: 0.95rem;
  line-height: 1.6;
}
.sb-empty b { color: #a5811a; }

.sb-by {
  min-height: 1.2em;
  padding-top: 6px;
  text-align: center;
  font-size: 0.78rem;
  color: #9b8a72;
}
