* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}
body {
  background-color: #121420;
  color: #94a3b8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.container {
  width: 100%;
  max-width: 420px;
}
.header-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.btn {
  background: #282d42;
  color: #e2e8f0;
  border: 1px solid #3b4261;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.btn:active {
  background: #3b4261;
}

/* 1P / 2P 切り替えコントロール */
.player-switch-container {
  display: none;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}
.player-switch-container.show {
  display: flex;
}
.player-btn {
  background: #181a29;
  color: #94a3b8;
  border: 1px solid #282d45;
  padding: 5px 16px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}
.player-btn.p1.active {
  background: rgba(239, 68, 68, 0.25);
  color: #f87171;
  border-color: #ef4444;
}
.player-btn.p2.active {
  background: rgba(59, 130, 246, 0.25);
  color: #60a5fa;
  border-color: #3b82f6;
}

/* 盤面フレーム */
.board-frame {
  background: #181a29;
  border: 1px solid #282d42;
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 12px;
}

.board-notice {
  background: #0f111a;
  color: #f87171;
  font-size: 10.5px;
  font-weight: bold;
  text-align: center;
  padding: 5px;
  border-radius: 6px;
  margin-bottom: 8px;
  border: 1px solid #282d45;
  letter-spacing: 0.5px;
}

/* 縦横比が絶対に崩れないグリッド定義 */
.grid-5x5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 6px;
}
.grid-6x6 {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
}

.cell {
  background: #0f111a;
  border: 1px dashed #282d45;
  border-radius: 6px;
  aspect-ratio: 1 / 1;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 1P・2Pごとの盤面セル枠デザイン */
.cell.p1-cell {
  border: 2px solid #ef4444;
  background: rgba(239, 68, 68, 0.1);
}
.cell.p2-cell {
  border: 2px solid #3b4261;
  background: rgba(59, 130, 246, 0.1);
}

.cell img {
  width: 90%;
  height: 90%;
  object-fit: contain;
}

/* モンスター選択エリア */
.monster-frame {
  background: #181a29;
  border: 1px solid #282d42;
  border-radius: 12px;
  padding: 10px;
}
.monster-title {
  font-size: 13px;
  font-weight: bold;
  color: #e2e8f0;
  margin-bottom: 8px;
  text-align: center;
}

/* アコーディオン（フィルター部分） */
.filter-details {
  background: #0f111a;
  border: 1px solid #282d45;
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
}
.filter-summary {
  padding: 8px 10px;
  font-size: 11px;
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.filter-summary::-webkit-details-marker {
  display: none;
}
.filter-details[open] .summary-arrow {
  transform: rotate(180deg);
}
.summary-arrow {
  transition: transform 0.2s;
}

.filter-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid #282d45;
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  justify-content: center;
}
.filter-label {
  font-size: 10px;
  color: #64748b;
  margin-right: 2px;
}
.filter-btn {
  background: #181a29;
  color: #94a3b8;
  border: 1px solid #282d45;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.filter-btn img {
  width: 14px;
  height: 14px;
  object-fit: contain;
}
.filter-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #3b82f6;
}

/* モンスター一覧 */
.monster-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 2px;
}
.monster-item {
  background: #0f111a;
  border: 1px solid #282d45;
  border-radius: 8px;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
  cursor: pointer;
  position: relative;
}

.monster-item[data-attr="水"] { background: rgba(37, 99, 235, 0.15); }
.monster-item[data-attr="炎"] { background: rgba(239, 68, 68, 0.15); }
.monster-item[data-attr="草"] { background: rgba(34, 197, 94, 0.15); }
.monster-item[data-attr="岩"] { background: rgba(202, 138, 4, 0.15); }
.monster-item[data-attr="雷"] { background: rgba(168, 85, 247, 0.15); }

.monster-item.active {
  border: 2px solid #4ade80;
  background: #1e293b !important;
}

.monster-type-icon {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  object-fit: contain;
  pointer-events: none;
}

.monster-thumb {
  width: 76%;
  height: 76%;
  object-fit: contain;
}
.monster-name {
  font-size: 9px;
  color: #cbd5e1;
  text-align: center;
  line-height: 1.1;
  word-break: break-all;
  margin-top: 2px;
}

/* ハンバーガーメニュー・ドロワー関連 */
.menu-btn {
  background: #282d42;
  color: #e2e8f0;
  border: 1px solid #3b4261;
  padding: 6px 7px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 32px;
  height: 28px;
}
.menu-btn span {
  display: block;
  height: 3px;
  width: 100%;
  background: #e2e8f0;
  border-radius: 1.5px;
}

.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 999;
}
.drawer-overlay.open {
  visibility: visible;
  opacity: 1;
}

.drawer-menu {
  position: fixed;
  top: 0;
  right: 0;
  width: 260px;
  height: 100%;
  background: #181a29;
  border-left: 1px solid #282d42;
  box-shadow: -4px 0 15px rgba(0, 0, 0, 0.5);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  padding: 20px;
}
.drawer-overlay.open .drawer-menu {
  transform: translateX(0);
}

.drawer-title {
  font-size: 14px;
  font-weight: bold;
  color: #e2e8f0;
  margin-bottom: 20px;
  text-align: center;
  border-bottom: 1px solid #282d42;
  padding-bottom: 10px;
}

.drawer-item {
  background: #0f111a;
  color: #94a3b8;
  border: 1px solid #282d45;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 10px;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s, color 0.2s;
}
.drawer-item:hover, .drawer-item.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #3b82f6;
}
.drawer-footer {
  margin-top: auto;
  text-align: center;
  font-size: 10px;
  color: #475569; /* 周りに溶り込む暗めのグレー */
  letter-spacing: 0.5px;
}
