:root {
  --bg: #ffffff;
  --panel: #f7f5f0;
  --text: #1c1c1c;
  --muted: #6b6b64;
  --accent: #a5342f;
  --idiot-color: #7a5324;
  --you-color: #1f3f6e;
  --border: #d9d5c7;
  --font: "Special Elite", "Courier Prime", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.hidden {
  display: none !important;
}

/* Intro screen */
#intro-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.intro-box {
  max-width: 560px;
  width: 100%;
  text-align: center;
}

.intro-box h1 {
  font-size: 1.5rem;
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}

.tagline {
  color: var(--muted);
  margin-bottom: 28px;
  line-height: 1.6;
}

.intro-label {
  display: block;
  text-align: left;
  margin-bottom: 8px;
  font-weight: 700;
}

#intro-input {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text);
  padding: 12px;
  font-size: 1rem;
  font-family: inherit;
}

#fight-btn {
  margin-top: 16px;
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  letter-spacing: 0.03em;
  font-family: inherit;
}

#fight-btn:hover {
  filter: brightness(1.1);
}

#fight-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Chat / book screen */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.chat-header h2 {
  font-size: 1.05rem;
  margin: 0;
  letter-spacing: 0.04em;
}

#start-over-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 2px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
}

#start-over-btn:hover {
  color: var(--text);
  border-color: var(--muted);
}

.book {
  flex: 1;
  overflow-y: auto;
  padding: 36px 24px 60px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.epigraph {
  font-style: italic;
  color: var(--muted);
  text-align: center;
  padding: 0 16px 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 26px;
  line-height: 1.7;
}

.epigraph::before {
  content: open-quote;
}

.epigraph::after {
  content: close-quote;
}

.chapter {
  padding-bottom: 22px;
  margin-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}

.chapter:last-child {
  border-bottom: none;
}

.chapter-label {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 16px;
}

.chapter-line {
  line-height: 1.75;
  font-size: 1.05rem;
  margin: 0 0 12px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.chapter-line .speaker {
  font-weight: 700;
}

.chapter-line.idiot .speaker {
  color: var(--idiot-color);
}

.chapter-line.you .speaker {
  color: var(--you-color);
}

.typing-cursor {
  display: inline-block;
  width: 0.5em;
  animation: blink 0.9s steps(1) infinite;
}

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

/* Inline answer editor, written directly into the current chapter */
.you-line {
  line-height: 1.75;
  font-size: 1.05rem;
  margin: 0 0 4px;
}

.answer-input {
  display: inline-block;
  min-width: 200px;
  outline: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  min-width: 40px;
  border-bottom: 1px solid var(--border);
}

.answer-input:empty::before {
  content: "type your answer here...";
  color: var(--muted);
  font-style: italic;
}

.answer-hint {
  color: var(--muted);
  font-size: 0.78rem;
  margin: -8px 0 18px;
  font-style: italic;
}

.footnote {
  margin: 0 0 14px;
}

.footnote summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: italic;
}

.footnote-text {
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 200px;
  overflow-y: auto;
  padding: 6px 0 0 14px;
  border-left: 2px solid var(--border);
  margin-top: 6px;
}

.error {
  margin: 0 18px 12px;
  padding: 10px 14px;
  background: #fbeceb;
  border: 1px solid #e3b3af;
  color: #8a2b25;
  border-radius: 2px;
  font-size: 0.85rem;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.retry-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid #e3b3af;
  color: #8a2b25;
  padding: 6px 12px;
  border-radius: 2px;
  cursor: pointer;
  font-weight: 700;
  font-family: inherit;
}

.retry-btn:hover {
  background: #e3b3af;
}

.feedback-prompt {
  max-width: 90%;
  margin: 8px auto 0;
  text-align: center;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 2px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.feedback-buttons {
  display: flex;
  gap: 10px;
}

.feedback-buttons button {
  padding: 8px 20px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  font-family: inherit;
}

.feedback-buttons button:hover {
  border-color: var(--accent);
}

.feedback-thanks {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Mobile */
@media (max-width: 600px) {
  .intro-box h1 {
    font-size: 1.2rem;
  }

  .book {
    padding: 24px 16px 40px;
  }

  .chapter-line, .you-line {
    font-size: 0.98rem;
  }

  .chat-header {
    padding: 10px 12px;
  }
}
