:root {
  --bg: #0d0d0d;
  --fg: #d8d8d8;
  --muted: #666;
  --accent: #d01121;
  --line: #2a2a2a;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  line-height: 1.65;
  min-height: 100vh;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

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

.screen {
  display: none;
}

.screen.active {
  display: block;
}

h1, h2 {
  font-weight: 400;
  letter-spacing: 0.02em;
  margin: 0 0 0.6rem 0;
}

h1 {
  font-size: 1.8rem;
  color: var(--accent);
}

h2 {
  font-size: 1.4rem;
}

p {
  margin: 0 0 0.9rem 0;
}

button {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--line);
  padding: 0.7rem 1.4rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-top: 0.8rem;
}

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

#progress {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
  letter-spacing: 0.05em;
}

#question-text {
  font-size: 1.25rem;
  line-height: 1.45;
  margin-bottom: 1.5rem;
}

.answer {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.85rem 1rem;
  margin: 0 0 0.6rem 0;
  color: var(--fg);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.12s ease;
}

.answer:hover {
  border-color: var(--muted);
  background: rgba(255,255,255,0.02);
}

.answer.selected {
  border-color: var(--accent);
  color: var(--accent);
}

.viz {
  margin: 0;
  text-align: center;
}

canvas {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

#result-card {
  padding: 1rem;
}

.archetype-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0 0 0.3rem 0;
}

#archetype-title {
  color: var(--accent);
  font-size: 1.8rem;
  margin: 0 0 0.4rem 0;
  line-height: 1.2;
}

#archetype-desc {
  color: var(--fg);
  margin: 0 0 1rem 0;
  line-height: 1.45;
}

#axis-scores {
  margin: 0.8rem 0 0 0;
}

#axis-scores h3 {
  font-weight: 400;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.axis-row {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
}

.axis-tier {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 0.1rem;
}

.axis-desc {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
  margin-bottom: 0.35rem;
}

.axis-bar-line {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.axis-pole {
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 2.5rem;
}

.axis-pole:last-child {
  text-align: right;
}

.axis-track {
  flex: 1;
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.axis-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--accent);
  border-radius: 4px;
}

.axis-extreme {
  border-left: 2px solid var(--accent);
  padding-left: 1rem;
  margin-left: -1rem;
}

.axis-extreme .axis-tier {
  color: var(--fg);
}

.score-row {
  display: none;
}

#quiz-controls {
  margin-top: 2rem;
}

#quiz-controls button {
  margin-top: 0;
}

#back {
  color: var(--muted);
  border-color: var(--line);
}

#back:hover {
  color: var(--fg);
  border-color: var(--muted);
}

#back:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

#result-controls {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.8rem 0;
  justify-content: center;
}

#result-controls button {
  margin-top: 0;
  flex: 1 1 150px;
  max-width: 220px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

#share {
  border-color: var(--accent);
  color: var(--accent);
}

#share:hover {
  background: rgba(208, 17, 33, 0.08);
}

#share.copied {
  color: var(--fg);
  border-color: var(--fg);
}

.warning {
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 1rem;
}

#letter {
  border: 1px solid var(--line);
  padding: 0.9rem 1rem;
  margin: 0.8rem 0;
  background: rgba(255,255,255,0.015);
}

#letter p {
  margin-bottom: 0.8rem;
}

#letter .signoff {
  color: var(--accent);
  margin-top: 0.8rem;
  font-style: italic;
}

#letter .keep {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.8rem;
  border-top: 1px solid var(--line);
  padding-top: 0.6rem;
}

#letter .keep code {
  font-family: inherit;
  color: var(--fg);
  word-break: break-all;
}

#intro h1 {
  margin-bottom: 1.5rem;
}

#intro p:not(.warning) {
  color: #aaa;
}

#intro button {
  margin-top: 1.5rem;
}

@media (max-width: 480px) {
  body {
    padding: 1rem;
  }
  #result-card {
    padding: 0.8rem;
  }
  .axis-pole {
    min-width: 2.5rem;
    font-size: 0.6rem;
  }
  .axis-desc {
    font-size: 0.7rem;
  }
  #archetype-title {
    font-size: 1.5rem;
  }
}
