/* Workstation shell and direct off-duty room presentation. */
.laptop-frame {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  transition: filter 0.35s ease, transform 0.35s ease;
}

.laptop-frame:not(.work-mode-active) {
  visibility: hidden;
  pointer-events: none;
}

.laptop-frame.computer-screen-active {
  position: fixed;
  inset: 0;
  z-index: 2100;
  visibility: visible;
  pointer-events: auto;
}
.computer-screen-active .desktop-icon[data-app-id="phase-toggle"],
.computer-screen-active .start-menu-item[data-app-id="phase-toggle"] {
  display: none;
}

.laptop-frame.work-mode-active::before {
  display: none;
}

.dorm-mode-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #171335;
  color: #fff;
  opacity: 1;
}

.dorm-mode-overlay.hidden { display: none; }
.dorm-mode-overlay.computer-open {
  z-index: 2200;
  background: transparent;
  pointer-events: none;
}
.dorm-mode-overlay.computer-open .dorm-room-frame { visibility: hidden; }

.dorm-room-frame {
  width: min(760px, 96vw);
  max-height: 96vh;
  padding: 10px;
  background: #302b48;
  border: 8px solid #51486d;
  box-shadow: inset 0 0 0 3px #171335, 0 0 0 3px #0b0918;
}

.dorm-room-header {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px 8px;
  color: #f4ecc9;
}

.dorm-mode-tip { font-size: 12px; opacity: 0.8; }

.dorm-viewport {
  position: relative;
  width: min(480px, 96vw);
  aspect-ratio: 480 / 300;
  padding: 0;
  overflow: hidden;
  background: #2c2842;
}

.dorm-scene-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.dorm-marker-layer { position: absolute; inset: 0; }
.dorm-player {
  position: absolute;
  z-index: 4;
  cursor: pointer;
  transform-origin: bottom center;
  transition: left 0.25s linear, top 0.25s linear, transform 0.15s ease;
}

.dorm-wall-clock {
  position: absolute;
  z-index: 3;
  top: 30px;
  left: 210px;
  width: 92px;
  padding: 5px 4px;
  text-align: center;
  color: #261f42;
  background: #f4ecc9;
  border: 3px solid #8a6a4c;
  box-shadow: 2px 2px 0 #171335;
  transform: rotate(-2deg);
}
.dorm-wall-clock-label { display: block; font-size: 8px; letter-spacing: 1px; }
.dorm-wall-clock strong { display: block; font: bold 20px var(--w95-font); }

.dorm-npc-marker,
.dorm-bed-marker {
  position: absolute;
  z-index: 5;
  cursor: pointer;
  white-space: nowrap;
}
.dorm-npc-marker { transform: translate(-50%, -100%); }
.dorm-npc-image {
  position: absolute;
  width: 78px;
  height: 112px;
  object-fit: contain;
  object-position: bottom center;
  transform: translate(-50%, -100%);
  cursor: pointer;
  border: 2px solid transparent;
  filter: drop-shadow(2px 2px 0 #171335);
}
.dorm-npc-image:hover,
.dorm-npc-image:focus-visible {
  border-color: #fff;
  outline: 1px dotted #000;
}
.dorm-npc-image.offline { opacity: 0.55; }
.dorm-item-placement-marker {
  position: absolute;
  z-index: 6;
  transform: translate(-50%, -50%);
  cursor: pointer;
  font-size: 16px;
}
.dorm-bed-marker { left: 82px; top: 220px; }
.dorm-phone-marker { left: 330px; top: 178px; }
.dorm-clue-wall-marker { left: 26px; top: 168px; }
.dorm-npc-marker.offline { opacity: 0.55; }

.dorm-interaction {
  min-height: 86px;
  max-height: 190px;
  margin-top: 8px;
  color: #222;
}
.dorm-interaction h3,
.dorm-interaction h4 { margin: 0 0 6px; }
.dorm-interaction button { margin: 3px; }

.dorm-bed-confirm {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 12, 35, 0.62);
}
.dorm-bed-confirm.hidden { display: none; }
.dorm-bed-confirm-box {
  width: min(320px, 90%);
  padding: 14px;
  color: #222;
  background: #c0c0c0;
  border: 3px solid #51486d;
  box-shadow: 4px 4px 0 #171335;
}
.dorm-bed-confirm-title { display: block; margin-bottom: 8px; }
.dorm-bed-confirm-message { margin: 0 0 12px; }
.dorm-bed-confirm-actions { text-align: right; }

.computer-close-button {
  position: fixed;
  z-index: 2300;
  top: 18px;
  right: 24px;
  padding: 6px 12px;
  color: #fff;
  background: #7d2635;
  border-color: #f5d8d8;
  pointer-events: auto;
}
.computer-close-button.hidden { display: none; }

.dorm-clue-wall-note { margin: 0 0 4px; font-size: 11px; }
.dorm-clue-wall {
  position: relative;
  width: 100%;
  height: var(--clue-wall-height);
  overflow: auto;
  background: #c99666;
  border: 5px solid #70482f;
  box-shadow: inset 0 0 0 2px #e2bd8d;
}
.dorm-clue-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.dorm-clue-lines line { stroke: #b21f2d; stroke-width: 3; stroke-linecap: round; opacity: 0.88; }
.dorm-clue-node {
  position: absolute;
  width: 130px;
  min-height: 28px;
  padding: 5px 7px;
  transform: translate(-50%, -50%) rotate(-1deg);
  color: #241b1b;
  background: #fff3c9;
  border: 1px solid #9e8156;
  box-shadow: 2px 2px 0 rgba(49, 25, 15, 0.45);
  text-align: center;
  font-size: 11px;
  z-index: 1;
}

.dorm-mode-overlay.mode-transition { animation: room-fade 0.62s ease both; }
.dorm-mode-overlay.closing-laptop { animation-name: laptop-close; }
.dorm-mode-overlay.opening-laptop { animation-name: laptop-open; }

@keyframes laptop-close {
  0% { opacity: 0; transform: perspective(900px) rotateX(-78deg) scale(0.7); transform-origin: 50% 100%; }
  55% { opacity: 1; transform: perspective(900px) rotateX(12deg) scale(1.02); }
  100% { opacity: 1; transform: none; }
}
@keyframes laptop-open {
  0% { opacity: 0; transform: scale(1.08); filter: brightness(1.8); }
  100% { opacity: 1; transform: none; filter: none; }
}
@keyframes room-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Full-screen dorm layout ─────────────────────────────────────────────── */
.dorm-fs-root {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 0;
  background: #1a1530;
  color: #f4ecc9;
}

.dorm-fs-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: #211c38;
  border-bottom: 2px solid #51486d;
  flex-shrink: 0;
}
.dorm-fs-title { font-size: 14px; font-weight: bold; color: #f4ecc9; margin-right: 6px; }
.dorm-fs-header .dorm-wall-clock {
  position: static;
  transform: none;
  margin: 0 8px;
  padding: 3px 8px;
  box-shadow: none;
}
.dorm-fs-actions { margin-left: auto; display: flex; gap: 6px; }
.dorm-fs-actions button { font-size: 12px; }

.dorm-fs-scene {
  display: flex;
  flex: 1;
  gap: 0;
  padding: 10px 16px 8px;
  overflow: hidden;
  align-items: stretch;
  background: #1a1530;
}

/* ── New scene-wrap: background image + item layer ───────────────────────── */
.dorm-scene-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #0a0812;
}

.dorm-scene-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

/* Portrait layer — sits above background, below item layer */
.dorm-portrait-layer {
  position: absolute;
  inset: 0;
  pointer-events: all;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
}

.dorm-portrait-layer.hidden {
  display: none;
}

.dorm-portrait-img {
  /* height is set inline as a % of the scene */
  max-height: 100%;
  width: auto;
  object-fit: contain;
  object-position: bottom;
  display: block;
  position: relative;
  /* offsetX and offsetY applied via inline style */
  filter: drop-shadow(2px 0 8px rgba(0,0,0,0.7));
  transition: opacity 0.2s;
  cursor: pointer;
  user-select: none;
}

.dorm-portrait-img:hover {
  opacity: 0.92;
}

.dorm-scene-item-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.dorm-scene-item-layer .loc-item-btn {
  pointer-events: auto;
}

/* NPC quick-action strip below the scene */
.dorm-npc-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 12px;
  background: #211c38;
  border-top: 2px solid #51486d;
  flex-shrink: 0;
}

.dorm-npc-strip-btn {
  font-size: 12px;
}

.dorm-npc-strip-btn.offline {
  opacity: 0.5;
}

/* ── Bunk unit (one bed + one desk per person) ───────────────────────────── */
.dorm-bunk-unit {
  flex: 1;
  display: flex;
  flex-direction: column;
  border: 2px solid #3d3460;
  border-radius: 4px;
  background: #231d3e;
  margin: 0 4px;
  overflow: hidden;
  min-width: 0;
}

/* Upper bunk: the bed + character */
.dorm-bunk-top {
  flex: 1;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  background: #2c2548;
  border-bottom: 3px solid #5a4a8a;
  cursor: pointer;
  min-height: 0;
}
.dorm-bunk-top:hover { background: #342d56; }

/* Bed-rail pseudo-decoration */
.dorm-bunk-bed-rail {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: repeating-linear-gradient(90deg, #5a4a8a 0 6px, transparent 6px 14px);
  pointer-events: none;
}

/* Character sprite on the bunk */
.dorm-bunk-char {
  display: block;
  max-height: 88%;
  max-width: 80%;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(1px 1px 0 #171335);
  z-index: 1;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 2px;
  transition: border-color 0.12s;
}
.dorm-bunk-char:hover,
.dorm-bunk-char:focus-visible { border-color: #f4ecc9; outline: none; }
.dorm-bunk-char.offline { opacity: 0.45; filter: grayscale(0.7); }

.dorm-npc-btn {
  margin: 8px;
  font-size: 11px;
}
.dorm-npc-btn.offline { opacity: 0.5; }

/* Lower area: desk */
.dorm-bunk-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 6px 6px;
  background: #1e1936;
  gap: 4px;
}
.dorm-bunk-label {
  font-size: 11px;
  color: #a090c8;
  letter-spacing: 1px;
}
.dorm-bunk-desk {
  width: 100%;
  min-height: 30px;
  background: #2a2240;
  border: 1px solid #4a3e70;
  border-radius: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 3px 4px;
  align-items: center;
  justify-content: flex-start;
}

/* Item buttons inside desk/fridge */
.dorm-item-slot-btn {
  font-size: 18px;
  padding: 2px 4px;
  line-height: 1;
  cursor: pointer;
  background: #302a50;
  border-color: #6a5a9a;
}
.dorm-item-slot-btn:hover { background: #3e3562; }

/* ── Fridge column (right side) ─────────────────────────────────────────── */
.dorm-fridge-col {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: 72px;
  flex-shrink: 0;
  margin-left: 8px;
}
.dorm-fridge {
  background: #2a3a4a;
  border: 2px solid #4a7a9a;
  border-radius: 4px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 90px;
}
.dorm-fridge-label {
  font-size: 10px;
  color: #80c0d8;
  text-align: center;
  letter-spacing: 0.5px;
}

/* ── Dorm computer overlay ─────────────────────────────────────────────── */
.dorm-computer-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(20, 16, 50, 0.96);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12px;
  overflow: hidden;
}
.dorm-computer-overlay.hidden { display: none; }

.dorm-computer-inner {
  width: 100%;
  max-width: 820px;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.dorm-computer-tabs {
  display: flex;
  gap: 4px;
  padding: 6px 6px 0;
  background: #e8e0f0;
  border: 0;
  flex-shrink: 0;
}
.dorm-comp-tab-btn { font-size: 12px; color: #222; }
.dorm-comp-tab-btn.active {
  background: #c8a8e8;
  color: #111;
  box-shadow: inset 1px 1px 0 #e0c8f8;
}
.dorm-comp-close { margin-left: auto; }

.dorm-computer-panel {
  flex: 1;
  overflow-y: auto;
  background: #f8f7fc;
  border: 0;
  padding: 8px;
  color: #111;
}
.dorm-computer-panel.hidden { display: none; }

/* Override dark-themed social media colors inside computer */
.dorm-computer-panel .sm-post-body { color: #333; white-space: pre-wrap; }
.dorm-computer-panel .sm-post-meta { color: #666; }
.dorm-computer-panel .sm-post-title { color: #111; }
.dorm-computer-panel .sm-msg-text { color: #222; }
.dorm-computer-panel .sm-msg-sender { color: #1a5fa8; }
.dorm-computer-panel .sm-answer { color: #444; }
.dorm-computer-panel .sm-answers { border-left-color: #bbb; }
.dorm-computer-panel .sm-app-header { border-bottom-color: #ccc; }
.dorm-computer-panel .sm-app-icon { font-size: 20px; }
.dorm-computer-panel .sm-app-desc { color: #666; }
.dorm-computer-panel .sm-tag { background: #e8f0fe; color: #1a5fa8; }
.dorm-computer-panel .sm-group-name { color: #111; }
.dorm-computer-panel .sm-loading { color: #666; }
.dorm-computer-panel .sm-tab-btn { color: #222; }
.dorm-computer-panel .sm-tab-btn.active { background: #c0a060; color: #111; }
.dorm-computer-panel .sm-unread-badge {
  display: inline-block;
  background: #e53935;
  color: #fff;
  font-size: 10px;
  border-radius: 8px;
  padding: 0 5px;
  margin-left: 4px;
  vertical-align: middle;
}
/* ChatGTP inside computer */
.dorm-computer-panel .chatgtp-history { background: #f0eef8; color: #111; }
.dorm-computer-panel .chatgtp-keywords { background: #f5f3fc; color: #111; }

.dorm-computer-panel .bubble-npc { background: #e8f0fe; border-color: #aac; color: #111; }
.dorm-computer-panel .bubble-me { background: #d4edda; border-color: #8bc; color: #111; }
.dorm-computer-panel .chatgtp-san-indicator { color: #444; }

/* ── Social media (sm-) ────────────────────────────────────────────────── */
.app-social-media,
.sm-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.sm-tabs {
  display: flex;
  gap: 4px;
  padding: 4px 4px 0;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.sm-tab-btn { font-size: 12px; }
.sm-tab-btn.active {
  background: #c0a060;
  color: #1a1200;
}
.sm-panel {
  flex: 1;
  overflow-y: auto;
  padding: 8px 4px;
}
.sm-app-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 4px;
  border-bottom: 1px solid #444;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.sm-app-icon { font-size: 20px; }
.sm-app-desc { font-size: 11px; color: #aaa; }
.sm-browse-btn { margin: 4px 0 8px; font-size: 12px; }
.sm-feed { display: flex; flex-direction: column; gap: 10px; }
.sm-post-card {
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
}
.sm-post-title { font-weight: 600; margin-bottom: 2px; }
.sm-post-meta { font-size: 10px; color: #888; margin-bottom: 4px; }
.sm-post-body { margin: 4px 0; color: #ddd; white-space: pre-wrap; }
.sm-post-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.sm-tag {
  font-size: 10px;
  background: #2a4060;
  color: #80c0f0;
  padding: 1px 5px;
  border-radius: 2px;
}
.sm-answers-toggle { margin-top: 4px; font-size: 11px; }
.sm-answers { margin-top: 6px; padding-left: 8px; border-left: 2px solid #555; }
.sm-answer { font-size: 11px; color: #ccc; margin: 3px 0; }
.sm-answer-num { color: #888; margin-right: 4px; }
.sm-group-card { padding: 8px 10px; font-size: 12px; }
.sm-group-name { font-weight: 600; margin-bottom: 6px; }
.sm-msg-list { display: flex; flex-direction: column; gap: 3px; }
.sm-msg-row { line-height: 1.4; }
.sm-msg-sender { font-weight: 600; color: #90c0e8; }
.sm-msg-text { color: #ddd; }
.sm-loading { color: #888; padding: 24px; text-align: center; }
.sm-panel.hidden { display: none; }
.sm-answers.hidden { display: none; }

/* ── Location scene overlay ─────────────────────────────────────────────── */
.location-scene-overlay {
  position: fixed;
  inset: 0;
  z-index: 2100;
  background: #0a0812;
  display: flex;
  flex-direction: column;
}
.location-scene-overlay.hidden { display: none; }

.loc-scene-root {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.loc-scene-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(10, 8, 18, 0.75);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(4px);
}
.loc-scene-title { font-size: 14px; color: #f4ecc9; }
.loc-scene-back { margin-left: auto; font-size: 12px; }

.loc-scene-bg-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.loc-scene-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.loc-scene-item-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.loc-scene-item-layer .loc-item-btn {
  pointer-events: auto;
}

.loc-item-btn {
  font-size: 20px;
  width: 40px;
  height: 40px;
  padding: 0;
  cursor: pointer;
  background: rgba(60, 50, 100, 0.8);
  border: 2px outset rgba(100, 80, 160, 0.9);
  color: #f4ecc9;
  border-radius: 4px;
  transition: transform 0.1s, background 0.15s;
}
.loc-item-btn:hover {
  background: rgba(90, 70, 150, 0.95);
  transform: scale(1.1);
}
/* Buttons placed directly in the layer (have x/y) are absolutely positioned */
.loc-scene-item-layer > .loc-item-btn {
  position: absolute;
}
/* Unpositioned items go into a centered single row just above the interaction box */
.loc-item-float-bar {
  position: absolute;
  bottom: 6px;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
  align-items: flex-end;
  max-width: calc(100% - 16px);
  overflow-x: auto;
  padding: 2px 0;
}
.loc-item-float-bar .loc-item-btn {
  position: relative;
  pointer-events: all;
}

.loc-scene-interaction {
  flex-shrink: 0;
  min-height: 100px;
  max-height: 220px;
  overflow-y: auto;
  padding: 10px 14px;
  background: rgba(16, 12, 36, 0.92);
  border-top: 2px inset #3a2e6e;
  font-size: 13px;
  color: #e0d8f8;
}
.loc-scene-interaction h3 { margin: 0 0 6px; font-size: 14px; color: #f4ecc9; }
.loc-scene-interaction button { margin: 3px; }
.loc-scene-interaction p { margin: 4px 0; }
.loc-scene-hint { color: #888; font-size: 12px; }

/* ── ChatGTP daily banner (dorm computer) ───────────────────────────────── */
.chatgtp-daily-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #e8f4fd;
  border: 1px solid #b3d8f5;
  border-radius: 3px;
  font-size: 12px;
  color: #1a5fa8;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.chatgtp-daily-label { flex: 1; }
.chatgtp-daily-btn { font-size: 11px; }

/* ── CG overlay — fullscreen background image above scene layers ─────────── */
/* sits above dorm-mode (2000) and location-scene (2100), below windows (2200) */
.cg-overlay {
  position: fixed;
  inset: 0;
  z-index: 2150;
  pointer-events: none;  /* dialogue/options receive events through it */
  background: transparent;
  display: flex;
  align-items: stretch;
}
.cg-overlay.hidden { display: none; }

.cg-overlay-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

/* CG background inside dorm scene-wrap (lower z-index, behind item layer) */
.dorm-cg-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  z-index: 2;           /* above scene-bg (implicit 0), below portrait (5) */
}
.dorm-cg-bg.hidden { display: none; }

/* Item layer suppression during CG — no interaction, almost invisible */
.cg-active-layer {
  pointer-events: none !important;
  opacity: 0.1 !important;
}
