/* --- Custom properties --- */
/* CSS custom properties (variables) — like constants, defined once, reused everywhere.
   The `:root` selector targets the <html> element, making these globally available. */
:root {
  --bg: #08080a;
  --surface: #0e0e12;
  --surface-raised: #14141a;
  --border: #1e1e28;
  --border-subtle: #16161e;

  --text-primary: #e2e2ea;
  --text-secondary: #9898a8;
  --text-muted: #808090;

  /* Amber/ochre accent — cold, clinical, institutional */
  --accent: #c49a40;
  --accent-dim: #a07e38;
  --accent-glow: rgba(196, 154, 64, 0.08);

  /* Human = stark white presence */
  --human: #e8e8e8;
  --human-dim: #5a5a5a;
  --human-bg: rgba(232, 232, 232, 0.04);

  /* Verdict colors */
  --pass: #6aaa64;
  --fail: #c45040;

  --font-display: "DM Serif Display", "Georgia", serif;
  --font-body: "IBM Plex Mono", "SF Mono", "Consolas", monospace;

  --radius: 2px;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --- Noise overlay ---
   Creates a subtle film grain / CRT texture over the whole page.
   Generated using an SVG filter embedded as a data URL. `pointer-events: none`
   ensures it doesn't block clicks. */
.noise-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 16px;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  -webkit-font-smoothing: antialiased;
  /* Subtle radial vignette — darkens the edges of the viewport */
  background-image: radial-gradient(ellipse at center, transparent 0%, rgba(0,0,0,0.4) 100%);
  background-attachment: fixed;
}

main {
  width: 100%;
  max-width: 640px;
  padding: 2rem;
}

/* --- Screen management --- */
.screen {
  display: none;
  width: 100%;
}

.screen.active {
  display: flex;
  flex-direction: column;
  /* Fade-in animation when a screen becomes active */
  animation: screenIn 0.6s ease-out;
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Landing screen --- */
.landing-content {
  text-align: left;
}

/* --- Memo: sci-fi artifact / intercepted document ---
   Meant to look like something you weren't supposed to see.
   Faded, slightly degraded, monospaced. */
.memo {
  margin-bottom: 2rem;
  padding: 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  position: relative;
  /* Slight transparency — like a faded printout */
  opacity: 0.75;
}

.memo-header {
  margin-bottom: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border-subtle);
}

.memo-classification {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent-dim);
  margin-bottom: 0.3rem;
}

.memo-dept {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
}

.memo-meta {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-style: italic;
}

.memo-body {
  font-size: 0.75rem;
  font-weight: 300;
  color: var(--text-muted);
  line-height: 1.8;
}

.memo-body p {
  margin-bottom: 0.7rem;
}

.memo-body p:last-child {
  margin-bottom: 0;
}

.memo-footer {
  padding-top: 0.5rem;
  font-style: italic;
  color: var(--text-muted);
}

/* --- Instructions: addressed to the participant ---
   Brighter, clearer, more prominent. This is what they need to read. */
.instructions {
  margin-bottom: 2.5rem;
  padding: 1.5rem;
  background: var(--surface-raised);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  /* `box-shadow` with the accent color gives a subtle warm glow
     around the border, drawing the eye here */
  box-shadow: 0 0 20px rgba(196, 154, 64, 0.06);
}

.instructions-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 1rem;
}

.instructions p {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.8;
  margin-bottom: 0.8rem;
}

.instructions p:last-child {
  margin-bottom: 0;
}

/* `strong` tags inside instructions get the accent color for emphasis */
.instructions strong {
  color: var(--accent);
  font-weight: 600;
}

/* --- Buttons --- */
.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 0.75rem 2rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.2s ease;
  position: relative;
}

.btn-primary:hover {
  background: #d4a84a;
  /* `box-shadow` creates a glow effect — the large blur radius with low opacity
     makes it look like light emission rather than a drop shadow. */
  box-shadow: 0 0 30px rgba(196, 154, 64, 0.2);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 0.75rem 2rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

/* --- Game screen --- */
.game-header {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.progress {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.progress-sep {
  color: var(--border);
  margin: 0 0.2em;
}

/* Highlight the round number */
#round-num {
  color: var(--accent);
}

.chat-area {
  flex: 1;
  min-height: 280px;
  max-height: 55vh;
  overflow-y: auto;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  /* Hide scrollbar but keep scrolling — cleaner look */
  scrollbar-width: none;
}

.chat-area::-webkit-scrollbar {
  display: none;
}

/* Chat messages */
.msg {
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  line-height: 1.6;
  max-width: 88%;
  font-size: 0.85rem;
  /* Messages fade in when appended */
  animation: msgIn 0.4s ease-out;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-judge {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--border-subtle);
  align-self: flex-start;
  font-weight: 400;
}

.msg-human {
  background: var(--human-bg);
  color: var(--human);
  border: 1px solid var(--human-dim);
  align-self: flex-end;
  font-weight: 300;
}

/* --- Input area --- */
.input-area {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s ease;
}

/* `focus-within` triggers when ANY child element inside has focus —
   here it highlights the wrapper when the input is focused. */
.input-wrapper:focus-within {
  border-color: var(--accent-dim);
}

.input-prompt {
  color: var(--accent-dim);
  padding: 0 0.5rem 0 0.8rem;
  font-size: 0.85rem;
  font-weight: 500;
  /* `user-select: none` prevents the caret symbol from being selectable */
  user-select: none;
}

#answer-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 0.8rem 0.8rem 0.8rem 0;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 300;
  outline: none;
}

/* `::placeholder` styles the input's placeholder text */
#answer-input::placeholder {
  color: var(--text-muted);
  font-weight: 300;
}

.btn-send {
  background: var(--surface-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 0.8rem 1.2rem;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.15s ease;
}

.btn-send:hover {
  background: var(--border);
  color: var(--text-primary);
}

/* Loading indicator */
.loading-dots::after {
  content: "";
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
}

/* Disabled state */
.input-area.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* --- Verdict screen --- */
.verdict-content {
  text-align: left;
}

.verdict-eyebrow {
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  margin-bottom: 1rem;
  text-align: center;
}

.verdict-result {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  font-weight: 400;
  text-align: center;
  margin-bottom: 2.5rem;
  line-height: 1.3;
}

.verdict-result.win {
  color: var(--pass);
  text-shadow: 0 0 60px rgba(106, 170, 100, 0.15);
}

.verdict-result.lose {
  color: var(--fail);
  text-shadow: 0 0 60px rgba(196, 80, 64, 0.15);
}

.verdict-section-label {
  font-size: 0.6rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent-dim);
  margin-bottom: 0.8rem;
}

/* Interview transcript blocks */
.verdict-rounds {
  margin-bottom: 2rem;
}

.interview-block {
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
}

.interview-header {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
}

/* Color the header differently for you vs AI */
.interview-you .interview-header {
  color: var(--human);
  border-left: 2px solid var(--human-dim);
}

.interview-ai .interview-header {
  color: var(--accent);
  border-left: 2px solid var(--accent-dim);
}

.interview-round {
  border-bottom: 1px solid var(--border-subtle);
}

.interview-round:last-of-type {
  border-bottom: none;
}

.interview-question {
  padding: 0.8rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 400;
  font-style: italic;
  line-height: 1.6;
  background: var(--surface);
}

.interview-answer {
  padding: 0.8rem;
  font-size: 0.82rem;
  font-weight: 300;
  line-height: 1.7;
  color: var(--text-primary);
}

.interview-you .interview-answer {
  background: var(--human-bg);
}

.interview-ai .interview-answer {
  background: var(--accent-glow);
}

.interview-analysis {
  padding: 0.8rem;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-style: italic;
  font-weight: 300;
  line-height: 1.7;
  border-top: 1px solid var(--border-subtle);
}

/* Summary + provocation */
.verdict-summary-section {
  margin-bottom: 2rem;
}

.verdict-summary {
  color: var(--text-secondary);
  line-height: 1.8;
  font-size: 0.85rem;
  font-weight: 300;
}

.verdict-provocation {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  margin-bottom: 2.5rem;
  text-align: center;
}

.provocation-text {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.6;
}

.verdict-actions {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
}

/* --- Responsive --- */
@media (max-width: 480px) {
  main {
    padding: 1.5rem;
  }

  h1 {
    font-size: 2.4rem;
  }

  .round-answers {
    /* Stack answers vertically on narrow screens */
    grid-template-columns: 1fr;
  }

  .round-answer.you {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  .verdict-actions {
    flex-direction: column;
  }

  .btn-primary, .btn-secondary {
    width: 100%;
    text-align: center;
  }
}
