:root {
  --bg-deep: #09080c;
  --bg-card: rgba(20, 17, 24, 0.76);
  --gold-light: #f3dfb9;
  --gold-main: #d6b174;
  --gold-dark: #9e7940;
  --text-main: #f7f3eb;
  --text-sub: rgba(247, 243, 235, 0.72);
  --danger: #ff8a8a;
}

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

html, body {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

img {
  -webkit-touch-callout: default;
  -webkit-user-drag: none;
  user-select: none;
}

button, input {
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  border: none;
  outline: none;
}

[hidden] {
  display: none !important;
}

/* 表紙ロック画面 */
.lock-screen {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}

.lock-bg {
  position: absolute;
  inset: -6%;
  background-size: cover;
  background-position: center 25%;
  filter: blur(10px) brightness(0.58) saturate(1.1);
  animation: slowBreath 16s ease-in-out infinite alternate;
}

@keyframes slowBreath {
  from { transform: scale(1); }
  to { transform: scale(1.07); }
}

.lock-veil {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(18,14,22,0.28) 0%, rgba(9,8,12,0.86) 100%);
}

.lock-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 380px;
  padding: 36px 26px 32px;
  border-radius: 20px;
  background: var(--bg-card);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid rgba(214, 177, 116, 0.32);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  text-align: center;
}

.brand-logo {
  width: 82%;
  max-width: 260px;
  height: auto;
  margin: 0 auto 10px;
  display: block;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,0.6));
}

.lock-subtitle {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 13px;
  letter-spacing: 0.22em;
  color: var(--gold-light);
  margin-bottom: 26px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap input,
.inline-auth input {
  width: 100%;
  height: 48px;
  padding: 0 64px 0 16px;
  border-radius: 12px;
  background: rgba(8, 7, 11, 0.75);
  border: 1px solid rgba(214, 177, 116, 0.38);
  color: var(--text-main);
  font-size: 16px;
  letter-spacing: 0.06em;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.inline-auth input {
  padding: 0 14px;
  height: 44px;
  font-size: 15px;
}

.input-wrap input:focus,
.inline-auth input:focus {
  border-color: var(--gold-light);
  box-shadow: 0 0 0 3px rgba(214, 177, 116, 0.18);
}

.pw-toggle {
  position: absolute;
  right: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--gold-light);
  font-size: 12px;
  cursor: pointer;
}

.gold-btn {
  height: 48px;
  padding: 0 22px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ebd2a3 0%, #c79c57 55%, #9e7535 100%);
  color: #1a1308;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.1em;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(199, 156, 87, 0.3);
  transition: transform 0.15s, opacity 0.2s;
}

.gold-btn.compact {
  height: 44px;
  padding: 0 16px;
  white-space: nowrap;
  font-size: 14px;
}

.gold-btn:active {
  transform: scale(0.98);
}

.error-msg {
  font-size: 13px;
  line-height: 1.5;
  color: var(--danger);
  margin-top: 4px;
}

/* メインビューア＆上部バー */
.viewer-screen {
  position: relative;
  width: 100%;
  height: 100%;
}

.top-hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 14px;
  background: linear-gradient(to bottom, rgba(6, 5, 9, 0.72) 0%, rgba(6, 5, 9, 0) 100%);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

body.ui-hidden .top-hud,
body.ui-hidden .prologue-logo,
body.ui-hidden .slide-floating-ui,
body.ui-hidden .final-msg-wrap {
  opacity: 0 !important;
  pointer-events: none !important;
}

.hud-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(15, 13, 20, 0.64);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(214, 177, 116, 0.34);
  color: var(--gold-light);
  font-size: 12px;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.hud-chapter {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 13px;
  letter-spacing: 0.16em;
  color: var(--gold-light);
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-counter {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-sub);
  text-shadow: 0 2px 6px rgba(0,0,0,0.9);
}

/* 縦吸着スライド */
.slides-root {
  width: 100%;
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.slides-root::-webkit-scrollbar {
  display: none;
}

.slide {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg-deep);
}

.slide-ambient {
  position: absolute;
  inset: -8%;
  background-size: cover;
  background-position: center;
  filter: blur(26px) brightness(0.38) saturate(1.15);
  pointer-events: none;
}

.photo-frame {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  max-width: 58vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-aspect-ratio: 3/4) {
  .photo-frame {
    max-width: 100%;
  }
}

.photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-frame.is-landscape {
  max-width: 100%;
  padding: 0;
}

.photo-frame.is-landscape .photo-img {
  width: 100%;
  height: auto;
  max-height: 82%;
  object-fit: contain;
  box-shadow: 0 18px 50px rgba(0,0,0,0.7);
}

/* n_01 グアム導入パノラマ演出 */
.photo-frame.is-prologue {
  max-width: 100%;
}

.photo-frame.is-prologue .photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 86% 58%;
  transition: object-position 6.5s cubic-bezier(0.22, 0.08, 0.24, 1);
}

.slide.is-active .photo-frame.is-prologue:not(.fit-mode) .photo-img {
  object-position: 16% 58%;
}

.photo-frame.is-prologue.fit-mode .photo-img {
  height: auto;
  max-height: 82%;
  object-fit: contain;
  object-position: center;
  transition: none;
}

.prologue-logo {
  right: auto;
  bottom: auto;
  position: absolute;
  top: calc(58px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  width: 64%;
  max-width: 230px;
  pointer-events: none;
  filter: drop-shadow(0 6px 18px rgba(0,0,0,0.75));
  transition: opacity 0.6s ease;
}

.slide-floating-ui {
  position: absolute;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  left: 0;
  right: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.slide-floating-ui button {
  pointer-events: auto;
}

.swipe-hint {
  font-size: 12px;
  letter-spacing: 0.15em;
  color: rgba(247, 243, 235, 0.85);
  text-shadow: 0 2px 8px rgba(0,0,0,0.9);
  animation: floatUp 2.2s ease-in-out infinite;
}

@keyframes floatUp {
  0%, 100% { transform: translateY(0); opacity: 0.72; }
  50% { transform: translateY(-5px); opacity: 1; }
}

/* 章扉スライド */
.divider-card {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 40px 28px;
  max-width: 340px;
}

.divider-sub {
  font-size: 12px;
  letter-spacing: 0.32em;
  color: var(--gold-main);
  margin-bottom: 14px;
}

.divider-title {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--gold-light);
  margin-bottom: 18px;
}

.divider-line {
  width: 64px;
  height: 1px;
  margin: 0 auto 18px;
  background: linear-gradient(90deg, transparent, var(--gold-main), transparent);
}

.divider-desc {
  font-size: 13px;
  line-height: 1.85;
  color: var(--text-sub);
  letter-spacing: 0.06em;
}

/* 未解放ランク用の封印扉 */
.gate-card {
  position: relative;
  z-index: 3;
  width: calc(100% - 40px);
  max-width: 360px;
  padding: 32px 24px;
  border-radius: 20px;
  background: rgba(16, 13, 20, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(214, 177, 116, 0.36);
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.65);
}

.gate-seal-preview {
  width: 82px;
  height: 82px;
  object-fit: contain;
  margin: 0 auto 14px;
  display: block;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,0.6));
}

.gate-title {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 20px;
  letter-spacing: 0.12em;
  color: var(--gold-light);
  margin-bottom: 12px;
}

.gate-desc {
  font-size: 13px;
  line-height: 1.75;
  color: var(--text-sub);
  margin-bottom: 20px;
}

.inline-auth {
  display: flex;
  gap: 8px;
}

/* 袋とじ開封ギミック */
.fukuro-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.fukuro-half {
  position: absolute;
  left: 0;
  right: 0;
  height: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(44, 33, 24, 0.94), rgba(13, 11, 16, 0.98));
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  transition: transform 0.85s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.75s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.fukuro-top {
  top: 0;
  justify-content: flex-end;
  padding-bottom: 58px;
  border-bottom: 1px dashed rgba(214, 177, 116, 0.45);
}

.fukuro-bottom {
  bottom: 0;
  justify-content: flex-start;
  padding-top: 62px;
  border-top: 1px dashed rgba(214, 177, 116, 0.45);
}

.fukuro-overlay.opened {
  pointer-events: none;
}

.fukuro-overlay.opened .fukuro-top {
  transform: translateY(-106%) rotate(-1.5deg);
  opacity: 0;
}

.fukuro-overlay.opened .fukuro-bottom {
  transform: translateY(106%) rotate(1.5deg);
  opacity: 0;
}

.fukuro-overlay.opened .tear-zone {
  opacity: 0;
  transform: scale(1.08);
  pointer-events: none;
}

.fukuro-badge {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--gold-main);
  margin-bottom: 10px;
}

.fukuro-heading {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 22px;
  letter-spacing: 0.16em;
  color: var(--gold-light);
}

.fukuro-guide {
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--gold-light);
}

.tear-zone {
  position: relative;
  z-index: 12;
  width: min(88%, 360px);
  height: 96px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  touch-action: none;
  cursor: ew-resize;
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.tear-line-bg {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  border-top: 2px dashed rgba(243, 223, 185, 0.55);
}

.tear-line-cut {
  position: absolute;
  left: 0;
  height: 4px;
  width: 0%;
  border-radius: 4px;
  background: linear-gradient(90deg, #fff6df, #f0c97d, #ffffff);
  box-shadow: 0 0 16px 3px rgba(243, 205, 130, 0.9);
}

.tear-seal {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 84px;
  height: 84px;
  transform: translate(-50%, -50%);
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,0.75));
  transition: transform 0.25s ease;
}

.tear-knob {
  position: absolute;
  left: 0%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff5dc 0%, #d8b272 75%);
  box-shadow: 0 0 20px rgba(243, 210, 145, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1d1406;
  font-size: 16px;
  font-weight: 700;
  pointer-events: none;
}

/* 袋とじ最終カット s_03 手書きメッセージ浮上 */
.final-msg-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 56px 20px calc(34px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, rgba(7, 6, 10, 0.78) 0%, rgba(7, 6, 10, 0.32) 60%, transparent 100%);
  display: flex;
  justify-content: center;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 1.4s ease, transform 1.4s ease;
  pointer-events: none;
}

.slide.msg-visible .final-msg-wrap {
  opacity: 1;
  transform: translateY(0);
}

.final-msg-img {
  width: min(86%, 340px);
  height: auto;
  filter: drop-shadow(0 3px 12px rgba(0, 0, 0, 0.92));
}

/* 目次ドロワー（カスタムスクロールバー完備） */
.drawer-wrap {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 3, 7, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.drawer-sheet {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 520px;
  max-height: 82vh;
  max-height: 82dvh;
  border-radius: 22px 22px 0 0;
  background: #141119;
  border-top: 1px solid rgba(214, 177, 116, 0.36);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.drawer-title {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 18px;
  color: var(--gold-light);
}

.rank-badge {
  font-size: 12px;
  color: var(--gold-main);
  margin-top: 4px;
}

.drawer-body {
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dark) rgba(255, 255, 255, 0.05);
}

.drawer-body::-webkit-scrollbar {
  width: 5px;
}

.drawer-body::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
}

.drawer-body::-webkit-scrollbar-thumb {
  background: var(--gold-dark);
  border-radius: 4px;
}

.chapter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chapter-pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(214, 177, 116, 0.12);
  border: 1px solid rgba(214, 177, 116, 0.34);
  color: var(--gold-light);
  font-size: 12px;
  cursor: pointer;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.thumb-item {
  position: relative;
  aspect-ratio: 9 / 16;
  border-radius: 8px;
  overflow: hidden;
  background: #1f1b26;
  border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-num {
  position: absolute;
  bottom: 4px;
  right: 5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0,0,0,0.68);
  color: #fff;
  font-size: 10px;
}

.upgrade-box {
  padding: 16px;
  border-radius: 14px;
  background: rgba(214, 177, 116, 0.07);
  border: 1px solid rgba(214, 177, 116, 0.25);
  margin-bottom: 18px;
}

.upgrade-label {
  font-size: 13px;
  color: var(--gold-light);
  margin-bottom: 10px;
}

.drawer-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sub-btn {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text-sub);
  font-size: 13px;
  cursor: pointer;
}

/* 拡大鑑賞モーダル */
.zoom-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(5, 4, 8, 0.97);
  display: flex;
  flex-direction: column;
}

.zoom-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.75), transparent);
}

.zoom-hint {
  font-size: 12px;
  color: var(--text-sub);
}

.zoom-actions {
  display: flex;
  gap: 8px;
}

.zoom-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

#zoom-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  will-change: transform;
}
