:root {
  --bg: #fff5f8;
  --surface: #ffffff;
  --text: #2b1a22;
  --muted: #8a7580;
  --accent: #e8437a;
  --accent-soft: #ffe0ea;
  --border: #f1d4de;
  --shadow: 0 4px 16px rgba(232, 67, 122, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 120px;
  min-height: 80vh;
}

h1 { margin: 0; line-height: 1.2; }
button { font: inherit; cursor: pointer; }
a { color: var(--accent); }
.muted { color: var(--muted); }

.btn {
  display: block;
  width: 100%;
  padding: 16px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  text-align: center;
  text-decoration: none;
}
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--accent); border: 2px solid var(--accent); }
.btn + .btn { margin-top: 12px; }

/* トップ */
.hero { text-align: center; padding: 48px 0 32px; }
.hero .kicker { color: var(--accent); font-weight: 700; font-size: 22px; letter-spacing: 0.1em; }
.hero h1 { font-size: 44px; margin: 4px 0 16px; }
.hero .count { color: var(--muted); margin-bottom: 32px; }
.notice {
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* 年齢確認 */
.gate { text-align: center; padding: 80px 8px; }
.gate h1 { font-size: 24px; margin-bottom: 16px; }
.gate p { line-height: 1.8; margin-bottom: 32px; }

/* 進行表示 */
.steps { display: flex; gap: 6px; margin: 8px 0 12px; }
.steps span {
  flex: 1;
  text-align: center;
  font-size: 13px;
  padding: 6px 0;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}
.steps span.on { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-bar div { height: 100%; background: var(--accent); transition: width 0.2s; }
.round-head { display: flex; justify-content: space-between; align-items: baseline; margin: 10px 0 4px; font-size: 13px; }
.question { font-size: 20px; font-weight: 700; margin: 12px 0 4px; }
.hint { font-size: 13px; color: var(--muted); margin: 0 0 12px; }

/* 顔カード */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.card {
  position: relative;
  padding: 0;
  border: 3px solid transparent;
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow);
  text-align: left;
  color: inherit;
}
.card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / var(--img-ratio, 1);
  object-fit: cover;
  object-position: center top;
  background: var(--accent-soft);
}
.card .name {
  display: block;
  padding: 6px 6px 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card.selected { border-color: var(--accent); }
.card.selected::after {
  content: "♥";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
}
.card .rank {
  position: absolute;
  top: 6px;
  left: 6px;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.grid.two { grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid.two .name { font-size: 14px; padding: 8px 10px 10px; }
.duel .card { border-width: 4px; }
.ranked { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.ranked span {
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
}
.how { background: var(--surface); border-radius: 12px; padding: 14px 14px 14px 34px; margin: 0 0 16px; box-shadow: var(--shadow); font-size: 14px; line-height: 1.9; }
.how b { color: var(--accent); }

.pr {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  border: 1px solid var(--muted);
  border-radius: 4px;
  padding: 0 4px;
  vertical-align: middle;
  line-height: 1.5;
}
.pickup { margin-top: 32px; }
.pickup h2 { font-size: 17px; margin: 0 0 12px; }
.pickup .card { text-decoration: none; }
.pickup .more { display: block; padding: 0 6px 8px; font-size: 11px; color: var(--accent); font-weight: 700; }
.ad-slot { margin-top: 24px; text-align: center; }
.ad-slot .pr { display: block; width: fit-content; margin: 0 auto 4px; }
.ad-slot img { max-width: 100%; height: auto; }
.other-site { margin-top: 24px; }

/* 保存・シェア */
.share-hint { text-align: center; margin: 10px 0 0; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 200;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(43, 26, 34, 0.92);
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}
.save-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(20, 10, 15, 0.75);
}
.save-modal-body {
  width: 100%;
  max-width: 420px;
  max-height: 100%;
  overflow: auto;
  background: var(--surface);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
}
.save-modal-body p { margin: 0 0 12px; }
.save-modal-body img { width: 100%; border-radius: 8px; margin-bottom: 12px; -webkit-touch-callout: default; }

/* モード選択 */
.mode-head { margin: 20px 0 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.modes { display: grid; gap: 10px; margin-bottom: 12px; }
.mode {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 20px;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
}
.mode b { font-size: 17px; }
.mode small { font-size: 12px; color: var(--muted); }
.mode.primary { background: var(--accent); color: #fff; }
.mode.primary small { color: rgba(255, 255, 255, 0.85); }

/* カード＋作品リンク */
/* 枠・影・選択色はラッパー側に持たせ、上（選択ボタン）と下（作品リンク）を1枚のカードに見せる */
.card-wrap {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 3px solid transparent;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.card-wrap.selected { border-color: var(--accent); }
.card-wrap .card { display: block; width: 100%; flex: 1; border: 0; border-radius: 0; box-shadow: none; }
.card-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 4px 7px;
  border-top: 1px solid var(--border);
  background: #fff8fa;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.card-link .pr { font-size: 8px; padding: 0 3px; }
.grid.two .card-link { padding: 9px 4px 10px; font-size: 13px; }
.back-link { display: inline-block; margin: 4px 0; font-size: 14px; font-weight: 700; text-decoration: none; }

/* 下部固定バー */
.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--border);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  z-index: 10;
}
.bottom-bar .inner { max-width: 560px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.bottom-bar .count { flex: 0 0 auto; font-size: 13px; color: var(--muted); min-width: 64px; text-align: center; }
.bottom-bar .btn { padding: 12px; font-size: 15px; }
.bottom-bar .btn + .btn { margin-top: 0; }
.bottom-bar .back { flex: 0 0 auto; width: auto; padding: 12px 16px; }

/* 結果 */
.result-title { text-align: center; font-size: 22px; margin: 16px 0; }
.result-img { width: 100%; border-radius: 12px; box-shadow: var(--shadow); display: block; }
.actions { margin: 20px 0 28px; }
.ranking-list { list-style: none; padding: 0; margin: 0; }
.ranking-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: 12px;
  padding: 8px 12px 8px 8px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}
.ranking-list img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; object-position: center top; }
.ranking-list .no { font-weight: 800; color: var(--accent); width: 28px; text-align: center; }
.ranking-list .who { flex: 1; font-weight: 700; min-width: 0; }
.ranking-list .who small { display: block; color: var(--muted); font-weight: 400; }
.ranking-list a { font-size: 13px; font-weight: 700; white-space: nowrap; }

.site-footer { text-align: center; font-size: 12px; color: var(--muted); padding: 24px 16px 140px; }
.site-footer p { margin: 4px 0; }
