/* ===================================================================
   The Gilded Cage — noir, v3 ("the detective's desk, past midnight")
   Type: Newsreader (read) · DM Serif Display (signage) · Oswald (stamps)
         Courier Prime (typed notes) · Caveat (handwriting). No build step.
   =================================================================== */

:root {
  --ink:        #0a0908;
  --night:      #14110d;   /* warm mahogany-dark */
  --panel:      #1a160f;
  --panel-2:    #211c14;
  --raised:     #2b2519;
  --line:       #3a3122;
  --line-soft:  #271f15;
  --fog:        #b3aa97;
  --fog-dim:    #877c64;
  --paper:      #efe6d0;   /* aged paper — dialogue & headings */
  --paper-dim:  #cabfa6;
  --brass:      #d8a85b;
  --brass-lit:  #ecc379;
  --brass-soft: #9c7c40;
  --blood:      #9a2f2f;
  --blood-lit:  #cf5050;
  --teal:       #5aa3a3;
  --text:       #e4dcc9;   /* primary reading text, warm */
  --text-2:     #b8ad96;   /* secondary, still readable */
  --radius:     4px;
  --shadow:     0 12px 38px rgba(0,0,0,0.62);
  --display:    "DM Serif Display", Georgia, serif;
  --read:       "Newsreader", Georgia, serif;
  --label:      "Oswald", system-ui, sans-serif;
  --typewriter: "Courier Prime", "Courier New", monospace;
  --hand:       "Caveat", "Segoe Script", cursive;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  /* A dark office: a warm desk-lamp pool, cold light off a rain-streaked
     window, faint rain, over a warm-dark base. */
  background:
    radial-gradient(880px 520px at 86% -10%, rgba(216,168,91,0.12), transparent 60%),
    radial-gradient(760px 620px at 6% 116%, rgba(70,116,150,0.08), transparent 60%),
    repeating-linear-gradient(105deg, rgba(255,255,255,0.013) 0 1px, transparent 1px 9px),
    linear-gradient(180deg, var(--night), var(--ink));
  color: var(--text);
  font-family: var(--read);
  font-optical-sizing: auto;
  font-size: 17px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Heavy noir vignette. */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  box-shadow: inset 0 0 260px 60px rgba(0,0,0,0.62);
}
/* Film grain over the whole desk. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 60; pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.topbar, .board, .error-banner, .modal-overlay { position: relative; z-index: 1; }

h1, h2, h3 { font-family: var(--label); font-weight: 600; letter-spacing: 0.03em; margin: 0; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
.hidden { display: none !important; }

/* ----------------------------------------------------------------- */
/* Error banner                                                       */
/* ----------------------------------------------------------------- */
.error-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  background: linear-gradient(180deg, var(--blood), #6f2222);
  color: #fbeeee;
  font-family: var(--label); font-weight: 500; letter-spacing: 0.05em;
  padding: 11px 18px;
  display: flex; align-items: center; justify-content: center; gap: 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.error-banner button { background: none; border: none; color: inherit; font-size: 22px; line-height: 1; cursor: pointer; opacity: 0.8; }
.error-banner button:hover { opacity: 1; }

/* ----------------------------------------------------------------- */
/* Top bar — a case-folder header                                     */
/* ----------------------------------------------------------------- */
.topbar {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 26px;
  background: linear-gradient(180deg, #211b13, #15110b);
  border-bottom: 1px solid var(--brass-soft);
  box-shadow: 0 3px 18px rgba(0,0,0,0.5), inset 0 -2px 0 rgba(216,168,91,0.10);
}
.topbar-title { position: relative; }
.topbar-kicker {
  display: block;
  font-family: var(--label); font-size: 11px; font-weight: 600;
  letter-spacing: 0.4em; text-transform: uppercase;
  color: var(--brass); opacity: 0.9; margin-bottom: 1px;
}
.topbar-title h1 {
  font-family: var(--display); font-weight: 400;
  font-size: 31px; letter-spacing: 0.01em; color: var(--paper);
  text-shadow: 0 2px 10px rgba(0,0,0,0.6);
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }

/* ----------------------------------------------------------------- */
/* Buttons                                                            */
/* ----------------------------------------------------------------- */
.btn {
  cursor: pointer;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--raised), #221c13);
  color: var(--text);
  padding: 9px 15px; border-radius: var(--radius);
  font-family: var(--label); font-weight: 500; letter-spacing: 0.07em;
  text-transform: uppercase; font-size: 13px;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s, opacity .15s;
}
.btn:hover:not(:disabled) { border-color: var(--brass-soft); box-shadow: 0 3px 12px rgba(0,0,0,0.4); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn-sm { padding: 6px 11px; font-size: 11px; }
.btn-lg { padding: 13px 24px; font-size: 15px; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-primary { background: linear-gradient(180deg, var(--brass-lit), var(--brass-soft)); border-color: var(--brass); color: #1c1308; font-weight: 700; }
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #f2cd85, var(--brass)); box-shadow: 0 0 20px rgba(216,168,91,0.3); }
.btn-secondary { background: linear-gradient(180deg, var(--panel-2), #1a160f); }
.btn-accuse {
  background: linear-gradient(180deg, var(--blood), #5e1f1f);
  border-color: var(--blood-lit); color: #fbeaea; font-weight: 700;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn-accuse:hover:not(:disabled) { background: linear-gradient(180deg, var(--blood-lit), var(--blood)); box-shadow: 0 0 20px rgba(207,80,80,0.32); }
.lock-icon { font-size: 12px; }
.accuse-progress { font-size: 11px; opacity: 0.9; background: rgba(0,0,0,0.32); border-radius: 999px; padding: 2px 9px; }

/* ----------------------------------------------------------------- */
/* Board / three columns                                              */
/* ----------------------------------------------------------------- */
.board {
  flex: 1 1 auto;
  display: grid; grid-template-columns: 252px 1fr 336px; gap: 1px;
  background: #0c0a07; min-height: 0;
}
.rail, .middle { overflow-y: auto; padding: 18px; min-height: 0; }
.middle { background: linear-gradient(180deg, #18140e, #120f0a); display: flex; flex-direction: column; gap: 20px; }

.rail-heading {
  font-family: var(--label); font-size: 13px; font-weight: 600;
  letter-spacing: 0.24em; text-transform: uppercase; color: var(--brass);
  border-bottom: 1px solid var(--line); padding-bottom: 9px; margin-bottom: 14px;
}
.casebook-heading { margin-top: 24px; }
.section-label {
  font-family: var(--label); font-size: 11px; font-weight: 500;
  letter-spacing: 0.22em; text-transform: uppercase; color: var(--fog);
  margin-bottom: 9px;
}
.section-label::before { content: "■ "; color: var(--brass-soft); font-size: 9px; }

/* ----------------------------------------------------------------- */
/* Left rail — the city, pinned to a board                            */
/* ----------------------------------------------------------------- */
.rail-left {
  background:
    repeating-linear-gradient(0deg, rgba(140,165,185,0.035) 0 1px, transparent 1px 27px),
    repeating-linear-gradient(90deg, rgba(140,165,185,0.035) 0 1px, transparent 1px 27px),
    linear-gradient(180deg, #15130d, #100e0a);
}
.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 10px; padding-top: 6px; }
.room-box {
  position: relative; text-align: left;
  padding: 13px 10px 26px; min-height: 70px;
  border: 1px solid var(--line); border-radius: 3px;
  background: linear-gradient(165deg, #262015, #19140d);
  color: var(--text); cursor: pointer;
  font-family: var(--label); font-weight: 500; font-size: 12.5px;
  letter-spacing: 0.02em; line-height: 1.28;
  box-shadow: 0 5px 12px rgba(0,0,0,0.45);
  transition: transform .14s, border-color .14s, box-shadow .14s;
}
.room-box:nth-child(odd)  { transform: rotate(-0.9deg); }
.room-box:nth-child(even) { transform: rotate(0.8deg); }
.room-box:nth-child(3n)    { transform: rotate(0.4deg); }
/* push-pin */
.room-box::before {
  content: ""; position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #e98a8a, #9a2f2f 72%);
  box-shadow: 0 2px 4px rgba(0,0,0,0.55), inset 0 -1px 2px rgba(0,0,0,0.4);
}
.room-box-name { display: block; }
.room-box:hover:not(.locked) { transform: rotate(0deg) translateY(-2px); border-color: var(--brass-soft); box-shadow: 0 9px 18px rgba(0,0,0,0.5); }
.room-box.current { border-color: var(--brass); background: linear-gradient(165deg, #34291541, #19140d), linear-gradient(165deg, #2f2613, #19140d); color: var(--paper); box-shadow: 0 7px 16px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(216,168,91,0.28); }
.room-box.current::before { background: radial-gradient(circle at 34% 30%, var(--brass-lit), #b9892f 72%); }
.room-box.locked { cursor: not-allowed; color: var(--fog-dim); opacity: 0.62; border-style: dashed; }
.room-box.locked::before { background: radial-gradient(circle at 34% 30%, #8b8b8b, #4a4a4a 72%); }
.room-box .room-glyphs { position: absolute; bottom: 7px; left: 10px; font-size: 13px; letter-spacing: 2px; }
.room-box .visited-dot { color: var(--teal); }
.room-box .person-dot  { color: var(--brass-lit); }
.room-box .lock-dot    { color: var(--fog-dim); }

.map-legend {
  list-style: none; margin: 20px 0 0; padding: 14px 0 0;
  border-top: 1px solid var(--line-soft);
  font-family: var(--label); font-size: 11.5px; letter-spacing: 0.04em; color: var(--fog);
}
.map-legend li { margin-bottom: 6px; }
.legend-glyph { display: inline-block; width: 18px; }

/* ----------------------------------------------------------------- */
/* Middle column — the room & the interrogation                       */
/* ----------------------------------------------------------------- */
.room-header h2 { font-family: var(--display); font-weight: 400; font-size: 29px; letter-spacing: 0.01em; color: var(--paper); line-height: 1.14; }
.room-desc { color: var(--text); margin: 9px 0 0; max-width: 64ch; font-size: 16.5px; }
.examine-list, .npc-list { display: flex; flex-wrap: wrap; gap: 9px; }

/* Examine buttons as little evidence tags with a punched hole. */
.examine-btn {
  position: relative;
  background: linear-gradient(165deg, #241d12, #1a150d);
  border: 1px solid var(--line); border-radius: 3px;
  padding: 8px 13px 8px 22px; cursor: pointer;
  font-family: var(--label); font-weight: 500; font-size: 13px; letter-spacing: 0.02em;
  color: var(--text);
  display: inline-flex; align-items: center; gap: 7px;
  transition: border-color .15s, background .15s, transform .05s;
}
.examine-btn::before { content: ""; position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 6px; height: 6px; border-radius: 50%; background: #0c0a07; box-shadow: inset 0 0 0 1px var(--brass-soft); }
.examine-btn:hover { border-color: var(--brass-soft); transform: translateY(-1px); }
.examine-btn.discovered { color: var(--fog-dim); border-style: dashed; opacity: 0.8; }
.examine-btn .magnifier { opacity: 0.6; }

/* NPC chips — persons of interest. */
.npc-chip {
  background: linear-gradient(165deg, var(--raised), var(--panel-2));
  border: 1px solid var(--line); border-left: 3px solid var(--brass-soft);
  border-radius: 3px; padding: 9px 15px; cursor: pointer; text-align: left;
  transition: border-color .15s, transform .1s, box-shadow .15s;
}
.npc-chip:hover { border-left-color: var(--brass); transform: translateY(-1px); box-shadow: 0 6px 14px rgba(0,0,0,0.4); }
.npc-chip.active { border-color: var(--brass); border-left-color: var(--brass); background: linear-gradient(165deg, #2f2613, #1d1810); }
.npc-chip .npc-chip-name { display: block; font-family: var(--label); font-weight: 600; font-size: 14.5px; letter-spacing: 0.02em; color: var(--paper); }
.npc-chip .npc-chip-role { display: block; font-size: 13px; color: var(--text-2); font-style: italic; margin-top: 1px; }
.npc-empty { color: var(--text-2); font-style: italic; font-size: 15px; }

/* ----------------------------------------------------------------- */
/* Chat — the interrogation transcript                                */
/* ----------------------------------------------------------------- */
.chat-panel {
  flex: 1 1 auto; display: flex; flex-direction: column; min-height: 300px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, #1d1810, #120f0a);
  overflow: hidden; box-shadow: var(--shadow), inset 0 1px 0 rgba(216,168,91,0.06);
}
.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 16px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #241d13, #1a150d);
}
.chat-with-label { font-family: var(--label); font-size: 10px; font-weight: 500; letter-spacing: 0.24em; text-transform: uppercase; color: var(--fog); }
.chat-head strong { font-family: var(--display); font-weight: 400; font-size: 20px; color: var(--paper); margin-left: 7px; }
.chat-npc-role { font-size: 13px; color: var(--text-2); font-style: italic; margin-left: 9px; }

.chat-log { flex: 1 1 auto; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 82%; padding: 11px 15px; border-radius: 3px; line-height: 1.55; font-size: 16px; position: relative; }
/* Detective — a typed note, clipped to the right. */
.msg-user {
  align-self: flex-end;
  background: linear-gradient(165deg, #232a30, #1a1f25);
  border: 1px solid #36404a; border-right: 3px solid var(--teal);
  color: var(--text);
}
/* NPC dialogue — a warm paper card, the most-read text. */
.msg-npc {
  align-self: flex-start;
  background: linear-gradient(165deg, #2a2013, #1e1710);
  border: 1px solid var(--brass-soft); border-left: 3px solid var(--brass);
  color: var(--paper); font-size: 16.5px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}
.msg-npc > div + div { margin-top: 7px; }
.msg-speech { color: var(--paper); }
.msg-action { font-style: italic; color: var(--paper-dim); opacity: 0.85; font-size: 14.5px; line-height: 1.45; text-align: center; }
.msg-system {
  align-self: center; font-family: var(--label); font-size: 11px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--teal);
  background: rgba(90,163,163,0.1); border: 1px dashed var(--line);
  padding: 6px 14px; max-width: 92%; text-align: center; border-radius: 3px;
}
.msg-typing { color: var(--text-2); }
.msg-typing .dots::after { content: ""; animation: dots 1.2s steps(4, end) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.chat-form { border-top: 1px solid var(--line); padding: 11px 13px; background: linear-gradient(180deg, #1f1a11, #15110b); }
.present-row { display: flex; gap: 8px; margin-bottom: 9px; }
.present-select { flex: 1 1 auto; background: #0f0d09; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 11px; font-size: 13.5px; color: var(--text); }
.chat-input-row { display: flex; gap: 8px; }
.chat-input { flex: 1 1 auto; background: #0f0d09; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 13px; font-size: 16px; color: var(--text); }
.chat-input::placeholder { color: var(--fog-dim); }
.chat-input:focus, .present-select:focus, .note-area:focus, select:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 2px rgba(216,168,91,0.16); }

/* ----------------------------------------------------------------- */
/* Right rail — evidence list + casebook                              */
/* ----------------------------------------------------------------- */
.rail-right { background: linear-gradient(180deg, #18140e, #110f0a); }
.rail-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 9px; margin-bottom: 13px; }
.rail-heading-row .rail-heading { border: none; padding: 0; margin: 0; }
.count-badge { font-family: var(--label); font-size: 11px; font-weight: 600; color: var(--brass); background: rgba(216,168,91,0.12); border: 1px solid var(--brass-soft); border-radius: 999px; padding: 1px 8px; vertical-align: middle; }
#evidence-open { background: linear-gradient(180deg, #2c2417, var(--panel-2)); border-color: var(--brass-soft); color: var(--brass); border-bottom-width: 2px; }
#evidence-open:hover:not(:disabled) { background: #352b1a; }

.evidence-compact { display: flex; flex-direction: column; gap: 4px; }
.evidence-row {
  display: flex; align-items: baseline; gap: 8px; width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius);
  padding: 7px 9px; cursor: pointer; transition: background .12s, border-color .12s;
}
.evidence-row:hover { background: var(--panel-2); border-color: var(--line); }
.ev-row-dot { color: var(--brass); font-size: 10px; flex: 0 0 auto; }
.ev-row-name { font-family: var(--read); font-size: 15px; color: var(--paper); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-note { color: var(--text-2); font-style: italic; font-size: 15px; }

/* Casebook tabs as file-folder tabs. */
.tabs { display: flex; gap: 5px; margin-bottom: 0; position: relative; z-index: 1; }
.tab {
  flex: 1; background: linear-gradient(180deg, #1c1710, #15110b);
  border: 1px solid var(--line); border-bottom: none;
  border-radius: 5px 5px 0 0; padding: 7px; cursor: pointer;
  font-family: var(--label); font-weight: 500; font-size: 12px;
  letter-spacing: 0.13em; text-transform: uppercase; color: var(--fog);
}
.tab.active { color: var(--brass); background: linear-gradient(180deg, #2a2214, #1d1810); border-color: var(--brass-soft); }
.tab-panel { border: 1px solid var(--line); border-radius: 0 0 5px 5px; padding: 12px; background: rgba(0,0,0,0.18); }

.log-list { list-style: none; margin: 0; padding: 0; }
.log-list li { font-family: var(--typewriter); font-size: 13px; color: var(--text-2); padding: 8px 0 8px 17px; border-bottom: 1px solid var(--line-soft); position: relative; line-height: 1.5; }
.log-list li::before { content: "\25AA"; position: absolute; left: 0; top: 10px; color: var(--brass); font-size: 9px; }

/* Notes: a torn-out leaf of the same ruled pad. */
.note-area {
  width: 100%; min-height: 220px; resize: vertical;
  border: 1px solid var(--line); border-radius: 3px;
  color: #283450; font-family: var(--typewriter); font-size: 14px; line-height: 26px;
  padding: 9px 11px 9px 40px;
  background-color: #f3ead2;
  background-image:
    linear-gradient(90deg, transparent 0 30px, rgba(168,58,58,0.4) 30px 31px, transparent 31px),
    repeating-linear-gradient(180deg, transparent 0 25px, rgba(70,92,132,0.18) 25px 26px);
  background-attachment: local;
}
.note-area::placeholder { color: #8a7c5e; }
.note-status { font-family: var(--label); font-size: 11px; letter-spacing: 0.08em; color: var(--fog-dim); margin-top: 7px; height: 14px; }

/* ----------------------------------------------------------------- */
/* Modals — case-file dossiers                                        */
/* ----------------------------------------------------------------- */
.modal-overlay { position: fixed; inset: 0; z-index: 150; background: rgba(4,4,6,0.82); display: flex; align-items: center; justify-content: center; padding: 24px; backdrop-filter: blur(3px); }
.modal {
  position: relative;
  background: linear-gradient(170deg, #201a12, #14110b);
  border: 1px solid var(--brass-soft); border-radius: 6px;
  box-shadow: var(--shadow); max-width: 560px; width: 100%; padding: 30px 32px;
  animation: modal-rise .35s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes modal-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.modal-close { position: absolute; top: 11px; right: 15px; background: none; border: none; color: var(--fog); font-size: 26px; line-height: 1; cursor: pointer; }
.modal-close:hover { color: var(--paper); }
.modal-title { font-family: var(--display); font-weight: 400; font-size: 28px; color: var(--paper); margin-bottom: 7px; }
.modal-sub { color: var(--text-2); font-style: italic; margin: 0 0 20px; font-size: 15.5px; }

/* Intro — the cold-open dossier. */
.intro-modal { max-width: 660px; border-color: var(--brass-soft); overflow: hidden; }
.intro-grain { position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(255,255,255,0.016) 0 1px, transparent 1px 4px); }
.intro-title { font-family: var(--display); font-weight: 400; font-size: 41px; color: var(--brass); text-align: center; letter-spacing: 0.01em; margin-bottom: 20px; text-shadow: 0 2px 12px rgba(0,0,0,0.65); }
.intro-text { color: var(--paper); font-size: 18px; line-height: 1.72; white-space: pre-wrap; margin-bottom: 26px; }
.intro-text::first-letter { font-family: var(--display); font-size: 3.2em; float: left; line-height: 0.8; padding: 6px 10px 0 0; color: var(--brass); }
.intro-modal .btn { display: block; margin: 0 auto; }

/* Accuse — the verdict sheet. */
.accuse-form { display: flex; flex-direction: column; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-family: var(--label); font-size: 11px; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass); }
.accuse-form select { background: #0f0d09; border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 13px; font-size: 15.5px; color: var(--text); }
.accuse-form .btn-accuse { margin-top: 7px; justify-content: center; }
.accuse-result { margin-top: 18px; padding: 17px; border-radius: var(--radius); font-size: 16.5px; line-height: 1.62; }
.accuse-result.correct { background: rgba(90,163,163,0.13); border: 1px solid var(--teal); color: var(--paper); }
.accuse-result.wrong { background: rgba(154,48,48,0.16); border: 1px solid var(--blood-lit); color: #f0dada; }

.hint-text { color: var(--paper); font-size: 17.5px; line-height: 1.62; font-style: italic; }

/* ===================================================================
   Evidence notepad — top-bound reporter's pad; two-layer page flip.
   =================================================================== */
.notepad { position: relative; width: min(600px, 94vw); height: min(80vh, 740px); display: flex; flex-direction: column; filter: drop-shadow(0 28px 46px rgba(0,0,0,0.64)); animation: modal-rise .35s cubic-bezier(.2,.7,.2,1) both; }

.notepad-spiral { height: 30px; border-radius: 11px 11px 0 0; background: linear-gradient(180deg, #17120b, #100c07); position: relative; z-index: 3; box-shadow: 0 2px 6px rgba(0,0,0,0.4); }
.notepad-spiral::before { content: ""; position: absolute; left: 0; right: 0; top: 17px; height: 9px; background-image: radial-gradient(circle 4px at 17px 4px, #000 60%, rgba(0,0,0,0) 64%); background-size: 34px 9px; background-repeat: repeat-x; }
.notepad-spiral::after { content: ""; position: absolute; left: 0; right: 0; top: 4px; height: 16px; background-image: linear-gradient(105deg, transparent 0 9px, rgba(214,210,196,0.78) 9px 13px, rgba(120,116,104,0.6) 13px 25px, transparent 25px); background-size: 34px 16px; background-repeat: repeat-x; border-radius: 7px; }

.notepad-stage { flex: 1 1 auto; position: relative; perspective: 1900px; overflow: hidden; background: #cfc2a0; box-shadow: inset 0 16px 22px -16px rgba(0,0,0,0.55); }

/* Both sheets share the ruled-paper look; they stack in the stage. */
.notepad-page {
  position: absolute; inset: 0; overflow-y: auto;
  transform-origin: top center; backface-visibility: hidden;
  color: #243049; background-color: #f3ead2;
  background-image:
    radial-gradient(420px 300px at 88% 6%, rgba(150,110,60,0.10), transparent 70%),
    linear-gradient(90deg, transparent 0 47px, rgba(168,58,58,0.55) 47px 49px, transparent 49px),
    repeating-linear-gradient(180deg, transparent 0 31px, rgba(70,92,132,0.20) 31px 32px);
  background-attachment: local, local, local;
  padding: 26px 30px 44px 64px;
}
.notepad-under { z-index: 1; }
.notepad-top   { z-index: 2; }
/* The lifting sheet catches shadow toward the spiral as it curls up. */
.notepad-top::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; background: linear-gradient(180deg, rgba(18,11,4,0.55) 0%, rgba(18,11,4,0) 46%); transition: opacity .2s; }
.notepad-top.flip-up, .notepad-top.flip-down { z-index: 4; box-shadow: 0 34px 44px rgba(0,0,0,0.5); }
.notepad-top.flip-up::after, .notepad-top.flip-down::after { opacity: 1; }
.notepad-top.flip-up   { animation: pageFlipUp   .56s cubic-bezier(.37,.08,.21,1) forwards; }
.notepad-top.flip-down { animation: pageFlipDown .56s cubic-bezier(.37,.08,.21,1) forwards; }
@keyframes pageFlipUp   { 0% { transform: rotateX(0deg); } 100% { transform: rotateX(-122deg); } }
@keyframes pageFlipDown { 0% { transform: rotateX(-122deg); } 100% { transform: rotateX(0deg); } }
@media (prefers-reduced-motion: reduce) { .notepad-top.flip-up, .notepad-top.flip-down { animation-duration: .01s; } }

.page-inner { min-height: 100%; }
.page-tab { display: inline-block; font-family: var(--label); font-size: 10px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; color: #1c1308; background: linear-gradient(180deg, #d8a85b, #b9892f); padding: 3px 11px; border-radius: 2px; transform: rotate(-1.4deg); box-shadow: 0 2px 5px rgba(0,0,0,0.25); margin-bottom: 16px; }
.page-clue-name { font-family: var(--hand); font-weight: 700; font-size: 35px; line-height: 1.05; color: #1b2944; margin: 0; }
.page-clue-name::after { content: ""; display: block; width: 64%; height: 2px; margin-top: 5px; background: rgba(168,58,58,0.5); border-radius: 2px; transform: rotate(-0.5deg); }
.page-meta { font-family: var(--typewriter); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: #6a5436; margin: 13px 0 18px; }
.page-desc { font-family: var(--typewriter); font-size: 15px; line-height: 32px; color: #283450; white-space: pre-wrap; margin: 0; }
.page-empty { display: flex; flex-direction: column; justify-content: center; height: 100%; opacity: 0.8; }
.page-empty .page-clue-name::after { display: none; }

.notepad-foot { display: flex; align-items: center; justify-content: space-between; padding: 9px 14px; background: linear-gradient(180deg, #17120b, #100c07); border-radius: 0 0 11px 11px; z-index: 3; }
.notepad-nav { font-family: var(--label); font-size: 12px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brass); background: transparent; border: 1px solid var(--brass-soft); border-radius: 4px; padding: 7px 15px; cursor: pointer; transition: background .15s, opacity .15s; }
.notepad-nav:hover:not(:disabled) { background: rgba(216,168,91,0.14); }
.notepad-nav:disabled { opacity: 0.3; cursor: not-allowed; }
.notepad-pageno { font-family: var(--typewriter); font-size: 12px; letter-spacing: 0.06em; color: #cdb487; }
.notepad-close { position: absolute; top: -13px; right: -13px; z-index: 6; width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--blood-lit), var(--blood) 72%); border: 1px solid #6f2222; color: #f6e3e3; font-size: 20px; line-height: 1; cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,0.5); transition: transform .12s; }
.notepad-close:hover { transform: scale(1.07); }

/* ----------------------------------------------------------------- */
/* Scrollbars                                                         */
/* ----------------------------------------------------------------- */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: #0e0c08; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; border: 2px solid #0e0c08; }
::-webkit-scrollbar-thumb:hover { background: var(--raised); }
* { scrollbar-color: var(--line) #0e0c08; scrollbar-width: thin; }

/* ----------------------------------------------------------------- */
/* Responsive                                                         */
/* ----------------------------------------------------------------- */
@media (max-width: 1080px) {
  body { overflow: auto; }
  .board { grid-template-columns: 1fr; height: auto; }
  .rail, .middle { max-height: none; }
  .chat-panel { min-height: 340px; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .topbar { flex-direction: column; gap: 10px; align-items: stretch; }
  .topbar-actions { justify-content: space-between; }
  .map-grid { grid-template-columns: 1fr 1fr; }
}
