:root {
  color-scheme: dark;
  --ink: #02090a;
  --panel: rgba(5, 23, 24, 0.96);
  --panel-card: rgba(8, 30, 32, 0.98);
  --paper: #f2ead6;
  --paper-aged: #e8dfc8;
  --paper-dark: #222521;
  --muted: #94aaa5;
  --gold: #d5b970;
  --gold-glow: rgba(213, 185, 112, 0.35);
  --line: rgba(213, 185, 112, 0.35);
  --wine: #8b2635;
  --green: #4caf50;
  --border-radius: 3px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-user-drag: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--ink);
  color: var(--paper);
  font-family: "Courier New", Courier, Georgia, "Noto Serif KR", serif;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all 0.2s ease;
}

button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.ui-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.ui-layer > * {
  pointer-events: auto;
}

.ui-layer > section[hidden] {
  display: none !important;
}

.ui-layer > section:not([hidden]) {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   공통 타이포그래피 및 빈티지 서류 스타일
   ========================================================================== */
.eyebrow {
  color: var(--gold);
  font: 700 0.75rem "Courier New", monospace;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.vintage-card {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, var(--panel-card), rgba(3, 14, 15, 0.98));
  padding: clamp(24px, 5vw, 48px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), inset 0 0 40px rgba(0, 0, 0, 0.5);
  position: relative;
}

.vintage-card::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(213, 185, 112, 0.12);
  pointer-events: none;
}

.btn-primary {
  background: #173b3b;
  color: var(--paper);
  border: 1px solid var(--gold);
  padding: 14px 28px;
  font-weight: 600;
  letter-spacing: 0.05em;
  min-height: 48px;
}

.btn-primary:hover {
  background: var(--gold);
  color: var(--ink);
  box-shadow: 0 0 15px var(--gold-glow);
}

.btn-primary-small {
  background: #173b3b;
  color: var(--paper);
  border: 1px solid var(--gold);
  padding: 6px 14px;
  font-weight: 600;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary-small:hover {
  background: var(--gold);
  color: var(--ink);
}

.btn-secondary {
  background: rgba(10, 30, 32, 0.8);
  color: var(--paper);
  border: 1px solid var(--line);
  padding: 12px 24px;
  min-height: 44px;
}

.btn-secondary:hover {
  border-color: var(--gold);
  background: rgba(20, 50, 52, 0.9);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 8px 16px;
  min-height: 44px;
}

.btn-ghost:hover {
  color: var(--gold);
  border-color: var(--line);
}

.btn-ghost-small {
  background: rgba(5, 23, 24, 0.7);
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-ghost-small:hover {
  color: var(--paper);
  border-color: var(--gold);
}

.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed !important;
}

/* ==========================================================================
   화면 1: 메인 화면 (Main Menu)
   ========================================================================== */
.screen-wrapper {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.main-card {
  width: min(560px, 94vw);
  max-height: 92vh;
  overflow-y: auto;
  text-align: center;
  padding: clamp(20px, 4vh, 44px) clamp(18px, 4vw, 40px);
}

.main-title {
  font-size: clamp(1.8rem, 4.5vw, 3.2rem);
  letter-spacing: 0.08em;
  margin: clamp(8px, 1.5vh, 14px) 0 clamp(10px, 2vh, 18px);
  color: var(--paper);
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.main-desc {
  color: var(--muted);
  font-size: clamp(0.82rem, 1.1vw, 0.95rem);
  line-height: 1.6;
  margin-bottom: clamp(16px, 3vh, 32px);
}

.menu-button-group {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.5vh, 12px);
  margin-bottom: clamp(14px, 2.5vh, 24px);
}

.menu-button-group button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: clamp(0.9rem, 1.2vw, 1.05rem);
  min-height: clamp(40px, 6vh, 48px);
}

.main-footer {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.75rem;
}

.scenario-select-screen {
  width: 100%;
  height: 100%;
  overflow-y: auto !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(10px, 2vh, 24px) clamp(12px, 2vw, 32px);
}

.screen-header {
  width: min(1200px, 95vw);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: clamp(10px, 2vh, 20px);
  flex-shrink: 0;
}

.section-title {
  font-size: clamp(1.2rem, 2vw, 1.8rem);
  color: var(--paper);
  letter-spacing: 0.08em;
}

.scenario-layout {
  width: min(1200px, 95vw);
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: clamp(12px, 2vw, 24px);
  margin-bottom: 12px;
}

.scenario-grid {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 8px;
}

.scenario-item-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: clamp(10px, 1.5vh, 16px);
  border: 1px solid var(--line);
  background: rgba(8, 26, 28, 0.85);
  cursor: pointer;
  transition: all 0.2s ease;
}

.scenario-item-card:hover, .scenario-item-card.active {
  border-color: var(--gold);
  background: rgba(18, 48, 50, 0.95);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.card-icon-tag {
  font-family: "Courier New", monospace;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--paper);
  padding: 6px 10px;
  border: 1px solid var(--gold);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.card-badge {
  display: inline-block;
  font-size: 0.68rem;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.card-title {
  font-size: clamp(1rem, 1.2vw, 1.2rem);
  margin-bottom: 2px;
}

.card-subtitle {
  font-size: clamp(0.78rem, 0.9vw, 0.85rem);
  color: var(--muted);
  margin-bottom: 4px;
}

.card-meta {
  color: var(--muted);
  font-size: 0.72rem;
}

.scenario-detail-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-y: auto;
  padding: clamp(16px, 2.5vh, 32px);
}

.detail-title {
  font-size: clamp(1.4rem, 2.2vw, 2.2rem);
  margin: 4px 0;
}

.detail-subtitle {
  color: var(--muted);
  font-size: clamp(0.85rem, 1.1vw, 1rem);
  margin-bottom: 12px;
}

.detail-meta-box {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  background: rgba(2, 12, 13, 0.6);
  padding: 16px;
  border: 1px solid rgba(213, 185, 112, 0.15);
  margin-bottom: 20px;
}

.detail-meta-box span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

.detail-meta-box strong {
  font-size: 0.95rem;
  color: var(--paper);
}

.detail-summary h4 {
  font-size: 0.95rem;
  color: var(--gold);
  margin-bottom: 8px;
}

.detail-summary p {
  color: var(--muted);
  line-height: 1.7;
  font-size: 0.95rem;
}

.player-name-setup-box {
  margin-top: 18px;
  background: rgba(3, 14, 15, 0.85);
  border: 1px solid var(--gold);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-name-setup-box label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.05em;
}

.player-name-setup-box small {
  color: var(--muted);
  font-size: 0.75rem;
}

.detail-actions {
  margin-top: 24px;
}

.detail-actions button {
  width: 100%;
}

/* ==========================================================================
   화면 3: 인게임 대화 / 씬 (In-Game VN)
   ========================================================================== */
.vn-screen-shell {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: clamp(8px, 1.5vh, 16px) clamp(10px, 1.5vw, 20px);
  overflow: hidden;
}

.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(3, 14, 15, 0.9);
  border: 1px solid var(--line);
  padding: clamp(6px, 1vh, 10px) clamp(10px, 1.5vw, 18px);
  backdrop-filter: blur(8px);
  z-index: 20;
  flex-wrap: wrap;
  gap: 8px;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1vw, 12px);
  flex-wrap: wrap;
}

.hud-title-group strong {
  display: block;
  font-size: clamp(0.88rem, 1.2vw, 1.05rem);
  color: var(--paper);
  white-space: nowrap;
}

.hud-stat span {
  font-size: clamp(0.7rem, 0.9vw, 0.78rem);
  color: var(--muted);
  margin-right: 4px;
}

.hud-stat b {
  color: var(--gold);
  font-size: clamp(0.8rem, 1vw, 0.95rem);
}

.btn-hud-tool {
  background: rgba(4, 18, 20, 0.85);
  border: 1px solid var(--line);
  color: var(--paper);
  padding: clamp(4px, 0.8vh, 6px) clamp(8px, 1vw, 12px);
  font-size: clamp(0.72rem, 0.95vw, 0.82rem);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-hud-tool:hover {
  background: rgba(23, 59, 59, 0.9);
  border-color: var(--gold);
}

.btn-hud-tool.active {
  background: var(--gold);
  color: var(--ink);
  font-weight: 700;
  border-color: var(--gold);
}

.btn-notebook-trigger {
  position: relative;
  background: #1a4242;
  color: var(--paper);
  border: 1px solid var(--gold);
  padding: clamp(6px, 1vh, 8px) clamp(10px, 1.2vw, 16px);
  font-size: clamp(0.8rem, 1vw, 0.92rem);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-notebook-trigger:hover {
  background: var(--gold);
  color: var(--ink);
}

.badge-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 8px;
  height: 8px;
  background: #ff5252;
  border-radius: 50%;
  border: 1px solid var(--ink);
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.scene-stage {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  position: relative;
  overflow: hidden;
  height: 100%;
}

.character-standing-box {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 100%;
  max-height: calc(100vh - 240px);
  pointer-events: none;
  z-index: 10;
  margin-bottom: -4px;
  animation: standing-appear 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.character-standing-box[hidden] {
  display: none !important;
}

@keyframes standing-appear {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.character-sprite-img {
  height: 100%;
  max-height: 520px;
  width: auto;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 15px 35px rgba(0, 0, 0, 0.75));
  display: block;
}

.location-badge {
  position: absolute;
  top: 16px;
  left: 16px;
  color: var(--gold);
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  background: rgba(3, 16, 17, 0.85);
  padding: 6px 14px;
  border: 1px solid var(--line);
  z-index: 15;
}

.dialogue-panel {
  background: linear-gradient(180deg, rgba(8, 28, 30, 0.96), rgba(3, 14, 15, 0.98));
  border: 1px solid var(--line);
  padding: clamp(12px, 2vh, 22px) clamp(16px, 2.5vw, 32px);
  min-height: clamp(120px, 18vh, 180px);
  max-height: 28vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  z-index: 20;
}

.speaker-row {
  margin-bottom: 6px;
  display: flex;
  align-items: center;
}

.speaker-name {
  font-size: clamp(0.95rem, 1.3vw, 1.18rem);
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.05em;
}

.speaker-role-tag {
  font-size: clamp(0.7rem, 0.9vw, 0.78rem);
  color: var(--gold);
  background: rgba(4, 18, 20, 0.85);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 2px;
  margin-left: 10px;
  font-weight: normal;
}

.dialogue-text {
  font-size: clamp(0.88rem, 1.35vw, 1.18rem);
  line-height: 1.65;
  color: var(--paper);
  flex-grow: 1;
  overflow-y: auto;
}

/* 중요 키워드 하이라이트 */
.kw-danger { color: #ff5252; font-weight: 700; }
.kw-wine { color: #e57373; font-weight: 700; }
.kw-time { color: #64b5f6; font-weight: 700; }
.kw-gold { color: var(--gold); font-weight: 700; }
.kw-person { color: #81c784; font-weight: 700; }

.dialogue-choices-box {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(680px, 90vw);
  z-index: 30;
}

.btn-dialogue-choice {
  background: rgba(8, 28, 30, 0.95);
  border: 1px solid var(--gold);
  color: var(--paper);
  padding: 14px 20px;
  font-size: 1.05rem;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.btn-dialogue-choice:hover {
  background: var(--gold);
  color: var(--ink);
  transform: translateX(6px);
  box-shadow: 0 0 20px var(--gold-glow);
}

.choice-marker {
  color: var(--gold);
  font-size: 0.85rem;
}

.btn-dialogue-choice:hover .choice-marker {
  color: var(--ink);
}

.advance-hint {
  text-align: right;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 8px;
  font-family: "Courier New", monospace;
}

.clue-toast-container {
  position: absolute;
  top: 80px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 50;
}

.clue-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(10, 32, 34, 0.95);
  border: 1px solid var(--gold);
  padding: 12px 18px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  animation: slide-in 0.3s ease-out;
  transition: opacity 0.4s ease;
}

.clue-toast.fade-out {
  opacity: 0;
}

@keyframes slide-in {
  from { transform: translateX(50px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.clue-toast-category-tag {
  font-family: "Courier New", monospace;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold);
}

.clue-toast-body small {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
}

.clue-toast-body strong {
  font-size: 0.95rem;
  color: var(--paper);
}

/* ==========================================================================
   화면 4: 현실의 수사 책상 보드 (Physical Investigation Desk)
   ========================================================================== */
.desk-container {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #020b0c;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.desk-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(6px, 1vh, 10px) clamp(10px, 1.5vw, 20px);
  background: rgba(4, 18, 20, 0.95);
  border-bottom: 1px solid var(--line);
  z-index: 50;
  flex-wrap: wrap;
  gap: 8px;
}

.desk-topbar-left, .desk-topbar-center, .desk-topbar-right {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1vw, 12px);
  flex-wrap: wrap;
}

.desk-title-group strong {
  color: var(--paper);
  font-size: clamp(0.85rem, 1.1vw, 1.05rem);
  white-space: nowrap;
}

.zoom-indicator {
  font-size: clamp(0.75rem, 0.9vw, 0.85rem);
  color: var(--gold);
  min-width: 40px;
  text-align: center;
  font-weight: 600;
}

/* 좌측 서랍 (Drawer) */
.desk-drawer {
  position: absolute;
  top: 53px;
  left: 0;
  bottom: 0;
  width: 320px;
  background: rgba(5, 22, 24, 0.97);
  border-right: 1px solid var(--line);
  z-index: 45;
  display: flex;
  flex-direction: column;
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.6);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.desk-drawer.closed {
  transform: translateX(-100%);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.drawer-header h3 {
  font-size: 1.05rem;
  color: var(--gold);
}

.drawer-section {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(213, 185, 112, 0.15);
}

.drawer-section.tags-section {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 8px;
}

.section-label {
  font-size: 0.72rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 10px;
  font-weight: 700;
  display: block;
}

.tool-chips-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.desk-draggable-tool {
  background: #173b3b;
  color: var(--paper);
  border: 1px solid var(--gold);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: grab;
  transition: all 0.2s ease;
}

.desk-draggable-tool:hover {
  background: var(--gold);
  color: var(--ink);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.desk-draggable-tool:active {
  cursor: grabbing;
}

.category-tabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.cat-tab {
  background: rgba(8, 28, 30, 0.8);
  color: var(--muted);
  border: 1px solid rgba(213, 185, 112, 0.2);
  padding: 4px 8px;
  font-size: 0.72rem;
}

.cat-tab:hover, .cat-tab.active {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(20, 55, 58, 0.9);
}

.drawer-tags-container {
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.drawer-tag-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: grab;
  transition: all 0.15s ease;
  border-radius: 2px;
}

.drawer-tag-item:hover {
  transform: translateX(4px);
  filter: brightness(1.15);
}

.drawer-tag-item:active {
  cursor: grabbing;
}

.tag-cat-indicator {
  font-family: "Courier New", monospace;
  font-size: 0.65rem;
  font-weight: 700;
  opacity: 0.85;
  letter-spacing: 0.05em;
}

.drawer-tag-item .tag-meta {
  display: flex;
  flex-direction: column;
}

.drawer-tag-item .tag-meta strong {
  font-size: 0.85rem;
  color: var(--paper);
}

.drawer-tag-item .tag-meta small {
  font-size: 0.68rem;
  opacity: 0.8;
}

.drawer-empty-note {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  margin-top: 20px;
}

/* ==========================================================================
   속성별 타자기 잉크 라벨 스티커 칩 컬러 시스템 (Aged Label Tags)
   ========================================================================== */
.tag-cat-who { background: #143a3b; border: 1px solid #4db6ac; color: #e0f2f1; }
.tag-cat-when { background: #1e2a38; border: 1px solid #64b5f6; color: #e3f2fd; }
.tag-cat-where { background: #283618; border: 1px solid #a3b18a; color: #f4f6f0; }
.tag-cat-what { background: #3d2614; border: 1px solid #d4a373; color: #faedcd; }
.tag-cat-how { background: #3d141e; border: 1px solid #e57373; color: #ffebee; }
.tag-cat-why { background: #3a3212; border: 1px solid #d5b970; color: #fffde7; }
.tag-cat-action { background: #421212; border: 1px solid #ef5350; color: #ffebee; }
.tag-cat-evidence { background: #14253d; border: 1px solid #81d4fa; color: #e1f5fe; }

/* 무한 캔버스 뷰포트 */
.desk-board-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at center, #071f21 0%, #02090a 100%);
  background-image: 
    radial-gradient(rgba(213, 185, 112, 0.08) 1px, transparent 1px),
    radial-gradient(rgba(213, 185, 112, 0.04) 1px, transparent 1px);
  background-size: 40px 40px, 10px 10px;
  cursor: default;
}

.desk-board-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
}

.desk-empty-watermark {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: rgba(213, 185, 112, 0.4);
  text-align: center;
  pointer-events: none;
}

.desk-empty-watermark p {
  font-size: 1.1rem;
  color: rgba(242, 234, 214, 0.5);
}

.desk-empty-watermark small {
  font-size: 0.8rem;
  color: rgba(148, 170, 165, 0.4);
}

.desk-svg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 5000px;
  height: 5000px;
  pointer-events: none;
  z-index: 10;
}

.desk-arrow-line {
  animation: dash 1.5s linear infinite;
}

@keyframes dash {
  from { stroke-dashoffset: 20; }
  to { stroke-dashoffset: 0; }
}

.desk-items-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 5000px;
  height: 5000px;
  z-index: 20;
}

/* 책상 위 자유 단서 스티커 */
.desk-placed-tag {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 2px;
  font-size: 0.85rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
  cursor: grab;
  transition: box-shadow 0.2s ease;
  z-index: 30;
}

.desk-placed-tag:hover {
  box-shadow: 0 0 16px var(--gold-glow);
}

.desk-placed-tag:active {
  cursor: grabbing;
}

.btn-remove-placed-tag {
  background: transparent;
  color: inherit;
  opacity: 0.7;
  font-size: 0.9rem;
  font-weight: 700;
  margin-left: 6px;
  padding: 2px 4px;
  cursor: pointer;
}

.btn-remove-placed-tag:hover {
  opacity: 1;
  color: #ff5252;
}

/* ==========================================================================
   현실감 있는 빈티지 종이 서류철 & 수첩 카드 (Paper Dossier & Notepad Cards)
   ========================================================================== */

/* 1. 사건 서류철 (Event Card - 낡은 격자 노트 종이 질감) */
.desk-board-card {
  position: absolute;
  width: 380px;
  background: #091c1e;
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
  border-radius: 2px;
  backdrop-filter: blur(8px);
  z-index: 25;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background-image: 
    linear-gradient(rgba(213, 185, 112, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(213, 185, 112, 0.05) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* 접힌 사건 서류철 (Folded State - 반으로 접힌 마닐라 서류봉투) */
.desk-board-card.card-folded {
  width: 360px;
  background: #051415;
  border-color: rgba(213, 185, 112, 0.6);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.8);
}

.desk-board-card.card-folded .desk-card-slots,
.desk-board-card.card-folded .evidence-card-content,
.desk-board-card.card-folded .evidence-relation-selector {
  display: none !important;
}

.desk-board-card.card-folded .desk-card-sentence {
  border-bottom: none;
  background: rgba(2, 10, 11, 0.95);
  padding: 16px 18px;
}

.desk-board-card.card-folded .sentence-body {
  font-size: 1.05rem;
  color: var(--paper);
  line-height: 1.6;
}

.desk-board-card.primary-card {
  border-color: var(--gold);
  box-shadow: 0 0 25px var(--gold-glow);
}

.desk-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(3, 15, 16, 0.95);
  border-bottom: 1px solid var(--line);
  cursor: grab;
}

.desk-card-header:active {
  cursor: grabbing;
}

.card-title-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.primary-badge {
  font-family: "Courier New", monospace;
  font-size: 0.65rem;
  color: var(--ink);
  background: var(--gold);
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 2px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-toggle-fold {
  background: rgba(8, 28, 30, 0.8);
  color: var(--gold);
  border: 1px solid var(--line);
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 2px;
  font-weight: 600;
}

.btn-toggle-fold:hover {
  background: var(--gold);
  color: var(--ink);
}

.btn-connect-arrow {
  background: rgba(15, 42, 44, 0.8);
  color: var(--gold);
  border: 1px solid var(--line);
  font-size: 0.72rem;
  padding: 4px 8px;
}

.btn-connect-arrow:hover, .btn-connect-arrow.connecting-active {
  background: var(--gold);
  color: var(--ink);
}

.btn-delete-card {
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 4px 6px;
}

.btn-delete-card:hover {
  color: #ff5252;
}

.desk-card-sentence {
  padding: 12px 14px;
  background: rgba(2, 12, 13, 0.9);
  border-bottom: 1px solid rgba(213, 185, 112, 0.2);
}

.desk-card-sentence small {
  font-size: 0.68rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: 4px;
  font-family: "Courier New", monospace;
}

.sentence-body {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--paper);
}

.desk-card-slots {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.desk-slot-box {
  min-height: 34px;
  border: 1px dashed;
  display: flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 2px;
  transition: all 0.2s ease;
  background: rgba(3, 14, 15, 0.4);
}

.desk-slot-box.filled {
  border-style: solid;
  background: transparent;
}

/* 속성별 슬롯 빈칸 가이드 컬러 테두리 & 배경 */
.desk-slot-box.slot-cat-who { border-color: rgba(77, 182, 172, 0.45); background: rgba(20, 58, 59, 0.25); }
.desk-slot-box.slot-cat-when { border-color: rgba(100, 181, 246, 0.45); background: rgba(30, 42, 56, 0.25); }
.desk-slot-box.slot-cat-where { border-color: rgba(163, 177, 138, 0.45); background: rgba(40, 54, 24, 0.25); }
.desk-slot-box.slot-cat-what { border-color: rgba(212, 163, 115, 0.45); background: rgba(61, 38, 20, 0.25); }
.desk-slot-box.slot-cat-how { border-color: rgba(229, 115, 115, 0.45); background: rgba(61, 20, 30, 0.25); }
.desk-slot-box.slot-cat-why { border-color: rgba(213, 185, 112, 0.45); background: rgba(58, 50, 18, 0.25); }
.desk-slot-box.slot-cat-action { border-color: rgba(239, 83, 80, 0.45); background: rgba(66, 18, 18, 0.25); }

.desk-slot-box.snap-target-hover {
  outline: 2px dashed var(--gold) !important;
  box-shadow: 0 0 16px var(--gold-glow);
  filter: brightness(1.3);
}

.desk-slot-box.snap-reject-shake {
  animation: slot-reject-shake 0.45s ease-in-out;
  background: rgba(239, 83, 80, 0.3) !important;
  outline: 2px solid #ef5350 !important;
}

@keyframes slot-reject-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.slot-hint {
  color: rgba(148, 170, 165, 0.35);
  font-size: 0.72rem;
  font-style: italic;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 0.8rem;
  cursor: grab;
}

.tag-chip:active {
  cursor: grabbing;
}

.btn-remove-slot-tag {
  background: transparent;
  color: inherit;
  opacity: 0.7;
  font-size: 0.85rem;
  margin-left: 4px;
  padding: 0 2px;
}

.btn-remove-slot-tag:hover {
  opacity: 1;
  color: #ff5252;
}

/* 2. 근거 메모지 (Evidence Card - 가로로 긴 콤팩트 수첩 종이) */
.desk-evidence-card {
  width: 320px;
  background: #081a18;
}

.evidence-relation-selector {
  display: flex;
  padding: 6px 10px;
  gap: 4px;
  background: rgba(3, 14, 15, 0.8);
  border-bottom: 1px solid var(--line);
}

.btn-rel {
  flex: 1;
  padding: 4px 0;
  font-size: 0.72rem;
  background: rgba(8, 26, 28, 0.8);
  color: var(--muted);
  border: 1px solid var(--line);
}

.btn-rel.active.rel-support { background: #1b5e20; color: #fff; border-color: #4caf50; }
.btn-rel.active.rel-contradict { background: #b71c1c; color: #fff; border-color: #f44336; }
.btn-rel.active.rel-question { background: #e65100; color: #fff; border-color: #ff9800; }

.evidence-sentence-box {
  background: rgba(3, 16, 18, 0.95);
  border-left: 3px solid var(--gold);
}

.evidence-card-content {
  padding: 12px;
  transition: all 0.2s ease;
}

.desk-evidence-card.snap-target-hover {
  outline: 2px dashed var(--gold);
  box-shadow: 0 0 16px var(--gold-glow);
}

.evidence-tag-preview {
  padding: 8px 10px;
  border-radius: 2px;
}

.evidence-tag-preview .ev-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.evidence-tag-preview .ev-desc {
  font-size: 0.8rem;
  opacity: 0.9;
  line-height: 1.4;
  margin-bottom: 8px;
}

.evidence-empty-box {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 14px 0;
}

/* 물리 드래그 고스트 및 마그네틱 슬롯 스냅 */
.desk-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 2000;
  transform: translate(-50%, -50%);
  opacity: 0.95;
  transition: none;
}

.desk-drag-ghost.ghost-magnetic-snapped {
  transition: left 0.12s cubic-bezier(0.16, 1, 0.3, 1), top 0.12s cubic-bezier(0.16, 1, 0.3, 1), transform 0.12s cubic-bezier(0.16, 1, 0.3, 1);
  transform: translate(-50%, -50%) scale(1.05);
}

.desk-drag-ghost.ghost-magnetic-snapped .ghost-chip {
  box-shadow: 0 0 25px var(--gold-glow), 0 8px 30px rgba(0, 0, 0, 0.9);
  border-width: 2px;
}

.ghost-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8), 0 0 20px var(--gold-glow);
  font-size: 0.9rem;
  border-radius: 2px;
}

.tool-ghost {
  background: #173b3b;
  color: var(--paper);
  border: 1px solid var(--gold);
  font-weight: 700;
}

/* 하단 종합 사건 본문 및 결론 제출 바 */
.desk-verdict-bar {
  position: absolute;
  bottom: 24px;
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  background: rgba(3, 15, 16, 0.94);
  border: 1px solid var(--gold);
  padding: 14px 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  z-index: 50;
}

.verdict-bar-info {
  flex: 1;
  overflow: hidden;
}

.hypothesis-live-preview {
  color: var(--paper);
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-step-badge {
  font-family: "Courier New", monospace;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--gold);
  padding: 1px 6px;
  border-radius: 2px;
  margin-right: 4px;
}

.card-connecting-source {
  outline: 2px solid var(--gold) !important;
  box-shadow: 0 0 25px var(--gold-glow) !important;
}

.event-flow-arrow {
  animation: dash 1s linear infinite;
  filter: drop-shadow(0 0 6px rgba(213, 185, 112, 0.6));
}

.btn-verdict-highlight {
  background: #173b3b;
  border: 1px solid var(--gold);
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
}

.btn-verdict-highlight:hover {
  background: var(--gold);
  color: var(--ink);
  box-shadow: 0 0 20px var(--gold-glow);
}

/* ==========================================================================
   화면 5: 결과 및 판정 화면 (Verdict)
   ========================================================================== */
.verdict-card {
  width: min(840px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
}

.verdict-header {
  text-align: center;
  margin-bottom: 24px;
}

.grade-banner {
  display: inline-block;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 6px 24px;
  margin: 10px 0;
  border: 2px solid;
  font-family: "Courier New", monospace;
}

.grade-perfect { color: #ffd700; border-color: #ffd700; background: rgba(255, 215, 0, 0.1); }
.grade-partial { color: #64b5f6; border-color: #64b5f6; background: rgba(100, 181, 246, 0.1); }
.grade-wrong { color: #ef5350; border-color: #ef5350; background: rgba(239, 83, 80, 0.1); }

.verdict-title {
  font-size: 2rem;
  margin-bottom: 8px;
}

.verdict-summary {
  color: var(--muted);
  line-height: 1.6;
}

.submitted-hypothesis-box {
  background: rgba(2, 12, 13, 0.8);
  border: 1px solid var(--line);
  padding: 16px;
  margin-bottom: 20px;
}

.submitted-hypothesis-box p {
  font-size: 1.05rem;
  color: var(--paper);
  font-style: italic;
}

.verdict-breakdown {
  margin-bottom: 24px;
}

.verdict-breakdown h4, .verdict-explanation h4 {
  font-size: 0.95rem;
  color: var(--gold);
  margin-bottom: 10px;
}

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.breakdown-item {
  padding: 10px;
  border: 1px solid;
  background: rgba(4, 16, 18, 0.7);
}

.breakdown-item.match { border-color: rgba(76, 175, 80, 0.6); }
.breakdown-item.mismatch { border-color: rgba(239, 83, 80, 0.6); }

.slot-name {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 700;
  display: block;
  font-family: "Courier New", monospace;
}

.slot-status-icon {
  font-size: 0.8rem;
  font-weight: 700;
  font-family: "Courier New", monospace;
}

.breakdown-item.match .slot-status-icon { color: #81c784; }
.breakdown-item.mismatch .slot-status-icon { color: #e57373; }

.slot-values {
  margin-top: 4px;
  font-size: 0.8rem;
}

.truth-hint {
  display: block;
  color: var(--gold);
  margin-top: 2px;
}

.verdict-explanation {
  background: rgba(5, 20, 22, 0.6);
  border-left: 3px solid var(--gold);
  padding: 14px;
  margin-bottom: 24px;
  line-height: 1.6;
  color: var(--muted);
}

.verdict-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

/* ==========================================================================
   화면 6: 시나리오 제작 스튜디오 (Studio)
   ========================================================================== */
.studio-screen-shell {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at center, rgba(14, 40, 42, 0.96) 0%, rgba(3, 14, 15, 0.98) 100%);
  color: var(--paper);
  overflow: hidden;
}

.studio-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  background: rgba(3, 15, 16, 0.95);
  border-bottom: 1px solid var(--gold);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  z-index: 20;
}

.studio-topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.studio-title-group strong {
  display: block;
  font-size: 1.15rem;
  color: var(--gold);
  letter-spacing: 0.05em;
}

.studio-content-viewport {
  flex: 1;
  overflow-y: auto !important;
  padding: clamp(10px, 2vh, 24px) clamp(12px, 2vw, 24px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.studio-card {
  width: min(920px, 96vw);
  background: rgba(5, 20, 22, 0.94);
  border: 1px solid var(--gold);
  padding: clamp(14px, 2.5vh, 28px) clamp(16px, 3vw, 32px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.5vh, 18px);
  margin-bottom: 20px;
}

.studio-form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.flex-1 { flex: 1; min-width: 160px; }
.flex-2 { flex: 2; min-width: 220px; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.label-with-hint {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
}

.label-with-hint small {
  color: var(--gold);
  font-size: 0.75rem;
}

.studio-input, .studio-textarea, .studio-select {
  background: rgba(2, 10, 11, 0.9);
  border: 1px solid var(--line);
  color: var(--paper);
  padding: clamp(8px, 1vh, 12px) clamp(10px, 1.2vw, 14px);
  font-family: inherit;
  font-size: clamp(0.85rem, 1.1vw, 0.95rem);
  transition: all 0.2s ease;
}

.studio-input:focus, .studio-textarea:focus, .studio-select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 15px var(--gold-glow);
}

.studio-textarea {
  height: clamp(110px, 20vh, 240px);
  min-height: 90px;
  resize: vertical;
  line-height: 1.6;
  font-family: "Malgun Gothic", sans-serif;
}

.studio-actions-bar {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

/* 2단계: 등장인물 설정 카드 그리드 */
.step-guide-box h3 {
  color: var(--gold);
  font-size: 1.25rem;
  margin-bottom: 6px;
}

.step-guide-box p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.studio-character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 16px;
  margin-top: 10px;
}

.char-setup-card {
  display: flex;
  gap: 16px;
  background: rgba(3, 14, 15, 0.85);
  border: 1px solid var(--line);
  padding: 16px;
  align-items: center;
}

.char-preview-avatar {
  width: 90px;
  height: 90px;
  background: #020809;
  border: 1px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.char-preview-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.loc-preview-box {
  width: 120px;
  height: 75px;
  background: #020809;
  border: 1px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.loc-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.loc-placeholder {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.1em;
}

.char-initial {
  font-size: 1.8rem;
  font-weight: 700;
  color: #030f10;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.char-info-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.char-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.char-name-label {
  font-size: 1.1rem;
  color: var(--gold);
  white-space: nowrap;
}

.studio-input-small {
  background: rgba(2, 10, 11, 0.9);
  border: 1px solid var(--line);
  color: var(--paper);
  padding: 4px 8px;
  font-size: 0.82rem;
  flex: 1;
}

.char-image-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-upload-file {
  display: inline-block;
  background: rgba(23, 59, 59, 0.9);
  border: 1px solid var(--gold);
  color: var(--paper);
  padding: 6px 12px;
  font-size: 0.8rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-upload-file:hover {
  background: var(--gold);
  color: var(--ink);
}

.studio-tags-summary-box {
  background: rgba(2, 10, 11, 0.8);
  border: 1px dashed var(--line);
  padding: 16px;
}

.studio-tags-summary-box h4 {
  color: var(--gold);
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.studio-tags-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.studio-tag-chip {
  font-size: 0.78rem;
  padding: 4px 8px;
  border-radius: 2px;
  border: 1px solid rgba(213, 185, 112, 0.4);
  background: rgba(4, 18, 20, 0.8);
}

.badge-custom {
  background: #b26a38 !important;
  color: #fff !important;
}

/* ==========================================================================
   반응형 미디어 쿼리 (가로/세로 낮은 해상도 완벽 대응)
   ========================================================================== */
@media (max-width: 900px), (max-height: 700px) {
  .scenario-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow-y: visible;
  }

  .scenario-grid {
    max-height: 260px;
  }

  .scenario-detail-panel {
    min-height: 300px;
  }

  .game-hud {
    padding: 6px 10px;
  }

  .hud-stat {
    display: none;
  }

  .desk-drawer {
    width: 260px;
  }

  .desk-board-card {
    width: 300px;
  }

  .studio-character-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .hud-left strong, .hud-title-group small {
    display: none;
  }

  .btn-hud-tool {
    padding: 4px 6px;
    font-size: 0.7rem;
  }
}
