/* ==========================================================
   Pom Plan (Phase 3-E) - THE CHALLENGE themed redesign
   既存 JS が生成する HTML 構造:
     .sheet > .cell
       .cell .pip-container > .pip (x3)
       .cell .image-box > img + .pomander-name
       .cell .button-grid > button (x9)
   デザイン: ダーク + ゴールドアクセント (サイト統一)
========================================================== */

.pom-plan-page {
  --pp-bg:       var(--bg, #0a0a0a);
  --pp-bg-2:     var(--bg-2, #111);
  --pp-bg-3:     var(--bg-3, #161616);
  --pp-line:     var(--line, rgba(255,255,255,0.08));
  --pp-line-2:   var(--line-2, rgba(255,255,255,0.15));
  --pp-accent:   var(--accent, #f0c060);
  --pp-accent-2: var(--accent-2, #d4a04a);
  --pp-white:    var(--white, #f5f3ee);
  --pp-text-2:   var(--text-2, #c8c5bd);
  --pp-text-3:   var(--text-3, #888);
  --pp-text-4:   var(--text-4, #666);
  --pp-alert:    #ff6666;

  --pp-font-mono: "Roboto Mono", "SF Mono", Menlo, Consolas, monospace;

  /* 上部グラデーション (WPヘッダー部分が薄く明るく、下に行くほど真っ黒) */
  background: linear-gradient(
    180deg,
    #2a2a2e 0%,
    #1a1a1d 20%,
    #0a0a0a 45%,
    #0a0a0a 100%
  );
  background-attachment: fixed;
  color: var(--pp-text-2);
  min-height: 100vh;
  padding: 24px 20px 80px;
  box-sizing: border-box;
  position: relative;
}

/* body 自体もグラデに統一（WPヘッダーが透ける部分に色を差し込む） */
body:has(.pom-plan-page) {
  background: linear-gradient(
    180deg,
    #2a2a2e 0%,
    #1a1a1d 20%,
    #0a0a0a 45%,
    #0a0a0a 100%
  );
  background-attachment: fixed;
  margin: 0;
}

/* ========== ヘッダー (sound toggle) ========== */
.pom-plan-page .header-actions {
  display: flex;
  justify-content: flex-end;
  max-width: 1280px;
  margin: 0 auto 24px;
  padding: 0 4px;
}
.pom-plan-page .btn-group-left,
.pom-plan-page .btn-group-right { display: flex; gap: 10px; }
.pom-plan-page .header-btn {
  font-family: var(--font-ui, "Noto Sans JP", sans-serif);
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--pp-text-3); background: transparent;
  border: 1px solid var(--pp-line-2); padding: 7px 14px;
  cursor: pointer; transition: all 0.2s ease;
}
.pom-plan-page .header-btn:hover {
  color: var(--pp-accent); border-color: var(--pp-accent);
}

/* ========== メインレイアウト ========== */
.pom-plan-page .main-content {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  position: relative;
}
@media (max-width: 960px) {
  .pom-plan-page .main-content {
    grid-template-columns: 1fr;
  }
}
.pom-plan-page .left-panel { min-width: 0; }

/* ========== タブ ========== */
.pom-plan-page .tab-bar {
  display: flex; gap: 1px;
  background: var(--pp-line);
  border: 1px solid var(--pp-line);
  margin-bottom: 16px;
}
.pom-plan-page .tab-button {
  flex: 1; padding: 14px 8px;
  font-family: var(--font-ui, "Noto Sans JP", sans-serif);
  font-size: 11px; letter-spacing: 0.1em;
  color: var(--pp-text-3);
  background: var(--pp-bg-2);
  border: 0; cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
  position: relative; font-weight: 500;
}
.pom-plan-page .tab-button:hover {
  color: var(--pp-white); background: var(--pp-bg-3);
}
.pom-plan-page .tab-button.active {
  color: var(--pp-accent); background: var(--pp-bg-3);
}
.pom-plan-page .tab-button.active::after {
  content: ''; position: absolute;
  left: 0; bottom: 0; right: 0;
  height: 2px; background: var(--pp-accent);
}

/* ========== タブコンテンツ ========== */
.pom-plan-page .tab-content { display: none; }
.pom-plan-page .tab-content.active { display: block; }

/* ========== シート (土器カードグリッド) ========== */
.pom-plan-page .sheet {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  position: relative;
}
@media (max-width: 960px) {
  .pom-plan-page .sheet { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 640px) {
  .pom-plan-page .sheet { grid-template-columns: repeat(3, 1fr); gap: 6px; }
}

/* ========== RESET ALL ボタン (シート上部に絶対配置) ========== */
.pom-plan-page .reset-btn-fixed {
  grid-column: 1 / -1;
  padding: 10px;
  font-family: var(--font-ui, "Noto Sans JP", sans-serif);
  font-size: 11px; letter-spacing: 0.25em;
  color: var(--pp-alert);
  background: transparent;
  border: 1px solid rgba(255, 102, 102, 0.3);
  cursor: pointer; transition: all 0.2s ease;
  text-transform: uppercase;
}
.pom-plan-page .reset-btn-fixed:hover {
  background: rgba(255, 102, 102, 0.08);
  border-color: var(--pp-alert);
}

/* ========== セル (土器カード1枚) ========== */
.pom-plan-page .cell {
  position: relative;
  padding: 12px 8px 8px;
  background: var(--pp-bg-2);
  border: 1px solid var(--pp-line);
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.pom-plan-page .cell:hover {
  border-color: var(--pp-line-2);
}
.pom-plan-page .cell.has-active,
.pom-plan-page .cell.max-alert {
  border-color: var(--pp-accent);
}
.pom-plan-page .cell.max-alert {
  border-color: var(--pp-alert);
  animation: pp-pulse 0.4s ease;
}
.pom-plan-page .cell.empty {
  background: transparent;
  border: none;
  pointer-events: none;
}
@keyframes pp-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

/* ========== Pips (●●○) 表示 - セル右上 ========== */
.pom-plan-page .pip-container {
  position: absolute;
  top: 4px; right: 6px;
  display: flex;
  gap: 3px;
}
.pom-plan-page .pip {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.pom-plan-page .pip.active {
  background: var(--pp-accent);
  box-shadow: 0 0 6px rgba(240, 192, 96, 0.6);
}

/* ========== image-box (土器画像 + 名前) ========== */
.pom-plan-page .image-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.pom-plan-page .image-box img {
  width: 64px; height: 64px;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}
@media (max-width: 640px) {
  .pom-plan-page .image-box img {
    width: 52px; height: 52px;
  }
}

.pom-plan-page .pomander-name {
  font-family: var(--font-ui, "Noto Sans JP", sans-serif);
  font-size: 11px;
  color: var(--pp-text-2);
  text-align: center;
  line-height: 1.3;
  letter-spacing: 0.02em;
}
.pom-plan-page .cell.has-active .pomander-name {
  color: var(--pp-white);
}

/* ========== 階層ボタングリッド (1-9) ========== */
.pom-plan-page .button-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  width: 100%;
  margin-top: 2px;
}
.pom-plan-page .button-grid button {
  padding: 4px 0;
  font-family: var(--pp-font-mono);
  font-size: 11px;
  color: var(--pp-text-4);
  background: var(--pp-bg-3);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.pom-plan-page .button-grid button:hover {
  color: var(--pp-text-2);
  background: rgba(240, 192, 96, 0.08);
}
.pom-plan-page .button-grid button.active {
  color: var(--pp-accent);
  background: rgba(240, 192, 96, 0.18);
  border-color: rgba(240, 192, 96, 0.5);
  font-weight: 500;
}

/* ========== 入力ボックス (隠し) ========== */
.pom-plan-page .input-box {
  display: none !important;
}

/* ========== select (HoH / EO / PT 用ドロップダウン) ========== */
.pom-plan-page .cell select {
  width: 100%;
  background: var(--pp-bg-3);
  color: var(--pp-white);
  border: 1px solid var(--pp-line-2);
  padding: 4px 6px;
  font-size: 11px;
  font-family: var(--font-ui, "Noto Sans JP", sans-serif);
  cursor: pointer;
  margin-top: 2px;
}

/* ========== 右パネル ========== */
.pom-plan-page .right-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 20px;
  align-self: start;
}
@media (max-width: 960px) {
  .pom-plan-page .right-panel {
    position: fixed;
    bottom: 0; left: 0; right: 0; top: auto;
    background: var(--pp-bg);
    border-top: 1px solid var(--pp-accent);
    padding: 16px;
    max-height: 70vh; overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 100;
  }
  .pom-plan-page .right-panel.mobile-open {
    transform: translateY(0);
  }
}

.pom-plan-page .share-button {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 12px;
  font-family: var(--font-ui, "Noto Sans JP", sans-serif);
  font-size: 11px; letter-spacing: 0.2em;
  color: var(--pp-bg);
  background: var(--pp-accent);
  border: 0; cursor: pointer;
  text-transform: uppercase;
  font-weight: 600;
  transition: background 0.2s ease;
}
.pom-plan-page .share-button:hover {
  background: var(--pp-accent-2);
}

/* ========== 階層リスト ========== */
.pom-plan-page .floor-list {
  background: var(--pp-bg-2);
  border: 1px solid var(--pp-line);
  padding: 14px 16px;
}

.pom-plan-page .floor-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--pp-line);
  min-height: 38px;
}
.pom-plan-page .floor-row:last-child { border-bottom: none; }

.pom-plan-page .floor-label {
  font-family: var(--pp-font-mono);
  font-size: 13px;
  color: var(--pp-accent);
  font-weight: 500;
  min-width: 44px;
  font-variant-numeric: tabular-nums;
}

.pom-plan-page .floor-items {
  display: flex;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
}
.pom-plan-page .floor-items img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

/* ========== SHORT / MACRO 出力 ========== */
.pom-plan-page .output,
.pom-plan-page .short-output {
  background: var(--pp-bg-2);
  border: 1px solid var(--pp-line);
  padding: 12px 14px;
  position: relative;
}

.pom-plan-page .output-header {
  font-family: var(--font-ui, "Noto Sans JP", sans-serif);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--pp-accent);
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--pp-line);
}

.pom-plan-page .copy-btn {
  position: absolute;
  top: 10px; right: 14px;
  font-family: var(--font-ui, "Noto Sans JP", sans-serif);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--pp-text-3);
  background: transparent;
  border: 1px solid var(--pp-line-2);
  padding: 3px 8px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.2s ease;
}
.pom-plan-page .copy-btn:hover {
  color: var(--pp-accent);
  border-color: var(--pp-accent);
}

.pom-plan-page .output pre,
.pom-plan-page .short-output pre {
  font-family: var(--pp-font-mono);
  font-size: 11px;
  line-height: 1.7;
  color: var(--pp-text-2);
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}

/* ========== モバイル FAB ========== */
.pom-plan-page .mobile-fab {
  display: none;
  position: fixed;
  bottom: 20px; right: 20px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--pp-accent);
  color: var(--pp-bg);
  border: 0;
  cursor: pointer;
  font-size: 22px;
  z-index: 99;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease;
}
.pom-plan-page .mobile-fab:hover {
  transform: scale(1.05);
}
@media (max-width: 960px) {
  .pom-plan-page .mobile-fab { display: block; }
}

/* ========== info-box ========== */
.pom-plan-page .info-box {
  max-width: 1280px;
  margin: 32px auto 0;
  padding: 16px 20px;
  background: var(--pp-bg-2);
  border: 1px solid var(--pp-line);
  border-left: 3px solid var(--pp-accent);
  font-size: 12px;
  line-height: 1.8;
  color: var(--pp-text-3);
}
.pom-plan-page .info-box ul {
  margin: 0;
  padding: 0 0 0 18px;
}
.pom-plan-page .info-box b {
  color: var(--pp-accent);
}

/* ========== 更新履歴 ========== */
.pom-plan-page .changelog-container {
  max-width: 1280px;
  margin: 16px auto 0;
}
.pom-plan-page .changelog-details {
  background: var(--pp-bg-2);
  border: 1px solid var(--pp-line);
}
.pom-plan-page .changelog-details summary {
  padding: 12px 16px;
  cursor: pointer;
  font-family: var(--font-ui, "Noto Sans JP", sans-serif);
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--pp-text-3);
  text-transform: uppercase;
  user-select: none;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.pom-plan-page .changelog-details summary::-webkit-details-marker {
  display: none;
}
.pom-plan-page .changelog-details summary::after {
  content: '▼';
  font-size: 9px;
  transition: transform 0.25s ease;
  color: var(--pp-text-4);
}
.pom-plan-page .changelog-details[open] summary::after {
  transform: rotate(180deg);
}
.pom-plan-page .changelog-details summary:hover {
  color: var(--pp-accent);
}
.pom-plan-page #changelogContent {
  padding: 8px 16px 16px;
  font-size: 12px;
  line-height: 1.8;
  color: var(--pp-text-3);
}
.pom-plan-page #changelogContent > div {
  padding: 6px 0;
  border-bottom: 1px dashed var(--pp-line);
}
.pom-plan-page #changelogContent > div:last-child {
  border-bottom: none;
}

/* ========== フッター ========== */
.pom-plan-page .pom-plan-footer {
  max-width: 1280px;
  margin: 24px auto 0;
  padding: 16px;
  text-align: center;
  font-size: 10px;
  color: var(--pp-text-4);
  letter-spacing: 0.05em;
  line-height: 1.6;
}

/* ========== シェアモーダル ========== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  animation: pp-fade-in 0.25s ease;
}
@keyframes pp-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-content {
  max-width: 480px;
  width: calc(100% - 32px);
  background: var(--bg-2, #111);
  border: 1px solid rgba(240, 192, 96, 0.3);
  padding: 24px;
  color: var(--text-2, #c8c5bd);
}
.modal-content h2 {
  margin: 0 0 16px;
  font-size: 14px;
  letter-spacing: 0.2em;
  color: var(--accent, #f0c060);
  text-transform: uppercase;
  font-weight: 500;
}
.modal-content p {
  margin: 6px 0;
  font-size: 12px;
  line-height: 1.7;
}
.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}
.modal-buttons button {
  padding: 8px 16px;
  font-family: var(--font-ui, "Noto Sans JP", sans-serif);
  font-size: 11px;
  letter-spacing: 0.15em;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.2s ease;
  border: 0;
}
#modalOpenTwitterBtn {
  background: var(--accent, #f0c060);
  color: var(--bg, #0a0a0a);
  font-weight: 500;
}
#modalOpenTwitterBtn:hover {
  background: var(--accent-2, #d4a04a);
}
#modalCancelBtn {
  background: transparent;
  color: var(--text-3, #888);
  border: 1px solid var(--line-2, rgba(255,255,255,0.15));
}
#modalCancelBtn:hover {
  color: var(--white, #f5f3ee);
  border-color: var(--white, #f5f3ee);
}

/* ========== 粒子をサイレント化 (念のため非表示) ========== */
.pom-plan-page ~ .particle,
.pom-plan-page ~ .pomander-particle,
.particle,
.pomander-particle {
  display: none !important;
}
