:root {
  --bg: #0a0a0a;
  --panel: #141414;
  --line: #252525;
  --text: #e8e8e8;
  --muted: #888;
  --accent: #fff;
  --win: #5cb85c;
  --loss: #e55;
  --draw: #6af;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Ubuntu", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

/* Layout */

.app-shell {
  width: calc(100% - 3rem);
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.5rem 0 2rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
}

.panel::before {
  display: none;
}

/* Hero */

.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  overflow: hidden;
}

.hero::after {
  display: none;
}

.hero-copy {
  padding: 1.5rem;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow {
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 500;
}

h1,
h2 {
  margin: 0;
  font-family: "Ubuntu", sans-serif;
  font-weight: 700;
  line-height: 1.15;
}

h1 {
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
}

h2 {
  font-size: 1.15rem;
}

.lede {
  max-width: 50ch;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--muted);
  margin-top: 0.75rem;
}

/* Scoreboard */

.scoreboard-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  background: var(--panel);
}

.scoreboard-label,
.status-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.headline-score {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-family: "Ubuntu", sans-serif;
  font-weight: 700;
  font-size: clamp(2.4rem, 4vw, 3.4rem);
  font-variant-numeric: tabular-nums;
}

#human-score {
  color: var(--win);
}

#agent-score {
  color: var(--loss);
}

.score-separator {
  color: #444;
}

.scoreboard-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  font-size: 0.85rem;
}

#draw-score {
  color: var(--draw);
}

#total-games {
  color: var(--muted);
}

.setup-controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.donate-card {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
}

.donate-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.donate-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.donate-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.8rem;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--line);
  background: #1a1a1a;
  font-size: 0.8rem;
  font-weight: 500;
}

.donate-link:hover {
  background: #222;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.control span {
  color: var(--muted);
  font-size: 0.8rem;
}

/* Inputs */

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 0;
  padding: 0.6rem 0.75rem;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #555;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.primary-button,
.secondary-button,
.ghost-link {
  padding: 0.65rem 1.2rem;
  border-radius: 0;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 500;
}

.primary-button {
  background: var(--text);
  color: var(--bg);
}

.primary-button:hover {
  background: #fff;
}

.secondary-button {
  background: #222;
  color: var(--text);
  border: 1px solid var(--line);
}

.secondary-button:hover {
  background: #2a2a2a;
}

.ghost-link {
  color: var(--draw);
  background: none;
  border: 1px solid var(--line);
}

.ghost-link:hover {
  background: #1a1a1a;
}

/* Content grid */

.content-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1px;
  background: var(--line);
  margin-top: 1rem;
}

.game-panel,
.side-column {
  min-width: 0;
}

.game-panel {
  padding: 1.5rem;
  background: var(--panel);
}

.side-column {
  display: grid;
  gap: 1px;
  background: var(--line);
}

.side-column > .panel {
  border: none;
  padding: 1.5rem;
}

/* Game header */

.game-header,
.section-heading,
.chat-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.counter-pill {
  padding: 0.4rem 0.7rem;
  background: #1a1a1a;
  color: var(--text);
  font-size: 0.85rem;
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* Status strip */

.status-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  margin: 1rem 0;
}

.status-strip > div {
  padding: 0.75rem;
  background: #1a1a1a;
}

.status-strip strong {
  font-size: 1rem;
}

/* Chat */

.chat-log {
  height: 460px;
  overflow: auto;
  padding: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.empty-state {
  padding: 1rem;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}

.message {
  max-width: 78%;
  padding: 0.75rem 0.85rem;
  line-height: 1.6;
  font-size: 0.9rem;
}

.message-human {
  align-self: flex-end;
  background: #1e1e1e;
  border: 1px solid var(--line);
}

.message-agent {
  align-self: flex-start;
  background: #181818;
  border: 1px solid var(--line);
}

.message-meta {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.chat-form {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.game-status {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Leaderboard table */

.table-wrap {
  overflow-x: auto;
  margin-top: 0.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.65rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
}

td {
  font-size: 0.9rem;
}

tr:last-child td {
  border-bottom: none;
}

/* Side panel */

.panel-copy {
  color: var(--muted);
  line-height: 1.6;
  margin: 0.25rem 0 0.75rem;
  font-size: 0.85rem;
}

.stack-list {
  display: grid;
  gap: 0.5rem;
}

.recent-card,
.tier-chip {
  background: #1a1a1a;
  border: 1px solid var(--line);
}

.recent-card {
  padding: 0.75rem;
}

.recent-card strong {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
}

.recent-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.tier-breakdown {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.tier-chip {
  padding: 0.65rem 0.85rem;
  min-width: 140px;
  font-size: 0.85rem;
}

.tier-chip strong {
  display: block;
  margin-bottom: 0.2rem;
}

/* Color utilities */

.c-win {
  color: var(--win);
}

.c-loss {
  color: var(--loss);
}

.c-draw {
  color: var(--draw);
}

/* Dialog */

.reveal-dialog {
  width: min(700px, calc(100% - 2rem));
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.reveal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.8);
}

.dialog-shell {
  padding: 1.5rem;
  background: #1a1a1a;
  border: 1px solid #333;
}

.dialog-shell .eyebrow {
  color: #aaa;
}

.dialog-shell h2 {
  color: #fff;
  font-size: 1.3rem;
}

.dialog-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  margin: 1rem 0;
}

.dialog-stat {
  padding: 0.75rem;
  background: #222;
}

.dialog-stat span {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #aaa;
}

.dialog-stat strong {
  display: block;
  margin-top: 0.3rem;
  font-size: 1.05rem;
  color: #fff;
}

.slip-card {
  padding: 0.75rem;
  margin-bottom: 1rem;
  background: #222;
  border: 1px solid var(--line);
  color: #ddd;
}

blockquote {
  margin: 0.5rem 0 0;
  padding-left: 0.75rem;
  border-left: 2px solid #555;
  color: #bbb;
  font-size: 0.85rem;
}

.muted {
  color: var(--muted);
}

.floating {
  transform: none;
}

.reveal {
  opacity: 1;
  transform: none;
}

/* Responsive */

@media (max-width: 980px) {
  .hero,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .chat-log {
    height: 360px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: calc(100% - 1rem);
    padding-top: 0.75rem;
  }

  .hero-copy,
  .scoreboard-card,
  .game-panel,
  .side-column > .panel,
  .dialog-shell {
    padding: 1rem;
  }

  .setup-controls,
  .status-strip,
  .dialog-grid {
    grid-template-columns: 1fr;
  }

  .chat-actions,
  .dialog-actions,
  .game-header,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .message {
    max-width: 92%;
  }
}
