@font-face {
  font-family: 'Alphabet';
  src: local("Tahoma");
  font-weight: normal;
  /*unicode-range: U+0030-0039, U+0041-005A, U+0061-007A;*/
  /* A-Z, a-z */
}

@font-face {
  font-family: 'jr-cen_rollsignregular';
  src: url('../fonts/JR-Central_Rollsign.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

body {
  background-color: #222;
  font-family: 'DotGothic16', monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2em;
}

.title {
  font-size: 2em;
}

.display-frame {
  background-color: #333;
  padding: 1em;
  border-radius: 1em;
  width: fit-content;
  box-shadow: 0 0 15px #000;
}

.led-display {
  display: flex;
  align-items: stretch;
  background-color: black;
  border: 4px solid #111;
  border-radius: 0.5em;
  overflow: hidden;
  flex-wrap: nowrap;
  font-size: 2.2em;
  color: white;
  min-width: 600px;
  min-height: 100px;
  position: relative;
}

#dot-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  /* テキストより手前に表示 */
  opacity: 0;
  /*transition: opacity 0.2s ease;*/
  /* ふわっと点灯させる */
  box-sizing: border-box;
  /* 枠のズレ防止 */
  pointer-events: none;
  /* クリック操作を邪魔しない */
}

/* ドット枠 */
.led-display.show-dots::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* 網目を通して下の文字等を選択・操作できるようにする */

  /* 縦と横の黒い細線を引いて網目を作る */
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.5) 1px, transparent 1px);

  /* 1マスのサイズ。LEDの文字サイズに合わせて数値を調整してください */
  background-size: 4px 4px;

  z-index: 10;
  /* 文字よりも上に表示させる */
}

.car-number {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0.2em 0.5em;
  background-color: black;
  color: orange;
  font-size: 1em;
  width: 1em;
  text-orientation: upright;
  line-height: 1;
  white-space: nowrap;
  font-family: 'DM Sans', sans-serif;
}

.car-digit {
  font-size: 1.3em;
  /* 数字を大きく */
  line-height: 1;
  width: max-content;
  white-space: nowrap;
  flex-shrink: 0;
  transform-origin: center center;
  /* 中央を基準に縮小 */
  /* transition: transform 0.1s ease-out;*/
}

.car-label {
  font-size: 0.7em;
  /* 「号車」を小さく */
  margin-top: 0.2em;
}


.type-area {
  background-color: #000000;
  padding: 0.3em 0.3em;
  font-size: 1.5em;
  /* 枠のベースサイズ */
  color: white;
  height: 1.5em;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  width: 3.4em;
  flex-shrink: 0;
  text-align: center;
  font-family: 'Alphabet', 'Noto Sans JP', sans-serif;
  font-weight: normal;
  position: relative;
  z-index: 2;
  /* 他の要素より前面に表示 */
}

#rounded-box {
  width: 3.4em;
  height: 1.5em;
  border-radius: 10px;
  border: 2px solid #fff;
  display: flex;
  justify-content: center;
  align-items: center;
}

#type-text {
  font-size: 0.9em;
  /* ← このサイズだけを JavaScript で変更する */
  display: inline-block;
  line-height: 1.5em;
  text-shadow: 1px 1px 0 black,
    /* 右下 */
    -1px 1px 0 black,
    /* 左下 */
    1px -1px 0 black,
    /* 右上 */
    -1px -1px 0 black;
  /* 左上 */
}

.destination-area {
  background-color: black;
  padding: 0.3em 1em;
  font-size: 1.5em;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-grow: 1;
  width: 4em;
  /* 幅を固定 */
  height: 1.5em;
  letter-spacing: 0.1em;
  /* ← ここが文字間隔 */
  font-family: 'Alphabet', 'Noto Sans JP', sans-serif;
  position: relative;
  z-index: 1;
  /* type-area より後ろに表示 */
  overflow: hidden;
  /* はみ出しを隠す */
  white-space: nowrap;
  /* 改行禁止 */
}

#destination-text {
  font-size: 1em;
  /* ← JSで変更されるサイズ */
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  height: 100%;
  /* 親の高さに合わせる */
  width: max-content;
  white-space: nowrap;
  /* 改行禁止 */
  flex-shrink: 0;
  transform-origin: left center;
  /* 左端を基準に縮小 */
  /*transition: transform 0.1s ease-out; */
  /* 変化を少し滑らかに */
}

.italic-text {
  /*font-style: italic;*/
  font-family: 'jr-cen_rollsignregular', 'Alphabet', 'Noto Sans JP', sans-serif;
}

/* 制御部 */
.controls {
  margin-top: 2em;
  display: flex;
  gap: 1em;
  flex-wrap: wrap;
  justify-content: center;
}

select,
input,
button {
  font-size: 1em;
  padding: 0.4em 0.7em;
}

.a {
  display: inline-block;
  background-color: #444;
  color: white;
  border: none;
  border-radius: 0.3em;
  padding: 0.5em 1em;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.3s ease;
  margin-top: 3em;
}

.a:hover {
  background-color: #666;
}

footer {
  text-align: center;
  padding: 6px 10px;
  font-size: 11px;
  color: #777;

  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 15px;
}

footer p {
  margin: 0;
}

footer #site-version {
  color: #aaa;
}


.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
  margin: 1.5em auto;
  max-width: 900px;
  justify-content: center;
  color: #ffffff;
  font-family: 'Noto Sans JP', sans-serif;
}

.section {
  width: 80%;
}

.controls label {
  display: flex;
  flex-direction: column;
  font-size: 0.9em;
  color: #ddd;
}

.controls input,
.controls select {
  margin-top: 0.1em;
  padding: 0.4em 0.6em;
  border: 1px solid #555;
  border-radius: 8px;
  background-color: #1e1e1e;
  color: #f0f0f0;
  font-size: 1em;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.controls input:focus,
.controls select:focus {
  border-color: #00aaff;
  box-shadow: 0 0 0 2px rgba(0, 170, 255, 0.4);
}

.controls select {
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg fill="%23aaa" height="16" viewBox="0 0 24 24" width="16" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 0.6em center;
  background-size: 1em;
  padding-right: 2em;
}

.controls button {
  padding: 0.6em 1.2em;
  font-size: 1em;
  background-color: #00aaff;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

.controls button:hover {
  background-color: #0088cc;
}

.controls button:active {
  transform: scale(0.97);
}

.toggle-container {
  display: flex;
  gap: 30px;
  /* 2つの設定項目の間の隙間（お好みで調整） */
  justify-content: flex-start;
  /* 左寄せ（中央揃えが良い場合は center に変更） */
  flex-wrap: wrap;
  /* スマホなどで画面が狭い場合は、自動で縦並びに折り返す */
  margin: 15px 0;
  /* 上下への余白 */
}

/* 1つ1つの設定項目（文字＋スイッチ） */
.toggle-item {
  display: flex;
  align-items: center;
  gap: 10px;
  /* 文字とスイッチ本体の間の隙間 */
  width: fit-content;
  /* ★解決！横幅を中身に合わせる（右側の空白誤タップ防止） */
}

/* 文字部分をクリックできるようにする */
.toggle-item label {
  cursor: pointer;
}

/* トグルスイッチの枠 */
.toggle-switch {
  display: inline-block;
  position: relative;
  margin-top: 5px;
  width: 50px;
  height: 25px;
  border-radius: 25px;
  /* heightの半分にするときれいなカプセル型になります */
  background-color: #dddddd;
  cursor: pointer;
  transition: background-color 0.4s;
}

/* チェックされた時の背景色 */
.toggle-switch:has(:checked) {
  background-color: #4bd865;
}

/* スイッチの丸い部分 */
.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2.5px;
  /* (枠25px - 丸20px) ÷ 2 で上下中央に */
  left: 2.5px;
  /* 左側に少し余白を持たせる */
  width: 20px;
  height: 20px;
  border-radius: 50%;
  box-shadow: 0 0 5px rgb(0 0 0 / 20%);
  background-color: #fff;
  transition: left 0.4s;
}

/* チェックされた時の丸の位置 */
.toggle-switch:has(:checked)::after {
  /* 枠幅50px - 丸幅20px - 右余白2.5px = 27.5px */
  left: 27.5px;
}

/* デフォルトのチェックボックス（四角い枠）を隠す */
.toggle-switch input {
  display: none;
}

/* ▼ 設定モーダルのスタイル */
#settings-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal {
  background: #fff;
  color: #000;
  padding: 20px;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}


#settings-modal label,
.color-group label {
  color: #111111;
  /* ほぼ真っ黒な色 */
  font-weight: 500;
  /* ほんの少しだけ文字を太くして視認性を高める */
}

.preset {
  margin-bottom: 15px;
  display: flex;
  gap: 10px;
  white-space: nowrap;
}

#preset-select {
  width: 100%;
}

.type-edit-row {
  display: flex;
  flex-wrap: wrap;
  /* 画面が狭いときは自動で折り返す */
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 6px;
}

.type-edit-row input[type="text"] {
  padding: 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* PC等でのベースサイズ */
.edit-ja {
  flex: 1;
  min-width: 80px;
}

.edit-en {
  flex: 1;
  min-width: 100px;
}

/* カラーピッカー等をまとめるグループ */
.color-group {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.9em;
}

.color-group input[type="color"] {
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 4px;
}

#close-settings-btn {
  background: #b8b8b8;
  color: black;
  margin-right: 10px;
}

#close-settings-btn:hover {
  background-color: #908f8f;
}

#save-settings-btn {
  width: 100%;
  font-weight: bold;
  background: #00aadd;
  color: white;
  padding: 10px 25px;
  margin-top: 10px;
}

#save-settings-btn:hover {
  background-color: #003fbd;
}

#save-image-button {
  padding: 0.6em 1.2em;
  font-size: 1em;
  background-color: #28a745;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

#save-image-button:hover {
  background-color: #218838;
}

#save-image-button:active {
  transform: scale(0.97);
}

@media (max-width: 600px) {
  .title {
    font-size: 1.5em;
    /*transform: scale(0.8); */
    /* 全体を縮小 */
  }

  .display-frame {
    transform: scale(0.55);
    /* 全体を縮小 */
  }

  .controls {
    transform: scale(1);
    margin-top: 0;
    /* 全体を縮小 */
  }

  .a {
    margin-top: 1.5em;
  }

  .type-edit-row {
    padding: 12px;
    gap: 8px;
  }

  .edit-ja,
  .edit-en {
    /* 上段：日本語と英語の入力欄を半分ずつ横幅いっぱいに広げる */
    flex: 1 1 45%;
    width: 100% !important;
    box-sizing: border-box;
  }

  .color-group {
    /* 下段：カラーピッカーとチェックボックスを横並びで均等配置 */
    flex: 1 1 100%;
    justify-content: space-between;
    margin-top: 4px;
  }

  .color-group label {
    display: flex;
    align-items: center;
  }

  .preset {
    white-space: normal;
  }

  #preset-select {
    width: auto;
  }
}