:root {
  --bg: #eeeade;
  --paper: #f8f5ec;
  --paper-strong: #fffdf7;
  --ink: #24251f;
  --muted: #615e52;
  --line: #bfb9a8;
  --line-soft: #d7d2c3;
  --red: #862e31;
  --red-dark: #682124;
  --red-soft: #f5e6e6;
  --serif: "Yu Mincho", "Hiragino Mincho ProN", "MS PMincho", Georgia, serif;
  --sans: "Yu Gothic", YuGothic, "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  font-family: var(--sans);
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse at 75% 20%, rgba(255, 252, 244, 0.72), transparent 65%),
    repeating-linear-gradient(0deg, rgba(115, 100, 73, 0.03) 0 1px, transparent 1px 4px);
}

h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--serif); }
p { line-height: 1.8; }

button, a, input, summary {
  touch-action: manipulation;
  font-family: inherit;
}
button, a, summary { cursor: pointer; }
button {
  color: inherit;
  border-radius: 0;
  font-weight: 700;
}
a {
  color: inherit;
  text-underline-offset: 0.25em;
}
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid #965619;
  outline-offset: 3px;
}
main { flex: 1; }
main:focus { outline: 0; }

.bar, main, footer {
  width: min(1120px, calc(100% - 7vw));
  margin-inline: auto;
}

/* Header */
.mast {
  border-bottom: 1px solid var(--line);
  background: rgba(238, 234, 222, 0.85);
}
.bar {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  letter-spacing: 0.08em;
  font: 700 1.15rem var(--serif);
}
.mark {
  display: grid;
  place-items: center;
  background: var(--red);
  color: var(--paper);
  width: 30px;
  height: 38px;
  clip-path: polygon(0 0, 100% 0, 100% 80%, 50% 100%, 0 80%);
  font: italic 1.5rem Georgia, serif;
  padding-bottom: 4px;
  flex-shrink: 0;
}
.bar nav {
  display: flex;
  align-items: center;
  gap: 1.4rem;
}
.navlink {
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--muted);
  padding: 6px 2px;
}
.navlink:hover {
  color: var(--red);
  text-decoration: underline;
}

/* Footer */
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem 1.2rem;
  border-top: 1px solid var(--line);
  padding: 1.1rem 0 1.6rem;
  color: var(--muted);
  font-size: 0.82rem;
}
footer a:hover { color: var(--red); }

/* Kicker */
.kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 700 0.78rem/1.4 Georgia, var(--serif);
  letter-spacing: 0.14em;
  color: var(--red);
  text-transform: uppercase;
}
.kicker::before {
  content: "";
  width: 28px;
  border-top: 1px solid currentColor;
}

/* Home (Centered Typography) */
.home-center {
  max-width: 720px;
}
.hero-sheet {
  padding: clamp(2rem, 5.5vw, 3.4rem);
}
.hero-title {
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: clamp(2.4rem, 5.4vw, 3.8rem);
  line-height: 1.2;
  margin: 0.9rem 0 1.15rem;
}
.hero-title span { display: block; }
.lead {
  color: #46463c;
  font-size: 1rem;
  line-height: 1.9;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem 1rem;
  margin-top: 1.7rem;
}
.btn-start {
  min-width: 240px;
  min-height: 56px;
  font-size: 1.08rem;
  letter-spacing: 0.06em;
}
.roster-count {
  margin-top: 1rem;
  font-size: 0.86rem;
  color: var(--muted);
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-share, .btn-copy {
  padding: 0.85rem 1.45rem;
  min-height: 50px;
  border: 1px solid var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.35;
  transition: background-color 0.14s ease, color 0.14s ease, transform 0.08s ease;
}
.btn-primary:active, .btn-secondary:active, .btn-choice:active, .btn-scale:active {
  transform: translateY(1px);
}
.btn-primary {
  background: var(--red);
  color: #fff9ec;
  border-color: var(--red);
}
.btn-primary:hover {
  background: var(--red-dark);
  border-color: var(--red-dark);
}
.btn-secondary {
  background: var(--paper-strong);
  color: var(--ink);
}
.btn-secondary:hover {
  background: #e4dfd0;
}
.btn-share {
  background: var(--ink);
  color: #fffdf7;
  border-color: var(--ink);
}
.btn-share:hover {
  background: #3d3e35;
}
.btn-copy {
  background: transparent;
  color: var(--ink);
}
.btn-copy:hover {
  background: #e4dfd0;
}
.bare {
  background: none;
  border: 0;
  padding: 6px 0;
  font-size: 0.88rem;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}
.bare:hover { color: var(--red); }

/* Creator Strip */
.creator-card {
  margin: 1.2rem 0 2.4rem;
  padding: 1rem 1.25rem;
  background: var(--paper);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.9rem 1.2rem;
}
.creator-info {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.creator-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.creator-name {
  font-weight: 700;
  font-size: 0.96rem;
}
.creator-desc {
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.45;
}
.creator-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}
.creator-btn {
  padding: 0.48rem 0.95rem;
  border: 1px solid var(--ink);
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: none;
  background: var(--paper-strong);
}
.creator-btn:hover { background: #e4dfd0; }

/* Play Workspace */
.work {
  max-width: 760px;
  margin: clamp(1.5rem, 4.5vh, 3.2rem) auto 2.5rem;
}

/* Progress Meter */
.progress-head {
  margin-bottom: 0.9rem;
}
.progress-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.45rem;
}
.q-num {
  font: 700 0.95rem var(--serif);
  letter-spacing: 0.08em;
  color: var(--ink);
}
.meter-label {
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 700;
}
.meter-label strong {
  color: var(--red);
  font-size: 0.96rem;
}
.meter-track {
  width: 100%;
  height: 7px;
  background: #d7d2c2;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  background: var(--red);
  transition: width 0.28s ease-out;
}
.mood-line {
  margin-top: 0.55rem;
  font-size: 0.88rem;
  color: var(--muted);
}

/* Paper Sheet */
.sheet {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: clamp(1.4rem, 4.2vw, 2.8rem);
  box-shadow: 3px 4px 0 #d9d4c4;
}
.sheet::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(195, 189, 172, 0.55);
  pointer-events: none;
}
.sheet-q {
  font-size: clamp(1.45rem, 3.3vw, 2.2rem);
  line-height: 1.5;
  margin-bottom: 0.45rem;
}
.sheet-hint {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

/* Binary (2-Choice) Answers */
.binary-answers {
  margin-top: 1.7rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}
.btn-bin {
  min-height: 70px;
  padding: 0.9rem 1rem;
  border: 1.5px solid var(--ink);
  background: var(--paper-strong);
  font-size: 1.25rem;
  letter-spacing: 0.08em;
  transition: background-color 0.14s ease, color 0.14s ease, transform 0.08s ease;
}
.btn-bin:active { transform: translateY(1px); }
.btn-bin.is-yes {
  background: var(--ink);
  color: var(--paper-strong);
}
.btn-bin.is-yes:hover { background: #3f4037; }
.btn-bin.is-no {
  border-color: var(--red);
  color: var(--red);
}
.btn-bin.is-no:hover {
  background: var(--red);
  color: #fff9ec;
}

/* Sheet Footer Links */
.play-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.9rem;
}

/* Guess & Result Card */
.reveal-typo {
  margin: 1rem 0 1.25rem;
  padding: 1.1rem 1.25rem;
  background: var(--paper-strong);
  border: 1px solid var(--line-soft);
}
.faction-tag {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 9px;
  border: 1px solid var(--line);
  color: var(--muted);
  margin-bottom: 0.45rem;
}
.faction-tag.hunter {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-soft);
}
.result-name {
  font-size: clamp(2.1rem, 5.4vw, 3.4rem);
  line-height: 1.18;
  color: var(--red);
}
.result-real {
  font-size: 0.92rem;
  color: var(--muted);
  margin-top: 0.3rem;
}
.ability-box {
  background: var(--paper-strong);
  border-left: 3px solid var(--red);
  padding: 0.8rem 1rem;
  font-size: 0.94rem;
  color: #3a3a31;
}
.lore-line {
  margin-top: 0.6rem;
  font-size: 0.86rem;
  color: var(--muted);
}
.divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.35rem 0;
}
.verdict-title {
  font-size: 1.25rem;
  margin-bottom: 0.85rem;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1rem;
}
.actions > * { flex: 1 1 200px; }

/* Miss Explanation & Trail Log */
.explain-box {
  margin-top: 0.85rem;
  padding: 0.8rem 1rem;
  background: var(--paper-strong);
  border: 1px solid var(--line-soft);
  font-size: 0.9rem;
  color: #3d3c34;
}
.trail-log {
  margin-top: 1.2rem;
  border-top: 1px solid var(--line-soft);
  padding-top: 0.9rem;
}
.trail-log summary {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
}
.trail-log ol {
  margin: 0.65rem 0 0;
  padding-left: 1.35rem;
  font-size: 0.86rem;
  line-height: 1.75;
  color: #424139;
}
.trail-log li strong { color: var(--red); }

/* Searchable Character Picker & Roster */
.picker-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0;
}
.search-input {
  flex: 1 1 220px;
  padding: 0.72rem 0.95rem;
  border: 1px solid var(--ink);
  background: var(--paper-strong);
  font-size: 0.95rem;
}
.tab-group {
  display: flex;
  border: 1px solid var(--ink);
}
.tab-btn {
  padding: 0.65rem 1rem;
  border: 0;
  background: var(--paper-strong);
  font-size: 0.86rem;
  color: var(--muted);
}
.tab-btn + .tab-btn { border-left: 1px solid var(--ink); }
.tab-btn.active {
  background: var(--ink);
  color: var(--paper-strong);
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 0.5rem;
  max-height: 390px;
  overflow-y: auto;
  padding: 2px;
}
.char-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.18rem;
  padding: 0.62rem 0.72rem;
  border: 1px solid var(--line);
  background: var(--paper-strong);
  text-align: left;
}
button.char-tile:hover {
  border-color: var(--red);
  background: var(--red-soft);
}
.char-tile-name {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.25;
}
.char-tile-real {
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.25;
}

/* Mobile Responsive */
@media (max-width: 720px) {
  .bar, main, footer {
    width: calc(100% - 28px);
  }
  .bar { height: 58px; gap: 0.5rem; }
  .brand { font-size: 0.92rem; gap: 0.45rem; letter-spacing: 0.03em; min-width: 0; }
  .brand span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mark { width: 24px; height: 30px; font-size: 1.2rem; }
  .bar nav { gap: 0.55rem; flex-shrink: 0; }
  .navlink { font-size: 0.76rem; white-space: nowrap; }
  .nav-yt { padding: 4px 8px; }

  .hero {
    grid-template-columns: 1fr;
    padding: 1.3rem 0 1rem;
    gap: 1rem;
  }
  .hero h1 { font-size: clamp(2.1rem, 9.2vw, 2.8rem); margin: 0.6rem 0 0.85rem; }
  .hero h1 span { display: block; }
  .lead { font-size: 0.93rem; }
  .hero-actions { margin-top: 1.1rem; gap: 0.6rem; }
  .hero-actions > * { flex: 1 1 100%; }

  .creator-card { padding: 0.9rem; }
  .creator-links { width: 100%; }
  .creator-btn { flex: 1; text-align: center; }

  .sheet { padding: 1.25rem 1.05rem; }
  .sheet-q { font-size: 1.32rem; }
  .choice-grid { grid-template-columns: 1fr; }
  .btn-choice { min-height: 54px; padding: 0.78rem 0.9rem; }
  .btn-scale { min-height: 54px; font-size: 1rem; }
  .btn-scale.is-soft { min-height: 46px; font-size: 0.82rem; padding: 0.5rem 0.3rem; }

  .reveal-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85rem;
  }
  .portrait-frame { width: 92px; height: 92px; }
  .result-name { font-size: 2rem; }
  .actions > * { flex: 1 1 100%; }
  .char-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: no-preference) {
  .sheet, .hero-copy {
    animation: reveal 0.2s ease-out;
  }
  @keyframes reveal {
    from { transform: translateY(4px); opacity: 0.8; }
    to { transform: none; opacity: 1; }
  }
}
