/* ============================= */
/* 全体のベーススタイル         */
/* ============================= */
body {
  background: #008080;
  font-family: "MS Gothic", monospace, monospace;
  user-select: none;
  margin: 0;
  display: flex;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

/* ============================= */
/* メインウィンドウ               */
/* ============================= */
main.window {
  background: #c0c0c0;
  border: 2px solid #000;
  box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #404040;
  padding: 16px;
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ============================= */
/* タイトル                       */
/* ============================= */
h1 {
  font-weight: normal;
  color: #000080;
  text-shadow: 1px 1px 0 #fff;
  margin: 0 auto 1rem;
  text-align: center;
  width: 100%;
}

h1 .title-part,
h1 .subtitle {
  display: inline;
}

h1 .subtitle {
  font-weight: normal;
  font-size: 0.8em;
  margin-left: 0.3rem;
}

/* ============================= */
/* 作品名入力                     */
/* ============================= */
#titleContainer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

#title-label {
  font-weight: bold;
  color: #000080;
  text-shadow: 1px 1px #fff;
  user-select: none;
}

#titleInput {
  font-family: "MS Gothic", monospace;
  font-size: 1rem;
  border: 2px inset buttonface;
  padding: 4px 8px;
  min-width: 180px;
  max-width: 100%;
  box-sizing: border-box;
}

/* ============================= */
/* アプリコンテナ                 */
/* ============================= */
#app-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

/* ============================= */
/* 色パレット                     */
/* ============================= */
#palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(36px, 1fr));
  grid-gap: 6px;
  border: 2px outset buttonface;
  padding: 8px;
  background: #c0c0c0;
  min-width: 140px;
  max-width: 100%;
}

.color-btn {
  width: 36px;
  height: 36px;
  cursor: pointer;
  border: 2px outset buttonface;
  box-sizing: border-box;
  background-clip: padding-box;
  border-radius: 0;
}

.color-btn.selected {
  border-style: inset;
  outline: 2px solid #000080;
  outline-offset: 1px;
}

.color-btn.transparent {
  background: repeating-linear-gradient(45deg, #ccc, #ccc 4px, #fff 4px, #fff 8px);
  position: relative;
}

.color-btn.transparent::after {
  content: "T";
  position: absolute;
  top: 8px;
  left: 12px;
  font-weight: bold;
  color: black;
  user-select: none;
}

/* ============================= */
/* キャンバス                     */
/* ============================= */
#canvas {
  display: grid;
  grid-template-columns: repeat(16, 24px);
  grid-gap: 2px;
  border: 2px outset buttonface;
  background-color: #c0c0c0;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  touch-action: none;
}

.pixel {
  width: 24px;
  height: 24px;
  background-color: transparent;
  border: 2px inset buttonface;
  cursor: pointer;
  box-sizing: border-box;
  transition: background-color 0.15s ease;
}

.pixel:hover {
  filter: brightness(0.85);
}

/* ============================= */
/* 操作ボタン                     */
/* ============================= */
#controls {
  margin-top: 1rem;
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

#controls button {
  margin: 0;
  padding: 6px 16px;
  font-family: "MS Gothic", monospace;
  font-size: 1rem;
  border: 2px outset buttonface;
  cursor: pointer;
  user-select: none;
  min-width: 120px;
  flex-grow: 1;
  max-width: 200px;
}

#controls button:active {
  border-style: inset;
  background: #c0c0c0;
}

#controls button:focus-visible {
  outline: 2px solid #000080;
  outline-offset: 2px;
}

/* ============================= */
/* フッター                       */
/* ============================= */
footer {
  margin-top: 15px;
  text-align: center;
  font-size: 14px;
  color: #000080;
  user-select: none;
}

/* ============================= */
/* モバイル対応                   */
/* ============================= */
@media (max-width: 480px) {
  /* タイトルを縦並びに */
  h1 .title-part,
  h1 .subtitle {
    display: block;
    margin-left: 0;
  }

  /* バージョンリンク調整 */
  #version-links {
    flex-direction: column;
    gap: 0.5rem;
  }

  #version-links a.btn {
    width: 100%;
    max-width: 100%;
    min-width: auto;
    padding: 0.5rem 0;
  }

  /* パレットサイズ調整 */
  #palette {
    grid-template-columns: repeat(auto-fit, minmax(28px, 1fr));
    min-width: 100px;
  }

  .color-btn {
    width: 28px;
    height: 28px;
  }

  /* キャンバスサイズ調整 */
  #canvas {
    grid-template-columns: repeat(16, 20px);
    grid-gap: 1px;
  }

  .pixel {
    width: 20px;
    height: 20px;
    border-width: 1px;
  }
}
