:root {
  --paper: #f4ecdc;
  --paper-raised: #fbf6ea;
  --paper-deep: #e8dcc6;
  --ink: #25241f;
  --ink-soft: #625e53;
  --ink-faint: #8e887c;
  --cinnabar: #a33c2d;
  --cinnabar-dark: #77271e;
  --jade: #446d5d;
  --jade-soft: #dce8df;
  --brass: #a88754;
  --line: rgba(76, 67, 52, 0.16);
  --line-strong: rgba(76, 67, 52, 0.28);
  --danger: #a33c2d;
  --danger-soft: #f3ddd7;
  --success: #3f6b58;
  --success-soft: #dfebe3;
  --shadow-frame: 0 28px 80px rgba(57, 45, 27, 0.2);
  --shadow-card: 0 12px 30px rgba(72, 55, 31, 0.08);
  --radius-frame: 38px;
  --radius-card: 24px;
  --radius-control: 16px;
  --font-display: "Songti SC", "STSong", "Noto Serif SC", Georgia, serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --radius-small: 12px;
  --radius-medium: 18px;
  --radius-large: 26px;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 14% 12%, rgba(255, 250, 238, 0.9), transparent 27%),
    radial-gradient(circle at 88% 86%, rgba(68, 109, 93, 0.12), transparent 30%),
    #d9cdb9;
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.ambient-mark {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.ambient-mark::before,
.ambient-mark::after {
  position: absolute;
  content: "";
  width: 36vmin;
  height: 36vmin;
  border: 1px solid rgba(113, 91, 58, 0.12);
  border-radius: 50%;
}

.ambient-mark::before {
  top: -16vmin;
  right: -8vmin;
}

.ambient-mark::after {
  bottom: -20vmin;
  left: -10vmin;
}

.app-frame {
  position: relative;
  width: min(100vw, 390px);
  height: min(100dvh, 844px);
  overflow: hidden;
  border: 1px solid rgba(70, 58, 40, 0.16);
  border-radius: var(--radius-frame);
  background:
    linear-gradient(rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0)),
    var(--paper);
  box-shadow: var(--shadow-frame);
  isolation: isolate;
}

.app-frame::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(75, 64, 47, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(75, 64, 47, 0.02) 1px, transparent 1px);
  background-size: 24px 24px;
  content: "";
  mask-image: linear-gradient(to bottom, black, transparent 88%);
}

.view {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  padding:
    max(24px, env(safe-area-inset-top))
    22px
    max(22px, env(safe-area-inset-bottom));
}

.view.is-active {
  display: flex;
  flex-direction: column;
  animation: view-in 240ms var(--ease);
}

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

#boot-view {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.boot-mark,
.brand-seal {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 50%;
  background: var(--cinnabar);
  color: #fff8ed;
  font-family: var(--font-display);
  font-size: 27px;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.boot-mark {
  margin-bottom: 20px;
}

.loading-line {
  width: 88px;
  height: 2px;
  margin-top: 18px;
  overflow: hidden;
  background: rgba(37, 36, 31, 0.1);
}

.loading-line span {
  display: block;
  width: 44%;
  height: 100%;
  background: var(--cinnabar);
  animation: load-line 1.1s ease-in-out infinite alternate;
}

@keyframes load-line {
  from {
    transform: translateX(-80%);
  }
  to {
    transform: translateX(210%);
  }
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--cinnabar);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.035em;
}

h1 {
  margin-bottom: 0;
  font-size: 38px;
  line-height: 1.14;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.26;
}

.auth-view {
  justify-content: space-between;
}

.brand-lockup {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-top: 30px;
}

.brand-lockup.compact {
  align-items: center;
  margin-top: 0;
}

.brand-lockup.compact h1 {
  font-size: 30px;
}

.lead {
  max-width: 310px;
  margin: 0;
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 19px;
  line-height: 1.7;
}

.code-card,
.name-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: rgba(251, 246, 234, 0.84);
  box-shadow: var(--shadow-card);
}

.code-card label,
.name-card label {
  display: block;
  margin-bottom: 10px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  outline: none;
  background: rgba(255, 252, 245, 0.8);
  color: var(--ink);
  font-size: 16px;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}

input::placeholder {
  color: #a39a8a;
}

input:focus {
  border-color: var(--cinnabar);
  box-shadow: 0 0 0 3px rgba(163, 60, 45, 0.12);
}

.field-message {
  min-height: 18px;
  margin: 8px 2px 0;
  color: var(--danger);
  font-size: 12px;
}

.fine-print {
  margin: 0;
  color: var(--ink-faint);
  font-size: 11px;
  line-height: 1.65;
}

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  cursor: pointer;
  font-weight: 700;
  transition:
    transform 150ms ease,
    background-color 150ms ease,
    border-color 150ms ease;
}

.button:active {
  transform: scale(0.985);
}

.button:focus-visible,
.icon-button:focus-visible,
.text-button:focus-visible,
.choice-button:focus-visible,
.identity-button:focus-visible {
  outline: 3px solid rgba(163, 60, 45, 0.25);
  outline-offset: 3px;
}

.button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.button-primary {
  background: var(--ink);
  color: #fffaf0;
}

.button-secondary {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--ink);
}

.button-danger {
  background: var(--cinnabar-dark);
  color: #fff8ed;
}

.button-large {
  width: 100%;
  min-height: 52px;
  font-size: 15px;
}

.text-button {
  align-self: center;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 13px;
}

.cover-view {
  gap: 14px;
}

.cover-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding-top: 6px;
}

.cover-episode-mark {
  display: flex;
  width: 56px;
  height: 64px;
  align-items: baseline;
  justify-content: center;
  padding-top: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 28px 28px 12px 12px;
  color: var(--jade);
}

.cover-episode-mark span {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
}

.cover-episode-mark small {
  margin-left: 1px;
  font-size: 10px;
}

.cover-card {
  margin: 22px 0 8px;
  padding: 26px 24px;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.cover-question {
  margin-bottom: 18px;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.04em;
}

.cover-card > p:not(.cover-question) {
  margin-bottom: 20px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.75;
}

.cover-rule {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.cover-rule span {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 11px;
}

#continue-button {
  flex-direction: column;
  min-height: 58px;
}

#continue-button small {
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 500;
}

.view-header {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: start;
  gap: 12px;
}

.view-header h2 {
  font-size: 25px;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 252, 245, 0.56);
  color: var(--ink);
  cursor: pointer;
  font-size: 27px;
  line-height: 1;
}

.header-count {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--cinnabar);
  font-family: var(--font-display);
  font-weight: 700;
}

.section-intro {
  margin: 14px 0 14px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
}

.identity-view {
  padding-bottom: 0;
}

.identity-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 -2px;
  padding: 2px 2px max(20px, env(safe-area-inset-bottom));
  overflow-y: auto;
  scrollbar-width: none;
}

.identity-list::-webkit-scrollbar {
  display: none;
}

.identity-button {
  position: relative;
  min-height: 148px;
  padding: 16px 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(251, 246, 234, 0.74);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition:
    transform 160ms var(--ease),
    border-color 160ms ease,
    background 160ms ease;
}

.identity-button::after {
  position: absolute;
  right: -8px;
  bottom: -18px;
  color: rgba(163, 60, 45, 0.075);
  content: "命";
  font-family: var(--font-display);
  font-size: 72px;
  font-weight: 700;
}

.identity-button:hover {
  border-color: rgba(163, 60, 45, 0.32);
  background: rgba(255, 250, 240, 0.94);
  transform: translateY(-2px);
}

.identity-index {
  display: block;
  margin-bottom: 11px;
  color: var(--cinnabar);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
}

.identity-button h3 {
  margin: 0 0 5px;
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.2;
}

.identity-button p {
  position: relative;
  z-index: 1;
  margin: 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.5;
}

.name-view {
  gap: 16px;
}

.selected-identity {
  margin-top: 18px;
}

.selected-identity-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--paper-raised);
  box-shadow: var(--shadow-card);
}

.selected-identity-card h3 {
  margin-bottom: 6px;
  font-family: var(--font-display);
  font-size: 26px;
}

.selected-identity-card p {
  margin-bottom: 10px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.6;
}

.ability-line {
  padding-top: 11px;
  border-top: 1px solid var(--line);
  color: var(--jade) !important;
  font-size: 12px !important;
  font-weight: 650;
}

.name-card {
  display: grid;
  gap: 14px;
}

.game-view {
  padding-top: max(18px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.game-identity p {
  margin-bottom: 2px;
}

.game-player {
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
}

.episode-seal {
  display: flex;
  width: 62px;
  height: 62px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(163, 60, 45, 0.48);
  border-radius: 50%;
  background: rgba(163, 60, 45, 0.045);
  color: var(--cinnabar);
}

.episode-seal span {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 700;
  line-height: 1;
}

.episode-seal small {
  margin-top: 3px;
  font-size: 9px;
  letter-spacing: 0.1em;
}

.chapter-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 15px 0 9px;
  color: var(--ink-soft);
  font-size: 11px;
}

.chapter-line span:first-child {
  color: var(--ink);
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.stat-item {
  min-width: 0;
  padding: 9px 7px 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 252, 245, 0.54);
}

.stat-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 3px;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 9px;
}

.stat-label strong {
  color: var(--ink);
  font-size: 12px;
}

.stat-meter {
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(37, 36, 31, 0.1);
}

.stat-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--jade);
  transition: width 260ms var(--ease);
}

.stat-item[data-risk="true"] .stat-meter span {
  background: var(--cinnabar);
}

.stat-item[data-warning="true"] {
  border-color: rgba(163, 60, 45, 0.34);
  background: rgba(163, 60, 45, 0.055);
}

.event-card {
  min-height: 0;
  padding: 18px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: rgba(251, 246, 234, 0.88);
  box-shadow: var(--shadow-card);
  scrollbar-width: none;
}

.event-card::-webkit-scrollbar {
  display: none;
}

.event-heading {
  margin-bottom: 13px;
}

.scene-chip {
  display: inline-block;
  margin-bottom: 7px;
  color: var(--cinnabar);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.event-heading h2 {
  font-size: 24px;
}

.event-text {
  margin-bottom: 15px;
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.72;
}

.choice-list {
  display: grid;
  gap: 8px;
}

.choice-button {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-height: 60px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.72);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition:
    border-color 150ms ease,
    transform 150ms ease,
    background 150ms ease;
}

.choice-button:hover {
  border-color: rgba(163, 60, 45, 0.35);
  background: rgba(255, 252, 244, 0.98);
  transform: translateX(2px);
}

.choice-index {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--cinnabar);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
}

.choice-copy strong,
.choice-copy span {
  display: block;
}

.choice-copy strong {
  margin-bottom: 3px;
  font-size: 13px;
  line-height: 1.35;
}

.choice-copy span {
  color: var(--ink-faint);
  font-size: 10px;
  line-height: 1.35;
}

.inventory-row {
  display: flex;
  gap: 5px;
  margin-top: 9px;
  overflow: hidden;
}

.inventory-chip {
  max-width: 130px;
  padding: 5px 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-faint);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.consequence-view {
  gap: 14px;
}

.consequence-header {
  grid-template-columns: minmax(0, 1fr) auto;
}

.tone-mark {
  align-self: start;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
}

.consequence-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--paper-raised);
  box-shadow: var(--shadow-card);
}

.consequence-card > p {
  margin-bottom: 18px;
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.72;
}

.effect-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.effect-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink-soft);
  font-size: 10px;
}

.effect-item strong {
  color: var(--ink);
  font-size: 12px;
}

.effect-item[data-direction="down"] strong {
  color: var(--danger);
}

.effect-item[data-direction="up"] strong {
  color: var(--success);
}

.relationship-details {
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 252, 245, 0.5);
  color: var(--ink-soft);
  font-size: 11px;
}

.relationship-details summary {
  cursor: pointer;
  font-weight: 700;
}

#relationship-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.relationship-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

#consequence-next {
  margin-top: auto;
}

.result-view {
  padding: 0;
}

.result-scroll {
  height: 100%;
  padding:
    max(26px, env(safe-area-inset-top))
    22px
    max(24px, env(safe-area-inset-bottom));
  overflow-y: auto;
  scrollbar-width: none;
}

.result-scroll::-webkit-scrollbar {
  display: none;
}

.result-header {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-strong);
}

.result-header h1 {
  margin-bottom: 10px;
  font-size: 31px;
}

.result-ending {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.65;
}

.grade-seal {
  display: grid;
  width: 150px;
  height: 150px;
  margin: 22px auto;
  place-items: center;
  border: 1px solid rgba(163, 60, 45, 0.38);
  border-radius: 50%;
  background: rgba(163, 60, 45, 0.045);
  color: var(--cinnabar);
  text-align: center;
}

.grade-seal strong {
  margin-top: 19px;
  font-family: var(--font-display);
  font-size: 54px;
  line-height: 0.8;
}

.grade-seal span {
  margin-top: -2px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
}

.grade-seal small {
  margin-top: -15px;
  color: var(--ink-faint);
  font-size: 9px;
}

.result-card-panel,
.score-panel,
.result-advice {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(251, 246, 234, 0.7);
}

.result-card-panel {
  display: grid;
  gap: 12px;
}

.result-fact {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
}

.result-fact span {
  color: var(--ink-faint);
  font-size: 10px;
}

.result-fact strong {
  font-size: 12px;
  line-height: 1.5;
}

.score-panel {
  margin-top: 10px;
}

.score-panel h2 {
  margin-bottom: 12px;
  font-size: 17px;
}

#score-breakdown {
  display: grid;
  gap: 8px;
}

.score-line {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 34px;
  gap: 8px;
  align-items: center;
  color: var(--ink-soft);
  font-size: 10px;
}

.score-line-track {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(37, 36, 31, 0.09);
}

.score-line-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--jade);
}

.score-line strong {
  color: var(--ink);
  font-size: 10px;
  text-align: right;
}

.result-advice {
  margin-top: 10px;
}

.result-advice p:last-child {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
}

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

.toast {
  position: absolute;
  right: 22px;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 22px;
  z-index: 20;
  padding: 11px 14px;
  border-radius: 13px;
  background: rgba(37, 36, 31, 0.92);
  color: #fffaf0;
  font-size: 11px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.app-dialog {
  width: min(calc(100vw - 40px), 346px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: var(--paper-raised);
  color: var(--ink);
  box-shadow: var(--shadow-frame);
}

.app-dialog::backdrop {
  background: rgba(33, 29, 22, 0.36);
  backdrop-filter: blur(3px);
}

.app-dialog form {
  padding: 22px;
}

.app-dialog h2 {
  margin-bottom: 13px;
  font-size: 23px;
}

.dialog-copy {
  margin-bottom: 18px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.7;
}

.dialog-copy p {
  margin-bottom: 10px;
}

.dialog-copy strong {
  color: var(--ink);
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* 2026-11-21 page refinement: palace ledger rather than generic card stack. */
.view {
  padding:
    max(22px, env(safe-area-inset-top))
    20px
    max(20px, env(safe-area-inset-bottom));
}

.cover-structure {
  position: absolute;
  inset: 74px 20px 196px;
  z-index: -1;
  display: grid;
  grid-template-columns: 1fr 1.35fr 1fr;
  gap: 14px;
  opacity: 0.38;
  pointer-events: none;
}

.cover-structure span {
  border-inline: 1px solid rgba(76, 67, 52, 0.15);
  clip-path: polygon(0 8%, 50% 0, 100% 8%, 100% 100%, 0 100%);
}

.cover-structure span:nth-child(2) {
  border-top: 1px solid rgba(76, 67, 52, 0.15);
}

.cover-header {
  position: relative;
  z-index: 1;
}

.cover-episode-mark {
  width: 62px;
  height: 72px;
  padding-top: 19px;
  background: rgba(251, 246, 234, 0.54);
}

.cover-card {
  position: relative;
  margin: 16px 0 6px;
  padding: 18px 0 18px;
  border-top-color: var(--line);
  border-bottom: 0;
  background: transparent;
}

.cover-question {
  max-width: 330px;
  margin-bottom: 14px;
  font-size: 39px;
  letter-spacing: -0.055em;
}

.cover-card > p:not(.cover-question) {
  max-width: 315px;
  margin-bottom: 0;
  font-size: 13px;
  line-height: 1.7;
}

.cover-ledger {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 18px;
  border-block: 1px solid var(--line);
}

.cover-ledger div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
  padding: 13px 8px 12px;
  border-right: 1px solid var(--line);
}

.cover-ledger div:first-child {
  padding-left: 0;
}

.cover-ledger div:last-child {
  border-right: 0;
}

.cover-ledger strong {
  color: var(--cinnabar);
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.cover-ledger small {
  color: var(--ink-faint);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.cover-view > .button,
.cover-view > .text-button {
  position: relative;
  z-index: 1;
}

.auth-watermark {
  position: absolute;
  inset: 15% -30px auto auto;
  display: flex;
  gap: 6px;
  color: rgba(163, 60, 45, 0.035);
  font-family: var(--font-display);
  font-size: 126px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
  writing-mode: vertical-rl;
}

.auth-view .brand-lockup {
  position: relative;
  z-index: 1;
  margin-top: 38px;
}

.auth-view h1 {
  font-size: 42px;
}

.lead {
  position: relative;
  z-index: 1;
  max-width: 300px;
  font-size: 18px;
}

.code-card {
  position: relative;
  z-index: 1;
  padding: 18px;
  border-color: var(--line-strong);
  box-shadow: none;
}

.identity-list {
  gap: 8px;
}

.identity-button {
  display: grid;
  min-height: 132px;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-content: start;
  padding: 14px 12px;
  border-radius: var(--radius-medium);
  background: rgba(251, 246, 234, 0.62);
}

.identity-button::after {
  right: -5px;
  bottom: -13px;
  font-size: 58px;
}

.identity-button:hover {
  transform: translateY(-1px);
}

.identity-sigil {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(163, 60, 45, 0.3);
  border-radius: 50%;
  color: var(--cinnabar);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
}

.identity-copy {
  position: relative;
  z-index: 1;
  display: block;
  min-width: 0;
}

.identity-copy small {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-faint);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.identity-copy h3 {
  margin: 0 0 7px;
  font-size: 16px;
  line-height: 1.22;
}

.identity-copy p {
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 12px;
  line-height: 1.45;
}

.selected-identity-card {
  position: relative;
  padding: 22px 20px 20px 24px;
  overflow: hidden;
  border-color: var(--line-strong);
  box-shadow: none;
}

.selected-identity-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--cinnabar);
  content: "";
}

.selected-identity-card h3 {
  font-size: 29px;
}

.game-top {
  padding-bottom: 3px;
}

.episode-seal {
  width: 58px;
  height: 58px;
  border-color: var(--cinnabar);
  background: var(--cinnabar);
  color: #fff8ed;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.12);
}

.chapter-line {
  margin: 13px 0 7px;
}

.chapter-track {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 10px;
}

.chapter-step {
  position: relative;
  display: grid;
  flex: 1;
  min-width: 0;
  place-items: center;
}

.chapter-step:not(:last-child)::after {
  position: absolute;
  top: 50%;
  left: calc(50% + 7px);
  width: calc(100% - 7px);
  height: 1px;
  background: var(--line);
  content: "";
}

.chapter-step i {
  position: relative;
  z-index: 1;
  display: grid;
  width: 14px;
  height: 14px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink-faint);
  font-size: 7px;
  font-style: normal;
}

.chapter-step[data-state="done"] i {
  border-color: var(--jade);
  background: var(--jade);
  color: var(--paper-raised);
}

.chapter-step[data-state="current"] i {
  width: 19px;
  height: 19px;
  border-color: var(--cinnabar);
  background: var(--cinnabar);
  color: #fff8ed;
  box-shadow: 0 0 0 4px rgba(163, 60, 45, 0.09);
}

.stats-grid {
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 252, 245, 0.38);
}

.stat-item {
  padding: 7px 6px 7px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.stat-item:last-child {
  border-right: 0;
}

.stat-item[data-warning="true"] {
  border-color: var(--line);
  background: transparent;
}

.stat-item[data-warning="true"] .stat-label strong {
  color: var(--danger);
}

.event-card {
  flex: 1;
  margin-top: 10px;
  padding: 17px 16px 15px;
  border-color: var(--line-strong);
  border-radius: 22px;
  background: rgba(251, 246, 234, 0.9);
  box-shadow: none;
}

.event-heading {
  margin-bottom: 11px;
}

.scene-chip {
  margin-bottom: 5px;
  font-size: 9px;
}

.event-heading h2 {
  font-size: 23px;
  line-height: 1.22;
}

.event-text {
  margin-bottom: 13px;
  font-size: 15px;
  line-height: 1.68;
}

.choice-list {
  gap: 7px;
}

.choice-button {
  min-height: 57px;
  padding: 10px 11px;
  border-radius: 14px;
}

.choice-button[data-tone="danger"] {
  background: rgba(163, 60, 45, 0.035);
}

.choice-button[data-tone="gain"] {
  background: rgba(68, 109, 93, 0.035);
}

.choice-index {
  border-color: var(--line-strong);
}

.choice-button[data-tone="danger"] .choice-index {
  border-color: rgba(163, 60, 45, 0.42);
  color: var(--danger);
}

.choice-button[data-tone="gain"] .choice-index {
  border-color: rgba(68, 109, 93, 0.4);
  color: var(--jade);
}

.inventory-row {
  min-height: 22px;
}

.inventory-chip {
  background: rgba(255, 252, 245, 0.42);
}

.consequence-card {
  border-color: var(--line-strong);
  box-shadow: none;
}

.change-ledger {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.ledger-caption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.ledger-caption span {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
}

.ledger-caption small {
  color: var(--ink-faint);
  font-size: 9px;
}

.effect-list {
  gap: 6px;
}

.effect-item {
  padding: 8px 9px;
  border-radius: 10px;
  background: rgba(255, 252, 245, 0.38);
}

.relationship-details {
  border-radius: 13px;
  background: rgba(255, 252, 245, 0.44);
}

.result-scroll {
  padding:
    max(18px, env(safe-area-inset-top))
    18px
    max(20px, env(safe-area-inset-bottom));
}

.result-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 10px;
  align-items: center;
  padding: 2px 0 18px;
  border-bottom: 1px solid var(--line-strong);
}

.result-hero .result-header {
  padding: 0;
  border: 0;
}

.result-hero .result-header h1 {
  font-size: 29px;
  line-height: 1.2;
}

.result-hero .result-ending {
  max-height: 92px;
  overflow: hidden;
}

.grade-seal {
  width: 118px;
  height: 118px;
  margin: 0;
  border-color: rgba(163, 60, 45, 0.5);
  background: rgba(163, 60, 45, 0.055);
}

.grade-seal strong {
  margin-top: 13px;
  font-size: 43px;
}

.grade-seal span {
  font-size: 12px;
}

.grade-seal small {
  margin-top: -10px;
  font-size: 8px;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.result-stat {
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 252, 245, 0.44);
}

.result-stat span,
.result-stat strong {
  display: block;
}

.result-stat span {
  margin-bottom: 3px;
  color: var(--ink-faint);
  font-size: 8px;
}

.result-stat strong {
  font-family: var(--font-display);
  font-size: 19px;
}

.result-stat[data-risk="true"] strong {
  color: var(--danger);
}

.result-card-panel,
.score-panel,
.result-advice {
  border-radius: 16px;
  background: rgba(251, 246, 234, 0.62);
}

.result-card-panel {
  margin-top: 10px;
  padding: 15px;
}

.result-actions {
  position: sticky;
  bottom: 0;
  padding: 10px 0 max(2px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 76%, transparent);
}

.app-dialog {
  box-shadow: 0 20px 60px rgba(57, 45, 27, 0.26);
}

@media (max-width: 430px) {
  .app-frame {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (max-width: 350px) {
  .view {
    padding-inline: 16px;
  }

  .cover-question {
    font-size: 35px;
  }

  .identity-button {
    grid-template-columns: 32px minmax(0, 1fr);
    padding-inline: 10px;
  }

  .identity-sigil {
    width: 32px;
    height: 32px;
    font-size: 17px;
  }

  .identity-copy h3 {
    font-size: 15px;
  }

  .result-hero {
    grid-template-columns: minmax(0, 1fr) 102px;
  }

  .grade-seal {
    width: 100px;
    height: 100px;
  }
}

@media (max-height: 720px) {
  .cover-view {
    gap: 10px;
  }

  .cover-card {
    margin: 10px 0 4px;
    padding: 16px 0;
  }

  .cover-question {
    font-size: 30px;
  }

  .stats-grid {
    margin-bottom: 8px;
  }

  .event-card {
    padding: 15px;
  }

  .cover-ledger div {
    padding-block: 9px;
  }

  .result-hero {
    padding-bottom: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
