/* 基本リセット */
* {
  box-sizing: border-box;
}
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #f4f6f8;
  color: #222;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

/* コンテナ */
.container {
  max-width: 700px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ヘッダー */
header {
  text-align: center;
  margin-bottom: 16px;
  width: 100%;
}
h1 {
  font-size: 1.5rem;
  margin: 0 0 4px;
  color: #1a1a1a;
}
.subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: #666;
}

/* 迷路描画エリア */
.maze-wrapper {
  width: 100%;
  max-width: 640px;
  max-height: 640px;
  border: 2px solid #999;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  margin-bottom: 16px;
  /* タップ時のブラウズ挙動を抑制 */
  touch-action: none;
}
#mazeCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  cursor: default;
}

/* 操作ボタン */
.controls {
  width: 100%;
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
button {
  flex: 1;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: #2563eb;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px; /* タッチ操作しやすく */
}
button:active {
  background: #1d4ed8;
  transform: translateY(1px);
}
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ステータス表示 */
.status {
  width: 100%;
  max-width: 640px;
  margin-bottom: 24px;
}
.status-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  margin-bottom: 6px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.9rem;
}
.status-label {
  color: #666;
}
.status-value {
  font-weight: 700;
  color: #111;
}

/* フッター */
footer {
  width: 100%;
  max-width: 640px;
  text-align: center;
  font-size: 0.8rem;
  color: #888;
  margin-top: auto;
}

/* 無効化ボタン */
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 探索関連ボタンの特別な色 */
#pauseBtn {
  background: #eab308; /* 黄色 */
}
#pauseBtn:active {
  background: #ca8a04;
}
#methodBtn {
  background: #0891b2; /* シアン */
}
#methodBtn:active {
  background: #0e7490;
}
#exploreBtn {
  background: #2563eb; /* 青 */
}
#exploreBtn:active {
  background: #1d4ed8;
}

/* タイマー表示 */
#timer {
  font-variant-numeric: tabular-nums;
}

/* ステージ表示 */
#stageNum {
  font-weight: bold;
  color: #2563eb;
}

/* クリア画面オーバーレイ */
.clear-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.clear-content {
  background: #fff;
  padding: 32px;
  border-radius: 12px;
  text-align: center;
  max-width: 90%;
  width: 400px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.clear-title {
  margin: 0 0 12px;
  font-size: 1.75rem;
  color: #16a34a;
}

.clear-message {
  margin: 0 0 20px;
  font-size: 1rem;
  color: #374151;
}

.clear-time {
  margin: 0 0 24px;
  padding: 12px;
  background: #f3f4f6;
  border-radius: 8px;
}

.clear-time-label {
  display: block;
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 4px;
}

.clear-time-value {
  font-size: 1.75rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #111827;
}

.clear-buttons {
  display: flex;
  gap: 12px;
}

.clear-buttons button {
  flex: 1;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: #2563eb;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
}

.clear-buttons button:active {
  background: #1d4ed8;
}

.clear-buttons button:nth-child(2) {
  background: #6b7280;
}

.clear-buttons button:nth-child(2):active {
  background: #4b5563;
}



/* ベストタイム表示エリア */
.best-time-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.best-time-container button {
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  background: #dc2626;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  min-height: auto;
}

.best-time-container button:active {
  background: #b91c1c;
}

/* スマートフォン向け調整 */
@media (max-width: 480px) {
  .container {
    padding: 10px;
  }
  h1 {
    font-size: 1.25rem;
  }
  button {
    font-size: 0.95rem;
    padding: 10px 12px;
  }
  .status-item {
    font-size: 0.85rem;
    padding: 5px 8px;
  }
}