
/* ==========================================
   1. 基本レイアウト（共通設定）
   ========================================== */
html, body {
  width: 100%;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  background: #fafafa;
  font-family: Arial, sans-serif;
}

header, footer {
  background: #333;
  color: white;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
}

header {
  padding: 10px;
  font-size: 14px;
}

footer {
  padding: 5px;
  font-size: 12px;
}

footer a {
  color: white;
}

/* 修正：指板＋フレット番号が表示されるよう高さを 250px に固定 */
#wrap {
  position: relative;
  max-width: 1200px;
  width: 95%;
  height: 270px; 
  margin: 20px auto;
  overflow-x: auto; /* 横スクロールを許可 */
  overflow-y: hidden; /* 縦揺れを防止 */
}

.scroll-wrapper {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 900;
  background: #fafafa;
  flex-shrink: 0;
  overflow-x: auto;
}

/* 修正：Canvasの高さをCSS側でも250pxに強制固定 */
canvas {
  position: absolute;
  top: 0;
  left: 0;
  height: 250px !important;
}

/* メインコンテンツのスクロール領域 */
#scrollable-content {
}

/* ==========================================
   2. コントロール部品（ボタン・セレクト）
   ========================================== */
select, button {
  font-size: 16px;
  padding: 5px 10px;
  margin: 5px;
  border: 1px solid #888;
  border-radius: 4px;
  background-color: #fff;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  text-align: center;
}

.grid-checkbox {
  width: 30px;
  height: 30px;
  border: 1px solid #888;
  border-radius: 4px;
  display: grid;
  place-content: center;
  cursor: pointer;
  background: #fff;
  appearance: none;
  -webkit-appearance: none;
}

.grid-checkbox:checked::after {
  content: '✔';
  font-size: 18px;
}

/* ==========================================
   3. メインパネルレイアウト (PC・横長表示)
   ========================================== */
#main-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 15px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 10px;
  box-sizing: border-box;
}

#audioControlPanel {
  margin: 0 auto;
  padding: 10px;
  max-width: 1200px;
  width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
}

.audio-controls-wrapper {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 10px;
  background-color: #fff;
  box-sizing: border-box;
}

.panel-top-wrapper {
  display: grid !important;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  width: 100%;
}

.panel-controls-row {
  display: contents;
}

.panel-controls-row > div {
  width: 100%;
  min-width: 0;
}

.panel-controls-row select {
  width: 100%;
}

/* ==========================================
   5. スマホ縦型（幅480px以下）のレスポンシブ
   ========================================== */
@media (max-width: 480px) {
  /* 修正：スマホでも高さを250pxに固定 */

  /* ピアノモード時にさらに縮小表示（50%） */
  .piano-mode canvas {
    width: 50% !important;
  }

  #main-controls {
    grid-template-columns: 1fr;
  }

  .audio-controls-wrapper {
    display: grid !important;
    grid-template-columns: 1fr 1fr ;
   
  }

  #scaleControlPanel, #chordControlPanel {
    padding: 5px 12px !important;
    box-sizing: border-box;
  }

  .panel-top-wrapper {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px;
    padding: 0px;
  }

  .panel-controls-row {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    width: 100%;
  }

  .panel-controls-row > * {
    width: 100% !important;
    margin: 0 !important;
  }

  .panel-controls-row span {
    font-size: 11px !important;
  }

  #degreeControlsScale select,
  #degreeControlsChord select,
  #degreeControlsScale .grid-checkbox,
  #degreeControlsChord .grid-checkbox,
  #degreeControlsScale div[id*="ColorBox"],
  #degreeControlsChord div[id*="ColorBox"] {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
    max-width: none !important;
    font-size: 11px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 3px !important;
    box-sizing: border-box !important;
  }

  .grid-checkbox:checked::after {
    font-size: 14px;
  }

  .grid-label-all {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
    font-size: 10px !important;
    border: 1px solid #888;
    border-radius: 4px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fff;
  }
}

/* ==========================================
   6. スマホ横向き・低画面対応
   ========================================== */
@media (max-height: 500px) and (orientation: landscape) {
  /* 修正：横向き時も高さを250pxに固定 */
  #wrap {
    height: 250px;
  }
  
  .audio-controls-wrapper {
    display: flex !important;
    flex-direction: row !important;
    justify-content: center;
  }
  
  .panel-top-wrapper {
    display: flex !important;
    flex-direction: row !important;
    justify-content: center;
  }
}

/* ==========================================
   7. 度数コントロール（グリッド設定）
   ========================================== */
#degreeControlsScale {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

#degreeControlsChord {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

#degreeControlsScale > div,
#degreeControlsChord > div {
  width: 100%;
}

#degreeControlsScale select,
#degreeControlsChord select,
#degreeControlsScale .grid-checkbox,
#degreeControlsChord .grid-checkbox,
#degreeControlsScale div[id*="ColorBox"],
#degreeControlsChord div[id*="ColorBox"] {
  width: 100% !important;
  max-width: 30px;
  height: auto !important;
  aspect-ratio: 1 / 1;
  max-width: none !important;
  font-size: 11px !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 3px !important;
  box-sizing: border-box !important;
}

.grid-checkbox:checked::after {
  font-size: 14px;
}

.grid-label-all {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 1 / 1;
  font-size: 10px !important;
  border: 1px solid #888;
  border-radius: 4px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fff;
}

/* ==========================================
   8. 追加スタイル（index.htmlからマージ）
   ========================================== */
/* Contact Modal Styles */
.modal {
  display: none; 
  position: fixed; 
  z-index: 1000; 
  left: 0;
  top: 0;
  width: 100%; 
  height: 100%; 
  overflow: auto; 
  background-color: rgba(0,0,0,0.5); 
}

.modal-content {
  background-color: #fefefe;
  margin: 10% auto; 
  padding: 20px;
  border: 1px solid #888;
  width: 90%; 
  max-width: 500px;
  border-radius: 8px;
  position: relative;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.close-modal {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close-modal:hover,
.close-modal:focus {
  color: black;
  text-decoration: none;
  cursor: pointer;
}

#contact-form-modal input, #contact-form-modal textarea {
  width: 100%;
  padding: 10px;
  margin: 8px 0;
  display: inline-block;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
  font-size: 16px; /* iOSでのズーム防止 */
}

#contact-form-modal button {
  width: 100%;
  background-color: #333;
  color: white;
  padding: 14px 20px;
  margin: 8px 0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
}

#contact-form-modal button:hover {
  background-color: #555;
}

/* View Toggle Styles */
.view-toggle {
  display: flex;
  justify-content: center;
  margin: 10px 0;
}
.view-toggle button {
  padding: 10px 20px;
  margin: 0 5px;
  font-size: 16px;
  cursor: pointer;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 5px;
}
@media (max-width: 600px) {
  .view-toggle button {
    padding: 10px 0;
    margin: 0 2px;
    font-size: 14px;
    flex: 1;
  }
}
.view-toggle button.active {
  background-color: #333;
  color: #fff;
  border-color: #333;
}

#piano-wrap {
  position: relative;
  width: 1200px;
  height: 250px;
  margin: 0 auto;
  display: none;
}
#piano-wrap canvas {
  position: absolute;
  top: 0;
  left: 0;
}

#fretboard-area {
  display: flex;
  justify-content: center;
}
#string-controls {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 250px;
  padding-top: 35px;
  padding-bottom: 10px;
  padding-right: 2px;
  box-sizing: border-box;
  position: relative;
  z-index: 1000;
  flex-shrink: 0;
  width: 40px;
}
.str-box {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 20px;
}
.str-box span {
  font-size: 12px;
  font-family: Arial, sans-serif;
  margin-right: 5px;
  color: rgba(0,0,0,0.55);
}
.str-box input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 1px solid #888; /* grid-checkboxと統一 */
  border-radius: 4px;      /* grid-checkboxと統一 */
  background-color: #fff;
  cursor: pointer;
  position: relative;
  margin: 0;
  /* 中央配置のための設定を追加 */
  display: grid;
  place-content: center;
}

/* 共通のチェックマーク表示（✔に統一） */
.str-box input[type="checkbox"]:checked::after {
  content: '✔';           /* 図形から文字に変更 */
  font-size: 14px;        /* サイズはお好みで調整してください */
  color: #333;            /* 色を統一 */
  /* 以前の図形用スタイル（borderやtransform）は不要なので削除 */
  position: static; 
  width: auto;
  height: auto;
  border: none;
  transform: none;
}
@media (min-width: 601px) {
  #string-controls {
    margin-right: -25px;
  }
}

/* ピアノモード時は弦コントロールとギター表示を非表示にし、ピアノ表示を有効にする */
.piano-mode #string-controls,
.piano-mode .str-box,
.piano-mode #wrap {
  display: none !important;
}

.piano-mode #piano-wrap {
  display: block !important;
}
