body {
  margin: 0;
  padding: 20px;
  font-family: "KaiTi", "楷体", serif;
  background: linear-gradient(to right, #f0f2f5, #e2e6ec);
  color: #222;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header h1 {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 40px;
  font-weight: 600;
  margin-bottom: 30px;
  color: #2c3e50;
}

#input {
  background: #fafafa;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

textarea {
  width: 80%;
  height: 200px;
  font-size: 16px;
  margin-bottom: 20px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  resize: vertical;
}

button {
  letter-spacing: 0.5px;
  padding: 10px 20px;
  font-family: inherit;
  font-weight: 600;
  font-size: 18px;
  cursor: pointer;
  background: #0070f3;
  color: white;
  border: none;
  border-radius: 5px;
  margin: 5px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transition: background 0.3s, transform 0.2s;
}

button:hover {
  background: #0055cc;
  transform: scale(1.05);
}

.container {
  width: 100%;
  display: flex;
  justify-content: center;
  overflow: auto;
  margin-top: 0;
  margin-bottom: 0;
}

.page {
  width: 2480px;
  height: 3508px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  page-break-after: always;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: 1.05fr 1fr 1fr 1.05fr;
  row-gap: 8px;
  column-gap: 15px;
  padding: 150px 100px 360px 115px;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
  transform-origin: top center;
  margin-bottom: -30px;
  transform: translateY(-10%);
}

#pageCount.page-count-display {
  margin-top: 30px;
  font-size: 20px;
  font-weight: 500;
  color: #555;
  font-family: 'Segoe UI', sans-serif;
}

.entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: auto;
  width: 100%;
  box-sizing: border-box;
  padding: 4px;
  overflow: visible;
  min-height: 340px;
}

#output {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.page.deceased {
  background-image: url("GongXiu-Deceased.png");
}

.page.regular {
  background-image: url("GongXiu.png");
}

.name-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: auto;
  max-height: 100%;
  overflow: visible;
  margin: 0;
  padding: 0;
}

.name-wrapper.tight-gap {
  padding-top: 5px;
  padding-bottom: 0;
}

.deceased-label {
  font-size: 60px;
  font-weight: bold;
  margin: 0;
  padding: 0;
  line-height: 1;
}

.name {
  margin: 0;
  padding: 0;
  display: block;
  width: 100%;
  line-height: 1;
  text-align: center;
  white-space: pre-line;
  overflow-wrap: break-word;
  overflow: visible;
  font-size: clamp(24px, 5vw, 60px);
  max-height: none;
  box-sizing: border-box;
}

.number {
  font-size: 45px;
  margin: 0;
  margin-top: 30px;
  padding: 0;
  color: #333;
  line-height: 1.5;
  max-height: 15%;
  overflow: visible;
}

.grid-page {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(4, 1fr);
  row-gap: 8px;
  column-gap: 15px;
}

.vertical-deceased {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  gap: 2px;
  margin-bottom: 20px;
}

.vertical-char {
  font-size: 70px;
  line-height: 1;
}

.rotated-bracket {
  display: inline-block;
  transform: rotate(90deg) translateY(-2px);
  transform-origin: center;
  font-size: 80px;
  line-height: 0.5;
  font-weight: 10;
}
