body {
  margin: 0;
  background: #111; /* 黒ベース */
  color: #eee;       /* 明るめの文字色 */
  font-family: sans-serif;
  overflow: hidden;
}

#title-en, #title-ja, #title-code, #global-label {
  color: #ffffff;
}

#title-area {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 1000;
  pointer-events: none;
}

#title-left {
  display: flex;
  flex-direction: column;
  text-align: left;
  padding-left: 16px; /* ← スマホではsidebar左に揃えるため */
}

#title-en {
  font-size: 5vw;
  font-weight: bold;
  color: #ffffff;
  line-height: 1.2;
  margin: 0;
}

#title-ja {
  font-size: 3vw;
  color: #ffffff;
  margin-top: 0;
}

.subheader-en {
  font-size: 12px;
  color: #bbb;
  margin-top: 2px;       /* ← ここが調整ポイント！半分に */
  margin-bottom: 4px;    /* 必要ならこちらも調整可能 */
}

/* 🧩 分類コード（C1aなど） */
#title-code {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 5vw;
  font-weight: bold;
  color: #ffffff;
  z-index: 1000;
}

#global-label {
  position: absolute;
  bottom: 20px;
  left: 20px;
  font-size: 3vw;
  font-weight: bold;
  color: #ffffff;
}

#sidebar {
  position: absolute;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  width: 280px; /* ← 少し狭く */
  height: 88vh; /* ← わずかに短縮 */
  overflow-y: auto;
  background: rgba(30, 30, 30, 0.95); /* 半透明の黒 */
  color: #eee;
  padding: 12px 16px; /* ← 上下左右のパディングを調整 */
  border-radius: 12px; /* ← 少し小さめに */
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
  font-size: 13px; /* ← テキストを1px小さく */
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 10px; /* ← セクション間のギャップも縮小 */
}

input[type="range"] {
  accent-color: #ffffff; /* スライダーの色を白に */
}

.sidebar-section {
  margin: 10px 0;
}

.divider {
  border-top: 1px solid #ccc;
  margin: 8px 0;
}

#header-title {
  font-size: 16px;
  font-weight: bold;
  margin: 0;
  text-align: left;
}

#header-title .info-link {
  display: block;
  text-align: left !important;  /* ← ここを強制 */
  font-size: 12px;
  margin-top: 4px;
  color: #bbb;
  opacity: 0.9;
  text-decoration: none;
}

#subtypes-title {
  font-weight: bold;
  margin-bottom: 4px;
}

#subtypes {
  line-height: 1.4;
  min-height: 120px;
}

#matrix-canvas {
  width: 100%;
  height: auto;
}

#ui {
  background: #222;
  color: #fff;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.05);
  padding: 0;                /* ← パディングをゼロに */
}

.slider-group {
  padding: 0 8px;            /* ← 必要なら左右に少しだけ余白 */
}

input[type="range"] {
  accent-color: #ffffff;
  width: 100%;               /* ← スライダーを全幅に */
  box-sizing: border-box;
}

#type, #info {
  font-size: 13px;
}

.info-link {
  font-size: 12px;
  text-align: left;            /* ← 左寄せに変更 */
  color: #ccc;                 /* ← 少し明るいグレーに */
  text-decoration: none;
  margin-top: 2px;
  display: block;
  opacity: 0.9;                /* ← 視認性のため軽く強調 */
}

.info-link:hover {
  text-decoration: underline;
  opacity: 1.0;
}

.info-link-box {
  margin-top: 8px;
}

#title-code-mobile,
#title-code-desktop {
  font-weight: bold;
  color: #ffffff;
  pointer-events: none;
}

.slider-label {
  font-size: 12px;
  color: #aaa;
  margin-bottom: 4px;
  display: block;
}

.en-label {
  font-size: 11px;
  color: #aaa;
}

@media (min-width: 1001px) {

  #title-code {
    top: auto;
    bottom: 20px;
    right: auto;
    left: 20px;
    font-size: 4.5vw;
  }

  #title-code-mobile {
    display: none;
  }

  #title-code-desktop {
    display: block;
    position: absolute;
    bottom: 20px;
    left: 20px;
    font-size: 4.5vw;
    text-align: left;
  }

  #sidebar {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    width: 280px;
    height: 88vh;
    background: rgba(30, 30, 30, 0.95);
    color: #eee;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  #title-code-mobile { display: none; }
  #title-code-desktop {
    position: absolute;
    bottom: 20px;
    left: 20px;
    font-size: 4.5vw;
    font-weight: bold;
    color: #ffffff;
    z-index: 1000;
  }
  
}

/* iPadもスマホと同じく縦レイアウトにする（1000px以下） */
@media (min-width: 769px) and (max-width: 1000px) {
  body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-y: auto;
    height: auto;
  }

    canvas {
      display: block;
      width: 100% !important;
      height: auto !important;
      max-height: 100vh;
    }

  #title-area {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    padding: 12px 16px 0;
  }

  #title-left {
    padding-left: 16px;
  }

  #title-en {
    font-size: 6vw;
    margin: 0;
  }

  #title-ja {
    font-size: 4.5vw;
  }

  #title-code {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 5vw;
    font-weight: bold;
    color: #ffffff;
    z-index: 1000;
    display: block;
  }

  #global-label {
    position: static;
    font-size: 4.5vw;
    text-align: center;
    margin-top: 4px;
    margin-bottom: 12px;
  }

  canvas {
    display: block;
    width: 100% !important;
    max-width: 800px; /* ← 必要に応じて調整 */
    aspect-ratio: 1 / 1; /* ← ★潰れ防止 */
    margin: 0 auto;
  }

  #sidebar {
  position: static !important;
  transform: none !important;
  width: 90vw;              /* ← ビューポートの90%幅 */
  max-width: 820px;         /* ← iPad横幅に最大合わせる */
  margin: 0 auto 20px;      /* ← 中央に配置 */
  height: auto;
  border-radius: 16px;
  padding: 24px 24px;
  background: rgba(30, 30, 30, 0.95);
  color: #eee;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

  #ui {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .info-link {
    color: #bbb;                        /* フッターリンクも白寄りに */
  }

  .slider-graph-wrapper {
    display: flex;
    flex-direction: row;
    gap: 20px;
    align-items: flex-start;
  }

    .slider-group {
    flex: 1;
  }

  .matrix {
    flex: 1;
  }

    #matrix-ui {
    display: flex;
    flex-direction: row;
    gap: 20px;
    align-items: flex-start;
    justify-content: center;
  }

  #sliders, #graph {
    flex: 1;
    min-width: 0;
  }

#ui, .sidebar-section.matrix {
  flex: 1;
  max-width: 340px;         /* ← 横幅統一（左右揃える） */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.sidebar-section.matrix {
  align-items: center;
  justify-content: center;
}

#matrix-canvas {
    display: block;
    margin: 0 auto;
  }

  #title-code-mobile {
    display: block;
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 5vw;
    z-index: 1000;
  }

  #title-code-desktop {
    display: none;
  }

  .sidebar-section {
    margin: 0;
  }

  .divider {
    margin: 8px 0;
  }

  .info-link {
    text-align: center;
    font-size: 12px;
  }

  #matrix-canvas {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 280px;
  height: auto !important;
  aspect-ratio: 1 / 1;
}


  #ui, .sidebar-section.matrix {
    flex: 1;
    min-width: 45%;
  }

  #title-code-mobile {
    display: block;
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 5vw;
  }

  #title-code-desktop {
    display: none;
  }

  #title-code-desktop {
  display: block;
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 5vw;
  text-align: right;
  z-index: 1000;
}

#title-code-desktop { display: none; }
  #title-code-mobile {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 5vw;
    font-weight: bold;
    color: #ffffff;
    z-index: 1000;
  }




}

@media (max-width: 768px) {
  body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: auto;
    overflow-y: auto;
  }

  #title-left {
    padding-left: 0; /* ← 統一：スマホでは0 */
  }

  #title-code {
    position: absolute;
    top: 20px; /* ← title-area と合わせる */
    right: 20px;
    font-size: 5vw;
    font-weight: bold;
    color: #ffffff;
    z-index: 1000;
    pointer-events: none;
  }

  #title-area {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: baseline; /* ← ここ重要！ */
    pointer-events: none;
  }

  #title-en {
    font-size: 6vw;
    margin: 0;
    line-height: 1;
  }

  #title-ja {
    font-size: 4.5vw;
    margin: 0;
  }

  #title-code-mobile {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 5vw;
    font-weight: bold;
    color: #ffffff;
    z-index: 1000;
    pointer-events: none;
    margin: 0;
    padding: 0;
  }

  #title-code-desktop {
    display: none;
  }

  #global-label {
    position: static;
    font-size: 4.5vw;
    text-align: center;
    margin-top: 4px;
    margin-bottom: 12px;
  }

  canvas {
    display: block;
    width: 100% !important;
    height: auto !important;
    margin: 0 auto;
  }

  #sidebar {
    position: static !important;
    transform: none !important;
    width: 85vw;
    max-width: 92vw;
    margin: 0 auto 20px;
    height: auto;
    border-radius: 16px;
    padding: 16px 12px;
    background: rgba(30, 30, 30, 0.95);
    color: #eee;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  #ui {
    background: #222;
    color: #fff;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.05);
  }

  input[type="range"] {
    accent-color: #ffffff;
  }

  .sidebar-section {
    margin: 0;
  }

  .divider {
    margin: 8px 0;
  }

  .info-link {
    text-align: center;
    font-size: 12px;
  }

  #matrix-canvas {
    display: block;
    margin: 0 auto;
  }

  .slider-graph-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  #ui,
  .sidebar-section.matrix {
    width: 100%;
  }

  .sidebar-section.matrix {
  display: flex;
  justify-content: center;
  align-items: center;       /* ← ★これが抜けると左寄りになります */
}
}
