:root {
  --paper: #fffdf5;
  --ink: #1b1a17;
  --muted: #6d675c;
  --line: #e4dcc8;
  --card: #ffffff;
  --accent: #e8452c;
  --accent-ink: #ffffff;
  --yellow: #ffd84d;
  --blue: #2f6fde;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif; line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}
.shell { max-width: 520px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); min-height: 100vh; }
h1 { font-size: 28px; line-height: 1.25; margin: 4px 0 12px; font-weight: 900; letter-spacing: .01em; }
h2 { font-size: 18px; margin: 0; font-weight: 800; }
p { margin: 8px 0; }
.center { text-align: center; }
.muted { color: var(--muted); font-size: 14px; }
.tiny { color: var(--muted); font-size: 12px; text-align: center; }
.lead { font-size: 17px; font-weight: 700; }
.eyebrow { font-size: 12px; letter-spacing: .18em; font-weight: 800; color: var(--accent); margin: 0; }

.panel { padding: 28px 4px; }
.hero h1 { font-size: 32px; }
.hero h1::after { content: ""; display: block; width: 72px; height: 8px; background: var(--yellow); margin-top: 10px; border-radius: 4px; }
.card { background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius); padding: 14px 16px; margin: 18px 0; box-shadow: 4px 4px 0 var(--ink); text-align: left; }
.card p { margin: 4px 0; font-size: 15px; }
.card small { display: block; color: var(--muted); margin-top: 8px; font-size: 12.5px; }

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
.primary, .secondary, .ghost { border-radius: 999px; font-weight: 800; padding: 12px 18px; border: 2px solid var(--ink); }
.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 3px 3px 0 var(--ink); }
.primary:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.secondary { background: var(--card); }
.ghost { background: none; border-color: transparent; color: var(--muted); text-decoration: underline; font-weight: 600; }
.big { display: block; width: 100%; font-size: 17px; padding: 16px; margin: 14px 0 6px; }
.ghost { display: block; margin: 6px auto; }
.text-btn { background: none; border: 0; color: var(--muted); font-size: 13px; text-decoration: underline; padding: 6px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 20px; }
.two .secondary { font-size: 13px; padding: 10px 8px; }

.about { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 12px; font-size: 13px; color: var(--muted); text-align: left; }
.about summary { cursor: pointer; font-weight: 700; color: var(--ink); }

/* ステージ共通ヘッダー */
.stage-header { position: sticky; top: 0; z-index: 5; background: var(--paper); padding: 8px 0 10px; }
.stage-row { display: flex; justify-content: space-between; align-items: center; }
.chip { display: inline-block; background: var(--ink); color: var(--paper); font-size: 12px; font-weight: 800; border-radius: 999px; padding: 2px 10px; margin-right: 8px; }
.track { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 8px 0 10px; }
.bar { height: 100%; background: var(--accent); border-radius: 4px; transition: width .25s; }
.prompt h2 { font-size: 20px; }
.prompt p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* 作品タイル */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid.three .cell:first-child { grid-column: 1 / -1; width: calc(50% - 6px); margin: 0 auto; }
.duel { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.cell { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tile { display: block; width: 100%; padding: 0; text-align: left; background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius); overflow: hidden; transition: transform .08s; }
button.tile:active { transform: scale(.98); }
.tile-art { position: relative; aspect-ratio: 3 / 4; }
.tile-art.noimg { aspect-ratio: 5 / 4; } /* 題字タイルは低くして、予選の4作がスクロールなしで1画面に収まるようにする */
.result-grid .tile-art.noimg { aspect-ratio: 1 / 1; }
.tile-art.cover { aspect-ratio: 1 / 1; background: #f4efe2; padding: 6px; } /* 正方形の枠に縦長の表紙を全体表示（切り抜かない） */
.tile-cover { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile-badge.inline { position: static; align-self: flex-start; margin-bottom: 3px; font-size: 11px; padding: 1px 8px; }
.tile-face {
  height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 30px 12px 12px; text-align: center; /* 上の余白は左上のバッジ用 */
  background-color: var(--tone, #f3ead2);
  background-image: radial-gradient(rgba(0,0,0,.13) 1.2px, transparent 1.4px);
  background-size: 9px 9px;
}
.era-1960, .era-1970 { --tone: #eadfc4; }
.era-1980 { --tone: #ffd9cf; }
.era-1990 { --tone: #cfe3ff; }
.era-2000 { --tone: #d5f0d8; }
.era-2010 { --tone: #e6dafc; }
.era-2020 { --tone: #ffe9b0; }
.tile-title { font-weight: 900; font-size: 21px; line-height: 1.25; word-break: break-word; overflow-wrap: anywhere; text-shadow: 0 0 6px var(--tone), 0 0 6px var(--tone); }
.tile-title.sm { font-size: 17px; }
.tile-title.xs { font-size: 14px; }
.tile-years { font-size: 11px; font-weight: 700; color: rgba(0,0,0,.6); }
.tile-meta { padding: 6px 8px 8px; border-top: 2px solid var(--ink); font-size: 11.5px; color: var(--muted); display: flex; flex-direction: column; min-height: 34px; }
.tile-meta strong { color: var(--ink); font-size: 13px; }
.tile-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-badge { position: absolute; top: 8px; left: 8px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 800; border-radius: 999px; padding: 2px 10px; }
.tile.liked, .tile.first { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent); }
.tile.liked .tile-badge, .tile.first .tile-badge { background: var(--accent); }
.tile.wished, .tile.second { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue); }
.tile.wished .tile-badge, .tile.second .tile-badge { background: var(--blue); }
.wish-btn { background: none; border: 1.5px dashed var(--muted); border-radius: 999px; font-size: 12px; padding: 6px 4px; color: var(--muted); }
.wish-btn.on { border-style: solid; border-color: var(--blue); color: var(--blue); font-weight: 800; }

/* 下部の操作バー */
.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: 10px max(16px, calc(50vw - 244px)) calc(10px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 2px solid var(--ink);
}
.status { text-align: center; font-size: 13px; font-weight: 700; }
.hint { font-size: 11px; color: var(--muted); text-align: right; line-height: 1.3; }

.names { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 16px 0; }
.names span { background: var(--card); border: 1.5px solid var(--ink); border-radius: 999px; font-size: 12px; padding: 2px 10px; }
.interstitial { padding-top: 30vh; }
.check { width: 64px; height: 64px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 34px; font-weight: 900; display: grid; place-items: center; margin: 0 auto 12px; border: 2px solid var(--ink); }
.spinner { width: 36px; height: 36px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; margin: 30vh auto 12px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 結果 */
.result-head { text-align: center; padding: 18px 0 6px; }
.pr { font-size: 11.5px; color: var(--muted); text-align: center; margin: 0 0 10px; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.result-cell { text-decoration: none; color: inherit; min-width: 0; }
.result-grid .tile-face { padding: 22px 6px 6px; gap: 4px; }
.result-grid .tile-title { font-size: 14px; }
.result-grid .tile-title.sm { font-size: 12px; }
.result-grid .tile-title.xs { font-size: 10.5px; }
.result-grid .tile-years { font-size: 9px; }
.result-grid .tile-meta { font-size: 10px; padding: 4px 6px; min-height: 0; }
.result-grid .tile-badge { top: 5px; left: 5px; font-size: 10.5px; padding: 1px 7px; }
.rank-1 .tile { border-color: var(--accent); box-shadow: 0 0 0 3px var(--yellow); }
.rank-1 .tile-badge { background: var(--accent); }
.rank-list { margin: 18px 0; border-top: 2px solid var(--ink); }
.row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.row-rank { width: 36px; font-size: 14px; }
.row-main { min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 800; font-size: 14.5px; }
.row-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-links { display: flex; gap: 6px; }
.row-links a { font-size: 12px; font-weight: 800; text-decoration: none; color: var(--ink); background: var(--yellow); border: 1.5px solid var(--ink); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.wish { margin: 26px 0; padding: 16px 14px 8px; background: #eef4ff; border: 2px solid var(--blue); border-radius: var(--radius); }
.wish .row { grid-template-columns: 1fr auto; }
.follow { display: block; text-align: center; font-size: 13px; font-weight: 700; color: var(--blue); padding: 12px 0 6px; }
.submit { text-align: center; }
.submit p { font-size: 13.5px; }
.submit details { text-align: left; font-size: 12px; color: var(--muted); margin-top: 8px; }

/* コース選択 */
.sub-head { margin: 22px 0 0; font-size: 15px; color: var(--muted); }
.courses { display: grid; gap: 10px; margin: 16px 0 6px; }
.course { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; text-align: left; background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius); padding: 12px 14px; }
.course strong { font-size: 16px; }
.course-n { font-size: 13px; font-weight: 800; align-self: center; }
.course small { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; }
.course.on { background: var(--yellow); box-shadow: 3px 3px 0 var(--ink); }
.course.on small { color: var(--ink); }
.era-label { font-size: 13px; font-weight: 700; margin: 16px 0 6px; }
.eras { display: flex; flex-wrap: wrap; gap: 6px; }
.era { background: var(--card); border: 1.5px solid var(--ink); border-radius: 999px; font-size: 13px; padding: 5px 12px; }
.era.on { background: var(--ink); color: var(--paper); font-weight: 800; }
.early { margin-top: 16px; font-size: 13px; }
.age-note { font-size: 12.5px; font-weight: 600; color: var(--accent); }
.era-or { font-size: 12px; color: var(--muted); margin: 12px 0 6px; }
.result-grid .tile-art.cover { padding: 3px; }
.result-grid .tile-meta strong { font-size: 10.5px; line-height: 1.3; }
.result-grid .tile-badge.inline { font-size: 10px; padding: 0 6px; }
.tile-meta strong { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; }
.tile-art.cover + .tile-meta { min-height: 70px; } /* バッジの有無でタイルの高さが変わらないように、バッジ1行ぶんを常に確保 */
.result-grid .tile-art.cover + .tile-meta { min-height: 0; }
.result-grid { align-items: stretch; }
.result-cell { display: flex; }
.result-cell .tile { height: 100%; } /* 題名が1行の作品と2行の作品でマスの高さがばらつかないように揃える */
.kindle { margin: 22px 0; }
.kindle h2 { font-size: 15px; margin-bottom: 8px; }
.kindle-links { display: flex; flex-wrap: wrap; gap: 6px; }
.kindle-links a { font-size: 12.5px; font-weight: 700; text-decoration: none; color: var(--ink); background: var(--card); border: 1.5px solid var(--ink); border-radius: 999px; padding: 4px 11px; }

/* 好み分析・おすすめ・みんなのランキング */
.analysis h2, .everyone h2 { font-size: 19px; margin: 2px 0 12px; }
.bars { display: grid; gap: 7px; margin-bottom: 12px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 38px; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.bar-track { height: 12px; background: var(--line); border-radius: 6px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.bar-row:nth-child(n+2) .bar-fill { background: var(--ink); }
.bar-pct { text-align: right; font-variant-numeric: tabular-nums; }
.recommend { margin: 26px 0 8px; }
.recommend h2 { font-size: 19px; }
.rec-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 10px; }
.rec-cell { text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rec-cell .tile { flex: 1; }
.rec-cell .tile-art.cover + .tile-meta { min-height: 0; }
.rec-reason { font-size: 11.5px; font-weight: 800; color: var(--accent); text-align: center; }
.everyone-list { margin: 0 0 12px; padding-left: 26px; }
.everyone-list li { padding: 5px 6px; border-bottom: 1px solid var(--line); font-size: 14px; }
.everyone-list li.mine { background: #fff3c4; font-weight: 800; }
.ev-title { display: inline-block; min-width: 9em; }
.ev-num { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.kindle-sub { font-size: 12px; color: var(--muted); margin: 10px 0 5px; font-weight: 700; }
.confirm-msg { font-size: 14px; font-weight: 700; text-align: center; margin: 14px 0 6px; }
.confirm-box .two { margin: 0 0 8px; }
.confirm-box .two button { font-size: 15px; padding: 13px 8px; }
.copy-fallback { width: 100%; font: inherit; font-size: 13px; border: 1.5px solid var(--ink); border-radius: 10px; padding: 8px; }

/* おすすめ：紹介文つきのカード */
.rec-card { display: grid; grid-template-columns: 92px 1fr; gap: 12px; align-items: start; text-decoration: none; color: inherit;
  background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius); padding: 10px; margin-top: 12px; box-shadow: 3px 3px 0 var(--ink); }
.rec-cover { width: 92px; height: 132px; object-fit: contain; background: #f4efe2; border-radius: 6px; display: block; }
div.rec-cover { display: flex; align-items: center; justify-content: center; padding: 6px; }
.rec-body { display: flex; flex-direction: column; min-width: 0; }
.rec-lead { font-size: 12px; font-weight: 800; color: var(--accent); margin-bottom: 2px; }
.rec-title { font-size: 16px; line-height: 1.3; }
.rec-sub { font-size: 11px; color: var(--muted); margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-hook { font-size: 13.5px; margin: 0 0 4px; line-height: 1.55; }
.rec-pull { font-size: 12.5px; margin: 0 0 8px; line-height: 1.5; color: var(--muted); }
.rec-tags { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-top: auto; }
.rec-tags span { font-size: 11px; font-weight: 700; border: 1.5px solid var(--ink); border-radius: 999px; padding: 1px 8px; }
.rec-tags .rec-go { margin-left: auto; border: 0; background: var(--yellow); border: 1.5px solid var(--ink); font-weight: 800; padding: 3px 10px; }

/* 3×3 の小さいタイル（予選・順位づけ）。作者名は省き、題名は2行まで */
.grid.nine { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid.nine .tile { border-radius: 10px; }
.grid.nine .tile-art.cover { padding: 3px; }
.grid.nine .tile-art.noimg { aspect-ratio: 1 / 1; }
.grid.nine .tile-face { padding: 22px 5px 5px; gap: 3px; }
.grid.nine .tile-title { font-size: 13px; }
.grid.nine .tile-title.sm { font-size: 11.5px; }
.grid.nine .tile-title.xs { font-size: 10px; }
.grid.nine .tile-years { font-size: 9px; }
.grid.nine .tile-meta { padding: 4px 5px 5px; font-size: 10px; min-height: 50px; }
.grid.nine .tile-art.cover + .tile-meta { min-height: 50px; }
.grid.nine .tile-meta strong { font-size: 10.5px; }
.grid.nine .tile-meta > span:not(.tile-badge) { display: none; }
.grid.nine .tile-badge { font-size: 10px; padding: 0 6px; top: 4px; left: 4px; }
.grid.nine .tile-badge.inline { margin-bottom: 2px; }
.grid.nine .tile.liked, .grid.nine .tile.first, .grid.nine .tile.wished, .grid.nine .tile.second { box-shadow: 0 0 0 2px currentColor; }
.grid.nine .tile.liked, .grid.nine .tile.first { color: var(--accent); }
.grid.nine .tile.wished, .grid.nine .tile.second { color: var(--blue); }
.grid.nine .tile strong, .grid.nine .tile .tile-title, .grid.nine .tile .tile-years { color: var(--ink); }
.cell.dim { opacity: .38; }

/* 年齢スライダー */
.age { display: flex; flex-direction: column; gap: 4px; }
.age-row { display: grid; grid-template-columns: auto auto 1fr auto auto; align-items: center; gap: 8px; }
.age-cap { font-size: 14px; font-weight: 700; }
.age-range { width: 100%; height: 32px; accent-color: var(--muted); }
.age-range.on { accent-color: var(--accent); }
.age-value { font-size: 17px; font-weight: 900; min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }
.age-clear { background: none; border: 1.5px solid var(--ink); border-radius: 999px; font-size: 12px; padding: 3px 10px; }
.age-step { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--ink); background: var(--card); font-size: 20px; font-weight: 900; line-height: 1; display: grid; place-items: center; padding: 0; }
.age-step:active:not(:disabled) { transform: scale(.94); }
.age-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 26px; }
