:root {
  --blue-deep: #07549a;
  --blue-main: #1374c3;
  --blue-soft: #dff3ff;
  --gold: #d3a33d;
  --gold-light: #ffe6a0;
  --white: #ffffff;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }

body {
  overflow: hidden;
  font-family: "Sarabun", system-ui, sans-serif;
  background: #cfeaff;
  opacity: 0;
  animation: page-in 1s ease forwards;
}

.royal-landing {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 620px;
  overflow: hidden;
  isolation: isolate;
}

.background {
  position: absolute;
  inset: 0;
  z-index: -5;
  background: url("../images/bg.webp") center center / cover no-repeat;
  transform: scale(1.015);
}

.soft-light {
  position: absolute;
  inset: 0;
  z-index: -4;
  pointer-events: none;
  background:
    radial-gradient(circle at 47% 34%, rgba(255,255,255,.74), rgba(255,255,255,0) 34%),
    linear-gradient(90deg, rgba(255,255,255,.18), rgba(255,255,255,0) 48%, rgba(14,107,188,.08));
}

.sparkles {
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  opacity: .34;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.95) 0 1px, transparent 2px),
    radial-gradient(circle, rgba(255,224,139,.9) 0 1px, transparent 2px);
  background-size: 190px 190px, 270px 270px;
  background-position: 30px 25px, 120px 85px;
  animation: twinkle 6s ease-in-out infinite alternate;
}

.monogram {
  position: absolute;
  top: clamp(28px, 5.8vh, 68px);
  left: clamp(30px, 8vw, 145px);
  width: clamp(68px, 7vw, 112px);
  max-height: 150px;
  z-index: 5;
  filter: drop-shadow(0 5px 10px rgba(21,75,122,.22));
}

.portrait-stage {
  position: absolute;
  right: clamp(-46px, .5vw, 14px);
  bottom: clamp(78px, 9vh, 102px);
  width: min(66vw, 1010px);
  z-index: 2;
}

.portrait-glow {
  position: absolute;
  left: 53%;
  top: 40%;
  width: 59%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.62), rgba(177,222,255,.28) 45%, transparent 72%);
  filter: blur(13px);
  z-index: -1;
}

.portrait {
  display: block;
  width: 100%;
  height: auto;
  filter:
    drop-shadow(0 0 24px rgba(255,255,255,.44))
    drop-shadow(0 16px 28px rgba(20,95,155,.18));
}

.tribute-panel {
  position: absolute;
  left: clamp(48px, 9vw, 175px);
  top: 50%;
  width: min(55vw, 860px);
  transform: translateY(-46%) scale(.94);
  transform-origin: center;
  text-align: center;
  z-index: 4;
  color: var(--blue-deep);
  text-shadow: 0 2px 12px rgba(255,255,255,.74);
}

.pre-title {
  margin: 0 0 4px;
  font-family: "Noto Serif Thai", serif;
  font-size: clamp(16px, 1.25vw, 21px);
  font-weight: 500;
  color: #236aa8;
  letter-spacing: .02em;
}

.date {
  margin: 0 0 8px;
  font-family: "Noto Serif Thai", serif;
  font-size: clamp(27px, 2.7vw, 45px);
  font-weight: 600;
  color: #1769af;
  line-height: 1.1;
}

h1 {
  margin: 0;
  font-family: "Noto Serif Thai", serif;
  font-size: clamp(43px, 5.2vw, 80px);
  font-weight: 600;
  line-height: 1.02;
  color: #1163aa;
  letter-spacing: .01em;
  text-shadow: 0 3px 0 rgba(255,255,255,.75), 0 7px 22px rgba(21,98,161,.15);
}

.main-text {
  margin: 13px 0 2px;
  font-family: "Noto Serif Thai", serif;
  font-size: clamp(19px, 1.75vw, 28px);
  font-weight: 500;
  line-height: 1.32;
}

.royal-name {
  margin: 0 auto;
  max-width: 720px;
  font-family: "Noto Serif Thai", serif;
  font-size: clamp(19px, 1.7vw, 27px);
  font-weight: 500;
  line-height: 1.36;
}

.ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(420px, 78%);
  margin: 15px auto 11px;
  color: var(--gold);
}

.ornament span {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold));
}
.ornament span:last-child { transform: scaleX(-1); }
.ornament b { font-size: 20px; font-weight: 400; }

.with-respect {
  margin: 0 0 3px;
  font-family: "Noto Serif Thai", serif;
  font-size: clamp(17px, 1.35vw, 22px);
  font-weight: 600;
}

.org-label {
  margin: 0 auto;
  max-width: 650px;
  font-family: "Noto Serif Thai", serif;
  font-size: clamp(15px, 1.12vw, 19px);
  line-height: 1.45;
}

.enter-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 220px;
  margin-top: 17px;
  padding: 12px 31px 13px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.92);
  border-radius: 999px;
  color: #fffdf2;
  font-size: clamp(16px, 1.2vw, 19px);
  font-weight: 600;
  text-decoration: none;
  background: linear-gradient(180deg, #efcb6d 0%, #c6952f 52%, #9b6a17 100%);
  box-shadow: 0 9px 24px rgba(22,91,149,.22), inset 0 1px 0 rgba(255,255,255,.75);
  text-shadow: 0 1px 2px rgba(94,56,0,.55);
  transition: transform .2s ease, filter .2s ease;
}

.enter-btn::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 -70%;
  width: 45%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.62), transparent);
  transform: skewX(-18deg);
  animation: shine 4.8s ease-in-out infinite;
}

.enter-btn:hover { transform: translateY(-2px); filter: brightness(1.06); }
.enter-btn:active { transform: translateY(0); }

@keyframes page-in { to { opacity: 1; } }
@keyframes twinkle { from { opacity: .25; transform: translateY(0); } to { opacity: .48; transform: translateY(-5px); } }
@keyframes shine { 0%, 58% { left: -70%; } 85%, 100% { left: 135%; } }

/* Notebook / จอเตี้ย */
@media (max-height: 760px) and (min-width: 901px) {
  .royal-landing { min-height: 540px; }
  .portrait-stage { width: min(58vw, 815px); right: -30px; bottom: 58px; }
  .tribute-panel { top: 48%; transform: translateY(-44%) scale(.9); transform-origin: center left; }
  .monogram { top: 24px; width: 74px; }
}

/* Tablet แนวนอน */
@media (max-width: 1180px) and (min-width: 769px) {
  .portrait-stage { width: min(68vw, 785px); right: -90px; bottom: clamp(48px, 6vh, 68px); }
  .tribute-panel { left: 5vw; width: 49vw; }
  .monogram { left: 5vw; width: 76px; }
}

/* Tablet แนวตั้ง / Mobile */
@media (max-width: 768px) {
  body { overflow: auto; }
  .royal-landing { min-height: 100svh; height: 100svh; }
  .background { background-position: 47% center; }
  .soft-light {
    background:
      linear-gradient(to bottom, rgba(255,255,255,.1), rgba(255,255,255,.12) 40%, rgba(232,247,255,.9) 70%, rgba(223,243,255,.98)),
      radial-gradient(circle at 50% 23%, rgba(255,255,255,.66), transparent 38%);
  }
  .monogram {
    top: max(18px, env(safe-area-inset-top));
    left: 22px;
    width: clamp(54px, 16vw, 78px);
  }
  .portrait-stage {
    top: 7vh;
    right: 50%;
    bottom: auto;
    width: min(112vw, 690px);
    transform: translateX(50%);
  }
  .portrait { width: 100%; }
  .tribute-panel {
    left: 50%;
    top: auto;
    bottom: max(22px, env(safe-area-inset-bottom));
    width: min(92vw, 590px);
    transform: translateX(-50%);
    padding: 0 8px;
  }
  .pre-title { display: none; }
  .date { margin-bottom: 4px; font-size: clamp(22px, 6.6vw, 34px); }
  h1 { font-size: clamp(38px, 11.5vw, 58px); }
  .main-text { margin-top: 7px; font-size: clamp(16px, 4.4vw, 22px); }
  .royal-name { font-size: clamp(16px, 4.3vw, 21px); line-height: 1.3; }
  .ornament { margin: 8px auto 6px; }
  .with-respect { font-size: clamp(15px, 4vw, 19px); }
  .org-label { font-size: clamp(13px, 3.45vw, 17px); line-height: 1.34; }
  .enter-btn { min-width: 190px; margin-top: 10px; padding: 10px 24px 11px; }
}

/* มือถือจอเตี้ย */
@media (max-width: 480px) and (max-height: 740px) {
  .portrait-stage { top: 4vh; width: 105vw; }
  .tribute-panel { bottom: 12px; transform: translateX(-50%) scale(.91); transform-origin: bottom center; width: 98vw; }
  .monogram { width: 50px; top: 12px; left: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
