:root {
  color-scheme: dark;
  --bg: #14141c;
  --panel: #1e1e2a;
  --panel-border: #35354a;
  --text: #e8e6f0;
  --text-dim: #9c99b0;
  --accent: #f2c14e;
  --danger: #e35d5d;
  --good: #5da35d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", -apple-system, sans-serif;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-border);
}

#hud-title { font-weight: 700; color: var(--accent); }
#hud-round { color: var(--text-dim); font-size: 13px; }

.hidden { display: none !important; }

#start-screen, #reveal-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#intro-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: #000;
  font-family: "Special Elite", "Courier New", Courier, monospace;
}

#intro-number {
  font-size: 34px;
  color: #d8d4c8;
  letter-spacing: 0.05em;
}

#intro-title {
  font-size: 20px;
  color: #9c9890;
  letter-spacing: 0.03em;
}

#intro-number.typing::after,
#intro-title.typing::after {
  content: "\2588";
  margin-left: 2px;
  animation: cursor-blink 0.8s steps(1) infinite;
}

@keyframes cursor-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

#start-box, #reveal-box {
  max-width: 480px;
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  text-align: center;
}

#start-box h1 { color: var(--accent); margin-top: 0; }
#start-box p { color: var(--text-dim); line-height: 1.6; margin-bottom: 22px; }

#start-btn, #restart-btn, #charge-btn, #release-btn {
  padding: 12px 20px;
  background: var(--accent);
  color: #14141c;
  border: none;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
}
#start-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.secondary-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 10px 20px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}
.secondary-btn:hover { border-color: var(--accent); color: var(--text); }

#start-error { color: var(--danger); margin-top: 14px; font-size: 13px; white-space: pre-wrap; }

#difficulty-select { margin-bottom: 18px; }
.difficulty-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 700;
}
#difficulty-options { display: flex; gap: 8px; }
.difficulty-btn {
  flex: 1;
  padding: 9px 8px;
  background: #262636;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.difficulty-btn:hover { border-color: var(--accent); }
.difficulty-btn.selected {
  background: var(--accent);
  color: #14141c;
  border-color: var(--accent);
}

#game-screen {
  flex: 1;
  display: flex;
  gap: 12px;
  padding: 12px;
  min-height: 0;
}

.panel-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 700;
}

#left-column {
  width: 26%;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

#center-column {
  width: 38%;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

#room-panel {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

#case-info-panel {
  flex-shrink: 1;
  min-height: 0;
  max-height: 45%;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 14px;
  overflow-y: auto;
}
#case-type-badge {
  display: inline-block;
  padding: 2px 8px;
  margin-bottom: 6px;
  background: rgba(242, 193, 78, 0.12);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}
#case-title { font-weight: 700; color: var(--accent); font-size: 15px; margin-bottom: 6px; }
#case-brief { color: var(--text-dim); font-size: 13px; line-height: 1.6; white-space: pre-wrap; }

#room-scene {
  position: relative;
  flex: 1;
  background: radial-gradient(ellipse at 50% 20%, #23232f 0%, #16161e 100%);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  min-height: 160px;
  overflow: hidden;
  perspective: 700px;
}

.table-surface {
  position: absolute;
  left: 0%;
  top: 36%;
  width: clamp(60%, 750px - 40vw, 92%);
  height: 58%;
  background: linear-gradient(135deg, #4a4056 0%, #322a3c 100%);
  border: 2px solid #241f2c;
  border-radius: 12px;
  transform: scaleX(-1) rotateX(58deg) rotateZ(-30deg);
  box-shadow: 0 20px 30px rgba(0, 0, 0, 0.4);
}

.figure {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}

.portrait {
  border-radius: 50%;
  background: #2a2a38;
  border: 2px solid var(--panel-border);
  overflow: hidden;
  flex-shrink: 0;
}

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

.face-head { fill: #e8c9a0; transition: fill 0.4s ease; }
.ear { fill: #e8c9a0; }
.eyebrow rect { fill: #4a3626; }
.eyebrow { transform-box: fill-box; transform-origin: center; transition: transform 0.3s ease; }
.eye { fill: #241a12; }
.mouth { fill: none; stroke: #4a3626; stroke-width: 3; stroke-linecap: round; }
.sweat path { fill: #5da9e3; opacity: 0.85; }
.sweat { animation: drip 1.2s ease-in-out infinite; display: none; }

@keyframes drip {
  0%, 100% { transform: translateY(0); opacity: 0.85; }
  50% { transform: translateY(4px); opacity: 0.45; }
}

.portrait.shake { animation: shake 0.3s infinite; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

/* interrogator: large foreground silhouette, seen from behind, looking toward the suspect */
.interrogator-figure {
  left: -6%;
  bottom: -30px;
  z-index: 3;
}
.interrogator-figure .portrait {
  width: 156px;
  height: 156px;
  border-radius: 30px;
  background: radial-gradient(circle at 50% 32%, #4a3c30 0%, #2a2018 75%);
  border: 2px solid rgba(242, 193, 78, 0.35);
  box-shadow: 0 0 14px rgba(242, 193, 78, 0.15);
}
.interrogator-body {
  width: 196px;
  height: 66px;
  margin-top: -20px;
  background: #262230;
  border: 2px solid var(--panel-border);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
}

/* suspect: smaller, further away, sitting in the interrogator's line of sight */
.suspect-figure {
  right: 22%;
  top: 22%;
}
.suspect-figure .portrait {
  width: 82px;
  height: 82px;
}
.suspect-body {
  width: 92px;
  height: 30px;
  margin-top: -9px;
  background: #262230;
  border: 2px solid var(--panel-border);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
}

.char-label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  margin-top: 6px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

#detector-panel {
  flex-shrink: 0;
  height: 90px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 14px;
}

#misc-panel {
  flex: 1;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 14px;
  overflow-y: auto;
}

#stress-percent { color: var(--text-dim); font-size: 12px; margin-top: 6px; text-align: right; }

#evidence-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.evidence-card {
  padding: 10px 12px;
  background: #20202c;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}
.evidence-card.used { opacity: 0.55; }

.evidence-index {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 3px;
}

.evidence-name {
  font-weight: 700;
  color: var(--accent);
  font-size: 13px;
  margin-bottom: 6px;
}

.evidence-desc {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.55;
  margin-bottom: 8px;
}

.evidence-btn {
  width: 100%;
  padding: 7px 10px;
  background: #262636;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.evidence-btn:hover:not(:disabled) { border-color: var(--accent); }
.evidence-btn:disabled { opacity: 0.5; cursor: not-allowed; }

#right-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 14px;
  min-width: 260px;
  min-height: 0;
}

#transcript {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px;
  margin-bottom: 12px;
}

.bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
}

.bubble.interrogator {
  align-self: flex-start;
  background: #2a3a52;
  border-top-left-radius: 2px;
}

.bubble.suspect {
  align-self: flex-end;
  background: #3a2a2a;
  border-top-right-radius: 2px;
}

.bubble-speaker { font-size: 11px; color: var(--text-dim); margin-bottom: 3px; }

.bubble.system {
  align-self: center;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-style: italic;
}

.bubble.alert {
  align-self: center;
  max-width: 85%;
  background: rgba(227, 93, 93, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

#detector-panel.alert-flash {
  animation: detector-flash 0.5s ease-in-out 2;
}
@keyframes detector-flash {
  0%, 100% { border-color: var(--panel-border); box-shadow: none; }
  50% { border-color: var(--danger); box-shadow: 0 0 10px rgba(227, 93, 93, 0.5); }
}

.stress-bar {
  width: 100%;
  height: 14px;
  background: #262636;
  border-radius: 7px;
  overflow: hidden;
}

.stress-fill {
  height: 100%;
  width: 0%;
  background: var(--good);
  transition: width 0.3s ease, background 0.3s ease;
}

#controls {
  display: flex;
  gap: 8px;
}

.tactic-btn {
  flex: 1;
  padding: 12px 8px;
  background: #262636;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}
.tactic-btn small { color: var(--text-dim); font-weight: 400; display: block; margin-top: 3px; }
.tactic-btn:hover:not(:disabled) { border-color: var(--accent); }
.tactic-btn:disabled { opacity: 0.4; cursor: not-allowed; }

#tactic-pressure:hover:not(:disabled) { border-color: var(--danger); }
#tactic-empathy:hover:not(:disabled) { border-color: var(--good); }
#tactic-analytic:hover:not(:disabled) { border-color: #5da9e3; }

#verdict-row {
  margin-top: 10px;
  padding: 10px;
  background: #262636;
  border-radius: 8px;
  text-align: center;
}
#verdict-prompt { margin-bottom: 8px; color: var(--text-dim); font-size: 12px; }
#charge-btn, #release-btn { font-size: 12px; padding: 8px 12px; }
#charge-btn { background: var(--danger); color: white; margin-right: 8px; }
#release-btn { background: var(--good); color: white; }

#reveal-title { color: var(--accent); }
#reveal-message { line-height: 1.6; }
#reveal-truth { color: var(--text-dim); font-size: 13px; line-height: 1.6; border-top: 1px solid var(--panel-border); padding-top: 12px; }

#records-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  min-height: 0;
}

#records-box {
  width: 100%;
  max-width: 640px;
  max-height: 100%;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

#records-list-view, #record-detail-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#records-box h2 { color: var(--accent); margin-top: 0; }

#records-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  max-height: 50vh;
}

#records-empty { color: var(--text-dim); font-size: 13px; text-align: center; padding: 24px 0; }

.record-item {
  padding: 12px 14px;
  background: #20202c;
  border: 1px solid var(--panel-border);
  border-left: 3px solid var(--text-dim);
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
}
.record-item:hover { border-color: var(--accent); }
.record-item.record-success { border-left-color: var(--good); }
.record-item.record-fail { border-left-color: var(--danger); }

.record-item-title { font-weight: 700; color: var(--text); font-size: 14px; margin-bottom: 4px; }
.record-item-meta { color: var(--text-dim); font-size: 12px; }

#record-detail-view { text-align: left; }
#record-detail-title { color: var(--accent); margin-bottom: 4px; }
#record-detail-meta { color: var(--text-dim); font-size: 12px; margin-bottom: 16px; }

.record-detail-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 700;
  margin: 14px 0 6px;
}

#record-detail-brief {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

#record-detail-transcript {
  min-height: 160px;
  max-height: 260px;
  flex-shrink: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px;
  background: #16161e;
  border-radius: 8px;
}

#record-detail-result {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}
