﻿:root {
  --bg: #121a24;
  --panel: #1a2532;
  --panel-2: #202e3f;
  --line: #33475f;
  --text: #e8f0f9;
  --muted: #8ea4bb;
  --accent: #23c28a;
  --danger: #e8535b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  color: var(--text);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 700px at 0% 0%, #1e3a46 0%, transparent 50%),
    radial-gradient(900px 500px at 100% 100%, #2d3147 0%, transparent 50%),
    var(--bg);
  display: grid;
  grid-template-rows: 86px 44px 1fr;
}

.topbar {
  height: 86px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 20, 29, 0.86);
  backdrop-filter: blur(6px);
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.sync-indicator {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #d8e4ef;
}

.sync-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.25);
}

.sync-dot.synced {
  background: #2fe387;
  box-shadow: 0 0 12px rgba(47, 227, 135, 0.7);
}

.sync-dot.waiting {
  background: #ffd86a;
  box-shadow: 0 0 12px rgba(255, 216, 106, 0.65);
}

.sync-dot.disconnected {
  background: #ff6f7a;
  box-shadow: 0 0 12px rgba(255, 111, 122, 0.7);
}

.conn {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  max-width: 78vw;
}

.conn input,
.conn select {
  max-width: 160px;
}

.auth-status {
  min-width: 84px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.auth-status.ok {
  color: #45d995;
}

input,
select,
button {
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #182330;
  color: var(--text);
  padding: 0 10px;
}

label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

button {
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button.active {
  border-color: var(--accent);
}

.tab-nav {
  display: flex;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 16, 24, 0.75);
}

.tab-btn {
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: #15202b;
  color: #cde0f1;
  font-size: 12px;
}

.tab-root {
  min-height: 0;
  overflow: hidden;
  padding: 12px;
}

.tab-pane {
  display: none;
  height: 100%;
  min-height: 0;
}

.tab-pane.active {
  display: block;
}

.console-layout {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 60% 40%;
  gap: 14px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(20, 30, 40, 0.9);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(51, 71, 95, 0.55);
}

.section-head h2 {
  margin: 0;
  font-size: 15px;
}

#logMeta {
  font-size: 12px;
  color: var(--muted);
}

.log-panel {
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  min-height: 0;
}

.log-view {
  margin: 10px 12px;
  border: 1px solid #2c4058;
  border-radius: 8px;
  background: #081019;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.45;
  overflow: auto;
  padding: 10px;
  min-height: 0;
}

.log-line {
  color: #e8f0f9;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-line.warn {
  color: #ffd55d;
}

.log-line.error {
  color: #ff5e66;
}

.log-line.ok {
  color: #e8f0f9;
}

.log-line.pending {
  color: #8ea4bb;
}

.history-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 0 12px 8px;
  color: var(--muted);
  font-size: 12px;
}

.history-list {
  display: flex;
  gap: 8px;
  overflow: auto;
  white-space: nowrap;
  padding-bottom: 2px;
}

.history-item {
  height: 24px;
  display: inline-flex;
  align-items: center;
  border-radius: 100px;
  border: 1px solid #3d4d62;
  background: #182230;
  color: #d8e6f3;
  padding: 0 10px;
  cursor: pointer;
  font-size: 12px;
}

.cmd-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  padding: 0 12px 12px;
}

.command-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 12px;
}

.command-tools > div {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

#cmdInput {
  font-family: "Cascadia Mono", "Consolas", monospace;
}

.right-stack {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(86px, auto) minmax(260px, 1fr) minmax(176px, auto);
  gap: 14px;
}

.server-panel {
  min-height: 108px;
  display: grid;
  grid-template-rows: auto 1fr;
}

.server-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  max-height: 104px;
  overflow: auto;
}

.server-chip {
  height: 30px;
  display: inline-grid;
  grid-template-columns: minmax(80px, 1fr) auto;
  gap: 8px;
  align-items: center;
  max-width: 220px;
  border-radius: 999px;
  background: #122131;
}

.server-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-chip strong {
  color: #45d995;
  font-size: 12px;
}

.server-chip.active {
  border-color: var(--accent);
  background: #173225;
}

.server-chip.stale {
  opacity: 0.6;
}

.server-empty {
  color: var(--muted);
  font-size: 12px;
}

.player-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.console-player-table-wrap {
  min-height: 0;
  margin: 0 10px;
}

.console-player-table {
  table-layout: auto;
}

.console-player-table thead {
  display: none;
}

.console-player-table tbody {
  display: grid;
  gap: 6px;
  padding: 8px;
}

.console-player-table tr {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(58px, auto);
  grid-template-areas:
    "id name hp"
    "id role hp";
  column-gap: 8px;
  row-gap: 2px;
  align-items: center;
  min-height: 42px;
  padding: 6px 8px;
  border: 1px solid rgba(67, 94, 125, 0.72);
  border-radius: 8px;
  background: rgba(11, 21, 32, 0.66);
  cursor: pointer;
}

.console-player-table td {
  display: block;
  border-bottom: 0;
  padding: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.console-player-table td:first-child {
  grid-area: id;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(35, 194, 138, 0.1);
  color: #9ee6c8;
  font-weight: 700;
}

.console-player-table td:nth-child(2) {
  grid-area: name;
  min-width: 0;
  font-weight: 650;
  color: #edf6ff;
}

.console-player-table td:nth-child(3) {
  grid-area: role;
  min-width: 0;
  color: #9fb4c8;
  font-size: 11px;
}

.console-player-table td:nth-child(4) {
  grid-area: hp;
  justify-self: end;
  color: #d5e7f7;
  font-variant-numeric: tabular-nums;
}

.console-player-table tr.selected {
  border-color: rgba(35, 194, 138, 0.95);
  background: rgba(35, 194, 138, 0.18);
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 12px;
}

.actions-grid.two-col {
  grid-template-columns: repeat(2, 1fr);
}

.actions-grid.three-col {
  grid-template-columns: repeat(3, 1fr);
}

.teleport-grid {
  display: grid;
  gap: 10px;
  padding: 12px 12px 2px;
}

.teleport-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.teleport-row label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.teleport-grid select {
  width: 100%;
}

.teleport-row button {
  min-width: 92px;
}

.danger {
  border-color: var(--danger);
}

.table-wrap {
  min-height: 0;
  overflow: auto;
  margin: 0 12px;
  border: 1px solid #2c4058;
  border-radius: 8px;
}

.table-wrap-large {
  height: calc(100vh - 280px);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

thead tr {
  background: var(--panel-2);
}

th,
td {
  text-align: left;
  padding: 7px;
  border-bottom: 1px solid rgba(51, 71, 95, 0.45);
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover {
  background: rgba(35, 194, 138, 0.08);
}

tbody tr.selected {
  background: rgba(35, 194, 138, 0.2);
}

.hint {
  margin: 8px 12px 10px;
  color: var(--muted);
  font-size: 11px;
}

.hint.ok {
  color: #30d18c;
}

.hint.warn {
  color: #ffd55d;
}

.hint.error {
  color: #ff6d73;
}

.hint.pending {
  color: #a7b9ca;
}

.broadcast-panel {
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
}

.broadcast-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
}

.broadcast-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 12px 10px;
}

.broadcast-options label,
.control-grid label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.broadcast-format {
  display: flex;
  gap: 12px;
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 12px;
}

.role-options {
  padding-top: 2px;
}

#playerActionFeedback {
  margin-top: 2px;
}

.broadcast-format label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.broadcast-format input[type="checkbox"] {
  width: 14px;
  height: 14px;
  padding: 0;
}

.quick-grid {
  padding: 0 12px 12px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.quick {
  background: #1d2a39;
}

.manage-layout {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 58% 42%;
  gap: 14px;
}

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

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}

.inline-actions {
  display: flex;
  gap: 8px;
  align-items: end;
}

.inline-actions button {
  min-width: 76px;
  white-space: nowrap;
}

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

.inline-input button {
  min-width: 64px;
}

.player-center-card {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.player-subtabs {
  display: flex;
  gap: 8px;
  padding: 10px 12px 0;
  border-bottom: 1px solid rgba(51, 71, 95, 0.55);
}

.player-subtab-btn {
  height: 30px;
  border-radius: 999px;
  font-size: 12px;
  padding: 0 12px;
  background: #15202b;
}

.player-subtab-btn.active {
  border-color: var(--accent);
  color: #dff7eb;
  background: #193043;
}

.player-subpane {
  display: none;
  min-height: 0;
  overflow: auto;
  padding-bottom: 10px;
}

.player-subpane.active {
  display: block;
}

.request-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
}

.request-box {
  margin: 0 12px;
  min-height: 240px;
  max-height: calc(100vh - 380px);
  overflow: auto;
  border: 1px solid #2c4058;
  border-radius: 8px;
  background: #081019;
  color: #d2e4f5;
  padding: 10px;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.round-grid {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.round-group {
  border: 1px solid #2c4058;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  gap: 8px;
  background: rgba(8, 16, 25, 0.45);
}

.round-group h3 {
  margin: 0;
  font-size: 14px;
}

.map-card {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.map-head-tools {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.map-toggle-btn {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.map-controls-block {
  overflow: hidden;
  max-height: 260px;
  opacity: 1;
  transition: max-height 0.22s ease, opacity 0.2s ease;
}

.map-controls-block.collapsed {
  max-height: 0;
  opacity: 0;
}

.map-card.controls-collapsed .map-board {
  min-height: min(78vh, calc(100vh - 190px));
}

.map-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(51, 71, 95, 0.4);
  color: #bfd2e4;
  font-size: 12px;
  flex-wrap: wrap;
}

.map-control-check input,
.broadcast-format input[type="checkbox"],
.role-options input[type="checkbox"] {
  height: auto;
  min-height: 0;
}

.map-control-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.map-head-check {
  color: #bfd2e4;
  font-size: 12px;
}

.replay-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(51, 71, 95, 0.32);
}

.replay-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #bfd2e4;
  font-size: 12px;
}

.replay-toolbar select {
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid #2c4058;
  background: #0f1b28;
  color: #d7e8fa;
}

.replay-toolbar button {
  height: 28px;
  padding: 0 10px;
}

.replay-playback-strip {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-rows: auto 14px 38px;
  min-height: 0;
  background: #07111c;
  border-bottom: 1px solid rgba(51, 71, 95, 0.28);
}

.public-replay-map-wrap .replay-playback-strip {
  border: 1px solid rgba(71, 99, 132, 0.38);
  border-radius: 8px;
  overflow: hidden;
}

.replay-timeline-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 16px 0;
  min-height: 30px;
  position: relative;
  z-index: 2;
}

.replay-event-ticks {
  position: relative;
  height: 14px;
  margin: 0 84px 0 16px;
  z-index: 1;
}

.replay-event-tick {
  position: absolute;
  top: 1px;
  display: block;
  width: 9px;
  height: 9px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: 999px;
  transform: translateX(-50%);
  border-color: rgba(255, 255, 255, 0.55);
  background: #d7e8fa;
  font-size: 0;
  line-height: 0;
}

.replay-event-list {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 16px 8px;
  scrollbar-width: thin;
}

.replay-event-item {
  flex: 0 0 auto;
  height: 26px;
  max-width: 260px;
  border-radius: 999px;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.replay-controls-block {
  overflow: hidden;
  max-height: 1200px;
  min-height: 0;
  opacity: 1;
  border-bottom: 1px solid rgba(51, 71, 95, 0.32);
  transition: max-height 0.22s ease, opacity 0.2s ease;
}

.replay-controls-block.collapsed {
  max-height: 0;
  opacity: 0;
  border-bottom: 0;
  visibility: hidden;
  pointer-events: none;
}

.replay-map-toolbar {
  border-bottom: 1px solid rgba(51, 71, 95, 0.32);
}

.replay-card {
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
}

.replay-zone-toolbar {
  border-bottom: 1px solid rgba(51, 71, 95, 0.32);
}

.replay-zone-tabs {
  margin-left: 8px;
}

.replay-map-board {
  position: relative;
  z-index: 1;
  cursor: grab;
}

.replay-card.controls-collapsed .replay-map-board {
  min-height: min(78vh, calc(100vh - 230px));
}

#replayTimeline {
  width: 100%;
  height: 24px;
  min-height: 0;
  padding: 0;
}

#replayTimeText {
  font-size: 12px;
  color: #c3d5e7;
  white-space: nowrap;
}

.map-zone-tabs {
  display: inline-flex;
  gap: 6px;
  margin-left: 8px;
  flex-wrap: wrap;
}

.map-zone-btn {
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid #35506c;
  background: #132131;
  color: #c9d9e8;
}

.map-zone-btn.active {
  border-color: #66c2ff;
  color: #e8f6ff;
  background: #17304a;
}

.map-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.map-legend .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}

.dot.scp {
  background: #ff5568;
}

.dot.mtf {
  background: #3fa1ff;
}

.dot.chaos {
  background: #57d87a;
}

.dot.civ {
  background: #ffd769;
}

.dot.other {
  background: #d0d7df;
}

.map-board {
  min-height: min(64vh, calc(100vh - 300px));
  overflow: hidden;
  /* Hide overflow for zoom/pan */
  padding: 0;
  /* Remove padding to let plane fill */
  border: 1px solid #2d425a;
  border-radius: 10px;
  background: rgba(8, 15, 24, 0.5);
  position: relative;
  /* Context for absolute positioning if needed */
  cursor: grab;
}

.map-plane {
  position: relative;
  /* overflow: hidden; -> Removed to allow scaling beyond */
  border-radius: 10px;
  background:
    radial-gradient(1000px 600px at 40% 30%, rgba(25, 74, 122, 0.18) 0%, transparent 65%),
    linear-gradient(180deg, rgba(8, 25, 46, 0.72), rgba(5, 15, 29, 0.82));
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.35);
  transform-origin: 0 0;
  /* Zoom from top-left logic handled by JS */
  width: 100%;
  height: 100%;
}

.map-zone-panel {
  position: absolute;
  border: 1px solid rgba(83, 130, 179, 0.46);
  border-radius: 10px;
  background: rgba(6, 15, 24, 0.34);
}

.map-zone-layer {
  position: absolute;
  overflow: hidden;
  border-radius: 10px;
}

.map-zone-title {
  position: absolute;
  top: 8px;
  left: 10px;
  font-size: 11px;
  color: #d7e8fa;
  background: rgba(5, 14, 24, 0.76);
  border: 1px solid rgba(68, 107, 146, 0.7);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

.map-empty {
  color: #97acc0;
  font-size: 12px;
  padding: 16px;
}

.map-room {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-radius: 4px;
  background: #2a5a8a;
  padding: 2px 3px;
  overflow: hidden;
  transition: left 0.2s ease, top 0.2s ease, width 0.2s ease, min-height 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.map-room.topology {
  z-index: 2;
  border-width: 0;
  border-radius: 3px;
  padding: 0;
  opacity: 0.82;
  box-shadow: 0 0 2px rgba(141, 190, 238, 0.25);
}

.map-room.topology.occupied {
  opacity: 0.98;
  border-width: 1px;
  box-shadow: 0 0 10px rgba(125, 194, 255, 0.3);
}

.map-room.topology .map-room-title,
.map-room.topology .map-room-sub,
.map-room.topology .map-room-players {
  display: none;
}

.map-room-overlay-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  z-index: 10;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 2px;
}

.map-links {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.map-link {
  position: absolute;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(121, 178, 232, 0.35), rgba(121, 178, 232, 0.9), rgba(121, 178, 232, 0.35));
  box-shadow: 0 0 8px rgba(82, 142, 199, 0.55);
}

.map-room.topology.shape-cross {
  border-radius: 2px;
}

.map-room.topology.shape-t,
.map-room.topology.shape-line-h,
.map-room.topology.shape-line-v {
  border-radius: 2px;
}

.map-room.topology.shape-corner,
.map-room.topology.shape-end,
.map-room.topology.shape-isolated {
  border-radius: 4px;
}

.map-room.topology.shape-surface {
  border-radius: 10px;
}

.map-player-marker {
  position: absolute;
  transform: translate(-50%, -11px);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  z-index: 6;
  pointer-events: auto;
  transition: left 0.3s linear, top 0.3s linear;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

.map-heat-cell {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 3;
  pointer-events: none;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 91, 108, 0.66), rgba(255, 216, 106, 0.32) 42%, transparent 72%);
  filter: blur(1px);
}

.map-trail-line {
  position: absolute;
  z-index: 5;
  overflow: visible;
  pointer-events: none;
}

.map-trail-line polyline {
  fill: none;
  stroke: rgba(102, 194, 255, 0.72);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 4px rgba(102, 194, 255, 0.55));
}

.replay-trail-line polyline {
  opacity: 0.68;
  stroke-width: 2.4;
}

.map-shot-rays {
  position: absolute;
  z-index: 8;
  overflow: visible;
  pointer-events: none;
}

.map-shot-ray {
  stroke: var(--shot-color, rgba(255, 221, 112, 0.94));
  stroke-width: 3;
  stroke-linecap: round;
}

.map-shot-ray.event-kill {
  stroke: var(--shot-color, rgba(255, 95, 112, 0.98));
}

.map-shot-impact {
  fill: var(--shot-color, #ffdd70);
  stroke: rgba(8, 16, 25, 0.9);
  stroke-width: 1.2;
}

.map-shot-impact.event-kill {
  fill: var(--shot-color, #ff5f70);
}

.map-kill-x {
  position: absolute;
  z-index: 10;
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 0;
  background: transparent;
  color: var(--kill-color, #ff6f7a);
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-shadow:
    0 0 8px var(--kill-color, #ff6f7a),
    0 1px 2px rgba(0, 0, 0, 0.95);
  cursor: pointer;
}

.map-kill-x.future {
  opacity: 0.4;
}

.map-event-marker {
  position: absolute;
  z-index: 7;
  width: 20px;
  height: 20px;
  min-width: 20px;
  padding: 0;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  background: #172638;
  border-color: rgba(255, 255, 255, 0.65);
}

.map-event-marker.future {
  opacity: 0.45;
}

.event-kill {
  color: #ff6f7a;
  border-color: #ff6f7a;
}

.event-shot,
.event-hit {
  color: #ffdd70;
  border-color: #ffdd70;
}

.event-escape {
  color: #56e093;
  border-color: #56e093;
}

.event-warhead_start,
.event-warhead_detonating,
.event-warhead_detonated {
  color: #ffd86a;
  border-color: #ffd86a;
}

.map-context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 180px;
  padding: 6px;
  display: grid;
  gap: 4px;
  border: 1px solid #45617f;
  border-radius: 8px;
  background: rgba(8, 16, 25, 0.98);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.38);
}

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

.map-context-menu button {
  width: 100%;
  height: 30px;
  text-align: left;
  border-radius: 6px;
}

.audit-card {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

td.ok {
  color: #45d995;
}

td.error {
  color: #ff6f7a;
}

td.pending {
  color: #a7b9ca;
}

.map-player-arrow {
  display: block;
  width: 16px;
  height: 22px;
  background: currentColor;
  clip-path: polygon(50% 0, 100% 100%, 50% 76%, 0 100%);
  color: #d7e8fb;
  transform-origin: 50% 56%;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.7));
}

.map-player-text {
  display: grid;
  gap: 0;
  line-height: 1.05;
  white-space: nowrap;
  max-width: 136px;
  text-align: center;
  pointer-events: none;
}

.map-player-role {
  font-size: 9px;
  font-weight: 700;
  color: #d8ebff;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-player-nickname {
  font-size: 9px;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-player-marker.team-scp .map-player-arrow,
.map-player-marker.team-scp .map-player-role {
  color: #ff5b6c;
}

.map-player-marker.team-mtf .map-player-arrow,
.map-player-marker.team-mtf .map-player-role {
  color: #67bcff;
}

.map-player-marker.team-chaos .map-player-arrow,
.map-player-marker.team-chaos .map-player-role {
  color: #68de86;
}

.map-player-marker.role-guard .map-player-arrow,
.map-player-marker.role-guard .map-player-role {
  color: #aeb7c2;
}

.map-player-marker.role-classd .map-player-arrow,
.map-player-marker.role-classd .map-player-role {
  color: #ffad43;
}

.map-player-marker.role-scientist .map-player-arrow,
.map-player-marker.role-scientist .map-player-role {
  color: #ffe15a;
}

.map-player-marker.role-tutorial .map-player-arrow,
.map-player-marker.role-tutorial .map-player-role {
  color: #ff79c9;
}

.map-player-marker.role-spectator .map-player-arrow,
.map-player-marker.role-spectator .map-player-role {
  color: #cfd8e3;
}

.map-player-marker.spectator-merged {
  transform: translate(-50%, -50%);
  gap: 0;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(193, 210, 228, 0.55);
  background: rgba(10, 20, 30, 0.72);
}

.map-player-marker.spectator-merged .map-player-arrow {
  display: none;
}

.map-player-marker.spectator-merged .map-player-text {
  max-width: none;
}

.map-player-marker.spectator-merged .map-player-role {
  font-size: 10px;
  line-height: 1.1;
}

.map-player-marker.spectator-merged .map-player-nickname {
  display: none;
}

.map-player-marker.team-other .map-player-arrow,
.map-player-marker.team-other .map-player-role {
  color: #e1e8f0;
}

.map-room.zone-lightcontainment,
.map-zone-label.zone-lightcontainment {
  border-color: rgba(220, 226, 232, 0.45);
  background: rgba(90, 90, 90, 0.78);
}

.map-room.zone-heavycontainment,
.map-zone-label.zone-heavycontainment {
  border-color: rgba(130, 174, 216, 0.5);
  background: rgba(26, 58, 90, 0.82);
}

.map-room.zone-entrance,
.map-zone-label.zone-entrance {
  border-color: rgba(233, 179, 121, 0.5);
  background: rgba(138, 90, 42, 0.76);
}

.map-room.zone-surface,
.map-zone-label.zone-surface {
  border-color: rgba(153, 222, 178, 0.5);
  background: rgba(62, 126, 84, 0.8);
}

.map-room.zone-pocket,
.map-zone-label.zone-pocket {
  border-color: rgba(183, 148, 243, 0.5);
  background: rgba(77, 55, 116, 0.82);
}

.map-room.zone-unknown,
.map-zone-label.zone-unknown {
  border-color: rgba(164, 190, 212, 0.45);
  background: rgba(61, 90, 117, 0.8);
}

.map-room-title {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  color: #ffffff;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-room-sub {
  font-size: 10px;
  color: rgba(230, 242, 252, 0.95);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.map-room-players {
  margin-top: 2px;
  display: grid;
  gap: 2px;
  width: 100%;
}

.map-player-chip {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-left: 3px solid #9aa9b7;
  border-radius: 6px;
  background: rgba(3, 10, 19, 0.72);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 4px;
  align-items: center;
  min-height: 18px;
  padding: 1px 4px;
  font-size: 10px;
}

.map-player-chip.team-scp {
  border-left-color: #ff5568;
}

.map-player-chip.team-mtf {
  border-left-color: #49a9ff;
}

.map-player-chip.team-chaos {
  border-left-color: #57d87a;
}

.map-player-chip.team-civilian {
  border-left-color: #ffd769;
}

.map-player-chip.team-other {
  border-left-color: #d0d7df;
}

.map-role-icon {
  width: 12px;
  text-align: center;
  font-size: 11px;
  color: #d7e9ff;
}

.map-player-name {
  color: #ecf5ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-view-arrow {
  color: #93d3ff;
  font-size: 9px;
  transform-origin: center;
}

.map-more {
  font-size: 10px;
  color: #a7bfd6;
  text-align: right;
}

.map-zone-label {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 3px 8px;
  border: 1px solid #3f668f;
  border-radius: 100px;
  background: rgba(6, 15, 24, 0.82);
  color: #d7e8fa;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
}

@media (max-width: 1280px) {

  .console-layout,
  .manage-layout {
    grid-template-columns: 1fr;
  }

  .right-stack {
    grid-template-rows: minmax(90px, auto) minmax(260px, 1fr) minmax(176px, auto);
  }

  .broadcast-options,
  .control-grid,
  .round-grid,
  .actions-grid.three-col,
  .request-actions,
  .teleport-row,
  .login-grid {
    grid-template-columns: 1fr;
  }

  .inline-input {
    grid-template-columns: 1fr;
  }

  .player-subtabs {
    flex-wrap: wrap;
  }

  .map-board {
    min-height: min(56vh, calc(100vh - 250px));
  }
}

/* ====== 小饭堂数据库 & 任务系统 ====== */
.xft-search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
}

.xft-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.xft-modal-content {
  width: 620px;
  max-width: 92vw;
  max-height: 85vh;
  overflow: auto;
  border: 1px solid var(--accent);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.xft-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.xft-modal-close:hover {
  color: var(--danger);
}

.xft-modal-actions {
  display: flex;
  gap: 8px;
  padding: 8px 12px 12px;
}

.xft-check-label {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 6px !important;
}

.xft-check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  padding: 0;
}

#xftPlayerProgressBox {
  padding: 0 12px 12px;
}

#xftPlayerProgressBox h3 {
  margin: 12px 0 8px;
  font-size: 14px;
}

.xft-badge-active {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(35, 194, 138, 0.2);
  color: #30d18c;
  border: 1px solid rgba(35, 194, 138, 0.4);
}

.xft-badge-inactive {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(232, 83, 91, 0.15);
  color: #ff6d73;
  border: 1px solid rgba(232, 83, 91, 0.3);
}

tbody tr .xft-action-btn {
  height: 26px;
  padding: 0 8px;
  font-size: 11px;
  margin-right: 4px;
}

/* ====== 通用数据库与弹窗 ====== */
.xft-modal[hidden] {
  display: none !important;
}

.compact-modal {
  width: 460px;
}

.login-modal-card {
  width: min(720px, 94vw);
}

.login-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 14px 4px;
}

.login-grid label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.login-grid input {
  width: 100%;
}

.login-token-field {
  grid-column: 1 / -1;
}

.generic-db-card {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  min-height: 0;
}

.generic-db-card .section-head {
  gap: 12px;
}

.generic-db-card .map-head-tools {
  flex-wrap: wrap;
  justify-content: flex-end;
}

#dbStatusText {
  min-width: 92px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.db-toolbar {
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) minmax(120px, 0.8fr) minmax(180px, 1.4fr) minmax(82px, 0.45fr) auto auto auto;
  gap: 8px;
  align-items: end;
  padding: 12px;
}

.db-toolbar label {
  display: grid;
  gap: 4px;
}

.db-toolbar input,
.db-toolbar select {
  width: 100%;
}

.db-detected-columns {
  min-height: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 10px;
}

.db-column-chip {
  display: inline-flex;
  align-items: center;
  max-width: 260px;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid rgba(35, 194, 138, 0.35);
  border-radius: 999px;
  background: rgba(35, 194, 138, 0.12);
  color: #b7f0d5;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.db-table-wrap {
  height: calc(100vh - 320px);
  background: rgba(10, 16, 24, 0.24);
}

.db-grid-table {
  min-width: 760px;
  table-layout: auto;
}

.db-grid-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #203044;
  color: #dceaf7;
}

.db-grid-table th,
.db-grid-table td {
  min-width: 120px;
  max-width: 320px;
  vertical-align: middle;
}

.db-grid-table th:first-child,
.db-grid-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 58px;
  width: 58px;
  background: #192635;
  color: var(--muted);
  text-align: center;
}

.db-grid-table thead th:first-child {
  z-index: 3;
  background: #203044;
}

.db-grid-table tr.dirty {
  background: rgba(255, 213, 93, 0.08);
}

.db-grid-table tr.dirty:hover {
  background: rgba(255, 213, 93, 0.14);
}

.db-row-state {
  font-size: 11px;
  color: #ffd55d;
  white-space: nowrap;
}

.db-cell-input {
  width: 100%;
  min-width: 110px;
  height: 30px;
  border-color: rgba(88, 114, 143, 0.8);
  background: #111b27;
  font-size: 12px;
}

.db-cell-input:focus {
  outline: 1px solid rgba(35, 194, 138, 0.75);
  border-color: var(--accent);
}

.db-readonly {
  color: #b9c9d8;
  background: rgba(255, 255, 255, 0.025);
  word-break: break-all;
}

.db-key-column {
  color: #9ee6c8 !important;
  font-weight: 600;
}

.db-empty-cell {
  height: 92px;
  color: var(--muted);
  text-align: center !important;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (max-width: 1280px) {
  .db-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .db-toolbar > input,
  .db-toolbar > button {
    width: 100%;
  }
}

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

  .generic-db-card .map-head-tools {
    justify-content: flex-start;
  }

  #dbStatusText {
    width: 100%;
    text-align: left;
  }

  .xft-modal-content {
    width: min(92vw, 620px);
  }
}

/* ====== Mobile layout ====== */
@media (max-width: 760px) {
  html {
    min-width: 0;
    min-height: 100%;
  }

  body {
    display: block;
    width: 100%;
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--bg);
  }

  .topbar {
    height: auto;
    min-height: 0;
    padding: 12px;
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .brand h1 {
    font-size: 21px;
  }

  .conn {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    max-width: none;
    gap: 8px;
  }

  .conn .auth-status,
  .conn label {
    grid-column: 1 / -1;
  }

  .conn label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .conn input,
  .conn select {
    width: 100%;
    max-width: none;
  }

  input,
  select,
  button {
    min-height: 44px;
    height: 44px;
    font-size: 16px;
  }

  .tab-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    gap: 6px;
    padding: 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .tab-nav::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    flex: 0 0 auto;
    min-height: 40px;
    height: 40px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 14px;
  }

  .tab-root {
    min-height: calc(100dvh - 56px);
    overflow: visible;
    padding: 8px;
  }

  .tab-pane,
  .console-layout,
  .manage-layout,
  .right-stack {
    height: auto;
    min-height: 0;
  }

  .console-layout,
  .manage-layout,
  .right-stack {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    gap: 10px;
  }

  .card,
  .round-group,
  .map-board,
  .table-wrap,
  .log-view {
    border-radius: 8px;
  }

  .log-panel {
    height: 72dvh;
    min-height: 560px;
  }

  .right-stack > .player-panel {
    height: 68dvh;
    min-height: 520px;
  }

  .server-panel,
  .broadcast-panel,
  .player-center-card,
  .generic-db-card,
  .audit-card {
    height: auto;
  }

  .server-list {
    max-height: 180px;
  }

  .section-head {
    gap: 8px;
    padding: 10px;
  }

  .section-head h2 {
    font-size: 14px;
  }

  .section-head .map-head-tools {
    min-width: 0;
    overflow-x: auto;
    justify-content: flex-start;
    flex-wrap: nowrap;
  }

  .map-card > .section-head,
  .replay-card > .section-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .map-card > .section-head .map-head-tools,
  .replay-card > .section-head .map-head-tools {
    width: 100%;
  }

  .map-head-tools > * {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .history-row,
  .command-tools,
  .cmd-row,
  .broadcast-row,
  .xft-search-row,
  .teleport-row,
  .inline-input {
    grid-template-columns: minmax(0, 1fr);
  }

  .history-row {
    align-items: stretch;
  }

  .command-tools {
    gap: 8px;
  }

  .command-tools > div {
    grid-template-columns: minmax(0, 1fr);
  }

  .actions-grid,
  .actions-grid.three-col,
  .quick-grid,
  .round-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .broadcast-options,
  .control-grid,
  .request-actions,
  .login-grid,
  .db-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .broadcast-format,
  .inline-actions,
  .xft-modal-actions {
    flex-wrap: wrap;
  }

  .inline-actions > button,
  .xft-modal-actions > button {
    flex: 1 1 120px;
  }

  .player-subtabs,
  .map-toolbar,
  .replay-toolbar {
    overflow-x: hidden;
    overscroll-behavior-x: contain;
  }

  .map-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
  }

  .map-toolbar > .map-legend,
  .map-toolbar > label,
  .map-toolbar > button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .map-toolbar > .map-zone-tabs {
    order: -1;
    flex: 1 0 100%;
    min-width: 0;
    margin-left: 0;
    padding-bottom: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  .player-subtab-btn,
  .map-toggle-btn,
  .map-zone-btn,
  .replay-toolbar button,
  .replay-toolbar select {
    flex: 0 0 auto;
    min-height: 40px;
    height: 40px;
  }

  .table-wrap-large,
  .db-table-wrap {
    height: 62dvh;
    min-height: 420px;
  }

  .table-wrap table:not(.console-player-table) {
    min-width: 720px;
  }

  .map-card,
  .replay-card {
    height: auto;
    min-height: calc(100dvh - 72px);
  }

  .map-board,
  .map-card.controls-collapsed .map-board,
  .replay-card.controls-collapsed .replay-map-board {
    min-height: 68dvh;
    height: 68dvh;
    touch-action: none;
  }

  .replay-timeline-row {
    grid-template-columns: minmax(0, 1fr);
    padding: 8px 10px 0;
  }

  .replay-event-ticks {
    margin: 0 10px;
  }

  .xft-modal {
    align-items: flex-start;
    padding: max(12px, env(safe-area-inset-top)) 8px max(12px, env(safe-area-inset-bottom));
    overflow-y: auto;
  }

  .xft-modal-content,
  .login-modal-card,
  .compact-modal {
    width: 100%;
    max-width: 100%;
    max-height: none;
  }

  .generic-db-card {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
  }

  .generic-db-card .section-head,
  .generic-db-card .section-head .map-head-tools,
  .db-toolbar,
  .db-detected-columns {
    min-width: 0;
    max-width: 100%;
  }

  .db-table-wrap {
    width: calc(100% - 24px);
    max-width: calc(100% - 24px);
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  .db-grid-table {
    min-width: 640px;
  }
}
