:root {
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    sans-serif;
  color: #e5eceb;
  background: #10191e;
  font-size: 16px;
  color-scheme: dark;
  --muted: #a2b5bb;
  --line: #304249;
  --panel: #19282e;
  --accent: #9ddcc7;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select {
  font: inherit;
}
button,
a,
input,
select {
  outline-offset: 4px;
}
button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #22353c;
  color: #edf5f4;
  padding: 9px 13px;
  cursor: pointer;
}
button:hover {
  background: #304851;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
button.primary {
  background: var(--accent);
  color: #10271e;
  border-color: var(--accent);
  font-weight: 650;
}
button.subtle {
  background: transparent;
}
button.active {
  border-color: var(--accent);
  color: var(--accent);
}
input,
select {
  width: 100%;
  padding: 10px;
  border: 1px solid #506168;
  background: #111e24;
  border-radius: 5px;
  color: #edf5f4;
}
input[type="checkbox"] {
  width: auto;
}
label {
  display: block;
  font-size: 0.875rem;
  color: #c8d7db;
  margin-bottom: 14px;
}
label input,
label select {
  margin-top: 6px;
}
a {
  color: var(--accent);
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  font-size: 2rem;
  letter-spacing: -0.05em;
}
h2 {
  font-size: 1.3rem;
}
h3 {
  font-size: 1rem;
}
small,
.muted {
  color: var(--muted);
}
.top {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 0 26px;
  gap: 20px;
}
.brand {
  display: flex;
  gap: 12px;
  color: #eef6f5;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.brand small {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0;
  font-weight: 400;
  margin-top: 5px;
}
.sigil {
  font:
    600 30px Georgia,
    serif;
  border: 1px solid #61877d;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--accent);
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
}
#connection {
  color: var(--muted);
}
#notice {
  background: #375047;
  border-bottom: 1px solid #608271;
  padding: 12px 26px;
}
#notice.error {
  background: #573536;
}
#sessionTitle {
  font-weight: 600;
}
.loading {
  padding: 40px;
}
.auth {
  max-width: 460px;
  margin: 65px auto;
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  color: var(--accent);
  margin-bottom: 16px;
}
.auth p {
  line-height: 1.6;
  color: var(--muted);
}
.auth .primary {
  width: 100%;
  margin-top: 8px;
}
.auth .subtle {
  width: 100%;
  margin-top: 12px;
}
.lobby {
  max-width: 1120px;
  margin: 44px auto;
  padding: 0 24px;
}
.lobby-title {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 28px;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.campaign {
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  margin-bottom: 22px;
}
.campaign-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
.chapter-list { display:grid; gap:12px; }
.chapter-row { border:1px solid var(--line); border-radius:9px; background:#17282e; overflow:hidden; }
.chapter-row.current { border-color:#74b8a5; }
.chapter-summary,.session-row { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:14px 16px; }
.chapter-summary strong,.session-row strong { display:block; }
.chapter-summary small,.session-row small { display:block; margin-top:4px; color:var(--muted); }
.session-rows { list-style:none; border-top:1px solid var(--line); margin:0; padding:0; background:transparent; }
.session-row { padding-left:32px; background:transparent; }
.archived-sessions { margin:10px 20px 14px 32px; color:var(--muted); }
.archived-sessions summary { cursor:pointer; padding:6px; }
.session-row + .session-row { border-top:1px solid var(--line); }
.session-row > button { flex:1; text-align:left; padding:0; background:transparent; border:0; color:inherit; }
.session-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 22px;
}
.session-card {
  text-align: left;
  padding: 20px;
  background: #142329;
  min-height: 105px;
}
.session-card strong {
  display: block;
  margin-bottom: 12px;
}
.session-card small {
  display: block;
}
.workspace {
  height: calc(100dvh - 84px);
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto;
}
.workspace-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: #15242a;
  border-bottom: 1px solid var(--line);
}
.workspace-toolbar select {
  width: auto;
  max-width: 210px;
}
.spacer {
  flex: 1;
}
.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  min-height: 0;
}
.map-container {
  position: relative;
  overflow: hidden;
  background: #0a1116;
  touch-action: none;
  min-height: 300px;
}
.map-world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}
.map-image {
  width: 100%;
  height: 100%;
  position: absolute;
  pointer-events: none;
}
.map-overlays {
  position: absolute;
  inset: 0;
}
.map-hint {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  text-align: center;
  color: #c4d5d8;
  font-size: 0.8rem;
  pointer-events: none;
  text-shadow: 0 1px 4px #000;
}
.token {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid #deeee9;
  box-shadow: 0 5px 12px #0006;
  color: #0b1a1c;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 750;
  padding: 3px;
  overflow: hidden;
  line-height: 1.1;
}
.token small {
  color: #0b1a1c;
  font-size: 10px;
  margin-top: 4px;
}
.token:hover {
  filter: brightness(1.15);
}
.token.selected {
  outline: 4px solid #fff;
  outline-offset: 4px;
}
.hidden-token {
  opacity: 0.5;
  border-style: dashed;
}
.effect {
  position: absolute;
  transform: translate(-50%, -50%);
  border: 2px dashed #dfb971;
  background: #dfb97133;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 20px;
  pointer-events: none;
}
.effect.circle {
  border-radius: 50%;
}
.ghost {
  position: absolute;
  transform: translate(-50%, -50%);
  border: 3px dashed #eacb88;
  border-radius: 50%;
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  background: #eacb8822;
  font-size: 16px;
  pointer-events: none;
}
.ping {
  position: absolute;
  width: 80px;
  height: 80px;
  border: 6px solid #f2d48d;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: pulse 1s infinite;
  pointer-events: none;
}
@keyframes pulse {
  to {
    width: 130px;
    height: 130px;
    opacity: 0.1;
  }
}
.inspector {
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow: auto;
  padding: 22px;
}
.inspector section {
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.inspector h2 {
  margin-bottom: 6px;
}
.inspector p {
  line-height: 1.5;
  font-size: 0.875rem;
  color: var(--muted);
}
.inspector .actions button {
  flex: 1;
}
.hp-display {
  font-size: 2rem;
  margin: 20px 0;
}
.hp-display small {
  font-size: 1rem;
}
.roster {
  display: grid;
  gap: 6px;
}
.roster button {
  text-align: left;
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
}
.roster button small {
  align-self: center;
}
.request {
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 6px;
  margin: 10px 0;
}
.request p {
  margin: 6px 0;
}
.log-entry {
  font-size: 0.875rem;
  line-height: 1.5;
  margin: 12px 0;
}
.log-entry small {
  display: block;
}
.combat {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  background: #20332f;
  flex-wrap: wrap;
}
.combat strong {
  color: var(--accent);
}
.prepare-panel {
  padding: 14px 18px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  background: #23343a;
}
.presentation .play-layout {
  grid-template-columns: 1fr;
}
.presentation .inspector {
  display: none;
}
dialog {
  background: #19282e;
  color: #e5eceb;
  border: 1px solid #4a6069;
  border-radius: 12px;
  width: min(520px, calc(100vw - 30px));
  max-height: 90dvh;
  padding: 26px;
}
dialog::backdrop {
  background: #050a10bb;
}
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.dialog-head h2 {
  margin: 0;
}
.dialog-head button {
  font-size: 1.2rem;
}
.dialog-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
#dialogError {
  color: #ffb9b5;
  font-size: 0.875rem;
}
.target-row {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.target-row input[type="number"] {
  max-width: 110px;
}
.target-row label {
  margin-bottom: 6px;
}
.empty {
  padding: 35px 0;
  color: var(--muted);
  line-height: 1.7;
}
details {
  margin-top: 20px;
}
summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.875rem;
}
.live-dot {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}
[hidden] {
  display: none !important;
}
@media (max-width: 850px) {
  .top {
    height: auto;
    min-height: 84px;
    padding: 16px;
    flex-wrap: wrap;
  }
  .brand small {
    display: none;
  }
  #sessionTitle {
    display: none;
  }
  .top-actions {
    gap: 6px;
  }
  .play-layout {
    grid-template-columns: minmax(0, 1fr) 240px;
  }
  .inspector {
    padding: 15px;
  }
  .workspace {
    height: calc(100dvh - 84px);
  }
  .workspace-toolbar {
    padding: 8px;
  }
  .workspace-toolbar button {
    padding: 8px;
    font-size: 0.875rem;
  }
}
@media (max-width: 620px) {
  .play-layout {
    display: flex;
    flex-direction: column;
    overflow: auto;
  }
  .map-container {
    min-height: 55dvh;
    flex-shrink: 0;
  }
  .inspector {
    overflow: visible;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .lobby-title,
  .campaign-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .auth {
    margin: 24px 14px;
  }
  .top-actions #connection {
    max-width: 95px;
    font-size: 0.75rem;
  }
  .map-hint {
    font-size: 0.75rem;
  }
  .dialog-grid {
    grid-template-columns: 1fr;
  }
  .presentation .map-container {
    height: 100%;
    flex: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ping {
    animation: none;
  }
}

#verification {
  font-size: 0.75rem;
  color: #f3d29a;
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.8rem;
}

/* Map-space grid: pans and zooms with the image, below tokens and effects. */
.map-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255,255,255,.32) 1px, rgba(0,0,0,.24) 1px, rgba(0,0,0,.24) 2px, transparent 2px),
    linear-gradient(to bottom, rgba(255,255,255,.32) 1px, rgba(0,0,0,.24) 1px, rgba(0,0,0,.24) 2px, transparent 2px);
  background-size: 64px 64px;
}

.initiative-order { display:flex; flex-wrap:wrap; gap:8px; margin:0; padding:0; list-style:none; }
.initiative-order li { padding:8px 12px; border:1px solid #385058; border-radius:8px; }
.initiative-order .current { border-color:#9ddcc7; background:#28483f; }

/* Roster and player actions flank the map. */
.play-layout { grid-template-columns: 220px minmax(0,1fr) 310px; }
.roster-panel { overflow:auto; padding:16px 12px; background:#15242a; border-right:1px solid var(--line); }
.roster-panel h4 { margin:16px 0 7px; color:var(--muted); font-size:.75rem; text-transform:uppercase; letter-spacing:.08em; }
.roster-row { display:flex; gap:4px; margin-bottom:5px; border-radius:6px; }
.roster-row > button:first-child { flex:1; min-width:0; display:block; text-align:left; padding:8px; }
.roster-row strong,.roster-row small { display:block; overflow-wrap:anywhere; }
.roster-row small { font-size:.7rem; margin-top:3px; }
.roster-row.current { outline:2px solid var(--accent); background:#28483f; }
.roster-row.current > button { background:#28483f; }
.combat-status { color:var(--accent); font-size:.8rem; }
.roster-controls { display:grid; gap:6px; margin-top:18px; }
.inspector-shell { min-height:0; position:relative; display:flex; flex-direction:column; border-left:1px solid var(--line); background:var(--panel); }
#toggleInspector { align-self:flex-start; margin:6px; padding:2px 11px; font-size:24px; }
.inspector { border:0; padding:14px 18px; flex:1; }
.inspector-collapsed { grid-template-columns:220px minmax(0,1fr) 46px; }
.inspector-collapsed .inspector { display:none; }
.personal-token { display:grid; gap:8px; padding-bottom:16px; margin-bottom:16px; border-bottom:1px solid var(--line); }
.turn-prompt { padding:12px; border:1px solid var(--accent); background:#28483f; }
.presentation .roster-panel,.presentation .inspector-shell { display:none; }
.presentation .play-layout { grid-template-columns:1fr; }
.token.current-turn { box-shadow:0 0 0 6px #f2d48d,0 5px 12px #0006; }
@media(max-width:1000px) { .play-layout { grid-template-columns:180px minmax(0,1fr) 250px; } .inspector-collapsed { grid-template-columns:180px minmax(0,1fr) 46px; } }
@media(max-width:620px) { .roster-panel { max-height:240px; flex-shrink:0; } .inspector-shell { min-height:46px; flex-shrink:0; } .inspector { overflow:visible; } }

.presentation .roster-panel { display:block; }
.presentation .play-layout { grid-template-columns:220px minmax(0,1fr); }
.roster-row.category-party { border-left:4px solid #60a5fa; }
.roster-row.category-party strong { color:#93c5fd; }
.roster-row.category-enemy { border-left:4px solid #f87171; }
.roster-row.category-enemy strong { color:#fca5a5; }
.roster-row.category-other { border-left:4px solid #fde047; }
.roster-row.current { outline:2px solid #f2d48d; }
.roster-row[draggable="true"] { cursor:grab; }
.movement-preview { position:absolute; inset:0; pointer-events:none; overflow:visible; }
@media(max-width:1000px) { .presentation .play-layout { grid-template-columns:180px minmax(0,1fr); } }
@media(max-width:620px) { .presentation .roster-panel { max-height:200px; } }

.directory { max-width:1440px; }
.table-scroll { overflow-x:auto; border:1px solid var(--line); border-radius:8px; margin-top:18px; }
.data-grid { width:100%; border-collapse:collapse; text-align:left; background:var(--panel); font-size:.875rem; }
.data-grid th { color:var(--muted); background:#142329; font-size:.75rem; text-transform:uppercase; letter-spacing:.05em; }
.data-grid th,.data-grid td { padding:15px 16px; border-bottom:1px solid var(--line); vertical-align:top; }
.data-grid tbody tr:last-child td { border-bottom:0; }
.data-grid small { display:block; margin-top:4px; }
.data-grid .actions { min-width:180px; }
.data-grid button { font-size:.8rem; padding:7px 10px; }
.top-actions { flex-wrap:wrap; }
@media(max-width:1100px) { .top { height:auto; min-height:84px; flex-wrap:wrap; padding:14px 20px; } }

.token[data-shape="square"] { border-radius:8%; }
.token[data-shape="hexagon"] { border-radius:0; clip-path:polygon(25% 0,75% 0,100% 50%,75% 100%,25% 100%,0 50%); }
.token[data-shape="diamond"] { border-radius:0; clip-path:polygon(50% 0,100% 50%,50% 100%,0 50%); }
