:root {
  --paper: #eee2cc;
  --paper-light: #f7efdf;
  --ink: #211f1b;
  --ink-soft: #544f46;
  --gold: #76591f;
  --gold-highlight: #8a6a2c;
  --shadow: rgba(30, 24, 15, .22);
  --serif: "Noto Serif TC", "Source Han Serif TC", "PMingLiU", "MingLiU", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.65), transparent 28rem),
    #d7d0c3;
  font-family: var(--serif);
}

.page-header {
  width: min(1120px, calc(100% - 32px));
  margin: 36px auto 22px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.page-header h1 { margin: 0 0 7px; font-size: 25px; font-weight: 600; letter-spacing: .12em; }
.page-header p { margin: 0; color: #5f5a51; font-size: 14px; letter-spacing: .06em; }
.header-actions { display: flex; align-items: center; gap: 14px; }
.hint { color: #756d60; font-size: 12px; white-space: nowrap; }
#flip-all {
  padding: 8px 13px;
  border: 1px solid rgba(118,89,31,.55);
  border-radius: 999px;
  color: #4d4029;
  background: rgba(247,239,223,.72);
  font: 600 12px/1 var(--serif);
  letter-spacing: .08em;
  cursor: pointer;
}
#flip-all:hover, #flip-all:focus-visible { background: var(--paper-light); outline: 2px solid rgba(118,89,31,.25); }

.deck {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto 52px;
  display: grid;
  grid-template-columns: repeat(3, 350px);
  gap: 34px;
  justify-content: center;
}

.card-shell { width: 350px; }
.card-caption { margin: 13px 0 0; text-align: center; color: #625d54; font-size: 12px; letter-spacing: .12em; }

.card {
  width: 350px;
  height: 600px;
  position: relative;
  perspective: 1500px;
  cursor: pointer;
  outline: none;
}

.card:focus-visible { filter: drop-shadow(0 0 0.4rem rgba(148,111,39,.65)); }

.card-inner {
  width: 100%; height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .8s cubic-bezier(.2,.75,.2,1);
}

.card.is-flipped .card-inner { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 13px;
  box-shadow: 0 18px 38px var(--shadow), 0 2px 7px rgba(31,23,13,.18);
  backface-visibility: hidden;
  background: var(--paper);
}

.card-back { transform: rotateY(180deg); }
.painting { width: 100%; height: 100%; object-fit: cover; display: block; }
.front-vignette { position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(20,16,11,.28), transparent 19%, transparent 70%, rgba(238,226,204,.94) 100%); }

.front-title-wash {
  position: absolute;
  top: 8px;
  left: 2px;
  width: 310px;
  height: 82px;
  background: radial-gradient(ellipse at 42% 50%, rgba(247,239,223,.88) 0%, rgba(247,239,223,.58) 35%, rgba(247,239,223,.2) 58%, rgba(247,239,223,0) 76%);
  filter: blur(5px);
  opacity: .95;
  pointer-events: none;
}

.foil-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.front-line {
  position: absolute;
  left: 35px; right: 35px; bottom: 59px;
  margin: 0;
  padding: 7px 8px 8px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.65;
  letter-spacing: .12em;
  color: #27231d;
  text-shadow: 0 1px 0 rgba(255,255,255,.65);
  background: radial-gradient(ellipse at center, rgba(247,239,223,.92) 0%, rgba(247,239,223,.68) 58%, rgba(247,239,223,0) 78%);
  border-top: 0;
  border-bottom: 0;
}

.front-line::before,
.front-line::after {
  content: "";
  position: absolute;
  left: 12.5%;
  right: 12.5%;
  height: 1px;
  background: rgba(118,89,31,.55);
}
.front-line::before { top: 0; }
.front-line::after { bottom: 0; }

.paper-back {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 16% 14%, rgba(69,76,70,.12), transparent 18%),
    radial-gradient(ellipse at 88% 73%, rgba(67,75,78,.08), transparent 24%),
    linear-gradient(105deg, rgba(90,74,50,.035), transparent 23%, rgba(255,255,255,.2) 50%, transparent 74%),
    var(--paper-light);
}

.paper-back::after {
  content: ""; position: absolute; inset: 0; opacity: .18; pointer-events: none;
  background-image: repeating-linear-gradient(7deg, transparent 0 10px, rgba(94,76,51,.09) 11px, transparent 12px);
}

.back-copy {
  position: absolute;
  top: 101px;
  right: 53px;
  bottom: 64px;
  left: 53px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  overflow: hidden;
}

.section {
  position: static;
  margin: 0;
  color: #34312c;
  font-size: 9.99px;
  line-height: 1.27;
  letter-spacing: .018em;
  text-align: justify;
  overflow-wrap: anywhere;
}

.screen-label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 3px;
  padding: 0;
  color: var(--gold);
  border-bottom: 0;
  font-size: 10.27px;
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: .08em;
  text-align: left;
}

.screen-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(118,89,31,.32);
}

.classic-text {
  position: relative;
  margin: 0;
  padding: 0 0 0 10px;
  border-left: 0;
  border-bottom: 0;
  background: none;
  color: #211f1b;
}

.classic-text::before,
.yao-text::before,
.s4::before {
  content: "";
  position: absolute;
  left: 0;
  top: 17px;
  bottom: 1px;
  width: 1.5px;
  background: rgba(118,89,31,.62);
}

.classic-text .screen-label,
.yao-text .screen-label,
.s4 .screen-label { margin-left: -10px; }

.classic-text p { margin: 0; }
.classic-text .guaci { font-size: 10.91px; font-weight: 600; line-height: 1.28; letter-spacing: .03em; }
.classic-text .daxiang { margin-top: 1px; font-size: 9.99px; line-height: 1.27; letter-spacing: .018em; }
.classic-text small { display: block; margin-top: 1px; color: #766d5f; font-size: 7.49px; line-height: 1; letter-spacing: .12em; text-align: right; }

.s4 {
  position: relative;
  padding-left: 10px;
  border-left: 0;
  border-bottom: 0;
  background: none;
  color: #201e1a;
  font-size: 10.27px;
  font-weight: 500;
  line-height: 1.28;
}

.yao-text {
  position: relative;
  margin: 0;
  padding: 0 0 0 10px;
  border-left: 0;
  border-bottom: 0;
  background: none;
  color: #3c3831;
  font-size: 9.28px;
  line-height: 1.18;
  letter-spacing: .012em;
}

.yao-line { margin: 0; overflow-wrap: anywhere; }
.yao-line strong { color: var(--gold); font-weight: 700; }
.yao-yong { margin-top: .5em; }

.card.compact .section { font-size: 9.34px; }
.card.compact .screen-label { font-size: 9.6px; }
.card.compact .classic-text .guaci { font-size: 10.2px; }
.card.compact .classic-text .daxiang { font-size: 9.34px; }
.card.compact .classic-text small { font-size: 7px; }
.card.compact .s4 { font-size: 9.6px; }
.card.compact .yao-text { font-size: 8.67px; }

.flip-note { display: none; }

@media (max-width: 1120px) {
  .deck { grid-template-columns: repeat(2, 350px); }
}

@media (max-width: 760px) {
  .page-header { align-items: start; flex-direction: column; }
  .header-actions { align-items: flex-start; flex-direction: column; }
  .deck { grid-template-columns: 350px; }
}

@media (prefers-reduced-motion: reduce) { .card-inner { transition: none; } }

@page { size: 70mm 120mm; margin: 0; }
@media print {
  body { background: white; }
  .page-header, .card-caption { display: none; }
  .deck { display: block; width: auto; margin: 0; }
  .card-shell { width: 70mm; height: 120mm; page-break-after: always; }
  .card { width: 70mm; height: 120mm; }
  .card-face { border-radius: 0; box-shadow: none; }
  .card.is-flipped .card-inner { transform: none; }
}
