:root {
  color-scheme: light;
  --accent: #711a5f;
  --accent-soft: #f8e8f3;
  --accent-line: #d9b8cf;
  --ink: #261b2a;
  --muted: #716174;
  --panel: #ffffff;
  --line: #eadbe7;
  --mint: #dff3ed;
  --mint-strong: #2f8f7a;
  --peach: #ffd9bf;
  --peach-strong: #ff9f72;
  --blue: #7f79b9;
  --blue-soft: #efedff;
  --yellow: #ffe68a;
  --danger: #e86f6f;
  --shadow: 0 14px 34px rgba(113, 26, 95, 0.1);
}

* {
  box-sizing: border-box;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family:
    Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: #fbf8fb;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(900px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 10px 0 14px;
}

.game-panel {
  display: grid;
  gap: 8px;
  background: #ffffff;
  border: 2px solid var(--accent);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 10px 12px;
}

.top-bar,
.game-footer,
.badge-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.top-bar {
  min-height: 100px;
}

.seal-placeholder {
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 2px solid currentColor;
  color: var(--accent);
  background: #fffafd;
  font-weight: 800;
}

.brand-mark,
.logo-placeholder {
  display: block;
  flex: 0 0 auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  object-fit: contain;
}

.brand-mark {
  width: 112px;
  height: 112px;
}

.title-block {
  flex: 1;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: clamp(0.86rem, 1.6vw, 1rem);
  font-weight: 650;
}

.eyebrow span {
  display: inline-block;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.85rem, 4.2vw, 2.65rem);
  line-height: 1.12;
}

.nowrap {
  white-space: nowrap;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.25rem, 2.4vw, 1.8rem);
}

.icon-button {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  color: var(--accent);
  background: var(--panel);
}

.canvas-wrap {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  background: #fffafd;
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  touch-action: none;
}

.game-footer {
  justify-content: space-between;
  flex-wrap: wrap;
}

.status-copy {
  flex: 1 1 280px;
  min-height: 24px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.42;
}

.primary-button,
.ghost-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 18px;
  font-weight: 700;
}

.primary-button {
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 10px 22px rgba(113, 26, 95, 0.22);
}

.primary-button:disabled {
  cursor: default;
  opacity: 0.58;
  box-shadow: none;
}

.ghost-button {
  color: var(--accent);
  background: #ffffff;
  border-color: var(--accent-line);
}

.hidden {
  display: none !important;
}

.badge-screen {
  display: grid;
  gap: 12px;
}

.postcard-scroll {
  container-type: inline-size;
  max-width: 100%;
  margin-inline: 0;
  padding-bottom: 4px;
  overflow-x: hidden;
  overflow-y: visible;
}

.postcard-frame {
  --postcard-scale: min(1, calc(100cqw / 900px));
  position: relative;
  width: calc(900px * var(--postcard-scale));
  height: calc(608.108px * var(--postcard-scale));
  max-width: 100%;
  margin-inline: auto;
}

.badge-controls {
  position: relative;
  z-index: 2;
  justify-content: flex-start;
  flex-wrap: wrap;
  background: rgba(255, 250, 253, 0.96);
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  padding: 10px 12px;
  backdrop-filter: blur(10px);
}

.badge-controls > div:first-child {
  margin-right: auto;
}

.name-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.86rem;
}

.name-field input {
  width: min(260px, 68vw);
  min-height: 40px;
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
}

.postcard-sheet {
  position: absolute;
  inset: 0 auto auto 0;
  box-sizing: border-box;
  width: 900px;
  min-width: 900px;
  height: 608.108px;
  aspect-ratio: 148 / 100;
  margin: 0;
  overflow: hidden;
  background: #fffafd;
  border: 0;
  outline: 0;
  box-shadow: var(--shadow);
  padding: 0;
  transform: scale(var(--postcard-scale));
  transform-origin: top left;
  --postcard-safe-left: 20%;
  --postcard-safe-width: 60%;
  --postcard-bg-scale: 1;
}

.postcard-sheet::after {
  content: "";
  position: absolute;
  inset: 14px;
  z-index: 2;
  pointer-events: none;
  border: 1.5px solid rgba(113, 26, 95, 0.52);
  border-radius: 9px;
}

.sheet-background,
.story-watermark {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sheet-background {
  background-position: center;
  background-size: 100% 100%;
  transform: scale(var(--postcard-bg-scale));
  transform-origin: center;
}

.story-sheet {
  color: #2d2430;
}

.story-sheet[data-drug="ibuprofen"] {
  background: #fbf0d7;
}

.story-sheet[data-drug="ibuprofen"] .sheet-background {
  background: url("./assets/postcards/ibuprofen-ui.jpg");
  background-position: center;
  background-size: 100% 100%;
}

.story-sheet[data-drug="penicillin"] {
  background: #fff4fb;
}

.story-sheet[data-drug="penicillin"] .sheet-background {
  background: url("./assets/postcards/penicillin-ui.jpg");
  background-position: center;
  background-size: 100% 100%;
}

.story-sheet[data-drug="artemisinin"] {
  background: #f4f4df;
}

.story-sheet[data-drug="artemisinin"] .sheet-background {
  background: url("./assets/postcards/artemisinin-ui.jpg");
  background-position: center;
  background-size: 100% 100%;
}

.story-sheet[data-drug="imatinib"] {
  background: #edf8ff;
}

.story-sheet[data-drug="imatinib"] .sheet-background {
  background: url("./assets/postcards/imatinib-ui.jpg");
  background-position: center;
  background-size: 100% 100%;
}

.story-watermark {
  display: none;
  z-index: 0;
  color: rgba(113, 26, 95, 0.07);
  font-size: clamp(3.4rem, 11vw, 6.4rem);
  font-weight: 900;
  line-height: 0.9;
  transform: rotate(-10deg);
  display: none;
  place-items: center;
  text-align: center;
  letter-spacing: 0;
}

.sheet-header,
.id-card,
.stamp-zone,
.honor-card,
.story-block,
.story-grid {
  position: relative;
  z-index: 1;
}

.sheet-header {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  width: var(--postcard-safe-width);
  margin-top: 48px;
  margin-left: var(--postcard-safe-left);
  padding: 13px 18px;
  border: 1px solid rgba(113, 26, 95, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-sizing: border-box;
}

.logo-placeholder {
  width: 82px;
  height: 82px;
  justify-self: center;
  transform: none;
}

.sheet-header p,
.stamp-zone p {
  margin-bottom: 4px;
  color: #667088;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.2;
}

.sheet-header h2 {
  font-size: 34px;
}

.story-header {
  align-items: center;
}

.story-header h2 {
  max-width: 100%;
  color: var(--accent);
  font-size: 32px;
  line-height: 1.12;
}

.honor-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: var(--postcard-safe-width);
  margin-left: var(--postcard-safe-left);
  margin-top: 14px;
  padding: 14px 24px;
  border: 1px solid rgba(113, 26, 95, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  box-sizing: border-box;
}

.honor-card h3 {
  margin: 0;
  color: var(--ink);
  font-size: 30px;
  line-height: 1.1;
  word-break: break-word;
}

.honor-badge {
  flex: 0 0 auto;
  padding: 9px 18px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  color: #ffffff;
  background: var(--accent);
  font-size: 14px;
  font-weight: 800;
}

.story-block,
.story-grid > div {
  border: 1px solid rgba(113, 26, 95, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
}

.story-block {
  width: var(--postcard-safe-width);
  margin-left: var(--postcard-safe-left);
  margin-top: 14px;
  padding: 14px 22px;
  box-sizing: border-box;
}

.story-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 18px;
  width: var(--postcard-safe-width);
  margin-left: var(--postcard-safe-left);
  margin-top: 12px;
}

.story-grid > div {
  min-height: 0;
  padding: 12px;
}

.story-label {
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 800;
}

.story-block p:not(.story-label),
.story-grid p:not(.story-label) {
  margin: 0;
  color: #4f4453;
  font-weight: 650;
  overflow: visible;
}

.story-block p:not(.story-label) {
  font-size: 14.2px;
  line-height: 1.42;
}

.story-grid p:not(.story-label) {
  font-size: 14.2px;
  line-height: 1.38;
}

.id-card {
  display: grid;
  grid-template-columns: 42mm 1fr;
  gap: 10mm;
  margin-top: 16mm;
  padding: 10mm;
  border: 2px solid var(--accent-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.id-photo {
  display: grid;
  place-items: center;
  width: 42mm;
  height: 52mm;
  border-radius: 8px;
  background: var(--accent-soft);
}

.beaker {
  position: relative;
  width: 19mm;
  height: 26mm;
  border: 2mm solid var(--accent);
  border-top: 0;
  border-radius: 0 0 8mm 8mm;
}

.beaker::before {
  content: "";
  position: absolute;
  left: 3mm;
  right: 3mm;
  top: -8mm;
  height: 8mm;
  border-left: 2mm solid var(--accent);
  border-right: 2mm solid var(--accent);
}

.beaker::after {
  content: "";
  position: absolute;
  left: 2mm;
  right: 2mm;
  bottom: 2mm;
  height: 9mm;
  border-radius: 0 0 6mm 6mm;
  background: #2f8f7a;
}

.id-info {
  min-width: 0;
  min-height: 60px;
  height: 60px;
}

.id-label {
  margin-bottom: 1mm;
  color: #667088;
  font-size: 10pt;
}

.id-info h3 {
  margin-bottom: 6mm;
  font-size: 30pt;
  line-height: 1.1;
  word-break: break-word;
}

.id-info strong {
  display: block;
  margin-bottom: 6mm;
  color: var(--accent);
  font-size: 20pt;
}

.id-note {
  color: #4b5870;
  font-size: 11pt;
  line-height: 1.7;
}

.stamp-zone {
  margin-top: 16mm;
}

.stamp-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10mm;
  margin-top: 8mm;
}

.stamp-grid span {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  border: 2px dashed var(--accent-line);
  border-radius: 999px;
  color: #667088;
  background: rgba(255, 255, 255, 0.68);
  font-size: 13pt;
  font-weight: 700;
}

.seal-placeholder {
  width: 30mm;
  height: 30mm;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.58);
  font-size: 10pt;
}

@media (max-width: 760px) {
  .app-shell {
    width: calc(100vw - 16px);
    padding-top: 8px;
  }

  .game-panel {
    padding: 8px;
  }

  .top-bar {
    display: grid;
    grid-template-columns: 60px minmax(0, 1fr) 36px;
    min-height: 82px;
    gap: 10px;
  }

  .brand-mark {
    width: 60px;
    height: 60px;
  }

  .eyebrow {
    margin-bottom: 2px;
    font-size: 0.78rem;
    line-height: 1.25;
  }

  .eyebrow span {
    display: block;
  }

  h1 {
    font-size: clamp(1.45rem, 6.6vw, 1.72rem);
    line-height: 1.08;
    white-space: nowrap;
  }

  .icon-button {
    width: 36px;
    height: 36px;
  }

  .status-copy {
    flex-basis: 100%;
    min-height: 0;
    font-size: 0.86rem;
    line-height: 1.36;
  }

  .badge-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
    align-items: end;
  }

  .badge-controls > div:first-child,
  .name-field {
    grid-column: 1 / -1;
  }

  .name-field input {
    width: 100%;
  }

  .badge-controls .primary-button,
  .badge-controls .ghost-button {
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
  }
}

@media (max-width: 420px) {
  .top-bar {
    grid-template-columns: 52px minmax(0, 1fr) 34px;
    min-height: 70px;
    gap: 8px;
  }

  .brand-mark {
    width: 52px;
    height: 52px;
  }

  .eyebrow {
    font-size: 0.72rem;
  }

  h1 {
    font-size: clamp(1.3rem, 5.8vw, 1.45rem);
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }
}

@media print {
  @page {
    size: 148mm 100mm landscape;
    margin: 6mm;
  }

  body {
    background: #ffffff;
  }

  .game-panel,
  .badge-controls {
    display: none !important;
  }

  .app-shell {
    width: auto;
    margin: 0;
    padding: 0;
  }

  .badge-screen {
    display: block !important;
  }

  .postcard-frame {
    width: 148mm;
    height: 100mm;
    margin: 0;
  }

  .postcard-sheet {
    position: relative;
    width: 148mm;
    height: 100mm;
    min-width: 0;
    margin: 0;
    border: 0;
    box-shadow: none;
    transform: none !important;
    break-after: avoid;
    page-break-after: avoid;
  }
}

/* ICP filing display (津ICP备2026012447号) */
.icp-footer {
  display: block;
  width: 100%;
  margin: 14px auto 24px;
  padding: 0 16px;
  box-sizing: border-box;
  text-align: center;
  font-size: 11px;
  line-height: 1.6;
  color: #8a8f98;
}

.icp-footer a {
  color: inherit !important;
  text-decoration: none !important;
  font-size: inherit;
}

.icp-footer a:hover {
  color: #6f747d;
  text-decoration: none !important;
}

/* 公安备案号分隔符（2026-09-16） */
.icp-footer .icp-sep { margin: 0 4px; opacity: 0.6; }
