.main_window {
  display: grid;
  position: relative;
  top: 0px;
  left: 0px;
  height: 100%;
  background-color: black;
  grid-template-columns: 160px auto;
  grid-gap: 0;
}

.left_menu {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  height: 100%;
  grid-row-start: 1;
  grid-row-end: 3;
}

/* Pinned to the bottom of the pane via margin-top: auto; styled to match
   .help_dismiss_hint so the two hints read as the same UI element. */
.instructions {
  color: white;
  opacity: 0.7;
  font-style: italic;
  margin-top: auto;
  margin-bottom: 20px;
  margin-left: 10px;
}

.debuginfo {
  color: white;
  margin-top:15px;
  margin-left:10px;
}

/* Bottom bar under the map, showing the last few Game.Messages entries (e.g. stair transitions).
   Fixed to the viewport rather than flowing after the map grid - the grid's height depends on
   window size/tile size (ASCII vs graphics), so a normal in-flow position can end up pushed below
   the fold. pointer-events: none so it never blocks clicks on the map underneath. */
.message_log {
  position: fixed;
  left: 160px;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
  padding: 4px 10px;
  color: white;
  opacity: 0.85;
  font-size: 0.9em;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
  z-index: 10;
}

.message_log_entry {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* One-line confirmation shown while a lava step is pending (see awaitingLavaConfirm in
   GamePage.razor). Sits just above the message log, aligned with the map area. */
.hazard_prompt {
  position: fixed;
  left: 160px;
  right: 0;
  bottom: 40px;
  padding: 4px 10px;
  text-align: center;
  color: #ffcf3f;
  font-weight: bold;
  text-shadow: 0 0 6px black, 1px 1px 2px black;
  pointer-events: none;
  z-index: 11;
}

/* Icon-based stat rows (see div[data-tool-tip] tooltip rules below for the hover explainer). */
.stat-icon {
  display: flex;
  align-items: center;
  gap: 0.3em;
  position: relative;
  height: 53px;
}

.stat-icon-img {
  width: 3.8em;
  height: 3.8em;
  image-rendering: pixelated;
}

/* ASCII-mode counterpart to .stat-icon: plain text, no images, to match the ASCII renderer's look. */
.stat-text {
  display: flex;
  justify-content: space-between;
  width: 145px;
  height: 1.5em;
  color: white;
}

/* Health bar: layered pixel-art blood meter built from the blood_meter_* sprites in the tileset
   atlas (see Rendering/SpriteAtlas.cs). Pieces are absolutely positioned, right-aligned, inside
   this fixed-size relative container so the meter drains from right to left as Wounds falls below
   MaxWounds. Rendered at 2x the assets' native size (48x16 -> 96x32) with pixelated
   image-rendering to keep the pixel art crisp. */
.health-bar {
  position: relative;
  width: 96px;
  height: 32px;
  flex-shrink: 0;
}

.health-bar-base,
.health-bar-cap,
.health-bar-marker,
.health-bar-strip-unit {
  image-rendering: pixelated;
}

.health-bar-base {
  position: absolute;
  left: 0;
  top: 0;
  width: 96px;
  height: 32px;
}

/* blood_meter_empty_right_end sprite is shaped to replace the bar's rounded right corner, so it
   sits flush at the bar's rightmost position as soon as any wound is lost - the first visual
   sliver. */
.health-bar-cap {
  position: absolute;
  right: 0;
  top: 0;
  width: 8px;
  height: 32px;
}

/* blood_meter_strip_full_right_end sprite bridges the seam between the tiled empty strips and
   whatever plain fill remains, positioned inline per-render at the far edge of that tiled run. */
.health-bar-marker {
  position: absolute;
  top: 0;
  width: 2px;
  height: 32px;
}

/* Repeatable drained strip: one .health-bar-strip-unit div per 2px-wide repeat (see
   GamePage.razor), laid out edge-to-edge instead of a single div background-repeat-tiling a
   standalone image - background-repeat would tile the *whole* shared atlas sheet at a 2px
   interval, smearing neighbouring sprites across the strip rather than repeating this one small
   sub-region of it. Sits just left of the fixed cap. */
.health-bar-strip {
  position: absolute;
  right: 8px;
  top: 0;
  height: 32px;
  display: flex;
}

.health-bar-strip-unit {
  width: 2px;
  height: 32px;
  flex-shrink: 0;
}

.map {
  display: grid;
  position: relative;
  top: 0px;
  left: 0px;
  bottom: 0px;
  right: 0px;
  height: 100%;
  background-color: black;
  grid-gap: 0px;
}

.cell {
  display: flex;
  position: relative;
  background-size: cover;
  grid-row: span 1;
  grid-column: span 1;
}

.tile {
  display: flex;
  position: absolute;
  width: 100%;
  height: 100%;
  justify-content: center;
  /* background-image/size/position come from the element's .spr-<key> (or, for an animated tile,
     .animated_<key>) class - see Rendering/SpriteAtlas.cs - which scales the tileset art to
     whatever the current cell size is (graphicGridTileSize / the +/- zoom in GamePage.razor)
     instead of rendering it 1:1 and clipping when zoomed out. */
  /* Keep the pixel art crisp when it isn't at 1:1 - browser zoom, OS display scaling, or the
     in-game zoom. Matches the UI sprites, which already opt in (see .stat-icon-img etc.). */
  image-rendering: pixelated;
}

.decoration {
  display: flex;
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0px;
  top: 0px;
  /* Same as .tile: background-image/size/position come from .spr-<key>/.animated_<key>. */
  image-rendering: pixelated;
  justify-content: center;
  /* Decorations only exist to be looked at - the game has no click-to-interact step - so by
     default they must not intercept the pointer. Without this, a decoration with no tooltip of
     its own (e.g. a wall bled upward via VerticalOffset to sit in front of the tile above it)
     can sit on top of a lower-layered decoration that DOES have a tooltip and steal :hover from
     it, so the tooltip beneath never triggers. Re-enabled below for decorations that actually
     have a tooltip, so hovering the topmost tooltip-bearing decoration still works normally. */
  pointer-events: none;
}

.decoration[data-tool-tip] {
  pointer-events: auto;
}

.decoration-ascii {
  background-color: black;
}

/* Freezes a sprite animation on one frame - see Decoration.AnimationPaused. */
.animation-paused {
  animation-play-state: paused;
}

.outoffov {
  filter: brightness(50%);
}

.lit {
  filter: brightness(120%);
}

.decinfront {
  z-index: 3;
}

.decmiddle {
  z-index: 2;
}

.decbehind {
  z-index: 1;
}

.interact_button {
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0px;
  top: 0px;
  background: transparent;
  border: none;
  color: transparent;
  z-index: 3;
}

.toggle_button {
  background-color: #4a6259;
  border: black;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  width: 145px;
  margin-top: 5px;
  margin-left: 5px;
  margin-right: 5px;
  margin-bottom: 5px;
  border-radius: 2px;
}

.toggle_button:hover {
  color: white;
}

/* Once the game is over, starting a new one is the only thing left to do - so draw the eye to it. */
.toggle_button.highlighted {
  background-color: #e56634;
  animation: newgamepulse 1.4s ease-in-out infinite;
}

@keyframes newgamepulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.7);
  }

  50% {
    box-shadow: 0 0 0 9px rgba(255, 82, 82, 0);
  }
}

/* Dimmed while the game is over, since the keys it documents no longer do anything. */
.instructions_disabled {
  opacity: 0.4;
}

/* Sits at the bottom of the play area, above decorations (z-index 3) and tooltips (5). */
.game_over {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 0.15em 0;
  text-align: center;
  font-size: 3em;
  font-weight: bold;
  letter-spacing: 0.05em;
  color: #e56634;
  text-shadow: 0 0 6px black, 2px 2px 3px black;
  background-color: rgba(0, 0, 0, 0.65);
  pointer-events: none;
}

/* ?-triggered help overlay: any keypress or a backdrop click dismisses it (see KeyUp/CloseHelp
   in GamePage.razor). Sits above .game_over (z-index 10) and tooltips (z-index 5). */
.help_backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.help_modal {
  background-color: #222;
  color: white;
  padding: 1.1em 1.4em;
  border-radius: 6px;
  max-width: 470px;
  max-height: 80vh;
  overflow-y: auto;
}

/* Two-column key/action grid: keys align in a single column down the left, the group labels
   ("Items", "View") span the full width as lightweight separators. Replaces the old per-section
   <h3> + <dl> layout, which stacked three lines (heading, term, description) per shortcut. */
.help_grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 1.25em;
  row-gap: 0.3em;
  align-items: baseline;
}

.help_key {
  font-weight: 700;
  white-space: nowrap;
}

.help_group {
  grid-column: 1 / -1;
  margin: 0.7em 0 0.15em;
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.55;
}

/* Key-cap styling for the shortcut letters in both the help overlay and the inventory modal. */
.help_modal kbd,
.instructions kbd {
  display: inline-block;
  min-width: 1em;
  margin: 0 0.05em;
  padding: 0 0.3em;
  border: 1px solid #555;
  border-bottom-width: 2px;
  border-radius: 3px;
  background-color: #333;
  font-family: inherit;
  font-size: 0.85em;
  line-height: 1.4;
  text-align: center;
}

.help_dismiss_hint {
  margin-top: 0.6em;
  opacity: 0.7;
  font-style: italic;
  font-size: 0.9em;
}

/* Inventory list inside the .help_modal. Each row is prefixed with the item's sprite (tileset
   mode) or its coloured ASCII glyph (ASCII mode) - see the inventory modal in GamePage.razor. */
.inventory_list {
  list-style: none;
  padding: 0;
  margin: 0.5em 0;
}

.inventory_row {
  display: flex;
  align-items: center;
  gap: 0.5em;
  line-height: 28px;
}

.inventory_icon {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
}

.inventory_glyph {
  display: inline-block;
  width: 28px;
  text-align: center;
  font-weight: bold;
  flex-shrink: 0;
}

  /* Tooltips */
div [data-tool-tip]::after {
  content: attr(data-tool-tip);
  display: block;
  position: absolute;
  color: black;
  background-color: burlywood;
  border-radius: 5px;
  font-size: 0.9em;
  padding: 0.1em;
  bottom: 100%;
  left: 0;
  white-space: nowrap;
  visibility: hidden;
  z-index: 5;
}

div[data-tool-tip]:hover::after {
  visibility: visible;
}

/* A decoration's own z-index (decinfront/decmiddle/decbehind) gives its ::after tooltip a
   stacking context scoped to that layer, so a higher-layered decoration elsewhere on the map -
   notably an offset one bleeding into this tile - can still cover the tooltip despite its
   z-index: 5. Boosting the hovered decoration itself above everything (including .game_over's 10)
   lifts its whole stacking context, tooltip included, above every other tile's decorations. */
div[data-tool-tip]:hover {
  z-index: 1000;
}
