:root {
  --bg-desk: #2b1e16;
  --manila-paper: #f4ecd8;
  --manila-border: #d2c3a5;
  --text-dark: #2c2825;
  --accent-red: #a82c2c;
  --header-gold: #c29b38;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body, html { width: 100%; height: 100%; overflow: hidden; font-family: 'Courier New', Courier, monospace; }

/* --- SYSTEM BAR STYLES --- */
#system-bar {
  height: 38px;
  background-color: #1a120c;
  color: #e6d7b9;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  font-size: 0.8rem;
  border-bottom: 2px solid var(--header-gold);
  z-index: 9999;
  position: relative;
}

.bar-left, .bar-right, .bar-center { display: flex; align-items: center; gap: 8px; }

.cbi-badge-container {
  display: flex; align-items: center; gap: 4px; background: #362417;
  padding: 2px 6px; border-radius: 3px; border: 1px solid var(--header-gold);
}
.cbi-star { color: var(--header-gold); }
.cbi-badge-text { font-weight: bold; font-size: 0.68rem; letter-spacing: 1px; color: #f4ecd8; }
.bar-title { font-weight: bold; font-size: 0.8rem; color: var(--header-gold); }

/* --- SEARCH BAR --- */
.search-wrapper { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 8px; font-size: 0.75rem; }
#cbi-search-input {
  background: #2b1c11; border: 1px solid var(--header-gold); color: #f4ecd8;
  padding: 4px 8px 4px 26px; border-radius: 12px; font-family: inherit;
  font-size: 0.75rem; width: 300px; outline: none;
}
#cbi-search-input:focus { border-color: #ffd700; box-shadow: 0 0 6px rgba(212, 175, 55, 0.4); }

#search-results-dropdown {
  position: absolute; top: 32px; left: 0; width: 380px;
  background: var(--manila-paper); border: 1px solid var(--manila-border);
  box-shadow: 4px 6px 16px rgba(0,0,0,0.6); border-radius: 4px;
  max-height: 280px; overflow-y: auto; z-index: 100000;
}
#search-results-dropdown.hidden { display: none; }
.search-result-item { padding: 8px 10px; border-bottom: 1px solid var(--manila-border); cursor: pointer; color: var(--text-dark); }
.search-result-item:hover { background-color: var(--header-gold); color: white; }
.search-result-title { font-weight: bold; font-size: 0.78rem; }
.search-result-type { font-size: 0.65rem; opacity: 0.8; }

/* --- DEDUCTION BANNER --- */
#deduction-banner {
  height: 22px; background-color: #120b07; color: #d2c3a5; display: flex;
  align-items: center; justify-content: center; gap: 8px; font-size: 0.72rem;
  font-style: italic; border-bottom: 1px solid #362417;
}

.app-launcher {
  background: #2e1f14; color: #f4ecd8; border: 1px solid #544133;
  padding: 3px 6px; font-family: inherit; font-size: 0.72rem; cursor: pointer; border-radius: 3px;
}
.app-launcher:hover { background: var(--header-gold); color: #1a120c; font-weight: bold; }
#system-clock { font-weight: bold; letter-spacing: 1px; color: var(--header-gold); font-size: 0.75rem; }

/* --- DESKTOP AREA --- */
#desktop { width: 100vw; height: calc(100vh - 60px); background-color: var(--bg-desk); position: relative; overflow: hidden; }

/* --- WINDOW BASE STYLES --- */
.window {
  position: absolute; background-color: var(--manila-paper);
  border: 1px solid var(--manila-border); box-shadow: 6px 6px 20px rgba(0, 0, 0, 0.5);
  border-radius: 4px; display: flex; flex-direction: column;
}

.window-header {
  background-color: #e6d7b9; border-bottom: 2px solid var(--manila-border);
  padding: 6px 10px; display: flex; justify-content: space-between; align-items: center;
  cursor: grab; user-select: none;
}
.window-header:active { cursor: grabbing; }

.stamp { font-size: 0.62rem; font-weight: bold; color: var(--accent-red); border: 1px solid var(--accent-red); padding: 1px 4px; margin-right: 6px; }
.window-title { font-weight: bold; color: var(--text-dark); font-size: 0.82rem; }
.window-controls .win-btn { background: transparent; border: none; font-weight: bold; font-size: 0.85rem; cursor: pointer; margin-left: 4px; color: var(--text-dark); }
.window-controls .win-btn:hover { color: var(--accent-red); }

.window-body { padding: 12px; color: var(--text-dark); font-size: 0.82rem; flex-grow: 1; }

/* --- TEAM BOARD WIDGET & AGENT PHOTOS --- */
.team-board-body { background: #e2d4b7; padding: 10px !important; }
.team-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.team-card {
  background: var(--manila-paper); border: 1px solid var(--manila-border);
  padding: 8px; border-radius: 4px; text-align: center; box-shadow: 2px 2px 6px rgba(0,0,0,0.15);
}
.director-card { border: 2px solid var(--header-gold); background: #fffdf0; }
.member-img-frame {
  width: 100%; 
  height: 130px; /* Increased slightly for better portrait proportions */
  background: #ebdcb8; 
  border: 1px solid var(--manila-border);
  display: flex; 
  justify-content: center; 
  align-items: center; 
  margin-bottom: 6px; 
  border-radius: 3px;
  overflow: hidden;
}

.roster-img { 
  width: 100%; 
  height: 100%; 
  object-fit: cover; 
  object-position: top center; /* <--- THIS FIXES THE HEAD CROP */
}
/* --- DIRECTOR PHOTO FRAME & ALIGNMENT --- */
.director-frame {
  background: #dcc89b;
  height: 110px; /* Matches roster image frame height */
  overflow: hidden;
}

#director-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center; /* Focuses on the head and neck */
  border-radius: 3px;
}
.member-name { font-weight: bold; font-size: 0.78rem; color: var(--text-dark); }
.member-role { font-size: 0.65rem; color: var(--accent-red); font-weight: bold; margin-bottom: 4px; }
.member-bio { font-size: 0.62rem; color: #555; line-height: 1.3; }
.upload-btn { margin-top: 6px; font-size: 0.62rem; padding: 2px 6px; border: 1px solid var(--manila-border); background: var(--header-gold); color: white; cursor: pointer; border-radius: 3px; }

/* --- DEVLOG PARAGRAPH STYLES --- */
.devlog-container { display: flex; padding: 0 !important; height: 300px; }
.devlog-sidebar { width: 180px; background-color: #ebdcb8; border-right: 1px solid var(--manila-border); padding: 8px; flex-shrink: 0; }
.sidebar-title { font-weight: bold; font-size: 0.72rem; color: var(--text-dark); margin-bottom: 6px; text-transform: uppercase; }
#devlog-list { list-style: none; }
.log-item { font-size: 0.72rem; padding: 5px 6px; margin-bottom: 4px; border-radius: 3px; cursor: pointer; color: var(--text-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-item:hover { background: #dfceaa; }
.log-item.active { background: var(--accent-red); color: white; font-weight: bold; }

.devlog-content { flex-grow: 1; padding: 12px; overflow-y: auto; line-height: 1.6; background-color: var(--manila-paper); }
.devlog-content h4 { color: var(--accent-red); margin-bottom: 4px; }
.devlog-content p { margin-bottom: 10px; text-align: justify; }

/* --- TEA & PINBOARD & NOTEPAD --- */
.tea-body { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.tea-icon { font-size: 2rem; animation: floatMug 3s ease-in-out infinite; }
@keyframes floatMug { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.tea-quote { font-style: italic; font-size: 0.72rem; color: #5a524a; }
.tea-presets { display: flex; gap: 4px; }
.tea-chip { background: #e2d4b7; border: 1px solid var(--manila-border); padding: 3px 6px; font-size: 0.68rem; font-family: inherit; cursor: pointer; border-radius: 3px; }
.tea-chip.active, .tea-chip:hover { background: var(--header-gold); color: white; }
.timer-display { font-size: 2.3rem; font-weight: bold; background: #eae0c8; width: 100%; padding: 6px 0; border-radius: 4px; border: 1px inset var(--manila-border); }
.tea-controls { display: flex; gap: 6px; width: 100%; }
.tea-btn { flex: 1; padding: 6px 0; font-family: inherit; font-weight: bold; border: 1px solid var(--manila-border); background: #e2d4b7; cursor: pointer; font-size: 0.75rem; }
.tea-btn.primary { background: var(--accent-red); color: white; }

.corkboard-body { background-color: #805229; border: 4px solid #523317; padding: 10px !important; }
.pinboard-grid { display: flex; gap: 12px; justify-content: space-around; margin-bottom: 10px; }
.polaroid-card { background: #ffffff; padding: 6px 6px 10px 6px; box-shadow: 4px 4px 10px rgba(0,0,0,0.5); text-align: center; position: relative; width: 130px; transform: rotate(-2deg); }
.polaroid-card:nth-child(2) { transform: rotate(3deg); }
.pin.red-pin { width: 10px; height: 10px; background: var(--accent-red); border-radius: 50%; position: absolute; top: 4px; left: 50%; transform: translateX(-50%); }
/* --- POLAROID EVIDENCE SUSPECT IMAGES --- */
.polaroid-img-box {
  background: #e6e6e6;
  height: 95px; /* Increased slightly for clear framing */
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 6px;
  overflow: hidden;
  border: 1px solid #d0d0d0;
}

.polaroid-img-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center; /* Keeps upper body and head in frame */
}
.placeholder-suspect { font-size: 2.2rem; }
.polaroid-label { font-weight: bold; font-size: 0.72rem; color: #2c2825; }
.polaroid-status { font-size: 0.62rem; margin-top: 4px; padding: 2px; font-weight: bold; }
.status-cleared { background: #d4edda; color: #155724; }
.status-wanted { background: #f8d7da; color: #721c24; }
.pinboard-footer { display: flex; justify-content: space-between; font-size: 0.62rem; color: #f4ecd8; border-top: 1px dashed #b38053; padding-top: 4px; }

.notepad-body { display: flex; flex-direction: column; padding: 8px !important; background: #fffdf2; }
.notepad-toolbar { display: flex; gap: 6px; margin-bottom: 6px; }
.notes-btn { background: var(--header-gold); color: white; border: none; padding: 4px 8px; font-family: inherit; font-size: 0.7rem; cursor: pointer; border-radius: 3px; font-weight: bold; }
.notes-select { flex-grow: 1; font-family: inherit; font-size: 0.7rem; padding: 3px; border: 1px solid var(--manila-border); background: #f4ecd8; }
#field-notes { width: 100%; height: 160px; background: transparent; border: none; resize: none; font-family: 'Courier New', Courier, monospace; font-size: 0.82rem; line-height: 1.5; color: #2c2825; outline: none; background-image: linear-gradient(#e1d9c6 1px, transparent 1px); background-size: 100% 1.5rem; }
.notepad-status { font-size: 0.62rem; color: #776e65; text-align: right; margin-top: 4px; }

.ambient-body { display: flex; flex-direction: column; gap: 12px; padding: 14px; }
.ambient-options { display: flex; flex-direction: column; gap: 8px; }
.sound-radio { font-size: 0.75rem; display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* --- REAL CBI BADGE EASTER EGG (BOTTOM LEFT) --- */
#cbi-badge-egg {
  position: absolute; bottom: 12px; left: 18px; cursor: pointer; opacity: 0.85;
  transition: all 0.3s; display: flex; align-items: center; gap: 6px;
  background: rgba(26, 18, 12, 0.85); border: 1px solid var(--header-gold);
  padding: 4px 8px; border-radius: 4px;
}
#cbi-badge-egg:hover { opacity: 1; transform: scale(1.08); box-shadow: 0 0 10px var(--header-gold); }
.cbi-badge-icon { font-size: 1.2rem; color: var(--header-gold); }
.badge-tag { font-size: 0.7rem; font-weight: bold; color: #f4ecd8; }

/* --- CBI CONSULTANT BADGE MODAL --- */
#cbi-credential-modal {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.75); z-index: 999999;
  display: flex; justify-content: center; align-items: center;
}
#cbi-credential-modal.hidden { display: none; }
.modal-card {
  background: var(--manila-paper); border: 2px solid var(--header-gold);
  border-radius: 6px; width: 440px; box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}
.modal-header {
  background: #2b1c11; color: var(--header-gold); padding: 8px 12px;
  display: flex; justify-content: space-between; align-items: center; font-weight: bold; font-size: 0.8rem;
}
.modal-body { padding: 16px; }
.modal-subtitle { font-size: 0.75rem; margin-bottom: 8px; color: #444; }
.badge-label { font-size: 0.72rem; font-weight: bold; color: var(--text-dark); margin-top: 6px; display: block; }
.badge-input { width: 100%; padding: 6px; margin-top: 4px; margin-bottom: 10px; font-family: inherit; font-size: 0.78rem; border: 1px solid var(--manila-border); background: #fffdf0; }

.official-cbi-badge-id {
  background: linear-gradient(135deg, #2b1c11 0%, #120b07 100%);
  border: 2px solid var(--header-gold); border-radius: 6px; padding: 14px; color: #f4ecd8;
}
.badge-top-bar { font-size: 0.65rem; font-weight: bold; letter-spacing: 1px; color: var(--header-gold); text-align: center; border-bottom: 1px solid var(--header-gold); padding-bottom: 4px; margin-bottom: 8px; }
.badge-id-body { display: flex; gap: 12px; align-items: center; }
.badge-star-seal { font-size: 3.2rem; color: var(--header-gold); }
.badge-details h3 { font-size: 0.98rem; color: #fff; }
.badge-details p { font-size: 0.72rem; color: #d2c3a5; margin-top: 2px; }
.badge-serial { font-size: 0.62rem; color: var(--header-gold); font-weight: bold; margin-top: 6px; display: block; }
.badge-signature { font-size: 0.6rem; font-style: italic; color: #aaa; text-align: right; margin-top: 10px; border-top: 1px dashed #443; padding-top: 4px; }

/* --- CONTEXT MENU & SCARY OVERLAY --- */
#context-menu { position: absolute; background-color: var(--manila-paper); border: 1px solid var(--manila-border); box-shadow: 4px 4px 14px rgba(0,0,0,0.5); border-radius: 3px; width: 180px; z-index: 100000; }
#context-menu.hidden { display: none; }
#context-menu ul { list-style: none; padding: 4px 0; }
#context-menu li { padding: 6px 10px; font-size: 0.75rem; color: var(--text-dark); cursor: pointer; }
#context-menu li:hover { background-color: var(--header-gold); color: white; }

#red-john-egg { position: absolute; bottom: 12px; right: 18px; cursor: pointer; opacity: 0.4; transition: all 0.3s; }
#red-john-egg:hover { opacity: 1; transform: scale(1.2); }
.rj-smiley { font-weight: bold; font-size: 1.5rem; color: var(--accent-red); font-family: 'Georgia', serif; }

#rj-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(10, 0, 0, 0.92); z-index: 999999; display: flex; justify-content: center; align-items: center; flex-direction: column; pointer-events: none; }
#rj-overlay.hidden { display: none; }
.rj-giant-smiley { font-size: 10rem; color: #cc0000; font-family: 'Georgia', serif; font-weight: bold; text-shadow: 0 0 25px #ff0000; }
.rj-scary-text { color: #ff4d4d; font-size: 1rem; letter-spacing: 4px; margin-top: 10px; font-weight: bold; }
#blood-drips-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; }
.blood-drop { position: absolute; top: -30px; width: 8px; height: 30px; background: #cc0000; border-radius: 0 0 8px 8px; box-shadow: 0 0 8px #800000; animation: dropFall linear infinite; }
@keyframes dropFall { 0% { transform: translateY(-30px); opacity: 1; } 100% { transform: translateY(100vh); opacity: 0.2; } }

body.dark-mode { --bg-desk: #0a0807; --manila-paper: #181412; --manila-border: #421616; --text-dark: #f0e6e6; --accent-red: #ff3b3b; --header-gold: #8f1d1d; }
body.dark-mode #system-bar { background-color: #050404; border-bottom: 2px solid #8f1d1d; }
body.dark-mode #deduction-banner { background-color: #050404; color: #f0e6e6; }
body.dark-mode .window-header { background-color: #2b1111; }
body.dark-mode .devlog-sidebar, body.dark-mode .timer-display { background-color: #221212; }
body.dark-mode #field-notes { color: #f0e6e6; }
body.dark-mode #context-menu { background-color: #1a1818; border-color: #3d1414; }
body.dark-mode #context-menu li { color: #f0e6e6; }
body.dark-mode #context-menu li:hover { background-color: #8f1d1d; }