/* ======================================
   ふるさと納税 控除上限シミュレーター
   スタイルシート
====================================== */

:root {
  --primary: #059669;
  --primary-hover: #047857;
  --primary-light: #d1fae5;
  --primary-rgb: 5, 150, 105;
  --bg: #f9f7f4;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --text-weak: #9ca3af;
  --border: #e2e8f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
  --transition: 0.15s ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'BIZ UDPGothic', 'Outfit', -apple-system, BlinkMacSystemFont,
               "Hiragino Sans", "Noto Sans JP", "Yu Gothic Medium", sans-serif;
  font-size: 0.9375rem;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  word-break: break-word;
}

/* ======================================
   ヘッダー
====================================== */
header {
  background: var(--primary);
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff;
  padding: 2rem 1.25rem 1.75rem;
  text-align: center;
}

.header-inner {
  max-width: 760px;
  margin: 0 auto;
}

.header-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  opacity: 0.9;
}

header h1 {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.3rem, 4vw, 1.9rem);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.subtitle {
  font-size: 0.9rem;
  opacity: 0.88;
  margin-top: 0.4rem;
}

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

/* ======================================
   広告ユニット
====================================== */
.ad-unit {
  min-height: 0;
  background: #f3f4f6;
  margin: 1.5rem 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px dashed #d1d5db;
  color: var(--text-weak);
  font-size: 0.75rem;
}

/* ======================================
   プライバシー通知
====================================== */
.privacy-notice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-sm);
  padding: 0.625rem 1rem;
  font-size: 0.8125rem;
  color: #065f46;
  margin-bottom: 1.25rem;
}

.privacy-notice .bi {
  font-size: 0.875rem;
  flex-shrink: 0;
}

/* ======================================
   カードベース
====================================== */
.tool-section,
.howto-section,
.faq-section,
.disclaimer-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.05);
  margin-bottom: 1.25rem;
}

/* ======================================
   セクションタイトル
====================================== */
.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--primary-light);
}

.section-title .bi {
  color: var(--primary);
  font-size: 1.1rem;
}

/* ======================================
   フォーム
====================================== */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 1.25rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  font-size: 0.875rem;
  font-weight: 700;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.required-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  background: #fee2e2;
  color: #dc2626;
  padding: 0.1rem 0.4rem;
  border-radius: 100px;
}

.field-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.input-with-unit {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.input-with-unit input {
  flex: 1;
}

.unit {
  font-size: 0.875rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 600;
}

input[type="number"],
input[type="text"],
select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.9375rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 44px;
  width: 100%;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

input:invalid:not(:placeholder-shown) {
  border-color: #dc2626;
}

.field-error-input { border-color: #dc2626 !important; box-shadow: 0 0 0 2px rgba(220,38,38,0.2) !important; }
.field-error-msg { color: #dc2626; font-size: 0.8rem; display: block; margin-top: 0.25rem; }

/* ======================================
   家族構成フィールドセット
====================================== */
.family-fieldset {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.family-fieldset legend {
  padding: 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: #374151;
}

/* ======================================
   チェックボックス
====================================== */
.checkbox-field {
  margin-bottom: 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
  font-size: 0.9375rem;
  color: var(--text);
  min-height: 44px;
  padding: 0.25rem 0;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 0;
  height: 0;
  opacity: 0;
  position: absolute;
}

.checkbox-custom {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color var(--transition), background var(--transition);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
  background: var(--primary);
  border-color: var(--primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
  content: '';
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

.checkbox-label input[type="checkbox"]:focus + .checkbox-custom {
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

/* ======================================
   子ども追加
====================================== */
.children-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.child-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.child-item select {
  flex: 1;
}

.btn-remove-child {
  width: 36px;
  height: 36px;
  min-height: 36px;
  border: 1.5px solid #fca5a5;
  background: #fff;
  color: #dc2626;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.btn-remove-child:hover {
  background: #fee2e2;
}

.btn-add-child {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border: 1.5px dashed var(--primary);
  background: transparent;
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  min-height: 44px;
}

.btn-add-child:hover {
  background: var(--primary-light);
}

/* ======================================
   プライマリボタン
====================================== */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), transform 0.12s ease, box-shadow var(--transition);
  min-height: 52px;
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.35);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.4);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(var(--primary-rgb), 0.25);
}

/* ======================================
   結果セクション
====================================== */
.result-section {
  margin-bottom: 1.25rem;
}

.result-panel {
  background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
  border: 1.5px solid #a7f3d0;
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  margin-bottom: 1.25rem;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary-hover);
  margin-bottom: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result-header .bi {
  font-size: 1.1rem;
}

.result-main {
  text-align: center;
  margin-bottom: 1.25rem;
}

.result-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.result-value {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(2.25rem, 8vw, 3.5rem);
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.result-value-man {
  font-size: 1.1rem;
  color: var(--primary-hover);
  font-weight: 600;
  margin-top: 0.25rem;
}

.result-gift {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: #fff;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: #065f46;
  text-align: center;
  margin-bottom: 1rem;
}

.result-gift .bi {
  font-size: 1rem;
  color: var(--primary);
  flex-shrink: 0;
}

.result-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
}

.detail-item {
  background: rgba(255,255,255,0.8);
  border: 1px solid #d1fae5;
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem;
}

.detail-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.125rem;
}

.detail-value {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
}

/* ======================================
   グラフカード
====================================== */
.chart-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.05);
  margin-bottom: 1.25rem;
}

.chart-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.chart-title .bi {
  color: var(--primary);
}

.chart-wrapper {
  max-width: 280px;
  margin: 0 auto 1rem;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ======================================
   比較カード
====================================== */
.comparison-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.05);
}

.comparison-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.comparison-title .bi {
  color: var(--primary);
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  white-space: nowrap;
  min-width: 480px;
}

.comparison-table th {
  background: #f0fdf4;
  font-weight: 700;
  padding: 0.625rem 0.875rem;
  text-align: center;
  color: #065f46;
  border-bottom: 2px solid #a7f3d0;
}

.comparison-table th:first-child {
  text-align: left;
  background: #f9f7f4;
  color: var(--text-muted);
}

.comparison-table td {
  padding: 0.6rem 0.875rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-align: center;
  vertical-align: middle;
}

.comparison-table td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.comparison-table tr:last-child td {
  border-bottom: none;
}

.comparison-table .good {
  color: var(--primary);
  font-weight: 600;
}

.comparison-note {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 0.375rem;
  line-height: 1.6;
}

.comparison-note .bi {
  flex-shrink: 0;
  margin-top: 0.125rem;
}

/* ======================================
   使い方セクション
====================================== */
.howto-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.howto-details[open] {
  border-color: #a7f3d0;
}

.howto-details summary {
  padding: 0.875rem 1rem;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--text);
  background: #f9fafb;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  user-select: none;
  transition: background var(--transition);
}

.howto-details summary::-webkit-details-marker {
  display: none;
}

.howto-details summary::after {
  content: '\002B';
  font-size: 1.25rem;
  color: var(--primary);
  flex-shrink: 0;
}

.howto-details[open] summary::after {
  content: '\2212';
}

.howto-details summary:hover {
  background: #f0fdf4;
}

.howto-content,
.howto-steps {
  padding: 1rem;
  background: var(--surface);
}

.howto-content p {
  font-size: 0.9375rem;
  color: #374151;
  line-height: 1.75;
}

.howto-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.howto-steps li {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.howto-steps strong {
  display: block;
  font-size: 0.9375rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.howto-steps p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.65;
}

.formula-box {
  background: #1a1a2e;
  color: #a7f3d0;
  border-radius: var(--radius-sm);
  padding: 0.875rem 1rem;
  margin-top: 0.75rem;
  overflow-x: auto;
}

.formula-box code {
  font-family: 'Courier New', Consolas, monospace;
  font-size: 0.8125rem;
  white-space: nowrap;
  line-height: 1.6;
}

/* ======================================
   FAQ セクション
====================================== */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.faq-item[open] {
  border-color: #a7f3d0;
}

.faq-item summary {
  padding: 0.875rem 1rem;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--text);
  background: #f9fafb;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 52px;
  user-select: none;
  transition: background var(--transition);
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: '\002B';
  font-size: 1.25rem;
  color: var(--primary);
  flex-shrink: 0;
}

.faq-item[open] summary::after {
  content: '\2212';
}

.faq-item summary:hover {
  background: #f0fdf4;
}

.faq-answer {
  padding: 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.faq-answer p {
  font-size: 0.9rem;
  color: #374151;
  line-height: 1.75;
}

/* ======================================
   免責事項
====================================== */
.disclaimer-content {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.75;
}

.disclaimer-content p {
  margin-bottom: 0.75rem;
}

.disclaimer-content strong {
  color: var(--text);
}

.disclaimer-content ul {
  padding-left: 1.25rem;
  margin-bottom: 1rem;
}

.disclaimer-content li {
  margin-bottom: 0.4rem;
}

.official-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  margin-top: 1rem;
}

.official-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  min-height: 44px;
}

.official-link:hover {
  background: var(--primary);
  color: #fff;
}

/* ======================================
   フッター
====================================== */
footer {
  text-align: center;
  padding: 2.5rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer-inner {
  max-width: 760px;
  margin: 0 auto;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1.25rem;
  margin-bottom: 0.875rem;
}

.footer-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  padding: 0.25rem 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  transition: color var(--transition);
}

.footer-nav a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.footer-copy {
  font-size: 0.8125rem;
  color: var(--text-weak);
  margin-bottom: 0.375rem;
}

.footer-note {
  font-size: 0.75rem;
  color: var(--text-weak);
  line-height: 1.5;
}

/* ======================================
   レスポンシブ
====================================== */
@media (min-width: 640px) {
  main {
    padding: 1.5rem 2rem 2.5rem;
  }

  .result-details {
    grid-template-columns: repeat(3, 1fr);
  }

  .chart-wrapper {
    max-width: 320px;
  }
}

@media (min-width: 900px) {
  main {
    padding: 2rem 2rem 3rem;
  }

  .tool-section {
    padding: 2rem;
  }
}

/* ======================================
   アニメーション
====================================== */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-section[style*="block"],
.result-section:not([style*="none"]) {
  animation: slideUp 0.25s ease;
}
