:root {
  --bg: #fbf8f1;
  --card: #ffffff;
  --ink: #3a3530;
  --muted: #746b62;
  --line: #ebe4d6;
  --primary: #c8414f;
  --primary-ink: #ffffff;
  --radius: 20px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Zen Maru Gothic', system-ui, sans-serif;
  font-weight: 500;
  line-height: 1.75;
}
main { max-width: 560px; margin: 0 auto; padding: 16px; }
a { color: var(--primary); }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, 'SF Mono', Menlo, monospace; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 20px;
  box-shadow: 0 8px 30px -18px rgba(58, 53, 48, 0.35);
}
.screen[hidden] { display: none; }
.title, .result { text-align: center; }

.hero { display: flex; justify-content: center; gap: 4px; margin-bottom: 8px; }
.hero .cat { width: 72px; }
.hero .cat:nth-child(2) { transform: translateY(-8px); }

.cat, .cell { position: relative; display: block; aspect-ratio: 1; }
.tint {
  position: absolute; inset: 0;
  background: var(--c);
  -webkit-mask: var(--skin-mask, url('/skins/default/mask.svg')) center / contain no-repeat;
  mask: var(--skin-mask, url('/skins/default/mask.svg')) center / contain no-repeat;
}
.cat img, .cell img { position: relative; width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }

.eyebrow { margin: 0; font-size: 12px; letter-spacing: 0.2em; color: var(--muted); }
h1 { margin: 4px 0 12px; font-size: 40px; font-weight: 900; line-height: 1.2; }
h1 .num { color: var(--primary); margin-left: 4px; }
.h1-sub { display: block; font-size: 14px; font-weight: 700; color: var(--muted); letter-spacing: 0.08em; margin-top: 4px; }
.lead { font-size: 17px; margin: 0 0 16px; }
.lead strong { color: var(--primary); }
.rules { text-align: left; margin: 0 auto 24px; padding-left: 1.2em; max-width: 380px; font-size: 14px; }
.rules li { margin: 4px 0; }
.note, .best { font-size: 12px; color: var(--muted); margin: 12px 0 0; }
.best:empty { display: none; }

.primary, .ghost {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 200px; min-height: 52px; padding: 0 28px;
  border-radius: 999px; border: 0; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 17px; text-decoration: none;
  touch-action: manipulation;
}
.primary { background: var(--primary); color: var(--primary-ink); }
.primary:hover { filter: brightness(1.06); }
.ghost { background: transparent; color: var(--ink); margin-top: 8px; }
.primary:focus-visible, .ghost:focus-visible, .cell:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

.hud { display: flex; justify-content: space-between; align-items: center; font-size: 15px; }
.hud b { font-size: 20px; }
.hud.sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.lives { color: var(--primary); letter-spacing: 0.15em; }
.timer { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 10px 0 14px; }
#timer-bar { display: block; height: 100%; background: var(--ink); transform-origin: left; }

.grid { display: grid; grid-template-columns: repeat(var(--cols, 2), 1fr); gap: 4px; }
.cell { border: 0; padding: 0; background: none; cursor: pointer; border-radius: 12px; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.cell:active { transform: scale(0.94); }
.cell.hit { animation: pop 0.25s ease-out; }
.cell.wrong { animation: shake 0.35s; opacity: 0.4; }
.cell.answer { outline: 3px solid var(--primary); outline-offset: -2px; animation: pop 0.5s ease-out 2; }
@keyframes pop { 50% { transform: scale(1.12); } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.feedback { min-height: 3.6em; margin: 12px 0 0; font-size: 13px; text-align: center; color: var(--muted); }
.feedback b { display: block; font-size: 17px; }
.feedback .ok { color: var(--ink); }
.feedback .ng { color: var(--primary); }
.score { font-size: 52px; font-weight: 700; margin: 0; line-height: 1.2; }
.rank { font-size: 26px; font-weight: 900; margin: 4px 0 16px; color: var(--primary); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 16px; }
.stats div { background: var(--bg); border-radius: 14px; padding: 10px 4px; }
.stats dt { font-size: 11px; color: var(--muted); }
.stats dd { margin: 0; font-size: 18px; font-weight: 700; }
.last { font-size: 13px; color: var(--muted); margin: 0 0 20px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--c); vertical-align: -1px; margin: 0 3px 0 6px; border: 1px solid rgba(0,0,0,.1); }

.content { padding: 24px 4px 0; }
.content section { padding: 16px 0; border-top: 1px solid var(--line); }
.content h2 { font-size: 20px; margin: 0 0 8px; line-height: 1.4; }
.content h3 { font-size: 16px; margin: 16px 0 4px; }
.content p { margin: 0 0 8px; font-size: 15px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
.wairo-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.wairo-list li { display: flex; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px; }
.wairo-list .chip { width: 40px; height: 40px; border-radius: 10px; background: var(--c); flex: none; }
.wairo-list b { display: block; font-size: 15px; }
.wairo-list small { display: block; font-size: 11px; color: var(--muted); line-height: 1.4; }

footer { text-align: center; font-size: 12px; color: var(--muted); padding: 32px 16px 40px; }
footer a { color: inherit; }
.crumb { font-size: 12px; color: var(--muted); padding: 4px 4px 0; }
.crumb a { color: inherit; }
.page-title { font-size: 26px; margin: 0 0 12px; }
.content .wairo-list { margin: 16px 0 24px; }

/* 内容ページ共通 */
.bluf { font-size: 16px !important; }
.steps { padding-left: 1.4em; margin: 0 0 8px; font-size: 15px; }
.steps li { margin: 4px 0; }
.content ul { padding-left: 1.2em; font-size: 15px; margin: 0 0 8px; }
.content li { margin: 6px 0; }
.content .primary { margin-top: 8px; }
.cta-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 8px 0 16px; text-align: center; }
.cta-box p { text-align: left; }
.formula { overflow-x: auto; white-space: nowrap; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 13px !important; }

/* 関連ページ導線（build.mjs が生成） */
.related { padding: 24px 4px 0; }
.related-title { font-size: 16px; font-weight: 700; margin: 0 0 8px; }
.related ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.related a { display: block; height: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; color: var(--ink); text-decoration: none; }
.related a:hover { border-color: var(--primary); }
.related a:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.related b { display: block; font-size: 15px; color: var(--primary); }
.related small { display: block; font-size: 12px; color: var(--muted); line-height: 1.5; }
.foot-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin-bottom: 8px; }

/* ΔE デモ */
.de-demo { padding: 20px 16px; text-align: center; margin-top: 8px; }
.de-swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-bottom: 12px; }
.de-swatches figure { margin: 0; }
.de-sw { display: block; aspect-ratio: 1; }
.de-swatches figure:first-child .de-sw { border-radius: 14px 0 0 14px; }
.de-swatches figure:last-child .de-sw { border-radius: 0 14px 14px 0; }
.de-swatches figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
.de-label { display: block; font-size: 15px; }
.de-label b { font-size: 22px; color: var(--primary); }
#de-range { width: 100%; accent-color: var(--primary); }
.de-read { font-weight: 700; margin: 8px 0 0 !important; }
.de-cmp { font-size: 12px !important; color: var(--muted); }
