:root {
  color-scheme: light;
  --ink: #27302b;
  --muted: #69736b;
  --paper: #fbfaf1;
  --panel: #eef3eb;
  --panel-strong: #dde8dc;
  --surface: rgba(255, 255, 255, 0.68);
  --surface-strong: rgba(255, 255, 255, 0.78);
  --surface-soft: rgba(255, 255, 255, 0.58);
  --line: rgba(49, 61, 52, 0.14);
  --line-strong: rgba(49, 61, 52, 0.18);
  --red: #b85c51;
  --green: #5b8b5a;
  --gold: #b69555;
  --blue: #557a86;
  --shadow: 0 22px 60px rgba(39, 48, 43, 0.12);
  --shadow-soft: 0 12px 28px rgba(39, 48, 43, 0.08);
  --cut-panel: polygon(4% 0, 100% 0, 96% 100%, 0 100%, 0 18%);
  --cut-small: polygon(7% 0, 100% 0, 93% 100%, 0 100%, 0 22%);
  --cut-slim: polygon(3% 0, 100% 0, 97% 100%, 0 100%, 0 20%);
  --cut-choice-left: polygon(4% 0, 100% 0, 96% 100%, 0 100%, 0 18%);
  --cut-choice-right: polygon(0 0, 96% 0, 100% 18%, 100% 100%, 4% 100%);
  --cut-reset: polygon(8% 0, 100% 0, 92% 100%, 0 100%, 0 20%);
  --surface-highlight: linear-gradient(180deg, rgba(238, 243, 235, 0.34), rgba(255, 255, 255, 0));
  --surface-highlight-soft: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0));
  --button-facet:
    linear-gradient(138deg, rgba(255, 255, 255, 0.28) 0 34%, rgba(255, 255, 255, 0) 35%),
    linear-gradient(28deg, rgba(39, 48, 43, 0.07) 0 22%, rgba(39, 48, 43, 0) 23%),
    linear-gradient(315deg, rgba(255, 255, 255, 0.18) 0 16%, rgba(255, 255, 255, 0) 17%);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Microsoft YaHei", sans-serif;
}

html.game-active,
body.game-active {
  overflow: hidden;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100svh;
  width: 100%;
  overflow-x: clip;
  background:
    linear-gradient(140deg, rgba(91, 139, 90, 0.06), transparent 28%),
    linear-gradient(222deg, rgba(182, 149, 85, 0.08), transparent 34%),
    linear-gradient(180deg, rgba(238, 243, 235, 0.92), rgba(251, 250, 241, 0.98)),
    url("./assets/chinese-reigns/share/result-card-bg.png") center / cover;
}

.app-version {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 20;
  margin: 0;
  color: rgba(39, 48, 43, 0.34);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  pointer-events: none;
  user-select: none;
}

.app-version:empty {
  display: none;
}

body.game-active .app-version {
  color: rgba(39, 48, 43, 0.24);
}

.screen {
  width: min(100%, 460px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.start-screen,
.result-screen,
.error-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.start-screen {
  gap: 8px;
}

.start-surface,
.error-surface {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.faceted-surface {
  position: relative;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  clip-path: var(--cut-panel);
}

.faceted-surface::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: var(--surface-highlight);
  clip-path: inherit;
  pointer-events: none;
}

.start-surface.faceted-surface {
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
  clip-path: none;
  isolation: isolate;
}

.start-surface.faceted-surface::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  clip-path: var(--cut-panel);
  pointer-events: none;
}

.start-surface.faceted-surface::after {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: -1;
  background: var(--surface-highlight);
  clip-path: var(--cut-panel);
  pointer-events: none;
}

.faceted-frame {
  position: relative;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  box-shadow: var(--shadow);
  clip-path: var(--cut-panel);
}

.faceted-frame::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: var(--surface-highlight-soft);
  clip-path: inherit;
  pointer-events: none;
}

.start-art,
.result-visual {
  width: min(64vw, 240px);
  margin: 0 auto 12px;
  overflow: hidden;
}

.start-art {
  aspect-ratio: 1;
}

.result-visual {
  width: min(66vw, 260px);
  aspect-ratio: 2 / 3;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.64), rgba(238, 243, 235, 0.26)),
    rgba(255, 255, 255, 0.46);
  border: 1px solid var(--line);
  clip-path: var(--cut-panel);
}

.start-art img,
.result-visual img {
  width: 100%;
  height: 100%;
  display: block;
}

.start-art img {
  object-fit: cover;
}

.result-visual img {
  object-fit: contain;
}

.result-visual.persona-revealed {
  aspect-ratio: 1;
  background: transparent;
  border: 0;
  clip-path: none;
  overflow: visible;
}

.result-visual img.persona-image {
  object-fit: contain;
  filter: drop-shadow(0 12px 20px rgba(39, 48, 43, 0.1));
}

h1,
h2 {
  margin: 0;
  line-height: 1.12;
  letter-spacing: 0;
}

h1 {
  font-size: 34px;
}

h2 {
  font-size: 25px;
}

.intro,
.archive-summary,
.ending-summary,
.error-screen p {
  color: var(--muted);
  line-height: 1.7;
  font-size: 15px;
}

.start-prompt {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  font-weight: 700;
}

.intro {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
}

.archive-summary {
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.55;
}

.next-run-nudge {
  margin: 8px 0 0;
  padding: 9px 11px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.54), rgba(238, 243, 235, 0.2)),
    rgba(85, 122, 134, 0.1);
  border: 1px solid rgba(85, 122, 134, 0.16);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.5;
  clip-path: polygon(5% 0, 100% 0, 95% 100%, 0 100%, 0 24%);
}

.dynasty-strip {
  --dynasty-bleed: clamp(18px, 8vw, 52px);
  position: relative;
  margin: 10px calc(var(--dynasty-bleed) * -1) 0;
  padding: 10px 0 9px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.56), rgba(238, 243, 235, 0.18)),
    rgba(255, 255, 255, 0.48);
  box-shadow: var(--shadow-soft);
  clip-path: var(--cut-slim);
  width: auto;
  max-width: none;
  min-width: 0;
  overflow: hidden;
}

.dynasty-strip::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: var(--surface-highlight);
  clip-path: inherit;
  pointer-events: none;
}

.dynasty-strip::after {
  content: "";
  position: absolute;
  top: 30px;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    linear-gradient(90deg, rgba(247, 243, 232, 0.88), rgba(247, 243, 232, 0) 58px),
    linear-gradient(270deg, rgba(247, 243, 232, 0.88), rgba(247, 243, 232, 0) 58px);
  pointer-events: none;
}

.dynasty-strip-title {
  position: relative;
  margin: 0 12px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.dynasty-strip-track {
  position: relative;
  display: flex;
  width: 100%;
  max-width: none;
  min-width: 0;
  overflow-x: auto;
  padding: 4px max(14px, var(--dynasty-bleed)) 4px;
  scrollbar-width: none;
  scroll-padding-inline: var(--dynasty-bleed);
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 34px, #000 calc(100% - 34px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 34px, #000 calc(100% - 34px), transparent 100%);
}

.dynasty-strip-track::-webkit-scrollbar {
  display: none;
}

.dynasty-milestone {
  --milestone-span: 92px;
  position: relative;
  flex: 0 0 var(--milestone-span);
  min-width: 84px;
  padding: 18px 6px 0;
  display: grid;
  gap: 4px;
  justify-items: center;
  text-align: center;
}

.dynasty-milestone::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  height: 2px;
  border-top: 1px solid rgba(116, 102, 70, 0.5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.45);
  background: linear-gradient(90deg, rgba(91, 139, 90, 0.62), rgba(182, 149, 85, 0.58));
}

.dynasty-milestone.first::before {
  left: 50%;
}

.dynasty-milestone.latest::before {
  right: 50%;
}

.dynasty-node {
  position: absolute;
  top: 3px;
  left: 50%;
  width: 18px;
  height: 18px;
  transform: translateX(-50%);
  background: url("./assets/chinese-reigns/ui/dynasty-node.svg") center / contain no-repeat;
  filter: drop-shadow(0 2px 4px rgba(42, 35, 27, 0.12));
}

.dynasty-milestone.latest .dynasty-node {
  width: 20px;
  height: 20px;
  top: 1px;
  background-image: url("./assets/chinese-reigns/ui/dynasty-node-latest.svg");
}

.dynasty-label,
.dynasty-years {
  margin: 0;
  white-space: nowrap;
  max-width: 100%;
}

.dynasty-label {
  color: var(--ink);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dynasty-years {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
}

.succession-preview {
  margin-top: 14px;
  padding: 12px 14px;
}

.succession-kicker {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
}

.succession-summary,
.succession-effect {
  margin: 0;
  color: var(--ink);
  line-height: 1.55;
}

.succession-summary {
  font-size: 13px;
}

.succession-effect {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.succession-inline {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.primary-button,
.ghost-button {
  position: relative;
  overflow: hidden;
  min-height: 46px;
  padding: 0 18px;
  font-weight: 800;
  clip-path: var(--cut-small);
  transition: transform 120ms ease, background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.primary-button::before,
.ghost-button::before,
.choice-buttons button::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0));
  clip-path: inherit;
  pointer-events: none;
}

.primary-button {
  width: 100%;
  margin-top: 10px;
  color: #fff;
  border: 1px solid rgba(39, 48, 43, 0.4);
  background:
    linear-gradient(180deg, rgba(91, 139, 90, 0.16), rgba(39, 48, 43, 0)),
    var(--ink);
  box-shadow: 0 12px 24px rgba(39, 48, 43, 0.12);
}

.ghost-button {
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.68), rgba(238, 243, 235, 0.18)),
    var(--surface-strong);
  border: 1px solid var(--line);
}

#restart-button {
  min-width: 72px;
  padding: 0 16px;
  color: #4a403a;
  border-color: rgba(118, 88, 70, 0.22);
  background:
    var(--button-facet),
    linear-gradient(180deg, rgba(255, 255, 255, 0.54), rgba(255, 255, 255, 0.12)),
    rgba(182, 149, 85, 0.2);
  box-shadow: 0 8px 16px rgba(79, 70, 64, 0.08);
  clip-path: var(--cut-reset);
}

.primary-button:active,
.ghost-button:active,
.choice-buttons button:active {
  transform: translateY(1px) scale(0.992);
}

.game-screen {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 14px;
  min-height: 0;
  height: 100svh;
  overflow: hidden;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.resource-hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.resource {
  position: relative;
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 5px 6px 7px;
  --resource-cut: polygon(12% 0, 100% 0, 90% 100%, 0 100%, 0 24%);
  background: transparent;
  overflow: visible;
  isolation: isolate;
}

.resource::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  background:
    var(--surface-highlight),
    linear-gradient(135deg, rgba(255, 255, 255, 0.62), rgba(221, 232, 220, 0.2)),
    rgba(255, 255, 255, 0.54);
  clip-path: var(--resource-cut);
  filter: drop-shadow(0 5px 8px rgba(39, 48, 43, 0.05));
  pointer-events: none;
  z-index: 0;
}

.resource-top {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  position: relative;
  z-index: 2;
}

.resource-preview-mark {
  position: absolute;
  top: -18px;
  right: -8px;
  width: 32px;
  height: 32px;
  opacity: 0;
  transform: translateY(4px) scale(0.74) rotate(var(--preview-tilt, -4deg));
  transition: opacity 120ms ease, transform 120ms ease, filter 120ms ease;
  background: center / contain no-repeat;
  filter: drop-shadow(0 7px 9px rgba(39, 48, 43, 0.18));
  pointer-events: none;
  z-index: 5;
}

.resource.preview-active {
  filter: saturate(1.04);
}

.resource.preview-active .resource-preview-mark {
  opacity: 1;
  transform: translateY(0) scale(1) rotate(var(--preview-tilt, -4deg));
}

.resource.preview-up .resource-preview-mark {
  background-image: url("./assets/chinese-reigns/ui/resource-preview-up.svg");
}

.resource.preview-down .resource-preview-mark {
  background-image: url("./assets/chinese-reigns/ui/resource-preview-down.svg");
}

.resource.preview-risk .resource-preview-mark {
  background-image: url("./assets/chinese-reigns/ui/resource-preview-risk.svg");
  filter: drop-shadow(0 7px 10px rgba(126, 62, 60, 0.24));
}

.resource-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  object-fit: contain;
}

.resource-label {
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.resource-bar {
  position: relative;
  z-index: 2;
  height: 10px;
  overflow: hidden;
  background: rgba(39, 48, 43, 0.12);
  clip-path: polygon(6% 0, 100% 0, 94% 100%, 0 100%, 0 30%);
}

.resource-fill {
  height: 100%;
  width: 50%;
  background: var(--green);
  transition: width 180ms ease, background 180ms ease;
  clip-path: polygon(6% 0, 100% 0, 94% 100%, 0 100%, 0 30%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.26);
}

.resource.danger .resource-fill {
  background: var(--red);
}

.resource.danger-low::after,
.resource.danger-high::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  clip-path: var(--resource-cut);
  background:
    linear-gradient(90deg, rgba(184, 92, 81, 0.2), transparent 36%),
    linear-gradient(180deg, rgba(184, 92, 81, 0.1), transparent 58%);
  z-index: 1;
}

.resource.danger-high::after {
  background:
    linear-gradient(270deg, rgba(184, 92, 81, 0.22), transparent 34%),
    linear-gradient(180deg, rgba(184, 92, 81, 0.1), transparent 58%);
}

.resource.preview-up .resource-fill {
  background: var(--gold);
}

.resource.preview-down .resource-fill,
.resource.preview-risk .resource-fill {
  background: var(--blue);
}

.objective-strip {
  position: relative;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.58), rgba(238, 243, 235, 0.22)),
    var(--surface);
  box-shadow: 0 8px 18px rgba(39, 48, 43, 0.05);
  clip-path: var(--cut-slim);
}

.objective-strip::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: var(--surface-highlight);
  clip-path: inherit;
  pointer-events: none;
}

.objective-strip p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: none;
}

.objective-strip ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0 0 0 2px;
  list-style: none;
  color: var(--ink);
  font-size: 13px;
}

.objective-strip li {
  position: relative;
  padding-left: 10px;
  line-height: 1.35;
}

.objective-strip li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.36em;
  width: 8px;
  height: 8px;
  background: url("./assets/chinese-reigns/ui/objective-pending.svg") center / contain no-repeat;
}

.objective-strip li.done {
  color: var(--green);
  text-decoration: none;
}

.objective-strip li.done::before {
  top: 0.3em;
  width: 10px;
  height: 10px;
  background-image: url("./assets/chinese-reigns/ui/objective-done.svg");
}

.objective-prefix {
  display: inline-block;
  min-width: 2.8em;
  margin-right: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.objective-strip li.done .objective-prefix {
  color: var(--green);
}

.playfield {
  position: relative;
  display: grid;
  justify-items: center;
  align-items: end;
  min-height: 0;
  padding-bottom: 8px;
  touch-action: none;
  overflow: visible;
}

.event-card {
  position: relative;
  --drag-progress: 0;
  width: auto;
  max-width: min(100%, 412px);
  height: min(100%, 620px);
  aspect-ratio: 0.72;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  user-select: none;
  will-change: transform, opacity, filter;
  transform: translate3d(0, 0, 0);
  transform-origin: 50% 68%;
  transition:
    transform 210ms cubic-bezier(0.2, 0.84, 0.28, 1),
    opacity 140ms ease,
    box-shadow 140ms ease,
    filter 140ms ease;
  clip-path: polygon(6% 0, 100% 0, 94% 100%, 0 100%, 0 16%);
  cursor: grab;
}

.event-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0)),
    linear-gradient(180deg, rgba(238, 243, 235, 0.12), rgba(251, 250, 241, 0.04)),
    linear-gradient(165deg, rgba(91, 139, 90, 0.05), transparent 34%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms ease;
}

.event-card::before {
  content: "";
  position: absolute;
  inset: 1px;
  background:
    var(--surface-highlight-soft),
    linear-gradient(160deg, rgba(238, 243, 235, 0.16), rgba(238, 243, 235, 0));
  clip-path: polygon(6% 0, 100% 0, 94% 100%, 0 100%, 0 16%);
  pointer-events: none;
  z-index: 0;
}

.event-card.card-exit-left,
.event-card.card-exit-right {
  opacity: 0;
  filter: saturate(0.92) blur(0.8px);
}

.event-card.card-dragging {
  transition: none;
  cursor: grabbing;
  box-shadow: 0 28px 70px rgba(39, 48, 43, 0.18);
  filter: saturate(1.02);
}

.event-card.card-dragging::after {
  opacity: calc(0.08 + var(--drag-progress) * 0.22);
}

.event-card.drag-left::after {
  background:
    linear-gradient(90deg, rgba(85, 122, 134, 0.34), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0));
}

.event-card.drag-right::after {
  background:
    linear-gradient(270deg, rgba(182, 149, 85, 0.36), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0));
}

.event-card.drag-commit {
  box-shadow: 0 32px 76px rgba(39, 48, 43, 0.22);
  filter: saturate(1.05) contrast(1.02);
}

.event-card.card-exit-left {
  animation: card-dismiss-left 190ms cubic-bezier(0.22, 0.8, 0.36, 1) forwards;
}

.event-card.card-exit-right {
  animation: card-dismiss-right 190ms cubic-bezier(0.22, 0.8, 0.36, 1) forwards;
}

.event-card.card-exit-left::after,
.event-card.card-exit-right::after {
  animation: card-dissolve 190ms ease-out forwards;
}

.event-card.card-enter {
  animation: card-rise-in 280ms cubic-bezier(0.2, 0.84, 0.28, 1) forwards;
}

.card-background {
  position: absolute;
  inset: 0;
}

.card-background img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.78;
  display: block;
}

.card-importance-badge {
  position: absolute;
  top: 20px;
  right: 18px;
  z-index: 4;
  min-width: 58px;
  max-width: 112px;
  margin: 0;
  padding: 8px 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0)),
    rgba(105, 115, 107, 0.12);
  box-shadow: 0 8px 16px rgba(39, 48, 43, 0.1);
  clip-path: polygon(14% 0, 100% 0, 100% 66%, 84% 100%, 0 100%, 0 26%);
  pointer-events: none;
}

.card-importance-badge::before {
  content: "";
  position: absolute;
  top: -8px;
  right: -5px;
  width: 18px;
  height: 18px;
  background: currentColor;
  opacity: 0.32;
  clip-path: polygon(50% 0, 100% 48%, 62% 100%, 0 74%, 10% 18%);
}

.card-importance-badge::after {
  content: "";
  position: absolute;
  right: 9px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: currentColor;
  opacity: 0.2;
  clip-path: polygon(0 20%, 100% 0, 74% 100%, 16% 82%);
}

.importance-common {
  color: var(--muted);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0)),
    rgba(105, 115, 107, 0.12);
}

.importance-urgent {
  color: var(--red);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0)),
    rgba(184, 92, 81, 0.15);
}

.importance-state {
  color: var(--green);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0)),
    rgba(91, 139, 90, 0.16);
}

.importance-secret {
  color: var(--blue);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0)),
    rgba(85, 122, 134, 0.16);
}

.importance-rare {
  color: var(--gold);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0)),
    rgba(182, 149, 85, 0.2);
}

.importance-late {
  color: var(--red);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0)),
    rgba(184, 92, 81, 0.16);
}

.card-content {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 22px 22px 28px;
  background: linear-gradient(180deg, rgba(251, 250, 241, 0.1), rgba(251, 250, 241, 0.92) 62%);
}

.actor-stage {
  position: relative;
  width: 100%;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 10px 0 2px;
  margin-bottom: auto;
  isolation: isolate;
  pointer-events: none;
}

.actor-stage::before {
  content: "";
  position: absolute;
  bottom: 14px;
  width: min(68%, 248px);
  aspect-ratio: 1.45;
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0) 68%),
    linear-gradient(180deg, rgba(221, 232, 220, 0.42), rgba(221, 232, 220, 0.12));
  clip-path: polygon(10% 18%, 90% 18%, 100% 58%, 86% 100%, 14% 100%, 0 58%);
  opacity: 0.82;
  z-index: -2;
}

.actor-stage::after {
  content: "";
  position: absolute;
  bottom: 8px;
  width: min(64%, 224px);
  height: 24px;
  background: radial-gradient(ellipse at center, rgba(39, 48, 43, 0.14), rgba(39, 48, 43, 0) 72%);
  filter: blur(2px);
  z-index: -3;
}

.actor-image {
  width: min(88%, 356px);
  aspect-ratio: 1;
  object-fit: contain;
  border: 0;
  filter:
    saturate(0.96)
    contrast(1.02)
    drop-shadow(0 16px 26px rgba(39, 48, 43, 0.12));
  mix-blend-mode: multiply;
  transform: translateY(10px) scale(1.1);
  pointer-events: none;
}

.card-title {
  margin: 18px 0 10px;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.card-text {
  min-height: 76px;
  margin: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.45;
}

.choice-hint {
  --hint-progress: 0;
  position: absolute;
  top: 7%;
  transform: translateY(calc(var(--hint-progress) * -4px)) scale(calc(0.96 + var(--hint-progress) * 0.08));
  min-width: 88px;
  max-width: min(42%, 156px);
  padding: 11px 14px;
  background: rgba(39, 48, 43, 0.88);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  opacity: 0;
  transition: opacity 100ms ease, transform 100ms ease, background 100ms ease;
  clip-path: polygon(10% 0, 100% 0, 90% 100%, 0 100%, 0 22%);
  box-shadow: 0 8px 18px rgba(39, 48, 43, 0.14);
  z-index: 3;
}

.choice-hint::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0));
  clip-path: inherit;
  pointer-events: none;
}

.choice-hint.left {
  left: 10px;
  clip-path: polygon(14% 0, 100% 0, 90% 100%, 0 100%, 0 34%);
}

.choice-hint.right {
  right: 10px;
  clip-path: polygon(10% 0, 100% 0, 100% 34%, 86% 100%, 0 100%);
}

.choice-hint.visible {
  opacity: calc(0.5 + var(--hint-progress) * 0.5);
}

.choice-hint.commit {
  background: rgba(39, 48, 43, 0.95);
}

.choice-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 2px;
}

.choice-buttons button {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  min-height: 50px;
  min-width: 0;
  padding: 0 24px;
  border: 1px solid rgba(39, 48, 43, 0.16);
  color: var(--ink);
  font-size: 17px;
  font-weight: 880;
  line-height: 1.15;
  box-shadow: 0 9px 18px rgba(39, 48, 43, 0.08);
}

#left-button {
  background:
    var(--button-facet),
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.08)),
    rgba(91, 139, 90, 0.28);
  color: #26372c;
  clip-path: var(--cut-choice-left);
}

#right-button {
  background:
    var(--button-facet),
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.08)),
    rgba(182, 149, 85, 0.32);
  color: #443923;
  clip-path: var(--cut-choice-right);
}

.result-badge {
  display: inline-flex;
  align-self: flex-start;
  margin: 8px 0 0;
  padding: 7px 12px;
  background: rgba(91, 139, 90, 0.14);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  clip-path: polygon(8% 0, 100% 0, 92% 100%, 0 100%, 0 24%);
}

.result-collection-label {
  display: inline-flex;
  align-self: flex-start;
  margin: 8px 0 0;
  padding: 6px 11px;
  color: var(--muted);
  background: rgba(105, 115, 107, 0.1);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.1;
  clip-path: polygon(7% 0, 100% 0, 94% 100%, 0 100%, 0 26%);
}

.collection-rare {
  color: #8f7844;
  background: rgba(182, 149, 85, 0.2);
}

.collection-hidden,
.collection-curio {
  color: var(--red);
  background: rgba(184, 92, 81, 0.14);
}

.collection-long {
  color: var(--blue);
  background: rgba(85, 122, 134, 0.15);
}

.collection-new {
  color: var(--green);
  background: rgba(91, 139, 90, 0.14);
}

.result-headline {
  margin: 10px 0 0;
  font-size: 30px;
}

.ending-name {
  margin: 8px 0 0;
  color: var(--green);
  font-size: 18px;
  font-weight: 900;
}

.result-epitaph {
  margin: 10px 0 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.55;
}

.persona-caption {
  margin: 10px 0 0;
  padding: 10px 12px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.58), rgba(238, 243, 235, 0.18)),
    var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.55;
  clip-path: var(--cut-small);
}

.historical-match-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin: 14px 0 0;
  padding: 12px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.68), rgba(238, 243, 235, 0.2)),
    var(--surface-strong);
  border: 1px solid var(--line);
  clip-path: var(--cut-panel);
}

.historical-match-label {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.historical-match-visual {
  aspect-ratio: 1;
  background: rgba(238, 243, 235, 0.58);
  border: 1px solid rgba(66, 83, 72, 0.12);
  clip-path: var(--cut-small);
  overflow: hidden;
}

.historical-match-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.historical-match-copy {
  min-width: 0;
}

.historical-match-headline,
.historical-match-fit,
.historical-match-body,
.historical-match-roast {
  margin: 0;
}

.historical-match-headline {
  color: var(--ink);
  font-size: 20px;
  font-weight: 950;
  line-height: 1.2;
}

.historical-match-fit {
  display: inline-block;
  margin-top: 7px;
  padding: 4px 7px;
  color: var(--green);
  background: rgba(91, 139, 90, 0.12);
  border: 1px solid rgba(91, 139, 90, 0.22);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
  clip-path: var(--cut-slim);
}

.historical-match-body {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.45;
}

.historical-match-roast {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.chronicle-comment-card {
  margin: 12px 0 0;
  padding: 13px 14px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(238, 243, 235, 0.18)),
    var(--surface-strong);
  border: 1px solid var(--line);
  clip-path: var(--cut-small);
}

.chronicle-comment-label {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 13px;
  font-weight: 950;
}

.chronicle-comment-text {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.65;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 0;
}

.result-stats div {
  position: relative;
  padding: 12px 44px 12px 12px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.62), rgba(238, 243, 235, 0.18)),
    var(--surface-strong);
  border: 1px solid var(--line);
  clip-path: var(--cut-small);
}

.result-stats div::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: var(--surface-highlight);
  clip-path: inherit;
  pointer-events: none;
}

.result-stats div::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  background: center / contain no-repeat;
  opacity: 0.58;
  pointer-events: none;
}

.result-stats div:nth-child(1)::after {
  background-image: url("./assets/chinese-reigns/ui/stat-years.svg");
}

.result-stats div:nth-child(2)::after {
  background-image: url("./assets/chinese-reigns/ui/stat-match.svg");
}

.result-stats div:nth-child(3)::after {
  background-image: url("./assets/chinese-reigns/ui/stat-endings.svg");
}

.result-stats dt {
  position: relative;
  z-index: 1;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.result-stats dd {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  line-height: 1.3;
}

.share-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.share-actions .ghost-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0 12px 0 38px;
  color: var(--ink);
  background:
    var(--button-facet),
    linear-gradient(135deg, rgba(255, 255, 255, 0.52), rgba(238, 243, 235, 0.2)),
    rgba(91, 139, 90, 0.12);
}

.share-actions .ghost-button::after {
  content: "";
  position: absolute;
  left: 11px;
  width: 23px;
  height: 23px;
  background: center / contain no-repeat;
  opacity: 0.72;
  pointer-events: none;
}

#generate-share-button::after {
  background-image: url("./assets/chinese-reigns/ui/action-historical-match.svg");
}

#save-share-button::after {
  background-image: url("./assets/chinese-reigns/ui/action-result-card.svg");
}

.share-status {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.share-preview-panel {
  position: relative;
  margin-top: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.58), rgba(238, 243, 235, 0.18)),
    var(--surface);
  clip-path: var(--cut-panel);
}

.share-preview-panel::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: var(--surface-highlight);
  clip-path: inherit;
  pointer-events: none;
}

.start-surface {
  padding: 18px 18px 20px;
}

.error-surface {
  padding: 22px 18px;
  text-align: center;
}

.error-screen h2 {
  margin-bottom: 8px;
}

.share-preview-panel img {
  width: 100%;
  display: block;
  border: 1px solid rgba(39, 48, 43, 0.08);
  clip-path: polygon(4% 0, 100% 0, 96% 100%, 0 100%, 0 18%);
}

@media (max-height: 760px) {
  .screen {
    padding: max(12px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  }

  .game-screen {
    gap: 10px;
  }

  .succession-preview {
    margin-top: 10px;
    padding: 10px 12px;
  }

  .succession-summary {
    font-size: 12px;
  }

  .succession-effect {
    font-size: 11px;
  }

  .succession-inline {
    margin-top: 4px;
    font-size: 11px;
  }

  .start-screen {
    gap: 6px;
  }

  .start-art {
    width: min(54vw, 190px);
    margin-bottom: 8px;
  }

  .start-prompt {
    font-size: 15px;
  }

  .intro,
  .archive-summary,
  .next-run-nudge {
    font-size: 13px;
  }

  .eyebrow {
    margin-bottom: 6px;
    font-size: 12px;
  }

  h2 {
    font-size: 22px;
  }

  .ghost-button,
  .primary-button,
  .choice-buttons button {
    min-height: 44px;
  }

  .resource-icon {
    width: 28px;
    height: 28px;
  }

  .resource-label {
    font-size: 10px;
  }

  .objective-strip {
    padding: 8px 10px;
  }

  .objective-strip p,
  .objective-strip ul {
    font-size: 12px;
  }

  .event-card {
    height: min(100%, 510px);
  }

  .card-content {
    padding: 16px 16px 22px;
  }

  .actor-stage::before {
    width: min(70%, 210px);
    bottom: 12px;
  }

  .actor-stage::after {
    width: min(62%, 194px);
  }

  .actor-image {
    width: min(78%, 238px);
  }

  .card-title {
    margin: 12px 0 8px;
    font-size: 12px;
  }

  .result-headline {
    font-size: 26px;
  }

  .ending-name {
    font-size: 16px;
  }

  .result-epitaph {
    font-size: 14px;
  }

  .card-text {
    min-height: 62px;
    font-size: 19px;
    line-height: 1.36;
  }
}

@media (max-height: 680px) {
  .screen {
    padding: max(8px, env(safe-area-inset-top)) 12px env(safe-area-inset-bottom);
  }

  .game-screen {
    gap: 6px;
  }

  .game-header {
    gap: 8px;
  }

  h2 {
    font-size: 18px;
  }

  .start-art {
    width: min(48vw, 160px);
    margin-bottom: 6px;
  }

  .result-badge {
    padding: 5px 8px;
    font-size: 11px;
  }

  .result-headline {
    font-size: 22px;
  }

  .ending-name {
    font-size: 15px;
  }

  .result-epitaph {
    font-size: 13px;
    line-height: 1.45;
  }

  .start-prompt {
    font-size: 14px;
    line-height: 1.45;
  }

  .intro,
  .archive-summary,
  .next-run-nudge {
    font-size: 12px;
    line-height: 1.45;
  }

  .succession-inline {
    margin-top: 2px;
    font-size: 10px;
  }

  .resource-hud {
    gap: 6px;
  }

  .resource-top {
    min-height: 28px;
  }

  .resource-icon {
    width: 26px;
    height: 26px;
  }

  .resource-label {
    font-size: 9px;
  }

  .objective-strip {
    padding: 6px 8px;
  }

  .objective-strip p {
    margin-bottom: 3px;
    font-size: 11px;
  }

  .objective-strip ul {
    gap: 2px;
    font-size: 11px;
  }

  .event-card {
    height: min(100%, 360px);
  }

  .card-content {
    padding: 12px 12px 16px;
  }

  .actor-stage::before {
    width: min(72%, 180px);
    bottom: 10px;
  }

  .actor-stage::after {
    width: min(64%, 170px);
    height: 20px;
  }

  .actor-image {
    width: min(82%, 210px);
  }

  .card-text {
    min-height: 46px;
    font-size: 15px;
    line-height: 1.32;
  }

  .choice-buttons {
    gap: 6px;
    margin-top: 0;
  }

  .choice-buttons button {
    min-height: 44px;
  }
}

@media (min-width: 720px) {
  .app-shell {
    display: grid;
    place-items: center;
    padding: 24px;
  }

  .screen {
    position: relative;
    min-height: min(900px, calc(100svh - 48px));
    border: 1px solid var(--line);
    background:
      linear-gradient(150deg, rgba(255, 255, 255, 0.54), transparent 24%),
      linear-gradient(220deg, rgba(221, 232, 220, 0.34), transparent 30%),
      rgba(251, 250, 241, 0.88);
    box-shadow: var(--shadow);
    clip-path: polygon(3% 0, 100% 0, 97% 100%, 0 100%, 0 10%);
  }
}

.screen.hidden {
  display: none;
}

@keyframes card-dismiss-left {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }
  55% {
    transform: translate3d(-42vw, -8px, 0) rotate(-9deg) scale(0.985);
    opacity: 0.5;
  }
  100% {
    transform: translate3d(-88vw, -18px, 0) rotate(-13deg) scale(0.94);
    opacity: 0;
  }
}

@keyframes card-dismiss-right {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }
  55% {
    transform: translate3d(42vw, -8px, 0) rotate(9deg) scale(0.985);
    opacity: 0.5;
  }
  100% {
    transform: translate3d(88vw, -18px, 0) rotate(13deg) scale(0.94);
    opacity: 0;
  }
}

@keyframes card-dissolve {
  0% {
    opacity: 0;
  }
  30% {
    opacity: 0.14;
  }
  100% {
    opacity: 0;
  }
}

@keyframes card-rise-in {
  0% {
    transform: translate3d(0, 24px, 0) scale(0.94);
    opacity: 0.05;
  }
  52% {
    transform: translate3d(0, 10px, 0) scale(0.975);
    opacity: 0.6;
  }
  100% {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: 1;
  }
}
