:root {
  --cell-size: 50px;
  --grid-color: rgba(255, 255, 255, 0.08);
  --bg-color: #0f0f13;
  --panel-bg: #18181b;
  --border-color: #27272a;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
}
body {
  background-color: var(--bg-color);
  color: #e4e4e7;
  overflow: hidden;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  user-select: none;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #09090b;
}
::-webkit-scrollbar-thumb {
  background: #3f3f46;
  border-radius: 4px;
  border: 2px solid #09090b;
}
::-webkit-scrollbar-thumb:hover {
  background: #52525b;
}
#app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
}
.panel {
  background: var(--panel-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#viewport {
  flex: 1;
  position: relative;
  background-color: #000;
  overflow: auto;
  cursor: default;
  background-image: radial-gradient(#1f1f22 1px, transparent 1px);
  background-size: 20px 20px;
}
#grid-container {
  position: relative;
  background-color: #121212;
  background-image: linear-gradient(
      to right,
      var(--grid-color) 1px,
      transparent 1px
    ),
    linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
  background-size: var(--cell-size) var(--cell-size);
  box-shadow: 0 0 0 1px #333, 0 20px 50px rgba(0, 0, 0, 0.8);
  margin: 50px;
  transform-origin: 0 0;
  transition: width 0.2s, height 0.2s;
}
.layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#layer-terrain {
  z-index: 5;
}
#layer-decor {
  z-index: 8;
}
#layer-walls {
  z-index: 10;
  pointer-events: auto;
}
#layer-labels {
  z-index: 12;
}
#layer-aoe {
  z-index: 15;
  opacity: 0.6;
}
#layer-preview {
  z-index: 25;
}
#layer-tokens {
  z-index: 30;
  pointer-events: auto;
}
#layer-remote-previews { z-index: 35; pointer-events: none; }
.remote-move-preview {
  position: absolute;
  display: grid;
  place-items: center;
  border: 2px dashed #93c5fd;
  border-radius: 50%;
  background: #93c5fd22;
  color: #bfdbfe;
  font-weight: 700;
  opacity: .7;
  pointer-events: none;
}
#layer-vision-fog {
  z-index: 40;
  pointer-events: none;
}
#layer-brush {
  z-index: 60;
}
.cell-obj {
  position: absolute;
  width: var(--cell-size);
  height: var(--cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
}
.wall-block {
  background: #3f3f46;
  border: 1px solid #71717a;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}
.wall-height-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.85);
  color: #fbbf24;
  font-size: 9px;
  font-weight: bold;
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid #78350f;
  pointer-events: none;
}
.door {
  background: #451a03;
  border: 2px solid #78350f;
  cursor: pointer;
  transition: transform 0.2s;
  z-index: 12;
}
.door.open {
  background: rgba(69, 26, 3, 0.2);
  border-style: dashed;
  transform: scale(0.8);
}
.window {
  background: rgba(56, 189, 248, 0.15);
  border: 2px solid #0ea5e9;
  cursor: pointer;
  z-index: 12;
}
.window.open {
  background: rgba(56, 189, 248, 0.05);
  border-style: dashed;
}
.terrain-diff {
  background-image: repeating-linear-gradient(
    45deg,
    rgba(234, 179, 8, 0.1) 0,
    rgba(234, 179, 8, 0.1) 10px,
    transparent 10px,
    transparent 20px
  );
  border: 1px dashed rgba(234, 179, 8, 0.3);
}
.fog-manual {
  background: #000000;
  border: 1px solid #111;
}
.vision-mask {
  background-color: #000;
  transition: opacity 0.2s ease;
}
.grid-label {
  position: absolute;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-family: monospace;
  user-select: none;
}
.gl-col {
  top: -15px;
  height: 15px;
  width: var(--cell-size);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.gl-row {
  left: -20px;
  width: 20px;
  height: var(--cell-size);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}
.aoe-cell {
  background: rgba(239, 68, 68, 0.4);
  border: 1px solid rgba(239, 68, 68, 0.6);
}
.aoe-cell.persistent {
  background: rgba(147, 51, 234, 0.3);
  border-color: rgba(147, 51, 234, 0.5);
}
.token {
  position: absolute;
  transition: filter 0.15s ease;
  cursor: grab;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
}
.token:hover {
  z-index: 40;
  filter: brightness(1.1);
}
.token.selected .token-avatar {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4);
}
.token-avatar {
  width: 90%;
  height: 90%;
  border-radius: 50%;
  border: 2px solid #fff;
  background-color: #27272a;
  background-size: cover;
  background-position: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white;
  text-shadow: 0 1px 2px black;
  overflow: visible;
}
.team-red .token-avatar {
  border-color: #ef4444;
}
.team-blue .token-avatar {
  border-color: #3b82f6;
}
.team-green .token-avatar {
  border-color: #22c55e;
}
.team-neutral .token-avatar {
  border-color: #f59e0b;
}

/* Condições (Top Right Overlay) */
.token-conditions {
  position: absolute;
  top: -5px;
  right: -5px;
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  justify-content: flex-end;
  width: 40px;
  pointer-events: none;
  z-index: 55;
}
.cond-icon {
  width: 12px;
  height: 12px;
  background: #000;
  border: 1px solid #555;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.hp-bar-bg {
  position: absolute;
  bottom: -4px;
  width: 80%;
  height: 4px;
  background: #27272a;
  border-radius: 2px;
  overflow: visible;
}
.hp-bar-fill {
  height: 100%;
  background: #22c55e;
  transition: width 0.3s;
  border-radius: 2px;
}
.elevation-pill {
  position: absolute;
  top: -8px;
  left: -4px;
  background: #eab308;
  color: #000;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid #fff;
  z-index: 41;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
.sneak-icon {
  position: absolute;
  bottom: -10px;
  right: -10px;
  color: #ef4444;
  background: black;
  border: 1px solid #ef4444;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  z-index: 50;
  box-shadow: 0 0 5px #ef4444;
  animation: pulse 2s infinite;
  cursor: help;
}
.flanked-icon {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  color: #eab308;
  background: black;
  border: 1px solid #eab308;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  z-index: 50;
}
@keyframes pulse {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.1);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}
.tool-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  color: #a1a1aa;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
}
.tool-btn:hover {
  background: rgba(255, 255, 255, 0.03);
  color: #f4f4f5;
}
.tool-btn.active {
  background: rgba(59, 130, 246, 0.1);
  border-left-color: var(--accent);
  color: white;
  font-weight: 600;
}
.tool-icon {
  width: 20px;
  text-align: center;
}
.context-panel {
  background: #27272a;
  border: 1px solid #3f3f46;
  border-radius: 6px;
  padding: 12px;
  margin: 0 12px 12px 12px;
  animation: slideIn 0.2s ease-out;
}
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.input-dark {
  background: #09090b;
  border: 1px solid #3f3f46;
  color: white;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  transition: border-color 0.2s;
}
.input-dark:focus {
  border-color: var(--accent);
  outline: none;
}
.path-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 25;
  box-shadow: 0 0 4px #000;
}
.dot-move {
  background: var(--accent);
}
.dot-jump {
  background: #8b5cf6;
}
.dot-invalid {
  background: var(--danger);
}
#tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.95);
  border: 1px solid #52525b;
  color: white;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  display: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  white-space: pre-line;
  max-width: 220px;
}
.floating-menu {
  position: absolute;
  width: 200px;
  z-index: 200;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
}
.hidden-in-normal {
  display: none;
}
body.panoramic .panoramic-show {
  display: block;
}
body.panoramic .panel {
  display: none !important;
}
body.panoramic #panoramic-restore {
  display: flex;
}

.token-name-label {
  position: absolute;
  top: -18px;
  width: 150px;
  text-align: center;
  font-size: 10px;
  font-weight: bold;
  color: white;
  text-shadow: 0 1px 2px black;
  pointer-events: none;
}
.token-hp-text {
  position: absolute;
  right: -35px;
  top: -2px;
  width: 30px;
  font-size: 8px;
  color: #22c55e;
  font-weight: bold;
  text-shadow: 0 1px 1px black;
}
