:root {
  --primary-color: #f0f4ff;
  --secondary-color: #e0e7ff;
  --accent-color: #6366f1;
  --accent-color-dark: #4f46e5;
  --text-color: #1f2937;
  --header-bg: linear-gradient(135deg, #6366f1, #4f46e5);
  --footer-bg: #2d3748;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Sans JP', 'Roboto', sans-serif;
  background-color: var(--primary-color);
  color: var(--text-color);
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-header {
  background: var(--header-bg);
  padding: 1.2rem 0;
  color: white;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.header-content h1 {
  margin: 0;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
}

.header-content h1 i {
  margin-right: 0.5rem;
  color: #FFD700;
}

.header-image {
  width: 100%;
  text-align: center;
  margin: 0 0 1.5rem 0;
  overflow: hidden;
  background-color: var(--secondary-color);
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  border-radius: 12px;
}

.header-img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}


.container {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 2rem 1rem;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.site-footer {
  background-color: var(--footer-bg);
  color: white;
  padding: 1rem 0;
  text-align: center;
  margin-top: auto;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.day-menu {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.5rem;
  justify-content: flex-start;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 8px;
}

.day-button {
  padding: 1rem;
  border: none;
  border-radius: 8px;
  background-color: var(--secondary-color);
  cursor: pointer;
  transition: all 0.3s;
  font-size: 0.9rem;
  line-height: 1.4;
  flex: 1;
  min-width: 150px;
  max-width: 200px;
  text-align: center;
}

.day-button.active {
  background-color: var(--accent-color);
  color: white;
}

/* スクロールバーのスタイル */
.day-menu::-webkit-scrollbar {
  height: 4px;
}

.day-menu::-webkit-scrollbar-track {
  background: var(--secondary-color);
  border-radius: 4px;
}

.day-menu::-webkit-scrollbar-thumb {
  background: var(--accent-color);
  border-radius: 4px;
}

.day-menu::-webkit-scrollbar-thumb:hover {
  background: var(--accent-color-dark);
}

.content {
  flex: 1;
  background: white;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.point-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.input-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.input-group label {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
  max-width: 95%; /* ラベルの最大幅を広げる */
  flex-wrap: nowrap; /* ヘルプアイコンが次の行に行かないように */
}

/* 目標ポイントのヘルプアイコン用特別スタイル */
.current-points label {
  display: inline-flex !important;
  align-items: center !important;
  flex-wrap: nowrap !important;
}

.input-group .note {
  display: none !important; /* 強制的に非表示 */
  font-size: 0.8rem;
  color: #666;
  margin-left: 1rem;
  margin-bottom: 0.3rem;
  font-style: italic;
  margin-right: 3rem;
}

.help-icon {
  margin-left: 0.5rem;
  color: var(--accent-color);
  cursor: pointer;
  display: inline-block !important;
  z-index: 2; /* 他の要素よりも前面に表示 */
  position: relative;
}

.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltip-text {
  visibility: hidden;
  width: 200px;
  background-color: var(--text-color);
  color: white;
  text-align: center;
  border-radius: 6px;
  padding: 8px;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  margin-left: -100px;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 0.8rem;
  font-style: normal;
}

.tooltip .tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: var(--text-color) transparent transparent transparent;
}

.tooltip.active .tooltip-text {
  visibility: visible;
  opacity: 1;
}

.input-group input {
  width: 100px; /* 幅を拡大して3桁以上入力しやすく */
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-align: right; /* 入力フォームの数値を右揃えに */
}

.total-points {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 2px solid var(--secondary-color);
  text-align: center;
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 2rem;
}

.points-display {
  flex: 1;
  min-width: 200px;
}

.points-display.total {
  border-left: 2px solid var(--secondary-color);
  padding-left: 2rem;
}

.points-display h2, .points-display h3 {
  margin-bottom: 0.5rem;
}

.points-display p {
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--accent-color);
}

.points-display.total p {
  font-size: 2.2rem;
  color: var(--accent-color-dark);
}

@media (max-width: 600px) {
  .total-points {
    flex-direction: column;
    gap: 1rem;
  }

  .points-display {
    width: 100%;
    padding: 1rem;
    background-color: rgba(240, 244, 255, 0.5);
    border-radius: 8px;
  }

  .points-display h2, .points-display h3 {
    font-size: 1.2rem;
  }

  .points-display p {
    font-size: 1.5rem;
  }

  .points-display.total p {
    font-size: 1.8rem;
  }
}

.target-diff {
  font-size: 1rem;
  margin-top: 0.5rem;
  font-weight: bold;
}

.target-diff.positive {
  color: #3182ce; /* 青色（正数） */
}

.target-diff.negative {
  color: #e53e3e; /* 赤色（負数） */
}

.form-divider {
  height: 2px;
  background-color: var(--secondary-color);
  margin: 1.5rem 0;
  width: 100%;
}

.current-points {
  background-color: rgba(99, 102, 241, 0.1);
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.current-points label {
  font-weight: bold;
  color: var(--accent-color-dark);
  margin-right: 1rem;
}

.current-points input {
  flex: 1;
  min-width: 100px;
  padding: 0.5rem;
  border: 1px solid #ccd0e1;
  border-radius: 4px;
  text-align: right;
}

@media (max-width: 600px) {
  .current-points {
    flex-direction: column;
    align-items: flex-start;
  }

  .current-points label {
    margin-bottom: 0.5rem;
    display: block;
    width: 100%;
  }

  .current-points input {
    width: 100%;
    padding: 0.8rem;
  }
}

@media (max-width: 600px) {
  .points-display.total {
    border-left: none;
    border-top: 2px solid var(--secondary-color);
    padding-left: 0;
    padding-top: 1rem;
  }

  .input-group {
    flex-direction: column;
    position: relative;
    margin-bottom: 1.5rem;
    background-color: rgba(240, 244, 255, 0.5);
    padding: 0.8rem;
    border-radius: 8px;
    display: flex !important; /* 確実に表示されるようにする */
  }

  .input-group label {
    display: block;
    width: 100%;
    text-align: left;
    margin-bottom: 0.8rem;
    font-weight: 600;
  }

  .input-group .note {
    display: block;
    margin-left: 0;
    margin-top: 0.3rem;
    margin-bottom: 0.8rem;
    font-size: 0.75rem;
    font-style: italic;
    color: #555;
  }

  .help-icon {
    display: inline-block;
    position: static;
    margin-left: 0.5rem;
    vertical-align: middle;
    color: var(--accent-color);
    font-size: 1rem;
  }

  .input-group input {
    width: 60%;
    padding: 0.8rem;
    border: 1px solid #ccd0e1;
    border-radius: 4px;
    text-align: right;
    font-size: 1rem;
    display: inline-block;
  }

  .input-group span:not(.tooltip):not(.tooltip-text) {
    display: inline-block;
    margin-left: 0.5rem;
    position: static;
    vertical-align: middle;
  }

  /* 入力フィールドと単位を横並びにする */
  .input-group div:last-child {
    display: flex;
    align-items: center;
    width: 100%;
  }
}

/* 計算フォームが常に表示されるようにする重要なスタイル */
#pointForm {
  display: block !important;
  width: 100% !important;
  visibility: visible !important;
  max-height: none !important;
  overflow: visible !important;
}

.input-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  position: relative;
}

/* 報酬箱関連のスタイル */
.reward-boxes-container {
  margin: 1.5rem 0;
  text-align: center;
}

.reward-box-message {
  display: inline-block;
  margin: 0.5rem 0;
  padding: 0.75rem 1.5rem;
  font-size: 1.2rem;
  font-weight: bold;
  border-radius: 8px;
  animation: pulse 1.5s infinite;
}

.reward-box-message span {
  display: inline-block;
  transform: scale(1);
  animation: scale 1s infinite alternate;
}

.red-box {
  background-color: #ffe5e5;
  color: #e53e3e;
  border: 2px solid #e53e3e;
}

.blue-box {
  background-color: #e6f7ff;
  color: #3182ce;
  border: 2px solid #3182ce;
}

.gold-box {
  background-color: #fffbe6;
  color: #d69e2e;
  border: 2px solid #d69e2e;
  text-shadow: 0px 0px 3px rgba(214, 158, 46, 0.3);
}

.next-box-message {
  font-size: 0.9rem;
  color: #718096;
  margin-top: 0.5rem;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
  }
}

@keyframes scale {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(1.1);
  }
}

/* Tips関連のスタイル */
.tips-container {
  margin-top: 2rem;
  display: block;
  width: 100%;
}

.tips-button {
  width: 100%;
  padding: 1rem;
  background-color: var(--accent-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  text-align: left;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tips-button::after {
  content: '▼';
  margin-left: 0.5rem;
}

.tips-content {
  background-color: var(--secondary-color);
  border-radius: 0 0 8px 8px;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transition: all 0.3s ease-in-out;
  opacity: 0;
  visibility: hidden;
}

.tips-content.show {
  padding: 1.5rem;
  max-height: 2000px;
  opacity: 1;
  visibility: visible;
}

@media (max-width: 600px) {
  .tips-content.show {
    padding: 1rem;
  }

  .tip-section {
    padding: 0.5rem;
    background-color: rgba(255, 255, 255, 0.6);
    border-radius: 6px;
    margin-bottom: 1rem;
  }

  .tip-section h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--accent-color-dark);
  }

  .tip-section ul {
    padding-left: 1.2rem;
  }

  .tip-section li {
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
    line-height: 1.4;
  }
}

.day-tips {
  display: none;
}

.tips-content h3 {
  margin-bottom: 1rem;
  color: var(--accent-color);
}

.tip-section {
  margin-bottom: 1.5rem;
}

.tip-section h4 {
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.tip-section ul {
  list-style-type: disc;
  padding-left: 1.5rem;
}

.tip-section li {
  margin-bottom: 0.5rem;
}

/* 折りたたみセクションのスタイル */
.collapsible-header {
  background-color: #e0e7ff;
  padding: 1rem;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  user-select: none;
  z-index: 10;
  position: relative;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
}

.collapsible-header:hover {
  background-color: #d4d6ff;
  transform: translateY(-1px);
}

.collapsible-header.active {
  background-color: #d1d2ff;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.collapsible-content {
  display: block;
  max-height: 2000px; 
  overflow: visible;
  transition: all 0.5s ease-out;
  opacity: 1;
  visibility: visible;
  height: auto;
  border-left: 2px solid var(--secondary-color);
  padding-left: 1rem;
  margin-bottom: 1rem;
  margin-left: 1rem;
  background-color: rgba(240, 244, 255, 0.5);
  border-radius: 0 0 8px 8px;
}

.collapsible-content.collapsed {
  display: none !important;
  max-height: 0 !important;
  opacity: 0 !important;
  visibility: hidden !important;
  overflow: hidden !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
}

.collapsible-item {
  padding: 0.8rem;
  margin: 0.8rem 0;
  background-color: white;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.collapsible-item label {
  font-size: 0.95rem;
  font-weight: 500;
}

/* モバイル向けアコーディオン調整 */
@media (max-width: 768px) {
  .collapsible-header {
    padding: 1.2rem 1rem;
  }

  .collapsible-header > span:first-child {
    font-size: 1rem;
    font-weight: bold;
  }

  .collapsible-header > span:last-child {
    font-size: 0.8rem;
    background-color: rgba(99, 102, 241, 0.1);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
  }
}

/* フローティングボタン */
.floating-button {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background-color: var(--accent-color);
  color: white;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 1000;
  border: none;
  animation: pulse-light 2s infinite;
}

.floating-button:hover {
  background-color: var(--accent-color-dark);
  transform: translateY(-3px);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
}

.floating-button i {
  font-size: 24px;
}

@keyframes pulse-light {
  0% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
  }
}

/* ヘルプアイコンとツールチップ */
.help-icon {
  display: inline-block !important;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: #6366f1;
  color: white;
  text-align: center;
  line-height: 20px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  margin-left: 4px; /* ラベルの文字列の近くに配置 */
  user-select: none;
  position: relative;
  z-index: 20;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  transition: transform 0.2s ease;
}

.help-icon:active {
  transform: scale(0.95);
  background-color: #4f46e5;
}

.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip-text {
  visibility: hidden;
  position: fixed; /* 絶対位置に固定 */
  background-color: #333;
  color: white;
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 14px;
  width: 300px;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  font-weight: normal;
  text-align: left;
  opacity: 0;
  transition: opacity 0.3s;
  line-height: 120%;
  height: auto;
  max-width: 90vw;
  white-space: normal;
  word-break: break-word;
}

.tooltip-overlay {
  display: none;
}

.tooltip.active .tooltip-text {
  visibility: visible;
  opacity: 1;
  display: block;
}

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

/* モバイル向けツールチップの位置調整 */
@media (max-width: 768px) {
  .tooltip-text {
    width: 90vw;
    max-width: 300px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 30px;
    top: auto;
    right: auto;
    z-index: 1500;
  }

  .tooltip::after {
    display: none; /* 矢印を非表示に */
  }

  .help-icon {
    display: inline-block !important;
    width: 24px;
    height: 24px;
    line-height: 24px;
    font-size: 16px;
    margin-left: 4px; /* モバイルでのマージンを縮小 */
  }

  /* モバイルでのラベルとヘルプアイコンの配置を改善 */
  .input-group label {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 0.5rem;
  }

  .day-menu {
    overflow-x: auto;
    padding-bottom: 1rem;
    justify-content: flex-start;
    flex-wrap: nowrap;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.5rem;
    padding: 0 0.5rem 1rem 0.5rem;
    width: calc(100% + 1rem);
  }

  .day-button {
    min-width: 130px;
    flex: 0 0 auto;
    margin-right: 0.5rem;
    padding: 0.75rem 0.5rem;
    font-size: 0.85rem;
    scroll-snap-align: start;
    white-space: nowrap;
  }

  .header-content h1 {
    font-size: 1.1rem;
  }

  .content {
    padding: 1rem;
  }

  .point-form {
    display: block;
    width: 100%;
  }

  /* 計算フォームが必ず表示されるようにする */
  #pointForm {
    display: block !important;
    width: 100%;
  }
}

.collapsible-header > span:first-child {
  flex: 1;
  margin-right: 5rem; /* 操作テキスト用の余白 */
  word-break: break-word; /* 長いテキストを適切に折り返す */
  padding-right: 1rem; /* 右側に余白を追加してテキストが展開ボタンに被らないようにする */
  max-width: calc(100% - 8rem); /* 右側のボタンのスペースを確保 */
}

.collapsible-header > span:last-child {
  position: absolute;
  right: 1rem;
  white-space: nowrap; /* 「クリックで展開」を折り返さない */
}

.collapsible-header::after {
  content: '▼';
  position: absolute;
  right: 1rem;
  transition: transform 0.3s;
  font-size: 0.8rem;
  font-weight: normal;
}

.collapsible-header.active {
  background-color: #d4d6ff;
}

.collapsible-header.active span:last-child {
  content: 'クリックで折りたたむ ▲';
}

.collapsible-content {
  overflow: hidden;
  max-height: 800px;
  transition: max-height 0.3s ease-in-out;
  margin-left: 1rem;
  border-left: 2px solid var(--secondary-color);
}

.collapsible-content.collapsed {
  max-height: 0 !important;
  overflow: hidden !important;
  transition: max-height 0.3s ease-out;
  margin: 0;
  padding: 0;
}

.collapsible-item {
  padding-left: 1rem;
  margin: 0.5rem 0;
}

.collapsible-item label {
  font-size: 0.95rem;
}