* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* 全体の高さ: ビューポートに収まる最大値 */
  /* 幅の比率: イメージ(4:3) + サイドパネル(1:2) = 4/3 + 1/2 = 11/6 */
  --game-height: min(100vh, 100vw * 6 / 11);
}

body {
  background-color: #1a1a2e;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: sans-serif;
}

.game-container {
  display: flex;
  flex-direction: row;
  gap: 0;
  padding: 0;
}

#dungeon-view {
  position: relative;
  width: calc(var(--game-height) * 4 / 3);
  height: var(--game-height);
  background-color: #000;
  overflow: hidden;
}

#sequence-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
  transform: scale(1.05);
}

#loading-indicator {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 1.2rem;
}

#side-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

#minimap {
  background-color: #2a2a4e;
  border: none;
  width: calc(var(--game-height) / 2);
  height: calc(var(--game-height) / 2);
}

#info-panel {
  background-color: #1a1a2e;
  border: none;
  padding: 12px;
  color: #0f0;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.8;
  width: calc(var(--game-height) / 2);
  height: calc(var(--game-height) / 2);
  overflow-y: auto;
}

#info-content {
  white-space: pre-line;
}

#debug-overlay {
  display: none;
  background-color: #2a2a4e;
  border: none;
  padding: 12px;
  color: #fff;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.6;
  width: calc(var(--game-height) / 2);
  height: calc(var(--game-height) / 2);
  overflow-y: auto;
}

#debug-overlay.visible {
  display: block;
}

#info-panel.hidden {
  display: none;
}

#debug-position {
  font-size: 14px;
  font-weight: bold;
  color: #4ecdc4;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #444;
}

#debug-pattern {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #444;
}

#debug-pattern .pattern-name {
  font-size: 16px;
  font-weight: bold;
  color: #f39c12;
}

#debug-pattern .pattern-explain {
  color: #aaa;
  margin-top: 4px;
}

#debug-walls {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #444;
}

#debug-walls .wall-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  text-align: center;
  margin-top: 4px;
}

#debug-walls .wall-cell {
  padding: 4px;
  border-radius: 3px;
}

#debug-walls .wall-cell.floor {
  background-color: #27ae60;
  color: #fff;
}

#debug-walls .wall-cell.wall {
  background-color: #c0392b;
  color: #fff;
}

#debug-walls .wall-cell.player {
  background-color: #3498db;
  color: #fff;
}

#debug-legend {
  color: #888;
  font-size: 11px;
}

#debug-legend .legend-title {
  color: #aaa;
  margin-bottom: 4px;
}

#debug-legend .legend-item {
  margin-left: 8px;
}

/* Bump effects */
.bump-forward {
  animation: bumpForward 0.2s ease-out;
}

.bump-backward {
  animation: bumpBackward 0.2s ease-out;
}

@keyframes bumpForward {
  0% { transform: scale(1.05); }
  50% { transform: scale(1.10); }
  100% { transform: scale(1.05); }
}

@keyframes bumpBackward {
  0% { transform: scale(1.05); }
  50% { transform: scale(1.0); }
  100% { transform: scale(1.05); }
}

/* Mobile responsive */
@media (max-width: 768px) {
  body {
    align-items: flex-start;
  }

  .game-container {
    flex-direction: column;
    align-items: stretch;
    width: 100vw;
    height: 100vh;
    padding: 0;
    gap: 0;
  }

  #side-panel {
    flex-direction: row;
    order: -1;
    gap: 0;
    flex-shrink: 0;
  }

  #minimap {
    width: 50vw !important;
    height: 50vw !important;
    border: none;
  }

  #info-panel {
    width: 50vw;
    height: 50vw;
    border: none;
    overflow: hidden;
    font-size: 11px;
    padding: 8px;
    line-height: 1.5;
  }

  #debug-overlay {
    width: 50vw;
    height: 50vw;
    border: none;
    overflow: hidden;
    font-size: 9px;
    padding: 8px;
    line-height: 1.3;
  }

  #dungeon-view {
    width: 100vw;
    flex: 1;
    max-width: none;
    max-height: none;
  }

  #sequence-image {
    object-fit: cover;
    object-position: center;
  }
}
