body {
  font-family: 'Yuji Syuku', serif; /* 筆文字風フォント */
  margin: 0;
  padding: 20px;
  text-align: center;
  background-color: #f0e4d0; /* 薄いベージュ、和紙のような背景色 */
  background-image: url("data:image/svg+xml,%3Csvg width='52' height='26' viewBox='0 0 52 26' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23d2b48c' fill-opacity='0.2'%3E%3Cpath d='M10 10c0-2.21-1.79-4-4-4-3.314 0-6-2.686-6-6h2c0 2.21 1.79 4 4 4 3.314 0 6 2.686 6 6 0 2.21 1.79 4 4 4 3.314 0 6 2.686 6 6 0 2.21 1.79 4 4 4v2c-3.314 0-6-2.686-6-6 0-2.21-1.79-4-4-4-3.314 0-6-2.686-6-6zm25.464-1.95l8.486 8.486-1.414 1.414-8.486-8.486 1.414-1.414z' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); /* 薄い和柄パターン */
}
.container {
  background-color: #fff8e1; /* クリーム色 */
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 0 20px rgba(0,0,0,0.1), 0 0 40px rgba(139,69,19,0.3); /* 影と木の枠のような影 */
  border: 5px solid #8B4513; /* 濃い茶色の枠 (木のイメージ) */
  display: inline-block; /* コンテンツに合わせて幅を調整 */
  max-width: 400px;
  width: 90%;
}
h1 {
  font-size: 2.5em;
  color: #fff;
  background-color: #c0392b; /* 祭りの赤 */
  padding: 15px 20px;
  border-radius: 10px;
  display: inline-block;
  margin-bottom: 30px;
  border: 3px solid #f1c40f; /* 金色の枠 */
  text-shadow: 2px 2px 2px #555;
  box-shadow: 0px 5px 10px rgba(0,0,0,0.3);
}
.form-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}
label {
  display: block;
  width: auto; /* 自動幅調整 */
  margin: 15px 0 5px;
  font-size: 1.3em;
  color: #5D4037; /* 濃い茶色 */
  background-color: #FFDEAD; /* ナバホホワイト (木の札のような色) */
  padding: 8px 15px;
  border-radius: 5px;
  border: 2px solid #8B4513; /* 濃い茶色の枠 */
  box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
}
input[type="number"] {
  width: 180px;
  margin-bottom: 15px;
  padding: 12px;
  box-sizing: border-box;
  border: 2px solid #8B4513; /* 濃い茶色の枠 */
  border-radius: 5px;
  font-size: 1.1em;
  text-align: center;
  background-color: #fff;
  color: #333;
  font-family: Arial, sans-serif; /* 数字は見やすいフォントに */
}
input[type="number"]:focus {
  outline: none;
  border-color: #e67e22; /* オレンジ系のフォーカス色 */
  box-shadow: 0 0 8px rgba(230, 126, 34, 0.5);
}
button {
  padding: 12px 25px;
  cursor: pointer;
  background-color: #d35400; /* 提灯のようなオレンジレッド */
  color: white;
  border: none;
  border-radius: 25px; /* 丸みのあるボタン */
  font-family: 'Yuji Syuku', serif;
  font-size: 1.5em;
  font-weight: bold;
  text-shadow: 1px 1px 2px #555;
  box-shadow: 0px 4px 8px rgba(0,0,0,0.2);
  transition: background-color 0.3s, transform 0.1s;
  margin-top: 10px;
  border-bottom: 4px solid #a04000; /* ボタンに厚みを持たせる */
}
button:hover {
  background-color: #e67e22; /* ホバー時の色を少し明るく */
  transform: translateY(-2px);
  box-shadow: 0px 6px 10px rgba(0,0,0,0.3);
}
button:active {
  transform: translateY(1px);
  box-shadow: 0px 2px 5px rgba(0,0,0,0.2);
}
#result {
  margin-top: 30px;
  font-size: 1.4em;
  color: #333;
  background-color: #fffacd; /* レモンシフォン (薄黄色、結果用紙風) */
  padding: 20px;
  border-radius: 8px;
  border: 3px dashed #8B4513; /* 茶色の破線枠 */
  line-height: 1.8;
  text-align: left; /* 結果は左寄せの方が見やすい */
  display: inline-block; /* 幅をコンテンツに合わせる */
  box-shadow: inset 0 0 10px rgba(0,0,0,0.05);
}
#result span { /* 結果の数値を目立たせる */
    font-weight: bold;
    color: #c0392b; /* 赤色 */
    font-size: 1.2em;
}

@media (max-width: 600px) { /* 一般的なスマートフォンの縦向き幅を想定 */
  body {
    padding: 10px; /* 画面端の余白を少し減らす */
    display: flex; /* コンテナを中央に配置しやすくするため */
    flex-direction: column; /* 要素を縦に並べる */
    align-items: center; /* 中央揃え */
    min-height: 100vh; /* 画面全体の高さを確保 */
    box-sizing: border-box;
  }

  .container {
    padding: 15px; /* コンテナの内側の余白を減らす */
    margin: auto 0; /* 上下マージンを自動にして、縦方向中央寄せを試みる */
    border-width: 3px; /* 枠線を少し細く */
    max-height: calc(100vh - 20px); /* 画面の高さから少し引いた値を最大高さに */
    overflow-y: hidden; /* コンテナ内の縦スクロールを禁止 (これが重要) */
    
    /* コンテナ内の要素をFlexboxで配置し、スペースを有効活用 */
    display: flex;
    flex-direction: column;
    /* 要素間のスペースをどう配分するか。space-around や space-between も試す価値あり */
    justify-content: center; /* 要素を中央に寄せる */
  }

  h1 {
    font-size: 1.8em; /* タイトルの文字サイズを小さく */
    padding: 10px 15px; /* タイトルの余白を調整 */
    margin-bottom: 10px; /* タイトルの下の余白を調整 */
    border-width: 2px; /* 枠線を少し細く */
  }

  .form-container {
    /* form-containerが残りのスペースを柔軟に使うようにする */
    /* 必要に応じて flex-grow: 1; なども検討 */
    width: 100%; /* 幅をコンテナに合わせる */
  }

  label {
    font-size: 1.1em; /* ラベルの文字サイズを調整 */
    padding: 6px 12px; /* ラベルの余白を調整 */
    margin: 8px 0 4px; /* ラベルの上下余白を調整 */
  }

  input[type="number"] {
    width: 100%; /* 入力欄の幅を親要素に合わせる */
    max-width: 170px; /* 最大幅は少し小さめに */
    padding: 10px; /* 入力欄の余白を調整 */
    font-size: 1em; /* 入力欄の文字サイズを調整 */
    margin-bottom: 8px; /* 入力欄の下の余白を調整 */
  }

  button {
    font-size: 1.3em; /* ボタンの文字サイズを調整 */
    padding: 10px 20px; /* ボタンの余白を調整 */
    margin-top: 8px; /* ボタンの上の余白を調整 */
  }

  #result {
    font-size: 1.15em; /* 結果表示の文字サイズを調整 */
    padding: 12px; /* 結果表示の余白を調整 */
    margin-top: 10px; /* 結果表示の上の余白を調整 */
    line-height: 1.6; /* 行間を調整 */
    /* 結果表示エリアが長文になる場合、ここだけスクロールさせるか、
       表示文字数を制限するなどの考慮が必要になることがあります。
       今回はコンテナ全体をスクロールさせないため、ここも収まる前提です。 */
  }
}

/* 画面の高さが特に低いスマートフォン向けの調整 (例: 横向きにした場合など) */
/* 必要に応じて、さらに値を調整してください */
@media (max-width: 600px) and (max-height: 600px) {
  body {
    padding: 5px;
  }
  .container {
    padding: 10px;
    max-height: calc(100vh - 10px);
  }
  h1 {
    font-size: 1.5em;
    padding: 8px 10px;
    margin-bottom: 8px;
  }
  label {
    font-size: 1em;
    padding: 5px 10px;
    margin: 6px 0 3px;
  }
  input[type="number"] {
    padding: 8px;
    font-size: 0.9em;
    margin-bottom: 6px;
  }
  button {
    font-size: 1.1em;
    padding: 8px 15px;
    margin-top: 6px;
  }
  #result {
    font-size: 1em;
    padding: 10px;
    margin-top: 8px;
    line-height: 1.5;
  }
}