/* ═══════════════════════════════════════════
   GRID & CELLS
   ═══════════════════════════════════════════ */
.grid-wrap {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--grid-cols), var(--cell-size));
  grid-template-rows: repeat(var(--grid-cols), var(--cell-size));
  gap: var(--cell-gap);
  z-index: var(--z-grid);
  padding: 6px;
  background: rgba(6, 6, 18, 0.75);
}

/* ─── Cells ─── */
.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell-size) * 0.5);
  border-radius: var(--cell-radius);
  transition: background var(--t-fast), box-shadow var(--t-fast);
  position: relative;
}

/* SVG icons inside cells */
.cell svg.gi {
  width: calc(var(--cell-size) * 0.55);
  height: calc(var(--cell-size) * 0.55);
  filter: drop-shadow(0 0 3px currentColor);
}

/* Walls — textured brick/stone */
.cell--wall {
  background: var(--wall-texture), linear-gradient(145deg, var(--c-wall-light) 0%, var(--c-wall) 50%, var(--c-wall-dark) 100%);
  background-size: var(--cell-size) var(--cell-size), 100% 100%;
  border: 1px solid var(--c-wall-edge);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    inset 0 -2px 4px rgba(0,0,0,0.6),
    0 1px 3px rgba(0,0,0,0.4);
}

/* Wall cracks — appear on deeper floors */
.cell--wall-cracked { position: relative; }

.cell--wall-cracked::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 60% 60%;
}

.cell--wall-cracked[data-crack="1"]::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23887799' stroke-width='0.8'%3E%3Cpath d='M8 2L10 8L7 12L11 16L9 22'/%3E%3C/svg%3E");
}

.cell--wall-cracked[data-crack="2"]::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23887799' stroke-width='0.8'%3E%3Cpath d='M12 1L10 7L14 11L11 17L13 23'/%3E%3Cpath d='M10 7L6 10'/%3E%3C/svg%3E");
}

.cell--wall-cracked[data-crack="3"]::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23887799' stroke-width='0.8'%3E%3Cpath d='M6 3L9 9L7 14L10 20'/%3E%3Cpath d='M9 9L15 7L17 12'/%3E%3C/svg%3E");
}

/* Floors — subtle stone tile */
.cell--floor {
  background: var(--floor-texture);
  background-size: var(--cell-size) var(--cell-size);
  border: 1px solid var(--c-floor-edge);
}

/* Visited floor — scuff marks from passage */
.cell--visited {
  background:
    radial-gradient(circle, rgba(168, 85, 247, 0.22) 15%, transparent 55%),
    var(--floor-texture) !important;
  background-size: 100% 100%, var(--cell-size) var(--cell-size);
}

/* Fog — dark abyss with noise */
.cell--fog {
  background: var(--fog-texture), var(--fog-color) !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

.cell--fog * { visibility: hidden; }

.cell--player {
  background: var(--floor-texture);
  background-size: var(--cell-size) var(--cell-size);
  z-index: 2;
  box-shadow:
    0 0 14px var(--c-accent-glow),
    0 0 4px rgba(168, 85, 247, 0.6),
    inset 0 0 10px rgba(168, 85, 247, 0.2);
  border: 1px solid rgba(168, 85, 247, 0.4);
}

.cell--portal {
  background: radial-gradient(circle, rgba(168, 85, 247, 0.15) 0%, transparent 70%),
              var(--floor-texture);
  background-size: 100% 100%, var(--cell-size) var(--cell-size);
  animation: portal-pulse 2s ease-in-out infinite;
  z-index: 2;
}

.cell--portal svg.gi {
  width: calc(var(--cell-size) * 0.65);
  height: calc(var(--cell-size) * 0.65);
  animation: portal-icon-breathe 2s ease-in-out infinite;
  filter: drop-shadow(0 0 6px currentColor);
}

@keyframes portal-pulse {
  0%, 100% {
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.4),
                0 0 30px rgba(168, 85, 247, 0.15),
                inset 0 0 10px rgba(168, 85, 247, 0.2);
    border-color: rgba(168, 85, 247, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.7),
                0 0 50px rgba(168, 85, 247, 0.25),
                0 0 8px rgba(139, 92, 246, 0.9),
                inset 0 0 16px rgba(168, 85, 247, 0.4);
    border-color: rgba(168, 85, 247, 0.6);
  }
}

@keyframes portal-icon-breathe {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
}

/* ─── Player portrait on grid ─── */
.cell__portrait {
  position: relative;
  z-index: 1;
  border-radius: 4px;
  filter: drop-shadow(0 0 3px rgba(255,255,255,0.3));
}

/* ─── Boss ─── */
.cell--boss {
  z-index: 2;
  animation: boss-pulse 2.5s ease-in-out infinite;
}

.cell--boss svg.gi {
  width: calc(var(--cell-size) * 0.65);
  height: calc(var(--cell-size) * 0.65);
  filter: drop-shadow(0 0 6px currentColor);
}

.cell--boss-aura {
  background: radial-gradient(circle, rgba(255, 69, 0, 0.12) 0%, transparent 80%),
              var(--floor-texture);
  background-size: 100% 100%, var(--cell-size) var(--cell-size);
  border-color: rgba(255, 69, 0, 0.15);
}

@keyframes boss-pulse {
  0%, 100% {
    box-shadow: 0 0 10px rgba(255, 69, 0, 0.4),
                inset 0 0 8px rgba(255, 69, 0, 0.15);
    border-color: rgba(255, 69, 0, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 69, 0, 0.7),
                0 0 40px rgba(255, 69, 0, 0.2),
                inset 0 0 14px rgba(255, 69, 0, 0.3);
    border-color: rgba(255, 69, 0, 0.5);
  }
}

/* Exit name label below icon */
.cell__label {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.45rem;
  font-family: var(--font-ui);
  color: var(--c-accent);
  white-space: nowrap;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  letter-spacing: 0.3px;
  opacity: 0.8;
}
