﻿* { margin: 0; padding: 0; box-sizing: border-box; }
button { touch-action: manipulation; }


body {
  font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.7;
  overflow-x: hidden;
}

header {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 1rem 0;
}

.header-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.logo {
  font-size: 1.2rem;
  font-weight: bold;
  color: #16a34a;
  text-decoration: none;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

/* ━━━ ヒーロー ━━━ */
.hero {
  text-align: center;
  padding: 1.5rem 0 1rem;
}

.hero-icon { font-size: 2.2rem; margin-bottom: 0.3rem; }

h1 {
  font-size: 1.75rem;
  font-weight: bold;
  margin-bottom: 0.4rem;
}

h2 {
  font-size: 1.05rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.description {
  color: #666;
  font-size: 0.9rem;
  line-height: 1.8;
}

/* ━━━ ヒーローバッジ ━━━ */
.hero-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.badge {
  display: inline-block;
  padding: 5px 13px;
  background: #dcfce7;
  color: #14532d;
  border: 1.5px solid #86efac;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ━━━ カード共通 ━━━ */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  border: 1px solid #e0e0e0;
}

/* ━━━ ゲームラッパー ━━━ */
.game-wrap {
  background: #fff;
  border-radius: 16px;
  border: 1px solid #e0e0e0;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* ━━━ 設定 ━━━ */
.setting-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.setting-label {
  font-size: 0.85rem;
  font-weight: bold;
  color: #666;
  min-width: 3rem;
  padding-top: 0.4rem;
}

.op-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.op-btn {
  padding: 0.5rem 1rem;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fafafa;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: bold;
  color: #666;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.op-btn:hover { border-color: #16a34a; color: #16a34a; }
.op-btn.active { background: #16a34a; border-color: #16a34a; color: #fff; }

.best-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 1rem;
  padding: 0.65rem 1rem;
  background: #f0fdf4;
  border-radius: 8px;
  border: 1px solid #bbf7d0;
}

.best-label { font-size: 0.85rem; color: #14532d; }
.best-value { font-size: 1.3rem; font-weight: 900; color: #16a34a; line-height: 1; font-variant-numeric: tabular-nums; }
.best-unit  { font-size: 0.78rem; color: #14532d; }

.primary-btn {
  display: block;
  width: 100%;
  padding: 0.9rem;
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  transition: opacity 0.15s;
  letter-spacing: 0.05em;
}

.primary-btn:hover { opacity: 0.9; }

/* ━━━ プレイパネル ━━━ */

/* 統計バー */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #f0f0f0;
}

.stat-box {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.stat-icon { font-size: 0.9rem; }

.stat-val {
  font-size: 1.1rem;
  font-weight: 900;
  color: #16a34a;
  font-variant-numeric: tabular-nums;
}

.stat-of {
  font-size: 0.75rem;
  color: #999;
  font-weight: normal;
}

.grade-btn {
  margin-left: auto;
  padding: 0.35rem 0.9rem;
  border: 1px solid #16a34a;
  border-radius: 6px;
  background: #fff;
  color: #16a34a;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s;
}

.grade-btn:hover { background: #16a34a; color: #fff; }

/* ━━━ グリッド ━━━ */
.grid-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0.75rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 2px;
  min-width: 308px; /* ensures cells ≥28px */
}

/* ヘッダーセル（演算子・数字ラベル） */
.cell-header {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border-radius: 3px;
  font-size: clamp(0.55rem, 2.2vw, 0.82rem);
  font-weight: bold;
  user-select: none;
}

.cell-op {
  background: #14532d;
  color: #86efac;
}

.cell-col {
  background: #16a34a;
  color: #fff;
}

.cell-row {
  background: #4ade80;
  color: #14532d;
}

/* 入力セル */
.cell-input {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  font-size: clamp(0.52rem, 2vw, 0.8rem);
  font-weight: bold;
  color: #333;
  background: #fff;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.cell-input:hover { border-color: #86efac; }

.cell-input.selected {
  background: #bbf7d0;
  border: 2px solid #16a34a;
  color: #14532d;
}

.cell-input.correct {
  background: #dcfce7;
  border-color: #86efac;
  color: #15803d;
}

.cell-input.wrong {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

/* ━━━ 入力エリア ━━━ */
.input-area {
  border-top: 1px solid #f0f0f0;
  padding-top: 0.75rem;
}

.input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  min-height: 2rem;
}

.cur-problem {
  font-size: 0.85rem;
  color: #999;
}

.cur-buf {
  font-size: 1.5rem;
  font-weight: 900;
  color: #16a34a;
  min-width: 3ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
  border-bottom: 2px solid #16a34a;
  padding-bottom: 1px;
}

.cur-buf.empty {
  color: #d1fae5;
  border-color: #d1fae5;
}

/* 数字パッド */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.numpad-last {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.num-btn {
  height: 52px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  font-family: inherit;
  font-size: clamp(0.9rem, 3vw, 1.2rem);
  font-weight: bold;
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

.num-btn:hover { background: #f0fdf4; border-color: #16a34a; }
.num-btn:active { transform: scale(0.94); }

.sign-btn {
  font-size: clamp(0.75rem, 2.5vw, 1rem);
  background: #f9fafb;
  color: #555;
}

.sign-btn.active {
  background: #fef9c3;
  border-color: #eab308;
  color: #92400e;
}

.del-btn {
  background: #f9fafb;
  color: #555;
  font-size: clamp(0.75rem, 2.5vw, 1rem);
}

.ok-btn {
  background: linear-gradient(135deg, #16a34a, #15803d);
  border-color: #16a34a;
  color: #fff;
  font-size: clamp(0.75rem, 2.5vw, 0.95rem);
}

.ok-btn:hover { opacity: 0.9; }

/* ━━━ 結果パネル ━━━ */
.result-emoji { font-size: 3.5rem; text-align: center; margin-bottom: 0.5rem; }
.result-title { font-size: 1.5rem; font-weight: 900; text-align: center; margin-bottom: 1rem; }

.result-stats {
  background: #f0fdf4;
  border-radius: 10px;
  border: 1px solid #bbf7d0;
  padding: 1rem;
  margin-bottom: 1rem;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0;
  border-bottom: 1px solid #d1fae5;
}

.result-row:last-of-type { border-bottom: none; }

.result-lbl { font-size: 0.88rem; color: #14532d; }
.result-val { font-size: 1.1rem; font-weight: 900; color: #16a34a; font-variant-numeric: tabular-nums; }

.result-best {
  text-align: center;
  font-size: 0.88rem;
  font-weight: bold;
  color: #16a34a;
  margin-top: 0.5rem;
  min-height: 1.4rem;
}

.result-btns {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.review-btn {
  display: block;
  width: 100%;
  padding: 0.7rem;
  background: #f9fafb;
  color: #555;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
}

.review-btn:hover { border-color: #16a34a; color: #16a34a; }

.hidden { display: none; }

/* ━━━ Amazon ━━━ */
.amazon-card h2 { margin-bottom: 0.25rem; }
.amazon-note { font-size: 0.82rem; color: #999; margin-bottom: 1rem; }
.amazon-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.amazon-item {
  display: block;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 0.9rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s;
}
.amazon-item:hover {
  border-color: #FF9900;
  box-shadow: 0 2px 8px rgba(255,153,0,0.15);
  transform: translateY(-1px);
}
.amazon-item-icon { font-size: 1.7rem; margin-bottom: 0.35rem; }
.amazon-item-name { font-size: 0.88rem; font-weight: bold; margin-bottom: 0.2rem; }
.amazon-item-desc { font-size: 0.76rem; color: #888; line-height: 1.5; margin-bottom: 0.45rem; }
.amazon-item-link { font-size: 0.78rem; color: #FF9900; font-weight: bold; }

/* ━━━ 遊び方 ━━━ */
.how-item { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid #f0f0f0; }
.how-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.how-item h3 { font-size: 0.9rem; font-weight: bold; margin-bottom: 0.3rem; color: #16a34a; }
.how-item p { font-size: 0.875rem; color: #666; line-height: 1.7; }

footer {
  text-align: center;
  padding: 2rem;
  color: #999;
  font-size: 0.875rem;
}
footer a { color: #999; text-decoration: none; margin: 0 0.5rem; }
footer a:hover { color: #16a34a; }
footer p { margin-bottom: 0.3rem; }

/* ━━━ レスポンシブ ━━━ */

/* ─── Tips grid (rank-tracker 統一パターン) ──────── */
.tips-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.tip-item { display: flex; gap: .65rem; }
.tip-icon { font-size: 1.4rem; flex-shrink: 0; }
.tip-text strong { display: block; font-weight: 700; margin-bottom: .15rem; font-size: .88rem; }
.tip-text p { font-size: .8rem; color: #78716c; line-height: 1.55; }
@media (max-width: 480px) {
  h1 { font-size: 1.4rem; }
  .game-wrap { padding: 0.9rem; }
  .num-btn { font-size: 1rem; height: 38px; }
  .cur-buf { font-size: 1.3rem; }

  .tips-grid { grid-template-columns: 1fr; }
  .scene-grid { grid-template-columns: 1fr; }
}

.amazon-notice {
  font-size: 0.72rem;
  color: #bbb;
  margin-top: 0.2rem;
}

/* ━━━ 活用シーン ━━━ */
.scene-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .75rem;
}
.scene-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .85rem 1rem;
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  border-radius: 12px;
}
.scene-icon { font-size: 1.7rem; flex-shrink: 0; }
.scene-body strong { display: block; font-size: .88rem; font-weight: 700; color: #14532d; margin-bottom: .2rem; }
.scene-body p { font-size: .78rem; color: #4b5563; line-height: 1.55; margin: 0; }

/* ━━━ 関連ツール ━━━ */
.related-tools {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem;
}
.related-tool-item {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .85rem 1rem;
  border: 1.5px solid #e8edf5;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.related-tool-item:hover { border-color: #16a34a; box-shadow: 0 2px 8px rgba(22,163,74,.1); }
.related-tool-icon { font-size: 1.6rem; flex-shrink: 0; }
.related-tool-item strong { display: block; font-size: .88rem; font-weight: 700; color: #16a34a; margin-bottom: .2rem; }
.related-tool-item p { font-size: .76rem; color: #888; line-height: 1.5; margin: 0; }

/* ━━━ FAQ ━━━ */
.faq-list { display: flex; flex-direction: column; }
.faq-item { padding: .9rem 0; border-bottom: 1px solid #f0f0f0; }
.faq-item:last-child { border-bottom: none; padding-bottom: 0; }
.faq-q { font-size: .9rem; font-weight: 700; color: #16a34a; margin-bottom: .35rem; }
.faq-a { font-size: .85rem; color: #555; line-height: 1.75; }
