/*.sidebar {
  width: 160px;
  background: #222;
  padding: 10px;
  box-sizing: border-box;
  border-right: 2px solid #444;
  display: flex;
  flex-direction: column;
  gap: 10px;
  user-select: none;
  overflow-y: auto;
}
.sidebar h2 {
  margin: 0 0 10px 0;
  font-size: 18px;
  text-align: center;
  flex-shrink: 0;
}
.sidebar p {
  font-size: 12px;
  margin: 0 0 10px 0;
  flex-shrink: 0;
}*/
.item-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-grow: 1;
  overflow-y: auto;
  padding-bottom: 10px;
}
.item {
  width: 48px;
  height: 48px;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #333;
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
  user-select: none;
}
.item.selected {
  border-color: #00c8ff;
  box-shadow: 0 0 8px #00c8ff;
}
.item img {
  max-width: 36px;
  max-height: 36px;
  pointer-events: none;
  user-select: none;
}
/* Container for grid + centering & overflow scroll */
.grid-wrapper {
  flex-grow: 1;
  display: flex; /* flex for centering */
  justify-content: center;
  align-items: center;
  background-color: #333;
  position: relative;
  user-select: none;
  overflow: auto;
  cursor: default;
}
/* Wrapper to hold the grid and zoom */
.grid-container {
  position: relative;
  display: grid;
  grid-template-columns: repeat(20, 32px);
  grid-template-rows: repeat(20, 32px);
  gap: 0px;
  background-color: #333;
  transform-origin: 0 0; /* top-left for zoom origin */
  will-change: transform;
  background-repeat: no-repeat;
  background-position: top left;
  background-size: 100% 100%;
}

.cell {
  width: 30px;
  height: 30px;
  background-color: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  position: relative;
}
.token {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  position: absolute;
  cursor: grab;
  user-select: none;
  box-shadow: none;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  z-index: 10;
  background-color: transparent;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.token.dragging {
  cursor: grabbing;
  border-color: #00c8ff;
  box-shadow: 0 0 8px #00c8ffcc;
  z-index: 1000;
}
.token img {
  max-width: 100%;
  max-height: 100%;
  pointer-events: none;
  user-select: none;
  background-color: #000000; /* shown while image is loading */
}
.token img[src] {
  background-color: transparent;
}
.instructions {
  color: #888;
  font-size: 12px;
  margin-top: auto;
  text-align: center;
  user-select: none;
}
.cell.hovered {
  outline: 2px solid #00c8ff88;
}
.grid-wrapper {
  flex-grow: 1;
  position: relative;
  overflow: hidden;
  background-color: #333;
  cursor: grab;
}
.grid-container {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  will-change: transform;
}
#draw-layer {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none; /* unless drawing */
  z-index: 100;
  transform-origin: top left;
}
#pencil-btn {
  background: #444;
  color: #eee;
  border: 1px solid #666;
  padding: 6px;
  cursor: pointer;
  font-size: 14px;
  border-radius: 4px;
}
#pencil-btn.active {
  background: #00c8ff;
  color: black;
}

#turn-indicator {
  position: fixed;
  top: 20px;
  left: 320px;
  width: 80px;
  overflow: hidden;
  z-index: 500;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 12px;
  transition: height 0.4s ease;
}

#turn-header {
  text-align: center;
  font-size: 14px;
  font-weight: bold;
  padding: 6px;
  background: rgba(0, 0, 0, 0.8);
  border-bottom: 1px solid #444;
  color: #fff;
  cursor: pointer;
  user-select: none;
  position: relative;
  z-index: 600;
}

/* Expanded view (7 entries) */
#turn-indicator.expanded {
  height: 440px; /* header (30–40px) + 7 entries */
}

/* Collapsed view (only 1 entry) */
#turn-indicator.collapsed {
  height: 140px; /* header + 1 entry */
}

#turn-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: center;
}


.turn-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease,
    filter 0.3s ease;
  transform-origin: center;
}

.turn-entry img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: #444;
}

.turn-entry span {
  margin-top: 4px;
  font-size: 12px;
  color: #fff;
  text-align: center;
  max-width: 100px;
  word-wrap: break-word;
}

.turn-entry.current {
  font-weight: bold;
  border: 2px solid #00c8ff;
  border-radius: 10%;
  padding: 4px;
}

/* Distance-based scaling and fading */
.turn-entry[data-offset="-3"],
.turn-entry[data-offset="3"] {
  opacity: 0.2;
  transform: scale(0.75);
  filter: blur(1px);
}
.turn-entry[data-offset="-2"],
.turn-entry[data-offset="2"] {
  opacity: 0.4;
  transform: scale(0.85);
  filter: blur(0.5px);
}
.turn-entry[data-offset="-1"],
.turn-entry[data-offset="1"] {
  opacity: 0.7;
  transform: scale(0.95);
  filter: none;
}
.turn-entry[data-offset="0"] {
  opacity: 1;
  transform: scale(1);
  filter: none;
}
#combat-list .combat-entry.drag-over {
  border-top: 2px solid #00c8ff;
}

/* Ensure entries have a baseline border so border-color can transition */
.turn-entry {
  display: flex;
  flex-direction: column;
  align-items: center;

  /* animate layout and visuals */
  transition:
    transform 320ms cubic-bezier(.2,.9,.2,1),
    opacity 320ms cubic-bezier(.2,.9,.2,1),
    filter 320ms cubic-bezier(.2,.9,.2,1),
    border-color 320ms cubic-bezier(.2,.9,.2,1),
    box-shadow 320ms cubic-bezier(.2,.9,.2,1);

  transform-origin: center;

  /* baseline transparent border so color can animate */
  border: 2px solid transparent;
  border-radius: 10%;
  padding: 6px;
}

/* current entry visual (will animate from transparent -> blue) */
.turn-entry.current {
  font-weight: bold;
  border-color: #00c8ff;
  box-shadow: 0 0 10px #00c8ff66;
}

/* keep your distance-based scaling styles (unchanged) */
.turn-entry[data-offset="-3"],
.turn-entry[data-offset="3"] { opacity: 0.2; transform: scale(0.75); filter: blur(1px); }
.turn-entry[data-offset="-2"],
.turn-entry[data-offset="2"] { opacity: 0.4; transform: scale(0.85); filter: blur(0.5px); }
.turn-entry[data-offset="-1"],
.turn-entry[data-offset="1"] { opacity: 0.7; transform: scale(0.95); filter: none; }
.turn-entry[data-offset="0"] { opacity: 1; transform: scale(1); filter: none; }
