.log-date {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ベーススタイル */
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: auto;
  /* iOS Safari対応 */
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  background: var(--sky);
  color: var(--ink);
  font-family: "Nunito", "Noto Sans JP", system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  font-size: 12px;
  line-height: 1.3;
  /* 完全レスポンシブ：画面サイズに追従 */
  display: flex;
  flex-direction: column;
  /* iOS Safe Areaに対応 */
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

/* 上部バー（デフォルト：モバイルファースト） */
.sessionBar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  padding: 6px 8px;
  background: #fffdf6;
  border-bottom: 2px solid var(--line);
}

.sessionBar-left,
.sessionBar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

#bgmTrackSelect {
  padding: 4px 10px;
  border: 1px solid #d4d4d8;
  border-radius: 999px;
  background: #fff;
  color: #1f2937;
  font-size: 12px;
  line-height: 1.2;
  height: 28px;
  min-width: 58px;
  max-width: 96px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  pointer-events: auto !important;
  touch-action: manipulation !important;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

#bgmTrackSelect:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.sessionBar-headline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* 通信状況情報グループ（薄い背景コンテナ） */
.status-info-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(147, 197, 253, 0.1);
  /* 空色系（爽やか） */
  border-radius: 6px;
  border: 1px solid rgba(147, 197, 253, 0.2);
  /* 空色系のボーダー */
}

.sessionBar h1 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

/* 通信状況情報グループ内の要素（統一スタイル） */
.status-info-group .stat-info,
.status-info-group .stat-active,
.status-info-group .version-tag,
.status-info-group .wsStat {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  line-height: 1.4;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  margin: 0;
  /* マージンをリセット（gapで統一） */
}

.status-info-group .stat-info span,
.status-info-group .stat-active span {
  margin-left: 2px;
}

.sessionBar-left {
  width: 100%;
  justify-content: flex-start;
}

.sessionBar-right {
  justify-content: flex-end;
  gap: 6px;
}

/* 通信状態（意味のある色分け） */
.status-info-group .wsStat {
  color: #8b5cf6;
  /* 紫系（通信状態を強調） */
}

/* バージョン（グレー） */
.status-info-group .version-tag {
  color: #64748b;
  /* 統一グレー */
}

/* 統計情報（グレー） */
.status-info-group .stat-info {
  color: #64748b;
  /* 統一グレー */
}

/* ログイン中（青系） */
.status-info-group .stat-active {
  color: #3b82f6;
  /* 青系（アクティブ状態を強調） */
}

.sessionBar small {
  color: #e67e22;
  font-weight: 900;
  /* ゲストモード警告色 */
}

.sessionBar a {
  color: #1a73e8;

  .bgm-info {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    font-style: italic;
    letter-spacing: 0.3px;
    color: #4c566a;
    background: linear-gradient(120deg, rgba(148, 163, 184, 0.22), rgba(226, 232, 240, 0.05));
    box-shadow: 0 6px 12px rgba(15, 23, 42, 0.08);
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.28);
    backdrop-filter: blur(6px);
  }

  .bgm-info:empty {
    display: none;
  }

  text-decoration: none;
  font-weight: 700;
}

.button {
  padding: 6px 10px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #3b2900;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--shadow-strong);
  font-size: 12px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

.mutebtn {
  padding: 5px 9px;
  border: 0;
  border-radius: 10px;
  background: #ffe8a6;
  color: #3b2900;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--shadow-mid);
  font-size: 12px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.mutebtn:hover {
  background: #ffd966;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.mutebtn:active {
  background: #ffcc33;
  transform: scale(0.98);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* 本体3カラム：残り高すべてを占有（スクロールは内部要素で）*/
.wrap {
  flex: 1;
  min-height: 0;
  padding: 10px 12px 12px;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 2.4fr 1.32fr 1.32fr;
  gap: 10px;
}

.panel {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  box-sizing: border-box;
  box-shadow: 0 6px 0 var(--shadow-soft), 0 2px 0 rgba(0, 0, 0, .03) inset;
  min-height: 0;
}

.row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

input,
select,
textarea {
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 6px 9px;
  font: inherit;
  font-size: 12px;
}

#game {
  outline: none;
  border: none;
  border-radius: 0;
  display: block;
  position: relative;
  height: 100%;
  min-height: 0;
}

/* Phaserキャンバスをコンテナ高にフィットさせる（見た目縮小） */
#game>canvas {
  width: 100% !important;
  height: 100% !important;
}

.map-area {
  position: relative;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  border-radius: 10px;
}

/* 魔法選択UI（シンプル版） - HTMLのインラインスタイルで対応 */

.game-overlay {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 10;
  overflow: hidden;
  border-radius: 10px;
}

.game-inventory {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid rgba(15, 23, 42, 0.75);
  background: rgba(30, 58, 138, 0.4);
  backdrop-filter: blur(3px);
  color: #fef9c3;
  font-family: 'Press Start 2P', 'Courier New', 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 9px;
  letter-spacing: 0.4px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.65);
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  max-width: calc(100% - 16px);
  box-sizing: border-box;
}


.game-hp-container {
  pointer-events: auto;
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.game-hp-bars {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 140px;
  width: auto;
  /* 内容に合わせて自動拡張 */
  padding: 2px 4px;
  border-radius: 6px;
  border: 1.5px solid rgba(15, 23, 42, 0.65);
  background: rgba(15, 23, 42, 0.4);
  box-sizing: border-box;
}

.game-mini-inline {
  display: flex;
  flex-direction: row;
  /* 横並び */
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding: 2px 2px 1px 2px;
  /* 上に少し余白、下は最小限 */
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  /* HP/SPとの区切り線 */
  margin-top: 1px;
  color: #f8fafc;
  font-family: 'Press Start 2P', 'Courier New', 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 6px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-mini-label {
  font-size: 8px;
  letter-spacing: 0.2px;
  color: #e0f2fe;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.game-mini-value {
  font-size: 9px;
  font-weight: 700;
  color: #facc15;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.game-inventory-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.game-field-name {
  pointer-events: none;
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-block;
  font-family: 'Misaki Gothic', 'みさきゴシック', sans-serif;
  font-size: 12px;
  color: #ffffff;
  text-shadow:
    -1px 0 rgba(0, 0, 0, 0.9),
    1px 0 rgba(0, 0, 0, 0.9),
    0 -1px rgba(0, 0, 0, 0.9),
    0 1px rgba(0, 0, 0, 0.9),
    -1px -1px rgba(0, 0, 0, 0.9),
    1px 1px rgba(0, 0, 0, 0.9),
    -1px 1px rgba(0, 0, 0, 0.9),
    1px -1px rgba(0, 0, 0, 0.9);
  max-width: calc(100% - 16px);
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-hp-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.game-hp-label {
  font-family: 'Press Start 2P', 'Courier New', 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 6px;
  color: #f8fafc;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  min-width: 18px;
  line-height: 1.2;
  flex-shrink: 0;
}

.game-hp-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.9);
  background: rgba(15, 23, 42, 0.45);
  overflow: hidden;
  position: relative;
  min-width: 0;
}

/* ステータスヘッダー右側ツールバー（テーマ＆各種編集ボタン） */
.status-toolbar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.game-hp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ef4444 0%, #b91c1c 100%);
  transition: width 0.3s ease;
}

.game-hp-fill.sp {
  background: linear-gradient(90deg, #38bdf8 0%, #2563eb 100%);
}

.game-hp-value {
  font-family: 'Press Start 2P', 'Courier New', 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 6px;
  color: #f8fafc;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  min-width: 32px;
  text-align: right;
  line-height: 1.2;
  flex-shrink: 0;
}

@media (max-width: 720px) {
  .game-inventory {
    left: 8px;
    top: auto;
    bottom: 110px;
    transform: none;
    max-width: calc(100% - 16px);
  }

  .game-hp-container {
    flex-direction: column;
    align-items: center;
    bottom: 12px;
    gap: 4px;
    transform: translateX(-50%);
  }

  .game-hp-bars {
    min-width: 120px;
    width: auto;
    /* 内容に合わせて自動拡張 */
  }

  .game-mini-inline {
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
    /* 親要素（game-hp-bars）の幅に合わせる */
  }

  .game-player-nameplate {
    bottom: 150px;
    font-size: 7px;
    gap: 6px;
  }

  .game-field-name {
    top: 8px;
    right: 8px;
    max-width: calc(100% - 16px);
  }
}

/* 統一セクションスタイル */
.section {
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 6px 8px;
  display: grid;
  gap: 4px;
  min-height: 0;
}

.section>strong {
  display: block;
  font-size: 13px;
  font-weight: 900;
  padding-bottom: 2px;
  border-bottom: 1px dashed var(--line);
}

/* ステータス：余白調整 */
.status-section {
  display: grid;
  grid-template-rows: auto auto;
  min-height: 0;
  gap: 3px;
}

.status {
  display: flex;
  flex-direction: column;
  /* 3行表示 */
  gap: 4px;
  /* 行間の間隔 */
  align-items: flex-start;
  background: #fff8dd;
  /* 元の淡い黄色 */
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
  /* RPGステータスと同じpadding */
  margin-bottom: 0;
  font-size: 12px;
  /* 11px → 12pxに変更 */
}

.status>div,
.status-row {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  white-space: nowrap;
}

.status-row-main {
  gap: 0.5em;
  width: 100%;
}

.status-row-secondary {
  gap: 0.5em;
  width: 100%;
}

.status-row-exp {
  width: 100%;
}

.status-separator {
  display: inline-block;
  margin: 0 0.6em;
  color: rgba(100, 116, 139, 0.9);
  font-size: 12px;
}

.status-label-next {
  color: #2563eb;
}

.status-next-exp {
  font-weight: 700;
  font-size: 12px;
  color: #1d4ed8;
}

/* ラベルと値の間の間隔を完全に0にする */
.status>div>span {
  margin: 0;
  padding: 0;
}

/* 状態ラベル（「状態：」「今日：」など）をRPGラベルと同じスタイルに */
.status-label {
  font-weight: 700;
  color: #d97706;
  /* 濃い黄色（オレンジ系） */
  font-size: 12px;
  /* 11px → 12pxに変更 */
}

/* 累計経験値の表示スタイル */
#rpgTotalExp {
  font-size: 12px;
  /* 11px → 12pxに変更 */
  color: #1e40af;
  /* 少し濃い青で経験値であることを強調 */
}

.project-actions {
  display: flex;
  justify-content: flex-start;
  margin: 4px 0 0;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.subkind-inline {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #64748b;
  flex-wrap: wrap;
}

.subkind-inline select,
.subkind-inline input {
  padding: 3.6px 6px;
  /* 縦幅1.2倍（3px * 1.2 = 3.6px） */
  border: 2px solid #cbd5e1;
  border-radius: 6px;
  font-size: 10px;
  background: #fff;
  cursor: pointer;
  width: 126px;
  /* 横幅1.8倍（70px * 1.8 = 126px） */
  flex: 0 0 126px;
  /* 横幅1.8倍 */
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

.subkind-inline input {
  cursor: text;
}

/* プロジェクトボタンとサブ選択を横並び */
.projRow-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
}

/* プロジェクト編集ボタン（カテゴリー行の上） */
.project-edit-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}

.project-edit-btn-moved {
  border-radius: 999px;
  padding-inline: 14px;
}

/* カテゴリーラベルとカテゴリーボックス */
.project-category-label {
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
  margin-right: 4px;
  white-space: nowrap;
}

.project-category-box {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: #f9fafb;
  border: 2px solid var(--line);
  border-radius: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

/* 作業開始・集中モード・目標バーを横並び */
.actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 6px;
}

.actions-row-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.actions-row-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
}

/* もともとの2列グリッドを横スクロール1行に変更 */
.rpg-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 10px;
  background: #e6f7ff;
  border: 2px solid var(--line);
  border-radius: 10px;
  font-size: 12px;
  /* 11px → 12pxに変更 */
  margin-top: 4px;
}

.rpg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8em;
  /* 項目ごとの間隔を広げる */
  align-items: center;
}

.rpg-row>div {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  /* ラベルと値の間隔を狭める */
  white-space: nowrap;
}

.rpg-breakdown {
  flex-basis: 100%;
  color: #6b7280;
  font-size: 11px;
  white-space: normal;
}

/* ========== テーマ切り替えパレット ========== */
.theme-selector-container {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.theme-palette-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.1),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.theme-palette-btn:hover {
  transform: translateY(-1px);
  border-color: #fbbf24;
  box-shadow:
    0 4px 10px rgba(15, 23, 42, 0.18),
    0 0 0 1px rgba(251, 191, 36, 0.45) inset;
}

.theme-palette-btn:active {
  transform: translateY(0);
  box-shadow:
    0 1px 3px rgba(15, 23, 42, 0.2),
    0 0 0 1px rgba(251, 191, 36, 0.4) inset;
}

.palette-icon {
  display: block;
}

.theme-dropdown {
  position: absolute;
  top: 40px;
  left: 0;
  display: none;
  /* JSで制御 */
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 999px;
  box-shadow:
    0 10px 25px rgba(15, 23, 42, 0.18),
    0 0 0 1px rgba(148, 163, 184, 0.25);
  z-index: 100;
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.global-theme-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: #ffffff;
  font-size: 11px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.global-theme-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.18);
}

.global-theme-chip:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.22);
}

.global-theme-chip.active {
  border-color: #3b82f6;
  background: #eff6ff;
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}

.theme-mimosa .color-dot {
  background: #facc15;
}

.theme-sakura .color-dot {
  background: #f9a8d4;
}

.theme-mono .color-dot {
  background: #9ca3af;
}

.theme-green .color-dot {
  background: #4ade80;
}

.exp-breakdown {
  font-size: 0.75em;
  opacity: 0.85;
}

.rpg-inline-breakdown {
  font-size: 11px;
  color: #6b7280;
  margin-left: 4px;
}

.empty-slot-message {
  margin-top: 4px;
  padding: 12px;
  font-size: 12px;
  color: #6b7280;
  background: #f9fafb;
  border: 1px dashed #d1d5db;
  border-radius: 8px;
}

.rpg-label {
  font-weight: 700;
  color: #0369a1;
}

.stat {
  font-weight: 900;
  font-size: 12px;
  /* 11px → 12pxに変更 */
}

.timer {
  /* min-width: 86px; 削除（間隔が開く原因） */
  font-weight: 900;
  font-size: 12px;
  /* 11px → 12pxに変更 */
}

.small {
  font-size: 11px;
  color: var(--hint);
  line-height: 1.3;
}

.left {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  min-height: 0;
  align-items: stretch;
}

.map-section {
  display: grid;
  grid-template-rows: 1fr;
  min-height: 0;
  gap: 0;
  position: relative;
  padding: 0;
  margin: 0;
  border: none;
  overflow: hidden;
  border-radius: 10px;
  background: transparent;
}

.map-area #game {
  width: 100%;
  height: 100%;
  border-radius: 0;
  overflow: hidden;
}

#mapArea:fullscreen,
#mapArea:-webkit-full-screen,
#mapArea:-moz-full-screen,
#mapArea:-ms-fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  background: var(--panel);
}

#mapArea:fullscreen #game,
#mapArea:-webkit-full-screen #game,
#mapArea:-moz-full-screen #game,
#mapArea:-ms-fullscreen #game {
  width: 100%;
  height: 100%;
}

#mapArea:fullscreen .map-zoom-control,
#mapArea:-webkit-full-screen .map-zoom-control,
#mapArea:-moz-full-screen .map-zoom-control,
#mapArea:-ms-fullscreen .map-zoom-control {
  top: 16px;
  left: 16px;
}

#mapArea:fullscreen .map-fullscreen-close-btn,
#mapArea:-webkit-full-screen .map-fullscreen-close-btn,
#mapArea:-moz-full-screen .map-fullscreen-close-btn,
#mapArea:-ms-fullscreen .map-fullscreen-close-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10001;
}

.map-zoom-control {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  z-index: 15;
}

.map-zoom-toggle-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.2);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.1);
  font-size: 12px;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  padding: 0;
}

.map-zoom-toggle-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
}

.map-zoom-toggle-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.map-zoom-toggle-btn:focus-visible {
  outline: 1px solid #0ea5e9;
  outline-offset: 1px;
}

.map-zoom-toggle-btn.is-active {
  background: linear-gradient(135deg, #1f2937 0%, #0f172a 100%);
  color: #f8fafc;
  border-color: #0f172a;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.3);
}

.map-fullscreen-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.2);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.1);
  font-size: 12px;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  padding: 0;
}

.map-fullscreen-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
}

.map-fullscreen-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.map-fullscreen-btn:focus-visible {
  outline: 1px solid #0ea5e9;
  outline-offset: 1px;
}

.map-fullscreen-btn.is-active {
  background: linear-gradient(135deg, #1f2937 0%, #0f172a 100%);
  color: #f8fafc;
  border-color: #0f172a;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.3);
}

.map-fullscreen-close-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 2px solid rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.9);
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
  font-size: 16px;
  color: #fff;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.2s ease;
  padding: 0;
  font-weight: bold;
  z-index: 1000;
}

.map-fullscreen-close-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 1);
}

.map-fullscreen-close-btn:active {
  transform: translateY(0) scale(0.95);
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.map-fullscreen-close-btn:focus-visible {
  outline: 2px solid #ef4444;
  outline-offset: 2px;
}

.map-zoom-controls-wrapper {
  display: inline-flex !important;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.1);
}

.map-zoom-controls-wrapper.is-hidden {
  display: none !important;
}

.map-zoom-control-btn {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid #38bdf8;
  background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
  color: #0369a1;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  padding: 0;
}

.map-zoom-control-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 1px 3px rgba(56, 189, 248, 0.3);
}

.map-zoom-control-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.map-zoom-control-btn:focus-visible {
  outline: 1px solid #0ea5e9;
  outline-offset: 1px;
}

.map-zoom-control .zoom-display {
  font-size: 10px;
  font-weight: 700;
  color: #0f172a;
  min-width: 36px;
  text-align: right;
  padding: 0 2px;
}

.map-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.current-field-name {
  font-size: 13px;
  font-weight: 700;
  color: #2563eb;
}

/* ゲーム画面内右上のフィールド名表示 */
#game {
  position: relative;
}

.shortcut-section {
  display: grid;
  grid-template-rows: auto auto;
  min-height: 0;
  gap: 0;
  align-self: end;
  margin-top: auto;
}

/* === プロジェクトUI：二段構成（余白調整） === */
.project-section {
  display: grid;
  grid-template-rows: auto auto;
  min-height: 0;
  gap: 3px;
}

.mapCtrl {
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 4px;
  min-height: 0;
}

/* 上段：6プロジェクトのみ（編集ボタンは下段へ移動） */
.projRow {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.chip {
  padding: 6px 12px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.2);
  /* 枠線を薄くしてグレー感を軽減 */
  font-weight: 700;
  color: #475569;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.chip:hover {
  background: #ffffff;
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.chip:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #3b2900;
  /* 文字色を濃い茶色に変更（白だとチカチカするため） */
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
  text-shadow: none;
  /* テキストシャドウ削除 */
}

/* 真ん中カラム：もくにけーしょんのみ（縦いっぱい） */
.middle {
  display: grid;
  grid-template-rows: 1fr;
  gap: 8px;
  min-height: 0;
}

.middle .section.condensed {
  /* .panel.middle > .todo-sectionと.panel.middle > .pie-sectionで上書きされる */
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}

/* .panel.middle内のcondensedセクションは、utilities.cssの設定で上書きされる */
.panel.middle>.section.condensed {
  height: auto !important;
  /* grid-template-rowsに従う */
  flex: 0 0 auto !important;
  max-height: 100% !important;
}

.middle .section.condensed .todo-list,
.middle .section.condensed .pieWrap {
  overflow: hidden;
  min-height: 0;
}

.middle .section.condensed .pieWrap {
  height: 100%;
  min-height: 0;
}

.middle .section.condensed .todo-list {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
}

.goal-top-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

#goalInlineStartBtn {
  background: #fde68a !important;
  border: 2px solid #f59e0b;
  font-weight: 700;
}

#goalSetBtn {
  background: #fde68a !important;
  border: 2px solid #f59e0b;
  font-weight: 700;
}

#goalInlineStartBtn.btn-gray,
#goalSetBtn.btn-gray {
  background: #6b7280 !important;
  color: #fff !important;
  border: 2px solid #6b7280;
}

/* 通常作業中の「作業終了」ボタンは集中モードと同じスタイル */
#goalInlineStartBtn.goal-inline-focus-active {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%) !important;
  border: 2px solid #ef4444 !important;
  color: #b91c1c !important;
  box-shadow: 0 2px 0 rgba(239, 68, 68, 0.18) !important;
}

.pie-section {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  /* .panel.middleのgrid-template-rows: 1fr 1frにより、常に50%の高さが保証される */
  /* utilities.cssの.panel.middle > .pie-sectionで上書きされる */
}

.month-pie-section {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.log-section {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  /* .panel.rightのgrid-template-rows: 1fr 1frにより、常に50%の高さが保証される */
}


.chat-section {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.communication-section {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
  padding: 20px 4px;
  box-sizing: border-box;
  /* 縦いっぱいに伸ばす: タイトル / To WorldとFrom Worldを縦に並べたコンテナ */
}

/* To WorldとFrom Worldを縦に並べるコンテナ */
.communication-section>div:last-child {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  min-height: 0;
  height: calc(100% - 40px);
}

.communication-section>div:last-child>.communication-subsection:first-child {
  height: calc(100% - 20px);
  margin: 0 0 20px;
}

.communication-section>div:last-child>.communication-subsection:last-child {
  height: calc(100% - 4px);
  margin: 2px 0;
}

.communication-subsection {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  overflow: hidden;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  padding: 8px;
  background: #fff;
  height: 100%;
}

.communication-subsection-header {
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  padding: 4px 0;
  border-bottom: 1px solid #e5e7eb;
}

.communication-content.to-world,
.communication-content.from-world {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.communication-card {
  border: 2px solid #dbeafe;
  border-radius: 12px;
  background: #f8fafc;
  padding: 10px 12px;
  margin-bottom: 10px;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.communication-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}

/* From Worldカードのクリック可能スタイル */
.communication-card-clickable {
  cursor: pointer;
}

.communication-card-clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(59, 130, 246, 0.2);
  border-color: #3b82f6;
}

.communication-card-self {
  border-color: #c7d2fe;
  background: linear-gradient(135deg, rgba(199, 210, 254, 0.2), rgba(248, 250, 252, 0.8));
}

.communication-card-moca {
  border-style: dashed;
  border-color: #10b981;
  border-width: 2px;
  background: linear-gradient(135deg, rgba(236, 253, 245, 0.8), rgba(209, 250, 229, 0.6));
  position: relative;
}

.communication-card-moca::before {
  content: '📝';
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 16px;
  opacity: 0.6;
}

.communication-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #475569;
  margin-bottom: 4px;
}

.communication-card-sender {
  font-weight: 700;
  color: #1e293b;
}

.communication-card-time {
  font-variant-numeric: tabular-nums;
}

.communication-card-type {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  color: #0f172a;
  background: #e2e8f0;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.communication-card-type-work {
  background: #dbeafe;
  color: #1d4ed8;
}

.communication-card-type-focus {
  background: #fce7f3;
  color: #be185d;
}

.communication-card-type-other {
  background: #e5e7eb;
  color: #374151;
}

.communication-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #0f172a;
}

.communication-card-content {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.communication-card-comment {
  font-size: 11px;
  color: #475569;
  line-height: 1.4;
}

.communication-card-footer {
  margin-top: 6px;
  font-size: 10px;
  color: #64748b;
  font-weight: 600;
}

.communication-good-buttons {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}


.skill-tree-section {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.goal-section {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

/* 目標進捗バー */
.goal-progress {
  margin-bottom: 8px;
}

/* 進捗（左カラム版：1行に統合） */
.goal-top-single {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.goal-top-left {
  display: flex;
  gap: 6px;
  align-items: center;
}

.goal-top-left #breakBtn[disabled] {
  opacity: .5;
  cursor: not-allowed;
}

.goal-top-left #breakBtn.active {
  background: #ffe8e8;
  color: #b91c1c;
  font-weight: 900;
}

.goal-inline-start-active {
  background: #ef4444 !important;
  color: #fff !important;
  box-shadow: 0 2px 0 rgba(239, 68, 68, 0.35);
}

.goal-inline-start-active:hover {
  background: #dc2626 !important;
  color: #fff !important;
}

.goal-inline-start-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.goal-inline-start-disabled:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.goal-top-right {
  font-weight: 700;
  color: #374151;
  white-space: nowrap;
}

.goal-progress-inline {
  flex: 1 1 auto;
  min-width: 120px;
  max-width: 200px;
}

.goal-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
}

.goal-time-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.goal-inline-focus {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 999px;
  background: #fef3c7;
  border: 2px solid #fbbf24;
  font-weight: 700;
}

.goal-inline-focus-active {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  border: 2px solid #ef4444;
  color: #b91c1c;
  box-shadow: 0 2px 0 rgba(239, 68, 68, 0.18);
}

.goal-meta {
  font-weight: 700;
  color: var(--ink);
}

.goal-remaining {
  padding: 3px 8px;
  background: #1f2937;
  color: #fff;
  border-radius: 10px;
  font-weight: 900;
  font-size: 12px;
  white-space: nowrap;
}

.progress-bar {
  width: 100%;
  max-width: 200px;
  min-width: 120px;
  height: 24px;
  background: #e5e7eb;
  /* 薄いグレー背景 */
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.goal-remaining-inline {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 900;
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
  text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000,
    0 0 1px #000;
  pointer-events: none;
  z-index: 2;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 50%, #ec4899 100%);
  width: 0%;
  position: absolute;
  left: 0;
  /* 左から始まる */
  border-radius: 12px;
  transition: width 0.3s ease-out;
  z-index: 1;
}

.progress-text {
  text-align: center;
  margin-top: 4px;
  font-size: 12px;
  font-weight: bold;
  color: #374151;
}

.goal-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 祝福エフェクト */
@keyframes celebration {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }
}

/* トーストアニメーション */
@keyframes fadeinout {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }

  20% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  80% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
}

/* ポモドーロタイマー */
.pomodoro-panel {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 200px;
  background: rgba(0, 0, 0, 0.9);
  border: 2px solid #666;
  border-radius: 8px;
  z-index: 1000;
  padding: 8px;
}

.pomodoro-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.pomodoro-timer {
  font-size: 24px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 4px;
}

.pomodoro-status {
  text-align: center;
  font-size: 12px;
  margin-bottom: 8px;
  color: #ccc;
}

.pomodoro-controls {
  display: flex;
  gap: 4px;
  justify-content: center;
}

/* チャット */
.chat {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 6px;
  min-height: 0;
}

.chatInputRow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

#chatList {
  overflow: auto;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 6px;
  min-height: 0;
  background: #fff8dd;
  font-family: 'Press Start 2P', 'Courier New', 'Monaco', 'Menlo', 'Consolas', monospace;
}

.communication-content {
  overflow: auto;
  min-height: 0;
}

.pieWrap {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 6px;
  min-height: 0;
}

#pieCanvas {
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  width: 100%;
  height: 90px;
}

#legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  align-content: start;
  min-height: 0;
  overflow: hidden;
}

.lg {
  display: flex;
  gap: 4px;
  align-items: center;
}

.sw {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid #00000022;
}

.logBox {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 6px;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  border-radius: 8px;
  padding: 4px;
  padding-bottom: 4px;
}

.logBox input,
.logBox button {
  pointer-events: auto;
  touch-action: manipulation;
  position: relative;
  z-index: 11;
}

.loghead>div:first-child,
.loghead>div:nth-child(2),
.loglist .log-project,
.loglist .log-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loghead {
  display: grid;
  grid-template-columns: minmax(80px, 1.2fr) minmax(80px, 1fr) 60px 60px 60px 56px 80px 70px 70px;
  gap: 4px;
  font-weight: 900;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 4px;
}

/* grid-template-columns は main.js 側で inline 生成時に合わせる */

.loglist {
  overflow-y: auto;
  display: grid;
  grid-auto-rows: minmax(16px, auto);
  row-gap: 3px;
  min-height: 0;
  min-width: max-content;
}

.loglist>div {
  display: grid;
  grid-template-columns: minmax(80px, 1.2fr) minmax(80px, 1fr) 60px 60px 60px 56px 80px 70px 70px;
  column-gap: 4px;
  align-items: center;
  min-width: max-content;
}

.log-sub {
  font-size: 12px;
  color: #374151;
}

.log-sub--empty {
  color: #9ca3af;
}

.csvRow {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.log-summary {
  font-size: 12px;
  font-weight: 600;
  color: #1f2937;
  white-space: nowrap;
  flex: 0 0 auto;
  pointer-events: none;
}

.pie-header {
  align-items: center;
  gap: 8px;
}

.pie-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
}

.pie-controls select,
.pie-controls input {
  flex: 0 0 auto;
}

.log-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.log-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  margin-left: auto;
  min-width: 0;
  padding: 2px 0;
}

.log-controls select,
.log-controls input {
  flex: 0 0 auto;
  white-space: nowrap;
}

.log-range-select {
  width: 80px !important;
  min-width: 80px;
  font-size: 11px;
  padding: 4px 6px;
}

.log-controls button {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 4px 8px;
  font-size: 11px;
  min-width: auto;
}

@media (max-width: 768px) {

  .pie-controls,
  .log-controls {
    gap: 4px;
    flex-wrap: wrap;
  }

  .pie-controls .log-summary,
  .log-controls .log-summary {
    order: 5;
    flex-basis: 100%;
    text-align: left;
    margin-top: 4px;
  }

  .pie-controls select,
  .pie-controls input,
  .log-controls select,
  .log-controls input,
  .log-controls button {
    flex: 0 0 auto;
  }
}

/* オーバーレイ（掲示板/ランキング/編集モーダル） */
.overlay {
  position: fixed;
  inset: auto auto 10px 10px;
  width: 660px;
  height: 330px;
  display: none !important;
  pointer-events: none;
  z-index: 1000;
  visibility: hidden;
}

.overlay .card {
  /* 左上の四角い要素を削除 */
  display: none;
}

.ovHead {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ovBody {
  overflow: auto;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 8px;
  background: #fff;
}

.ovFoot {
  display: flex;
  gap: 8px;
  align-items: center;
}

.badgeTip {
  position: absolute;
  left: 50%;
  top: -24px;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  opacity: .9;
  display: none;
}

/* 共有モーダルUI（編集・アバター） */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .25);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  touch-action: auto;
  pointer-events: auto;
  overflow-y: auto;
  padding: 8px;
}

/* モバイル対応: モーダルを画面に収める */
@media (max-width: 768px) {
  .modal {
    align-items: flex-start;
    padding: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* モーダル内のボタンはタッチ操作可能にする */
.modal button,
.modal .mutebtn {
  touch-action: manipulation;
  pointer-events: auto;
  cursor: pointer;
}

.dialog {
  width: 520px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 18px;
  border: 2px solid var(--line);
  padding: 12px;
  box-shadow: 0 20px 0 var(--shadow);
}

/* プロジェクト編集モーダルをコンパクトに */
#editModal .dialog {
  max-width: 420px;
  /* 520px → 420px */
  width: 90%;
  padding: 16px;
  /* 10px → 16px */
}

/* プロジェクト編集モーダル内の大項目グリッド改善 */
#editModal .grid-2col {
  gap: 12px;
  /* 8px → 12px */
}

#editModal .grid-2col input {
  max-width: 180px;
  /* 幅を制限 */
  width: 100%;
  padding: 10px 12px;
  /* 統一 */
  font-size: 14px;
  /* 統一 */
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#editModal .grid-2col input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* プロジェクト編集モーダル内のセクション間隔調整 */
#editModal .mb-8 {
  margin-bottom: 20px;
  /* 統一 */
}

#editModal .section-title {
  margin-bottom: 8px;
  /* タイトルとコンテンツの間隔 */
}

/* プロジェクト編集モーダル内のサブ項目編集エリア改善 */
#editModal #editSubKindProjectSelect {
  width: 100%;
  /* 200px → 100% */
  max-width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#editModal #editSubKindProjectSelect:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* プロジェクト編集モーダル内のサブ項目編集アイテム改善 */
#editModal .subkind-edit-item {
  align-items: stretch;
  /* center → stretch */
}

#editModal .subkind-edit-item input {
  min-width: 0;
  /* 縮小を許可 */
}

/* プロジェクト編集モーダル内のラベルスタイル統一 */
#editModal label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

/* プロジェクト編集モーダル内の追加ボタン改善 */
#editModal #editSubKindAddBtn {
  width: 100%;
  /* 全幅ボタン */
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  margin-top: 8px;
}

/* プロジェクト編集モーダル内の保存ボタン改善 */
#editModal .row-end {
  margin-top: 16px;
  /* 8px → 16px */
}

#editModal #editSave {
  width: 100%;
  /* 全幅ボタン */
  padding: 12px 16px;
  /* 8px 16px → 12px 16px */
  font-size: 14px;
  /* 13px → 14px */
  font-weight: 600;
  border-radius: 8px;
}

.dialog h3 {
  margin: 0 0 6px 0;
  font-size: 14px;
}

.dialog .row-end {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.dialog label {
  font-weight: 700;
}

/* PC用レイアウト（大画面のみ横並び） */
@media (min-width: 1025px) {
  .sessionBar {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
  }

  .sessionBar-left {
    flex: 1;
    min-width: 0;
  }

  .sessionBar h1 {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .bgm-info {
    font-size: 11px;
  }

  .sessionBar-right {
    justify-content: flex-end;
    gap: 8px;
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

/* サブ項目編集画面のスタイル */
.subkinds-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.subkind-edit-item {
  display: flex;
  gap: 8px;
  align-items: center;
}

.subkind-edit-item input {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.3;
  min-height: 42px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.subkind-edit-item input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* プライバシー設定トグル */
.privacy-settings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.privacy-setting-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.privacy-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #d1d5db;
  background: #ffffff;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 13px;
  color: #1f2937;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.privacy-toggle-row:hover {
  border-color: #2563eb;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.15);
  transform: translateY(-1px);
}

.privacy-toggle-row:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.45);
  outline-offset: 2px;
}

.privacy-toggle-row.is-on {
  background: linear-gradient(135deg, #1f2937, #111827);
  border-color: #111827;
  color: #f9fafb;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.35);
}

.privacy-toggle-row__label {
  font-weight: 600;
  letter-spacing: 0.01em;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.privacy-toggle-row__state {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #1f2937;
}

.privacy-toggle-row.is-on .privacy-toggle-row__state {
  background: rgba(255, 255, 255, 0.18);
  color: #f9fafb;
}

.privacy-toggle-row__hint {
  font-size: 12px;
  color: #6b7280;
  letter-spacing: 0.01em;
}

.privacy-toggle-row__hint-inline {
  font-size: 10px;
  color: #6b7280;
  font-weight: 400;
}

.button-danger {
  background: #ef4444;
  color: #fff;
  border: 1px solid #dc2626;
}

.button-danger:hover {
  background: #dc2626;
}

.button-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
}

.button-secondary:hover {
  background: #e5e7eb;
}

.block {
  display: block;
}

.mb-4 {
  margin-bottom: 4px;
}

.mb-8 {
  margin-bottom: 8px;
}

.mt-4 {
  margin-top: 4px;
}

.w-200 {
  width: 200px;
}

/* （注）PCレイアウトは base の Grid 指定に従う。強制上書きは行わない。 */

/* ===== 魔法選択UI（古代ファンタジー風円盤） ===== */
.magic-circle {
  position: fixed;
  top: 50%;
  /* 画面の真ん中 */
  left: 50%;
  width: 200px;
  height: 200px;
  z-index: 10000;
  pointer-events: none;
  display: none;
  /* 初期状態は非表示 */
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5) rotate(-180deg);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.magic-circle.show {
  display: block;
  /* 表示時にblockに変更 */
  opacity: 1;
  transform: translate(-50%, -50%) scale(1) rotate(0deg);
}

.magic-circle-bg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at center,
      rgba(30, 20, 60, 0.95) 0%,
      rgba(15, 10, 40, 0.95) 50%,
      rgba(5, 5, 20, 0.95) 100%);
  border: 3px solid rgba(212, 175, 55, 0.8);
  box-shadow:
    0 0 40px rgba(147, 112, 219, 0.6),
    inset 0 0 60px rgba(75, 0, 130, 0.4),
    0 0 100px rgba(138, 43, 226, 0.3);
}

/* ルーン装飾 */
.magic-circle-runes {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
}

.rune {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-90px) rotate(calc(-1 * var(--angle)));
  font-size: 12px;
  color: rgba(212, 175, 55, 0.9);
  text-shadow: 0 0 10px rgba(212, 175, 55, 0.8);
  font-family: 'Times New Roman', serif;
  font-weight: bold;
}

/* 回転する魔法の光 */
.magic-circle-orbits {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
}

.orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  border-radius: 50%;
  animation: orbit-rotate 8s linear infinite;
}

.orbit-1 {
  animation-duration: 8s;
}

.orbit-2 {
  animation-duration: 12s;
  animation-direction: reverse;
}

.orbit-3 {
  animation-duration: 15s;
}

.orb-light {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 1) 0%, rgba(147, 112, 219, 0.8) 50%, transparent 100%);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.9), 0 0 20px rgba(147, 112, 219, 0.6);
  z-index: 1;
}

/* 光の跡 */
.orb-trail {
  position: absolute;
  top: 0;
  left: 50%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, transparent 70%);
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
  pointer-events: none;
  opacity: 0;
  transform-origin: 50% 100px;
  /* 回転の中心を軌道の中心に設定 */
  /* 軌道と同じ回転アニメーションを適用 */
  animation: orbit-rotate 8s linear infinite, orb-trail-fade 1.5s ease-out infinite;
}

/* 各跡の位置と遅延時間を設定（軌道に沿って配置、親要素の回転に合わせて回転） */
.orbit-1 .orb-trail {
  animation: orbit-rotate 8s linear infinite, orb-trail-fade 1.5s ease-out infinite;
}

.orbit-1 .orb-trail-1 {
  animation-delay: 0s, 0s;
  transform: translateX(-50%) translateY(-100px);
}

.orbit-1 .orb-trail-2 {
  animation-delay: 0s, 0.3s;
  transform: translateX(-50%) translateY(-100px) rotate(72deg);
}

.orbit-1 .orb-trail-3 {
  animation-delay: 0s, 0.6s;
  transform: translateX(-50%) translateY(-100px) rotate(144deg);
}

.orbit-1 .orb-trail-4 {
  animation-delay: 0s, 0.9s;
  transform: translateX(-50%) translateY(-100px) rotate(216deg);
}

.orbit-1 .orb-trail-5 {
  animation-delay: 0s, 1.2s;
  transform: translateX(-50%) translateY(-100px) rotate(288deg);
}

.orbit-2 .orb-trail {
  animation: orbit-rotate 12s linear infinite reverse, orb-trail-fade 1.5s ease-out infinite;
}

.orbit-2 .orb-trail-1 {
  animation-delay: 0s, 0s;
  transform: translateX(-50%) translateY(-100px);
}

.orbit-2 .orb-trail-2 {
  animation-delay: 0s, 0.3s;
  transform: translateX(-50%) translateY(-100px) rotate(72deg);
}

.orbit-2 .orb-trail-3 {
  animation-delay: 0s, 0.6s;
  transform: translateX(-50%) translateY(-100px) rotate(144deg);
}

.orbit-2 .orb-trail-4 {
  animation-delay: 0s, 0.9s;
  transform: translateX(-50%) translateY(-100px) rotate(216deg);
}

.orbit-2 .orb-trail-5 {
  animation-delay: 0s, 1.2s;
  transform: translateX(-50%) translateY(-100px) rotate(288deg);
}

.orbit-3 .orb-trail {
  animation: orbit-rotate 15s linear infinite, orb-trail-fade 1.5s ease-out infinite;
}

.orbit-3 .orb-trail-1 {
  animation-delay: 0s, 0s;
  transform: translateX(-50%) translateY(-100px);
}

.orbit-3 .orb-trail-2 {
  animation-delay: 0s, 0.3s;
  transform: translateX(-50%) translateY(-100px) rotate(72deg);
}

.orbit-3 .orb-trail-3 {
  animation-delay: 0s, 0.6s;
  transform: translateX(-50%) translateY(-100px) rotate(144deg);
}

.orbit-3 .orb-trail-4 {
  animation-delay: 0s, 0.9s;
  transform: translateX(-50%) translateY(-100px) rotate(216deg);
}

.orbit-3 .orb-trail-5 {
  animation-delay: 0s, 1.2s;
  transform: translateX(-50%) translateY(-100px) rotate(288deg);
}

@keyframes orb-trail-fade {
  0% {
    opacity: 0.5;
  }

  50% {
    opacity: 0.3;
  }

  100% {
    opacity: 0;
  }
}

/* 各軌道の跡の色を調整 */
.orbit-2 .orb-trail {
  background: radial-gradient(circle, rgba(255, 215, 0, 0.3) 0%, transparent 70%);
  box-shadow: 0 0 3px rgba(255, 215, 0, 0.2);
}

.orbit-3 .orb-trail {
  background: radial-gradient(circle, rgba(138, 43, 226, 0.3) 0%, transparent 70%);
  box-shadow: 0 0 3px rgba(138, 43, 226, 0.2);
}

.orbit-2 .orb-light {
  width: 4px;
  height: 4px;
  background: radial-gradient(circle, rgba(255, 215, 0, 1) 0%, rgba(255, 140, 0, 0.8) 50%, transparent 100%);
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.9), 0 0 15px rgba(255, 140, 0, 0.6);
}

.orbit-2 .orb-light::after {
  background: radial-gradient(circle, rgba(255, 215, 0, 0.5) 0%, transparent 70%);
  box-shadow: 0 0 6px rgba(255, 215, 0, 0.3);
}

.orbit-3 .orb-light {
  width: 5px;
  height: 5px;
  background: radial-gradient(circle, rgba(138, 43, 226, 1) 0%, rgba(75, 0, 130, 0.8) 50%, transparent 100%);
  box-shadow: 0 0 9px rgba(138, 43, 226, 0.9), 0 0 18px rgba(75, 0, 130, 0.6);
}

.orbit-3 .orb-light::after {
  background: radial-gradient(circle, rgba(138, 43, 226, 0.5) 0%, transparent 70%);
  box-shadow: 0 0 7px rgba(138, 43, 226, 0.3);
}

@keyframes orbit-rotate {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }

  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* 呪文アイコン */
.magic-spell {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.2s ease, filter 0.2s ease;
  pointer-events: none;
  z-index: 20;
  /* 水晶より前面に表示 */
}

.magic-spell-up {
  transform: translate(-50%, -50%) translateY(-70px);
}

.magic-spell-right {
  transform: translate(-50%, -50%) translateX(70px);
}

.magic-spell-down {
  transform: translate(-50%, -50%) translateY(70px);
}

.magic-spell-left {
  transform: translate(-50%, -50%) translateX(-70px);
}

.magic-spell.selected {
  /* 中央に移動せず、元の位置で強調 */
  filter: brightness(1.5) drop-shadow(0 0 15px rgba(255, 255, 255, 0.8));
  animation: spell-pulse 0.5s ease infinite;
}

/* 各方向の選択時も元の位置を保持 */
.magic-spell-up.selected {
  animation: spell-pulse-up 0.5s ease infinite;
}

.magic-spell-right.selected {
  animation: spell-pulse-right 0.5s ease infinite;
}

.magic-spell-down.selected {
  animation: spell-pulse-down 0.5s ease infinite;
}

.magic-spell-left.selected {
  animation: spell-pulse-left 0.5s ease infinite;
}

@keyframes spell-pulse-up {

  0%,
  100% {
    transform: translate(-50%, -50%) translateY(-70px) scale(1.2);
  }

  50% {
    transform: translate(-50%, -50%) translateY(-70px) scale(1.3);
  }
}

@keyframes spell-pulse-right {

  0%,
  100% {
    transform: translate(-50%, -50%) translateX(70px) scale(1.2);
  }

  50% {
    transform: translate(-50%, -50%) translateX(70px) scale(1.3);
  }
}

@keyframes spell-pulse-down {

  0%,
  100% {
    transform: translate(-50%, -50%) translateY(70px) scale(1.2);
  }

  50% {
    transform: translate(-50%, -50%) translateY(70px) scale(1.3);
  }
}

@keyframes spell-pulse-left {

  0%,
  100% {
    transform: translate(-50%, -50%) translateX(-70px) scale(1.2);
  }

  50% {
    transform: translate(-50%, -50%) translateX(-70px) scale(1.3);
  }
}

.spell-icon {
  font-size: 24px;
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
  transition: transform 0.2s ease;
}

.magic-spell.selected .spell-icon {
  animation: icon-glow 0.5s ease infinite;
}

@keyframes icon-glow {

  0%,
  100% {
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
  }

  50% {
    filter: drop-shadow(0 0 25px rgba(255, 255, 255, 1));
  }
}

.spell-label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* 中央の水晶 */
.magic-crystal {
  position: absolute;
  top: 50%;
  left: 50%;
  /* transformは下の定義で動的に設定される */
  width: 40px;
  height: 40px;
  pointer-events: none;
  transition: transform 140ms ease-out;
  z-index: 1;
  /* 魔法アイコンの後ろに配置 */
  /* CSS変数のデフォルト値 */
  --crystal-x: 0;
  --crystal-y: 0;
}

.crystal-core {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, rgba(255, 255, 210, 0.95) 0%, rgba(255, 225, 140, 0.92) 35%, rgba(255, 185, 90, 0.88) 65%, rgba(215, 120, 45, 0.85) 100%),
    conic-gradient(from 0deg, rgba(255, 245, 200, 0.4), rgba(255, 200, 120, 0.15), rgba(255, 245, 200, 0.4));
  box-shadow:
    0 0 25px rgba(255, 200, 90, 0.6),
    0 0 45px rgba(255, 160, 60, 0.45),
    inset 0 0 12px rgba(255, 255, 220, 0.75);
  animation: crystal-pulse 2s ease-in-out infinite;
}

.crystal-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 210, 120, 0.45) 0%, rgba(255, 170, 80, 0.25) 55%, transparent 80%);
  animation: crystal-glow-pulse 1.8s ease-in-out infinite;
}

/* 水晶を相対座標で移動（モバイル魔法ボタンとの連動用） */
.magic-crystal {
  --crystal-x: 0;
  --crystal-y: 0;
  transition: transform 140ms ease-out;
  /* デフォルトは中央、CSS変数がある場合は相対座標で移動 */
  /* !importantを追加して、move-to-*クラスより優先させる */
  transform: translate(calc(-50% + var(--crystal-x, 0)), calc(-50% + var(--crystal-y, 0))) !important;
}

/* 水晶が選択した魔法の位置に移動（少し手前まで）- キーボード操作用 */
.magic-crystal.move-to-up:not([style*="--crystal-x"]) {
  transform: translate(-50%, -50%) translateY(-55px);
  /* 70px → 55px（少し手前） */
}

.magic-crystal.move-to-right:not([style*="--crystal-x"]) {
  transform: translate(-50%, -50%) translateX(55px);
  /* 70px → 55px（少し手前） */
}

.magic-crystal.move-to-down:not([style*="--crystal-x"]) {
  transform: translate(-50%, -50%) translateY(55px);
  /* 70px → 55px（少し手前） */
}

.magic-crystal.move-to-left:not([style*="--crystal-x"]) {
  transform: translate(-50%, -50%) translateX(-55px);
  /* 70px → 55px（少し手前） */
}

@keyframes crystal-pulse {

  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.9;
  }

  50% {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 1;
  }
}

@keyframes crystal-glow-pulse {

  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.4;
  }

  50% {
    transform: translate(-50%, -50%) scale(1.2);
    opacity: 0.6;
  }
}

/* 選択時の光のエフェクト */
.magic-selection-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
  transition: opacity 0.3s ease;
}

.magic-circle.casting .magic-selection-glow {
  opacity: 1;
  animation: casting-explosion 0.5s ease-out;
}

@keyframes casting-explosion {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.3;
  }

  50% {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 0.8;
  }

  100% {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0;
  }
}

/* 円盤が閉じるアニメーション */
.magic-circle.closing {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5) rotate(180deg);
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 選択時も軌道のアニメーションは継続（速度変更なし） */