@import url("https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap");

:root {
  --bg-main: #151c2c;
  --bg-panel: #1e293b;
  --bg-panel-soft: #24344b;
  --bg-workspace: #151c2c;
  --border: #3d5a85;
  --text-main: #e8f1fb;
  --text-dim: #8ea8ca;
  --accent: #6fcf97;
  --accent-strong: #8adcae;
  --danger: #ff5e6c;
  --blue-team: #47afff;
  --red-team: #ff4757;
  --neutral-team: #a5b8d9;
  --grid-main: #2a3b57;
  --grid-major: #3d5a85;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: "Chakra Petch", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at 12% 16%, rgba(76, 146, 214, 0.2) 0%, transparent 36%),
    radial-gradient(circle at 82% 85%, rgba(75, 171, 121, 0.17) 0%, transparent 42%),
    linear-gradient(120deg, #101827, #151c2c);
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(340px, 1fr) 330px;
  gap: 10px;
  padding: 10px;
}

.sidebar {
  background: linear-gradient(165deg, rgba(26, 44, 71, 0.95), rgba(12, 24, 40, 0.92));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  overflow-y: auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 8px 24px rgba(0, 0, 0, 0.28);
}

.left-sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
}

.right-sidebar {
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

h1 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: 0.02em;
}

.sidebar-subtitle {
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.panel {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid rgba(90, 128, 173, 0.35);
  background: rgba(16, 31, 52, 0.82);
  border-radius: 10px;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 1rem;
  letter-spacing: 0.03em;
}

.tool-grid {
  display: grid;
  gap: 8px;
}

.default-panel {
  margin-top: auto;
}

.settings-toggle {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  border: 1px solid rgba(90, 128, 173, 0.5);
  background: linear-gradient(175deg, #2a405f, #1b2d47);
  color: #dbe8f7;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.settings-toggle:hover {
  border-color: var(--accent);
}

.settings-panel {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 280px;
  z-index: 8;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

.hidden {
  display: none;
}

.settings-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.settings-panel-header h2 {
  margin: 0;
}

.settings-close {
  border: 1px solid rgba(90, 128, 173, 0.5);
  background: linear-gradient(175deg, #4a2841, #2f1b2f);
  color: #f8d8e7;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
}

.team-swatches {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.team-swatch {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 2px solid rgba(190, 213, 238, 0.55);
  cursor: pointer;
}

.team-swatch.blue {
  background: #3d5dff;
}

.team-swatch.red {
  background: #ff3d3d;
}

.team-swatch.neutral {
  background: #667380;
}

.team-swatch.active {
  box-shadow: 0 0 0 2px rgba(246, 252, 255, 0.88);
  transform: translateY(-1px);
}

.team-swatches.compact {
  gap: 8px;
  margin: 4px 0 10px;
}

.team-swatches.compact .team-swatch {
  width: 24px;
  height: 24px;
}

button,
input,
select {
  font: inherit;
}

.tool-button,
.action-button,
.danger-button {
  border: 1px solid rgba(90, 128, 173, 0.45);
  background: linear-gradient(175deg, #1e3759, #152844);
  color: var(--text-main);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.2s ease;
}

.tool-button:hover,
.action-button:hover,
.danger-button:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.tool-button.active {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 1px rgba(61, 214, 181, 0.45) inset;
  background: linear-gradient(175deg, #1f5f6d, #1b3e5b);
}

.field,
.checkbox-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 8px;
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
}

.field span,
.checkbox-field span {
  color: var(--text-dim);
  font-size: 0.9rem;
}

input[type="number"],
input[type="text"],
select {
  background: rgba(12, 26, 45, 0.95);
  color: var(--text-main);
  border: 1px solid rgba(90, 128, 173, 0.45);
  border-radius: 7px;
  padding: 6px 8px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
}

.workspace {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-workspace);
  min-width: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

#mapCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.workspace-overlay {
  position: absolute;
  left: 12px;
  bottom: 10px;
  background: rgba(4, 9, 16, 0.65);
  border: 1px solid rgba(89, 128, 173, 0.4);
  color: #a9c3e4;
  border-radius: 7px;
  padding: 5px 8px;
  font-family: "Space Mono", monospace;
  font-size: 0.78rem;
  pointer-events: none;
}

.action-state {
  border: 1px solid rgba(89, 128, 173, 0.45);
  border-radius: 7px;
  padding: 6px 8px;
  margin-bottom: 8px;
  font-family: "Space Mono", monospace;
  font-size: 0.78rem;
  color: #cde2fb;
  background: rgba(16, 28, 47, 0.8);
  min-height: 31px;
  display: flex;
  align-items: center;
}

.action-state.warn {
  border-color: rgba(255, 201, 112, 0.65);
  color: #ffe7b7;
}

.action-state.error {
  border-color: rgba(255, 94, 108, 0.75);
  color: #ffd7dd;
}

.action-state.success {
  border-color: rgba(111, 207, 151, 0.75);
  color: #d7f7e3;
}

.action-state.idle {
  color: #b7cae1;
}

.tips {
  margin: 0;
  padding-left: 18px;
  color: var(--text-dim);
}

.tips li {
  margin-bottom: 5px;
}

.selection-panel {
  min-height: 100px;
}

.muted {
  color: var(--text-dim);
  margin: 0;
}

.readonly-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid rgba(90, 128, 173, 0.5);
  color: #bfd5ef;
  font-family: "Space Mono", monospace;
  font-size: 0.8rem;
}

.selection-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.danger-button {
  background: linear-gradient(175deg, #5f2532, #421924);
  border-color: rgba(255, 94, 108, 0.5);
}

.action-button {
  width: 100%;
  margin-bottom: 8px;
}

.action-button.secondary {
  background: linear-gradient(175deg, #23435b, #1a3349);
}

.data-panel {
  margin-bottom: 8px;
}

.quick-help-panel {
  margin-top: auto;
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 245px minmax(300px, 1fr) 285px;
  }
}

@media (max-width: 980px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(420px, 55vh) auto;
  }

  .left-sidebar,
  .right-sidebar {
    max-height: 38vh;
  }

  .workspace {
    min-height: 420px;
  }
}
