:root {
  --bg: #0b0b12;
  --panel: #15151f;
  --panel-2: #1c1c29;
  --ink: #f4f1ea;
  --muted: #9a97a8;
  --border: #2b2b3a;

  --Seagrim: #4fb0a5;
  --Brannigan: #e0a640;
  --Moreau: #9b6bd1;
  --Whitewood: #cfd8e3;
  --Falk: #d1495b;
  --Vane: #4c9a4c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, sans-serif;
}

#app { max-width: 1200px; margin: 0 auto; padding: 0.6rem; }

h1.title {
  font-size: clamp(1.2rem, 5vw, 2rem);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  margin: 0.3rem 0 0.6rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem;
  margin-bottom: 0.6rem;
}

.panel.center { text-align: center; }

.panel h2 {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

button {
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  padding: 0.5rem 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.85rem;
}

button:disabled { opacity: 0.35; cursor: not-allowed; }
button.secondary { background: var(--panel-2); color: var(--ink); border: 1px solid var(--border); }
button.big { font-size: 1.05rem; padding: 0.65rem 1.1rem; }

.room-code { font-size: 2.4rem; font-weight: 800; letter-spacing: 0.15em; margin: 0.4rem 0; }
.qr-wrap img { width: 220px; height: 220px; border-radius: 8px; }

.status-line { color: var(--muted); font-size: 0.8rem; text-align: center; }
.error-banner {
  background: #3a1420;
  border: 1px solid var(--Falk);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--panel-2);
}
.chip.disconnected { opacity: 0.5; }
.chip .dot { width: 0.6em; height: 0.6em; border-radius: 50%; flex: none; }

.standings { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.6rem; }
.standings .chip { font-size: 0.8rem; padding: 0.3rem 0.6rem; }
.standings .chip b { margin-left: 0.3rem; }

.districts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0.5rem;
}

.district-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 0.5rem; }
.district-card.me { border-color: var(--ember, var(--ink)); }
.district-card .player-name { font-weight: 700; font-size: 0.85rem; margin-bottom: 0.3rem; display: flex; justify-content: space-between; align-items: center; }
.district-card .player-name .chip.disconnected { color: var(--muted); }

.establishment {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem;
  margin-bottom: 0.35rem;
}
.establishment.controlled { border-color: var(--Falk); }
.establishment-header { display: flex; justify-content: space-between; align-items: center; font-size: 0.72rem; font-weight: 700; margin-bottom: 0.3rem; }

.staff-slots { display: flex; gap: 0.2rem; margin-bottom: 0.3rem; }
.staff-slot {
  width: 1.3rem; height: 1.3rem; border-radius: 4px;
  border: 1.5px solid rgba(244, 241, 234, 0.35);
  background: rgba(244, 241, 234, 0.06);
}
.staff-slot.filled { border-style: solid; border-color: transparent; }

.action-slot { display: flex; align-items: center; gap: 0.4rem; font-size: 0.68rem; padding: 0.2rem 0; border-top: 1px dotted var(--border); flex-wrap: wrap; }
.action-slot:first-of-type { border-top: none; }
.action-slot.locked { opacity: 0.55; }
.action-slot .label { color: var(--muted); white-space: nowrap; }
.action-slot .dice { display: flex; gap: 0.15rem; }
.action-slot .slot-placeholder {
  width: 1.1rem; height: 1.1rem; border-radius: 3px;
  border: 1px dashed var(--border);
  flex: none;
}

.die {
  width: 1.5rem; height: 1.5rem;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 800;
  flex: none;
  cursor: pointer;
  border: 2px solid transparent;
}
.die.selected { border-color: var(--ink); box-shadow: 0 0 0 2px rgba(244,241,234,0.3); }
.die.wild { background: repeating-linear-gradient(45deg, #333 0 6px, #444 6px 12px); color: #fff; }
.die.affliction { background: #222; color: #e8a54f; }
.die.readonly { cursor: default; }

/* Basic dice are circular; Family dice (normal/greater) are square with a
   solid border — a shape difference, not just a color/number one, so it
   still reads from across the table. Family (greater) gets an extra ring. */
.die.basic { border-radius: 50%; }
.die.family { border-radius: 4px; border-color: rgba(244, 241, 234, 0.55); }
.die.family-greater { border-radius: 4px; border-color: rgba(244, 241, 234, 0.55); box-shadow: 0 0 0 2px rgba(244, 241, 234, 0.3); }

/* A small corner mark for a rolled Staff Symbol face — stacks with
   whichever shape/ring the die already has above. */
.die-staff { position: relative; }
.die-staff::after {
  content: "🛠";
  position: absolute;
  bottom: -0.3rem; right: -0.3rem;
  font-size: 0.65rem;
  line-height: 1;
}

.hand { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0; }

.color-picker { display: flex; gap: 0.25rem; margin: 0.3rem 0; flex-wrap: wrap; }
.color-swatch {
  width: 1.4rem; height: 1.4rem; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
}
.color-swatch.active { border-color: var(--ink); }

.choice-row { display: flex; gap: 0.3rem; flex-wrap: wrap; margin: 0.3rem 0; align-items: center; }
.choice-row select, .choice-row input[type="text"] {
  background: var(--panel); color: var(--ink); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.3rem 0.4rem; font-size: 0.78rem;
}

.log { max-height: 160px; overflow-y: auto; font-size: 0.78rem; color: var(--muted); display: flex; flex-direction: column-reverse; }
.log div { padding: 0.1rem 0; border-bottom: 1px dotted var(--border); }

.bank-row { display: flex; align-items: center; gap: 0.3rem; font-size: 0.72rem; color: var(--muted); }

.end-screen h2 { color: var(--ink); font-size: 1.3rem; }

.editor-establishment label {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.75rem; color: var(--muted); margin: 0.2rem 0.6rem 0.2rem 0;
}
.editor-input {
  width: 4rem; background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px; padding: 0.25rem 0.4rem; font-size: 0.8rem;
}
.editor-action-slot {
  border-top: 1px dotted var(--border);
  padding: 0.4rem 0;
  margin-top: 0.3rem;
}
.editor-action-slot:first-of-type { border-top: none; }
.editor-action-slot-functionality { font-size: 0.68rem; color: var(--muted); margin-bottom: 0.2rem; }
.editor-action-slot select {
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.25rem 0.4rem; font-size: 0.78rem;
}
.editor-remove-btn { background: var(--Falk); color: var(--ink); font-size: 0.68rem; padding: 0.15rem 0.4rem; }
.editor-add-action-slot {
  border-top: 1px dotted var(--border);
  padding: 0.5rem 0 0.2rem;
  margin-top: 0.3rem;
  display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center;
}

.die-faces {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.3rem;
  border-top: 1px dotted var(--border);
  margin-top: 0.4rem;
  padding-top: 0.4rem;
}
.die-face-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 0.3rem 0.4rem; font-size: 0.72rem;
}
.die-face-row label { display: inline-flex; align-items: center; gap: 0.25rem; color: var(--muted); }
.die-face-label { font-weight: 700; color: var(--ink); white-space: nowrap; flex-basis: 100%; }
