:root {
  --bg: #0b0b0c;
  --panel: #141416;
  --panel-2: #1a1a1d;
  --paper: #f3efe5;
  --ink: #121214;
  --muted: #9e9d97;
  --line: rgba(255, 255, 255, 0.14);
  --red: #ea2d24;
  --yellow: #e9ee43;
  --accent: #ea2d24;
  --accent-2: #ef86b5;
  --display: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  --sans: "Hiragino Kaku Gothic ProN", "Yu Gothic", "YuGothic", "Noto Sans JP", system-ui, sans-serif;
  color-scheme: dark;
  font-family: var(--sans);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 10% 15%, rgba(234, 45, 36, 0.1), transparent 24rem),
    radial-gradient(circle at 90% 80%, rgba(233, 238, 67, 0.045), transparent 28rem),
    var(--bg);
  color: var(--paper);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

img {
  display: block;
  max-width: 100%;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: 0.04;
  background:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.24) 3px 4px),
    repeating-linear-gradient(90deg, transparent 0 5px, rgba(255, 255, 255, 0.13) 5px 6px);
  mix-blend-mode: soft-light;
}

.app-shell {
  width: min(100%, 1440px);
  margin: 0 auto;
  padding:
    max(18px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--paper);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  background: var(--red);
  color: white;
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy b {
  font-family: var(--display);
  font-size: 1rem;
  letter-spacing: 0.14em;
}

.brand-copy small {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.api-state {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
}

.api-state span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c7c7c0;
  box-shadow: 0 0 0 4px rgba(199, 199, 192, 0.08);
}

.api-state.is-live {
  color: #dcf46a;
}

.api-state.is-live span {
  background: #dcf46a;
  box-shadow: 0 0 0 4px rgba(220, 244, 106, 0.12);
}

.view-switcher {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(100%, 520px);
  margin: 22px 0 34px auto;
  border: 1px solid var(--line);
  background: rgba(12, 12, 13, 0.78);
  backdrop-filter: blur(16px);
}

.view-tab {
  min-height: 50px;
  padding: 10px 18px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  transition: background 180ms ease, color 180ms ease;
}

.view-tab + .view-tab {
  border-left: 1px solid var(--line);
}

.view-tab span {
  margin-right: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  opacity: 0.65;
}

.view-tab.is-active {
  background: var(--paper);
  color: var(--ink);
}

.view {
  animation: view-in 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.view[hidden] {
  display: none !important;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.encounter-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.section-kicker {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.section-kicker span {
  margin-right: 12px;
  color: var(--red);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.encounter-heading h1,
.quiz-copy h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.85rem, 4vw, 4.7rem);
  font-weight: 500;
  line-height: 1.13;
  letter-spacing: 0.03em;
}

.encounter-heading h1 em {
  color: var(--accent);
  font-size: 1.12em;
  font-style: normal;
  font-weight: 900;
  transition: color 300ms ease;
}

.date-stamp {
  flex: none;
  margin: 0 0 8px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  writing-mode: vertical-rl;
}

.character-card {
  --accent: #ea2d24;
  --accent-2: #ef86b5;
  position: relative;
  display: grid;
  grid-template-columns: 64px minmax(330px, 0.94fr) minmax(420px, 1.06fr);
  min-height: 650px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.4);
  transition: background 300ms ease;
}

.character-card::after {
  position: absolute;
  right: -12px;
  bottom: -80px;
  color: rgba(255, 255, 255, 0.018);
  content: "物語";
  font-family: var(--display);
  font-size: 15rem;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}

.number-rail {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  flex-direction: column;
  padding: 24px 0 20px;
  background: var(--paper);
  color: var(--ink);
}

.number-rail span {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.05rem;
  font-weight: 900;
}

.number-rail i {
  width: 1px;
  flex: 1;
  margin: 16px 0;
  background: rgba(0, 0, 0, 0.24);
}

.number-rail b {
  font-size: 0.62rem;
  line-height: 1.25;
  letter-spacing: 0.14em;
  writing-mode: vertical-rl;
}

.portrait-stage {
  position: relative;
  isolation: isolate;
  min-width: 0;
  overflow: hidden;
  border: 0;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent) 88%, black), var(--accent-2));
  cursor: pointer;
}

.portrait-stage::before,
.portrait-stage::after {
  position: absolute;
  z-index: -1;
  content: "";
  pointer-events: none;
}

.portrait-stage::before {
  inset: 0;
  background:
    linear-gradient(120deg, transparent 0 44%, rgba(255, 255, 255, 0.22) 44% 45%, transparent 45% 100%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.065) 0 1px, transparent 1px 7px);
  mix-blend-mode: overlay;
}

.portrait-stage::after {
  right: -30%;
  bottom: -15%;
  width: 95%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  box-shadow:
    0 0 0 44px rgba(255, 255, 255, 0.035),
    0 0 0 94px rgba(255, 255, 255, 0.025);
}

.portrait-stage img {
  position: absolute;
  z-index: 1;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 35%;
  filter: saturate(1.12) contrast(1.06);
  transition:
    opacity 240ms ease,
    transform 520ms cubic-bezier(0.22, 1, 0.36, 1),
    filter 240ms ease;
}

.portrait-stage:hover img {
  transform: scale(1.025);
}

.portrait-stage:active img {
  transform: scale(0.99);
}

.portrait-kana {
  position: absolute;
  z-index: 2;
  top: 18px;
  left: 16px;
  color: rgba(255, 255, 255, 0.88);
  font-family: var(--display);
  font-size: clamp(2.3rem, 4vw, 4.7rem);
  font-weight: 900;
  letter-spacing: -0.08em;
  line-height: 1;
  mix-blend-mode: overlay;
  writing-mode: vertical-rl;
}

.portrait-index {
  position: absolute;
  z-index: 2;
  top: 20px;
  right: 18px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: white;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.tap-cue {
  position: absolute;
  z-index: 3;
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  background: rgba(9, 9, 10, 0.82);
  color: white;
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  backdrop-filter: blur(10px);
}

.tap-cue svg {
  width: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.character-content {
  position: relative;
  z-index: 1;
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: clamp(30px, 4vw, 62px);
}

.character-title {
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.character-title > p {
  margin: 0 0 12px;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.character-title h2 {
  margin: 0;
  color: var(--paper);
  font-family: var(--display);
  font-size: clamp(2.2rem, 4vw, 4.8rem);
  font-weight: 800;
  letter-spacing: 0.025em;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.roman-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 12px;
}

.roman-row > span:first-child {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.cv {
  flex: none;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
}

.cv b {
  color: var(--paper);
  font-size: 0.82rem;
}

.detail-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 28px 0 22px;
  border-bottom: 1px solid var(--line);
}

.detail-tab {
  position: relative;
  min-height: 42px;
  padding: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.detail-tab::after {
  position: absolute;
  right: 20%;
  bottom: -1px;
  left: 20%;
  height: 3px;
  background: var(--accent);
  content: "";
  opacity: 0;
  transform: scaleX(0.5);
  transition: 180ms ease;
}

.detail-tab.is-active {
  color: var(--paper);
}

.detail-tab.is-active::after {
  opacity: 1;
  transform: scaleX(1);
}

.detail-panel {
  display: none;
  min-height: 154px;
  animation: panel-in 260ms ease both;
}

.detail-panel.is-active {
  display: block;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.profile-panel .lead {
  margin: 0;
  color: #dedbd2;
  font-family: var(--display);
  font-size: 1rem;
  line-height: 1.95;
}

.trait-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 18px;
}

.trait-list span {
  padding: 6px 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--line));
  color: color-mix(in srgb, var(--accent) 64%, white);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.quote-panel {
  position: relative;
  padding-left: 34px;
}

.quote-mark {
  position: absolute;
  top: -12px;
  left: 0;
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 4.4rem;
  line-height: 1;
}

.quote-panel blockquote {
  margin: 0;
  color: var(--paper);
  font-family: var(--display);
  font-size: clamp(1.28rem, 2.2vw, 2rem);
  font-weight: 700;
  line-height: 1.6;
}

.quote-panel p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.7;
}

.scene-panel > div {
  display: grid;
  gap: 11px;
}

.scene-entry {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 12px;
}

.scene-entry > span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  background: var(--accent);
  color: white;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.64rem;
  font-weight: 900;
}

.scene-entry b {
  display: block;
  margin-bottom: 3px;
  color: var(--paper);
  font-size: 0.82rem;
}

.scene-entry p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.65;
}

.spoiler-note {
  margin: 12px 0 0;
  color: #74746f;
  font-size: 0.68rem;
}

.primary-actions {
  margin-top: auto;
  padding-top: 26px;
}

.shuffle-button,
.start-button {
  display: flex;
  width: 100%;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border: 0;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0.05em;
  box-shadow: 0 16px 32px color-mix(in srgb, var(--accent) 22%, transparent);
  transition: transform 140ms ease, filter 140ms ease;
}

.shuffle-button:hover,
.start-button:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
}

.shuffle-button:active,
.start-button:active {
  transform: translateY(0) scale(0.99);
}

.shuffle-button .button-index {
  color: rgba(255, 255, 255, 0.72);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.64rem;
  letter-spacing: 0.12em;
}

.shuffle-button svg,
.start-button svg {
  width: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: square;
  stroke-width: 1.8;
}

.sub-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 9px;
}

.sub-actions button,
.outline-button {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.sub-actions button:hover,
.outline-button:hover {
  border-color: rgba(255, 255, 255, 0.38);
  color: var(--paper);
}

.sub-actions svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.shuffle-count {
  margin: 12px 2px 0;
  color: #777771;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-align: right;
}

.shuffle-count span {
  color: var(--paper);
}

.character-card.is-switching .portrait-stage img {
  opacity: 0;
  filter: saturate(0) contrast(1.8);
  transform: scale(1.08);
}

.character-card.is-switching .character-content {
  opacity: 0.72;
}

/* Quiz */
.quiz-shell {
  min-height: 660px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.38);
}

.quiz-intro {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(440px, 1.2fr);
  min-height: 660px;
}

.quiz-art {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  overflow: hidden;
  background:
    linear-gradient(120deg, rgba(0, 0, 0, 0.1), transparent 60%),
    var(--red);
}

.quiz-art::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(135deg, transparent 0 45%, rgba(255, 255, 255, 0.22) 45% 45.5%, transparent 45.5%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 8px);
  content: "";
}

.quiz-art > span {
  color: white;
  font-family: var(--display);
  font-size: clamp(6rem, 14vw, 12rem);
  font-weight: 900;
  letter-spacing: -0.12em;
  line-height: 1;
}

.quiz-art i {
  position: absolute;
  width: 70%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  box-shadow: 0 0 0 44px rgba(255, 255, 255, 0.06);
}

.quiz-art b {
  position: absolute;
  right: 22px;
  bottom: 20px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  line-height: 1.5;
  text-align: right;
}

.quiz-copy {
  display: flex;
  justify-content: center;
  flex-direction: column;
  padding: clamp(34px, 6vw, 88px);
}

.quiz-copy > p:not(.section-kicker) {
  max-width: 620px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.9;
}

.quiz-copy ul {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 30px 0;
  padding: 0;
  background: var(--line);
  list-style: none;
}

.quiz-copy li {
  display: grid;
  gap: 5px;
  padding: 14px;
  background: var(--panel);
  text-align: center;
}

.quiz-copy li b {
  font-family: var(--display);
  font-size: 1.7rem;
}

.quiz-copy li span {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
}

.quiz-copy .start-button {
  max-width: 420px;
  background: var(--red);
}

.quiz-question {
  width: min(100%, 840px);
  margin: 0 auto;
  padding: clamp(28px, 6vw, 80px);
}

.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.progress-row button {
  padding: 5px 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.7rem;
}

.progress-track {
  height: 4px;
  margin-top: 12px;
  overflow: hidden;
  background: #2c2c2e;
}

.progress-track i {
  display: block;
  width: 14.28%;
  height: 100%;
  background: var(--red);
  transition: width 320ms ease;
}

.question-number {
  margin: 42px 0 4px;
  color: var(--red);
  font-family: var(--display);
  font-size: 4.8rem;
  font-weight: 900;
  line-height: 1;
  opacity: 0.95;
}

.quiz-question h2 {
  margin: 0 0 30px;
  font-family: var(--display);
  font-size: clamp(1.65rem, 3.5vw, 2.8rem);
  line-height: 1.45;
}

.answer-list {
  display: grid;
  gap: 9px;
}

.answer-button {
  display: grid;
  grid-template-columns: 42px 1fr 24px;
  min-height: 64px;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: #18181a;
  color: var(--paper);
  cursor: pointer;
  text-align: left;
  transition: border 160ms ease, background 160ms ease, transform 160ms ease;
}

.answer-button:hover {
  border-color: var(--red);
  background: #202023;
  transform: translateX(4px);
}

.answer-button > span:first-child {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 900;
}

.answer-button b {
  font-size: 0.88rem;
  line-height: 1.5;
}

.answer-button svg {
  width: 19px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.6;
}

.answer-hint {
  margin: 18px 0 0;
  color: #6f6e69;
  font-size: 0.72rem;
  text-align: center;
}

.quiz-result {
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(440px, 1.18fr);
  min-height: 660px;
}

.result-visual {
  position: relative;
  isolation: isolate;
  min-height: 660px;
  overflow: hidden;
  background: var(--result-accent, var(--red));
}

.result-visual::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(to top, rgba(8, 8, 9, 0.84), transparent 55%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 7px);
  content: "";
}

.result-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 35%;
  filter: saturate(1.1) contrast(1.05);
}

.result-score {
  position: absolute;
  right: 18px;
  bottom: 20px;
  display: grid;
  place-items: end;
}

.result-score > span {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.15em;
}

.result-score strong {
  font-family: var(--display);
  font-size: 2.5rem;
  line-height: 1;
}

.result-score b {
  font-size: 5rem;
}

.result-kana {
  position: absolute;
  top: 16px;
  left: 14px;
  color: rgba(255, 255, 255, 0.62);
  font-family: var(--display);
  font-size: 3.4rem;
  font-weight: 900;
  line-height: 1;
  writing-mode: vertical-rl;
}

.result-copy {
  display: flex;
  justify-content: center;
  flex-direction: column;
  padding: clamp(32px, 5vw, 72px);
}

.result-copy h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.5rem, 5vw, 5.5rem);
  line-height: 1.1;
}

.result-type {
  margin: 12px 0 0;
  color: var(--result-accent, var(--red));
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.result-summary {
  margin: 24px 0;
  color: #d2cfc7;
  font-family: var(--display);
  font-size: 1rem;
  line-height: 1.9;
}

.chemistry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
}

.chemistry-grid > div {
  padding: 16px;
  background: var(--panel);
}

.chemistry-grid span {
  color: var(--result-accent, var(--red));
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.09em;
}

.chemistry-grid p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.7;
}

.result-actions {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 8px;
  margin-top: 26px;
}

.result-actions .start-button {
  min-height: 52px;
  justify-content: center;
  background: var(--result-accent, var(--red));
}

footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 30px;
  margin-top: 60px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  color: #73736e;
  font-size: 0.7rem;
  line-height: 1.8;
}

.footer-brand {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.08em;
}

.footer-brand span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  background: var(--red);
  color: white;
  font-family: var(--display);
  font-size: 0.9rem;
}

footer details {
  width: min(100%, 640px);
}

footer summary {
  width: fit-content;
  margin-left: auto;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

footer p {
  margin: 12px 0 0;
}

footer a {
  color: #adada6;
}

.toast {
  position: fixed;
  z-index: 30;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  max-width: calc(100vw - 36px);
  padding: 12px 16px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 200ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: none;
}

@media (max-width: 1000px) {
  .character-card {
    grid-template-columns: 52px minmax(300px, 0.85fr) minmax(380px, 1.15fr);
  }

  .character-content {
    padding: 32px;
  }
}

@media (max-width: 800px) {
  .app-shell {
    padding-right: max(14px, env(safe-area-inset-right));
    padding-left: max(14px, env(safe-area-inset-left));
  }

  .view-switcher {
    position: sticky;
    z-index: 10;
    top: max(8px, env(safe-area-inset-top));
    width: 100%;
    margin: 16px 0 28px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  }

  .encounter-heading {
    align-items: flex-start;
  }

  .date-stamp {
    font-size: 0.63rem;
  }

  .character-card {
    display: block;
    min-height: 0;
  }

  .number-rail {
    position: absolute;
    z-index: 5;
    top: 0;
    left: 0;
    width: 46px;
    height: clamp(380px, 62vh, 590px);
    background: rgba(243, 239, 229, 0.94);
    backdrop-filter: blur(10px);
  }

  .portrait-stage {
    display: block;
    width: 100%;
    height: clamp(380px, 62vh, 590px);
  }

  .portrait-stage img {
    object-position: center 28%;
  }

  .portrait-kana {
    left: 58px;
  }

  .character-content {
    min-height: 590px;
    padding: 30px 22px 24px;
  }

  .character-title h2 {
    font-size: clamp(2rem, 11vw, 3.6rem);
  }

  .roman-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .detail-panel {
    min-height: 184px;
  }

  .quiz-intro,
  .quiz-result {
    display: block;
    min-height: 0;
  }

  .quiz-art {
    min-height: 340px;
  }

  .quiz-copy {
    padding: 34px 22px 28px;
  }

  .quiz-copy h1 {
    font-size: clamp(2rem, 10vw, 3.4rem);
  }

  .quiz-question {
    min-height: 620px;
    padding: 28px 20px;
  }

  .result-visual {
    min-height: 470px;
    height: 58vh;
    max-height: 620px;
  }

  .result-copy {
    padding: 34px 22px 28px;
  }

  footer {
    align-items: stretch;
    flex-direction: column;
  }

  footer summary {
    margin-left: 0;
  }
}

@media (max-width: 480px) {
  .site-header {
    min-height: 52px;
  }

  .brand-copy small {
    display: none;
  }

  .api-state b {
    max-width: 82px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .encounter-heading h1 {
    font-size: 1.65rem;
  }

  .character-content {
    padding-right: 18px;
    padding-left: 18px;
  }

  .profile-panel .lead {
    font-size: 0.94rem;
  }

  .sub-actions {
    grid-template-columns: 1fr 1fr;
  }

  .quiz-copy ul {
    margin: 24px 0;
  }

  .quiz-copy li {
    padding: 12px 5px;
  }

  .chemistry-grid,
  .result-actions {
    grid-template-columns: 1fr;
  }

  .question-number {
    margin-top: 32px;
    font-size: 4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
