/* ==========================================================================
   1. 共通変数とフォント設定
   ========================================================================== */
@font-face {
  font-family: "MyDigitalFont";
  src: url("../fonts/DSEG7Classic-Bold.ttf") format("truetype");
}

:root {
  --primary-color-design: #00579f;
  --text-light-design: #ffffff;
  --text-dark-design: #333333;
  --card-bg-design: rgba(255, 255, 255, 0.1);
  --border-color-design: rgba(255, 255, 255, 0.3);

  /* タイプスケール */
  --fs-base: 1rem; /* 16px  本文・ラベル */
  --fs-md: 1.125rem; /* 18px  やや大きい本文 */
  --fs-lg: 1.25rem; /* 20px  サブ情報 */
  --fs-xl: 1.5rem; /* 24px  合数ボタン */
  --fs-2xl: 1.875rem; /* 30px  タイトル・指示テキスト */
  --fs-3xl: 2.25rem; /* 36px  STARTボタン */
  --fs-display: 4rem; /* 64px  タイマー・大数字 */
}

@media (min-width: 768px) {
  :root {
    --fs-2xl: 2.25rem; /* 36px */
    --fs-3xl: 2.625rem; /* 42px */
    --fs-display: 4.5rem; /* 72px */
  }
}

/* ==========================================================================
   2. 基本レイアウト (body, container)
   ========================================================================== */
body {
  margin: 0;
  color: var(--text-light-design);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 0;
  box-sizing: border-box;
  overflow-x: hidden;
  background-image: url("../assets/images/timer-bg-d.webp");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

.container-design {
  position: relative;
  width: 100%;
  max-width: 450px;
  margin-top: 40px;
  padding: 0 20px 40px;
  box-sizing: border-box;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

@media (min-width: 768px) {
  .container-design {
    max-width: 900px;
    padding: 0 30px 50px;
  }
}

/* ==========================================================================
   3. 炊飯量選択画面 (Index Page)
   ========================================================================== */
.page-title {
  font-size: var(--fs-2xl);
  font-weight: 600;
  color: var(--text-light-design);
  margin-bottom: 30px;
  letter-spacing: 0.1em;
}

.amount-selector-design {
  width: 100%;
  padding: 15px 0;
  margin-bottom: 20px;
  position: relative;
  overflow-x: hidden;
}

.amount-selector-design .scroll-wrapper {
  display: flex;
  overflow-x: auto;
  scroll-behavior: smooth;
  -ms-overflow-style: none;
  scrollbar-width: none;
  padding: 5px 10px;
  width: 100%;
}
.amount-selector-design .scroll-wrapper::-webkit-scrollbar {
  display: none;
}

.scroll-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 32px;
  height: 80px;
  border: none;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  color: white;
  font-size: var(--fs-2xl);
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    opacity 0.25s ease,
    background 0.2s ease;
  padding: 0;
}

.scroll-arrow-left {
  left: 0;
  border-radius: 0 8px 8px 0;
}

.scroll-arrow-right {
  right: 0;
  border-radius: 8px 0 0 8px;
}

.scroll-arrow:hover {
  background: rgba(0, 0, 0, 0.55);
}

.scroll-arrow.is-hidden {
  opacity: 0;
  pointer-events: none;
}

@media (min-width: 768px) {
  .amount-selector-design {
    overflow-x: visible;
  }
  .amount-selector-design .scroll-wrapper {
    flex-wrap: nowrap;
    justify-content: center;
    overflow-x: visible;
    padding: 0;
  }
  .amount-selector-design label {
    width: 130px;
    height: 130px;
    aspect-ratio: 1 / 1;
    margin: 8px;
  }
}

.amount-selector-design input[type="radio"] {
  display: none;
}

.amount-selector-design label {
  flex-shrink: 0;
  flex-grow: 0;
  width: 150px;
  height: 150px;
  aspect-ratio: 1 / 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--card-bg-design);
  backdrop-filter: blur(5px);
  border: 1px solid var(--border-color-design);
  border-radius: 15px;
  margin: 0 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 400;
  font-size: var(--fs-xl);
  color: var(--text-light-design);
}

.amount-selector-design input[type="radio"]:checked + label {
  background-color: #b9881d;
  border-color: var(--text-light-design);
  transform: scale(1.05);
}

.main-content-wrapper {
  width: 100%;
  margin-bottom: 30px;
}

.character-area {
  padding: 0 10px;
  box-sizing: border-box;
}

.character-area img {
  width: 100%;
  height: auto;
  max-width: 230px;
  display: block;
  margin: 0 auto;
}

.info-display-design {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  margin-bottom: 0;
}

.info-item-design {
  padding: 10px;
  margin: 10px;
  flex: 0 1 auto;
  width: 90%;
  align-self: center;
  background-color: var(--card-bg-design);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  border-radius: 20px;
}

.info-item-design .label {
  margin: 0 0 10px 0;
  font-size: var(--fs-base);
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  line-height: 3;
  border-bottom: 1px solid #ffffff65;
}

.info-item-design .value {
  margin: 15px 2px;
  font-size: var(--fs-display);
  font-weight: 400;
  color: #ffffff;
  display: flex;
  align-items: flex-end;
  line-height: 1;
  justify-content: center;
}

.info-item-design .value span {
  font-size: var(--fs-display);
  line-height: 1;
  font-weight: 600;
}

.info-item-design .value::after {
  font-size: var(--fs-base);
  font-weight: 400;
  margin-left: 5px;
  position: relative;
  bottom: 5px;
  color: rgba(255, 255, 255, 0.8);
}

.info-item-design:first-child .value::after {
  content: "回";
}
.info-item-design:last-child .value::after {
  content: "分";
}

.option-selector-design {
  display: flex;
  gap: 15px;
  width: 100%;
  justify-content: center;
  margin-bottom: 30px;
}

.option-selector-design input[type="checkbox"] {
  display: none;
}

.option-description {
  font-size: 0.68rem;
  opacity: 0.75;
  text-align: center;
}

.option-card {
  flex: 1;
  max-width: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 12px;
  background-color: var(--card-bg-design);
  backdrop-filter: blur(5px);
  border: 1px solid var(--border-color-design);
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--text-light-design);
  font-size: var(--fs-base);
  font-weight: 400;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  user-select: none;
}

.option-card:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.option-check {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.option-check::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(-45deg) translateY(-1px);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.option-selector-design input[type="checkbox"]:checked + .option-card {
  background-color: #b9881d;
  border-color: rgba(255, 255, 255, 0.8);
  transform: scale(1.03);
}

.option-selector-design
  input[type="checkbox"]:checked
  + .option-card
  .option-check {
  background-color: rgba(255, 255, 255, 0.25);
  border-color: white;
}

.option-selector-design
  input[type="checkbox"]:checked
  + .option-card
  .option-check::after {
  opacity: 1;
}

.button-design {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 90%;
  height: 100px;
  background-color: #00579f;
  backdrop-filter: blur(5px);
  border: 1px solid var(--border-color-design);
  color: white;
  text-decoration: none;
  border-radius: 100px;
  font-size: var(--fs-3xl);
  font-weight: 600;
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.4),
    0 0 0 5px rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
  letter-spacing: 0.1em;
}

.button-design:hover {
  transform: scale(1.05);
  box-shadow:
    0 10px 25px rgba(0, 0, 0, 0.5),
    0 0 0 7px rgba(255, 255, 255, 0.4);
}

.button-design .button-icon {
  width: 30px;
  height: 30px;
  background-image: url("../assets/images/timer.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

/* ==========================================================================
   4. タイマー実行画面 (Timer Page)
   ========================================================================== */
.page-timer .container-design {
  margin-top: 40px;
  flex-grow: 1;
  justify-content: center;
  padding-bottom: 20px;
}

.selected-amount-display {
  background-color: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 20px;
  padding: 8px 50px;
  font-size: var(--fs-xl);
  font-weight: 400;
  color: var(--text-light-design);
  margin-bottom: 30px;
  letter-spacing: 0.05em;
  backdrop-filter: blur(5px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.progress-display-design {
  margin-bottom: 30px;
  border-bottom: 1px dotted;
  font-size: var(--fs-xl);
}

/* タイマー表示エリア */
.timer-wrapper-design {
  display: flex;
  width: 100%;
  max-width: 400px;
  align-items: center;
  margin-bottom: 30px;
  padding: 15px;
  background-color: var(--card-bg-design);
  border: 1px solid var(--border-color-design);
  border-radius: 20px;
  box-sizing: border-box;
  backdrop-filter: blur(5px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  height: 150px;
  position: relative;
}

@media (min-width: 768px) {
  .timer-wrapper-design {
    max-width: 600px;
  }
  .product-kama-image-container {
    width: 180px;
  }
  .direction-text-design {
    max-width: 100%;
    gap: 24px;
  }
}

.timer-display-area {
  flex: 1;
  text-align: center;
}

.timer-label-design {
  font-size: var(--fs-base);
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 5px;
  letter-spacing: 0.1em;
  transition: opacity 0.5s ease;
}

#timer-display-design {
  font-family: "MyDigitalFont", sans-serif;
  font-size: var(--fs-display);
  font-weight: 700;
  color: var(--text-light-design);
  margin-bottom: 0;
  line-height: 1;
  white-space: nowrap;
}

/* タイマーがオレンジになるクラス */
#timer-display-design.is-warning {
  color: #ff8c00 !important;
  transition: color 0.5s ease;
}

/* 進捗バー */
.step-progress-container {
  width: 100%;
  height: 8px;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  margin-top: 10px;
  overflow: hidden;
  --progress: 100%;
}

#step-progress-bar {
  width: var(--progress);
  height: 100%;
  background-color: #ffffff;
  transition:
    width 1s linear,
    background-color 0.5s ease;
}

#step-progress-bar.is-warning {
  background-color: #ff8c00 !important;
}

/* キャラクターと指示 */
.product-kama-image-container {
  flex-shrink: 0;
  width: 140px;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
}

.product-kama-image-container img {
  width: 100%;
  height: auto;
  display: block;
}

.direction-text-design {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--text-light-design);
  letter-spacing: 0.05em;
  line-height: 1.4;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 15px;
  margin-bottom: 20px;
  max-width: 600px;
}

.direction-text-content {
  flex-grow: 1;
  background-color: #fff;
  border-radius: 20px;
  padding: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.direction-character-area {
  flex-shrink: 0;
  width: 130px;
}

.direction-character-area img {
  width: 100%;
  height: auto;
  display: block;
}

/* 方向テキスト個別 */
.direction-text-design #current-direction {
  font-family: "Mochiy Pop One", sans-serif;
  color: #00579f;
  font-size: var(--fs-display);
  display: block;
  margin-bottom: 5px;
  text-shadow:
    -2px -2px 0 #fff,
    2px -2px 0 #fff,
    -2px 2px 0 #fff,
    2px 2px 0 #fff,
    -2px 0 0 #fff,
    2px 0 0 #fff,
    0 -2px 0 #fff,
    0 2px 0 #fff,
    5px 5px 8px rgba(0, 0, 0, 0.5);
}

.direction-text-design #action-text {
  font-size: var(--fs-md);
  font-weight: 600;
  color: #00579f;
}

/* ==========================================================================
   5. 状態管理クラス (is-completed, is-resting, is-reverse)
   ========================================================================== */

/* 完了状態 */
.timer-page-design.is-completed #timer-display-design {
  color: #ffffff !important;
  font-size: var(--fs-display);
  text-shadow: none;
}

.timer-page-design.is-completed .timer-character-area {
  display: none;
}

.timer-page-design.is-completed .direction-text-design #current-direction {
  font-size: var(--fs-2xl);
  color: white;
  text-shadow: none;
}

.timer-page-design.is-completed .direction-text-content {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 100px;
}

.timer-page-design.is-completed .step-progress-container,
.timer-page-design.is-completed #current-direction,
.timer-page-design.is-completed .timer-label-design {
  display: none;
}

/* 休憩中（蒸らし）状態 */
.timer-page-design.is-resting #current-direction {
  display: none;
}

.timer-page-design.is-resting .direction-text-content {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 100px;
}

.timer-page-design.is-resting #action-text {
  font-size: var(--fs-lg);
  line-height: 1.5;
}

/* レイアウト反転 */
.direction-text-design.is-reverse {
  flex-direction: row-reverse;
}

/* 最終蒸らし状態 (LAST_INPUT) の制御 */
.timer-page-design.is-final-steaming .timer-label-design,
.timer-page-design.is-final-steaming #current-direction {
  display: none;
}

.timer-page-design.is-final-steaming .direction-text-content {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 100px;
}

/* マルチカバー最終ステップ蒸らし状態（タイマーラベルは残す） */
.timer-page-design.is-multi-cover-steaming #current-direction {
  display: none;
}

.timer-page-design.is-multi-cover-steaming .direction-text-content {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 100px;
}

/* カバー待機状態 (COVER_WAIT) の制御 */
.timer-page-design.is-cover-wait .timer-label-design,
.timer-page-design.is-cover-wait #current-direction {
  display: none;
}

.timer-page-design.is-cover-wait .direction-text-content {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 100px;
}

/* ==========================================================================
   6. ライトモード (Light Mode Override)
   ========================================================================== */
body.light-mode {
  color: var(--text-dark-design);
  background-image: url("../assets/images/timer-bg-l.webp");
}

body.light-mode .page-title,
body.light-mode .info-item-design .value,
body.light-mode .selected-amount-display,
body.light-mode #timer-display-design,
body.light-mode .direction-text-design,
body.light-mode .direction-text-design #current-direction {
  color: #5b5b5b;
  text-shadow: none;
}

body.light-mode .timer-page-design.is-completed #timer-display-design {
  color: #00579f !important;
}

body.light-mode .info-item-design {
  background-color: #fff;
}

body.light-mode .info-item-design .label {
  color: #666;
  border-bottom: 1px solid #333;
}

body.light-mode .info-item-design .value::after,
body.light-mode .direction-text-design #action-text,
body.light-mode .timer-label-design {
  color: #666;
}

body.light-mode .info-item-design .value span {
  color: #00579f;
}

body.light-mode .option-card {
  background-color: #ffffff;
  border-color: #e0e0e0;
  color: var(--text-dark-design);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

body.light-mode .option-card:hover {
  background-color: #f5f5f5;
}

body.light-mode .option-check {
  border-color: #ccc;
}

body.light-mode .option-check::after {
  border-color: #333;
}

body.light-mode
  .option-selector-design
  input[type="checkbox"]:checked
  + .option-card {
  background-color: #00579f;
  border-color: #00579f;
  color: white;
}

body.light-mode
  .option-selector-design
  input[type="checkbox"]:checked
  + .option-card
  .option-check {
  border-color: white;
}

body.light-mode
  .option-selector-design
  input[type="checkbox"]:checked
  + .option-card
  .option-check::after {
  border-color: white;
}

body.light-mode .scroll-arrow {
  background: rgba(255, 255, 255, 0.6);
  color: #333;
}

body.light-mode .scroll-arrow:hover {
  background: rgba(255, 255, 255, 0.85);
}

body.light-mode .amount-selector-design label {
  background-color: #ffffff;
  border-color: #e0e0e0;
  color: var(--text-dark-design);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

body.light-mode .amount-selector-design input[type="radio"]:checked + label {
  background-color: #00579f;
  border-color: #00579f;
  color: white;
}

body.light-mode .button-design {
  background-color: #b9881d;
  border: 1px solid #e0e0e0;
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.1),
    0 0 0 5px rgba(0, 0, 0, 0.05);
}

body.light-mode .button-design .button-icon {
  background-image: url("../assets/images/timer.svg");
}

body.light-mode .button-design:hover {
  box-shadow:
    0 10px 25px rgba(0, 0, 0, 0.15),
    0 0 0 7px rgba(0, 0, 0, 0.07);
}

body.light-mode .selected-amount-display {
  background-color: #ffffff;
  border: 1px solid #e0e0e0;
}

body.light-mode .theme-toggle-button {
  background-color: rgba(255, 255, 255, 0.7);
  border-color: #e0e0e0;
  color: #333;
}

body.light-mode .timer-wrapper-design {
  background-color: #ffffff;
  border: 1px solid #e0e0e0;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

body.light-mode .direction-text-design #current-direction {
  color: #00579f;
  font-family: "Mochiy Pop One", sans-serif;
  text-shadow:
    -2px -2px 0 #fff,
    2px -2px 0 #fff,
    -2px 2px 0 #fff,
    2px 2px 0 #fff,
    -2px 0 0 #fff,
    2px 0 0 #fff,
    0 -2px 0 #fff,
    0 2px 0 #fff,
    5px 5px 8px rgba(0, 0, 0, 0.2);
}

body.light-mode #step-progress-bar {
  background-color: #00579f;
}

/* ==========================================================================
   7. 共通UIパーツ (Buttons, Modals, etc.)
   ========================================================================== */
.sound-toggle-button {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 2000;
  cursor: pointer;
  background-color: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  font-size: var(--fs-xl);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
}
.sound-toggle-button:hover {
  transform: scale(1.1);
}
body.light-mode .sound-toggle-button {
  background-color: rgba(255, 255, 255, 0.7);
  border-color: #e0e0e0;
  color: #333;
}

/* 音声案内オーバーレイ（全デバイス共通） */
.start-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.82);
  z-index: 4000;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.start-overlay-content {
  text-align: center;
  color: #ffffff;
  padding: 40px 30px;
}

.start-overlay-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  line-height: 1;
}

.start-overlay-notice {
  font-size: var(--fs-lg);
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 32px;
  letter-spacing: 0.05em;
}

.start-overlay-tap {
  font-size: var(--fs-2xl);
  font-weight: bold;
  letter-spacing: 0.15em;
  margin: 0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.theme-toggle-button {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  cursor: pointer;
  background-color: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  font-size: var(--fs-xl);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
}
.theme-toggle-button:hover {
  transform: scale(1.1);
}

.reset-button-design {
  padding: 10px 25px;
  border-radius: 100px;
  border: 1px solid #fff;
  cursor: pointer;
  background: transparent;
  color: white;
  font-size: var(--fs-base);
}

.custom-modal-design {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.custom-modal-design.is-visible {
  display: flex;
}

.modal-content {
  background-color: #ffffff;
  color: #333;
  padding: 30px;
  border-radius: 12px;
  max-width: 90%;
  width: 350px;
  text-align: center;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.modal-content p {
  font-size: var(--fs-md);
  margin-bottom: 25px;
  font-weight: bold;
}

.modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 15px;
}

.modal-actions button {
  padding: 12px 20px;
  font-size: var(--fs-base);
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  width: 50%;
}

#modal-confirm-yes {
  background-color: #004ea2;
  color: white;
}
#modal-confirm-no {
  background-color: #ccc;
  color: #333;
}

/* ==========================================================================
   8. レスポンシブ (Media Queries) - Bootstrap補完
   ========================================================================== */
@media (min-width: 768px) {
  .button-design {
    max-width: 600px;
  }
}

/* スマートフォン：指示テキストをタイマー下に縦積み表示
   ※ is-resting 等の状態クラスが flex:1 (flex-basis:0) を指定するため !important で上書き */
@media (max-width: 767px) {
  .direction-text-design {
    flex-wrap: wrap;
    gap: 10px;
  }
  .direction-text-content {
    flex-basis: 100% !important;
    order: 3;
  }
}
