/* style.css */

@font-face {
  font-family: 'VT323';
  src: url('fonts/VT323-Regular.ttf') format('truetype');
}

body {
  font-family: 'VT323', sans-serif;
  background-color: #111;
  color: #eee;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  background-color: #000;
}

#mobile-controls {
  display: none;
}

@media (pointer: coarse) and (max-width: 800px) {
  #mobile-controls {
    display: block !important;
  }
  .move-btn {
    font-size: 1.5rem;
    padding: 4px 8px;
    margin: 2px;
    border-radius: 6px;
    border: 2px solid #444;
    background: #222;
    color: #fff;
    font-family: 'VT323', monospace;
    cursor: pointer;
    width: 48px;
  }
  .move-btn:active {
    background: #444;
  }
}

#main-game {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #222; /* dark gray background */
  color: #fff; /* white text for contrast */
  padding: 0px;
  min-width: fit-content;
  max-width: 100%;
}

/* Toggle Stats Button */
#toggle-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 32px;
  margin: 10px auto 0 auto;
  padding: 2px 2px;
  font-family: 'VT323', monospace;
  font-size: 1rem;
  border: 2px solid black;
  background: white;
  color: black;
  cursor: pointer;
  border-radius: 1px;
  transition: background 0.2s, color 0.2s;
}

#toggle-stats:hover {
  background: black;
  color: white;
}

#magic-menu {
  max-width: 350px;           /* Match your game/log/encounter width */
  background: #222;
  color: #fff;
  padding: 12px;
  border-radius: 8px;
  box-sizing: border-box;
  overflow-x: auto;
  word-break: break-word;     /* Ensures long text wraps */
}

.runes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

#spell-result {
  word-break: break-word;
  white-space: pre-line;
  max-width: 100%;
}

#magic-menu-btn {
  font-family: 'VT323', monospace;
  font-size: 1rem;
  width: 32px;
  padding: 2px 2px;
  border: 2px solid black;
  background: white;
  color: black;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

#magic-menu-btn:hover {
  background: black;
  color: white;
}

#magic-menu-btn img {
  height: 24px;
  width: 24px;
  vertical-align: middle;
}

.rune-btn {
  background: #333;
  border: 2px solid #666;
  border-radius: 6px;
  padding: 2px;
  cursor: pointer;
  transition: border 0.2s;
}
.rune-btn img {
  display: block;
}
.rune-btn:active {
  border: 2px solid #f80;
}

#game {
  display: grid;
  grid-template-columns: repeat(5, 64px);
  grid-template-rows: repeat(5, 64px);
  gap: 2px;
  background-color: #222; /* white background */
  padding: 0px;
  border: 20px solid black;
  width: max-content;
  user-select: none;
  font-family: 'VT323', sans-serif;
}

/* Each cell in the grid */
.cell {
  width: 64px;
  height: 64px;
  box-sizing: border-box;
  border: 0px solid black;
  background-color: white;
  color: black;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  font-size: 24px;
  cursor: default;
  user-select: none;
}

/* Player cell styling: inverted colors for emphasis */
@keyframes blinkPlayer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes blinkBorder {
  0%, 100% { border-color: yellow; }
  50% { border-color: transparent; }
}

.cell.current {
  position: relative;
  animation: blinkBorder 1s infinite;
  border: 2px solid yellow;
  box-sizing: border-box;
}

.cell.player-icon {
  position: absolute;
  top: 2px;
  left: 2px;
  z-index: 2;
  font-weight: bold;
  color: white;
  animation: blinkPlayer 1s infinite;
  pointer-events: none;
}

/* Enemy cell */
.cell.enemy {
  background-color: white;
  color: black;
  font-weight: bold;
}

/* Gold cell */
.cell.gold {
  background-color: white;
  color: black;
  font-weight: bold;
}

.cell.store {
  background-color: white;
  color: black;
  font-weight: bold;
}

/* Healing potion cell */
.cell.heal {
  background-color: white;
  color: black;
  font-weight: bold;
}

.cell.wall {
  background-color: black;
  color: black;
  cursor: default;
}

.cell.fog {
  color: black;
  background-color: #444; /* Dim gray */
}

.cell.visited {
  background-color: white;
  color: black;
}

.tile-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}


.tile-icon-player {
  width: 56px;
  height: 56px;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

#equipment {
  margin-top: 10px;
  border: 2px solid black;
  padding: 10px;
  background: white;
  color: black;
  min-height: 60px;
}

.equipment-slot {
  margin-bottom: 6px;
  padding: 4px;
  border: 1px solid black;
  background: #eee;
  color: black;
  font-size: 0.9rem;
}

/* Inventory container */
#inventory {
  margin-top: 10px;
  border: 2px solid black;
  padding: 10px;
  background: white;
  color: black;
  min-height: 50px;
}

/* Inventory items */
.inventory-item {
  cursor: pointer;
  padding: 3px 6px;
  margin-bottom: 4px;
  border: 1px solid black;
  background: white;
  color: black;
  user-select: none;
}

.inventory-icon {
  width: 16px;
  height: 16pxx;
}

.inventory-item:hover {
  background: black;
  color: white;
}

#info-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-top: 10px;
  width: 100%;
  max-width:  350px;/* Limit overall width */
}

/* Familiar area styles */
#familiar-area {
  display: flex;
  flex-direction: row;
  align-items: center;
  margin-right: 16px;
  margin-bottom: 10px;
  width: 350px;
  min-height: 64px;
  max-height: 100px;
  
}

#familiar-img-wrapper {
  position: relative;
  width: 64px;
  height: 64px;
}

#familiar-img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin-bottom: 6px;
}

.familiar-chat {
  min-height: 32px;
  max-width: 350px;
  background: #fffbe6;
  color: #222;
  border: 1px solid #999;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.95rem;
  text-align: center;
  box-shadow: 1px 2px 4px rgba(0,0,0,0.08);
  word-break: break-word;
}

/* Stats display */
#stats {
  margin-top: 10px;
  font-size: 0.8rem;
  border: 2px solid black;
  padding: 4px;
  background: white;
  color: black;
  flex: 1;
}

/* Log display */
#log {
  font-size: 0.9rem;
  margin-top: 10px;
  max-height: 120px;
  width: 350px;
  overflow-y: auto;
  border: 2px solid black;
  padding: 6px 10px;
  background: white;
  color: black;
  white-space: pre-line;
  user-select: none;
  flex: 1;
}

#encounter-area {
  border: 2px solid black;
  background: white;
  color: black;
  padding: 2px;
  width: 350px;
  margin-top: 10px;
  min-height: 50px;
    display: none; /* hidden by default */
}

.encounter-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: bold;
  background: white;
  color: black;
  padding: 0px;
  border-bottom: 1px solid #ccc;
}

.encounter-shoprow {
  display: flex;
  align-items: center;
  justify-content: space-between; /* Add this line */
  gap: 0.3rem;
  font-weight: normal;
  background: white;
  color: black;
  padding: 4px;
  border-bottom: 1px solid #ccc;
}

.encounter-icon {
  font-size: 1.2rem;
}

/* Enemy and player icons */
.encounter-enemy,
.encounter-player {
  font-size: 1rem;
  text-align: center;
  color: black;
  margin-bottom: 5px;
}

/* HP bars */
.encounter-hp {
  text-align: center;
  margin-bottom: 10px;
}

/* Buttons */
.encounter-button {
  font-family: 'VT323', monospace;
  font-size: 1rem;         /* or try 0.9rem or 14px for smaller text */
  cursor: pointer;
  padding: 1px 2px;
  margin-right: 4px;
  border: 1px solid black;
  background: white;
  color: black;
  border-radius: 2px;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.encounter-button:hover {
  background: black;
  color: white;
}

.encounter-enemy-icon {
  width: 48px;
  height: 48px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 6px;
}


.store-items-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  max-height: 140px;
  overflow-y: auto;
  margin-bottom: 10px;
  font-weight: normal;
}

.store-item {
  min-width: 0;
  word-break: break-word;
  font-size: 0.9rem;
}

/* Skill point menu grid for buttons */
.skill-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
  justify-content: center;
  align-items: center;
}

/* Optional: style for the stats summary in the menu */
.skill-stats-summary {
  display: grid;
  justify-content: center;
  align-items: center;
  text-align: center;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  margin: 8px 0 0 0;
}


#game-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  z-index: 10;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
}

#game-overlay img {
  max-width: 350px;
  max-height: 350px;
  border: 0px solid #fff;
  border-radius: 0px;
  box-shadow: 0 0 24px #000;
}


#game-container {
  position: relative;
  display: inline-block;
  /* Optionally, set a fixed size to match your frame image */
  width: 372px; /* or whatever matches your frame */
  height: 372px;
}

#game-frame {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 2;
}

#game {
  position: relative;
  z-index: 1;
  /* Optionally, add padding so the grid doesn't touch the frame edge */
  /* margin: 24px;*/
}