* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --indigo-deep: #0a1230;
  --indigo: #16224e;
  --gold: #f5d97a;
  --washi: #f7f2e7;
  --ink: #2a2a33;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--indigo-deep);
  color: var(--washi);
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#sky {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}

/* ---- タイトル ---- */
#title {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  right: 20px;
  display: flex;
  flex-direction: row-reverse; /* h1 を右端、サブタイトルをその左隣に */
  align-items: flex-start;
  gap: 12px;
  max-height: calc(100vh - 40px);
  pointer-events: none;
  z-index: 5;
}
#title h1 {
  font-family: "Yuji Syuku", serif;
  writing-mode: vertical-rl;
  font-size: clamp(28px, 6vmin, 52px);
  letter-spacing: 0.35em;
  color: var(--washi);
  text-shadow: 0 0 18px rgba(245, 217, 122, 0.45);
}
#title .subtitle {
  writing-mode: vertical-rl;
  margin-top: 8px;
  font-size: clamp(11px, 2vmin, 14px);
  color: rgba(247, 242, 231, 0.75);
  letter-spacing: 0.2em;
  max-height: calc(100vh - 60px);
}

#hint {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: 16px;
  font-size: 12px;
  color: rgba(247, 242, 231, 0.55);
  z-index: 5;
  max-width: 46vw;
  line-height: 1.6;
}

/* ---- 星ラベル ---- */
.star-label {
  position: fixed;
  transform: translate(-50%, -140%);
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9);
  cursor: pointer;
  z-index: 4;
  padding: 6px 8px;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  transition: transform 0.18s ease, color 0.18s ease, text-shadow 0.18s ease;
}
.star-label:hover {
  transform: translate(-50%, -140%) scale(1.18);
  color: #fff3c4;
  text-shadow: 0 0 14px rgba(245, 217, 122, 0.95), 0 0 30px rgba(245, 217, 122, 0.5);
  z-index: 5;
}
/* ホバー時の距離チップ */
.star-label::before {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%) translateY(4px);
  background: rgba(10, 18, 48, 0.92);
  border: 1px solid rgba(245, 217, 122, 0.5);
  color: var(--washi);
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.star-label:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.star-label:after {
  content: "";
  display: block;
  width: 1px;
  height: 10px;
  background: rgba(245, 217, 122, 0.5);
  margin: 2px auto 0;
}
.star-label.dim { color: rgba(245, 217, 122, 0.6); font-size: 11px; }

/* ---- 下部 ---- */
#actions {
  position: fixed;
  left: 16px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  z-index: 6;
}
.pill {
  font-family: inherit;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid rgba(247, 242, 231, 0.35);
  background: rgba(10, 18, 48, 0.55);
  color: var(--washi);
  backdrop-filter: blur(6px);
  cursor: pointer;
}
.pill:hover {
  border-color: rgba(245, 217, 122, 0.75);
  background: rgba(22, 34, 78, 0.75);
  box-shadow: 0 0 14px rgba(245, 217, 122, 0.25);
}
.pill:active { transform: scale(0.96); }

#wish-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom));
  width: min(560px, calc(100vw - 32px));
  display: flex;
  gap: 8px;
  z-index: 6;
}
#wish-input {
  flex: 1;
  font-family: inherit;
  font-size: 16px;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid rgba(245, 217, 122, 0.45);
  background: rgba(10, 18, 48, 0.7);
  color: var(--washi);
  outline: none;
  backdrop-filter: blur(8px);
}
#wish-input::placeholder { color: rgba(247, 242, 231, 0.45); }
#wish-send {
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  padding: 0 22px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(160deg, #f5d97a, #e0b34e);
  color: #3a2c07;
  cursor: pointer;
}
#wish-send:active { transform: scale(0.97); }

/* ---- 短冊 ---- */
#tanzaku-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 3;
}
.tanzaku {
  pointer-events: auto;
  cursor: default;
  position: absolute;
  writing-mode: vertical-rl;
  font-size: 14px;
  line-height: 1.4;
  padding: 14px 7px 18px;
  min-height: 90px;
  max-height: 200px;
  border-radius: 3px 3px 6px 6px;
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  animation: floatUp linear forwards;
  letter-spacing: 0.08em;
  overflow: hidden;
}
.tanzaku:before {
  content: "";
  position: absolute;
  top: 4px;
  left: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
  transform: translateX(-50%);
}
.tanzaku.c0 { background: linear-gradient(#cfe3f7, #b8d4ef); }
.tanzaku.c1 { background: linear-gradient(#f7cfd4, #efb8c0); }
.tanzaku.c2 { background: linear-gradient(#f7eec2, #efdfa0); }
.tanzaku.c3 { background: linear-gradient(#f7f4ec, #ece7da); }
.tanzaku.c4 { background: linear-gradient(#e0d2f0, #cdb8e8); }

/* 動画つき短冊: 最初のフレームが和紙越しに透ける・タップで再生 */
.tanzaku.has-poster {
  cursor: pointer;
  background-image:
    linear-gradient(rgba(247, 242, 231, 0.62), rgba(247, 242, 231, 0.76)),
    var(--poster);
  background-size: cover;
  background-position: center 30%;
  min-height: 130px;
  text-shadow: 0 0 6px rgba(247, 242, 231, 0.95);
}
.tanzaku.has-poster:after {
  content: "▶";
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  writing-mode: horizontal-tb;
  width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  font-size: 9px;
  border-radius: 50%;
  background: rgba(247, 242, 231, 0.9);
  color: rgba(20, 30, 60, 0.85);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* ホバーで短冊が立ち止まる（読める） */
.tanzaku:hover {
  animation-play-state: paused;
  transform-origin: center;
  box-shadow: 0 4px 22px rgba(245, 217, 122, 0.45);
  outline: 1px solid rgba(245, 217, 122, 0.55);
  z-index: 7;
}

@keyframes floatUp {
  0%   { transform: translateY(0) rotate(var(--rot0)) scale(1); opacity: 0; }
  8%   { opacity: 1; }
  85%  { opacity: 0.9; }
  100% { transform: translateY(var(--dy)) translateX(var(--dx)) rotate(var(--rot1)) scale(0.25); opacity: 0; }
}

/* ---- カード ---- */
.card {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(96px + env(safe-area-inset-bottom));
  width: min(480px, calc(100vw - 28px));
  background: linear-gradient(170deg, rgba(22, 34, 78, 0.96), rgba(10, 18, 48, 0.96));
  border: 1px solid rgba(245, 217, 122, 0.4);
  border-radius: 18px;
  padding: 22px 20px 18px;
  z-index: 8;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  transition: opacity 0.25s, transform 0.25s;
}
.card.hidden, .modal.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(12px); }
.card-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: none;
  color: rgba(247, 242, 231, 0.6);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
}
.card h3 {
  font-size: 20px;
  color: var(--gold);
  margin-bottom: 4px;
  letter-spacing: 0.06em;
}
.card .yomi { font-size: 12px; color: rgba(247, 242, 231, 0.6); margin-bottom: 12px; }
.card .fact-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(247, 242, 231, 0.18);
  font-size: 14px;
}
.card .fact-row b { color: var(--gold); font-weight: 500; }
.card .story {
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.9;
  color: rgba(247, 242, 231, 0.92);
}
.card .make-video,
.modal-inner .make-video {
  display: block;
  width: 100%;
  margin-top: 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 13px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(160deg, #f5d97a, #e0b34e);
  color: #3a2c07;
  cursor: pointer;
}
/* LINE ログイン（ブランドグリーン） */
.modal-inner .make-video.line-login {
  background: #06c755;
  color: #fff;
  margin-top: 10px;
}

.tour-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
}
.tour-step { font-size: 12px; color: rgba(247, 242, 231, 0.5); }
#tour-next {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 26px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(160deg, #f5d97a, #e0b34e);
  color: #3a2c07;
  cursor: pointer;
}
.tour-body { font-size: 15px; line-height: 2; }
.tour-body h3 { color: var(--gold); font-size: 19px; margin-bottom: 8px; }

/* ---- モーダル ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 22, 0.8);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.25s;
}
.modal.hidden { transform: none; }
.modal-inner {
  position: relative;
  width: min(520px, calc(100vw - 28px));
  max-height: 84vh;
  overflow-y: auto;
  background: linear-gradient(170deg, rgba(22, 34, 78, 0.98), rgba(10, 18, 48, 0.98));
  border: 1px solid rgba(245, 217, 122, 0.4);
  border-radius: 18px;
  padding: 26px 22px;
}
.modal-inner h2 { font-size: 20px; color: var(--gold); margin-bottom: 8px; }
.modal-note { font-size: 13px; color: rgba(247, 242, 231, 0.7); line-height: 1.8; margin-bottom: 14px; }
#demo-videos video {
  /* 縦動画(9:16)がスクロールなしで丸ごと見える */
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(42vh, 420px);
  margin: 0 auto 12px;
  border-radius: 12px;
  background: #000;
  object-fit: contain;
}

/* じぶんの短冊（進捗一覧） */
.mine-item {
  position: relative;
  padding: 12px 14px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: 1px solid rgba(245, 217, 122, 0.25);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  overflow: hidden;
}
.mine-item.has-poster { padding-right: 74px; }
.mine-item.has-poster::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 60px;
  background: var(--poster) center / cover;
  opacity: 0.85;
}
.mine-item.succeeded { cursor: pointer; }
.mine-item.succeeded:hover { border-color: rgba(245, 217, 122, 0.6); }
.mine-item .mi-wish { font-size: 14px; margin-bottom: 4px; }
.mine-item .mi-status { font-size: 12px; color: rgba(247, 242, 231, 0.65); }
.mine-item.succeeded .mi-status { color: var(--gold); }
.mine-item.failed .mi-status { color: rgba(247, 180, 160, 0.85); }

/* 再生画面: 投稿者の公開プロフィール */
.video-author { margin-bottom: 12px; text-align: center; }
.video-author .va-name {
  font-size: 13px;
  color: rgba(247, 242, 231, 0.85);
  margin-bottom: 6px;
}
.video-author .va-link {
  display: inline-block;
  margin: 2px 6px;
  font-size: 12px;
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 3px;
  word-break: break-all;
}
.cta-shikibu {
  display: block;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  padding: 14px;
  border-radius: 12px;
  background: linear-gradient(160deg, #f5d97a, #e0b34e);
  color: #3a2c07;
  text-decoration: none;
  margin-top: 10px;
  transition: box-shadow 0.2s, transform 0.15s;
}
.cta-shikibu:hover { box-shadow: 0 0 18px rgba(245, 217, 122, 0.5); transform: translateY(-1px); }
.cta-shikibu.ghost {
  background: none;
  border: 1px solid rgba(245, 217, 122, 0.55);
  color: var(--gold);
  font-weight: 500;
}
.gone { display: none !important; }

#btn-write {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom));
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  padding: 15px 34px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(160deg, #f5d97a, #e0b34e);
  color: #3a2c07;
  cursor: pointer;
  z-index: 6;
  box-shadow: 0 4px 24px rgba(245, 217, 122, 0.35);
  transition: box-shadow 0.2s, transform 0.15s;
}
#btn-write:hover { box-shadow: 0 4px 32px rgba(245, 217, 122, 0.6); transform: translateX(-50%) translateY(-1px); }
#btn-write:active { transform: translateX(-50%) scale(0.97); }

.modal-hint {
  margin-top: 8px;
  font-size: 12px;
  color: rgba(247, 242, 231, 0.65);
  text-align: center;
}

.modal-fineprint {
  margin-top: 12px;
  font-size: 11px;
  color: rgba(247, 242, 231, 0.5);
  text-align: center;
}
#powered-by {
  position: fixed;
  left: 12px;
  bottom: calc(4px + env(safe-area-inset-bottom));
  font-size: 11px;
  color: rgba(245, 217, 122, 0.65);
  text-decoration: none;
  z-index: 2;
  transition: color 0.2s, text-shadow 0.2s;
}
#powered-by:hover {
  color: var(--gold);
  text-shadow: 0 0 10px rgba(245, 217, 122, 0.6);
}
@media (max-width: 600px) {
  #powered-by { font-size: 10px; max-width: 55vw; }
}

.fld {
  display: block;
  font-size: 13px;
  color: rgba(247, 242, 231, 0.8);
  margin-bottom: 12px;
}
.fld input, .fld textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(245, 217, 122, 0.35);
  background: rgba(7, 13, 36, 0.7);
  color: var(--washi);
  outline: none;
}
.tanzaku .tz-name {
  display: block;
  margin-top: 8px;
  font-size: 10px;
  opacity: 0.7;
}

#toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  bottom: calc(88px + env(safe-area-inset-bottom));
  background: rgba(10, 18, 48, 0.92);
  border: 1px solid rgba(245, 217, 122, 0.5);
  color: var(--washi);
  font-size: 14px;
  padding: 12px 20px;
  border-radius: 12px;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  max-width: calc(100vw - 40px);
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

#credit {
  position: fixed;
  right: 10px;
  bottom: calc(4px + env(safe-area-inset-bottom));
  font-size: 10px;
  color: rgba(247, 242, 231, 0.35);
  z-index: 2;
}

@media (max-width: 600px) {
  #hint { display: none; }
  #title { top: max(14px, env(safe-area-inset-top)); right: 12px; }
}
