* { box-sizing: border-box; }
html, body { margin: 0; }
/* Layout: full-bleed tactical canvas; floating instrument panels pinned to the edges like a plotting table. */
:root {
  color-scheme: dark;
  --bg: #0c1014;
  --panel: rgba(20, 26, 31, 0.95);
  --raise: #1d252c;
  --raise-hi: #27323b;
  --line: rgba(214, 228, 220, 0.10);
  --fg: #e4ebe6;
  --muted: #8d9b94;
  --accent: #e9b949;
  --accent-ink: #1b1505;
  --danger: #e5534b;
  --ok: #4cc38a;
  --info: #6aa7f5;
  --f-display: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  --f-body: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  --r: 10px;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}
html, body { height: 100%; overflow: hidden; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--fg); font: 15px/1.4 var(--f-body); }
button, input, select { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#board { position: fixed; inset: 0; display: block; touch-action: none; }

.topbar, .toolbar, .options, .users, .bottombar {
  position: fixed; z-index: 10; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); backdrop-filter: blur(8px);
}

.topbar { top: calc(10px + var(--sat)); left: 10px; right: 10px; min-height: 50px; display: flex; align-items: center; gap: 12px; padding: 6px 12px; flex-wrap: wrap; }
.brand .emblem { display: block; height: 26px; aspect-ratio: 264 / 96; background: var(--fg); -webkit-mask: url("emblem.png") center / contain no-repeat; mask: url("emblem.png") center / contain no-repeat; flex: none; }
.brand { font: 700 20px/1 var(--f-display); letter-spacing: 0.06em; text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
.brand i { width: 14px; height: 14px; border: 2.5px solid var(--accent); border-radius: 50%; display: inline-block; position: relative; }
.brand i::after { content: ""; position: absolute; inset: 3px; background: var(--accent); border-radius: 50%; }
.room { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.lbl { font: 600 11px/1 var(--f-body); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.room code { font: 500 13px/1 var(--f-mono); color: var(--accent); background: var(--raise); padding: 6px 8px; border-radius: 6px; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--raise); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.chip[data-role="owner"] { color: var(--accent); border-color: rgba(233, 185, 73, 0.45); }
.chip[data-role="edit"] { color: var(--ok); border-color: rgba(76, 195, 138, 0.4); }
.chip[data-role="view"] { color: var(--info); border-color: rgba(106, 167, 245, 0.4); }
.status { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.status[data-state="online"] .dot { background: var(--ok); }
.status[data-state="offline"] .dot { background: var(--danger); }
.status[data-state="local"] .dot { background: var(--muted); }

.btn { border: 1px solid var(--line); background: var(--raise); border-radius: 8px; padding: 6px 11px; cursor: pointer; white-space: nowrap; font-weight: 500; }
.btn:hover { background: var(--raise-hi); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--raise); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.danger:hover { border-color: var(--danger); }
.btn.icon { width: 34px; padding: 6px 0; text-align: center; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.zoom { min-width: 60px; font: 500 12px var(--f-mono); font-variant-numeric: tabular-nums; }
#peopleBtn { display: none; }

.toolbar { top: var(--panels-top, calc(72px + var(--sat))); left: 10px; display: flex; flex-direction: column; gap: 3px; padding: 5px; }
.toolbar button { position: relative; width: 42px; height: 42px; border: 0; background: transparent; border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.toolbar button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.toolbar button span { position: absolute; right: 3px; bottom: 1px; font: 500 9px var(--f-mono); color: var(--muted); }
.toolbar button:hover { background: var(--raise); }
.toolbar button.active { background: var(--accent); color: var(--accent-ink); }
.toolbar button.active span { color: var(--accent-ink); opacity: 0.7; }
.toolbar button:disabled { opacity: 0.28; cursor: not-allowed; }

.options { top: var(--panels-top, calc(72px + var(--sat))); left: 70px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 7px 11px; max-width: calc(100% - 320px); }
.og { display: flex; align-items: center; gap: 7px; }
.og .lbl { font-size: 13px; letter-spacing: 0; text-transform: none; font-weight: 400; }
.swatches { display: flex; gap: 5px; flex-wrap: wrap; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.14); cursor: pointer; padding: 0; }
.swatch.active { outline: 2px solid var(--fg); outline-offset: 2px; }
.shapes { display: flex; gap: 3px; }
.shapes button { width: 30px; height: 30px; border: 1px solid var(--line); background: transparent; border-radius: 7px; cursor: pointer; display: grid; place-items: center; }
.shapes button.active { background: var(--raise-hi); border-color: var(--accent); }
.shapes svg { width: 15px; height: 15px; fill: currentColor; }
.field { width: 150px; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 5px 9px; }
.check { display: flex; gap: 5px; align-items: center; color: var(--muted); font-size: 13px; cursor: pointer; white-space: nowrap; }
input[type=range] { accent-color: var(--accent); width: 100px; }

.symbols { flex-wrap: wrap; max-width: 400px; }
.shapes svg.sym { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.shapes svg.sym .f { fill: currentColor; stroke: none; }
.shapes svg.sym .k { fill: currentColor; opacity: .28; stroke: none; }

/* Tamanho em número, zoom e guild */
.stepper { display: inline-flex; align-items: center; gap: 3px; }
.stepper input { width: 50px; text-align: center; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 5px 4px; font: 500 13px var(--f-mono); font-variant-numeric: tabular-nums; }
.stepper .btn { width: 28px; height: 28px; padding: 0; font-size: 17px; line-height: 1; display: grid; place-items: center; }
.zoom-chip { position: fixed; right: 12px; bottom: calc(66px + var(--sab)); z-index: 12; background: var(--raise); border: 1px solid var(--line); color: var(--fg); border-radius: 99px; padding: 6px 12px; font: 500 12px var(--f-mono); cursor: pointer; box-shadow: var(--shadow); }
.zoom-chip:hover { background: var(--raise-hi); }
.brand img { width: 30px; height: 30px; object-fit: contain; border-radius: 6px; }
.brand span { max-width: 22vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guild-edit { display: grid; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.guild-edit label { font-size: 13px; color: var(--muted); }
.guild-edit .field { width: 100%; }
.guild-edit .row2 { display: flex; gap: 6px; flex-wrap: wrap; }

/* Selo de PT e ficha da PT */
.pt-card { position: fixed; left: 12px; bottom: calc(66px + var(--sab)); z-index: 12; width: min(330px, calc(100% - 24px)); max-height: calc(100% - 180px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--r); box-shadow: var(--shadow); padding: 12px 14px; display: grid; gap: 9px; }
.pt-head { display: flex; align-items: center; gap: 8px; }
.pt-head h4 { margin: 0; font: 700 18px/1.15 var(--f-display); letter-spacing: 0.04em; text-transform: uppercase; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pt-tag { font: 700 11px/1 var(--f-display); letter-spacing: 0.08em; text-transform: uppercase; color: #fff; background: #b3261e; padding: 4px 7px; border-radius: 999px; white-space: nowrap; }
.pt-close { border: 0; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.pt-close:hover { background: var(--raise); color: var(--fg); }
.pt-sub { margin: 0; font-size: 13px; color: var(--muted); }
.pt-card h5 { margin: 2px 0 0; font: 700 12px/1 var(--f-display); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.pt-members { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.pt-members li { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; background: var(--raise); }
.pt-members .dot { width: 10px; height: 10px; border-radius: 50%; }
.pt-members .nick { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pt-members .cls { font-size: 12px; color: var(--muted); white-space: nowrap; }
.pt-roles { margin: 0; padding-left: 16px; display: grid; gap: 4px; font-size: 13px; color: var(--fg); }
.pt-roles strong { font-weight: 600; }
@media (max-width: 640px) { .pt-card { bottom: calc(116px + var(--sab)); max-height: 46%; } }
/* Painéis recolhíveis */
.fold { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 7px; border: 1px solid var(--line); background: var(--raise); border-radius: 8px; cursor: pointer; }
.fold:hover { background: var(--raise-hi); }
/* Setinhas para recolher as barras de cima e de baixo */
/* Botão de PTs com planilha ligada: bolinha verde (ou vermelha se a última leitura falhou) */
#importPT.linked::after, #importPTEnemy.linked::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 7px; border-radius: 50%; background: var(--ok, #3fb950); vertical-align: middle; }
#importPT.sheet-err::after, #importPTEnemy.sheet-err::after { background: var(--danger, #ff3b30); }
.bar-fold { display: grid; place-items: center; width: 30px; height: 30px; flex: none; padding: 0; border: 1px solid var(--line); background: var(--raise); color: var(--muted); border-radius: 8px; cursor: pointer; }
.bar-fold:hover { background: var(--raise-hi); color: var(--fg); }
.bar-fold svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.topbar.collapsed { right: auto; min-height: 0; padding: 5px 6px 5px 10px; }
.topbar.collapsed > :not(.brand):not(.bar-fold) { display: none !important; }
.topbar.collapsed #brandName { display: none; }
.topbar.collapsed .bar-fold svg, .bottombar.collapsed .bar-fold svg { transform: rotate(180deg); }
.bottombar.collapsed > :not(.bar-fold) { display: none !important; }
.bottombar.collapsed { left: 50%; right: auto; transform: translateX(-50%); }
@media (prefers-reduced-motion: reduce) { .bar-fold svg { transition: none; } }
.fold svg, .fold-head svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.fold .cur { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.25); display: none; }
.options.collapsed { gap: 0; padding: 5px; }
.options.collapsed > .og { display: none !important; }
.options.collapsed .fold .cur { display: block; }
.options.collapsed .fold svg { transform: rotate(180deg); }
.fold-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; }
.fold-head svg { margin-left: auto; color: var(--muted); }
.fold-head:hover svg { color: var(--fg); }
.users.collapsed { width: auto; min-width: 0; gap: 0; padding: 8px 10px; }
.users.collapsed .fold-head { width: auto; gap: 6px; }
.users.collapsed .fold-head svg { margin-left: 2px; }
.users.collapsed > :not(h3) { display: none !important; }
.users.collapsed .fold-head svg { transform: rotate(-90deg); }
@media (prefers-reduced-motion: reduce) { .fold svg, .fold-head svg { transition: none; } }

.users { top: var(--panels-top, calc(72px + var(--sat))); right: 10px; width: 250px; padding: 12px; max-height: calc(100% - 170px); overflow: auto; display: grid; gap: 10px; align-content: start; }
.users h3 { margin: 0; font: 700 13px/1 var(--f-display); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.badge { background: var(--raise); color: var(--fg); padding: 2px 7px; border-radius: 99px; font: 500 11px var(--f-mono); }
.users ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.users li { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 7px; min-width: 0; }
.users li.me { cursor: pointer; }
.users li.me:hover { background: var(--raise); }
.users li.off .n { color: var(--muted); }
.users .c { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.users li.off .c { background: transparent !important; border: 1.5px solid var(--muted); }
.users .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.users .role { font-size: 12px; color: var(--muted); white-space: nowrap; }
.users select { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; font-size: 12px; padding: 3px 4px; }
.manage { display: grid; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.manage label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.users .note { margin: 0; font-size: 12px; color: var(--muted); }

.bottombar { bottom: calc(10px + var(--sab)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 5px; padding: 5px; max-width: calc(100% - 20px); overflow-x: auto; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 3px; flex: none; }

.empty { position: fixed; inset: 0; display: grid; place-items: center; z-index: 5; pointer-events: none; padding: 16px; }
.empty-card { pointer-events: auto; display: grid; justify-items: center; gap: 8px; text-align: center; padding: 24px 26px; background: var(--panel); border: 1px dashed rgba(233, 185, 73, 0.4); border-radius: 14px; max-width: 360px; color: var(--muted); }
.empty-card strong { font: 700 20px/1.1 var(--f-display); letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg); }

.drop { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; background: rgba(12, 16, 20, 0.8); border: 3px dashed var(--accent); font: 700 22px var(--f-display); letter-spacing: 0.05em; text-transform: uppercase; pointer-events: none; }
.drop.show { display: grid; }
.toast { position: fixed; left: 50%; bottom: calc(122px + var(--sab)); transform: translate(-50%, 8px); z-index: 60; background: var(--raise); border: 1px solid var(--line); padding: 9px 14px; border-radius: 9px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.banner { position: fixed; bottom: calc(66px + var(--sab)); left: 50%; transform: translateX(-50%); z-index: 11; background: var(--raise); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; font-size: 13px; color: var(--fg); width: max-content; max-width: min(620px, calc(100% - 32px)); text-align: center; }
.banner[data-kind="warn"] { border-color: rgba(229, 83, 75, 0.5); }

.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(6, 8, 10, 0.6); padding: 16px; }
.modal form { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: grid; gap: 12px; box-shadow: var(--shadow); }
.modal h4 { margin: 0; font: 700 18px/1.2 var(--f-display); letter-spacing: 0.04em; text-transform: uppercase; }
.modal p { margin: 0; color: var(--muted); }
.modal input { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
.modal .row { display: flex; justify-content: flex-end; gap: 8px; }

.modal.light { background: rgba(6, 8, 10, 0.18); place-items: start center; padding-top: calc(74px + var(--sat)); }
.modal.light form { border-color: rgba(255, 59, 48, 0.55); }
.modal.light #modalOk { background: var(--danger); color: #fff; }
@media (max-width: 900px) {
  .users { display: none; }
  .users.open { display: grid; }
  #peopleBtn { display: inline-block; }
  .options { max-width: calc(100% - 82px); }
}
@media (max-width: 640px) {
  .topbar { left: 8px; right: 8px; gap: 8px; }
  #brandName, #newRoom, .status .label { display: none; }
  .brand .emblem { height: 20px; }
  .toolbar { top: auto; bottom: calc(62px + var(--sab)); left: 8px; right: 8px; flex-direction: row; justify-content: space-between; overflow-x: auto; }
  .toolbar button { width: 38px; height: 38px; flex: none; }
  .options { left: 8px; right: 8px; max-width: none; top: var(--panels-top, calc(112px + var(--sat))); }
  .users.open { left: 8px; right: 8px; width: auto; top: var(--panels-top, calc(112px + var(--sat))); }
  .bottombar { left: 8px; right: 8px; transform: none; }
  .banner { bottom: calc(116px + var(--sab)); }
  .toast { bottom: calc(176px + var(--sab)); }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* Sem acesso: cobre tudo; nada da sala aparece */
.blocked-screen { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: var(--bg); padding: 24px; text-align: center; }
.blocked-screen > div { display: grid; justify-items: center; gap: 10px; max-width: 420px; }
.blocked-screen .emblem { display: block; height: 40px; aspect-ratio: 264 / 96; background: var(--muted); -webkit-mask: url("emblem.png") center / contain no-repeat; mask: url("emblem.png") center / contain no-repeat; }
.blocked-screen h2 { margin: 6px 0 0; font: 700 22px/1.2 var(--f-display); letter-spacing: 0.04em; text-transform: uppercase; }
.blocked-screen p { margin: 0; color: var(--muted); }
body.blocked #board, body.blocked .topbar, body.blocked .toolbar, body.blocked .options, body.blocked .users, body.blocked .bottombar, body.blocked #ptCard, body.blocked #empty { visibility: hidden; }
