@charset "utf-8";

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
  visibility: visible;
  display: block;
}

.container {
  & h2 {
    margin-top: 0;
  }

  /* ▼ ツールボックスのスタイル ▼ */
  .toolbox {
    margin-top: 15px;
    margin-bottom: 15px;
    padding: 10px 15px;
    background-color: #f8f9fa;
    border: 1px solid #ccc;
    border-radius: 6px;
    display: flex;
    /* inline-flexから変更 */
    justify-content: space-between;
    /* 左右に振り分ける */
    align-items: center;

    .tool-group {
      display: flex;
      gap: 20px;
      align-items: center;
    }

    .tool-label {
      font-weight: bold;
      color: #555;
    }

    .tool-radio {
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 5px;
      font-weight: bold;

      .icon-furniture {
        color: red;
        font-size: 1.2em;
      }

      .icon-item {
        color: #007bff;
        font-size: 1.2em;
        font-weight: bold;
      }
    }

    /* ：進捗表示のスタイル */
    .progress-display {
      font-weight: bold;
      color: #555;
      background-color: #fff;
      padding: 4px 12px;
      border-radius: 20px;
      border: 1px solid #ddd;
    }
  }

  /* ▼ データの管理/画像保存(シェア用) ▼ */
  .data-controls {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;

    .control-button {
      padding: 8px 16px;
      border: none;
      border-radius: 4px;
      background-color: #28a745;
      color: white;
      cursor: pointer;
      font-size: 0.9em;

      &:hover {
        background-color: #218838;
      }
    }

    .secondary {
      background-color: #6c757d;
      display: inline-block;

      &:hover {
        background-color: #5a6268;
      }
    }
  }

  .workspace {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    /* 3つの列の間の隙間 */
    margin-top: 10px;

    /* 1. 左列（タブ） */
    .workspace-sidebar {
      width: 180px;
      /* タブの幅を固定 */
      flex-shrink: 0;

      .tabs {
        display: flex;
        flex-direction: column;
        /* タブを縦並びにする魔法の1行 */
        gap: 8px;
        /* タブ同士の縦の隙間 */

        .tab-button {
          width: 100%;
          padding: 12px 10px;
          border: 1px solid #ccc;
          background-color: #f8f9fa;
          cursor: pointer;
          border-radius: 4px;
          text-align: center;
          /* ゲームに合わせて中央揃え */
          font-size: 0.9em;
          font-weight: bold;
          transition: background-color 0.2s;
        }

        .tab-button:hover {
          background-color: #e2e6ea;
        }

        .active {
          background-color: #dcb382;
          /* ゲーム内のアクティブタブに近い色（お好みで変更してください） */
          color: #fff;
          border-color: #c09869;
        }
      }
    }

    /* 2. 中央列（画像） */
    .workspace-main {
      flex-shrink: 0;
      /* 画像幅(365px)が縮まないようにする */

      .image-wrapper {
        position: relative;
        display: inline-block;
        /* 中身（画像）のサイズに合わせる */
        border: 3px solid #8e7a66;
        border-radius: 4px;
        /* 縁取り */
        line-height: 0;
        /* 画像下部の微細な隙間を排除 */
        background-color: transparent;
        /* 背景を透明に */
        /* スマホでのタップ時ハイライトと文字選択を抑制 */
        -webkit-tap-highlight-color: transparent;
        user-select: none;
        -webkit-user-select: none;

        & img {
          display: block;
          cursor: pointer;
          /* 指マークに変更 */
          /* スマホで画像を触った際の選択ハイライト・コールアウトを無効化 */
          user-select: none;
          -webkit-user-select: none;
          -webkit-touch-callout: none;
          -webkit-tap-highlight-color: transparent;
        }

        .check-mark {
          position: absolute;
          font-weight: bold;
          transform: translate(-50%, -50%);
          cursor: grab;
          user-select: none;
          text-shadow: 1px 1px 0 #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff;
          line-height: 1;
          transition: transform 0.1s;
          /* クリック時に少しアニメーションさせる用 */
        }

        /* マークの種類による見た目の違い */
        .type-furniture {
          color: red;
          font-size: 32px;
        }

        .type-item {
          color: #007bff;
          text-shadow:
            1px 1px 0 #fff,
            -1px -1px 0 #fff,
            1px -1px 0 #fff,
            -1px 1px 0 #fff;
          font-size: 32px;
          font-weight: bold;
        }
      }
    }

    /* 3. 右列 */
    .workspace-right {
      min-width: 200px;
      max-width: 220px;
      flex-grow: 1;
      /* 余ったスペースを埋める */

      /* ▼ ツールチップのスタイル ▼ */
      .tooltip-icon {
        display: inline-flex;
        justify-content: center;
        align-items: center;
        width: 16px;
        height: 16px;
        border-radius: 50%;
        background-color: #bfbfbf;
        /* コインの文字色に合わせる */
        color: #fff;
        font-size: 11px;
        cursor: help;
        /* マウスを「？」付きのカーソルにする */
        margin-left: 6px;
        position: relative;

        /* マウスオーバーで表示 */
        &:hover .tooltip-text {
          visibility: visible;
          opacity: 1;
        }

        .tooltip-text {
          visibility: hidden;
          opacity: 0;
          width: 220px;
          background-color: rgba(0, 0, 0, 0.8);
          color: #fff;
          text-align: center;
          border-radius: 4px;
          padding: 8px;
          position: absolute;
          z-index: 10;
          bottom: 140%;
          /* アイコンの少し上に配置 */
          right: 0;
          /* アイコンの右端を基準に左へ展開 */
          transform: none;
          transition: opacity 0.2s ease-in-out;
          font-size: 1.2rem;
          font-weight: normal;
          line-height: 1.4;
          white-space: normal;

          /* 吹き出しの「しっぽ（下向きの三角）」をアイコン真上（右端寄り）に */
          &::after {
            content: "";
            position: absolute;
            top: 100%;
            right: 4px;
            /* アイコン(16px)の中心に合わせる */
            left: auto;
            margin-left: 0;
            border-width: 5px;
            border-style: solid;
            border-color: rgba(0, 0, 0, 0.8) transparent transparent transparent;
          }
        }
      }

      /* 購入時間管理 */
      .timer-section {
        margin-bottom: 15px;
        padding: 15px;
        background-color: #d1ecf1;
        /* 薄い青色 */
        border: 1px solid #bee5eb;
        border-radius: 8px;

        .timer-header {
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-bottom: 10px;
          font-weight: bold;
          color: #0c5460;
        }

        .timer-body {
          font-size: 0.8em;
          color: #333;

          .timer-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 5px;
            border-bottom: 1px dashed #bee5eb;

            .timer-value {
              font-weight: bold;
              font-size: 1.15em;
              color: #0056b3;
            }
          }

          .reduction-toggle {
            display: flex;
            align-items: center;
            gap: 4px;
            cursor: pointer;

            & input[type="checkbox"] {
              width: 14px;
              height: 14px;
              cursor: pointer;
              accent-color: #0056b3;
              flex-shrink: 0;
            }
          }

          .timer-controls {
            margin-top: 10px;
            text-align: right;
            font-size: 0.9em;

            & input {
              width: 45px;
              padding: 4px;
              text-align: center;
              border: 1px solid #ccc;
              border-radius: 4px;
            }
          }
        }

        .timer-divider {
          border: none;
          border-top: 1px dashed #8bdce9;
          margin: 15px 0;
        }

        .countdown-controls {
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-bottom: 10px;
          font-size: 0.9em;

          & input {
            width: 35px;
            padding: 4px;
            text-align: center;
            border: 1px solid #ccc;
            border-radius: 4px;
          }

          .start-btn {
            padding: 5px 12px;
            background-color: #17a2b8;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-weight: bold;

            &:hover {
              background-color: #138496;
            }
          }
        }

        .quick-timer-controls {
          display: flex;
          gap: 8px;
          margin-bottom: 10px;

          .quick-btn {
            flex: 1;
            padding: 6px;
            background-color: #8d7866;
            border: 1px solid #c09869;
            border-radius: 4px;
            cursor: pointer;
            color: #fff;

            &:hover {
              background-color: #5a4437;
            }
          }
        }

        .reset-btn {
          background: none;
          border: none;
          color: #888;
          text-decoration: underline;
          cursor: pointer;
          font-size: 0.8em;
          padding: 0;
        }
      }

      /* コインカウンター */
      .coin-counter-section {
        margin-bottom: 15px;
        padding: 15px;
        background-color: #fff3cd;
        border: 1px solid #ffeeba;
        border-radius: 8px;

        .coin-header {
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-bottom: 10px;
          font-weight: bold;

          .coin-shortage {
            font-size: 0.8em;
            color: #856404;
          }
        }

        .coin-controls {
          display: flex;
          align-items: center;
          justify-content: center;
          gap: 10px;

          & input {
            width: 80px;
            padding: 8px;
            font-size: 1.2em;
            text-align: center;
            border: 1px solid #ccc;
            border-radius: 4px;
          }

          .coin-btn {
            width: 40px;
            height: 40px;
            border: none;
            background-color: #ffc107;
            color: #333;
            font-size: 1.5em;
            border-radius: 50%;
            cursor: pointer;

            &:hover {
              background-color: #e0a800;
            }
          }
        }

        /* ▼ コイン履歴 ▼ */
        .coin-history-toggle {
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-top: 10px;
          padding-top: 8px;
          border-top: 1px dashed #ffc107;
          font-size: 0.78em;
          color: #856404;
          cursor: pointer;
          user-select: none;

          &:hover {
            color: #5a4300;
          }

          .coin-history-arrow {
            font-style: normal;
            transition: transform 0.2s;
          }

          &.is-open .coin-history-arrow {
            transform: rotate(180deg);
          }
        }

        .coin-history-panel {
          display: none;
          margin-top: 8px;

          &.is-open {
            display: block;
          }

          .coin-history-list {
            list-style: none;
            margin: 0;
            padding: 0;
            max-height: 160px;
            overflow-y: auto;
            font-size: 0.78em;

            .coin-history-empty {
              color: #aaa;
              text-align: center;
              padding: 6px 0;
            }

            .coin-history-item {
              display: flex;
              justify-content: space-between;
              align-items: center;
              padding: 3px 4px;
              border-bottom: 1px dotted #ffe69c;
              gap: 4px;

              &:last-child {
                border-bottom: none;
              }

              .coin-history-date {
                color: #888;
                flex-shrink: 0;
              }

              .coin-history-change {
                font-weight: bold;
                flex-shrink: 0;

                &.coin-history-plus {
                  color: #c67c00;
                }

                &.coin-history-minus {
                  color: #6c757d;
                }
              }

              .coin-history-total {
                color: #555;
                text-align: right;
                flex-grow: 1;
              }

              .coin-history-delete-one {
                flex-shrink: 0;
                background: none;
                border: none;
                color: #ccc;
                cursor: pointer;
                font-size: 1em;
                line-height: 1;
                padding: 0 2px;

                &:hover {
                  color: #dc3545;
                }
              }
            }
          }

          .coin-history-clear {
            display: block;
            margin-top: 6px;
            text-align: right;
            font-size: 0.85em;
            color: #aaa;
            background: none;
            border: none;
            text-decoration: underline dotted;
            cursor: pointer;
            padding: 0;

            &:hover {
              color: #888;
            }
          }
        }
      }

      /* 家具スロット管理 */
      .slot-counter-section {
        margin-bottom: 15px;
        padding: 15px;
        background-color: #e2f0d9;
        border: 1px solid #c5e0b4;
        border-radius: 8px;

        .slot-header {
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-bottom: 10px;
          font-weight: bold;

          .slot-progress {
            font-size: 0.85em;
            color: #385723;
          }
        }

        .slot-controls {
          display: flex;
          align-items: center;
          justify-content: center;
          gap: 10px;

          & input {
            width: 60px;
            padding: 8px 4px;
            font-size: 1.1em;
            text-align: center;
            border: 1px solid #ccc;
            border-radius: 4px;
          }

          .slot-btn {
            flex: 1;
            max-width: 50px;
            height: 40px;
            border: none;
            background-color: #70ad47;
            color: white;
            font-size: 1em;
            font-weight: bold;
            border-radius: 4px;
            cursor: pointer;

            &:hover {
              background-color: #548235;
            }
          }
        }
      }
    }
  }
}

/* --- ここからスマホ・タブレット用レイアウト（画面幅 900px 以下） --- */
@media (max-width: 900px) {
  .container {
    .toolbox {
      flex-direction: column;
      /* 左右ではなく縦並びに変更 */
      align-items: center;
      /* 中央揃え */
      gap: 15px;
      /* 縦の隙間 */

      .tool-group {
        flex-wrap: wrap;
        /* 画面幅が足りない場合は折り返す */
        justify-content: center;
        gap: 10px 20px;
      }

      .tool-label {
        width: 100%;
        /* ラベル（見出し）に1行使わせる */
        text-align: center;
      }
    }

    .workspace {
      flex-direction: column;
      /* 3列の横並びを縦並びに変更 */
      align-items: center;
      /* 全体を中央揃えに */
      gap: 30px;

      .workspace-sidebar {
        width: 100%;
        max-width: 100vw;
        /* 画面幅を突き抜けないように制限 */

        /* ▼ グラデーションを配置するための基準位置にする ▼ */
        position: relative;

        /* ▼ 右端のグラデーション（影）の演出 ▼ */
        &::after {
          content: "";
          position: absolute;
          top: 0;
          right: 0;
          bottom: 10px;
          /* タップ領域の下余白（padding-bottom）を少し避ける */
          width: 30px;
          /* グラデーションの幅 */
          /* 透明から背景色(白)へのグラデーション */
          background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
          pointer-events: none;
          /* ★重要：これが無いと右端のタブがタップできなくなる */
        }

        .tabs {
          flex-direction: row;
          flex-wrap: nowrap;
          /* ★ 折り返しを禁止して1行にする */
          justify-content: flex-start;
          overflow-x: auto;
          /* ★ はみ出た部分を横スクロール可能にする */
          -webkit-overflow-scrolling: touch;
          /* iOSで滑らかにスクロールさせる */
          padding: 0 10px 10px 0;
          /* 右の余白と、下部のスクロールバー用の余白 */

          /* スクロールバーを非表示にしてアプリのような洗練された見た目に */
          scrollbar-width: none;

          /* Firefox用 */
          &::-webkit-scrollbar {
            display: none;
            /* Chrome/Safari用（疑似要素なので&を付与） */
          }

          .tab-button {
            width: auto;
            padding: 10px 16px;
            flex-shrink: 0;
            /* ★ 画面幅に合わせてボタンが縮むのを防ぐ */
            white-space: nowrap;
            /* 文字が途中で改行されるのを防ぐ */
          }
        }
      }

      .workspace-main {
        width: 100%;
        display: flex;
        justify-content: center;
        /* 画像を中央に配置 */

        .image-wrapper {
          max-width: 100%;
          /* スマホ画面からはみ出さないように制限 */

          & img {
            width: 100%;
            /* 枠に合わせて縮小させる */
            height: auto;
          }
        }
      }

      .workspace-right {
        width: 100%;
        max-width: 300px;
      }
    }

    .data-controls {
      justify-content: center;
      /* ボタン類も中央揃えに */
    }
  }
}

/* ▼ コイン目標設定モーダル ▼ */
.coin-goal-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  justify-content: center;
  align-items: center;

  &.is-open {
    display: flex;
  }

  .coin-goal-modal {
    background: #fff;
    border-radius: 10px;
    padding: 24px 28px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    width: 280px;
    text-align: center;

    .coin-goal-modal-title {
      font-weight: bold;
      font-size: 1.05em;
      margin-bottom: 14px;
      color: #333;
    }

    .coin-goal-modal-desc {
      font-size: 0.85em;
      color: #666;
      margin-bottom: 14px;
    }

    .coin-goal-modal-input {
      width: 100px;
      padding: 8px;
      font-size: 1.3em;
      text-align: center;
      border: 2px solid #ffc107;
      border-radius: 6px;
      margin-bottom: 18px;
    }

    .coin-goal-modal-buttons {
      display: flex;
      gap: 10px;
      justify-content: center;

      button {
        padding: 8px 20px;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        font-size: 0.95em;
        font-weight: bold;

        &.btn-save {
          background-color: #ffc107;
          color: #333;

          &:hover {
            background-color: #e0a800;
          }
        }

        &.btn-cancel {
          background-color: #e9ecef;
          color: #555;

          &:hover {
            background-color: #ced4da;
          }
        }
      }
    }
  }
}