:root {
  --primary-color: #FF9800;
  /* Pop Orange */
  --primary-shadow: #E65100;
  --secondary-color: #00BCD4;
  /* Pop Cyan */
  --secondary-shadow: #00838F;
  --accent-color: #FF4081;
  /* Pop Pink */
  --accent-shadow: #C2185B;
  --bg-color: #FFF9C4;
  /* Light Cream */
  --card-bg: #FFFFFF;
  --text-color: #424242;
  --coin-gold: #FFD700;
  --coin-border: #F57F17;
}

.container {
  max-width: 800px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 20px;
  background-color: transparent;
  position: relative;
  /* ボタンの基準位置にする */
}

/* ... existing code ... */



/* コイン表示エリア */
.coins-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-bottom: 20px;
  min-height: 120px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  border: 4px dashed #FFD54F;
}

/* ポップなコインデザイン */
.coin {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  /* バウンド効果 */
  cursor: default;
}

.coin-front,
.coin-back {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 800;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.1), 0 5px 10px rgba(0, 0, 0, 0.2);
}

.coin-front {
  background: radial-gradient(circle at 30% 30%, #FFEB3B, #FBC02D);
  border: 4px solid var(--coin-border);
  color: #E65100;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.5);
}

.coin-back {
  background: radial-gradient(circle at 30% 30%, #E0E0E0, #BDBDBD);
  border: 4px solid #757575;
  color: #616161;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.5);
  transform: rotateY(180deg);
}

.coin.flipping {
  animation: flip-pop 0.8s ease-in-out infinite;
}

@keyframes flip-pop {
  0% {
    transform: translateY(0) rotateY(0);
  }

  50% {
    transform: translateY(-150px) rotateY(180deg) scale(1.1);
  }

  100% {
    transform: translateY(0) rotateY(360deg);
  }
}

.coin.lose .coin-front,
.coin.lose .coin-back {
  background: radial-gradient(circle at 30% 30%, #B0BEC5, #78909C);
  border: 4px solid #546E7A;
  color: #37474F;
  opacity: 0.8;
}

/* メインボタン */
.flip-button {
  padding: 16px 40px;
  font-size: 1.5rem;
  font-weight: 800;
  font-family: "M PLUS Rounded 1c", sans-serif;
  background: var(--primary-color);
  color: white;
  border: none;
  border-bottom: 6px solid var(--primary-shadow);
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.1s;
  box-shadow: 0 4px 10px rgba(255, 152, 0, 0.4);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.flip-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.flip-button:active {
  transform: translateY(4px);
  border-bottom-width: 0px;
  margin-top: 6px;
  /* レイアウトずれ防止 */
  margin-bottom: -6px;
  box-shadow: none;
}

/* コントロールパネル */
.controls {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 600px;
  background: var(--card-bg);
  padding: 30px;
  border-radius: 24px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.05);
  border: 3px solid #F0F0F0;
}

/* コントロールパネルのレイアウト修正 */
.control-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.control-group label {
  font-size: 1.1rem;
  color: var(--text-color);
  font-weight: bold;
  white-space: nowrap;
  min-width: 140px;
  /* ラベルの幅を固定して揃える */
}

/* 確率入力エリア */
.probability-inputs {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 200px;
}

/* 数値・確率入力 */
#coinCountInput,
#probabilityInput {
  border: 3px solid #E0E0E0;
  border-radius: 12px;
  padding: 8px;
  font-family: inherit;
  font-weight: bold;
  font-size: 1.2rem;
  color: var(--text-color);
  transition: all 0.2s;
  background: #FAFAFA;
}

#coinCountInput:focus,
#probabilityInput:focus {
  border-color: var(--secondary-color);
  outline: none;
  background: #FFF;
  transform: scale(1.05);
}

/* スライダー */
#probabilitySlider {
  height: 12px;
  background: #E0E0E0;
  border-radius: 6px;
  border: 2px solid #FFF;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

#probabilitySlider::-webkit-slider-thumb {
  width: 28px;
  height: 28px;
  background: var(--secondary-color);
  border: 3px solid white;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transform: scale(1);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#probabilitySlider::-webkit-slider-thumb:hover {
  transform: scale(1.3);
}

/* コイン枚数入力エリア */
.coin-count-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  /* マージン削除 */
}

/* クイック選択ボタン */
.quick-select {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.quick-btn {
  background: #FFF;
  border: 2px solid var(--secondary-color);
  color: var(--secondary-color);
  font-weight: bold;
  border-radius: 20px;
  padding: 6px 12px;
  box-shadow: 0 3px 0 var(--secondary-color);
  margin: 0;
  transition: all 0.1s;
}

.quick-btn:hover {
  background: var(--secondary-color);
  color: #FFF;
  transform: translateY(-2px);
}

.quick-btn:active {
  transform: translateY(3px);
  box-shadow: none;
  margin-top: 3px;
  margin-bottom: 0px;
}

/* アクションエリア（結果とボタンのコンテナ） */
.action-area {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

/* 結果表示 */
.result-display {
  display: flex;
  gap: 20px;
  font-size: 1.2rem;
  margin: 0;
  /* マージン削除 (flex gapで制御) */
}

/* メインボタンの幅調整（モバイル対応） */
@media (max-width: 768px) {
  .action-area {
    flex-direction: column;
    gap: 16px;
  }
}

.result-display p {
  background: #FFF;
  padding: 12px 24px;
  border-radius: 16px;
  border: 3px solid #E0E0E0;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-display p:first-child {
  /* 当たり */
  border-color: #4CAF50;
  color: #2E7D32;
  background: #E8F5E9;
}

.result-display p:last-child {
  /* 外れ */
  border-color: #F44336;
  color: #C62828;
  background: #FFEBEE;
}

/* 履歴セクション */
.history-section {
  background: var(--card-bg);
  border-radius: 24px;
  border: 3px solid #E0E0E0;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.05);
  padding: 24px;
  width: 100%;
  max-width: 600px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px dashed #E0E0E0;
  padding-bottom: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  /* モバイル対応のため折りかえし許可 */
  gap: 10px;
}

.history-title {
  color: var(--text-color);
  font-size: 1.4rem;
  display: flex;
  align-items: center;
}

.history-title::before {
  content: "📜";
  margin-right: 8px;
}

/* 履歴アクションボタン */
.download-button,
.clear-button {
  border: none;
  font-weight: bold;
  border-radius: 12px;
  padding: 8px 16px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
  transition: all 0.1s;
  top: 0;
  position: relative;
}

.download-button {
  background: var(--secondary-color);
  box-shadow: 0 4px 0 var(--secondary-shadow);
  color: white;
}

.clear-button {
  background: var(--accent-color);
  box-shadow: 0 4px 0 var(--accent-shadow);
  color: white;
}

.download-button:active,
.clear-button:active {
  top: 4px;
  box-shadow: none;
}

/* 履歴リストアイテム */
.history-item {
  background: #FFF;
  border: 2px solid #EEE;
  border-radius: 16px;
  margin-bottom: 12px;
  padding: 16px;
  transition: transform 0.2s;
}

.history-item:hover {
  transform: translateX(4px);
  border-color: var(--secondary-color);
}

.history-item .history-result {
  font-size: 1.2rem;
  background: #333;
  color: #FFF;
  padding: 4px 12px;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 4px;
}

.history-item .history-result.win {
  background: #4CAF50;
  box-shadow: 0 2px 0 #2E7D32;
}

.history-item .history-result.lose {
  background: #F44336;
  box-shadow: 0 2px 0 #C62828;
}

/* メディアクエリ (コイン枚数によるサイズ調整) */
@media (max-width: 768px) {
  .coin {
    width: 80px;
    height: 80px;
  }

  .controls {
    padding: 20px;
    gap: 16px;
  }

  .flip-button {
    width: 100%;
  }


}

/* 大量コイン時のサイズ調整 */
.coins-container.medium-coins .coin {
  width: 80px;
  height: 80px;
  font-size: 1rem;
}

.coins-container.many-coins .coin {
  width: 60px;
  height: 60px;
  border-width: 3px;
}

.coins-container.many-coins .coin .coin-front,
.coins-container.many-coins .coin .coin-back {
  font-size: 0;
}

.coins-container.very-many-coins .coin {
  width: 40px;
  height: 40px;
  border-width: 2px;
}

.coins-container.very-many-coins .coin .coin-front,
.coins-container.very-many-coins .coin .coin-back {
  font-size: 0;
}

.coins-container.super-many-coins .coin {
  width: 30px;
  height: 30px;
  border-width: 1px;
}

.coins-container.super-many-coins .coin .coin-front,
.coins-container.super-many-coins .coin .coin-back {
  font-size: 0;
}

/* Sticky note (使用回数) */
.sticky-note {
  background: #FFF176;
  color: #5D4037;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: bold;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
  margin-bottom: 16px;
  border: 2px solid #FDD835;
  text-align: center;
}

/* フルスクリーンモード */
/* コンテナがフルスクリーンになるため、bodyのスタイルは不要 */
/* container自体にスタイルを適用 */
.container.fullscreen-mode {
  background-color: var(--bg-color);
  /* 背景色を適用 */
  overflow-y: auto;
  /* 必要に応じてスクロール */
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}

/* フルスクリーン時に非表示にする要素 */
.container.fullscreen-mode .controls,
.container.fullscreen-mode .history-section,
.container.fullscreen-mode .sticky-note,
.container.fullscreen-mode .fullscreen-btn {
  display: none !important;
}

/* フルスクリーン時の終了ボタン */
.exit-fullscreen-btn {
  display: none;
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1000;
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  font-weight: bold;
}

.container.fullscreen-mode .exit-fullscreen-btn {
  display: block;
}

/* フルスクリーン開始ボタン */
.fullscreen-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid var(--primary-color);
  color: var(--primary-color);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 10;
}

.fullscreen-btn:hover {
  background: var(--primary-color);
  color: white;
}

/* モバイル表示の優先スタイル（最後に記述して上書き） */
@media (max-width: 768px) {

  /* 全画面ボタンを非表示 */
  .fullscreen-btn {
    display: none !important;
  }

  /* 履歴ボタンの隙間確保 */
  .history-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  /* 13枚以上で強制的に縮小＆文字非表示 */
  .coins-container.coins-over-12 .coin {
    width: 30px !important;
    height: 30px !important;
    border-width: 2px !important;
    /* 線も少し細く */
  }

  .coins-container.coins-over-12 .coin .coin-front,
  .coins-container.coins-over-12 .coin .coin-back {
    font-size: 0 !important;
  }
}