* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: rgba(52, 152, 219, 0.3);
}

/* タッチ操作最適化 */
button, .grid-cell, .cycle-label {
  touch-action: manipulation;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  min-height: 100vh;
  color: #fff;
  padding: 16px;
  overflow-x: hidden;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* ヘッダー */
.header {
  text-align: center;
  margin-bottom: 20px;
}

.header h1 {
  font-size: 1.5rem;
  margin-bottom: 12px;
  background: linear-gradient(90deg, #ff6b6b, #ffd93d);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  padding: 6px 12px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-reset {
  background: #e74c3c;
  color: #fff;
}

.btn-reset:hover {
  background: #c0392b;
}

.btn-cz-predict {
  background: #9b59b6;
  color: #fff;
  width: 100%;
  margin-top: 6px;
  padding: 6px 8px;
  font-size: 0.7rem;
}

.btn-cz-predict:hover {
  background: #8e44ad;
}

.btn-cz-predict-small {
  background: #9b59b6;
  color: #fff;
  padding: 4px 8px;
  font-size: 0.65rem;
  margin-left: 4px;
  border-radius: 4px;
}

.btn-cz-predict-small:hover {
  background: #8e44ad;
}

/* CZ推算回数表示 */
.cz-status {
  margin-top: 8px;
  padding: 8px 12px;
  background-color: #f0f0f0;
  border-radius: 4px;
  font-size: 14px;
  color: #333;
  text-align: center;
}

#cz-prediction-count {
  font-weight: bold;
  color: #d32f2f;
}

/* トグル */
.toggle-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.toggle-label {
  font-size: 0.85rem;
  color: #aaa;
  min-width: 80px;
  text-align: right;
}

.toggle-group {
  display: flex;
  background: rgba(255,255,255,0.1);
  border-radius: 8px;
  overflow: hidden;
}

.toggle-btn,
.state-toggle-btn,
.prev-mode-btn {
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: #aaa;
  cursor: pointer;
  font-size: 0.7rem;
  transition: all 0.2s;
}

.toggle-btn.active {
  background: #3498db;
  color: #fff;
}

.state-toggle-btn.active {
  background: #9b59b6;
  color: #fff;
}

.prev-mode-btn.active {
  background: #e67e22;
  color: #fff;
}

.prev-mode-group {
  gap: 2px;
}

/* メインレイアウト */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
}

@media (max-width: 900px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* グリッド */
.grid-section {
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 16px;
}

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

.grid-section h2 {
  font-size: 1rem;
  margin-bottom: 0;
  color: #ffd93d;
}

.paint-mode-btns {
  display: flex;
  gap: 4px;
}

.paint-btn {
  width: 28px;
  height: 28px;
  border: 2px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.7rem;
  transition: all 0.15s;
}

.paint-btn[data-paint="pass"] {
  background: #3498db;
  color: #fff;
}

.paint-btn[data-paint="develop"] {
  background: #2ecc71;
  color: #fff;
}

.paint-btn[data-paint="current"] {
  background: #e67e22;
  color: #fff;
}

.paint-btn.active {
  border-color: #fff;
  box-shadow: 0 0 12px rgba(255,255,255,0.8), 0 0 20px currentColor;
  transform: scale(1.15);
  animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 12px rgba(255,255,255,0.8), 0 0 20px currentColor;
  }
  50% {
    box-shadow: 0 0 18px rgba(255,255,255,1), 0 0 30px currentColor;
  }
}

.grid-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.grid-table th,
.grid-table td {
  padding: 8px 4px;
  text-align: center;
  font-size: 0.85rem;
}

.grid-table th {
  color: #aaa;
  font-weight: 500;
}

.grid-table th.cycle-header {
  width: 30px;
}

.grid-cell {
  width: 100%;
  height: 40px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.75rem;
}

.grid-cell.none {
  background: rgba(255,255,255,0.1);
  color: #666;
}

.grid-cell.none.can-develop {
  background: rgba(46, 204, 113, 0.25);
  border: 1px solid rgba(46, 204, 113, 0.4);
  color: #2ecc71;
}

.grid-cell.current {
  background: #e67e22;
  color: #fff;
}

.grid-cell.pass {
  background: #3498db;
  color: #fff;
}

.grid-cell.develop {
  background: #2ecc71;
  color: #fff;
}

.grid-cell.disabled {
  background: rgba(255,255,255,0.03);
  color: #333;
  cursor: not-allowed;
}

.grid-cell:not(.disabled):hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* 結果セクション */
.result-section {
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 16px;
}

.result-section h2 {
  font-size: 1rem;
  margin-bottom: 16px;
  color: #ffd93d;
}

/* 統合ログセクション */
.unified-log-section {
  margin: 15px 0;
  padding: 8px 0;
}

.unified-log-section h2 {
  font-size: 0.9rem;
  margin: 0 0 8px 0;
  color: #ecf0f1;
  font-weight: 500;
}

.unified-log-entries {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.unified-log-entry {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.4;
}

/* 矢印セパレーター */
.unified-log-entry:not(:last-child)::after {
  content: '→';
  margin-left: 8px;
  color: #95a5a6;
  font-size: 0.9rem;
}

.log-cycle {
  font-weight: bold;
  color: #3498db;
  flex-shrink: 0;
}

.log-content {
  flex: 1;
  color: #ecf0f1;
  white-space: nowrap;
}

.log-remove-btn {
  color: #e74c3c;
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

.log-remove-btn:hover {
  color: #c0392b;
}

/* プログレスバー */
.mode-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.bar-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  min-width: 45px;
  flex-shrink: 0;
}

.progress-bar {
  flex: 1;
  height: 24px;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  transition: width 0.3s ease;
  border-radius: 6px;
}

.bar-percent {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  min-width: 50px;
  text-align: right;
  flex-shrink: 0;
}

.mode-normalA .progress-fill { background: linear-gradient(90deg, #e74c3c, #c0392b); }
.mode-normalB .progress-fill { background: linear-gradient(90deg, #3498db, #2980b9); }
.mode-normalC .progress-fill { background: linear-gradient(90deg, #2ecc71, #27ae60); }
.mode-heaven .progress-fill { background: linear-gradient(90deg, #f1c40f, #f39c12); }

/* 残りpt表示 */
.remaining-section {
  margin-top: 20px;
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 16px;
  overflow-x: auto;
}

/* 残りpt情報セクションのみ非表示（IDなしのセクション） */
.remaining-section:not([id]) {
  display: none !important;
}

.remaining-section h2 {
  font-size: 1rem;
  margin-bottom: 12px;
  color: #ffd93d;
}

.remaining-info {
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 12px;
}

.remaining-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.remaining-table th,
.remaining-table td {
  padding: 8px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.remaining-table th {
  color: #aaa;
  font-weight: 500;
}

.remaining-table th .th-desc {
  font-size: 0.65rem;
  font-weight: 400;
  color: #777;
  margin-top: 2px;
}

.remaining-table td {
  color: #fff;
}

.remaining-table .highlight {
  color: #2ecc71;
  font-weight: 700;
}

/* 凡例 */
.legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
  font-size: 0.75rem;
  color: #aaa;
}

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

.legend-box {
  width: 16px;
  height: 16px;
  border-radius: 4px;
}

.legend-box.none { background: rgba(255,255,255,0.1); }
.legend-box.can-develop { background: rgba(46, 204, 113, 0.25); border: 1px solid rgba(46, 204, 113, 0.4); }
.legend-box.current { background: #e67e22; }
.legend-box.pass { background: #3498db; }
.legend-box.develop { background: #2ecc71; }

/* 当選まで想定PT */
/* 当選まで想定PTセクションを完全非表示 */
#expectedSection {
  display: none !important;
}

.expected-section {
  margin-top: 20px;
  background: linear-gradient(135deg, rgba(230, 126, 34, 0.2), rgba(241, 196, 15, 0.1));
  border: 1px solid rgba(230, 126, 34, 0.4);
  border-radius: 12px;
  padding: 16px;
  overflow-x: auto;
}

.expected-section h2 {
  font-size: 1rem;
  margin-bottom: 12px;
  color: #e67e22;
}

.expected-summary {
  margin-bottom: 16px;
}

.expected-main {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.expected-label {
  font-size: 0.9rem;
  color: #aaa;
}

.expected-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #f1c40f;
}

.expected-position {
  font-size: 0.8rem;
  color: #aaa;
}

.expected-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.expected-table th,
.expected-table td {
  padding: 8px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.expected-table th {
  color: #aaa;
  font-weight: 500;
}

.expected-table td {
  color: #fff;
}

.expected-table .highlight {
  color: #f1c40f;
  font-weight: 700;
}

/* 状態選択メニュー */
.state-menu {
  display: flex;
  gap: 4px;
  background: rgba(30, 30, 50, 0.95);
  padding: 8px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  z-index: 1000;
}

.state-menu-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 0.1s;
}

.state-menu-btn:active {
  transform: scale(0.95);
}

.state-menu-btn.none {
  background: rgba(255,255,255,0.2);
  color: #aaa;
}

.state-menu-btn.pass {
  background: #3498db;
  color: #fff;
}

.state-menu-btn.develop {
  background: #2ecc71;
  color: #fff;
}

.state-menu-btn.current {
  background: #e67e22;
  color: #fff;
}

/* ========== マギウス関連スタイル ========== */

/* マギウスボタン（緑色） */
.paint-btn.magius {
  background: #27ae60;
  color: #fff;
}

.paint-btn.magius.active {
  border-color: #fff;
  box-shadow: 0 0 12px rgba(255,255,255,0.8), 0 0 25px rgba(39, 174, 96, 0.9);
  transform: scale(1.15);
  animation: pulse-glow-magius 1.5s ease-in-out infinite;
}

@keyframes pulse-glow-magius {
  0%, 100% {
    box-shadow: 0 0 12px rgba(255,255,255,0.8), 0 0 25px rgba(39, 174, 96, 0.9);
  }
  50% {
    box-shadow: 0 0 18px rgba(255,255,255,1), 0 0 35px rgba(39, 174, 96, 1);
  }
}

/* マギウス凡例 */
.legend-box.magius {
  background: rgba(39, 174, 96, 0.4);
  border: 2px solid #27ae60;
}

/* マギウス適用周期（緑背景） */
tr.magius-applied {
  background: rgba(39, 174, 96, 0.2) !important;
}

tr.magius-applied th {
  background: rgba(39, 174, 96, 0.4);
  color: #2ecc71;
}

/* マギウスアイコン */
.magius-icon {
  display: inline-block;
  background: #27ae60;
  color: #fff;
  font-size: 0.65rem;
  padding: 2px 4px;
  border-radius: 3px;
  margin-left: 4px;
  font-weight: 700;
}

/* 無効化周期（グレーアウト） */
tr.cycle-disabled {
  opacity: 0.35;
}

tr.cycle-disabled td,
tr.cycle-disabled th {
  background: rgba(100, 100, 100, 0.2);
  color: #666;
}

tr.cycle-disabled .grid-cell {
  cursor: not-allowed;
  pointer-events: none;
}

/* 周期ラベル（マギウスモード時クリック可能） */
.cycle-label {
  cursor: pointer;
  transition: background 0.15s;
  pointer-events: auto !important;
}

.cycle-label:hover {
  background: rgba(39, 174, 96, 0.3) !important;
}

tr.cycle-disabled .cycle-label {
  opacity: 1;
  color: #aaa;
}

/* ========== 当選率テーブル ========== */
.win-rate-section {
  margin-top: 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 16px;
  overflow-x: auto;
}

.win-rate-section h2 {
  font-size: 1rem;
  margin-bottom: 12px;
  color: #2ecc71;
}

.magius-info {
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: rgba(39, 174, 96, 0.15);
  border-radius: 6px;
  border-left: 3px solid #27ae60;
}

.magius-info span {
  color: #2ecc71;
  font-weight: 700;
}

.magius-confirm {
  background: #f1c40f;
  color: #000 !important;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 8px;
  font-size: 0.8rem;
  animation: blink-confirm 1s ease-in-out infinite;
}

@keyframes blink-confirm {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.win-rate-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.win-rate-table th,
.win-rate-table td {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.win-rate-table th {
  color: #aaa;
  font-weight: 500;
}

.win-rate-table td {
  color: #fff;
}

/* 天井周期の100%表示 */
.win-rate-table .ceiling-rate {
  color: #f1c40f;
  font-weight: 700;
  background: rgba(241, 196, 15, 0.15);
}

/* 無効化された当選率 */
.win-rate-table .disabled-rate {
  color: #555;
}

/* 当選率引き上げ表示 */
.original-rate {
  color: #888;
  text-decoration: line-through;
  font-size: 0.75rem;
}

.boosted-rate {
  color: #2ecc71;
  font-weight: 700;
}

/* 総合期待度列のスタイル - 他の列と統一 */
.overall-column {
  /* デフォルトの th スタイルを継承 */
}

.overall-expectation {
  /* デフォルトの td スタイルを継承 */
}

/* ========== 演出選択セクション ========== */
.production-section {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.production-section h2 {
  font-size: 1rem;
  margin-bottom: 12px;
  color: #9b59b6;
}

.prod-group {
  margin-bottom: 12px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

.prod-group:last-child {
  margin-bottom: 0;
}

.prod-label {
  font-size: 0.8rem;
  color: #aaa;
  margin-bottom: 8px;
}

.prod-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.prod-controls select {
  padding: 6px 10px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 0.75rem;
  cursor: pointer;
  min-width: 100px;
}

.prod-controls select:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.prod-controls select option {
  background: #1a1a2e;
  color: #fff;
}

.prod-effect {
  font-size: 0.7rem;
  color: #2ecc71;
  margin-top: 6px;
  min-height: 1em;
}

/* モード示唆ボタン */
.mode-hint-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-hint-btn {
  padding: 6px 12px;
  border: 2px solid transparent;
  border-radius: 6px;
  background: rgba(155, 89, 182, 0.3);
  color: #9b59b6;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-hint-btn:hover {
  background: rgba(155, 89, 182, 0.5);
}

.mode-hint-btn.active {
  background: #9b59b6;
  color: #fff;
  border-color: #fff;
  box-shadow: 0 0 10px rgba(155, 89, 182, 0.6);
}

/* ========== タップフィードバック ========== */
.grid-cell:active:not(.disabled) {
  transform: scale(0.9);
  opacity: 0.8;
}

.paint-btn:active,
.btn:active,
.toggle-btn:active,
.state-toggle-btn:active,
.prev-mode-btn:active {
  transform: scale(0.95);
  opacity: 0.9;
}

/* ========== モバイル最適化 ========== */
@media (max-width: 768px) {
  body {
    padding: 8px;
  }

  .header h1 {
    font-size: 1.1rem;
    line-height: 1.3;
  }

  .header {
    margin-bottom: 12px;
  }

  /* メインレイアウト - モード期待度を先に表示 */
  .main-layout {
    display: flex;
    flex-direction: column;
  }

  .result-section {
    order: 1;
    width: 100%;
    margin-bottom: 12px;
  }

  .grid-section {
    order: 2;
    width: 100%;
    margin-bottom: 12px;
  }

  /* ボタンサイズ */
  .btn {
    min-height: 36px;
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  .paint-btn {
    width: 34px;
    height: 34px;
    font-size: 0.8rem;
  }

  .paint-mode-btns {
    gap: 4px;
  }

  /* トグルボタン */
  .toggle-btn,
  .state-toggle-btn,
  .prev-mode-btn {
    padding: 8px 8px;
    min-height: 32px;
    font-size: 0.65rem;
  }

  .toggle-container {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  .toggle-label {
    min-width: auto;
    font-size: 0.8rem;
    text-align: left;
    margin-bottom: 2px;
  }

  .toggle-group {
    flex-wrap: wrap;
    width: 100%;
    justify-content: center;
  }

  /* 前回滞在選択の縦並び */
  #prevModeSelect {
    flex-direction: column;
    gap: 8px;
  }

  #prevModeSelect .toggle-group {
    order: 1;
  }

  #prevModeSelect .btn-cz-predict-small {
    order: 2;
    width: 100%;
    margin-left: 0;
    margin-top: 4px;
  }

  /* グリッドテーブル横スクロール */
  .grid-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -12px;
    padding: 0 12px;
    position: relative;
  }

  .grid-cell {
    height: 36px;
    font-size: 0.7rem;
  }

  .grid-table th,
  .grid-table td {
    padding: 4px 2px;
    font-size: 0.7rem;
  }

  .grid-table th.cycle-header {
    width: 28px;
    position: sticky;
    left: 0;
    background: rgba(26, 26, 46, 0.95);
    z-index: 10;
  }

  /* 周期ラベルを固定 */
  .grid-table tbody th {
    position: sticky;
    left: 0;
    background: rgba(26, 26, 46, 0.95);
    z-index: 10;
  }

  tr.magius-applied th {
    background: rgba(39, 174, 96, 0.6);
  }

  tr.cycle-disabled th {
    background: rgba(100, 100, 100, 0.4);
  }

  /* スクロールヒント（6列表示で不要） */
  .scroll-hint {
    display: none;
  }

  /* 凡例 */
  .legend {
    flex-wrap: wrap;
    gap: 6px 10px;
    font-size: 0.65rem;
  }

  .legend-box {
    width: 14px;
    height: 14px;
  }

  /* グリッドセクション */
  .grid-section {
    padding: 8px;
  }

  .grid-header {
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
  }

  .grid-section h2 {
    font-size: 0.85rem;
    margin-bottom: 0;
  }

  /* 結果セクション（モード期待度） */
  .result-section {
    padding: 8px;
  }

  .result-section h2 {
    font-size: 0.85rem;
    margin-bottom: 8px;
  }

  .mode-item {
    margin-bottom: 6px;
    gap: 6px;
  }

  .bar-name {
    font-size: 0.7rem;
    min-width: 38px;
  }

  .progress-bar {
    height: 20px;
  }

  .bar-percent {
    font-size: 0.75rem;
    min-width: 42px;
  }

  .btn-cz-predict {
    margin-top: 10px;
    padding: 10px;
    font-size: 0.8rem;
  }

  /* 残りpt・想定PT・当選率テーブル */
  .remaining-section,
  .expected-section,
  .win-rate-section {
    margin-top: 12px;
    padding: 12px;
  }

  .remaining-section h2,
  .expected-section h2,
  .win-rate-section h2 {
    font-size: 0.9rem;
    margin-bottom: 8px;
  }

  .remaining-table,
  .expected-table,
  .win-rate-table {
    font-size: 0.7rem;
  }

  .remaining-table th,
  .remaining-table td,
  .expected-table th,
  .expected-table td,
  .win-rate-table th,
  .win-rate-table td {
    padding: 6px 4px;
  }

  .th-desc {
    font-size: 0.55rem;
  }

  .expected-value {
    font-size: 1.5rem;
  }

  .expected-label {
    font-size: 0.8rem;
  }

  .expected-position {
    font-size: 0.7rem;
  }

  .magius-info {
    font-size: 0.75rem;
    padding: 6px 10px;
  }

  /* CZ推測ボタン */
  .btn-cz-predict {
    margin-top: 6px;
    padding: 6px 8px;
    font-size: 0.7rem;
  }

  .btn-cz-predict-small {
    padding: 5px 8px;
    font-size: 0.6rem;
    margin-left: 4px;
    white-space: nowrap;
  }

  /* 状態選択メニュー */
  .state-menu {
    padding: 6px;
  }

  .state-menu-btn {
    width: 44px;
    height: 44px;
    font-size: 1rem;
  }

  /* 演出選択セクション */
  .production-section {
    padding: 10px;
    margin-bottom: 8px;
  }

  .production-section h2 {
    font-size: 0.9rem;
    margin-bottom: 8px;
  }

  .prod-group {
    padding: 8px;
    margin-bottom: 8px;
  }

  .prod-label {
    font-size: 0.7rem;
    margin-bottom: 6px;
  }

  .prod-controls {
    gap: 6px;
  }

  .prod-controls select {
    padding: 5px 8px;
    font-size: 0.7rem;
    min-width: 80px;
  }

  .prod-effect {
    font-size: 0.65rem;
  }

  .mode-hint-btn {
    padding: 5px 10px;
    font-size: 0.65rem;
  }
}

/* 超小型画面（iPhone SE等） */
@media (max-width: 375px) {
  body {
    padding: 6px;
  }

  .header h1 {
    font-size: 1rem;
  }

  .toggle-btn,
  .state-toggle-btn,
  .prev-mode-btn {
    padding: 6px 6px;
    font-size: 0.6rem;
  }

  .grid-cell {
    height: 32px;
  }

  .paint-btn {
    width: 32px;
    height: 32px;
  }

  /* 固定アクションボタン - 超小型画面 */
  .fixed-actions {
    bottom: 6px;
    right: 6px;
    gap: 4px;
  }

  .settings-btn,
  .fixed-actions .btn-reset {
    padding: 6px 10px;
    font-size: 11px;
    min-width: 70px;
  }
}

/* ========== タブナビゲーション ========== */
.tab-nav {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 12px;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: #aaa;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  background: rgba(155, 89, 182, 0.2);
  color: #ccc;
}

.tab-btn.active {
  background: #9b59b6;
  color: #fff;
  box-shadow: 0 2px 8px rgba(155, 89, 182, 0.4);
}

/* タブコンテンツ */
.tab-content {
  position: relative;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== 演出選択タブコンテンツ ========== */
.production-tab-content {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 16px;
}

/* カテゴリ */
.prod-category {
  margin-bottom: 20px;
}

.prod-category:last-child {
  margin-bottom: 0;
}

.prod-category h3 {
  font-size: 0.95rem;
  color: #9b59b6;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(155, 89, 182, 0.3);
}

/* カードグリッド */
.prod-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.voice-cards,
.pino-cards {
  grid-template-columns: repeat(3, 1fr);
}

.text-cards {
  grid-template-columns: repeat(3, 1fr);
}

/* リスト選択式 */
.prod-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.prod-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  font-size: 0.9rem;
}

.prod-list-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.prod-list-item.selected {
  background: rgba(155, 89, 182, 0.3);
  border-color: #9b59b6;
}

.prod-list-item input[type="radio"],
.prod-list-item input[type="checkbox"] {
  display: none;
}

.prod-list-item .radio-mark {
  width: 16px;
  height: 16px;
  border: 2px solid #666;
  border-radius: 50%;
  flex-shrink: 0;
}

.prod-list-item.selected .radio-mark {
  border-color: #9b59b6;
  background: #9b59b6;
}

.prod-list-item .item-effect {
  margin-left: auto;
  font-size: 0.75rem;
  color: #aaa;
}

/* リスト項目の周期選択 */
.list-cycle-btns {
  display: none;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0 0 6px 6px;
  margin-top: -4px;
}

.list-cycle-btns.expanded {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* ピノPT選択（リスト用） */
.list-pt-select {
  margin-left: 8px;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid #555;
  border-radius: 4px;
  color: #fff;
  font-size: 0.8rem;
}

/* カード共通 */
.prod-card {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  border: 3px solid transparent;
  background: rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.prod-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.prod-card:active {
  transform: scale(0.98);
}

.prod-card.selected {
  border-color: #f1c40f;
  box-shadow: 0 0 15px rgba(241, 196, 15, 0.5);
}

/* カード選択中（周期ボタン展開時） */
.prod-card.selecting {
  border-color: #9b59b6;
  box-shadow: 0 0 12px rgba(155, 89, 182, 0.5);
}

.prod-card.selected::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 6px;
  background: #f1c40f;
  color: #000;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: bold;
  z-index: 10;
}

/* カード画像 */
.prod-card img {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 4/3;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.5);
  max-height: 80px;
}

/* カードラベル */
.card-label {
  display: block;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 4px 6px;
  font-size: 0.65rem;
  font-weight: 600;
  text-align: center;
}

/* カード効果説明 */
.card-effect {
  display: block;
  background: rgba(46, 204, 113, 0.2);
  color: #2ecc71;
  padding: 4px 6px;
  font-size: 0.6rem;
  text-align: center;
  border-top: 1px solid rgba(46, 204, 113, 0.3);
}

/* テキストカード（ピノセリフ用） */
.prod-card.text-card {
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 80px;
  background: linear-gradient(135deg, rgba(155, 89, 182, 0.2), rgba(241, 196, 15, 0.1));
}

.prod-card.text-card .card-text {
  font-size: 0.9rem;
  font-weight: 700;
  color: #f1c40f;
  margin-bottom: 6px;
  text-align: center;
}

.prod-card.text-card .card-effect {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 0.65rem;
}

/* 周期選択セレクター */
.cycle-selector,
.cycle-pt-selector {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(155, 89, 182, 0.15);
  border-radius: 8px;
  border-left: 3px solid #9b59b6;
}

.selector-label {
  font-size: 0.8rem;
  color: #aaa;
  margin-right: 8px;
}

.selector-row {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.selector-row:last-child {
  margin-bottom: 0;
}

.cycle-selector select,
.cycle-pt-selector select {
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 0.8rem;
  cursor: pointer;
  min-width: 100px;
}

.cycle-selector select option,
.cycle-pt-selector select option {
  background: #1a1a2e;
  color: #fff;
}

/* 選択状況サマリー */
.prod-summary {
  margin-top: 20px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(241, 196, 15, 0.15), rgba(230, 126, 34, 0.1));
  border-radius: 10px;
  border: 1px solid rgba(241, 196, 15, 0.3);
}

.prod-summary h3 {
  font-size: 0.85rem;
  color: #f1c40f;
  margin-bottom: 8px;
}

.summary-content {
  font-size: 0.8rem;
  color: #aaa;
  margin-bottom: 10px;
  min-height: 1.5em;
}

.summary-item {
  display: block;
  color: #fff;
  margin-bottom: 4px;
}

.summary-item .item-label {
  color: #9b59b6;
  margin-right: 4px;
}

.btn-clear-prod {
  background: rgba(231, 76, 60, 0.3);
  color: #e74c3c;
  border: 1px solid rgba(231, 76, 60, 0.5);
  padding: 8px 16px;
  font-size: 0.75rem;
  width: 100%;
}

.btn-clear-prod:hover {
  background: rgba(231, 76, 60, 0.5);
  color: #fff;
}

/* ========== 演出選択モバイル最適化 ========== */
@media (max-width: 768px) {
  .tab-nav {
    margin-bottom: 10px;
  }

  .tab-btn {
    padding: 10px 12px;
    font-size: 0.85rem;
  }

  .production-tab-content {
    padding: 12px;
  }

  .prod-category h3 {
    font-size: 0.85rem;
    margin-bottom: 10px;
  }

  .prod-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .voice-cards,
  .pino-cards {
    grid-template-columns: repeat(3, 1fr);
  }

  .text-cards {
    grid-template-columns: repeat(3, 1fr);
  }

  .prod-card {
    border-radius: 8px;
  }

  .prod-card img {
    max-height: 60px;
  }

  .card-label {
    font-size: 0.6rem;
    padding: 3px 4px;
  }

  .card-effect {
    font-size: 0.55rem;
    padding: 3px 4px;
  }

  .prod-card.text-card {
    min-height: 70px;
    padding: 8px;
  }

  .prod-card.text-card .card-text {
    font-size: 0.75rem;
  }

  .prod-card.text-card .card-effect {
    font-size: 0.55rem;
  }

  .cycle-selector,
  .cycle-pt-selector {
    padding: 8px 10px;
  }

  .selector-label {
    font-size: 0.75rem;
  }

  .cycle-selector select,
  .cycle-pt-selector select {
    padding: 6px 10px;
    font-size: 0.75rem;
    min-width: 80px;
  }

  .prod-summary {
    padding: 10px;
  }

  .prod-summary h3 {
    font-size: 0.8rem;
  }

  .summary-content {
    font-size: 0.75rem;
  }

  .btn-clear-prod {
    padding: 6px 12px;
    font-size: 0.7rem;
  }

  .mode-hint-btns {
    gap: 6px;
  }

  .mode-hint-btn {
    padding: 8px 12px;
    font-size: 0.7rem;
  }
}

@media (max-width: 375px) {
  .tab-btn {
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  .prod-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .voice-cards,
  .pino-cards,
  .text-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .prod-card.text-card {
    min-height: 60px;
  }

  .prod-card.text-card .card-text {
    font-size: 0.7rem;
  }

  .prod-card img {
    max-height: 50px;
  }
}

/* ========== グローバル結果セクション（タブ外） ========== */
.global-result {
  margin-bottom: 12px;
}

/* ========== 選択状態ログ ========== */
.selection-log {
  padding: 8px 0;
  margin-bottom: 12px;
  display: none !important;  /* 完全非表示に固定 */
}

.selection-log h3 {
  font-size: 0.85rem;
  color: #ecf0f1;
  margin-bottom: 8px;
}

.log-entries {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.log-entry {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
}

/* 矢印セパレーター */
.log-entry:not(:last-child)::after {
  content: '→';
  margin-left: 8px;
  color: #95a5a6;
  font-size: 0.9rem;
}

.log-entry-text {
  font-size: 0.8rem;
  color: #ecf0f1;
  white-space: nowrap;
}

.log-category {
  color: #9b59b6;
  margin-right: 6px;
  font-weight: 600;
}

.log-entry-remove {
  color: #e74c3c;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 2px;
}

.log-entry-remove:hover {
  color: #c0392b;
}

.log-empty {
  font-size: 0.8rem;
  color: #aaa;
}

.btn-clear-log {
  background: none;
  color: #e74c3c;
  border: 1px solid #e74c3c;
  padding: 6px 12px;
  font-size: 0.75rem;
  width: 100%;
  cursor: pointer;
}

.btn-clear-log:hover {
  background: #e74c3c;
  color: #fff;
}

/* ========== 想定期待値セクション ========== */
.expected-ev-section {
  margin-bottom: 12px;
}

.expected-ev-content {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
}

.expected-ev-row {
  display: flex;
  align-items: center;
  padding: 0;
  background: none;
  border-radius: 0;
  gap: 4px;
}

.expected-ev-label {
  font-size: 0.9rem;
  color: #ecf0f1;
  font-weight: 500;
}

.expected-ev-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
}

.expected-ev-value.positive {
  color: #2ecc71;
}

.expected-ev-value.negative {
  color: #e74c3c;
}

.expected-ev-value.neutral {
  color: #95a5a6;
}

.expected-ev-info {
  display: none;
}

/* ========== カードラッパー＆周期ボタン ========== */
.prod-card-wrapper {
  display: flex;
  flex-direction: column;
}

.prod-card-wrapper .prod-card {
  border-radius: 10px 10px 0 0;
}

.prod-card-wrapper .prod-card.no-cycle {
  border-radius: 10px;
}

/* 周期ボタン群（デフォルト非表示、タップで展開） */
.cycle-btns {
  display: none;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 0 0 10px 10px;
}

.cycle-btns.expanded {
  display: flex;
}

.cycle-btn {
  min-width: 28px;
  height: 24px;
  border: none;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: #888;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0 4px;
}

.cycle-btn:hover {
  background: rgba(155, 89, 182, 0.3);
  color: #ccc;
}

.cycle-btn:active {
  transform: scale(0.95);
}

.cycle-btn.active {
  background: #9b59b6;
  color: #fff;
  box-shadow: 0 0 8px rgba(155, 89, 182, 0.5);
}

/* ========== ピノPTセレクター（カード直下・デフォルト非表示） ========== */
.pino-pt-selector {
  display: none;
  padding: 6px 4px;
  background: rgba(241, 196, 15, 0.1);
  border-radius: 0 0 10px 10px;
  margin-top: -10px;
}

.pino-pt-selector.expanded {
  display: block;
}

.pino-wrapper .cycle-btns {
  border-radius: 0;
}

.pino-pt-select {
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 0.7rem;
  cursor: pointer;
}

.pino-pt-select option {
  background: #1a1a2e;
  color: #fff;
}

/* ========== モバイル最適化（追加） ========== */
@media (max-width: 768px) {
  .selection-log {
    padding: 10px;
  }

  .selection-log h3 {
    font-size: 0.8rem;
    margin-bottom: 8px;
  }

  .log-entry {
    padding: 5px 6px;
  }

  .log-entry-text {
    font-size: 0.75rem;
  }

  .cycle-btns {
    gap: 2px;
    padding: 4px 2px;
  }

  .cycle-btn {
    min-width: 24px;
    height: 22px;
    font-size: 0.6rem;
  }

  .pino-pt-selector {
    padding: 4px 2px;
  }

  .pino-pt-select {
    padding: 5px 6px;
    font-size: 0.65rem;
  }

  .global-result {
    margin-bottom: 10px;
  }

  /* 想定期待値セクション - モバイル縦並びレイアウト */
  .expected-ev-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
  }

  .expected-ev-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .expected-ev-label {
    font-size: 0.75rem;
    line-height: 1.3;
    color: #ecf0f1;
    font-weight: 500;
  }

  .expected-ev-value {
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.3;
  }

  #expected-cutpoint-cycle {
    padding: 4px 8px;
    font-size: 0.7rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: #3498db;
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-height: 28px;
  }

  .expected-ev-marie-hint {
    font-size: 0.7rem;
    margin-top: 4px;
  }
}

@media (max-width: 375px) {
  .cycle-btn {
    min-width: 22px;
    height: 20px;
    font-size: 0.55rem;
  }

  /* 想定期待値 - 超小型画面 */
  .expected-ev-label {
    font-size: 0.7rem;
  }

  .expected-ev-value {
    font-size: 0.85rem;
  }

  #expected-cutpoint-cycle {
    font-size: 0.65rem;
    padding: 3px 6px;
    min-height: 26px;
  }
}

/* ========== 期待値計算設定パネル ========== */

/* ========== 固定アクションボタンコンテナ ========== */
.fixed-actions {
  position: fixed;
  bottom: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.settings-btn {
  /* position, top, right, z-index は .fixed-actions が管理 */
  background: #2196F3;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: background 0.2s;
  min-width: 100px; /* ボタンの最小幅を統一 */
}

.settings-btn:hover {
  background: #1976D2;
}

/* 固定配置時のリセットボタンスタイル */
.fixed-actions .btn-reset {
  background: #e74c3c;
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: background 0.2s;
  min-width: 100px; /* 設定ボタンと幅を揃える */
}

.fixed-actions .btn-reset:hover {
  background: #c0392b;
}

/* AIに聞くボタン */
.fixed-actions .btn-ai-chat {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 10px 16px;
  min-width: 100px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.fixed-actions .btn-ai-chat:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

.fixed-actions .btn-ai-chat:active {
  transform: scale(0.95);
}

/* AIに聞くボタン - 無効化状態 */
.fixed-actions .btn-ai-chat:disabled {
  background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.fixed-actions .btn-ai-chat:disabled:hover {
  transform: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.settings-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
}

.settings-content {
  background: white;
  padding: 30px;
  border-radius: 8px;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.settings-content h2 {
  margin-top: 0;
  margin-bottom: 24px;
  color: #333;
  border-bottom: 2px solid #2196F3;
  padding-bottom: 10px;
}

.setting-group {
  margin-bottom: 24px;
  padding: 16px;
  background: #f5f5f5;
  border-radius: 4px;
}

.setting-group h3 {
  margin-top: 0;
  margin-bottom: 16px;
  color: #555;
  font-size: 16px;
}

.setting-item {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  gap: 10px;
}

.setting-item:last-child {
  margin-bottom: 0;
}

.setting-item label {
  flex: 0 0 180px;
  font-weight: bold;
  color: #666;
}

.setting-item input[type="number"] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
}

.setting-item input[type="number"]:focus {
  outline: none;
  border-color: #2196F3;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.setting-item .unit {
  flex: 0 0 60px;
  color: #888;
  font-size: 13px;
}

.setting-readonly {
  background: #fff3cd;
  padding: 12px;
  border-radius: 4px;
  margin-bottom: 20px;
  border-left: 4px solid #ffc107;
}

.setting-readonly p {
  margin: 4px 0;
  color: #856404;
  font-size: 13px;
}

.setting-readonly strong {
  color: #664d03;
}

.setting-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

.setting-buttons button {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: background 0.2s, transform 0.1s;
}

.setting-buttons button:active {
  transform: scale(0.98);
}

.btn-primary {
  background: #4CAF50;
  color: white;
}

.btn-primary:hover {
  background: #45a049;
}

.btn-secondary {
  background: #FF9800;
  color: white;
}

.btn-secondary:hover {
  background: #F57C00;
}

.btn-cancel {
  background: #f44336;
  color: white;
}

.btn-cancel:hover {
  background: #d32f2f;
}

/* 通知 */
.notification {
  animation: slideIn 0.3s ease-out, slideOut 0.3s ease-in 2.7s;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .settings-content {
    padding: 20px;
    width: 95%;
  }

  .setting-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .setting-item label {
    flex: 1;
    margin-bottom: 4px;
  }

  .setting-item input[type="number"] {
    width: 100%;
  }

  .setting-buttons {
    flex-direction: column;
  }

  .setting-buttons button {
    width: 100%;
  }

  /* 固定アクションボタン - モバイル */
  .fixed-actions {
    bottom: 8px;
    right: 8px;
    gap: 6px;
  }

  .settings-btn,
  .fixed-actions .btn-reset {
    padding: 8px 12px;
    font-size: 12px;
    min-width: 80px;
  }
}

/* ========== 期待値表示セクション ========== */
/* 既存のremaining-sectionスタイルを使用 */

/* 期待値のプラス/マイナス色分け */
#ev-table-body td.positive {
  color: #4ade80;
}

#ev-table-body td.negative {
  color: #f87171;
}

#ev-weighted-value.positive {
  color: #4ade80;
}

#ev-weighted-value.negative {
  color: #f87171;
}

/* ========== AI Chat Assistant Styles ========== */

/* Chat window */
/* Chat overlay - blocks background interaction */
.chat-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.chat-window {
  position: fixed;
  bottom: 10px;
  right: 10px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: 70vh;
  background: rgba(26, 26, 46, 0.98);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s ease;
  z-index: 9999;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Chat header */
.chat-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
}

.chat-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Chat messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(155, 89, 182, 0.5) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(155, 89, 182, 0.5);
  border-radius: 3px;
}

/* Chat message bubbles */
.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: fadeIn 0.3s ease;
}

.chat-message.user {
  align-self: flex-end;
}

.chat-message.ai {
  align-self: flex-start;
}

.message-content {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-message.user .message-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-message.ai .message-content {
  background: rgba(255, 255, 255, 0.1);
  color: #ecf0f1;
  border-bottom-left-radius: 4px;
}

/* AIメッセージ内のリンク */
.chat-message.ai .message-content a {
  color: #5dade2;
  text-decoration: underline;
  word-break: break-all;
  transition: color 0.2s;
}

.chat-message.ai .message-content a:hover {
  color: #85c1e9;
  text-decoration: none;
}

/* Expected value display in chat */
.message-ev-summary {
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  border-left: 3px solid #3498db;
  font-size: 0.85rem;
}

.ev-row {
  display: flex;
  justify-content: space-between;
  margin: 4px 0;
}

.ev-label {
  color: #aaa;
}

.ev-value {
  font-weight: 700;
  font-family: 'Courier New', monospace;
}

.ev-value.positive {
  color: #2ecc71;
}

.ev-value.negative {
  color: #e74c3c;
}

.ev-value.neutral {
  color: #95a5a6;
}

/* AI message inline reset button */
.ai-reset-btn {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 12px;
  background: rgba(52, 152, 219, 0.2);
  border: 1px solid rgba(52, 152, 219, 0.4);
  border-radius: 6px;
  color: #3498db;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.ai-reset-btn:hover {
  background: rgba(52, 152, 219, 0.3);
  border-color: rgba(52, 152, 219, 0.6);
  color: #5dade2;
}

.ai-reset-btn:active {
  transform: scale(0.95);
}

@media (max-width: 768px) {
  .ai-reset-btn {
    padding: 8px 14px;
    font-size: 0.85rem;
  }
}

/* Loading indicator */
.chat-loading {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  margin: 0 16px;
}

.loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9b59b6;
  animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Chat input area */
.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 10px 12px;
  color: #fff;
  font-size: 0.9rem;
  resize: none;
  max-height: 100px;
  overflow-y: auto;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chat-input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: none;
}

.chat-input::placeholder {
  color: #888;
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 8px;
  background: #9b59b6;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.chat-send-btn:hover {
  background: #8e44ad;
}

.chat-send-btn:active {
  transform: scale(0.95);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .chat-container {
    bottom: 70px;
    right: 8px;
  }

  .chat-window {
    width: calc(100vw - 16px);
    height: 50vh;
    max-height: 50vh;
    bottom: 10px;
    right: 8px;

    /* キーボード対応用 */
    transition: transform 0.2s ease-out;
    will-change: transform;
  }

  .fixed-actions .btn-ai-chat {
    padding: 8px 12px;
    font-size: 12px;
    min-width: 80px;
  }

  .fixed-actions .btn-ai-chat:disabled {
    opacity: 0.5;
  }

  .chat-header {
    padding: 12px;
  }

  .chat-messages {
    padding: 12px;
  }

  .message-content {
    font-size: 0.85rem;
  }

  .chat-input {
    font-size: 16px; /* Prevent iOS zoom */
  }
}

