:root {
  --paper: #f4ebda;
  --paper-deep: #e7d7b8;
  --panel: rgba(255, 250, 239, 0.92);
  --panel-strong: rgba(252, 244, 227, 0.98);
  --ink: #231e16;
  --muted: #695f52;
  --line: rgba(89, 73, 47, 0.18);
  --shadow: 0 20px 44px rgba(88, 63, 27, 0.16);
  --accent: #b46b30;
  --accent-deep: #7d4318;
  --good: #20654a;
  --bad: #a53a2f;
  --attack: #bf4732;
  --retreat: #2c6e95;
  --traitor: #7a5330;
  --neutral: #b9ac95;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(235, 177, 83, 0.42), transparent 35%),
    radial-gradient(circle at bottom right, rgba(125, 67, 24, 0.14), transparent 38%),
    linear-gradient(145deg, #f6efdf 0%, #ebdcc0 52%, #e0ccb0 100%);
  font-family: "Avenir Next", "Trebuchet MS", "Gill Sans", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1400px, calc(100vw - 32px));
  margin: 24px auto 40px;
}

.hero-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 28px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  overflow: hidden;
  position: relative;
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: auto -40px -60px auto;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(180, 107, 48, 0.16), transparent 65%);
  pointer-events: none;
}

.hero-card-instructor {
  background:
    linear-gradient(135deg, rgba(255, 247, 232, 0.96), rgba(243, 230, 206, 0.95)),
    var(--panel);
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  color: var(--accent-deep);
}

h1,
h2,
h3,
.pill,
.button,
.math-badge {
  font-family: "Avenir Next Condensed", "Trebuchet MS", sans-serif;
  letter-spacing: 0.01em;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 0.95;
}

h2 {
  margin: 0;
  font-size: 1.4rem;
}

h3 {
  margin: 0;
  font-size: 1.05rem;
}

p {
  line-height: 1.55;
}

.hero-copy {
  margin: 14px 0 0;
  max-width: 760px;
  color: var(--muted);
}

.hero-meta,
.panel-header,
.summary-row,
.progress-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.button-row,
.vote-buttons,
.graph-controls {
  display: flex;
  gap: 14px;
  row-gap: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.hero-meta {
  justify-content: flex-end;
  align-items: flex-start;
  min-width: 240px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(180, 107, 48, 0.13);
  color: var(--accent-deep);
  border: 1px solid rgba(180, 107, 48, 0.18);
  font-size: 0.95rem;
}

.pill-muted {
  background: rgba(105, 95, 82, 0.1);
  color: var(--muted);
  border-color: rgba(105, 95, 82, 0.14);
}

.pill-good {
  background: rgba(32, 101, 74, 0.12);
  color: var(--good);
  border-color: rgba(32, 101, 74, 0.18);
}

.pill-bad {
  background: rgba(165, 58, 47, 0.12);
  color: var(--bad);
  border-color: rgba(165, 58, 47, 0.18);
}

.pill-traitor {
  background: rgba(122, 83, 48, 0.14);
  color: var(--traitor);
  border-color: rgba(122, 83, 48, 0.22);
}

.content-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.9fr);
  gap: 20px;
}

.dashboard-layout {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.panel {
  padding: 22px;
}

.panel-wide,
.panel-graph {
  min-height: 420px;
}

.panel-tall {
  min-height: 480px;
}

.panel-graph {
  grid-column: 1 / -1;
}

.student-debrief-panel {
  margin-top: 20px;
}

.panel-header {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.side-panel {
  min-height: 420px;
}

.stage-stack,
.side-stack,
.queue-list,
.room-list,
.preview-grid {
  display: grid;
  gap: 16px;
}

.stage-card,
.info-card,
.preview-row,
.queue-card,
.room-card,
.message-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
}

.debrief-overview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0 16px;
}

.debrief-summary-card {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(125, 67, 24, 0.12);
  background: linear-gradient(180deg, rgba(255, 252, 246, 0.96), rgba(247, 238, 220, 0.96));
}

.debrief-summary-label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.debrief-node-grid {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.debrief-node-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 252, 246, 0.98), rgba(247, 239, 223, 0.98));
  color: var(--ink);
}

.debrief-node-card.is-aligned {
  border-color: rgba(32, 101, 74, 0.24);
  background: linear-gradient(180deg, rgba(242, 250, 246, 0.98), rgba(230, 244, 238, 0.98));
}

.debrief-node-card.is-tricked {
  border-color: rgba(165, 58, 47, 0.24);
  background: linear-gradient(180deg, rgba(252, 243, 241, 0.98), rgba(248, 230, 227, 0.98));
}

.debrief-node-card.is-malicious {
  border-color: rgba(122, 83, 48, 0.22);
  background: linear-gradient(180deg, rgba(249, 243, 235, 0.98), rgba(241, 229, 214, 0.98));
}

.debrief-node-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.debrief-node-header strong {
  font-size: 1.08rem;
  color: var(--ink);
}

.debrief-node-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.debrief-node-values {
  display: grid;
  gap: 10px;
}

.debrief-value-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.54);
  border: 1px solid rgba(89, 73, 47, 0.08);
}

.debrief-value-row span:first-child {
  color: var(--muted);
  font-weight: 600;
}

.order-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: "Avenir Next Condensed", "Trebuchet MS", sans-serif;
  letter-spacing: 0.01em;
}

.order-attack {
  background: rgba(191, 71, 50, 0.14);
  color: var(--attack);
  border-color: rgba(191, 71, 50, 0.18);
}

.order-retreat {
  background: rgba(44, 110, 149, 0.14);
  color: var(--retreat);
  border-color: rgba(44, 110, 149, 0.18);
}

.order-neutral {
  background: rgba(105, 95, 82, 0.1);
  color: var(--muted);
  border-color: rgba(105, 95, 82, 0.14);
}

.setup-form {
  display: grid;
  gap: 16px;
}

.radio-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.radio-card {
  position: relative;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  cursor: pointer;
}

.radio-card input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.radio-card:has(input:checked) {
  border-color: rgba(180, 107, 48, 0.5);
  box-shadow: inset 0 0 0 1px rgba(180, 107, 48, 0.2);
}

.form-field {
  display: grid;
  gap: 8px;
}

.form-field span {
  font-size: 0.95rem;
  color: var(--muted);
}

input[type="number"],
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fffdfa;
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--ink);
}

.button {
  border: 1px solid rgba(125, 67, 24, 0.2);
  border-radius: 999px;
  padding: 11px 16px;
  background: rgba(255, 247, 232, 0.96);
  color: var(--accent-deep);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(108, 72, 26, 0.13);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
  transform: none;
}

.button-strong {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff7ef;
}

.button-danger {
  border-color: rgba(165, 58, 47, 0.2);
  color: var(--bad);
}

.button-stage.is-active,
.button-toggle.is-active {
  background: linear-gradient(135deg, rgba(180, 107, 48, 0.18), rgba(125, 67, 24, 0.18));
}

.alert {
  margin-bottom: 16px;
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid rgba(165, 58, 47, 0.18);
  background: rgba(165, 58, 47, 0.08);
  color: var(--bad);
}

.hidden {
  display: none;
}

.empty-state {
  border: 1px dashed rgba(105, 95, 82, 0.24);
  border-radius: 18px;
  padding: 20px;
  color: var(--muted);
  background: rgba(255, 251, 244, 0.58);
}

.summary-row {
  justify-content: space-between;
  align-items: center;
}

.progress-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(105, 95, 82, 0.12);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
}

.message-list,
.player-list,
.participant-list {
  display: grid;
  gap: 10px;
}

.message-card strong,
.room-card strong {
  display: inline-block;
  min-width: 72px;
}

.decision-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.decision-row {
  display: grid;
  grid-template-columns: minmax(90px, 120px) repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
}

.decision-node {
  color: var(--muted);
  font-weight: 600;
}

.choice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid var(--line);
  cursor: pointer;
}

.choice input {
  margin: 0;
}

.choice-attack {
  color: var(--attack);
}

.choice-retreat {
  color: var(--retreat);
}

.math-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.9rem;
}

.math-good {
  color: var(--good);
  background: rgba(32, 101, 74, 0.1);
}

.math-bad {
  color: var(--bad);
  background: rgba(165, 58, 47, 0.1);
}

.preview-meta,
.queue-meta,
.room-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.preview-row {
  gap: 14px;
}

.queue-card,
.room-card {
  display: grid;
  gap: 12px;
}

.room-card.is-selected {
  border-color: rgba(180, 107, 48, 0.4);
  box-shadow: inset 0 0 0 1px rgba(180, 107, 48, 0.18);
}

.graph-summary {
  min-height: 76px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--muted);
}

.graph-workspace {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(280px, 0.82fr);
  gap: 16px;
  align-items: stretch;
}

.graph-canvas {
  min-height: 720px;
  height: min(78vh, 920px);
  border-radius: 22px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 252, 246, 0.92), rgba(246, 238, 222, 0.92)),
    var(--panel-strong);
  overflow: hidden;
}

.graph-details {
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 252, 246, 0.94), rgba(248, 240, 224, 0.94)),
    var(--panel-strong);
  color: var(--muted);
}

.graph-details h3 {
  margin: 0 0 12px;
  color: var(--ink);
}

.graph-detail-card {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.graph-detail-row {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.9);
  color: var(--ink);
}

.graph-detail-row strong {
  display: inline-block;
  min-width: 110px;
}

.graph-caption {
  margin-top: 10px;
  font-size: 0.95rem;
  color: var(--muted);
}

.code-note {
  font-family: "SFMono-Regular", "Menlo", "Monaco", monospace;
}

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

  .graph-workspace {
    grid-template-columns: 1fr;
  }

  .radio-group {
    grid-template-columns: 1fr;
  }

  .hero-card {
    flex-direction: column;
  }

  .debrief-overview {
    grid-template-columns: 1fr;
  }

  .hero-meta {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 20px, 100%);
    margin-top: 10px;
  }

  .hero-card,
  .panel {
    padding: 18px;
    border-radius: 20px;
  }

  .decision-row {
    grid-template-columns: 1fr;
  }

  .graph-canvas {
    min-height: 520px;
    height: 62vh;
  }
}
