/* 基本設定 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Arial', 'Helvetica', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* ページ共通 */
.page {
  background: white;
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  max-width: 600px;
  width: 100%;
}

.hidden {
  display: none !important;
}


/* 見出し */
h1 {
  font-size: 2.5rem;
  color: #333;
  text-align: center;
  margin-bottom: 30px;
}

h2 {
  font-size: 2rem;
  color: #333;
  text-align: center;
  margin-bottom: 20px;
}

h3 {
  font-size: 1.3rem;
  color: #555;
  margin-bottom: 15px;
  border-bottom: 2px solid #667eea;
  padding-bottom: 5px;
}

/* ボタン共通 */
button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 15px 30px;
  font-size: 1.1rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin: 5px;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* TOPページ */
#top-page {
  text-align: center;
}

#top-page button {
  font-size: 1.5rem;
  padding: 20px 50px;
  margin-top: 20px;
}

/* モード選択 */
.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.mode-buttons button {
  width: 100%;
  padding: 20px;
  font-size: 1.2rem;
}

/* 入力セクション */
.input-section {
  margin-bottom: 20px;
}

.input-section label {
  display: block;
  font-weight: bold;
  color: #555;
  margin-bottom: 5px;
  margin-top: 10px;
}

.input-section input {
  width: 100%;
  padding: 10px;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 5px;
  transition: border-color 0.3s ease;
}

.input-section input:focus {
  outline: none;
  border-color: #667eea;
}

.input-section button {
  margin-top: 10px;
  width: 100%;
}

/* 項目リスト */
.items-list {
  margin: 30px 0;
  padding: 20px;
  background: #f9f9f9;
  border-radius: 10px;
}

#custom-items-list {
  max-height: 300px;
  overflow-y: auto;
}

.item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  margin-bottom: 10px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.item-name {
  font-weight: bold;
  color: #333;
  flex: 1;
}

.item-weight {
  color: #666;
  margin: 0 15px;
  font-size: 0.9rem;
}

.item-row button {
  padding: 8px 15px;
  font-size: 0.9rem;
  background: #e74c3c;
}

.item-row button:hover {
  background: #c0392b;
}

#total-weight {
  margin-top: 15px;
  font-weight: bold;
  font-size: 1.2rem;
  color: #667eea;
  text-align: right;
}

/* アクションボタン */
.action-buttons {
  display: flex;
  gap: 10px;
  margin: 20px 0;
}

.action-buttons button {
  flex: 1;
}

/* 保存済みルーレット */
.saved-roulettes {
  margin-top: 30px;
  padding: 20px;
  background: #f0f0f0;
  border-radius: 10px;
}

#saved-list {
  margin-top: 15px;
}

.saved-roulette-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  margin-bottom: 10px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.roulette-title {
  font-weight: bold;
  color: #333;
  flex: 1;
}

/* 日時情報追加 */
.roulette-created {
  color: #666;
  margin-left: 15px;
  font-size: 0.9rem;
}

.saved-roulette-item button {
  padding: 8px 15px;
  font-size: 0.9rem;
  margin-left: 5px;
}

.saved-roulette-item button:first-of-type {
  background: #27ae60;
}

.saved-roulette-item button:first-of-type:hover {
  background: #229954;
}

.saved-roulette-item button:last-of-type {
  background: #e74c3c;
}

.saved-roulette-item button:last-of-type:hover {
  background: #c0392b;
}

/* ルーレット画面 */
#roulette-page {
  text-align: center;
}

/* ✅ 追加: ルーレットコンテナとポインタ */
#roulette-container {
  position: relative;
  margin: 30px auto;
  display: inline-block;
}

#roulette-pointer {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
  color: #e74c3c;
  z-index: 10;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  line-height: 1;
}

#roulette-canvas {
  display: block;
  border: 3px solid #667eea;
  border-radius: 50%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

#spin-button {
  width: 100%; /* 横幅を100%にして親コンテナいっぱいに広げ、「回す！」ボタンのみが上段に来るようにする */
  font-size: 1.5rem;
  padding: 20px 60px;
  margin-bottom: 10px; /* 左右のmarginをなくし、下だけ残す */
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

#spin-button:hover {
  background: linear-gradient(135deg, #f5576c 0%, #f093fb 100%);
}

/* 結果表示 */
#result {
  /* position: absolute で roulette-container の上に重ねる */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%); /* 中央揃え */

  /* 背景を半透明の白に（opacityではなくrgbaを使う） */
  background: rgba(255, 255, 255, 0.92);

  border-radius: 15px;
  padding: 20px 30px;
  animation: fadeIn 0.5s ease;

  /* ルーレットの円より少し小さい幅に収める */
  width: 240px;
  text-align: center;

  /* 元の gradient background は削除 */
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

#result h2 {
  color: #333;
  margin-bottom: 15px;
}

#result-text {
  font-size: 3rem;
  font-weight: bold;
  color: #e74c3c;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .page {
    padding: 20px;
  }
  
  h1 {
    font-size: 2rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
  
  button {
    padding: 12px 20px;
    font-size: 1rem;
  }
  
  #roulette-canvas {
    width: 300px;
    height: 300px;
  }
  
  #result-text {
    font-size: 2rem;
  }

  .action-buttons {
    flex-direction: column;
  }
  
  .saved-roulette-item {
    flex-direction: column;
    gap: 10px;
  }
  
  .saved-roulette-item button {
    width: 100%;
  }
}

@media (max-width: 500px) {
  /* ルーレットボタンの基本（大きい画面：横並び） */
  .roulette-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap; /* ← 収まらない時に自動で折り返す保険 */
  }

  .roulette-buttons button {
    width: 100%;
  }
}

/* スクロールバーのカスタマイズ */
#custom-items-list::-webkit-scrollbar {
  width: 8px;
}

#custom-items-list::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

#custom-items-list::-webkit-scrollbar-thumb {
  background: #667eea;
  border-radius: 10px;
}

#custom-items-list::-webkit-scrollbar-thumb:hover {
  background: #764ba2;
}

/* ボタンスタイルバリエーション */
.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.btn-success {
  background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
}

.btn-danger {
  background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
}

.btn-warning {
  background: linear-gradient(135deg, #f2994a 0%, #f2c94c 100%);
}

/* 入力フィールドのエラー表示 */
input.error {
  border-color: #e74c3c;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}

/* 空状態のメッセージ */
.empty-state {
  text-align: center;
  padding: 40px;
  color: #999;
  font-style: italic;
}

/* ローディング表示 */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* カードホバーエフェクト */
.item-row:hover,
.saved-roulette-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

/* フッター（オプション） */
.footer {
  text-align: center;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #eee;
  color: #999;
  font-size: 0.9rem;
}