:root {
  color-scheme: dark;
  --bg: #111313;
  --panel: #191c1d;
  --panel-2: #202525;
  --line: #313838;
  --text: #eef1ef;
  --muted: #9ba6a4;
  --accent: #b1c301;
  --accent-2: #7fb6a6;
  --danger: #d66a5f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  min-height: 36px;
  padding: 0 12px;
}

button:hover {
  border-color: #52605e;
}

.start-screen {
  align-items: center;
  background: #06021c;
  display: flex;
  inset: 0;
  justify-content: center;
  opacity: 1;
  position: fixed;
  transition: opacity 0.45s ease;
  z-index: 100;
}

.start-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.start-inner {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 32px;
  text-align: center;
}

.start-logo {
  animation: start-rise 0.7s ease 0.1s both;
  height: auto;
  max-width: min(560px, 80vw);
  width: 100%;
}

.start-logo .lodestar-star {
  animation: start-glow 4s ease-in-out 0.8s infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.start-tagline {
  animation: start-rise 0.7s ease 0.35s both;
  color: var(--muted);
  font-size: 1rem;
  letter-spacing: 0.02em;
  margin: 0;
}

.start-enter {
  animation: start-rise 0.7s ease 0.55s both;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 10px;
  color: #1b1508;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  min-height: 52px;
  padding: 0 48px;
}

.start-enter:hover {
  border-color: transparent;
  filter: brightness(1.08);
}

.start-credit {
  animation: start-fade 0.9s ease 0.9s both;
  bottom: 24px;
  color: var(--muted);
  font-size: 0.82rem;
  left: 0;
  letter-spacing: 0.03em;
  margin: 0;
  opacity: 0.7;
  position: absolute;
  right: 0;
  text-align: center;
}

@keyframes start-rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes start-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 0.7;
  }
}

@keyframes start-glow {
  0%,
  100% {
    filter: drop-shadow(0 0 2px rgba(177, 195, 1, 0.35));
  }
  50% {
    filter: drop-shadow(0 0 14px rgba(210, 230, 60, 1))
      drop-shadow(0 0 30px rgba(197, 215, 40, 0.85))
      drop-shadow(0 0 48px rgba(177, 195, 1, 0.55));
  }
}

.app-shell {
  display: grid;
  /* Three columns always: left controls, stage, initiative. The initiative track is 0
     when inactive and the left track is 0 when collapsed, so both panels animate open/shut
     by transitioning the track widths. */
  grid-template-columns: 320px minmax(0, 1fr) 0px;
  height: 100vh;
  transition: grid-template-columns 0.28s ease;
  width: 100vw;
}

.app-shell.has-initiative {
  grid-template-columns: 320px minmax(0, 1fr) 300px;
}

.app-shell.panel-collapsed {
  grid-template-columns: 0px minmax(0, 1fr) 0px;
}

.app-shell.panel-collapsed.has-initiative {
  grid-template-columns: 0px minmax(0, 1fr) 300px;
}

.app-shell[data-role="player"] {
  display: block;
  cursor: none;
}

.app-shell[data-role="player"].cursor-active {
  cursor: default;
}

.app-shell[data-role="player"] .gm-panel {
  display: none;
}

.app-shell[data-role="player"] .stage-controls {
  display: none;
}

.app-shell[data-role="player"] .stage-wrap {
  height: 100vh;
}

.gm-panel {
  background: #06021c;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 22px;
}

.brand {
  align-items: center;
  display: flex;
  justify-content: center;
}

.brand-logo {
  display: block;
  height: auto;
  max-width: 220px;
  width: 100%;
}

.eyebrow,
.hint {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  margin: 0;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 1.65rem;
  font-weight: 700;
}

h2 {
  font-size: 0.95rem;
  font-weight: 650;
}

.status {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 9px;
}

.control-section {
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 18px;
}

/* Sections made collapsible carry their own spacing inside .section-body. */
.control-section:has(.section-body) {
  gap: 0;
}

.section-title {
  align-items: center;
  display: flex;
  gap: 10px;
}

.section-title h2 {
  flex: 1;
  margin: 0;
}

/* Collapsible body: animate grid rows from 1fr to 0fr for a smooth slide. */
.section-toggle {
  align-items: center;
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  justify-content: center;
  min-height: 0;
  padding: 0;
  transition: transform 0.25s ease;
  width: 20px;
}

.section-toggle:hover {
  background: none;
  border: 0;
  color: var(--text);
}

.section-toggle svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 18px;
}

.control-section.collapsed .section-toggle {
  transform: rotate(-90deg);
}

.section-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.3s ease;
}

.control-section.collapsed .section-body {
  grid-template-rows: 0fr;
}

.section-body-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
  min-height: 0;
  overflow: hidden;
}

.control-section.collapsed .section-body-inner {
  margin-top: 0;
}

label {
  color: var(--muted);
  display: grid;
  gap: 7px;
  font-size: 0.83rem;
}

input[type="range"] {
  accent-color: var(--accent);
  width: 100%;
}

input[type="color"] {
  background: transparent;
  border: 0;
  height: 34px;
  padding: 0;
  width: 100%;
}

.file-loader input {
  display: none;
}

.file-loader span,
.primary-button,
.library-button {
  align-items: center;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 6px;
  color: #1b1508;
  cursor: pointer;
  display: flex;
  font-weight: 750;
  justify-content: center;
  min-height: 42px;
  padding: 0 12px;
}

.library-button.empty {
  background: #3a3f3f;
  border-color: #4a5151;
  color: #9aa3a1;
  cursor: default;
}

/* Top GM actions: four icon buttons in a 2x2 grid. */
.top-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.top-action {
  align-items: center;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 8px;
  color: #1b1508;
  cursor: pointer;
  display: flex;
  justify-content: center;
  min-height: 52px;
  padding: 0;
}

.top-action:hover:not(:disabled) {
  filter: brightness(1.08);
}

.top-action svg {
  fill: none;
  height: 24px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
  width: 24px;
}

.top-action.empty,
.top-action:disabled {
  background: #3a3f3f;
  border-color: #4a5151;
  color: #9aa3a1;
  cursor: default;
}

.secondary-loader span {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}

.primary-button,
.library-button {
  width: 100%;
}

.ghost-button {
  min-height: 30px;
  padding: 0 10px;
}

.inline-fields {
  display: grid;
  gap: 12px;
  grid-template-columns: 74px minmax(0, 1fr);
}

.inline-buttons {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.inline-buttons button,
.inline-loader span {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 36px;
  width: 100%;
}

.inline-loader {
  cursor: pointer;
}

.inline-loader input {
  display: none;
}

.inline-loader span {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
}

.checkbox-row {
  align-items: center;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.checkbox-row input {
  accent-color: var(--accent);
}

.switch input {
  display: none;
}

.switch.with-label {
  align-items: center;
  color: var(--text);
  display: inline-flex;
  font-size: 0.8rem;
  gap: 8px;
}

.switch span {
  background: #3a4241;
  border-radius: 999px;
  display: block;
  height: 24px;
  position: relative;
  width: 44px;
}

.switch span::after {
  background: white;
  border-radius: 50%;
  content: "";
  height: 18px;
  left: 3px;
  position: absolute;
  top: 3px;
  transition: transform 150ms ease;
  width: 18px;
}

.switch input:checked + span {
  background: var(--accent-2);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.segmented,
.fog-actions {
  display: grid;
  gap: 8px;
}

.segmented {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segmented:has(#brushMode),
.segmented:has(#roundShape) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented button {
  padding: 0 7px;
}

.segmented .active {
  background: #263635;
  border-color: var(--accent-2);
  color: #c6fff1;
}

/* Segmented rows whose buttons are icons rather than text (e.g. the AoE shapes). */
.icon-segmented button {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 36px;
}

.icon-segmented svg {
  fill: none;
  height: 20px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  width: 20px;
}

/* Controls disabled while players drive their own view. */
button:disabled,
input:disabled {
  cursor: default;
  opacity: 0.45;
}

.switch input:disabled + span {
  opacity: 0.45;
}

.fog-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hidden {
  display: none !important;
}

.stage-wrap {
  background: #080909;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* A tab on the left edge of the stage that collapses/expands the GM control panel. */
.panel-toggle {
  align-items: center;
  background: rgba(25, 28, 29, 0.92);
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  color: var(--muted);
  display: flex;
  height: 46px;
  justify-content: center;
  left: 0;
  min-height: 0;
  padding: 0;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  z-index: 7;
}

.panel-toggle:hover {
  background: var(--panel-2);
  color: var(--text);
}

.panel-toggle svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transition: transform 0.28s ease;
  width: 18px;
}

/* When the panel is collapsed, flip the chevrons to point "open". */
.app-shell.panel-collapsed .panel-toggle svg {
  transform: rotate(180deg);
}

.app-shell[data-role="player"] .panel-toggle {
  display: none;
}

.stage-controls {
  align-items: start;
  display: flex;
  flex-direction: column;
  gap: 10px;
  left: 14px;
  position: absolute;
  top: 14px;
  z-index: 6;
}

.mode-hint-bar {
  background: rgba(25, 28, 29, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  left: 50%;
  margin: 0;
  max-width: calc(100% - 240px);
  padding: 7px 14px;
  position: absolute;
  text-align: center;
  top: 14px;
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 6;
}

.app-shell[data-role="player"] .mode-hint-bar {
  display: none;
}

.tool-row {
  align-items: flex-start;
  display: flex;
  gap: 8px;
}

.map-tools {
  background: rgba(25, 28, 29, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr 1fr;
  padding: 7px;
  width: 96px;
}

/* Fog-of-war tools live in a ribbon that opens to the right of the toolbar. */
.fog-ribbon {
  background: rgba(25, 28, 29, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 6px;
  padding: 7px;
}

.fog-ribbon .tool-button {
  width: 38px;
}

.tool-button:disabled {
  cursor: default;
  opacity: 0.4;
}

.tool-button {
  align-items: center;
  aspect-ratio: 1;
  display: grid;
  justify-items: center;
  min-height: 0;
  padding: 0;
}

.tool-button svg {
  fill: none;
  height: 21px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  width: 21px;
}

.tool-button.active {
  background: #263635;
  border-color: var(--accent-2);
  color: #c6fff1;
}

.player-toggles {
  background: rgba(25, 28, 29, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px;
  width: 96px;
}

.toggle-chip {
  align-items: center;
  color: var(--text);
  cursor: pointer;
  display: flex;
  font-size: 0.82rem;
  gap: 8px;
  padding: 3px 4px;
}

.toggle-chip input {
  accent-color: var(--accent);
}

.tool-popover {
  background: rgba(25, 28, 29, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: grid;
  gap: 12px;
  min-width: 230px;
  max-width: 260px;
  padding: 12px;
}

/* Keep long hint text from stretching the grid-auto-sized popover. */
.tool-popover .hint {
  max-width: 236px;
}

.tool-popover h2 {
  font-size: 0.9rem;
}

.tool-popover input[type="text"],
.tool-popover select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-height: 34px;
  padding: 0 10px;
}

#measureCalibrateRow {
  display: grid;
  gap: 8px;
}

/* A field (label/slider) paired with a small action button to its right. */
.field-with-action {
  align-items: end;
  display: flex;
  gap: 8px;
}

.field-with-action label {
  flex: 1;
}

.field-with-action .calib-label {
  color: var(--muted);
  flex: 1;
  font-size: 0.83rem;
}

.mini-btn {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  flex: none;
  height: 34px;
  justify-content: center;
  min-height: 0;
  padding: 0;
  width: 34px;
}

.mini-btn:hover {
  border-color: #52605e;
}

.mini-btn svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 18px;
}

.mini-btn.active {
  background: #263635;
  border-color: var(--accent-2);
  color: #c6fff1;
}

.token-image-row {
  align-items: center;
  display: flex;
  gap: 8px;
}

.token-image-row .inline-loader {
  flex: 1;
}

.token-image-preview {
  border: 1px solid var(--line);
  border-radius: 50%;
  height: 36px;
  object-fit: cover;
  width: 36px;
}

.player-fullscreen {
  align-items: center;
  background: rgba(25, 28, 29, 0.6);
  border: 1px solid rgba(120, 130, 130, 0.4);
  border-radius: 8px;
  color: var(--text);
  display: none;
  height: 40px;
  justify-content: center;
  opacity: 0.35;
  position: absolute;
  right: 16px;
  top: 16px;
  transition: opacity 150ms ease;
  width: 40px;
  z-index: 7;
}

.player-fullscreen:hover {
  opacity: 1;
}

.player-fullscreen svg {
  fill: none;
  height: 20px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  width: 20px;
}

.app-shell[data-role="player"] .player-fullscreen {
  display: flex;
  opacity: 0;
  pointer-events: none;
}

/* Reveal the fullscreen button alongside the cursor (on mouse movement). */
.app-shell[data-role="player"].cursor-active .player-fullscreen {
  opacity: 0.55;
  pointer-events: auto;
}

.app-shell[data-role="player"].cursor-active .player-fullscreen:hover {
  opacity: 1;
}

/* ---- Top-right stage widgets (initiative toggle + floor nav) ---- */
.stage-top-right {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 6;
}

.app-shell[data-role="player"] .stage-top-right {
  display: none;
}

.floor-widget {
  align-items: center;
  background: rgba(25, 28, 29, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 4px;
}

.floor-widget-btn {
  align-items: center;
  aspect-ratio: 1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  display: flex;
  justify-content: center;
  min-height: 0;
  padding: 2px;
  width: 30px;
}

.floor-widget-btn:hover:not(:disabled) {
  border-color: var(--line);
  background: var(--panel-2);
}

.floor-widget-btn:disabled {
  cursor: default;
  opacity: 0.3;
}

.floor-widget-btn svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 18px;
}

.floor-widget-label {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0 2px;
  text-align: center;
  white-space: nowrap;
}

/* ---- Player floor badge ---- */
.player-floor-badge {
  background: rgba(6, 2, 28, 0.82);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 6;
}

/* ---- Floor panel controls in sidebar ---- */
.floor-add-row {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.floor-add-row .ghost-button {
  align-items: center;
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 0 8px;
}

.floor-add-row svg {
  fill: none;
  flex-shrink: 0;
  height: 16px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 16px;
}

.danger-button {
  background: transparent;
  border-color: rgba(214, 106, 95, 0.45);
  color: var(--danger);
}

.danger-button:hover:not(:disabled) {
  background: rgba(214, 106, 95, 0.1);
  border-color: var(--danger);
}

.danger-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.hint-inline {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
}

.name-dialog select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-height: 38px;
  padding: 0 10px;
  width: 100%;
}

#floorName {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-height: 34px;
  padding: 0 10px;
  width: 100%;
}

#battlemap {
  display: block;
  height: 100%;
  width: 100%;
}

.empty-state {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
  inset: 0;
  justify-content: center;
  pointer-events: none;
  position: absolute;
  text-align: center;
}

.empty-state strong {
  color: var(--text);
  font-size: 1.1rem;
}

.empty-state.hidden {
  display: none;
}

.library-dialog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  max-width: 560px;
  padding: 0;
  width: min(92vw, 560px);
}

.library-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.name-dialog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 0;
  width: min(92vw, 360px);
}

.name-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.name-dialog form {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 18px;
}

.name-dialog h2 {
  font-size: 1rem;
}

.name-dialog input[type="text"] {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-height: 40px;
  padding: 0 12px;
  width: 100%;
}

.name-dialog-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
}

.name-dialog-actions .save-btn {
  background: var(--accent);
  border-color: transparent;
  color: #1b1508;
  font-weight: 750;
}

.library-dialog form {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 18px;
}

.dialog-head,
.saved-map-row {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.saved-map-list {
  display: grid;
  gap: 8px;
  max-height: 55vh;
  overflow-y: auto;
}

.saved-map-row {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.saved-map-row strong,
.saved-map-row span {
  display: block;
}

.saved-map-row span {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 3px;
}

.saved-map-actions {
  display: flex;
  gap: 8px;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(280px, 45vh) 1fr;
  }

  .gm-panel {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    order: 2;
    padding: 16px;
  }

  .stage-wrap {
    height: auto;
    min-height: 0;
    order: 1;
  }

  .app-shell.has-initiative {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(280px, 45vh) 1fr auto;
  }

  .initiative-panel {
    order: 3;
  }

  /* Stacked layout: hide the initiative panel entirely until it's activated, and the
     left-collapse affordance doesn't apply, so keep the panel visible. */
  .app-shell:not(.has-initiative) .initiative-panel {
    display: none;
  }

  .app-shell.panel-collapsed .gm-panel {
    display: none;
  }

  .panel-toggle {
    display: none;
  }
}

/* ----------------------------- initiative tracker ----------------------------- */
.initiative-panel {
  background: #06021c;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px;
}

/* The player display never shows the GM's docked initiative panel. */
.app-shell[data-role="player"] .initiative-panel {
  display: none;
}

.init-head {
  align-items: center;
  display: flex;
  gap: 10px;
}

.init-head h2 {
  flex: 1;
  font-size: 1rem;
  margin: 0;
}

.init-close {
  align-items: center;
  background: none;
  border: 0;
  color: var(--muted);
  display: flex;
  justify-content: center;
  min-height: 0;
  padding: 0;
  width: 26px;
}

.init-close:hover {
  background: none;
  border: 0;
  color: var(--text);
}

.init-close svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 18px;
}

.init-round {
  align-items: center;
  display: flex;
  gap: 8px;
}

.init-round span {
  color: var(--accent);
  flex: 1;
  font-weight: 700;
  text-align: center;
}

.init-round button {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 34px;
  padding: 0 8px;
}

.init-round button svg {
  fill: none;
  height: 16px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 16px;
}

.init-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.init-row {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 8px;
}

.init-row.current {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.init-row-top {
  align-items: center;
  display: flex;
  gap: 8px;
}

.init-dot {
  border-radius: 50%;
  flex: none;
  height: 10px;
  width: 10px;
}

.init-dot.player {
  background: #6fb6f2;
}

.init-dot.npc {
  background: #c7b15a;
}

.init-dot.monster {
  background: #d66a5f;
}

.init-name {
  background: none;
  border: 0;
  color: var(--text);
  cursor: pointer;
  flex: 1;
  font-weight: 600;
  min-height: 0;
  overflow: hidden;
  padding: 2px 0;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.init-name:hover {
  background: none;
  border: 0;
  color: var(--accent);
}

.init-init {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--accent);
  font-weight: 700;
  min-height: 0;
  padding: 3px;
  text-align: center;
  width: 42px;
}

.init-remove {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  min-height: 0;
  padding: 0 4px;
}

.init-remove:hover {
  background: none;
  border: 0;
  color: var(--danger);
}

.init-hp-line {
  align-items: center;
  display: flex;
  gap: 6px;
}

.init-hp-step {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  min-height: 0;
  padding: 2px 7px;
}

.init-hp-bar {
  background: rgba(214, 106, 95, 0.18);
  border-radius: 4px;
  flex: 1;
  height: 8px;
  overflow: hidden;
}

.init-hp-bar span {
  background: linear-gradient(90deg, #8bbf6a, #b1c301);
  display: block;
  height: 100%;
}

.init-hp-input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  min-height: 0;
  padding: 3px;
  text-align: center;
  width: 48px;
}

.init-hp-max {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.init-add {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
}

.init-add input,
.init-add select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-height: 36px;
  padding: 0 10px;
}

.init-add-row {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr 1.2fr;
}

.init-add button[type="submit"] {
  background: var(--accent);
  border-color: transparent;
  color: #1b1508;
  font-weight: 700;
}

/* Floating turn-order overlay on the map (GM always; player when shared). */
.initiative-overlay {
  background: rgba(6, 2, 28, 0.86);
  border: 1px solid var(--line);
  border-radius: 10px;
  bottom: 16px;
  color: var(--text);
  left: 16px;
  max-height: 46vh;
  max-width: 240px;
  min-width: 170px;
  overflow-y: auto;
  padding: 10px 12px;
  position: absolute;
  z-index: 6;
}

.init-ov-round {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.initiative-overlay ol {
  display: flex;
  flex-direction: column;
  gap: 3px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.initiative-overlay li {
  align-items: center;
  border-radius: 6px;
  display: flex;
  gap: 8px;
  padding: 4px 8px;
}

.initiative-overlay li.current {
  background: rgba(177, 195, 1, 0.18);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.initiative-overlay .init-ov-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.initiative-overlay em {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
}
