/**
 * The Chronomancer's Ledger — Style Architecture
 * Victorian Steampunk / Clockwork Cyberpunk Aesthetics
 */

:root {
  --bg-deep: #0f0c09;
  --bg-panel: #1b1612;
  --bg-card: #26201a;
  --bg-terminal: #0a0806;
  --brass: #c8963e;
  --brass-light: #e6b86a;
  --brass-dark: #6e4e18;
  --amber: #f5a623;
  --crimson: #c8372d;
  --violet: #ab5bf5;
  --cyan: #4ecdc4;
  --text-main: #e8dccb;
  --text-muted: #a69886;
  --font-mono: "Courier New", Courier, monospace;
  --font-serif: "Georgia", "Palatino", serif;
}

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

body {
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-serif);
  overflow-x: hidden;
  user-select: none;
  min-height: 100vh;
}

/* Atmospheric CRT Scanline & Grain Overlay */
.steampunk-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
              radial-gradient(circle at 50% 50%, transparent 65%, rgba(0,0,0,0.6) 100%);
  background-size: 100% 4px, 100% 100%;
  z-index: 999;
}

#game-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  border-left: 2px solid var(--brass-dark);
  border-right: 2px solid var(--brass-dark);
}

/* ==========================================================================
   TOP HUD BAR
   ========================================================================== */
#hud-header {
  background: linear-gradient(180deg, #241d16 0%, #17120e 100%);
  border-bottom: 2px solid var(--brass);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  gap: 15px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.6);
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud-gear-icon {
  font-size: 28px;
  color: var(--brass-light);
  display: inline-block;
  animation: slowGear 24s linear infinite;
}

@keyframes slowGear {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.hud-title {
  font-size: 1.15rem;
  letter-spacing: 2px;
  color: var(--brass-light);
  text-shadow: 0 0 10px rgba(230, 184, 106, 0.4);
}

.hud-sub {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 1.5px;
  color: var(--amber);
  display: block;
}

/* Clock Meter */
.hud-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 180px;
}

.clock-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}

.clock-label strong {
  color: var(--amber);
}

.clock-label strong.danger-flash {
  color: var(--crimson);
  animation: flashUrgent 0.8s ease infinite alternate;
}

@keyframes flashUrgent {
  from { opacity: 0.4; }
  to { opacity: 1; transform: scale(1.05); }
}

.clock-meter-frame {
  width: 100%;
  height: 8px;
  background: #110e0a;
  border: 1px solid var(--brass-dark);
  border-radius: 4px;
  overflow: hidden;
}

.clock-meter-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--crimson), var(--amber), var(--cyan));
  transition: width 0.4s ease;
}

/* Navigation Tabs & Controls */
.hud-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-tabs {
  display: flex;
  background: #110e0b;
  border: 1px solid var(--brass-dark);
  border-radius: 4px;
  padding: 2px;
}

.tab-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--brass-dark);
  color: var(--brass-light);
  box-shadow: inset 0 0 6px rgba(0,0,0,0.6);
}

.hud-btn {
  background: #261f18;
  border: 1px solid var(--brass-dark);
  color: var(--text-main);
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}

.hud-btn:hover {
  background: #362c23;
  border-color: var(--brass);
}

.hud-btn.btn-gold {
  background: linear-gradient(180deg, #7a5518 0%, #4a3410 100%);
  border-color: var(--brass-light);
  color: #fff2d1;
  font-weight: bold;
}

.hud-btn.btn-gold:hover {
  box-shadow: 0 0 12px rgba(230, 184, 106, 0.4);
}

/* ==========================================================================
   MAIN STAGE
   ========================================================================== */
#main-stage {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

/* 1. ROOM VIEWPORT */
.room-viewport {
  display: flex;
  flex-direction: column;
  background: #110c08;
  border: 2px solid var(--brass-dark);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.7);
}

.room-canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
}

.room-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.room-hotspots-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.room-hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.hotspot-beacon {
  width: 32px;
  height: 32px;
  background: radial-gradient(circle, #e6b86a 0%, #7a5518 100%);
  border: 2px solid #fff2d1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1208;
  font-size: 16px;
  font-weight: bold;
  box-shadow: 0 0 12px rgba(230, 184, 106, 0.8);
  transition: transform 0.2s ease;
}

.room-hotspot:hover .hotspot-beacon {
  transform: scale(1.25) rotate(45deg);
}

.hotspot-pulse {
  position: absolute;
  width: 48px;
  height: 48px;
  border: 2px solid var(--amber);
  border-radius: 50%;
  animation: beaconPulse 1.8s infinite ease-out;
  pointer-events: none;
}

@keyframes beaconPulse {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}

.hotspot-label {
  position: absolute;
  top: 38px;
  background: rgba(15, 12, 9, 0.92);
  border: 1px solid var(--brass);
  color: #fff2d1;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

.room-hotspot:hover .hotspot-label {
  opacity: 1;
  transform: translateY(0);
}

/* NPC Marker in Room */
.room-npc-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: pointer;
  z-index: 12;
  text-align: center;
}

.npc-silhouette {
  width: 42px;
  height: 42px;
  background: linear-gradient(180deg, #c8963e, #4a3410);
  border: 2px solid #ffd56b;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 0 15px rgba(200, 150, 62, 0.7);
  transition: transform 0.2s;
}

.room-npc-marker:hover .npc-silhouette {
  transform: scale(1.18);
}

.npc-bubble {
  position: absolute;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%);
  background: #361f14;
  border: 1px solid #ffd56b;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 12px;
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(0,0,0,0.8);
}

.room-footer-bar {
  background: #1c150f;
  border-top: 1px solid var(--brass-dark);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.room-title-tag {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--brass-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-nav-chips {
  display: flex;
  gap: 8px;
}

.nav-chip {
  background: #2b1f14;
  border: 1px solid var(--brass-dark);
  color: var(--text-muted);
  padding: 5px 12px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-chip:hover, .nav-chip.active {
  background: var(--brass-dark);
  color: var(--brass-light);
  border-color: var(--brass-light);
}

/* ==========================================================================
   2. INTERROGATION GRID
   ========================================================================== */
.interrogation-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  height: 540px;
}

/* Suspect Panel */
.suspect-panel {
  background: var(--bg-panel);
  border: 2px solid var(--brass-dark);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.suspect-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.npc-switch-btn {
  background: #14100c;
  border: 1px solid var(--brass-dark);
  color: var(--text-muted);
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.npc-switch-btn.active {
  background: #3b2816;
  border-color: var(--brass-light);
  color: var(--brass-light);
}

.portrait-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 200px;
  margin: 0 auto;
  border: 2px solid var(--brass);
  border-radius: 50%;
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.9), 0 0 15px rgba(200, 150, 62, 0.3);
}

.npc-portrait-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.status-tags {
  position: absolute;
  bottom: 8px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 6px;
}

.status-chip {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.2);
}

.emotion-idle { background: #3d3b38; color: #ddd; }
.emotion-nervous { background: #1c3d52; color: #8ad2ff; border-color: #8ad2ff; }
.emotion-angry { background: #521c1c; color: #ff8a8a; border-color: #ff8a8a; }
.emotion-smug { background: #441c52; color: #df8aff; border-color: #df8aff; }

.mood-calm { background: #123d38; color: #7cf2d9; }
.mood-tense { background: #523c12; color: #ffd675; }
.mood-danger { background: #521212; color: #ff6e6e; animation: flashUrgent 1s infinite alternate; }
.mood-reveal { background: #423005; color: #ffe68a; border-color: #ffe68a; }

.suspect-bio h2 {
  font-size: 1.1rem;
  color: var(--brass-light);
}

.suspect-role {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 8px;
}

.meter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.meter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.meter-label {
  width: 50px;
  color: var(--text-muted);
}

.meter-track {
  flex: 1;
  height: 8px;
  background: #110e0b;
  border: 1px solid var(--brass-dark);
  border-radius: 4px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  transition: width 0.4s ease;
}

.trust-fill { background: linear-gradient(90deg, #1b665f, var(--cyan)); }
.stress-fill { background: linear-gradient(90deg, #661b1b, var(--crimson)); }

.meter-num {
  width: 35px;
  text-align: right;
  color: var(--text-main);
}

.memory-summary-box {
  background: #110d09;
  border: 1px dashed var(--brass-dark);
  padding: 8px;
  border-radius: 4px;
}

.summary-title {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--amber);
  display: block;
  margin-bottom: 4px;
}

.memory-summary-box p {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.3;
}

/* Right Dialogue Panel */
.dialogue-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dialogue-screen {
  flex: 1;
  background: var(--bg-terminal);
  border: 2px solid var(--brass);
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: inset 0 0 25px rgba(0,0,0,0.9);
}

.terminal-header {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--brass-dark);
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #241d14;
  padding-bottom: 8px;
  margin-bottom: 14px;
}

.clock-tick-indicator {
  color: var(--cyan);
}

.terminal-body {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  line-height: 1.6;
  color: #fff3db;
  text-shadow: 0 0 5px rgba(255, 243, 219, 0.3);
  position: relative;
}

.floating-delta {
  margin-top: 15px;
  padding: 6px 10px;
  background: #241b12;
  border: 1px solid var(--brass);
  border-radius: 4px;
  display: inline-block;
  font-size: 0.8rem;
}

.trust-up { color: var(--cyan); font-weight: bold; }
.trust-down { color: #888; }
.stress-up { color: var(--crimson); font-weight: bold; }
.stress-down { color: #888; }

.quick-ask-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-ask-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.quick-chip {
  background: #261e16;
  border: 1px solid var(--brass-dark);
  color: var(--text-main);
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-chip:hover {
  background: var(--brass-dark);
  color: #fff;
}

.interrogate-console {
  background: var(--bg-panel);
  border: 1px solid var(--brass-dark);
  border-radius: 6px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.console-row {
  display: flex;
  gap: 8px;
}

.clue-select {
  width: 100%;
  background: #14100c;
  border: 1px solid var(--brass-dark);
  color: var(--amber);
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  border-radius: 4px;
}

.input-row input {
  flex: 1;
  background: #14100c;
  border: 1px solid var(--brass-dark);
  color: #fff;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  border-radius: 4px;
}

.input-row input:focus {
  outline: none;
  border-color: var(--brass-light);
}

.console-btn {
  background: linear-gradient(180deg, #7a5518, #4a3410);
  border: 1px solid var(--brass-light);
  color: #fff2d1;
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: bold;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.console-btn:hover {
  box-shadow: 0 0 10px rgba(230, 184, 106, 0.5);
}

/* ==========================================================================
   BOTTOM EVIDENCE LOCKER (INVENTORY)
   ========================================================================== */
#evidence-shelf {
  background: #140f0b;
  border-top: 2px solid var(--brass);
  padding: 12px 20px;
}

.shelf-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.shelf-title {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--brass-light);
  letter-spacing: 1px;
}

.shelf-hint {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.clue-card {
  background: #241c14;
  border: 1px solid var(--brass-dark);
  border-radius: 4px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.clue-card:hover {
  border-color: var(--brass);
  background: #312519;
  transform: translateY(-2px);
}

.clue-icon {
  font-size: 20px;
}

.clue-info {
  flex: 1;
}

.clue-name {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--brass-light);
}

.clue-desc {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.clue-present-btn {
  background: #473216;
  border: 1px solid var(--brass);
  color: #fff2d1;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 4px 6px;
  border-radius: 3px;
  cursor: pointer;
}

.clue-present-btn:hover {
  background: var(--brass);
  color: #1a1208;
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-backdrop.active {
  display: flex;
}

.modal-box {
  background: #1e1711;
  border: 2px solid var(--brass);
  border-radius: 6px;
  width: 90%;
  max-width: 580px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.9);
  padding: 20px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--brass-dark);
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.modal-header h3 {
  font-size: 1rem;
  color: var(--brass-light);
  font-family: var(--font-mono);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}

.modal-close:hover {
  color: #fff;
}

.audit-intro {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.4;
}

.audit-form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--amber);
  margin-bottom: 6px;
}

.form-select {
  width: 100%;
  background: #110e0b;
  border: 1px solid var(--brass-dark);
  color: var(--text-main);
  padding: 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.radio-options, .checkbox-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #14100c;
  padding: 10px;
  border-radius: 4px;
  border: 1px solid #261f17;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.audit-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.submit-audit-btn {
  width: 100%;
  background: linear-gradient(180deg, #94671e, #593b0f);
  border: 2px solid var(--brass-light);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: bold;
  padding: 12px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 10px;
  box-shadow: 0 4px 15px rgba(200, 150, 62, 0.4);
}

.submit-audit-btn:hover {
  background: linear-gradient(180deg, #b88126, #6b4712);
}

/* Verdict Modal */
.verdict-banner {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: bold;
  padding: 6px;
  border-radius: 4px;
  margin-bottom: 12px;
}

.verdict-banner.success {
  background: #14402a;
  color: #6effaa;
  border: 1px solid #6effaa;
}

.verdict-banner.failure {
  background: #471714;
  color: #ff756b;
  border: 1px solid #ff756b;
}

.verdict-text {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-main);
  margin-bottom: 16px;
}

.modal-action-btn {
  width: 100%;
  background: var(--brass-dark);
  border: 1px solid var(--brass);
  color: #fff;
  padding: 8px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  border-radius: 4px;
  cursor: pointer;
}

/* Toast Container */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}

.toast {
  background: #241b12;
  border-left: 4px solid var(--brass);
  color: #fff2d1;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 10px 16px;
  border-radius: 4px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.8);
  transition: opacity 0.3s;
}

.toast-success { border-left-color: var(--cyan); }
.toast-danger { border-left-color: var(--crimson); }
.toast-warning { border-left-color: var(--amber); }

@media (max-width: 900px) {
  .interrogation-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
}
