:root {
  --bg: #f3efe6;
  --bg2: #ebe5d8;
  --ink: #141414;
  --ink2: #55524b;
  --line: #141414;
  --soft: rgba(20, 20, 20, .12);
  --card: #fbf9f4;
  --hot: #e8452c;
  --ac: #e8452c;
  --on-ac: #ffffff;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif CJK JP", "Noto Serif JP", serif;
  --sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans CJK JP", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --display: "Helvetica Neue", "Arial Black", "Arial", "Noto Sans CJK JP", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace;
}
[data-theme="dark"] {
  --bg: #0d0d0f;
  --bg2: #16161a;
  --ink: #f2efe8;
  --ink2: #a19d94;
  --line: #f2efe8;
  --soft: rgba(242, 239, 232, .14);
  --card: #141417;
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0 !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  background-image:
    linear-gradient(var(--soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--soft) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: -1px -1px;
  transition: background-color .25s, color .25s;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* progress */
.progress { position: fixed; inset: 0 0 auto 0; height: 4px; z-index: 30; background: transparent; }
.progress span { display: block; height: 100%; background: var(--ac); transform: scaleX(0); transform-origin: left; transition: transform .45s cubic-bezier(.2, .8, .2, 1); }
body[data-view="start"] .progress { opacity: 0; }

/* header */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; padding: 0 clamp(16px, 4vw, 40px);
  background: var(--bg);
  border-bottom: 2px solid var(--line);
}
.mark { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.mark-grid { display: grid; grid-template-columns: 9px 9px; gap: 2px; }
.mark-grid i { width: 9px; height: 9px; background: var(--ink); }
.mark-grid i:nth-child(1) { background: var(--hot); }
.mark-grid i:nth-child(4) { background: #2d5bff; }
.mark-text { font-family: var(--display); font-weight: 900; letter-spacing: .14em; font-size: 13px; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: transparent; border: 2px solid var(--line);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--ink); color: var(--bg); }
.i-moon { display: none; }
[data-theme="dark"] .i-sun { display: none; }
[data-theme="dark"] .i-moon { display: block; }

main { max-width: 1120px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) 64px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 22px;
  border: 2px solid var(--line); background: transparent;
  font-weight: 700; letter-spacing: .04em;
  transition: transform .12s, box-shadow .12s, background .15s, color .15s;
}
.btn-primary { background: var(--ink); color: var(--bg); box-shadow: 6px 6px 0 var(--ac); }
.btn-primary:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--ac); }
.btn-primary:active { transform: translate(4px, 4px); box-shadow: 2px 2px 0 var(--ac); }
.btn-ghost:hover { background: var(--ink); color: var(--bg); }
.btn:disabled { opacity: .35; cursor: default; }

.kicker { margin: 0; font-family: var(--mono); font-size: 11px; letter-spacing: .22em; color: var(--ink2); }

/* ---------- START ---------- */
.hero {
  display: grid; grid-template-columns: 1.05fr 1fr; gap: clamp(24px, 5vw, 64px);
  align-items: center; min-height: calc(100dvh - 60px - 64px); padding-top: 32px;
}
.hero-letters {
  display: grid; grid-template-columns: repeat(4, 1fr); border: 2px solid var(--line);
  background: var(--line); gap: 2px; aspect-ratio: 2 / 1;
}
.hero-letters span {
  display: grid; place-items: center; background: var(--bg);
  font-family: var(--display); font-weight: 900; font-size: clamp(44px, 9vw, 112px); line-height: 1;
  color: var(--c); transition: background .2s, color .2s;
  animation: tileIn .6s cubic-bezier(.2, .8, .2, 1) both;
}
.hero-letters span:nth-child(2n) { animation-delay: .06s; }
.hero-letters span:nth-child(3n) { animation-delay: .12s; }
@media (hover: hover) { .hero-letters span:hover { background: var(--c); color: var(--bg); } }
[data-theme="dark"] .hero-letters span[style*="#141414"] { color: var(--ink); }
.hero-letters span:nth-child(1), .hero-letters span:nth-child(6) { background: var(--c); color: var(--bg); }
@keyframes tileIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.hero-copy { display: flex; flex-direction: column; gap: 22px; }
.title { margin: 0; display: flex; align-items: flex-end; gap: 14px; line-height: .9; }
.title-num {
  font-family: var(--display); font-weight: 900; font-size: clamp(110px, 17vw, 200px);
  letter-spacing: -.06em; color: transparent; -webkit-text-stroke: 3px var(--ink);
  line-height: .78;
}
.title-ja { font-family: var(--serif); font-weight: 800; font-size: clamp(40px, 6vw, 68px); line-height: 1.02; padding-bottom: 4px; }
.lead { margin: 0; font-family: var(--serif); font-size: clamp(18px, 2.2vw, 22px); font-weight: 600; border-left: 6px solid var(--hot); padding-left: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 2px solid var(--line); border-bottom: 2px solid var(--line); }
.stats div { padding: 12px 0 10px; display: flex; flex-direction: column; }
.stats div + div { border-left: 2px solid var(--line); padding-left: 14px; }
.stats b { font-family: var(--display); font-weight: 900; font-size: clamp(22px, 3vw, 30px); line-height: 1.1; }
.stats span { font-family: var(--mono); font-size: 10px; letter-spacing: .2em; color: var(--ink2); }
.btn-start { align-self: flex-start; min-width: 240px; min-height: 64px; font-size: 18px; justify-content: space-between; padding: 0 22px 0 28px; }

/* ---------- QUIZ ---------- */
.view-quiz { max-width: 760px; margin: 0 auto; padding-top: clamp(28px, 6vh, 64px); }
.view-quiz.enter .q-head, .view-quiz.enter .q-scene, .view-quiz.enter .q-ask, .view-quiz.enter .options li { animation: rise .42s cubic-bezier(.2, .8, .2, 1) both; }
.view-quiz.enter .q-scene { animation-delay: .04s; }
.view-quiz.enter .options li:nth-child(1) { animation-delay: .08s; }
.view-quiz.enter .options li:nth-child(2) { animation-delay: .12s; }
.view-quiz.enter .options li:nth-child(3) { animation-delay: .16s; }
.view-quiz.enter .options li:nth-child(4) { animation-delay: .2s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.q-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; border-bottom: 2px solid var(--line); padding-bottom: 10px; }
.q-num { display: flex; align-items: flex-end; gap: 10px; }
.q-label { font-family: var(--mono); font-size: 11px; letter-spacing: .22em; color: var(--ink2); padding-bottom: 8px; }
#qNum { font-family: var(--display); font-weight: 900; font-size: clamp(56px, 10vw, 84px); line-height: .8; letter-spacing: -.04em; color: var(--ac); }
.q-tag { font-weight: 700; font-size: 13px; letter-spacing: .12em; padding: 4px 12px; background: var(--ink); color: var(--bg); }
.q-scene { margin: 28px 0 6px; font-family: var(--serif); font-weight: 800; font-size: clamp(24px, 4.2vw, 36px); line-height: 1.45; letter-spacing: .01em; word-break: auto-phrase; }
.q-ask { margin: 0 0 22px; font-weight: 700; color: var(--ac); letter-spacing: .1em; font-size: 14px; }

.options { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.opt {
  width: 100%; display: flex; align-items: stretch; text-align: left;
  background: var(--card); border: 2px solid var(--line); padding: 0;
  min-height: 64px; position: relative;
  transition: transform .12s, box-shadow .12s, background .15s, color .15s;
}
.opt-key {
  flex: 0 0 56px; display: grid; place-items: center;
  font-family: var(--display); font-weight: 900; font-size: 20px;
  border-right: 2px solid var(--line); background: var(--bg2);
  transition: background .15s, color .15s;
}
.opt-text { flex: 1; padding: 14px 18px; font-size: 16px; font-weight: 600; line-height: 1.55; display: flex; align-items: center; }
@media (hover: hover) {
  .opt:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
  .opt:hover .opt-key { background: var(--ac); color: #fff; }
}
.opt.is-picked { background: var(--ink); color: var(--bg); box-shadow: 6px 6px 0 var(--ac); transform: translate(-2px, -2px); }
.opt.is-picked .opt-key { background: var(--ac); color: #fff; border-color: var(--line); }
.opt:focus-visible { outline: 3px solid var(--ac); outline-offset: 3px; }

.q-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 28px; }
.q-foot .btn { min-height: 44px; padding: 0 16px; }

/* ---------- RESULT ---------- */
.view-result { padding-top: clamp(20px, 4vh, 40px); }
.r-hero {
  position: relative; overflow: hidden;
  background: var(--ac); color: var(--on-ac);
  border: 2px solid var(--line);
  padding: clamp(22px, 4vw, 44px);
  box-shadow: 10px 10px 0 var(--ink);
}
.r-hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, .09) 0 2px, transparent 2px 14px);
}
.r-kicker { color: rgba(255, 255, 255, .85); position: relative; z-index: 1; }
.r-letters { position: relative; z-index: 1; display: flex; gap: clamp(4px, 1vw, 12px); margin: 10px 0 8px; }
.r-letters span {
  font-family: var(--display); font-weight: 900; line-height: .82;
  font-size: clamp(84px, 21vw, 220px); letter-spacing: -.04em;
  animation: drop .55s cubic-bezier(.2, .9, .25, 1.2) both;
}
.r-letters span:nth-child(even) { color: transparent; -webkit-text-stroke: 3px #fff; }
@keyframes drop { from { opacity: 0; transform: translateY(-30px); } to { opacity: 1; transform: none; } }
.r-name { position: relative; z-index: 1; margin: 6px 0 0; font-family: var(--serif); font-weight: 800; font-size: clamp(30px, 5.4vw, 56px); line-height: 1.2; }
.r-en { position: relative; z-index: 1; margin: 6px 0 0; font-family: var(--mono); font-size: 12px; letter-spacing: .26em; opacity: .9; }

.r-body { display: grid; grid-template-columns: 1fr 1fr; gap: 0 clamp(24px, 5vw, 64px); margin-top: 40px; }
.r-desc { grid-column: 1; margin: 0; font-family: var(--serif); font-size: clamp(17px, 2vw, 20px); font-weight: 600; line-height: 1.9; }
.r-keys { grid-column: 1; list-style: none; margin: 20px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; }
.r-keys li { border: 2px solid var(--line); padding: 4px 12px; font-weight: 700; font-size: 14px; }
.r-keys li:first-child { background: var(--ac); color: #fff; border-color: var(--ac); }
.axes { grid-column: 2; grid-row: 1 / span 3; display: grid; gap: 20px; align-content: start; }
.axis-labels { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 8px; font-size: 13px; font-weight: 700; color: var(--ink2); }
.axis-labels b { font-family: var(--display); font-weight: 900; font-size: 22px; color: var(--ink2); margin: 0 6px 0 0; }
.ax-b { text-align: right; }
.ax-b b { margin: 0 0 0 6px !important; }
.ax-pct { font-family: var(--display); font-weight: 900; font-size: 26px; color: var(--ink); line-height: 1; }
.ax-pct small { font-size: 13px; margin-left: 1px; }
.lean-a .ax-a, .lean-a .ax-a b, .lean-b .ax-b, .lean-b .ax-b b { color: var(--ink); }
.lean-a .ax-a b, .lean-b .ax-b b { color: var(--ac); }
.axis-track { position: relative; height: 18px; margin-top: 8px; border: 2px solid var(--line); background: repeating-linear-gradient(90deg, var(--soft) 0 1px, transparent 1px 10%); }
.axis-fill { position: absolute; top: 0; bottom: 0; background: var(--ac); transition: width .9s cubic-bezier(.2, .8, .2, 1); }
.lean-a .axis-fill { left: 0; }
.lean-b .axis-fill { right: 0; }
.axis-mid { position: absolute; left: 50%; top: -6px; bottom: -6px; width: 2px; background: var(--line); }

.r-actions { grid-column: 1; display: flex; flex-wrap: wrap; gap: 14px; margin-top: 32px; }
.r-actions .btn-primary { flex: 1 1 220px; }
.btn-primary.is-done { background: var(--ac); color: #fff; box-shadow: 6px 6px 0 var(--ink); }
.copy-fallback { grid-column: 1; margin-top: 14px; width: 100%; min-height: 44px; padding: 0 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink); font-family: var(--mono); font-size: 13px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 40;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); border: 2px solid var(--ac);
  padding: 12px 20px; font-weight: 700; letter-spacing: .06em;
  transition: opacity .2s, transform .2s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; min-height: 0; padding-top: 22px; gap: 26px; }
  .hero-letters { order: 2; }
  .r-body { grid-template-columns: 1fr; margin-top: 30px; }
  .axes { grid-column: 1; grid-row: auto; margin-top: 30px; }
  .r-actions, .copy-fallback { grid-column: 1; }
}
@media (max-width: 480px) {
  .bar { height: 54px; }
  .hero { padding-top: 14px; }
  .title-num { -webkit-text-stroke-width: 2.5px; }
  .btn-start { align-self: stretch; }
  .opt-key { flex-basis: 46px; font-size: 18px; }
  .opt-text { font-size: 15px; padding: 12px 14px; }
  .q-scene { margin-top: 22px; }
  .r-hero { box-shadow: 6px 6px 0 var(--ink); }
  .r-letters span:nth-child(even) { -webkit-text-stroke-width: 2px; }
  .r-actions .btn { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
