/* General Styles from index.html */
:root {
  --cell-size: var(
    --dynamic-cell-size,
    40px
  ); /* Fallback to 40px if JS not loaded */
  --grid-gap: 2px;
}
body {
  font-family: sans-serif;
  background-color: #1a1a1a;
  color: #eee;
  display: flex;
  justify-content: center;
  align-items: flex-start; /* Changed from center to flex-start */
  min-height: 100vh; /* Changed from height to min-height */
  margin: 0;
  touch-action: manipulation; /* Disable double-tap to zoom */
  overflow-y: auto; /* Allow vertical scrolling if content overflows */
}
.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 500px;
  padding: 10px;
  box-sizing: border-box;
}
.game-container {
  width: 100%;
  border: 1px solid #555;
  padding: 10px;
  background-color: #222;
  box-sizing: border-box;
  /* position: relative; */ /* REMOVED */
  display: flex; /* NEW: 子要素をflexboxで配置 */
  flex-direction: column; /* NEW: 子要素を縦に並べる */
  align-items: center; /* NEW: 子要素を中央揃え */
}
h1 {
  font-size: 1.5em;
  text-align: center;
  margin-top: 0;
  margin-bottom: 10px;
}
.game-status {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 8px; /* 行間のスペース */
  margin-bottom: 10px;
  margin: 10px;
  padding: 10px;
  border: 1px solid #444;
  font-size: 0.9em;
  background-color: #2a2a2a;
  border-radius: 5px;
}

.status-main {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.item-list {
  line-height: 1.4;
  text-align: left;
}

.item-link, a {
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  color: #a9d7ff; /* A lighter blue to indicate interactivity */
}

.item-link:hover, a:hover {
  color: #ffffff;
}

.game-grid {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}
.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
}
.app-btn {
  background-color: #444;
  color: #eee;
  border: 1px solid #666;
  border-radius: 5px;
  cursor: pointer;
  user-select: none; /* Prevent text selection on tap */
  text-align: center;
}
.control-btn {
  padding: 15px 10px;
  font-size: 1.2em;
  font-weight: bold;
  background-color: #444;
  color: #eee;
  border: 1px solid #666;
  border-radius: 5px;
  cursor: pointer;
  user-select: none; /* Prevent text selection on tap */
  text-align: center;
}
.control-btn:active {
  background-color: #555;
}

.btn-up_left {
  grid-column: 1;
  grid-row: 1;
}
.btn-up_right {
  grid-column: 3;
  grid-row: 1;
}
.btn-down_left {
  grid-column: 1;
  grid-row: 3;
}
.btn-down_right {
  grid-column: 3;
  grid-row: 3;
}
.btn-up {
  grid-column: 2;
  grid-row: 1;
}
.btn-left {
  grid-column: 1;
  grid-row: 2;
}
.btn-inventory {
  grid-column: 2;
  grid-row: 2;
}
.btn-right {
  grid-column: 3;
  grid-row: 2;
}
.btn-down {
  grid-column: 2;
  grid-row: 3;
}

/* Grid styles previously in browser_io.js */
.game-table {
  border-collapse: separate;
  border-spacing: var(--grid-gap);
}

.game-cell, .skeleton td {
  width: var(--dynamic-cell-size);
  height: var(--dynamic-cell-size);
  text-align: center;
  vertical-align: middle;
  cursor: default;
  border-radius: 3px;
  position: relative;
  font-weight: bold;
  color: #ffffff;
  box-sizing: border-box;
}

/* Cell background colors by state */
.game-cell--hidden {
  background-color: #616161;
}
.game-cell--flagged {
  background-color: #616161;
  color: #beb4b4;
} /* Same bg as hidden, reddish-grey for symbol */
.game-cell--revealed {
  background-color: #9e9e9e;
}
.game-cell--trap {
  background-color: #f44336;
}
.game-cell--item {
  background-color: #ffc107;
} /* Yellow */
.game-cell--exit {
  background-color: #4caf50;
} /* Green */
.game-cell--player {
  background-color: #f48fb1;
} /* Light Pink */

/* Spans inside the cell */
.cell-number, .cell-entity, .cell-player-icon {
  position: absolute;
  font-weight: bold;
}

/* Number styling (default is centered) */
.cell-number {
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--dynamic-cell-size) * 0.8);
}

/* Number when player is on the same tile (moves to top-left) */
.cell-number.cell-number--player-present {
  top: 1px;
  left: 3px;
  width: auto;
  height: auto;
  display: inline;
  font-size: calc(var(--dynamic-cell-size) * 0.4);
}

/* Entity (I, E) in corner */
.cell-entity {
  top: 1px;
  right: 3px;
  font-size: calc(var(--dynamic-cell-size) * 0.4);
  color: rgba(255, 255, 255, 0.9);
}

/* Player icon (@) centered */
.cell-player-icon {
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--dynamic-cell-size) * 0.6);
}

/* Pop-up Notification Styles */
.game-popup {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(26, 26, 26, 0.9);
  color: #eee;
  padding: 12px 24px;
  border-radius: 8px;
  border: 1px solid #555;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.5s ease-in-out;
  text-align: center;
  max-width: 90%;
}

.game-popup.fade-out {
  opacity: 0;
}

/* Action Prompt Styles */
.action-prompt {
  padding: 8px;
  margin-bottom: 10px;
  background-color: #333;
  border: 1px solid #555;
  border-radius: 4px;
  text-align: center;
  font-weight: bold;
  /* display: none; is now handled in View Management */
}

/* Flash Red Effect */
.flash-red {
  animation: flashRed 0.2s ease-out;
}

@keyframes flashRed {
  0% {
    background-color: #1a1a1a;
  }
  50% {
    background-color: rgba(255, 0, 0, 0.5);
  }
  100% {
    background-color: #1a1a1a;
  }
}

/* Result Screen Styles */
.result-screen {
  padding: 10px;
  text-align: center;
  display: flex; /* NEW: Flexコンテナとして扱う */
  flex-direction: column; /* NEW: 子要素を縦に並べる */
  align-items: center; /* NEW: 子要素を中央揃えにする (任意) */
  background-color: transparent; /* 半透明の背景を透明に */
  margin-top: 20px; /* 盤面との間にスペースを設ける */
}

.result-screen h2 {
  margin-top: 0;
  font-size: 1.5em;
  margin-bottom: 15px;
}

.result-screen div {
  margin-bottom: 8px;
}

.floor-revelation-rates {
  margin-top: 15px; /* 上の要素との間にスペースを設ける */
}

.result-screen ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.result-screen li {
  margin-bottom: 4px;
}

.btn-reset {
  padding: 10px 20px;
  font-size: 1.2em;
  background-color: #4caf50;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  margin-top: 20px;
}

.btn-reset:hover {
  background-color: #45a049;
}

/* Modal Dialog Styles */
.modal-content::backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.modal-content {
  background-color: #2c2c2c;
  padding: 25px;
  border-radius: 8px;
  border: 1px solid #777;
  text-align: center;
  max-width: 80%;
  max-width: 400px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
  margin-top: 0;
  color: #ffc107; /* Yellow to match item color */
}

.modal-content p {
  margin-bottom: 20px;
  color: #eee;
}

.modal-content button {
  padding: 10px 20px;
  font-size: 1em;
  background-color: #4caf50;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.modal-content button:hover {
  background-color: #45a049;
}
.status-achieved {
  color: #4caf50;
}

.status-not-achieved {
  color: #f44336;
}

/* --- Confirmation Dialog Overlay --- */
.confirm-dialog-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 150;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
  text-align: center;
}

.confirm-dialog-screen .confirm-prompt-message {
  font-size: 1.2em;
  color: #ffc107;
  margin-bottom: 25px;
}

.confirm-dialog-screen .confirm-buttons {
  display: flex;
  flex-direction: column; /* Arrange buttons vertically */
  gap: 15px; /* Adjust gap for vertical layout */
  width: 60%;
  max-width: 200px;
}

/* --- Inventory Screen as an Overlay --- */
.inventory-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 100;
  display: none; /* Initially hidden */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
}

p, ul {
  margin: 0;
}
ul {
  padding-left: 16px;
}

.skeleton td:nth-child(1) {
  animation: 1s ease-in 0.5s infinite both skeletonPulse;
}
.skeleton td:nth-child(2) {
  animation: 1s ease-in 0.6s infinite both skeletonPulse;
}
.skeleton td:nth-child(3) {
  animation: 1s ease-in 0.7s infinite both skeletonPulse;
}
.skeleton td:nth-child(4) {
  animation: 1s ease-in 0.8s infinite both skeletonPulse;
}
.skeleton td:nth-child(5) {
  animation: 1s ease-in 0.9s infinite both skeletonPulse;
}
.skeleton td:nth-child(6) {
  animation: 1s ease-in 1.0s infinite both skeletonPulse;
}
.skeleton td:nth-child(7) {
  animation: 1s ease-in 1.1s infinite both skeletonPulse;
}
.skeleton td:nth-child(8) {
  animation: 1s ease-in 1.2s infinite both skeletonPulse;
}

@keyframes skeletonPulse {
  0% {
    background-color: #616161;
  }
  50% {
    background-color: #9e9e9e;
  }
  100% {
    background-color: #616161;
  }
}

footer {
  padding: 10px;
  margin-top: 32px;
}
