:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: #090909;
  --surface: #101010;
  --surface-strong: #151515;
  --line: #2d2d2d;
  --line-soft: #1d1d1d;
  --text: #f4f4f2;
  --muted: #aaa9a6;
  --red: #9f2638;
  --red-bright: #c3394d;
  --red-dark: #651824;
  --accent-text: #ffffff;
  --green: #5f9d75;
  --amber: #c99a4c;
  --violet: #8d75b8;
  --danger: #d34a58;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.48);
}

.recent-rooms {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

.active-rooms {
  border-top-color: color-mix(in srgb, var(--green) 58%, var(--line-soft));
}

.recent-rooms-heading,
.recent-room-entry,
.sheet-master-actions,
.sheet-viewer-heading,
.sheet-resource-grid,
.sheet-tab-list {
  display: flex;
  align-items: center;
}

.recent-rooms-heading,
.recent-room-entry,
.sheet-viewer-heading {
  justify-content: space-between;
  gap: 12px;
}

.recent-room-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.recent-room-entry {
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  border-color: var(--line-soft);
  background: rgba(255, 255, 255, 0.025);
}

.recent-room-entry > span:first-child {
  min-width: 0;
}

.recent-room-entry strong,
.recent-room-entry small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-room-entry:hover {
  border-color: var(--red);
  background: rgba(168, 50, 70, 0.12);
}

.recent-room-entry span,
.recent-room-entry small {
  display: block;
}

.recent-room-entry small {
  margin-top: 2px;
  color: var(--muted);
}

.recent-room-entry code {
  color: #f1a4af;
  font-weight: 800;
}

.room-entry-tail {
  flex: 0 0 auto;
  text-align: right;
}

.room-status {
  margin-top: 3px;
  font-size: 0.66rem;
  font-style: normal;
  font-weight: 750;
}

.room-status.is-active {
  color: var(--green);
}

.room-status.is-left {
  color: var(--amber);
}

.room-status.is-closed {
  color: var(--danger);
}

.room-status.is-unavailable {
  color: var(--muted);
}

.sheet-section {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(3, 3, 3, 0.82);
}

.sheet-master-actions,
.sheet-tab-list,
.sheet-resource-grid {
  gap: 8px;
}

.sheet-layout {
  display: grid;
  grid-template-columns: minmax(190px, 250px) minmax(0, 1fr);
  min-height: 330px;
  border-top: 1px solid var(--line-soft);
}

.sheet-list {
  display: grid;
  align-content: start;
  gap: 7px;
  padding: 12px;
  border-right: 1px solid var(--line-soft);
}

.sheet-list-entry {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 10px;
  text-align: left;
  background: rgba(255, 255, 255, 0.025);
}

.sheet-list-entry small {
  color: var(--muted);
}

.sheet-list-entry.is-active {
  border-color: var(--red-bright);
  background: rgba(168, 50, 70, 0.18);
}

.sheet-viewer {
  min-width: 0;
  padding: 16px;
}

.sheet-viewer-heading {
  align-items: flex-start;
}

.sheet-viewer-heading h3 {
  margin: 2px 0 5px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
}

.sheet-viewer-heading p,
.cris-sheet-preview p {
  margin: 0;
  color: var(--muted);
}

.sheet-portrait {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.sheet-tab-list {
  flex-wrap: wrap;
  margin: 16px 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.sheet-tab-list button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.74rem;
}

.sheet-tab-list button.is-active {
  border-color: var(--red);
  color: var(--accent-text);
  background: var(--red-dark);
}

.sheet-resource-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(90px, 1fr));
  margin-top: 12px;
}

.sheet-resource-card,
.sheet-attribute-card,
.sheet-detail-entry {
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.025);
}

.sheet-resource-card span,
.sheet-attribute-card span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.sheet-resource-card strong,
.sheet-attribute-card strong {
  display: block;
  margin-top: 4px;
  color: #fff;
  font-size: 1.1rem;
}

.sheet-attribute-grid,
.sheet-detail-list {
  display: grid;
  gap: 8px;
}

.sheet-attribute-grid {
  grid-template-columns: repeat(5, minmax(60px, 1fr));
}

.sheet-detail-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.sheet-detail-entry > div {
  min-width: 0;
  overflow-wrap: anywhere;
}

.sheet-detail-entry p {
  margin: 3px 0 0;
  color: var(--muted);
  white-space: pre-wrap;
}

.sheet-roll-command {
  width: fit-content;
  max-width: 100%;
  min-height: 32px;
  padding: 5px 9px;
  border-color: rgba(211, 74, 88, 0.58);
  color: #ffd5da;
  white-space: normal;
  overflow-wrap: anywhere;
}

.sheet-roll-actions {
  display: flex;
  width: 100%;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 6px;
}

.sheet-roll-command.damage-command {
  border-color: rgba(225, 177, 81, 0.55);
  color: #f6d99a;
}

.sheet-notes {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.player-notepad {
  display: grid;
  gap: 10px;
}

.player-notepad textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.55;
}

.player-notepad > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.player-notepad small {
  color: var(--muted);
}

.sheet-dialog {
  width: min(920px, calc(100vw - 24px));
}

.sheet-dialog form {
  max-height: min(86vh, 900px);
  overflow-y: auto;
}

.sheet-fieldset {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
}

.sheet-fieldset legend {
  padding: 0 6px;
  color: #d76777;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.attribute-input-grid,
.resource-input-grid {
  display: grid;
  gap: 9px;
}

.attribute-input-grid {
  grid-template-columns: repeat(5, 1fr);
}

.resource-input-grid {
  grid-template-columns: repeat(4, 1fr);
}

.cris-sheet-preview {
  min-height: 92px;
  padding: 13px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.025);
}

.cris-sheet-preview strong,
.cris-sheet-preview span {
  display: block;
}

.cris-sheet-preview span {
  margin-top: 5px;
  color: var(--muted);
}

@media (max-width: 760px) {
  .sheet-layout {
    grid-template-columns: 1fr;
  }

  .sheet-list {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .sheet-resource-grid,
  .attribute-input-grid,
  .resource-input-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sheet-identity-grid {
    grid-template-columns: 1fr;
  }
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  line-height: 1.45;
}

body::before,
body::after {
  position: fixed;
  inset: 0;
  z-index: -2;
  content: "";
  pointer-events: none;
}

body::before {
  background: url("/assets/vanguarda-capa.png") center 27% / cover no-repeat;
  opacity: 0.18;
}

body::after {
  z-index: -1;
  background: rgba(0, 0, 0, 0.78);
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: 0;
  background: #000;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 112px;
  padding: 11px 12px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  border-color: var(--red-bright);
  outline: 2px solid rgba(195, 57, 77, 0.28);
  outline-offset: 2px;
}

label > span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: #d9d9d7;
  font-size: 0.82rem;
  font-weight: 650;
}

label small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
}

[hidden] {
  display: none !important;
}

.mesa-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 58px;
  padding: 8px clamp(14px, 2.5vw, 34px);
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.94);
}

.home-command,
.quiet-command,
.icon-command,
.danger-command,
.primary-command,
.code-command,
.role-switch button {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #080808;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.home-command {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  padding: 8px 11px;
  color: var(--muted);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.home-command span:first-child {
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1;
}

.home-command:hover,
.quiet-command:hover,
.icon-command:hover {
  border-color: #555;
  background: #121212;
  color: var(--text);
}

.mesa-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--red);
  color: var(--accent-text);
  background: var(--red-dark);
  font-family: Georgia, serif;
  font-size: 0.78rem;
  font-weight: 800;
}

.mesa-brand div {
  display: grid;
  line-height: 1.18;
}

.mesa-brand strong {
  font-family: Georgia, serif;
  font-size: 0.96rem;
}

.mesa-brand small {
  color: var(--muted);
  font-size: 0.7rem;
}

.connection-area {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.77rem;
}

.connection-status i,
.presence-dot {
  display: block;
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #666;
}

.connection-status.is-online i,
.presence-dot.is-online {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(95, 157, 117, 0.12);
}

.connection-status.is-connecting i {
  background: var(--amber);
}

.quiet-command,
.danger-command,
.primary-command {
  min-height: 38px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 700;
}

.primary-command {
  border-color: var(--red-bright);
  background: var(--red);
  color: var(--accent-text);
}

.primary-command:hover {
  border-color: var(--red-bright);
  background: color-mix(in srgb, var(--red) 84%, #000000);
}

.danger-command {
  border-color: rgba(211, 74, 88, 0.58);
  color: #ffbdc4;
  background: rgba(101, 24, 36, 0.3);
}

.danger-command:hover {
  background: rgba(159, 38, 56, 0.4);
}

.auth-view {
  display: grid;
  min-height: calc(100vh - 59px);
  place-items: center;
  padding: 34px 18px;
}

.auth-panel {
  width: min(100%, 450px);
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid var(--line);
  border-top: 3px solid var(--red);
  border-radius: 7px;
  background: rgba(5, 5, 5, 0.96);
  box-shadow: var(--shadow);
}

.auth-heading {
  margin-bottom: 22px;
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: #d76777;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  overflow-wrap: anywhere;
  font-family: Georgia, "Times New Roman", serif;
}

.auth-heading h1 {
  margin-bottom: 0;
  font-size: 1.75rem;
}

.role-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  margin-bottom: 22px;
  padding: 3px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #000;
}

.role-switch button {
  min-height: 38px;
  border-color: transparent;
  color: var(--muted);
}

.role-switch button.is-active {
  border-color: var(--red-dark);
  background: var(--red-dark);
  color: var(--accent-text);
}

.auth-form {
  display: grid;
  gap: 15px;
}

.auth-form .primary-command {
  min-height: 44px;
  margin-top: 4px;
}

.room-code-input {
  color: #fff;
  font-family: Consolas, "Courier New", monospace;
  font-size: 1.15rem;
  font-weight: 800;
  text-transform: uppercase;
}

.form-error {
  margin: 13px 0 0;
  padding: 9px 11px;
  border-left: 3px solid var(--danger);
  color: #ffc2c9;
  background: rgba(101, 24, 36, 0.26);
  font-size: 0.8rem;
}

.room-view {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 2.2vw, 30px);
}

.room-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  min-height: 76px;
  margin-bottom: 16px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.room-heading h1 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
}

.room-code-block {
  display: flex;
  align-items: center;
  gap: 10px;
}

.room-code-block > span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.code-command {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 10px;
  min-height: 42px;
  padding: 7px 11px;
}

.code-command:hover {
  border-color: var(--red);
}

.code-command strong {
  color: #fff;
  font-family: Consolas, "Courier New", monospace;
  font-size: 1rem;
}

.code-command small {
  color: var(--muted);
  font-size: 0.66rem;
}

.room-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 320px);
  gap: 14px;
  align-items: start;
}

.session-stage,
.participants-panel {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(5, 5, 5, 0.94);
}

.section-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.section-bar.compact {
  min-height: 58px;
  padding-block: 10px;
}

.section-bar h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.count-badge {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: #090909;
  font-size: 0.7rem;
  font-weight: 700;
}

.stage-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 170px;
  padding: 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 12, 12, 0.78);
}

.stage-status {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.stage-status strong {
  display: block;
  margin-bottom: 5px;
  font-size: 1rem;
}

.stage-status p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.signal-emblem {
  display: grid;
  width: 74px;
  height: 74px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--red);
  color: #fff;
  background: #080808;
  font-family: Georgia, serif;
  font-size: 1.1rem;
  font-weight: 800;
  box-shadow: inset 0 0 0 7px #020202;
}

.master-actions {
  display: grid;
  justify-items: end;
  gap: 12px;
}

.toggle-row,
.option-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.76rem;
}

.toggle-row input,
.option-row input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--red-bright);
}

.tabletop-section {
  border-bottom: 1px solid var(--line);
  background: #050505;
}

.tabletop-heading {
  background: rgba(12, 12, 12, 0.88);
}

.active-map-name {
  max-width: 48%;
  overflow: hidden;
  color: #d5d5d1;
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabletop-layout {
  display: grid;
  grid-template-columns: minmax(190px, 230px) minmax(0, 1fr);
  min-height: 520px;
}

.tabletop-layout.is-player {
  grid-template-columns: minmax(0, 1fr);
}

.map-library-panel {
  min-width: 0;
  border-right: 1px solid var(--line);
  background: #080808;
  font-size: 100%;
}

.map-library-heading {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line-soft);
}

.map-library-heading strong {
  display: block;
  font-size: 0.9em;
}

.map-library-panel .eyebrow,
.map-library-panel .compact-command,
.map-library-panel .status-badge {
  font-size: 0.68em;
}

.compact-command {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.72rem;
}

.map-list {
  display: grid;
  max-height: 585px;
  overflow: auto;
}

.map-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
}

.map-entry.is-active {
  border-left: 3px solid var(--red-bright);
  background: rgba(122, 26, 41, 0.14);
}

.map-entry-copy {
  min-width: 0;
}

.map-entry-copy strong,
.map-entry-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-entry-copy strong {
  font-size: 0.83em;
}

.map-entry-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.66em;
}

.map-select-command {
  min-height: 30px;
  padding: 5px 8px;
  border-color: var(--line-soft);
  font-size: 0.68em;
}

.map-entry-actions {
  display: grid;
  justify-items: stretch;
  gap: 6px;
}

.map-delete-command {
  min-height: 28px;
  padding: 4px 7px;
  border-color: rgba(231, 81, 99, 0.42);
  color: #ffabb6;
  background: rgba(134, 24, 41, 0.12);
  font-size: 0.65em;
}

.board-panel {
  min-width: 0;
  background: #030303;
}

.board-toolbar {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: #0a0a0a;
}

.fog-toolbar {
  display: flex;
  min-height: 52px;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #070707;
}

.fog-toolbar[hidden] {
  display: none;
}

.fog-toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.66rem;
}

.fog-toolbar select,
.fog-toolbar input {
  min-height: 34px;
  padding: 5px 7px;
}

.fog-toolbar input {
  width: 76px;
}

.fog-tool-group,
.fog-global-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.fog-global-actions {
  margin-left: auto;
}

.fog-tool {
  min-height: 34px;
  padding: 6px 9px;
  border-color: var(--line-soft);
  color: var(--muted);
  background: #0d0d0d;
  font-size: 0.68rem;
}

.fog-tool.is-active {
  border-color: var(--red-bright);
  color: #fff;
  background: rgba(122, 26, 41, 0.34);
}

.zoom-controls,
.grid-controls {
  display: flex;
  align-items: center;
  gap: 7px;
}

.grid-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.7rem;
}

.grid-controls input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
  accent-color: var(--red-bright);
}

.grid-controls input[type="number"] {
  width: 66px;
  min-height: 34px;
  padding: 6px 7px;
}

.zoom-readout {
  min-width: 58px;
  min-height: 34px;
  padding-inline: 7px;
  color: var(--muted);
  font-size: 0.7rem;
}

.map-viewport {
  position: relative;
  height: clamp(420px, 62vh, 720px);
  overflow: hidden;
  outline: none;
  background-color: #050505;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.018) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.018) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.018) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.018) 75%);
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
  cursor: grab;
  touch-action: none;
}

.map-viewport:focus-visible {
  box-shadow: inset 0 0 0 2px var(--red-bright);
}

.map-viewport.is-panning {
  cursor: grabbing;
}

.map-empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.map-empty-state .signal-emblem {
  margin-bottom: 6px;
}

.map-empty-state p {
  margin: 0;
  font-size: 0.78rem;
}

.map-world {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  user-select: none;
  will-change: transform;
}

.map-world > img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
}

.map-grid,
.fog-layer,
.token-layer {
  position: absolute;
  inset: 0;
}

.map-grid {
  z-index: 2;
  background-image:
    linear-gradient(to right, rgba(238, 238, 230, 0.26) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(238, 238, 230, 0.26) 1px, transparent 1px);
  pointer-events: none;
}

.fog-layer {
  z-index: 3;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.fog-layer.is-editing {
  cursor: crosshair;
  pointer-events: auto;
  touch-action: none;
}

.fog-input-surface {
  cursor: crosshair;
}

.fog-cover {
  fill: #000;
  opacity: 0.9;
  pointer-events: none;
}

.fog-layer.is-master .fog-cover {
  opacity: 0.30;
}

.token-layer {
  z-index: 4;
}

.map-token {
  position: absolute;
  display: block;
  padding: 0;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7), inset 0 0 0 2px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -50%);
  transition: left 40ms linear, top 40ms linear, opacity 140ms ease;
  font-size: 0.72rem;
  font-weight: 800;
  text-shadow: 0 1px 3px #000;
  touch-action: none;
  user-select: none;
}

.map-token.is-draggable {
  cursor: grab;
}

.map-token.is-dragging {
  z-index: 5;
  cursor: grabbing;
  transition: none;
  box-shadow: 0 7px 22px rgba(0, 0, 0, 0.8), 0 0 0 3px rgba(195, 57, 77, 0.42);
}

.map-token.is-hidden-token {
  opacity: 0.48;
  border-style: dashed;
  box-shadow: 0 0 0 3px rgba(225, 177, 81, 0.25), 0 4px 14px rgba(0, 0, 0, 0.7);
}

.map-token.has-image {
  border-color: transparent;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none;
  text-shadow: none;
}

.map-token.has-image .token-portrait {
  inset: 0;
  overflow: visible;
  border-radius: 0;
}

.map-token.has-image.is-dragging {
  box-shadow: 0 0 0 3px rgba(195, 57, 77, 0.6);
}

.token-portrait {
  position: absolute;
  inset: 2px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.token-portrait img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.token-context-menu {
  position: fixed;
  z-index: 24;
  display: grid;
  width: min(250px, calc(100vw - 16px));
  padding: 8px;
  border: 1px solid #454545;
  border-radius: 6px;
  background: #0b0b0b;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.72);
}

.token-context-menu[hidden] {
  display: none;
}

.token-context-heading {
  display: grid;
  gap: 3px;
  padding: 8px 9px 10px;
  border-bottom: 1px solid var(--line-soft);
}

.token-context-heading strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.token-variant-field {
  display: grid;
  gap: 5px;
  padding: 9px;
}

.token-variant-field span {
  color: var(--muted);
  font-size: 0.64rem;
}

.token-variant-field select {
  min-height: 34px;
  padding: 5px 7px;
}

.token-context-menu > button {
  min-height: 36px;
  justify-content: flex-start;
  padding: 7px 9px;
  border-color: transparent;
  color: #d2d2ce;
  background: transparent;
  text-align: left;
}

.token-context-menu > button:hover {
  border-color: var(--line-soft);
  background: #171717;
}

.token-context-menu > .danger-menu-command {
  color: #f08a98;
}

.board-help {
  margin: 0;
  padding: 8px 12px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  background: #080808;
  font-size: 0.65rem;
}

.compact-dialog {
  width: min(460px, calc(100vw - 28px));
}

.session-tools-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
  background: #060606;
}

.dice-panel,
.initiative-panel {
  min-width: 0;
}

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

.dice-form,
.initiative-form {
  display: grid;
  gap: 11px;
  padding: 13px;
  border-bottom: 1px solid var(--line-soft);
  background: #090909;
}

.dice-form > .primary-command,
.initiative-form > .primary-command {
  justify-self: end;
}

.quick-dice {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.quick-dice button {
  min-width: 39px;
  min-height: 31px;
  padding: 5px 7px;
  border-color: var(--line-soft);
  color: #d5d5d1;
  background: #111;
  font-size: 0.68rem;
}

.quick-dice button:hover {
  border-color: var(--red-bright);
  background: rgba(122, 26, 41, 0.28);
}

.dice-history {
  display: grid;
  max-height: 430px;
  overflow: auto;
}

.dice-entry {
  display: grid;
  gap: 6px;
  padding: 12px 13px;
  border-bottom: 1px solid var(--line-soft);
  background: #070707;
}

.dice-entry[data-visibility="master_private"] {
  border-left: 3px solid #3e6e8f;
}

.dice-entry[data-visibility="master_secret"] {
  border-left: 3px solid #8b6a34;
  background: #0c0a06;
}

.dice-entry-heading,
.dice-entry-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dice-entry-heading strong {
  font-size: 0.76rem;
}

.dice-entry-heading time,
.dice-entry small {
  color: var(--muted);
  font-size: 0.62rem;
}

.dice-expression {
  color: #eee;
  font-family: Consolas, monospace;
  font-size: 0.74rem;
}

.dice-total {
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
}

.dice-details {
  margin: 0;
  color: #b8b8b3;
  font-size: 0.68rem;
  line-height: 1.5;
}

.roll-visibility {
  justify-self: start;
  padding: 3px 6px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.58rem;
}

.round-badge {
  padding: 5px 8px;
  border: 1px solid var(--red-dark);
  border-radius: 999px;
  color: #eee;
  background: rgba(122, 26, 41, 0.2);
  font-size: 0.66rem;
}

.initiative-current {
  min-height: 44px;
  padding: 12px 13px;
  border-bottom: 1px solid var(--line-soft);
  color: #ddd;
  background: rgba(122, 26, 41, 0.12);
  font-size: 0.74rem;
}

.initiative-current strong {
  color: #fff;
}

.initiative-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: #080808;
}

.initiative-fields {
  grid-template-columns: minmax(0, 1fr) 90px;
}

.initiative-list {
  display: grid;
  max-height: 430px;
  overflow: auto;
}

.initiative-entry {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: #070707;
}

.initiative-entry.is-current {
  border-left: 3px solid var(--red-bright);
  background: rgba(122, 26, 41, 0.18);
}

.initiative-entry.is-hidden-entry {
  opacity: 0.64;
  border-right: 3px solid #8b6a34;
}

.initiative-order {
  color: var(--muted);
  font-family: Consolas, monospace;
  font-size: 0.7rem;
  text-align: center;
}

.initiative-copy {
  min-width: 0;
}

.initiative-copy strong,
.initiative-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.initiative-copy strong {
  font-size: 0.76rem;
}

.initiative-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.6rem;
}

.initiative-value {
  min-width: 38px;
  color: #fff;
  font-size: 1rem;
  text-align: center;
}

.initiative-master-editor {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px auto auto;
  gap: 6px;
  align-items: center;
}

.initiative-master-editor input {
  min-height: 32px;
  padding: 5px 7px;
}

.initiative-hidden-label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.62rem;
}

.initiative-hidden-label input {
  width: 15px;
  min-height: 15px;
}

@media (max-width: 980px) {
  .session-tools-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .dice-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 640px) {
  .initiative-master-editor {
    grid-template-columns: minmax(0, 1fr) 76px;
  }

  .initiative-master-editor button,
  .initiative-hidden-label {
    grid-column: auto;
  }
}

/* Fase 10: area de jogo ampliada, participantes independentes e aparencia */
.session-metadata,
.session-stage > .section-bar:first-child,
.session-stage > .stage-content {
  display: none !important;
}

.topbar-room-code {
  display: none;
}

body.has-room .topbar-room-code {
  display: flex;
}

.topbar-room-code > span,
.topbar-room-code .code-command small {
  display: none;
}

.topbar-room-code .code-command {
  min-height: 34px;
  padding: 5px 9px;
}

.appearance-command {
  white-space: nowrap;
}

.accent-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.68rem;
}

.accent-picker > span {
  display: inline;
  margin: 0;
  color: inherit;
  font-size: inherit;
}

.accent-picker input[type="color"] {
  width: 34px;
  min-height: 34px;
  padding: 3px;
  border-radius: 50%;
  cursor: pointer;
}

.workspace-taskbar {
  grid-template-columns: auto minmax(280px, 1fr) auto auto;
}

.workspace-taskbar > .quiet-command.is-active {
  border-color: var(--red-dark);
  color: #fff;
  background: color-mix(in srgb, var(--red) 28%, transparent);
}

.workspace-right-rail {
  grid-template-rows: minmax(0, 1fr);
}

.participants-drawer {
  position: fixed;
  z-index: 25;
  top: 76px;
  right: 24px;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100dvh - 96px);
  overflow: auto;
  border-color: var(--red-dark);
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  box-shadow: var(--shadow);
}

.participant-master-actions {
  align-items: stretch;
  justify-items: stretch;
  padding: 12px 14px;
  border-top: 1px solid var(--line-soft);
}

.map-library-actions {
  display: flex;
  gap: 6px;
}

.map-location-group > summary {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--red-bright);
  background: var(--panel);
  font-size: 0.7em;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
}

.map-location-group > summary::-webkit-details-marker {
  display: none;
}

.map-location-group > summary::before {
  margin-right: 6px;
  content: "▸";
}

.map-location-group[open] > summary::before {
  content: "▾";
}

.map-location-group > summary span {
  flex: 1;
}

.map-location-group > summary small {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.8em;
}

.map-location-body-heading {
  display: grid;
  gap: 7px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
}

.map-location-body-heading > div:first-child small,
.map-location-body-heading > div:first-child strong {
  display: block;
}

.map-location-body-heading > div:first-child small {
  color: var(--muted);
  font-size: 0.66em;
}

.map-location-body-heading > div:first-child strong {
  margin-top: 2px;
  font-size: 0.72em;
}

.map-location-body-actions {
  display: flex;
  gap: 5px;
}

.map-location-information {
  border-bottom: 1px solid var(--line-soft);
}

.map-location-information > summary {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  font-size: 0.7em;
  font-weight: 750;
  cursor: pointer;
}

.map-location-description,
.map-location-secret,
.map-location-info-section {
  margin: 0;
  padding: 9px 10px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.7em;
  white-space: pre-wrap;
}

.map-location-description,
.map-location-info-section article p {
  color: var(--muted);
}

.map-location-secret {
  border-left: 2px solid var(--red);
  background: color-mix(in srgb, var(--red) 7%, transparent);
}

.map-location-secret p,
.map-location-info-section article p {
  margin: 4px 0 0;
}

.map-location-info-section > strong,
.map-location-info-section article b,
.map-location-info-section article small {
  display: block;
}

.map-location-info-section article {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px dashed var(--line-soft);
}

.map-location-info-section article small {
  margin-top: 2px;
  color: var(--muted);
}

.full-shield-tab.is-active {
  border-color: var(--red-bright);
  color: var(--accent-text);
  background: var(--red);
}

.full-master-shield {
  display: flex;
  min-height: 0;
  height: 100%;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
}

.full-master-shield-bar {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
}

.full-master-shield-bar strong,
.full-master-shield-bar span {
  display: block;
}

.full-master-shield iframe {
  width: 100%;
  min-height: 0;
  flex: 1;
  border: 0;
  background: #050505;
}

.map-location-select {
  min-height: 28px;
  margin-top: 7px;
  padding: 3px 6px;
  font-size: 0.7em;
}

@media (min-width: 1100px) {
  body.has-room.is-full-shield .room-view {
    grid-template-rows: minmax(0, 1fr);
  }

  body.has-room .room-view {
    grid-template-rows: auto minmax(0, 1fr);
  }

  body.has-room .room-layout {
    height: 100%;
    min-height: 0;
    align-items: stretch;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) minmax(335px, 390px);
  }

  body.has-room .session-stage,
  body.has-room .tabletop-section,
  body.has-room .tabletop-layout,
  body.has-room .board-panel {
    height: 100%;
    min-height: 0;
  }

  body.has-room .tabletop-section > .section-bar {
    min-height: 38px;
    padding-block: 4px;
  }

  body.has-room .tabletop-layout {
    grid-template-columns: minmax(175px, 210px) minmax(0, 1fr);
  }

  body.has-room .map-list {
    max-height: calc(100dvh - 205px);
  }

  body.has-room .map-viewport {
    height: auto;
    min-height: 0;
    flex: 1 1 auto;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef0f3;
  --panel: #ffffff;
  --surface: #f6f7f9;
  --surface-strong: #e8ebef;
  --line: #c5cbd3;
  --line-soft: #dde1e6;
  --text: #181b20;
  --muted: #626973;
  --shadow: 0 18px 55px rgba(22, 29, 38, 0.18);
}

:root[data-theme="light"] body::before {
  opacity: 0.08;
}

:root[data-theme="light"] body::after {
  background: rgba(238, 240, 243, 0.86);
}

:root[data-theme="light"] .mesa-topbar,
:root[data-theme="light"] .workspace-taskbar,
:root[data-theme="light"] .session-stage,
:root[data-theme="light"] .participants-panel,
:root[data-theme="light"] .sheet-section,
:root[data-theme="light"] .map-library-panel,
:root[data-theme="light"] .tabletop-section,
:root[data-theme="light"] .tabletop-heading,
:root[data-theme="light"] .board-panel,
:root[data-theme="light"] .board-toolbar,
:root[data-theme="light"] .fog-toolbar,
:root[data-theme="light"] .workspace-drawer,
:root[data-theme="light"] .auth-panel,
:root[data-theme="light"] dialog,
:root[data-theme="light"] .private-popup-card {
  background: var(--panel);
}

:root[data-theme="light"] input,
:root[data-theme="light"] textarea,
:root[data-theme="light"] select,
:root[data-theme="light"] .home-command,
:root[data-theme="light"] .quiet-command,
:root[data-theme="light"] .icon-command,
:root[data-theme="light"] .danger-command,
:root[data-theme="light"] .code-command,
:root[data-theme="light"] .role-switch,
:root[data-theme="light"] .role-switch button,
:root[data-theme="light"] .count-badge,
:root[data-theme="light"] .fog-tool {
  color: var(--text);
  background: var(--surface);
}

:root[data-theme="light"] .map-viewport {
  background-color: #dfe3e8;
}

:root[data-theme="light"] .code-command strong,
:root[data-theme="light"] .room-code-input,
:root[data-theme="light"] label > span,
:root[data-theme="light"] .active-map-name,
:root[data-theme="light"] .workspace-result-copy > strong {
  color: var(--text);
}

@media (max-width: 720px) {
  .appearance-command,
  .accent-picker > span {
    display: none;
  }

  .participants-drawer {
    top: 68px;
    right: 10px;
  }
}

.message-section {
  min-height: 270px;
}

.message-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 0.7fr)) minmax(180px, 1.4fr) auto;
  align-items: end;
  gap: 9px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.018);
}

.message-filters label {
  min-width: 0;
}

.message-filters label[hidden] {
  display: none;
}

.message-filters label > span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.message-filters input,
.message-filters select {
  min-height: 34px;
  padding: 0 9px;
  font-size: 0.72rem;
}

.message-result-count {
  align-self: center;
  min-width: 76px;
  color: var(--muted);
  font-size: 0.66rem;
  text-align: right;
}

.presentation-section {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(3, 3, 3, 0.88);
}

.presentation-media-gate,
.presentation-player-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(96, 27, 39, 0.1);
}

.presentation-media-gate p,
.presentation-player-summary p,
.presentation-control-card p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.presentation-player-summary {
  display: grid;
  background: transparent;
}

.presentation-master-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(250px, 0.82fr);
  gap: 1px;
  background: var(--line);
}

.presentation-library-card,
.presentation-control-card {
  min-width: 0;
  padding: 15px;
  background: #070707;
}

.presentation-library-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.presentation-library-card > header > div,
.presentation-control-card > div:first-child {
  display: grid;
  gap: 2px;
}

.presentation-asset-list,
.presentation-readiness {
  display: grid;
  gap: 7px;
  max-height: 260px;
  overflow: auto;
}

.presentation-asset-entry,
.presentation-ready-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: #0d0d0d;
}

.presentation-asset-entry > div,
.presentation-ready-entry > div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.presentation-asset-entry strong,
.presentation-ready-entry strong {
  overflow: hidden;
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.presentation-asset-entry small,
.presentation-ready-entry small {
  color: var(--muted);
  font-size: 0.64rem;
}

.presentation-control-card {
  display: grid;
  align-content: start;
  gap: 13px;
}

.presentation-control-row,
.presentation-seek-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.presentation-seek-row {
  align-items: end;
}

.presentation-seek-row label {
  flex: 1 1 120px;
}

.presentation-seek-row input {
  width: 100%;
}

.presentation-ready-state {
  color: #d4939d;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
}

.presentation-ready-entry.is-ready .presentation-ready-state {
  color: #91c6a3;
}

.presentation-overlay {
  position: fixed;
  inset: 0;
  z-index: 26;
  display: grid;
  place-items: stretch;
  padding: 0;
}

.presentation-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: #000;
}

.presentation-overlay-stage {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  overflow: hidden;
  place-items: center;
  background: #000;
}

.presentation-overlay[data-transition="fade"] .presentation-overlay-stage {
  animation: presentation-fade-in 420ms ease-out;
}

.presentation-scene-image,
.presentation-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.presentation-overlay-copy {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: clamp(48px, 9vh, 100px) clamp(22px, 6vw, 80px) clamp(24px, 6vh, 58px);
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
  pointer-events: none;
}

.presentation-overlay-copy h2 {
  margin: 5px 0 7px;
  font-size: clamp(1.5rem, 4vw, 3.4rem);
  text-shadow: 0 3px 18px #000;
}

.presentation-overlay-copy p {
  max-width: 780px;
  margin: 0;
  color: #deded9;
  font-size: clamp(0.82rem, 1.4vw, 1.05rem);
  white-space: pre-wrap;
}

.presentation-overlay-copy small {
  display: block;
  margin-top: 10px;
  color: #aaa;
}

.presentation-overlay-controls {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 9px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.78);
}

.presentation-overlay-controls label {
  width: min(190px, 36vw);
}

.presentation-overlay-controls label span {
  display: block;
  margin-bottom: 4px;
  color: #bbb;
  font-size: 0.64rem;
}

.presentation-overlay.is-master-minimized {
  inset: auto 18px 18px auto;
  width: min(440px, calc(100vw - 36px));
  height: min(300px, calc(100vh - 36px));
  border: 1px solid var(--red);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  pointer-events: none;
}

.presentation-overlay.is-master-minimized .presentation-overlay-backdrop {
  display: none;
}

.presentation-overlay.is-master-minimized .presentation-overlay-stage {
  pointer-events: auto;
}

.presentation-overlay.is-master-minimized .presentation-overlay-copy {
  padding: 70px 14px 14px;
}

.presentation-overlay.is-master-minimized .presentation-overlay-copy h2 {
  margin: 2px 0;
  font-size: 1rem;
}

.presentation-overlay.is-master-minimized .presentation-overlay-copy p,
.presentation-overlay.is-master-minimized .presentation-overlay-copy small,
.presentation-overlay.is-master-minimized .presentation-overlay-controls > :not(#presentationOverlayMinimizeBtn):not(#presentationOverlayStopBtn) {
  display: none !important;
}

.presentation-overlay.is-master-minimized .presentation-overlay-controls {
  top: 8px;
  right: 8px;
  padding: 6px;
}

@keyframes presentation-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 1180px) {
  .presentation-master-panel {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .presentation-control-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .presentation-master-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .presentation-control-card {
    grid-column: auto;
  }

  .presentation-media-gate {
    align-items: stretch;
    flex-direction: column;
  }

  .presentation-overlay-controls {
    right: 10px;
    left: 10px;
    flex-wrap: wrap;
  }
}

.icon-command {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--muted);
  font-size: 1.2rem;
}

.message-list,
.participant-list {
  display: grid;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  padding: 28px;
  color: var(--muted);
  text-align: center;
  font-size: 0.82rem;
}

.message-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.message-entry:last-child {
  border-bottom: 0;
}

.message-copy {
  min-width: 0;
}

.message-copy header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 5px;
}

.message-copy strong {
  overflow-wrap: anywhere;
  font-size: 0.84rem;
}

.message-copy small,
.message-meta {
  color: var(--muted);
  font-size: 0.7rem;
}

.message-copy .message-policy,
.message-copy .message-failure {
  display: block;
  margin-top: 7px;
}

.message-copy .message-failure {
  color: #ff9eaa;
}

.resend-badge {
  width: max-content;
  padding: 2px 5px;
  border: 1px solid rgba(129, 99, 177, 0.5);
  border-radius: 3px;
  color: #c1afe1;
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
}

.message-copy p {
  display: -webkit-box;
  overflow: hidden;
  margin-bottom: 0;
  color: #d2d2d0;
  font-size: 0.78rem;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.message-state {
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 5px;
}

.resend-command {
  min-height: 28px;
  margin-top: 3px;
  padding: 4px 8px;
  font-size: 0.65rem;
}

.status-badge,
.priority-badge {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-badge[data-status="read"] {
  border-color: rgba(95, 157, 117, 0.45);
  color: #91c6a3;
}

.status-badge[data-status="delivered"] {
  border-color: rgba(201, 154, 76, 0.45);
  color: #ddbc82;
}

.status-badge[data-status="failed"] {
  border-color: rgba(211, 74, 88, 0.55);
  color: #ff9eaa;
}

.priority-badge[data-priority="urgent"] {
  border-color: var(--red);
  color: #ff9eaa;
}

.priority-badge[data-priority="paranormal"] {
  border-color: var(--violet);
  color: #c1afe1;
}

.participant-list {
  padding: 5px 0;
}

.participant-entry {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 9px 13px;
  border-bottom: 1px solid var(--line-soft);
}

.participant-entry:last-child {
  border-bottom: 0;
}

.participant-entry div {
  display: grid;
  min-width: 0;
}

.participant-entry strong,
.participant-entry small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-entry strong {
  font-size: 0.8rem;
}

.participant-entry small {
  color: var(--muted);
  font-size: 0.67rem;
}

.message-command {
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid var(--red-dark);
  border-radius: 4px;
  color: #fff;
  background: var(--red-dark);
  font-size: 0.68rem;
  font-weight: 700;
}

.message-command:hover {
  border-color: var(--red-bright);
  background: var(--red);
}

.participant-actions {
  display: flex !important;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.kick-command {
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid rgba(225, 78, 92, 0.5);
  border-radius: 4px;
  color: #ff9eaa;
  background: rgba(116, 18, 31, 0.22);
  font-size: 0.68rem;
  font-weight: 700;
}

.kick-command:hover {
  border-color: #ff6677;
  background: rgba(116, 18, 31, 0.48);
}

.message-document-options {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 11px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
}

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

#composerDocumentFields[hidden],
.composer-document-preview[hidden] {
  display: none;
}

.composer-document-preview {
  max-height: 180px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: #050505;
}

.composer-document-preview img {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: contain;
}

.sheet-inventory-group + .sheet-inventory-group {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.received-document-list {
  display: grid;
  gap: 9px;
}

.received-document-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
  padding: 9px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.025);
}

.received-document-card > div {
  min-width: 0;
}

.received-document-card strong,
.received-document-card small {
  display: block;
}

.received-document-card p,
.document-viewer-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.received-document-card p {
  max-height: 5.4em;
  margin: 5px 0 9px;
  overflow: hidden;
  color: var(--muted);
}

.received-document-thumb,
.received-document-placeholder {
  width: 74px;
  height: 74px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #050505;
}

.received-document-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.received-document-placeholder {
  display: grid;
  place-items: center;
  color: var(--red-bright);
  font-weight: 800;
}

.received-document-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.standalone-document-inventory {
  padding: 14px;
}

.document-viewer-dialog article {
  min-width: 0;
}

.document-viewer-dialog img {
  display: block;
  width: 100%;
  max-height: min(68vh, 760px);
  object-fit: contain;
  background: #030303;
}

.document-viewer-content {
  padding: 0 16px;
}

.document-table-overlay {
  position: absolute;
  z-index: 35;
  inset: clamp(8px, 3vw, 32px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--red-dark);
  border-radius: 7px;
  background: rgba(3, 3, 4, 0.96);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

.document-table-overlay[hidden] {
  display: none;
}

.document-table-overlay header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.document-table-overlay header div {
  display: grid;
}

.document-table-overlay img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.document-table-overlay p {
  max-height: 7em;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
}

.document-table-overlay small {
  color: var(--muted);
}

.composer-dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100vh - 30px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.composer-dialog::backdrop {
  background: rgba(0, 0, 0, 0.76);
}

.composer-dialog form {
  display: grid;
  gap: 15px;
  padding: 21px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.dialog-heading h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.private-popup {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
}

.popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
}

.popup-sheet {
  position: relative;
  width: min(560px, 100%);
  max-height: min(620px, calc(100vh - 36px));
  padding: clamp(23px, 5vw, 38px);
  overflow: auto;
  border: 1px solid #4a4a4a;
  border-top: 4px solid var(--red);
  border-radius: 7px;
  background: #070707;
  box-shadow: var(--shadow);
  transform-origin: center;
  animation: popup-in 180ms ease-out;
}

.popup-sheet[data-priority="important"] {
  border-top-color: var(--amber);
}

.popup-sheet[data-priority="urgent"] {
  border-top-color: var(--red-bright);
  animation: popup-in 180ms ease-out, popup-alert 1.25s ease-in-out 220ms 2;
}

.popup-sheet[data-priority="paranormal"] {
  border-top-color: var(--violet);
}

.popup-priority {
  display: block;
  margin-bottom: 9px;
  color: #d76777;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.popup-sheet[data-priority="paranormal"] .popup-priority {
  color: #c1afe1;
}

.popup-sheet h2 {
  margin-bottom: 14px;
  font-size: 1.45rem;
}

.popup-sheet > p {
  margin-bottom: 25px;
  color: #e2e2df;
  font-size: 0.95rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.popup-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.popup-footer > span {
  color: var(--muted);
  font-size: 0.7rem;
}

.dice-roll-popup {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 29;
  width: min(410px, calc(100vw - 40px));
}

.dice-roll-popup[hidden] {
  display: none;
}

.dice-roll-popup > article {
  overflow: hidden;
  border: 1px solid #4a4a4a;
  border-top: 4px solid var(--red-bright);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 97%, transparent);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.82);
  animation: dice-popup-in 220ms ease-out;
}

.dice-roll-popup header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 15px 10px;
}

.dice-roll-popup header strong,
.dice-roll-popup header span {
  display: block;
}

.dice-roll-popup header strong {
  margin-top: 3px;
  font-size: 1rem;
}

.dice-popup-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 15px;
  border-block: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--red) 11%, transparent);
}

.dice-popup-result span {
  color: #e7d9dc;
  font-weight: 750;
}

.dice-popup-result strong {
  color: var(--red-bright);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
}

.dice-roll-popup > article > p {
  margin: 0;
  padding: 11px 15px 14px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.attack-confirmation {
  padding: 12px 15px 15px;
  border-top: 1px solid var(--line);
  background: rgba(126, 83, 18, 0.12);
}

.attack-confirmation > p {
  margin: 0 0 10px;
  line-height: 1.45;
}

.attack-confirmation > div {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
}

@keyframes dice-popup-in {
  from {
    opacity: 0;
    transform: translateX(-18px) translateY(8px);
  }

  to {
    opacity: 1;
    transform: translate(0);
  }
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: grid;
  width: min(360px, calc(100vw - 36px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  border-radius: 5px;
  color: #ececea;
  background: #090909;
  box-shadow: var(--shadow);
  font-size: 0.78rem;
  animation: toast-in 180ms ease-out;
}

.toast.is-error {
  border-left-color: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .room-layout {
    grid-template-columns: 1fr;
  }

  .participants-panel {
    order: -1;
  }

  .participant-list {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .participant-entry {
    border-right: 1px solid var(--line-soft);
  }

  .tabletop-layout {
    grid-template-columns: 1fr;
  }

  .map-library-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .map-list {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    max-height: 240px;
  }
}

@media (max-width: 640px) {
  .dice-roll-popup {
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
  }

  .attack-confirmation > div,
  .player-notepad > div {
    align-items: stretch;
    flex-direction: column;
  }

  .mesa-topbar {
    grid-template-columns: auto 1fr;
    gap: 10px;
  }

  .mesa-brand {
    justify-self: end;
  }

  .connection-area {
    grid-column: 1 / -1;
    justify-content: space-between;
    padding-top: 7px;
    border-top: 1px solid var(--line-soft);
  }

  .room-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .room-code-block {
    width: 100%;
    justify-content: space-between;
  }

  .stage-content {
    align-items: flex-start;
    flex-direction: column;
  }

  .master-actions {
    width: 100%;
    justify-items: stretch;
  }

  .signal-emblem {
    width: 58px;
    height: 58px;
  }

  .message-entry {
    grid-template-columns: 1fr;
  }

  .message-state {
    grid-auto-flow: column;
    justify-content: start;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .tabletop-heading,
  .board-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .active-map-name {
    max-width: 100%;
  }

  .zoom-controls,
  .grid-controls {
    flex-wrap: wrap;
  }

  .map-viewport {
    height: 420px;
  }

  .popup-footer {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

.message-meta {
  line-height: 1.45;
  text-align: right;
  white-space: pre-line;
}

@keyframes popup-in {
  from {
    opacity: 0;
    transform: scale(0.97);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes popup-alert {
  0%, 100% {
    box-shadow: var(--shadow);
  }

  50% {
    box-shadow: 0 18px 55px rgba(0, 0, 0, 0.48), 0 0 0 3px rgba(195, 57, 77, 0.22);
  }
}

@media (max-width: 640px) {
  .message-filters {
    grid-template-columns: 1fr 1fr;
  }

  .message-search-field,
  .message-result-count {
    grid-column: 1 / -1;
  }

  .message-result-count {
    text-align: left;
  }

  .message-state {
    grid-auto-flow: row;
    grid-template-columns: auto auto;
  }

  .message-meta {
    grid-column: 1 / -1;
    text-align: left;
  }
}

/* Fase 9: workspace integrado do Mestre */
.workspace-taskbar {
  display: grid;
  grid-template-columns: auto minmax(280px, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(3, 3, 3, 0.96);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.24);
}

.workspace-mode-tabs {
  display: flex;
  min-width: 0;
  gap: 5px;
  overflow-x: auto;
}

.workspace-mode-tabs button {
  min-height: 34px;
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  font-size: 0.7rem;
  font-weight: 800;
}

.workspace-mode-tabs button:hover,
.workspace-mode-tabs button.is-active,
.workspace-sheet-toggle.is-active {
  border-color: var(--red-dark);
  color: #fff;
  background: rgba(126, 31, 46, 0.28);
}

.workspace-search {
  display: grid;
  grid-template-columns: minmax(105px, 0.35fr) minmax(160px, 1fr) auto;
  gap: 6px;
}

.workspace-search input,
.workspace-search select {
  min-height: 34px;
  padding: 0 9px;
  font-size: 0.72rem;
}

.workspace-right-rail {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
}

.workspace-right-rail .sheet-section {
  display: flex;
  min-height: 0;
  flex-direction: column;
  margin-top: 0;
  overflow: hidden;
}

.workspace-right-rail .sheet-layout {
  min-height: 0;
  flex: 1;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.workspace-right-rail .sheet-list {
  display: flex;
  max-width: 100%;
  padding: 8px;
  border-right: 0;
  border-bottom: 1px solid var(--line-soft);
  overflow-x: auto;
}

.workspace-right-rail .sheet-list-entry {
  width: min(165px, 45%);
  flex: 0 0 145px;
}

.workspace-right-rail .sheet-viewer {
  min-height: 0;
  overflow: auto;
}

.workspace-right-rail .sheet-viewer-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.workspace-right-rail .sheet-portrait {
  width: 58px;
  height: 58px;
}

.workspace-right-rail .sheet-tab-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.workspace-right-rail .sheet-tab-list button {
  min-width: 0;
  padding-inline: 5px;
  font-size: 0.64rem;
}

.workspace-right-rail .sheet-resource-grid,
.workspace-right-rail .sheet-attribute-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.workspace-right-rail .participants-panel {
  max-height: 235px;
  overflow: auto;
}

.workspace-drawer {
  position: fixed;
  z-index: 24;
  right: clamp(380px, 26vw, 455px);
  bottom: 18px;
  left: clamp(18px, 2.2vw, 34px);
  max-height: min(64vh, 690px);
  overflow: auto;
  border: 1px solid #454545;
  border-radius: 8px;
  background: rgba(4, 4, 4, 0.985);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.78);
}

.room-layout.is-sheet-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.room-layout.is-sheet-collapsed .workspace-drawer {
  right: clamp(18px, 2.2vw, 34px);
}

.master-workspace-panel {
  min-height: 310px;
}

.workspace-panel-actions,
.workspace-result-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.workspace-help {
  margin: 0;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 0.7rem;
}

.workspace-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 9px;
  padding: 12px;
}

.workspace-result-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.024);
  cursor: grab;
  transition: border-color 150ms ease, background-color 150ms ease, opacity 150ms ease;
}

.workspace-result-card:hover {
  border-color: #4d4d4d;
  background: rgba(255, 255, 255, 0.04);
}

.workspace-result-card.is-dragging {
  opacity: 0.42;
}

.workspace-result-card > img {
  width: 54px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 5px;
  object-fit: cover;
}

.workspace-result-copy {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 5px;
}

.workspace-result-copy header {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.workspace-result-copy header small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.62rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-type-badge {
  flex: 0 0 auto;
  padding: 2px 5px;
  border: 1px solid rgba(159, 38, 56, 0.5);
  border-radius: 3px;
  color: #e799a5;
  font-size: 0.56rem;
  font-weight: 800;
  text-transform: uppercase;
}

.workspace-result-copy h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.88rem;
}

.workspace-result-copy > strong {
  color: #cecec9;
  font-size: 0.67rem;
}

.workspace-result-copy > p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.45;
  white-space: pre-wrap;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.workspace-result-actions {
  flex-wrap: wrap;
  margin-top: 5px;
}

.workspace-drop-target {
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.workspace-drop-target.is-drag-over {
  border-color: var(--red-bright);
  background-color: rgba(159, 38, 56, 0.11);
  box-shadow: inset 0 0 0 2px rgba(195, 57, 77, 0.2);
}

@media (min-width: 1100px) {
  body.has-room {
    overflow: hidden;
  }

  body.has-room .room-view {
    display: grid;
    width: 100%;
    height: calc(100dvh - 58px);
    grid-template-rows: auto auto minmax(0, 1fr);
    padding: 10px clamp(14px, 1.6vw, 26px) 14px;
  }

  body.has-room .room-heading {
    min-height: 50px;
    margin-bottom: 8px;
    padding-bottom: 7px;
  }

  body.has-room .room-heading h1 {
    font-size: 1.35rem;
  }

  body.has-room .room-layout {
    height: 100%;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) minmax(335px, 410px);
  }

  body.has-room .room-layout.is-sheet-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  body.has-room .session-stage {
    display: flex;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
  }

  body.has-room .session-stage > .section-bar:first-child {
    display: none;
  }

  body.has-room .stage-content {
    min-height: 48px;
    padding: 8px 14px;
  }

  body.has-room .stage-status {
    gap: 10px;
  }

  body.has-room .stage-status .signal-emblem {
    width: 38px;
    height: 38px;
    font-size: 0.7rem;
    box-shadow: inset 0 0 0 4px #020202;
  }

  body.has-room .tabletop-section {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
  }

  body.has-room .tabletop-section > .section-bar {
    min-height: 44px;
    padding-block: 6px;
  }

  body.has-room .tabletop-layout {
    min-height: 0;
    flex: 1;
  }

  body.has-room .map-list {
    max-height: calc(100dvh - 310px);
  }

  body.has-room .board-panel {
    display: flex;
    min-height: 0;
    flex-direction: column;
  }

  body.has-room .map-viewport {
    height: auto;
    min-height: 300px;
    flex: 1;
  }

  body.has-room .workspace-right-rail {
    height: 100%;
  }
}

@media (max-width: 1099px) {
  .workspace-taskbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .workspace-search {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .workspace-right-rail {
    order: -1;
  }

  .workspace-drawer,
  .room-layout.is-sheet-collapsed .workspace-drawer {
    right: 14px;
    bottom: 14px;
    left: 14px;
    max-height: 72vh;
  }
}

@media (max-width: 640px) {
  .workspace-taskbar {
    position: sticky;
    top: 0;
    z-index: 20;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .workspace-search {
    grid-template-columns: 110px minmax(0, 1fr);
  }

  .workspace-search button {
    grid-column: 1 / -1;
  }

  .workspace-right-rail .sheet-tab-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace-results {
    grid-template-columns: 1fr;
    padding: 8px;
  }

  .workspace-result-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace-result-card > img {
    width: 46px;
    height: 46px;
  }
}

/* Ajustes finais da Fase 10 devem prevalecer sobre o layout da Fase 9. */
.session-metadata,
.session-stage > .section-bar:first-child,
.session-stage > .stage-content {
  display: none !important;
}

.workspace-taskbar {
  grid-template-columns: auto minmax(280px, 1fr) auto auto;
}

.workspace-right-rail {
  grid-template-rows: minmax(0, 1fr);
}

@media (min-width: 1100px) {
  body.has-room .room-view {
    grid-template-rows: auto minmax(0, 1fr);
  }

  body.has-room .room-layout {
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) minmax(335px, 390px);
  }

  body.has-room .tabletop-layout {
    grid-template-columns: minmax(175px, 210px) minmax(0, 1fr);
  }

  body.has-room .map-list {
    max-height: calc(100dvh - 205px);
  }

  body.has-room .map-viewport {
    min-height: 420px;
  }
}

@media (max-width: 1099px) {
  .workspace-taskbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .workspace-search {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .connection-area {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .topbar-room-code {
    width: auto;
  }
}

/* Ajustes de layout da mesa: titulo util, camera responsiva e hubs laterais. */
.tabletop-heading {
  justify-content: flex-start;
}

.tabletop-heading .active-map-name {
  max-width: 100%;
  margin: 0;
  color: var(--text);
  font-family: Georgia, serif;
  font-size: 1.05rem;
  font-weight: 700;
}

.workspace-drawer,
.room-layout.is-sheet-collapsed .workspace-drawer {
  top: 122px;
  right: auto;
  bottom: 14px;
  left: clamp(14px, 1.6vw, 26px);
  width: min(760px, calc(100vw - 455px));
  max-height: none;
  margin: 0;
  border-radius: 0 8px 8px 0;
  animation: workspace-drawer-left-in 170ms ease-out;
}

.room-layout.is-sheet-collapsed .workspace-drawer {
  width: min(860px, calc(100vw - 52px));
}

.workspace-drawer > .workspace-drawer-close {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 10px;
}

.workspace-drawer > .workspace-drawer-close + section:first-of-type > .section-bar {
  padding-right: 58px;
}

@keyframes workspace-drawer-left-in {
  from {
    opacity: 0;
    transform: translateX(-28px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (max-width: 1099px) {
  .workspace-drawer,
  .room-layout.is-sheet-collapsed .workspace-drawer {
    top: 82px;
    right: auto;
    bottom: 14px;
    left: 14px;
    width: min(680px, calc(100vw - 28px));
    max-height: none;
  }
}

@media (max-width: 640px) {
  .workspace-drawer,
  .room-layout.is-sheet-collapsed .workspace-drawer {
    top: 68px;
    left: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
    border-radius: 7px;
  }
}

/* O jogador nao possui biblioteca de mapas: o tabuleiro deve ocupar a unica coluna. */
@media (min-width: 1100px) {
  body.has-room .tabletop-layout.is-player {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Divisorias redimensionaveis da Biblioteca, Mapa e Ficha. */
.panel-resize-handle {
  display: none;
}

@media (min-width: 1100px) {
  body.has-room .room-layout {
    grid-template-columns: minmax(0, 1fr) 10px minmax(280px, var(--sheet-panel-width, 390px));
    gap: 0;
  }

  body.has-room .tabletop-layout {
    grid-template-columns: clamp(150px, var(--map-library-width, 210px), 560px) 10px minmax(0, 1fr);
  }

  body.has-room .panel-resize-handle {
    position: relative;
    z-index: 8;
    display: grid;
    min-width: 10px;
    place-items: center;
    cursor: col-resize;
    touch-action: none;
    outline: 0;
  }

  body.has-room .panel-resize-handle::before {
    position: absolute;
    inset: 0;
    background: transparent;
    content: "";
    transition: background 140ms ease;
  }

  body.has-room .panel-resize-handle > span {
    position: relative;
    width: 2px;
    height: 54px;
    border-radius: 999px;
    background: var(--line);
    box-shadow: 0 -10px 0 -0.5px var(--line), 0 10px 0 -0.5px var(--line);
    transition: width 140ms ease, height 140ms ease, background 140ms ease;
  }

  body.has-room .panel-resize-handle:hover::before,
  body.has-room .panel-resize-handle:focus-visible::before,
  body.has-room .panel-resize-handle.is-active::before {
    background: color-mix(in srgb, var(--red) 13%, transparent);
  }

  body.has-room .panel-resize-handle:hover > span,
  body.has-room .panel-resize-handle:focus-visible > span,
  body.has-room .panel-resize-handle.is-active > span {
    width: 3px;
    height: 76px;
    background: var(--red-bright);
    box-shadow: 0 -11px 0 -0.5px var(--red-bright), 0 11px 0 -0.5px var(--red-bright);
  }

  body.has-room .room-layout.is-sheet-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  body.has-room .room-layout.is-sheet-collapsed .sheet-resize-handle,
  body.has-room .tabletop-layout.is-player .library-resize-handle {
    display: none;
  }

  body.is-resizing-panels,
  body.is-resizing-panels * {
    cursor: col-resize !important;
    user-select: none !important;
  }

  body.is-resizing-panels iframe {
    pointer-events: none;
  }
}
