/* Solarized dark, teal accent, DM Sans for the chrome; the thread itself uses a
   plain system sans so it reads like a real forum. Mobile first. */
:root {
  --base03: #002b36;
  --base02: #073642;
  --base01: #586e75;
  --base00: #657b83;
  --base0: #839496;
  --base1: #93a1a1;
  --base2: #eee8d5;
  --yellow: #b58900;
  --orange: #cb4b16;
  --red: #dc322f;
  --magenta: #d33682;
  --violet: #6c71c4;
  --blue: #268bd2;
  --teal: #2aa198;
  --green: #859900;

  --ground: var(--base03);
  --panel: var(--base02);
  --line: rgba(147, 161, 161, 0.14);
  --text: var(--base1);
  --muted: var(--base01);
  --chrome-font: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --forum-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 10px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--text);
  font: 15px/1.5 var(--chrome-font);
  padding-top: env(safe-area-inset-top, 0px);
}
button, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Lobby ─────────────────────────────────────────────────────────── */
.lobby {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 16px calc(32px + env(safe-area-inset-bottom, 0px));
}
.hero { margin-bottom: 36px; }
.eyebrow {
  margin: 0 0 8px;
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
}
.hero h1 {
  margin: 0;
  font-size: clamp(32px, 7vw, 54px);
  line-height: 1.02;
  letter-spacing: -0.02em;
  color: var(--base2);
}
.hero h1 em {
  font-style: normal;
  color: var(--red);
  text-decoration: underline wavy var(--red);
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}
.lede { margin: 16px 0 0; font-size: 17px; color: var(--base0); max-width: 34em; }

.step { margin-bottom: 28px; }
.step h2, .cabinet h2 {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 12px;
  font-size: 14px; font-weight: 700; letter-spacing: 0.02em;
  color: var(--base1);
}
.num {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--teal); color: var(--base03);
  font-size: 12px;
}

.archetypes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.archetype {
  display: grid; gap: 4px; align-content: start;
  text-align: left;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  transition: border-color 0.15s, transform 0.15s;
}
.archetype:hover { border-color: rgba(42, 161, 152, 0.5); }
.archetype[aria-checked="true"] {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 1px var(--teal);
}
.archetype .avatar { font-size: 26px; line-height: 1; }
.archetype .name { font-weight: 700; color: var(--base2); }
.archetype .flavor { font-size: 13px; color: var(--base0); }
.archetype .level { font: 500 11px/1 var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.select-wrap select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.enter {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 13px 26px;
  border: 0;
  border-radius: 999px;
  background: var(--teal);
  color: var(--base03);
  font-weight: 700;
  font-size: 16px;
}
.enter:hover { filter: brightness(1.08); }
.enter:disabled { opacity: 0.4; cursor: not-allowed; }
.closed-note { margin: 12px 0 0; color: var(--yellow); font-size: 13px; }

.cabinet {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.badge-grid {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.badge {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 13px;
}
.badge.earned { border: 1px solid var(--teal); color: var(--base2); background: rgba(42, 161, 152, 0.12); }
.badge .times { margin-left: 6px; font: 500 11px var(--mono); color: var(--teal); }
.bests {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 18px 0 0;
}
.bests div { padding: 10px 12px; border-radius: var(--radius); background: var(--panel); }
.bests dt { font-size: 12px; color: var(--muted); }
.bests dd { margin: 2px 0 0; font: 500 16px var(--mono); color: var(--base2); }

.foot {
  display: grid; gap: 4px;
  margin-top: 40px;
  font-size: 12px; color: var(--muted);
}
.foot strong { color: var(--teal); }

/* ── Thread ────────────────────────────────────────────────────────── */
.thread { min-height: 100dvh; display: flex; flex-direction: column; }

.meters {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  padding: 10px 16px;
  background: rgba(0, 43, 54, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.meter { display: inline-flex; align-items: center; gap: 6px; }
.meter .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.meter .value { font-family: var(--mono); color: var(--base2); font-variant-numeric: tabular-nums; }
.meter.chip { padding: 3px 9px; border-radius: 999px; background: var(--panel); }
.meter.sanity { flex: 1 1 100%; }
.meter.sanity .bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--panel);
  overflow: hidden;
}
.meter.sanity .fill {
  display: block; height: 100%; width: 100%;
  background: var(--teal);
  border-radius: inherit;
  transition: width 0.5s ease, background-color 0.5s;
}
.meter.sanity .fill.warn { background: var(--yellow); }
.meter.sanity .fill.bad { background: var(--orange); }
.meter.sanity .fill.dire { background: var(--red); }
.meter.sanity .value { width: 3ch; text-align: right; }
.meter.clock { gap: 8px; }
.meter.clock .label { text-transform: none; letter-spacing: 0; font-size: 12px; }
.ack, .meter .value { display: inline-block; }
.ack { transition: color 0.2s; }
.ack.hope { color: var(--green); animation: hope 0.3s ease-out; }
.ack.snap { color: var(--red); animation: snap 0.35s ease-in; }
.bump { animation: bump 0.35s ease-out; }
@keyframes bump { 40% { transform: scale(1.35); color: var(--teal); } }
@keyframes hope { from { transform: scale(0.6); } 60% { transform: scale(1.5); } }
@keyframes snap { 30% { transform: translateX(-3px); } 60% { transform: translateX(3px); } }

.closed-banner {
  margin: 0;
  padding: 8px 16px;
  background: rgba(181, 137, 0, 0.14);
  color: var(--yellow);
  font-size: 13px;
  text-align: center;
}

.board {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px 24px;
  font-family: var(--forum-font);
}

.post {
  display: flex; gap: 12px;
  padding: 14px 14px 12px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.votes {
  display: flex; flex-direction: column; align-items: center;
  min-width: 34px;
  color: var(--muted);
  font-size: 12px;
}
.votes .score { font-weight: 700; color: var(--base1); }
.post-body { min-width: 0; }
.post-meta, .post-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
  margin: 0;
  font-size: 12px; color: var(--muted);
}
.board-name { font-weight: 700; color: var(--base1); }
.username { color: var(--blue); font-weight: 600; }
.flair {
  padding: 1px 7px;
  border-radius: 4px;
  background: rgba(108, 113, 196, 0.2);
  color: #a9adf0;
  font-size: 11px;
}
.post-title {
  margin: 6px 0 8px;
  font-size: clamp(19px, 4.6vw, 24px);
  line-height: 1.25;
  color: var(--base2);
  overflow-wrap: anywhere;
}

.comments { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 12px; }
.comment {
  position: relative;
  padding: 0 0 0 14px;
  border-left: 2px solid var(--line);
  animation: arrive 0.25s ease-out;
}
.comment.op { margin-left: 18px; border-left-color: rgba(38, 139, 210, 0.35); }
.comment.mod { border-left-color: var(--green); }
@keyframes arrive { from { opacity: 0; transform: translateY(6px); } }
.comment-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
  font-size: 12px; color: var(--muted);
}
.comment-head .avatar { font-size: 15px; line-height: 1; }
.comment-head .you { color: var(--teal); font-weight: 600; }
.comment-head .modname { color: var(--green); font-weight: 700; }
.op-tag {
  padding: 0 5px; border-radius: 3px;
  background: var(--blue); color: var(--base03);
  font-size: 10px; font-weight: 700;
}
.tactic {
  margin-left: auto;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(203, 75, 22, 0.16);
  color: #e98a5f;
  font: 500 11px var(--chrome-font);
  white-space: nowrap;
}
.tactic.block { background: rgba(220, 50, 47, 0.2); color: #f07b78; }
.comment-text {
  margin: 4px 0 0;
  color: var(--base2);
  font-size: 15px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.comment.op .comment-text { color: var(--base1); }
.comment-text .quote {
  display: block;
  margin: 2px 0 6px;
  padding: 2px 0 2px 10px;
  border-left: 3px solid var(--base01);
  color: var(--base0);
}
.comment.failed { opacity: 0.5; }
.comment.failed .comment-text { text-decoration: line-through; }

.typing {
  margin: 14px 0 0 32px;
  font-size: 13px;
  color: var(--muted);
}
.dots { display: inline-flex; gap: 3px; margin-left: 4px; vertical-align: middle; }
.dots i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--base0);
  animation: dot 1.2s infinite ease-in-out;
}
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.composer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  width: 100%;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(0, 43, 54, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.composer textarea {
  display: block;
  width: 100%;
  max-width: 728px;
  margin: 0 auto;
  min-height: 48px;
  max-height: 40dvh;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  font-family: var(--forum-font);
  resize: vertical;
}
.composer textarea:disabled { opacity: 0.55; }
.composer-row {
  display: flex; align-items: center; gap: 10px;
  max-width: 728px;
  margin: 8px auto 0;
}
.laptop {
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}
.laptop:hover { color: var(--base1); border-color: var(--line); }
.count { margin-left: auto; font: 12px var(--mono); color: var(--muted); }
.count.long { color: var(--orange); }
.send {
  padding: 8px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--teal);
  color: var(--base03);
  font-weight: 700;
}
.send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Ending ────────────────────────────────────────────────────────── */
.ending {
  position: fixed; inset: 0;
  z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px));
  background: rgba(0, 20, 26, 0.78);
  backdrop-filter: blur(4px);
  overflow-y: auto;
}
.ending-card {
  width: 100%;
  min-width: 0;
  max-width: 520px;
  margin: auto 0;
  padding: 22px 18px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  animation: arrive 0.3s ease-out;
}
.kicker {
  margin: 0;
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--red);
}
.kicker.win { color: var(--green); }
.ending-card h2 { margin: 8px 0 16px; font-size: 20px; line-height: 1.3; color: var(--base2); }
.receipt {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
  border-radius: 8px;
  background: var(--base2);
  color: #333;
  /* 45 columns must fit a 400px phone without scrolling sideways. */
  font: clamp(10px, 2.7vw, 12.5px)/1.45 var(--mono);
}
.ending-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.secondary {
  padding: 12px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-weight: 600;
}
.secondary:hover { border-color: var(--teal); }
.copied { margin: 10px 0 0; font-size: 13px; color: var(--teal); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(120px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--base2);
  color: var(--base03);
  font-weight: 500;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

@media (min-width: 640px) {
  .meters { padding: 10px 24px; }
  .meter.sanity { flex: 1 1 200px; }
  .ending-card { padding: 26px 26px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
