/* public/style.css */

/* Anything marked "hidden" stays hidden, even if a rule below sets display */
[hidden] { display: none !important; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1e1e1e;
  font-family: system-ui, sans-serif;
  color: #eee;
}
/* The map area: the whole window except the chat column on the right */
:root { --chat-width: 330px; }
#board { position: fixed; top: 0; left: 0; bottom: 0; right: var(--chat-width); }

/* Top-left dock: panel + GM tool bar + tool options, side by side */
#left-dock {
  position: fixed;
  top: 10px;
  left: 10px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  z-index: 5;
  pointer-events: none;            /* the gaps between the boxes let clicks through to the map */
}
#left-dock > * { pointer-events: auto; }
#panel {
  position: relative;
  width: 230px;
  padding: 10px 12px;
  background: rgba(20, 20, 20, 0.85);
  border: 1px solid #444;
  border-radius: 8px;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#panel button {
  padding: 6px 10px;
  margin-right: 4px;
  background: #3a3a3a;
  color: #eee;
  border: 1px solid #666;
  border-radius: 5px;
  cursor: pointer;
}
#panel button:hover { background: #505050; }
#panel input[type=range] { width: 100%; }
#status.online { color: #6fdc6f; }
#status.offline { color: #ff7070; }
#role { font-weight: bold; }
.hint { font-size: 12px; color: #aaa; }

#join-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
}
#join-overlay.hidden { display: none; }
#btn-join {
  font-size: 22px;
  padding: 16px 32px;
  border-radius: 10px;
  border: none;
  background: #b8862b;
  color: #fff;
  cursor: pointer;
}

/* ---------- Login page ---------- */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background: #2a2420;
}
.login-box {
  width: 320px;
  padding: 24px 28px;
  background: #1b1b1b;
  border: 1px solid #555;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-box h1 { margin: 0 0 4px; font-size: 24px; text-align: center; color: #e2b75c; }
.login-box label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.login-box input {
  padding: 8px;
  font-size: 15px;
  background: #2b2b2b;
  color: #eee;
  border: 1px solid #666;
  border-radius: 5px;
}
.login-box button {
  padding: 10px;
  font-size: 16px;
  background: #b8862b;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.login-box button:disabled { opacity: 0.6; cursor: default; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-box small { color: #888; font-size: 11px; }
.form-error { color: #ff7a7a; min-height: 18px; font-size: 14px; }
.form-note { color: #e2b75c; font-size: 13px; line-height: 1.4; }
.login-box button.secondary { background: transparent; border: 1px solid #b8862b; color: #e2b75c; font-size: 14px; }
.login-box button.secondary:hover { background: #2a2216; }
.login-divider { display: flex; align-items: center; gap: 8px; color: #777; font-size: 12px; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; border-top: 1px solid #444; }

/* ---------- Table page additions ---------- */
#user-row { display: flex; justify-content: space-between; align-items: center; }
#panel button.small { padding: 2px 8px; font-size: 12px; }

/* ---------- Character sheet (right side) ---------- */
#sheet {
  position: fixed;
  top: 50px;
  right: calc(var(--chat-width) + 16px);   /* default: just left of the chat */
  width: 360px;
  max-width: calc(100vw - 20px);
  max-height: calc(100vh - 70px);
  box-sizing: border-box;
  padding: 0 14px 16px;
  overflow-y: auto;
  background: #1b1918;
  border: 2px solid #6b5636;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
  font-size: 13px;
  z-index: 20;
  animation: sheet-in 0.15s ease-out;
}
@keyframes sheet-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Title bar: drag the sheet window by it */
.sheet-titlebar {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 -14px 8px; padding: 6px 8px 6px 14px;
  background: #2a2216; border-bottom: 1px solid #6b5636;
  cursor: move; user-select: none;
}
.sheet-title { color: #c9b38a; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.sheet-name {
  width: 100%;
  margin-bottom: 2px;
  font-size: 20px !important;
  font-weight: bold;
  color: #e2b75c !important;
  background: transparent !important;
  border: 1px solid transparent !important;
  border-radius: 4px;
  padding: 4px;
}
.sheet-name:hover, .sheet-name:focus { border-color: #666 !important; background: #262422 !important; }
.sheet-close {
  background: #3a3a3a; color: #eee; border: 1px solid #666; border-radius: 5px;
  width: 26px; height: 26px; cursor: pointer; font-size: 13px;
}
.sheet-close:hover { background: #5a3030; }

.sheet-gm {
  display: flex; gap: 10px; padding: 8px; margin-bottom: 4px;
  background: #2a2216; border: 1px dashed #6b5636; border-radius: 6px;
}
.sheet-gm label { flex: 1; display: flex; flex-direction: column; gap: 3px; color: #c9b38a; }

#sheet h3 {
  margin: 14px 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #c9b38a;
  border-bottom: 1px solid #4a3d29;
  padding-bottom: 3px;
}
.sheet-grid { display: grid; gap: 8px; }
.sheet-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sheet-field.wide { grid-column: 1 / -1; }
.sheet-label { color: #aaa; font-size: 11px; }
.sheet-input-row { display: flex; align-items: center; gap: 4px; }
.sheet-input-row input { flex: 1; min-width: 0; }
.sheet-note { color: #e2b75c; font-weight: bold; min-width: 26px; text-align: right; }
.sheet-derived { color: #e2b75c; font-weight: bold; font-size: 15px; padding: 4px 0; }
.sheet-footer { margin-top: 16px; color: #666; font-size: 11px; text-align: center; }

#sheet input, #sheet textarea, #sheet select {
  background: #2b2b2b; color: #eee; border: 1px solid #555; border-radius: 4px;
  padding: 5px; font: inherit; box-sizing: border-box; width: 100%;
}
#sheet textarea { min-height: 70px; resize: vertical; }
#sheet input:focus, #sheet textarea:focus, #sheet select:focus { outline: none; border-color: #b8862b; }

/* ---------- Left panel tabs ---------- */
/* ends above the hotbar, so the two never overlap */
#panel { max-height: calc(100vh - 104px); overflow-y: auto; box-sizing: border-box; }
#panel.wide { width: 290px; }
.tab { display: flex; flex-direction: column; gap: 8px; }
#tab-bar { display: flex; gap: 2px; border-bottom: 1px solid #555; }
#tab-bar button {
  flex: 1;
  margin: 0;
  border-radius: 6px 6px 0 0;
  border-bottom: none;
  background: #2a2a2a;
  color: #aaa;
}
#tab-bar button.active { background: #4a3d29; color: #fff; }
#panel h4 { margin: 6px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: #c9b38a; }
#panel input:not([type=range]):not([type=checkbox]):not([type=color]), #panel select {
  background: #2b2b2b; color: #eee; border: 1px solid #555; border-radius: 4px; padding: 5px;
  font: inherit; box-sizing: border-box; max-width: 100%;
}
#panel input[type=file] { font-size: 12px; padding: 3px; }
#panel input[type=number] { width: 70px; }
#panel label.inline { display: flex; flex-direction: row; align-items: center; gap: 6px; font-size: 13px; }
#panel button.danger { background: #7a2b2b; border-color: #b04040; }
#panel button:disabled { opacity: 0.5; cursor: default; }

.gm-form { display: flex; flex-direction: column; gap: 6px; padding: 8px; background: #222; border-radius: 6px; }
.gm-msg { font-size: 12px; color: #e2b75c; min-height: 0; }
.gm-list { display: flex; flex-direction: column; gap: 8px; }
.gm-card { display: flex; flex-direction: column; gap: 6px; padding: 8px; background: #262626; border: 1px solid #3a3a3a; border-radius: 6px; }
.gm-card.active { border-color: #b8862b; }
.gm-card-body { display: flex; flex-direction: column; gap: 6px; }
.gm-name { width: 100%; font-weight: bold; }
.gm-thumb { height: 70px; border-radius: 4px; background: #111 center / cover no-repeat; }
.gm-buttons { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.gm-buttons button { margin: 0 !important; }
.gm-badge { color: #e2b75c; font-size: 12px; font-weight: bold; }

.gm-actor-head { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.gm-token-preview {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  border: 2px solid #fff; background: center / cover no-repeat;
}
.gm-actor-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.gm-actor-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-actor-text small { color: #999; font-size: 11px; }
.gm-arrow { color: #888; font-size: 10px; }
.gm-editor { display: flex; flex-direction: column; gap: 6px; padding-top: 6px; border-top: 1px dashed #444; }
.gm-editor label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }

/* ---------- GM: sign-up settings in the Table tab ---------- */
#gm-signup { display: flex; flex-direction: column; gap: 6px; padding: 8px; background: #222; border-radius: 6px; }
#gm-signup .row { display: flex; gap: 4px; }
#gm-signup input { flex: 1; min-width: 0; }
#signup-status { font-size: 12px; }
#signup-status.open { color: #6fdc6f; }
#signup-status.closed { color: #aaa; }

/* Short messages at the bottom of the screen (e.g. "New player registered") */
#notice {
  /* sits above the hotbar and the target tag, centred on the map area */
  position: fixed; bottom: 128px; left: calc((100vw - var(--chat-width)) / 2); transform: translateX(-50%);
  z-index: 7; max-width: 60vw; text-align: center;
  background: #2a2216; border: 1px solid #b8862b; color: #e2b75c;
  padding: 10px 18px; border-radius: 8px; font-size: 14px;
}

/* ---------- Chat (always on the right) ---------- */
#chat {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: var(--chat-width);
  display: flex; flex-direction: column;
  background: #181716;
  border-left: 2px solid #6b5636;
  box-sizing: border-box;
  z-index: 10;
}
#chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid #3a3226;
  color: #e2b75c; font-size: 15px;
}
#chat button { background: #3a3a3a; color: #eee; border: 1px solid #666; border-radius: 5px; cursor: pointer; padding: 4px 8px; }
#chat button:hover { background: #505050; }
#chat-log { flex: 1; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.chat-msg { background: #232120; border: 1px solid #333; border-radius: 6px; padding: 6px 8px; font-size: 13px; }
.chat-msg.mine { border-color: #4a4030; }
.chat-msg.error { background: #3a1e1e; border-color: #7a3030; color: #ffb0b0; }
.chat-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 3px; }
.chat-head b { color: #ddd; }
.chat-head b.chat-gm { color: #e2b75c; }
.chat-time { color: #777; font-size: 11px; }
.chat-text { white-space: pre-wrap; word-wrap: break-word; color: #eee; }
.chat-label { color: #c9b38a; font-weight: bold; margin-bottom: 2px; }
.roll-line { display: flex; justify-content: space-between; align-items: center; }
.roll-formula { color: #aaa; font-family: Consolas, monospace; }
.roll-total {
  font-size: 22px; font-weight: bold; color: #fff;
  background: #3b2f1c; border: 1px solid #b8862b; border-radius: 6px;
  min-width: 40px; text-align: center; padding: 0 8px;
}
.roll-details { color: #999; font-size: 12px; margin-top: 3px; }
.roll-details .die { color: #ddd; }
.roll-details .die.max { color: #6fdc6f; font-weight: bold; }
.roll-details .die.min { color: #ff7070; font-weight: bold; }
.roll-details .die.dropped { text-decoration: line-through; opacity: 0.5; }
.chat-tips { color: #999; font-size: 12px; line-height: 1.6; padding: 8px; border: 1px dashed #444; border-radius: 6px; }
.chat-tips b { color: #c9b38a; }
#chat-dice { display: flex; gap: 3px; padding: 6px 10px 0; flex-wrap: wrap; }
#chat-dice button { flex: 1; padding: 4px 0; font-size: 12px; }
#chat-form { display: flex; gap: 6px; padding: 8px 10px 10px; }
#chat-input {
  flex: 1; resize: none; font: inherit; font-size: 13px;
  background: #2b2b2b; color: #eee; border: 1px solid #555; border-radius: 5px; padding: 6px;
}
#chat-input:focus { outline: none; border-color: #b8862b; }
#chat-send { align-self: stretch; }

/* Checkbox fields on the sheet (saving throws, skills) */
.sheet-field.check { flex-direction: row; align-items: center; gap: 6px; }
.sheet-field.check input { width: auto !important; margin: 0; accent-color: #b8862b; }
.sheet-check-label { flex: 1; color: #ddd; font-size: 12px; }
#sheet .sheet-grid:has(.check) { gap: 3px 12px; }

/* ---------- Settings panel (under the chat header) ---------- */
#chat { position: fixed; }
#settings-panel {
  position: absolute; top: 46px; right: 8px; left: 8px; z-index: 30;
  background: #1f1d1b; border: 1px solid #6b5636; border-radius: 8px;
  padding: 10px 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  display: flex; flex-direction: column; gap: 8px; font-size: 13px;
}
.settings-head { display: flex; justify-content: space-between; align-items: center; color: #e2b75c; font-size: 15px; }
#settings-panel h4 { margin: 6px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: #c9b38a; }
.settings-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.key-btn { min-width: 56px; font-weight: bold; }
#chat .key-btn.clash { border-color: #c0392b; color: #ff9b9b; }
.settings-warn { color: #ff9b9b; font-size: 12px; }
.settings-check { display: flex; gap: 6px; align-items: flex-start; line-height: 1.4; }
#settings-panel button { align-self: flex-start; }
#chat-header span { display: flex; gap: 6px; }

/* ---------- Character builder overlay ---------- */
#builder { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.6); }

/* Builder button in the Tokens tab */
#panel button.builder-btn { background: #4a3d29; border-color: #b8862b; color: #ffe2a8; font-weight: bold; }
#panel button.builder-btn:hover { background: #5c4b31; }

/* ---------- GM tool bar ---------- */
#gm-toolbar {
  display: flex; flex-direction: column; gap: 4px; padding: 6px;
  background: rgba(20, 20, 20, 0.9); border: 1px solid #444; border-radius: 8px;
}
#gm-toolbar[hidden] { display: none !important; }
#gm-toolbar .tool {
  width: 38px; height: 38px; font-size: 20px; line-height: 1;
  background: #2b2b2b; color: #ddd; border: 1px solid #555; border-radius: 6px; cursor: pointer;
}
#gm-toolbar .tool:hover { background: #3c3c3c; }
#gm-toolbar .tool.active { background: #4a3d29; border-color: #e2b75c; color: #ffe2a8; }
#tool-options {
  width: 220px; padding: 10px 12px; font-size: 13px;
  background: rgba(20, 20, 20, 0.92); border: 1px solid #6b5636; border-radius: 8px;
  display: flex; flex-direction: column; gap: 8px; color: #eee;
}
#tool-options h4 { margin: 0; color: #e2b75c; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
#tool-options .row { display: flex; gap: 4px; flex-wrap: wrap; }
#tool-options button {
  background: #3a3a3a; color: #eee; border: 1px solid #666; border-radius: 5px; padding: 4px 8px; cursor: pointer; font: inherit;
}
#tool-options button.on { background: #4a3d29; border-color: #e2b75c; color: #ffe2a8; }
#tool-options button.danger { background: #7a2b2b; border-color: #b04040; }
#tool-options label { display: flex; gap: 6px; align-items: center; }
#tool-options .hint { color: #999; font-size: 11px; line-height: 1.4; }

/* ---------- Sheet: header, tabs, rolls, lists, actions ---------- */
.sheet-header { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.sheet-portrait {
  width: 64px; height: 64px; flex: none; border-radius: 50%;
  border: 3px solid #b8862b; background: #555 center / cover no-repeat;
}
.sheet-head-text { flex: 1; min-width: 0; }
.sheet-subtitle { display: block; color: #c9b38a; font-size: 12px; padding-left: 5px; }
.sheet-rollmodes { display: flex; align-items: center; gap: 4px; margin: 4px 0 8px; font-size: 12px; color: #999; }
.sheet-rollmodes button, .sheet-tabs button {
  background: #2b2b2b; color: #ccc; border: 1px solid #555; border-radius: 4px;
  padding: 3px 8px; cursor: pointer; font: inherit; font-size: 12px;
}
.sheet-rollmodes button.on { background: #6b2a2a; border-color: #c0392b; color: #fff; }
.sheet-tabs {
  display: flex; flex-wrap: wrap; gap: 3px; margin: 8px 0 2px;
  position: sticky; top: 38px; z-index: 1; background: #1b1918; padding: 4px 0;
  border-bottom: 1px solid #6b5636;
}
.sheet-tabs button.on { background: #4a3d29; border-color: #e2b75c; color: #ffe2a8; font-weight: bold; }
.sheet-roll {
  flex: none; background: #2b2b2b; border: 1px solid #555; border-radius: 4px;
  cursor: pointer; padding: 0 4px; font-size: 13px; line-height: 20px; color: #eee;
}
.sheet-roll:hover { background: #4a3d29; border-color: #b8862b; }
.sheet-roll.small { font-size: 11px; padding: 0 5px; }
.sheet-field.check .sheet-roll { margin-left: 2px; }
.sheet-prof {
  width: 20px; height: 20px; flex: none; padding: 0; line-height: 18px; text-align: center;
  background: transparent; border: none; color: #777; cursor: pointer; font-size: 15px;
}
.sheet-prof.on { color: #e2b75c; }
.sheet-field.type-select select { width: 100%; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
#sheet .sheet-amount { width: 70px !important; }
.sheet-action {
  background: #3a3a3a; color: #eee; border: 1px solid #666; border-radius: 5px;
  padding: 4px 9px; cursor: pointer; font: inherit; font-size: 12px;
}
.sheet-action:hover:not(:disabled) { background: #505050; }
.sheet-action.damage { background: #6b2a2a; border-color: #c0392b; }
.sheet-action.heal { background: #24572c; border-color: #3fa152; }
.sheet-action:disabled { opacity: 0.5; }
.sheet-list-table { display: flex; flex-direction: column; gap: 3px; }
.sheet-list-row { display: grid; gap: 4px; align-items: center; }
.sheet-list-row.head span { font-size: 10px; color: #999; text-transform: uppercase; }
#sheet .sheet-list-row input, #sheet .sheet-list-row select { padding: 3px 4px; font-size: 12px; min-width: 0; }
#sheet .sheet-list-row input[type=checkbox] { width: auto; justify-self: center; accent-color: #b8862b; }
.sheet-row-tools { display: flex; gap: 2px; }
.sheet-row-del { background: transparent; border: none; color: #888; cursor: pointer; padding: 0 3px; }
.sheet-row-del:hover { color: #ff7070; }
.sheet-list-add {
  margin-top: 4px; background: transparent; border: 1px dashed #6b5636; color: #e2b75c;
  border-radius: 4px; padding: 3px 8px; cursor: pointer; font: inherit; font-size: 12px;
}
.sheet-list-empty { color: #777; font-size: 12px; margin-top: 2px; }
.sheet-titlebar { top: 0; }

/* ---------- Hotbar (bottom of the map) ---------- */
#hotbar {
  position: fixed; bottom: 10px;
  left: calc((100vw - var(--chat-width)) / 2); transform: translateX(-50%);
  display: flex; gap: 5px; padding: 5px;
  background: rgba(20, 20, 20, 0.88); border: 1px solid #6b5636; border-radius: 8px;
  z-index: 6;
}
.hotbar-slot {
  position: relative; width: 60px; height: 60px; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: #222; border: 1px dashed #4a4136; border-radius: 6px; cursor: default;
  color: #ddd; font-size: 11px; text-align: center; user-select: none;
}
.hotbar-slot.filled { border-style: solid; border-color: #6b5636; cursor: pointer; background: #2a2620; }
.hotbar-slot.filled:hover { background: #3a3226; border-color: #b8862b; }
.hotbar-slot.drop { border-color: #e2b75c; background: #3a3226; }
.hotbar-slot.fired { background: #6b5a2a; }
.hotbar-slot.broken { background: #6b2a2a; }
.hotbar-key { position: absolute; top: 2px; left: 4px; font-size: 10px; color: #e2b75c; font-weight: bold; }
.hotbar-pic { width: 20px; height: 20px; border-radius: 50%; background: center / cover no-repeat; border: 1px solid #fff; }
.hotbar-label { max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.2; }
.hotbar-clear {
  position: absolute; top: 0; right: 1px; display: none;
  background: transparent; border: none; color: #aaa; cursor: pointer; font-size: 11px; padding: 1px 3px;
}
.hotbar-slot.filled:hover .hotbar-clear { display: block; }
.hotbar-clear:hover { color: #ff7070; }
.sheet-roll[draggable=true] { cursor: grab; }
#settings-panel { max-height: calc(100vh - 80px); overflow-y: auto; }

/* ---- list extras: calculated cells, second line, "add from list" ---- */
.sheet-list-derived { font-size: 12px; font-weight: bold; color: #e2b75c; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-list-extra { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 8px; padding: 0 0 6px 8px; border-bottom: 1px solid #333; margin-bottom: 2px; }
.sheet-list-extra-field { display: flex; align-items: center; gap: 4px; font-size: 10px; color: #999; text-transform: uppercase; white-space: nowrap; }
#sheet .sheet-list-extra-field input { width: 78px; padding: 2px 4px; font-size: 12px; }
.sheet-list-extra-field.wide { flex: 1; min-width: 200px; }
#sheet .sheet-list-extra-field.wide input { flex: 1; width: auto; min-width: 0; }
.sheet-row-tools { display: flex; justify-content: flex-end; gap: 2px; }
.sheet-list-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#sheet select.sheet-list-preset { width: auto; padding: 4px 6px; font-size: 12px; margin-top: 4px; }

/* ---- Combat / initiative tracker (combat.js) ---- */
#gm-toolbar .tool-sep { height: 1px; background: #444; margin: 4px 2px; }
#combat {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  margin-left: calc(var(--chat-width) / -2);   /* centred on the map area (the chat is on the right) */
  width: 300px; max-height: calc(100vh - 140px); overflow-y: auto;
  background: rgba(27, 25, 24, 0.96); border: 1px solid #6b5530; border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5); color: #ddd; font-size: 13px; z-index: 7; padding: 8px;
}
#combat[hidden] { display: none !important; }
.combat-head { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.combat-title { flex: 1; font-weight: bold; color: #e2b75c; letter-spacing: 0.5px; }
#combat button { background: #2e2b28; color: #ddd; border: 1px solid #555; border-radius: 4px; padding: 3px 8px; cursor: pointer; font: inherit; font-size: 12px; }
#combat button:hover:not(:disabled) { background: #3c3833; }
#combat button:disabled { opacity: 0.55; cursor: default; }
#combat .combat-mini { padding: 1px 6px; }
#combat .combat-big { width: 100%; padding: 6px; margin-top: 6px; background: #4a3d29; border-color: #e2b75c; color: #ffe2a8; font-weight: bold; }
.combat-hint { color: #999; font-size: 12px; margin: 4px 0; }
.combat-list { display: flex; flex-direction: column; gap: 3px; }
.combat-row { display: flex; align-items: center; gap: 6px; padding: 3px 5px; border-radius: 5px; border: 1px solid transparent; }
.combat-row.current { background: #3a3122; border-color: #e2b75c; }
.combat-row.hidden-turn { color: #999; font-style: italic; }
.combat-dot { width: 22px; height: 22px; border-radius: 50%; flex: none; background-size: cover; background-position: center; border: 1px solid #222; }
.combat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.combat-name:hover { text-decoration: underline; }
.combat-init { width: 46px; padding: 2px 4px; background: #111; color: #eee; border: 1px solid #555; border-radius: 4px; }
.combat-init-text { width: 30px; text-align: right; font-weight: bold; color: #e2b75c; }
#combat .combat-pip { border-color: #4f7d4f; color: #b9e6b9; }
#combat .combat-pip.used { border-color: #555; color: #888; background: #222; text-decoration: line-through; }
#combat .combat-pip.small { padding: 1px 5px; font-size: 11px; }
.combat-turn { margin-top: 8px; padding-top: 8px; border-top: 1px solid #444; }
.combat-turn-name { font-weight: bold; color: #ffe2a8; }
.combat-move { color: #ccc; margin: 3px 0 6px; }
.combat-pips { display: flex; flex-wrap: wrap; gap: 4px; }
.combat-gm { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; padding-top: 8px; border-top: 1px solid #444; }
#combat .combat-next { flex: 1; background: #4a3d29; border-color: #e2b75c; color: #ffe2a8; }
#combat .combat-end.armed { background: #6b2a2a; border-color: #c0392b; }

/* ---- Level up (sheet button + levelup.js window) ---- */
.sheet-levelup { align-self: center; background: #2e2b28; color: #ccc; border: 1px solid #555; border-radius: 6px; padding: 6px 10px; cursor: pointer; font: inherit; font-size: 13px; white-space: nowrap; }
.sheet-levelup.ready { background: #4a3d29; border-color: #e2b75c; color: #ffe2a8; font-weight: bold; animation: lvl-glow 1.6s ease-in-out infinite; }
@keyframes lvl-glow { 50% { box-shadow: 0 0 12px rgba(226, 183, 92, 0.7); } }
.sheet-gm .sheet-mini { padding: 1px 6px; margin: 0 3px; }
.sheet-lvcount { color: #ffe2a8; }
#levelup { position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, 0.6); display: flex; align-items: center; justify-content: center; }
#levelup[hidden] { display: none !important; }
.lvl-box { width: 560px; max-width: calc(100vw - 40px); max-height: calc(100vh - 60px); overflow-y: auto; background: #1f1c1a; color: #ddd;
  border: 1px solid #6b5530; border-radius: 10px; padding: 16px 20px; font-size: 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6); }
.lvl-box h2 { margin: 0 0 8px; color: #e2b75c; font-size: 19px; }
.lvl-box h3 { margin: 14px 0 6px; color: #e2b75c; font-size: 14px; text-transform: uppercase; letter-spacing: 0.5px; }
.lvl-lines { margin: 0; padding-left: 18px; color: #ccc; }
.lvl-feature { border: 1px solid #3a3530; border-radius: 6px; padding: 5px 8px; margin-bottom: 4px; background: #262220; }
.lvl-feature summary { cursor: pointer; font-weight: bold; }
.lvl-text { white-space: pre-wrap; color: #bbb; font-size: 13px; margin-top: 6px; }
.lvl-choice { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.lvl-choice[hidden] { display: none; }
.lvl-choice span { font-size: 12px; color: #999; }
.lvl-choice select { padding: 5px; background: #111; color: #eee; border: 1px solid #555; border-radius: 4px; font: inherit; }
.lvl-error { color: #e57373; min-height: 1em; }
.lvl-bar { display: flex; justify-content: flex-end; gap: 8px; }
.lvl-btn { background: #2e2b28; color: #ddd; border: 1px solid #555; border-radius: 5px; padding: 6px 14px; cursor: pointer; font: inherit; }
.lvl-btn.main { background: #4a3d29; border-color: #e2b75c; color: #ffe2a8; font-weight: bold; }

/* ---- Clickable roll boxes (instead of dice buttons) ---- */
.sheet-field.check.sheet-rollable {
  padding: 5px 8px; border: 1px solid #3d3631; border-radius: 6px; background: #221f1d;
}
.sheet-rollable { cursor: pointer; user-select: none; transition: background 0.12s, border-color 0.12s; }
.sheet-field.check.sheet-rollable:hover { background: #2f2820; border-color: #b8862b; }
.sheet-field.check.sheet-rollable:active { background: #3d3122; }
.sheet-field.check.sheet-rollable .sheet-check-label { cursor: pointer; }
.sheet-roll-chip {
  display: inline-block; min-width: 34px; text-align: center; padding: 3px 8px;
  border: 1px solid #6b5530; border-radius: 6px; background: #2a2520; color: #e2b75c; font-weight: bold;
}
.sheet-roll-chip:hover { background: #4a3d29; border-color: #e2b75c; }
.sheet-derived.sheet-roll-chip { font-size: 15px; padding: 2px 10px; }
#sheet .sheet-grid:has(.check) { gap: 5px 10px; }

/* ---- Locked sheets ---- */
.sheet-locked { margin: 0 0 8px; padding: 6px 10px; border: 1px solid #6b5530; border-radius: 6px; background: #2a2318; color: #e2c98f; font-size: 12px; }
#sheet input:disabled, #sheet select:disabled, #sheet textarea:disabled { opacity: 0.75; cursor: not-allowed; background: #1a1817; }
#sheet .sheet-prof:disabled { cursor: not-allowed; opacity: 0.8; }
.sheet-lock-toggle { display: flex; align-items: center; gap: 4px; color: #e2c98f; cursor: pointer; }

/* ---- Attack messages in chat ---- */
.chat-msg.attack.hit { border-left: 3px solid #4f9d4f; }
.chat-msg.attack.miss { border-left: 3px solid #777; }
.attack-verdict { font-weight: bold; font-size: 12px; margin-left: auto; margin-right: 8px; letter-spacing: 0.5px; }
.attack-verdict.hit { color: #7fd17f; }
.attack-verdict.miss { color: #999; }
.roll-line.damage { margin-top: 6px; }
.roll-total.dmg { border-color: #c0392b; color: #ff9c8f; }
.attack-note { color: #aaa; font-size: 11px; margin-top: 2px; }
.attack-down { color: #ff7b6b; font-weight: bold; margin-top: 4px; }
.attack-gm { color: #8fb3d9; font-size: 11px; margin-top: 4px; border-top: 1px dashed #444; padding-top: 3px; }
/* placeholders = example text: faint and italic, so they don't look like real values */
#sheet input::placeholder, #sheet textarea::placeholder { color: #6a645c; font-style: italic; opacity: 1; }
/* GM row: level-up point buttons small */
.sheet-gm label:has(.sheet-mini) { display: flex; flex-direction: row; align-items: center; gap: 4px; flex-wrap: wrap; }
.sheet-gm .sheet-mini { width: auto !important; flex: none; padding: 1px 8px; }
.sheet-gm .sheet-lock-toggle { flex-direction: row; align-items: center; }

/* ---- Target tag above the hotbar ---- */
#target-pill {
  position: fixed; bottom: 90px; left: calc((100vw - var(--chat-width)) / 2); transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 12px; z-index: 6;
  background: rgba(40, 18, 16, 0.95); border: 1px solid #c0392b; border-radius: 16px; color: #ffd2cc; font-size: 13px; font-weight: bold;
}
#target-pill[hidden] { display: none !important; }
#target-pill span { cursor: pointer; }
#target-pill button { background: #3a1d1a; color: #ffd2cc; border: 1px solid #7a2a22; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; padding: 0; }
#sheet .sheet-roll.attack { border-color: #a5432f; color: #ffb3a7; }

/* ---- Rolling dice animation in chat ---- */
.roll-total.spinning { color: #c9b38a; opacity: 0.85; }
.roll-total.landed { animation: dice-land 0.35s ease-out; }
@keyframes dice-land { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
.chat-later { visibility: hidden; }

/* ---- Music + Sounds tabs (audio-tabs.js) ---- */
#panel.wider { width: 340px; }
#panel:not(.wide):not(.wider) { width: 262px; }   /* room for 5 tabs */
#tab-bar button { padding: 6px 2px; font-size: 12.5px; }
#now-playing { font-size: 13px; color: #e2b75c; }
#mini-controls { display: flex; gap: 4px; }
#mini-controls[hidden] { display: none; }
#mini-controls button { flex: 1; margin: 0; padding: 4px 0; }
#volumes { display: flex; flex-direction: column; gap: 2px; }
#volumes label { display: grid; grid-template-columns: 52px 1fr; align-items: center; font-size: 13px; color: #ccc; }

.audio-player { display: flex; flex-direction: column; gap: 5px; padding: 8px; background: #2a2216; border: 1px solid #6b5636; border-radius: 6px; }
.audio-title { font-weight: bold; color: #ffe2a8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audio-sub { font-size: 12px; color: #aaa; }
.audio-time { font-size: 11px; color: #aaa; text-align: right; margin-top: -4px; }
.audio-buttons { display: flex; gap: 4px; justify-content: center; }
#panel .audio-buttons button { margin: 0; min-width: 44px; font-size: 16px; padding: 4px 8px; }
#panel .audio-buttons button.audio-big { min-width: 60px; background: #4a3d29; border-color: #b8862b; }
.audio-options { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.audio-options select { font-size: 12px !important; padding: 3px !important; }
#panel .audio-options input[type=number] { width: 52px; padding: 3px; }
#panel button.on { background: #4a3d29; border-color: #e2b75c; color: #ffe2a8; }

.audio-row { display: flex; gap: 4px; align-items: center; }
.audio-row input { flex: 1; min-width: 0; }
.audio-pl-head { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.audio-pl-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.audio-pl-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audio-pl-text small { color: #999; font-size: 11px; }
.audio-tracklist { display: flex; flex-direction: column; gap: 2px; }
.audio-track { display: flex; align-items: center; gap: 3px; padding: 2px 4px; border-radius: 4px; background: #222; font-size: 12px; }
.audio-track:hover { background: #2c2c2c; }
.audio-track.playing { background: #3a3020; outline: 1px solid #b8862b; }
.audio-track.playing .audio-track-name { color: #ffe2a8; font-weight: bold; }
.audio-track-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audio-track .audio-rename { flex: 1; min-width: 0; padding: 2px 4px !important; }
.audio-dur { color: #888; font-size: 11px; }
#panel .audio-track button.small { margin: 0; padding: 1px 6px; }
#panel button.audio-playbtn { color: #8fdc8f; }
#panel select.audio-tolist { width: 58px; padding: 1px !important; font-size: 11px !important; }

.audio-running { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.audio-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 8px; border-radius: 12px; background: #1f3524; border: 1px solid #3f8a52; color: #bff0c8; font-size: 12px; }
#panel .audio-chip button { margin: 0; padding: 0 5px; border-radius: 50%; }

.sound-groups { display: flex; flex-direction: column; gap: 8px; }
.sound-group-name { font-size: 12px; font-weight: bold; color: #c9b38a; margin-bottom: 3px; }
.sound-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.sound-list { display: flex; flex-direction: column; gap: 3px; }
.sound-item { display: flex; flex-direction: column; gap: 4px; }
.sound-row { display: flex; align-items: center; gap: 3px; }
#panel .sound-row button { margin: 0; }
#panel button.sound-btn { margin: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; padding: 6px 8px; }
.sound-row .sound-btn { flex: 1; min-width: 0; }
#panel .sound-row input.sound-vol { width: 56px; flex: none; }
#panel .sound-row button.sound-share { white-space: nowrap; font-size: 11px; padding: 2px 5px; }
#panel button.sound-btn.loop { border-style: dashed; }
#panel button.sound-btn.on { background: #1f3524; border: 1px solid #5fc274; color: #d6ffdd; box-shadow: 0 0 6px #3f8a52; }
#panel button.sound-share { opacity: 0.7; }
#panel button.sound-share.on { opacity: 1; background: #24384a; border-color: #4a90c8; }
