* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: #0b0f16;
  color: #fff;
  font-family: system-ui, sans-serif;
  overflow-x: hidden;
  overflow-y: auto;
}

/* ページ中央制御はここだけ */
#build-root {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px;
  /* 下が見切れないように余白を確保（ブラウザUI/スクロール操作の余裕） */
  padding-bottom: 140px;
}

/* 共有の短縮URLバーだけ少し小さく（全体は縮小しない） */
#shortBar {
  transform: scale(0.75);
  transform-origin: center top;
}


/* ===== build-area ロック =====
   build0: #build-area
   build1: #build-area-b1
   build2: #build-area-b2
   すべて同じ見た目でロックできるように prefix でまとめる
*/
[id^="build-area"].locked {
  opacity: 1;
  pointer-events: none;
}

[id^="build-area"].locked .icon.character {
  pointer-events: auto;
  cursor: pointer;
}

/* ===== キャラ選択 ===== */
#character-select {
  text-align: center;
  margin-top: 16px;
  margin-bottom: 24px;
}

#character-select h2 {
  font-size: 14px;
  margin-bottom: 8px;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  justify-content: center;
}


.character-grid button {
  aspect-ratio: 1 / 1;
  padding: 0;
  border-radius: 8px;
  background: #1f2633;
  border: 1px solid #2c3445;
}

.character-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 7px;
}

/* ===== ビルドカード ===== */
.build-swap-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0 0 12px;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

.build-swap-btn {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  background: #202938;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex: 1 1 180px;
  max-width: 240px;
}

.build-swap-btn:hover {
  background: #2b3546;
  border-color: rgba(255,255,255,0.32);
}

.build-card {
  padding: 16px;
  background: linear-gradient(180deg, #151a24, #0b0f16);
  border-radius: 12px;
  border: 1px solid #222;
  position: relative; /* ★ complete 表示用 */
}

/* ===== 上段 ===== */
.top-row {
  display: grid;
  grid-template-columns: 1.2fr 0.7fr 0.7fr;
  gap: 10px;
  margin-bottom: 18px;
}

.passives-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
}

.char-col {
  display: grid;
  grid-template-rows: auto auto;
  gap: 6px;
  align-content: center;
}

/* ===== スキル ===== */
.skills-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

/* ===== 装備 ===== */
.equipment {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

/* ===== 共通アイコン ===== */
.icon {
  border-radius: 10px;
  border: 1px solid #2c3445;
  background: #1f2633;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 比率 */
.icon.character,
.icon.passive,
.icon.brand {
  aspect-ratio: 1 / 1;
}

.icon.sp,
.icon.skill,
.icon.weapon,
.icon.charm {
  aspect-ratio: 3 / 4;
}

/* 空枠 */
.icon.empty {
  background: rgba(255,255,255,0.03);
  border: 1px dashed rgba(255,255,255,0.35);
  cursor: pointer;
}

.icon.empty span {
  margin: auto;
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
  color: rgba(255,255,255,0.65);
  pointer-events: none;
}

.icon.empty:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.55);
}

.icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== Character placeholder (no character selected) ===== */
.icon.character.no-char {
  background: rgba(255,255,255,0.03);
  border: 1px dashed rgba(245, 196, 0, 0.55);
  box-shadow: inset 0 0 0 2px rgba(245, 196, 0, 0.18);
}

.icon.character.no-char img {
  display: none;
}

.icon.character.no-char::after {
  content: "最初に\Aキャラを\A選択";
  white-space: pre;
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
  color: rgba(255,255,255,0.72);
  padding: 8px;
}

/* ===== チャーム表示の正規化 ===== */
.icon.charm .item-wrap.charm {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.icon.charm .item-wrap.charm img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.icon.charm .item-wrap.charm.is-card img {
  object-fit: cover;
}

/* XENO枠 */
/* XENO 9マス（各ビルドで同じ見た目） */
.icon.brand {
  position: relative;
  background: radial-gradient(circle at center, rgba(255,255,255,0.035), rgba(255,255,255,0.01));
  border: none;
  /* .icon の flex/center を打ち消して、子が100%で確実に伸びるようにする */
  display: block;
  justify-content: initial;
  align-items: initial;
  /* Safariで「子(height:100%) + 親padding」で下段が欠けることがあるので、paddingは子側に移す */
  padding: 0;
  box-sizing: border-box;
  overflow: hidden;
}

/* build0/1/2 すべてのミニグリッドに適用 */
[id^="positionGrid"] {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  /* 親(.icon.brand)のpaddingをここに移し、Safariの欠けを防ぐ */
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  /* 端数ピクセルでも下段が欠けないように */
  min-width: 0;
  min-height: 0;
}


.position-slot {
  background: rgba(0,0,0,0.18);
  border: 1px dashed rgba(255,255,255,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.position-slot img {
  max-width: 82%;
  max-height: 82%;
}

/* （旧モーダルCSSは下の「Overrides」で統一しているため削除） */

/* ===== 完成ゴールド枠 ===== */
.build-card.complete {
  border: 2px solid #f5c400;
  box-shadow: 0 0 12px rgba(245, 196, 0, 0.6);
}


/* ===========================
   Overrides for single-file main.js
   =========================== */

/* Character select as modal overlay (hidden by default; shown only when user taps a character slot) */
#character-select {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99990;
  background: rgba(0,0,0,0.72);
  margin: 0;
  padding: 18px 14px;
  overflow: auto;
}

#character-select h2 {
  margin-top: 0;
}

#character-select .character-grid {
  max-width: 720px;
  margin: 0 auto;
}

/* Position modal */
.modal-overlay {
  display: none; /* main.js toggles to flex */
  position: fixed;
  inset: 0;
  z-index: 99995;
  background: rgba(0,0,0,0.72);
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  background: #151b26;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 14px;
  width: min(92vw, 360px);
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  aspect-ratio: 1 / 1;
  width: 100%;
  gap: 10px;
}

.modal-slot {
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.18);
  cursor: pointer;
  overflow: hidden;
  position: relative;
  isolation: isolate;
}

.modal-slot.selected {
  outline: 2px solid #f5c400;
}

.modal-slot.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Mini 3x3 grid shown in each build (shared board, per-build selection) */
.pos-mini-cell {
  border: 1px dashed rgba(255,255,255,0.25);
  /* use background-color (not background shorthand) so inline background-image is never clobbered */
  background-color: rgba(0,0,0,0.14);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Occupancy markers (subtle, keep theme) */
/* occupied 表示方針：
   - 自分のビルドのマスだけ「塗り」
   - 他ビルドのマスは「枠」だけ（全体の配置情報は見える）
   ※ビルドごとの色分けはしない（キャラの邪魔をしない）
*/
.pos-mini-cell.occupied-other,
.modal-slot.occupied-other {
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.22);
}

.pos-mini-cell.occupied-self,
.modal-slot.occupied-self {
  /* self: character + filled frame */
  background-color: rgba(245, 196, 0, 0.12);
  box-shadow: inset 0 0 0 2px rgba(245, 196, 0, 0.75);
  border: 1px solid rgba(245, 196, 0, 0.55);
}

/* character thumbnails for position cells: now rendered via background-image */
.pos-mini-cell.has-char {
  background-color: rgba(0,0,0,0.10);
}

.modal-slot {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.modal-slot.has-char {
  background-color: rgba(0,0,0,0.10);
}


/* ===== 3 builds layout ===== */
#builds{display:flex;gap:12px;align-items:flex-start;justify-content:center;}
.build-wrap{flex:1;min-width:320px;max-width:460px;}
@media (max-width: 900px){#builds{overflow-x:auto;-webkit-overflow-scrolling:touch;scroll-snap-type:x mandatory;justify-content:flex-start;}
.build-wrap{flex:0 0 92%;scroll-snap-align:start;}
}

/* Moved from index.html */
.short-btn {
  margin-top: 12px;
  width: 100%;
  padding: 10px;
  background: #1f2633;
  color: #fff;
  border: 1px solid #2c3445;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.short-btn:hover {
  background: #273044;
}

.summary-btn {
  margin-top: 10px;
  width: 100%;
  padding: 10px;
  background: #283b33;
  color: #fff;
  border: 1px solid #3f6655;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.summary-btn:hover {
  background: #335044;
}

.build-title {
  font-size: 13px;
  opacity: 0.85;
  margin: 6px 0 10px;
  text-align: center;
}

/* Navigation styles */
.top-nav {
  margin-bottom: 10px;
}

.back-link {
  font-size: 14px;
  text-decoration: none;
  color: #409eff;
}
