/* ===== リセット & ベース ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #333;
  background: #f5f5f5;
  min-height: 100vh;
}

/* ===== ヘッダー ===== */
header {
  background: #2c3e50;
  color: white;
  padding: 1rem;
  text-align: center;
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  position: relative;
}

.back-link {
  display: inline-block;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 0.875rem;
  padding: 0.25rem 0.5rem;
  margin-bottom: 0.5rem;
  min-height: 44px;
  line-height: 44px;
  transition: color 0.2s;
}

.back-link:hover {
  color: white;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
}

.subtitle {
  font-size: 0.85rem;
  opacity: 0.8;
  margin-top: 0.25rem;
}

/* ===== メインレイアウト ===== */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}

/* ===== 広告ユニット ===== */
.ad-unit {
  margin: 1.25rem 0;
}

/* ===== タイマーセクション ===== */
.timer-section {
  border-radius: 16px;
  padding: 1.5rem 1rem;
  text-align: center;
  transition: background 0.5s ease, box-shadow 0.5s ease;
}

/* 集中モード: 温かいオレンジ〜赤系 */
.timer-section.focus-mode {
  background: linear-gradient(145deg, #c0392b, #e67e22);
  box-shadow: 0 4px 20px rgba(192,57,43,0.35);
  color: white;
}

/* 短い休憩: 落ち着いた緑 */
.timer-section.short-break-mode {
  background: linear-gradient(145deg, #27ae60, #2ecc71);
  box-shadow: 0 4px 20px rgba(39,174,96,0.35);
  color: white;
}

/* 長い休憩: 深い緑 */
.timer-section.long-break-mode {
  background: linear-gradient(145deg, #1e8449, #27ae60);
  box-shadow: 0 4px 20px rgba(30,132,73,0.35);
  color: white;
}

/* ===== アクティブタスクバー ===== */
.active-task-bar {
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  word-break: break-word;
}

.active-task-label {
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.active-task-name {
  opacity: 0.9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== モードバッジ ===== */
.mode-badge {
  display: inline-block;
  background: rgba(255,255,255,0.25);
  border-radius: 20px;
  padding: 0.25rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 1rem;
  letter-spacing: 0.05em;
}

/* ===== 円形タイマー ===== */
.timer-ring-wrapper {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 1.25rem;
}

.timer-ring {
  width: 200px;
  height: 200px;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(255,255,255,0.2);
  stroke-width: 10;
}

.ring-progress {
  fill: none;
  stroke: rgba(255,255,255,0.9);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 553;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}

.timer-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: white;
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
  line-height: 1;
}

/* ===== タイマーボタン ===== */
.timer-controls {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.btn-timer {
  min-width: 88px;
  min-height: 44px;
  padding: 0.6rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 700;
  border: 2px solid rgba(255,255,255,0.8);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  background: rgba(255,255,255,0.15);
  color: white;
}

.btn-timer:hover:not(:disabled) {
  background: rgba(255,255,255,0.3);
  transform: translateY(-1px);
}

.btn-timer:active:not(:disabled) {
  transform: translateY(0);
}

.btn-timer:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-start {
  background: rgba(255,255,255,0.9);
  color: #c0392b;
  border-color: white;
  min-height: 56px;
}

.btn-start:hover:not(:disabled) {
  background: white;
  color: #c0392b;
}

/* ===== 時間設定ボタン ===== */
.duration-settings {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.duration-label {
  font-size: 0.85rem;
  opacity: 0.85;
  white-space: nowrap;
}

.duration-options {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
  justify-content: center;
}

.duration-btn {
  min-height: 44px;
  padding: 0.375rem 0.75rem;
  font-size: 0.825rem;
  font-weight: 600;
  border: 1.5px solid rgba(255,255,255,0.5);
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  color: rgba(255,255,255,0.85);
  transition: all 0.2s;
}

.duration-btn:hover {
  background: rgba(255,255,255,0.2);
  color: white;
  border-color: rgba(255,255,255,0.8);
}

.duration-btn.active {
  background: rgba(255,255,255,0.9);
  color: #c0392b;
  border-color: white;
}

/* ===== 進捗セクション ===== */
.progress-section {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  margin-top: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.progress-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.stat-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #2c3e50;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.75rem;
  color: #777;
}

.stat-divider {
  width: 1px;
  height: 48px;
  background: #e0e0e0;
}

/* ===== タスクセクション ===== */
.task-section {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  margin-top: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 1rem;
}

/* ===== タスク追加フォーム ===== */
.task-add-form {
  margin-bottom: 1rem;
}

.task-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 1rem;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 0.5rem;
  font-family: inherit;
  min-height: 44px;
}

.task-input:focus {
  border-color: #e67e22;
  box-shadow: 0 0 0 3px rgba(230,126,34,0.15);
}

.task-add-options {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap;
}

.pomodoro-count-label {
  font-size: 0.875rem;
  color: #555;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pomodoro-count-select {
  padding: 0.4rem 0.625rem;
  font-size: 0.9rem;
  border: 1.5px solid #ddd;
  border-radius: 6px;
  outline: none;
  min-height: 44px;
  cursor: pointer;
  font-family: inherit;
}

.btn-add-task {
  min-height: 44px;
  padding: 0.4rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 700;
  background: #e67e22;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-left: auto;
  white-space: nowrap;
}

.btn-add-task:hover {
  background: #d35400;
  transform: translateY(-1px);
}

.btn-add-task:active {
  transform: translateY(0);
}

/* ===== タスクリスト ===== */
.task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.task-empty-msg {
  text-align: center;
  color: #aaa;
  font-size: 0.9rem;
  padding: 1.5rem 0;
}

/* ===== 個別タスクアイテム ===== */
.task-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: #fafafa;
  border: 1.5px solid #e8e8e8;
  border-radius: 10px;
  transition: border-color 0.2s, background 0.2s;
}

.task-item.active {
  border-color: #e67e22;
  background: #fff8f3;
}

.task-item.completed {
  opacity: 0.55;
  background: #f5f5f5;
}

.task-item.completed .task-name {
  text-decoration: line-through;
  color: #999;
}

/* タスク選択ボタン（アクティブ化） */
.btn-task-select {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  min-height: 44px;
  min-width: 44px;
  padding: 0;
  background: transparent;
  border: 1.5px solid #ccc;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: #888;
}

.btn-task-select:hover {
  border-color: #e67e22;
  color: #e67e22;
  background: rgba(230,126,34,0.08);
}

.task-item.active .btn-task-select {
  background: #e67e22;
  border-color: #e67e22;
  color: white;
}

/* タスク名 */
.task-name {
  flex: 1;
  font-size: 0.9rem;
  color: #333;
  word-break: break-word;
  min-width: 0;
}

/* ポモドーロ進捗バッジ */
.task-pomodoros {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: #e67e22;
  font-weight: 600;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.task-pomodoro-icon {
  font-size: 0.9rem;
}

/* 完了チェックボタン */
.btn-task-complete {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  min-height: 44px;
  min-width: 44px;
  padding: 0;
  background: transparent;
  border: 1.5px solid #ccc;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: #aaa;
}

.btn-task-complete:hover {
  border-color: #27ae60;
  color: #27ae60;
  background: rgba(39,174,96,0.08);
}

.task-item.completed .btn-task-complete {
  background: #27ae60;
  border-color: #27ae60;
  color: white;
}

/* 削除ボタン */
.btn-task-delete {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  min-height: 44px;
  min-width: 44px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: #ccc;
}

.btn-task-delete:hover {
  color: #e74c3c;
  background: rgba(231,76,60,0.08);
}

/* ===== 使い方セクション ===== */
.howto-section {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  margin-top: 1.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.howto-section h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #2c3e50;
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
}

.howto-section h2:first-child {
  margin-top: 0;
}

.howto-steps {
  padding-left: 1.25rem;
  color: #555;
  font-size: 0.925rem;
}

.howto-steps li {
  margin-bottom: 0.5rem;
  line-height: 1.65;
}

.howto-section p {
  font-size: 0.925rem;
  color: #555;
  line-height: 1.7;
}

/* ===== FAQ ===== */
.faq-list {
  font-size: 0.925rem;
}

.faq-list dt {
  font-weight: 700;
  color: #333;
  margin-top: 0.875rem;
  margin-bottom: 0.25rem;
}

.faq-list dd {
  color: #555;
  margin-left: 0;
  line-height: 1.65;
}

/* ===== フッター ===== */
footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.85rem;
  color: #888;
}

footer a {
  color: #666;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

footer p + p {
  margin-top: 0.375rem;
}

/* ===== タスクを選択していないアニメーション状態 ===== */
@keyframes ring-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.timer-section.running .ring-progress {
  /* 動いているときのビジュアルフィードバック */
}

/* ===== デスクトップ ===== */
@media (min-width: 640px) {
  header h1 {
    font-size: 1.6rem;
  }

  main {
    padding: 1.5rem 2rem;
  }

  .timer-ring-wrapper {
    width: 220px;
    height: 220px;
  }

  .timer-ring {
    width: 220px;
    height: 220px;
  }

  .timer-display {
    font-size: 3.75rem;
  }

  .task-add-options {
    flex-wrap: nowrap;
  }
}

/* ===== 超小画面対応 ===== */
@media (max-width: 360px) {
  .timer-display {
    font-size: 2.75rem;
  }

  .timer-ring-wrapper {
    width: 170px;
    height: 170px;
  }

  .timer-ring {
    width: 170px;
    height: 170px;
  }

  .duration-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }
}
