/* ========================= base ========================= */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  background: #1c2a1c;
  font-family: 'Klee One', '游教科書体', 'YuKyokasho Yoko', 'Hiragino Maru Gothic ProN',
               'Hiragino Sans', 'Yu Gothic', sans-serif;
  color: #3b3026;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}
body { position: fixed; inset: 0; }

button { font: inherit; }

/* ========================= screens ========================= */
.screen {
  position: absolute;
  inset: 0;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.4s ease;
  background: url(background/background1.jpg) center/cover;
}
.screen.active { visibility: visible; opacity: 1; }

/* ========================= title screen ========================= */
#screen-title { display: flex; align-items: center; justify-content: center; }
.title-card {
  position: relative;
  text-align: center;
  background: rgba(255, 250, 235, 0.92);
  border-radius: 24px;
  padding: clamp(24px, 5vw, 60px) clamp(40px, 9vw, 100px);
  box-shadow: 0 10px 36px rgba(0,0,0,0.25), inset 0 0 0 6px rgba(244,210,195,0.6);
  animation: titleFloat 4s ease-in-out infinite;
}
.title-card h1 {
  font-size: clamp(40px, 8vw, 96px);
  margin: 0;
  color: #d24a78;
  letter-spacing: 0.05em;
  text-shadow: 2px 2px 0 #fff5d8, 4px 4px 8px rgba(0,0,0,0.15);
}
.title-card .sub {
  font-size: clamp(16px, 2.4vw, 28px);
  color: #6c5340; margin: 8px 0 0;
}
.title-card .tap {
  margin-top: clamp(20px, 3vw, 40px);
  font-size: clamp(14px, 2vw, 22px);
  color: #b3795a;
  animation: blink 1.4s ease-in-out infinite;
}
@keyframes titleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.title-sparkle {
  position: absolute; inset: -20px;
  pointer-events: none;
  background:
    radial-gradient(circle 4px at 12% 18%, #fff 30%, transparent 40%),
    radial-gradient(circle 3px at 88% 22%, #fff 30%, transparent 40%),
    radial-gradient(circle 5px at 78% 88%, #fff 30%, transparent 40%),
    radial-gradient(circle 3px at 18% 78%, #fff 30%, transparent 40%),
    radial-gradient(circle 4px at 50% 5%, #fff 30%, transparent 40%);
  animation: sparkle 2.2s linear infinite;
}
@keyframes sparkle {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.3; }
}

/* ========================= game screen ========================= */
#screen-game { background: url(background/background1.jpg) center/cover; }

#scrapbook-frame {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#zoom-pan {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  transform-origin: 0 0;
  touch-action: none;
  will-change: transform;
}
#scrapbook-stage {
  position: absolute; inset: 0;
  background: url(Book/Book1.png) no-repeat center / 100% 100%;
}

/* photos */
.photo {
  position: absolute;
  transform-origin: center center;
  filter: drop-shadow(2px 3px 5px rgba(0,0,0,0.25));
}
.photo img {
  width: 100%; height: 100%;
  display: block;
  object-fit: cover;
  border: 3px solid #fffaf0;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
  pointer-events: none;
}

/* debug hit areas */
.hit-debug {
  position: absolute;
  background: rgba(255, 30, 30, 0.35);
  border: 1px dashed rgba(255,30,30,0.8);
  pointer-events: none;
}

/* message area on scrapbook */
#message-area {
  position: absolute;
  background: url(UI/Message1.png) no-repeat center / 100% 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6%;
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
}
#message-area .msg-text {
  font-size: clamp(8px, 1.3vw, 16px);
  color: #6f3a2a;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
#message-area .msg-text span {
  display: inline-block;
  opacity: 0;
  transform: translateY(8px) rotate(-3deg);
}
#message-area .msg-text span.show {
  animation: charPop 0.45s ease forwards;
}
@keyframes charPop {
  0% { opacity: 0; transform: translateY(8px) rotate(-3deg); }
  60% { opacity: 1; transform: translateY(-2px) rotate(2deg); }
  100% { opacity: 1; transform: translateY(0) rotate(0); }
}

/* ========================= find list ========================= */
#findlist {
  position: fixed;
  top: 12px; right: 12px;
  width: clamp(160px, 26vw, 260px);
  max-height: calc(100vh - 24px);
  padding: 14px 16px 16px;
  background: rgba(252, 247, 232, 0.94);
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.22), inset 0 0 0 3px rgba(244,210,195,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10;
  pointer-events: none; /* let taps pass through to scrapbook */
  transform: scale(0.667);
  transform-origin: top right;
}
#findlist h2 {
  margin: 0 0 8px;
  font-size: clamp(14px, 1.8vw, 20px);
  color: #b3705a;
  text-align: center;
  border-bottom: 2px dotted #d6b89e;
  padding-bottom: 4px;
}
#find-items {
  list-style: none; margin: 0; padding: 0;
  font-size: clamp(11px, 1.5vw, 17px);
}
#find-items li {
  display: flex; align-items: center;
  gap: 6px;
  padding: 4px 2px;
  color: #5a4632;
  transition: color 0.4s, opacity 0.4s;
}
#find-items li .box {
  display: inline-block;
  width: 1em; height: 1em;
  border: 2px solid #b3705a;
  border-radius: 3px;
  background: #fffdf6;
  position: relative;
  flex: 0 0 auto;
  transition: background 0.3s;
}
#find-items li.found {
  color: #d24a78;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  opacity: 0.85;
  animation: foundFlash 0.6s ease;
}
#find-items li.found .box {
  background: #ffd6e3;
}
#find-items li.found .box::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1em;
  line-height: 1;
  color: #d24a78;
  font-weight: bold;
}
@keyframes foundFlash {
  0% { transform: scale(1); }
  30% { transform: scale(1.08); background: rgba(255, 220, 230, 0.6); border-radius: 6px; }
  100% { transform: scale(1); }
}

/* ========================= next page button ========================= */
#next-page {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 28px;
  background: rgba(255, 230, 200, 0.95);
  color: #b34a78;
  border: 3px solid #b34a78;
  border-radius: 30px;
  font-size: clamp(14px, 2vw, 20px);
  font-weight: bold;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  cursor: pointer;
  z-index: 12;
  animation: blink 1.4s ease-in-out infinite;
}
#next-page.hidden { display: none; }

/* ========================= ED screen ========================= */
#screen-ed { display: flex; align-items: center; justify-content: center; }
.ed-card {
  position: relative;
  text-align: center;
  background: rgba(255, 250, 235, 0.94);
  border-radius: 22px;
  padding: clamp(28px, 5vw, 60px) clamp(40px, 9vw, 100px);
  box-shadow: 0 10px 32px rgba(0,0,0,0.22);
}
.ed-card h1 {
  margin: 0;
  font-size: clamp(36px, 7vw, 72px);
  color: #d24a78;
  text-shadow: 2px 2px 0 #fff5d8;
}
.ed-card .sub {
  font-size: clamp(16px, 2.4vw, 28px);
  color: #6c5340;
  margin: 14px 0 26px;
}
#back-title {
  padding: 10px 26px;
  background: #fff;
  color: #b3705a;
  border: 2px solid #b3705a;
  border-radius: 24px;
  font-size: clamp(13px, 1.7vw, 18px);
  cursor: pointer;
}

/* ========================= page flip overlay ========================= */
#page-flip-overlay {
  position: fixed; inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, #fffdf6 0%, #f4e2c8 60%, #c2a17c 100%);
  transform-origin: left center;
  transform: perspective(1200px) rotateY(0deg);
  opacity: 0;
  z-index: 100;
  box-shadow: 6px 0 20px rgba(0,0,0,0.4);
}
#page-flip-overlay.flipping {
  animation: pageFlip 0.85s ease-in-out forwards;
}
@keyframes pageFlip {
  0%   { opacity: 0; transform: perspective(1200px) rotateY(0deg);   transform-origin: left center; }
  10%  { opacity: 1; transform: perspective(1200px) rotateY(0deg);   transform-origin: left center; }
  60%  { opacity: 1; transform: perspective(1200px) rotateY(-170deg); transform-origin: left center; }
  100% { opacity: 0; transform: perspective(1200px) rotateY(-180deg); transform-origin: left center; }
}

/* ========================= star particle ========================= */
.star-particle {
  position: fixed;
  font-size: 22px;
  color: #ffe680;
  text-shadow: 0 0 6px #fff5a0, 0 0 12px #ffce5b;
  pointer-events: none;
  z-index: 50;
  will-change: transform, opacity;
}
.glitter-particle {
  position: absolute;
  width: 10px; height: 10px;
  background: radial-gradient(circle, #fff 0%, #fff5a0 40%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 8;
  will-change: transform, opacity;
}

/* ========================= orientation prompt ========================= */
#orientation-prompt {
  position: fixed; inset: 0;
  background: rgba(20, 30, 20, 0.96);
  color: #fff5d8;
  display: none;
  align-items: center; justify-content: center;
  z-index: 1000;
  text-align: center;
}
#orientation-prompt .op-inner { padding: 30px; }
#orientation-prompt .op-icon {
  font-size: 64px;
  animation: rotateHint 2s ease-in-out infinite;
}
#orientation-prompt p {
  font-size: 18px;
  margin: 14px 0 0;
}
@keyframes rotateHint {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-90deg); }
}
@media (orientation: portrait) {
  #orientation-prompt { display: flex; }
}

/* ========================= clear effect zoom ========================= */
#zoom-pan.clear-zoom {
  transition: transform 1.0s ease-in-out;
}
