* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  font-family: "Huninn", sans-serif;
  background: #dff4fc;
  color: #686868;
}

button, input {
  font: inherit;
}

/*
  第一頁使用 1290 × 2796 的固定比例設計座標系。
  background_1.png 與所有文字／圖片都放在同一個 .page 座標系內。
  因此螢幕尺寸改變時，元素與底圖的相對位置維持不變。
*/
 .page {
  position: relative;
  width: min(100%, 600px);
  margin: 0 auto;
  aspect-ratio: 1290 / 2796;
  overflow: hidden;
  /* 讓所有 cqw 尺寸都以第一頁 .page 的寬度為基準 */
  container-type: inline-size;
  background: #dff4fc;
}

.page::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("assets/background_1.png") center top / 100% 100% no-repeat;
  pointer-events: none;
}

.first-page-content {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.first-page-content {
  position: absolute;
  inset: 0;
}

/* 標題：上 785px、右 160px */
.page-title {
  position: absolute;
  margin: 0;
  color: #a5657d;
  font-size: clamp(26px, 3.72vw, 48px);
  font-size: 5.4cqw;
  font-weight: 1000;
  line-height: 1.5;
  white-space: nowrap;
  text-align: right;
  margin-top: -6px;
  margin-right: 5px;
}

.title-en {
  font-family: "Ubuntu", sans-serif;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.title-zh {
  margin-left: 0.28em;
  font-family: "Huninn", sans-serif;
  font-weight: 500;
}

/* 名字區：上 1217px、左 308px */
.name-area {
  position: absolute;
  top: 43.526467%;
  left: 23.875969%;
  width: 50%;
  height: 8%;
  margin-top: -20px;
}

.name-label {
  position: absolute;
  top: -4px;
  left: 0;
  margin: 0;
  color: #939393;
  font-family: "Huninn", sans-serif;
  font-size: clamp(20px, 2.48vw, 32px);
  font-size: 3.8cqw;
  font-weight: 400;
  line-height: 1.35;
  white-space: nowrap;
}

.name-input {
  position: absolute;
  top: -2%;
  left: 41%;
  width: 69%;
  height: 3.35cqw;
  min-height: 0;
  padding: 0 4px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #686868;
  font-family: "Huninn", sans-serif;
  font-size: clamp(20px, 2.48vw, 32px);
  font-size: 3.8cqw;
  font-weight: 400;
  line-height: 1.35;
  text-align: left;
  caret-color: #686868;
}

.name-input:focus {
  outline: none;
}

/* 顯示「請輸入你的名字」時，不讓輸入框的游標與提示文字重疊。
   開始輸入後，script.js 會清除 error-message，游標會自動恢復。 */
.name-area:has(.error-message:not(:empty)) .name-input {
  caret-color: transparent;
}

/* 錯誤訊息：仍放在原本輸入名字的空白區，不會改變後續資料儲存邏輯 */
.error-message {
  position: absolute;
  top: -4.5px;
  left: 35%;
  width: 69%;
  margin: 0;
  min-height: 1.35em;
  color: #b95454;
  font-family: "Huninn", sans-serif;
  font-size: clamp(16px, 2.05vw, 26px);
  font-size: 3.8cqw;
  font-weight: 400;
  line-height: 1.35;
  pointer-events: none;
  white-space: nowrap;
}

/* 一開始的「點擊此處開始」 */
.error-message.start-hint {
  color: #b8b8b8;
}
/* 下一頁按鍵：上 1217px、右 294px，沿用原本 next-arrow.png */
.next-button {
  position: absolute;
  top: 40.526467%;
  right: 22.790698%;
  width: clamp(50px, 11vw, 68px);
  width: 6cqw;
  aspect-ratio: 1;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: transform .15s ease;
  z-index: 10;
}

.next-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.next-button:active {
  transform: scale(.9);
}

/* 四個裝飾圖 */
.decorations {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.deco {
  position: absolute;
  width: 23.255814%; /* 300 / 1290 */
  height: auto;
  object-fit: contain;
  transform-origin: center center;
}

.deco-s1 {
  top: 52%;
  right: 2%;
  animation: gentle-sway-1 3.8s ease-in-out infinite;
}

.deco-s2 {
  top: 65%;
  right: 70%;
  animation: gentle-sway-2 4.2s ease-in-out infinite;
}

.deco-s3 {
  top: 77%;
  right: 80%;
  animation: gentle-sway-3 3.6s ease-in-out infinite;
}

/* explain：上約 2258px、右 203px，原尺寸 833 × 582，向右 10.4° */
.explain-wrap {
  position: absolute;
  top: 72%;
  right: -5%;
  width: 64.573643%; /* 833 / 1290 */
  aspect-ratio: 833 / 582;
  transform: rotate(10.4deg);
  transform-origin: center center;
  z-index: 3;
}

.explain-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 30 字說明文字，跟 explain.png 同樣旋轉 10.4°，並限制在圖檔範圍內 */
.explain-text {
  position: absolute;
  top: 50%;
  left: 10%;
  width: 80%;
  margin: 0;
  transform: translateY(-50%);
  color: #686868;
  font-family: "Huninn", sans-serif;
  font-size: clamp(15px, 2.05vw, 26px);
  font-size: 2.05cqw;
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0.02em;
  text-align: center;
  overflow-wrap: anywhere;
}

/* s4 必須位於 explain.png 之上 */
.deco-s4 {
  top: 87%;
  right: 0%;
  z-index: 5;
  animation: gentle-sway-4 4s ease-in-out infinite;
}

@keyframes gentle-sway-1 {
  0%, 100% { transform: translateX(-0.5cqw) rotate(-1.5deg); }
  50% { transform: translateX(0.5cqw) rotate(1.5deg); }
}

@keyframes gentle-sway-2 {
  0%, 100% { transform: translateX(0.5cqw) rotate(1.3deg); }
  50% { transform: translateX(-0.5cqw) rotate(-1.3deg); }
}

@keyframes gentle-sway-3 {
  0%, 100% { transform: translateX(-0.35cqw) rotate(-1.7deg); }
  50% { transform: translateX(0.35cqw) rotate(1.7deg); }
}

@keyframes gentle-sway-4 {
  0%, 100% { transform: translateX(0.35cqw) rotate(1.4deg); }
  50% { transform: translateX(-0.35cqw) rotate(-1.4deg); }
}

@media (prefers-reduced-motion: reduce) {
  .deco { animation: none; }
  .next-button { transition: none; }
}
