:root {
  color-scheme: light;
  font-family: "Mochiy Pop One", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  background: #ffe9f1;
  --scene-bg: url("https://pbs.twimg.com/media/G_ckRdSboAAoOnb.jpg");
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100svh;
  margin: 0;
  overflow: hidden;
}

body {
  background: #ffe9f1;
  color: #5c3b54;
  touch-action: manipulation;
}

.scene {
  position: relative;
  height: 100svh;
  padding: 10svh 5vw 4vh;
  display: flex;
  flex-direction: column;
  gap: 2vh;
  background-image: var(--scene-bg);
  background-size: cover;
  background-position: center;
}

.scene::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 240, 248, 0.72) 0%,
    rgba(255, 224, 237, 0.45) 45%,
    rgba(255, 201, 223, 0.7) 100%
  );
  z-index: 0;
  pointer-events: none;
}

.scene > * {
  position: relative;
  z-index: 1;
}

.hud {
  position: absolute;
  top: 2vh;
  right: 4vw;
  z-index: 2;
}

.hud__timer {
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 8px 18px rgba(255, 164, 200, 0.35);
  font-weight: 700;
  color: #d85c8c;
}

.player-line-header {
  position: absolute;
  top: 6svh;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 10px 20px rgba(255, 164, 200, 0.35);
  font-weight: 700;
  color: #d85c8c;
  letter-spacing: 0.08em;
  z-index: 2;
}

.intro-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.intro-card {
  width: min(520px, 90vw);
  text-align: center;
  padding: 36px 24px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 32px;
  box-shadow: 0 20px 40px rgba(255, 182, 208, 0.35);
  display: grid;
  gap: 22px;
  justify-items: center;
  z-index: 100;
}

.intro-card__label {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.intro-card__lead {
  margin: 0;
  font-size: 1rem;
  line-height: 1.7;
  color: #6a4663;
}

.actions {
  display: grid;
  gap: 14px;
  width: min(260px, 70vw);
}

.action-button {
  border: none;
  border-radius: 999px;
  padding: 14px 0;
  font-size: 1.1rem;
  font-weight: 600;
  background: #ff8fc1;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(255, 143, 193, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  touch-action: manipulation;
}

.action-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 22px rgba(255, 143, 193, 0.5);
}

.action-button--secondary {
  background: #ffc2dd;
  color: #5c3b54;
}

.tree-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 228, 242, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vh 3vw 5svh;
  z-index: 200;
  backdrop-filter: blur(6px);
}

.tree-overlay.is-hidden {
  display: none;
}

.tree-panel {
  width: min(1200px, 96vw);
  height: min(82svh, 760px);
  background: rgba(255, 255, 255, 0.96);
  border-radius: 28px;
  padding: 24px;
  box-shadow: 0 24px 48px rgba(216, 92, 140, 0.28);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tree-title {
  margin: 0;
  font-size: 1.4rem;
}

.tree-subtitle {
  margin: 6px 0 0;
  font-size: 0.9rem;
  color: #8a5b75;
}

.tree-close {
  border: none;
  background: #ffd3e5;
  color: #6b3e58;
  font-size: 1.4rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
}

.tree-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tree-status {
  min-height: 20px;
  font-size: 0.9rem;
  color: #b45a7b;
}

.tree-graph {
  flex: 1;
  position: relative;
  background: #fff6fb;
  border-radius: 20px;
  overflow: auto;
  cursor: grab;
  touch-action: none;
  overscroll-behavior: contain;
}

.tree-graph.is-loading {
  opacity: 0.7;
}

.tree-graph.is-dragging {
  cursor: grabbing;
}

.tree-canvas {
  position: relative;
  min-width: max-content;
  min-height: max-content;
}

.tree-levels {
  position: relative;
  z-index: 1;
  min-width: 100%;
  min-height: 100%;
}

.tree-node {
  background: #ffffff;
  border: 2px solid #ffd1e4;
  border-radius: 16px;
  padding: 10px 14px;
  font-size: 0.95rem;
  color: #6b3e58;
  min-width: 120px;
  max-width: 220px;
  text-align: center;
  box-shadow: 0 6px 16px rgba(216, 92, 140, 0.15);
  position: absolute;
  width: 180px;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  
  
  /* 追加 */
  line-height: 1.35;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  /*-webkit-line-clamp: 4;   /* 4行で省略 */
  /*overflow: auto;*/
}

.tree-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.tree-empty {
  margin: 0;
  text-align: center;
  color: #8a5b75;
  font-size: 0.95rem;
}

.play-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 2vh;
  position: relative;
}

.character-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.character-stage__image {
  max-height: 52vh;
  max-width: 80vw;
  object-fit: contain;
  filter: drop-shadow(0 14px 24px rgba(141, 82, 108, 0.3));
}

.choice-card-list {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  width: min(720px, 88vw);
  display: grid;
  gap: 12px;
  justify-items: stretch;
}

.choice-card {
  padding: 14px 24px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 18px rgba(255, 164, 200, 0.3);
  font-size: 1rem;
  color: #6b3e58;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  touch-action: manipulation;
}

.choice-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 24px rgba(255, 164, 200, 0.45);
}

.choice-card.is-empty {
  min-height: 48px;
}

.input-panel {
  width: min(760px, 92vw);
  padding: 18px 20px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 28px rgba(255, 148, 197, 0.35);
  display: grid;
  gap: 12px;
  justify-items: stretch;
  position: absolute;
  top: 10svh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
}

.input-panel__label {
  font-weight: 700;
  color: #c35f8c;
}

.input-panel__textarea {
  border: 2px solid rgba(255, 170, 206, 0.6);
  border-radius: 18px;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  color: #5a3a53;
  resize: vertical;
  background: #fff8fb;
  box-shadow: inset 0 4px 10px rgba(255, 182, 214, 0.2);
}

.input-panel__select {
  border: 2px solid rgba(255, 170, 206, 0.6);
  border-radius: 18px;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  color: #5a3a53;
  background: #fff8fb;
  box-shadow: inset 0 4px 10px rgba(255, 182, 214, 0.2);
}

.input-panel__select:focus {
  outline: none;
  border-color: #ff8fc1;
  box-shadow: 0 0 0 3px rgba(255, 143, 193, 0.25);
}

.input-panel__textarea:focus {
  outline: none;
  border-color: #ff8fc1;
  box-shadow: 0 0 0 3px rgba(255, 143, 193, 0.25);
}

.send-button {
  border: none;
  border-radius: 999px;
  padding: 12px 0;
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(135deg, #ff8fc1, #ffa6d4);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(255, 143, 193, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  touch-action: manipulation;
}

.send-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 22px rgba(255, 143, 193, 0.5);
}

.send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.dialogue-box {
  position: relative;
  width: min(820px, 92vw);
  padding: 26px 28px 24px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 32px rgba(255, 146, 193, 0.35);
}

.dialogue-name {
  position: absolute;
  top: -18px;
  left: 24px;
  padding: 6px 16px;
  border-radius: 999px;
  background: #ff9bc9;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 16px rgba(255, 131, 184, 0.35);
}

.dialogue-line {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.6;
  color: #5a3a53;
}

.dialogue-hint {
  display: block;
  margin-top: 10px;
  font-size: 0.85rem;
  color: #b07a9b;
  text-align: right;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 232, 244, 0.75);
  z-index: 5;
}

.modal__content {
  width: min(540px, 88vw);
  padding: 28px 26px 30px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 20px 40px rgba(255, 140, 190, 0.45);
  text-align: center;
  position: relative;
}

.modal__text {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.7;
  color: #5b3a52;
  white-space: pre-line;
}

.modal__footnote {
  position: absolute;
  right: 16px;
  bottom: 12px;
  font-size: 0.55rem;
  color: rgba(91, 58, 82, 0.2);
}

.curtain {
  position: fixed;
  inset: 0;
  z-index: 9999;
  transform: translateY(-110%);
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  background: linear-gradient(180deg, #ffbfe2 0%, #ff9bcb 45%, #ff7fb8 100%);
  box-shadow: inset 0 -20px 40px rgba(255, 255, 255, 0.35);
  overflow: hidden;
}

.curtain::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(
      circle at 15% 12%,
      rgba(255, 255, 255, 0.6),
      transparent 35%
    ),
    radial-gradient(circle at 85% 18%, rgba(255, 255, 255, 0.45), transparent 30%),
    radial-gradient(circle at 30% 75%, rgba(255, 255, 255, 0.4), transparent 32%),
    radial-gradient(circle at 70% 68%, rgba(255, 255, 255, 0.45), transparent 34%);
  opacity: 0.85;
  animation: curtain-twinkle 2.6s ease-in-out infinite alternate;
}

.curtain::after {
  content: "";
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -14px;
  height: 60px;
  background: radial-gradient(circle at 30px 0, #ffdaef 26px, transparent 27px)
    repeat-x;
  background-size: 60px 60px;
  opacity: 0.95;
}

.curtain__bow {
  position: absolute;
  top: 12%;
  left: 50%;
  width: 120px;
  height: 70px;
  transform: translateX(-50%);
  background: radial-gradient(circle at 50% 40%, #fff3fb 0%, #ffd1e8 48%, #ff9bc9 100%);
  border-radius: 40px;
  box-shadow: 0 12px 24px rgba(255, 153, 203, 0.35);
}

.curtain__bow::before,
.curtain__bow::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 60px;
  height: 40px;
  background: linear-gradient(135deg, #ffd6eb, #ff9bc9);
  border-radius: 40px 40px 10px 40px;
}

.curtain__bow::before {
  left: -40px;
  transform: translateY(-50%) rotate(-12deg);
}

.curtain__bow::after {
  right: -40px;
  transform: translateY(-50%) rotate(12deg) scaleX(-1);
}

.curtain.is-lowered {
  transform: translateY(0);
}

.result-rating.is-delayed {
  opacity: 0;
  transform: translateY(6px);
}

@keyframes curtain-twinkle {
  from {
    opacity: 0.7;
  }
  to {
    opacity: 1;
  }
}

.result-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-card {
  width: min(760px, 92vw);
  padding: 36px 28px;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 24px 44px rgba(255, 160, 204, 0.4);
  display: grid;
  gap: 24px;
  justify-items: center;
  text-align: center;
}

.result-card__label {
  font-size: 1.8rem;
  font-weight: 700;
  color: #d85c8c;
  letter-spacing: 0.2em;
}

.result-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 18px;
  width: 100%;
}

.slot {
  height: 200px;
  border-radius: 24px;
  background: #fff5fa;
  border: 3px solid rgba(255, 164, 200, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 6px 12px rgba(255, 170, 206, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.slot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.slot--empty {
  background: linear-gradient(135deg, #ffe3f0, #fff7fb);
}

.slot.is-spinning {
  animation: slot-bounce 0.3s ease-in-out infinite alternate;
  filter: blur(0.3px);
}

.slot.is-stopped {
  transform: scale(1.05);
  box-shadow: 0 16px 26px rgba(255, 150, 195, 0.4);
}

.result-rating {
  display: grid;
  gap: 8px;
  justify-items: center;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.result-rating__label {
  font-weight: 700;
  color: #c95e8b;
}

.result-rating__rank {
  font-size: 2.4rem;
  font-weight: 800;
  color: #ff7fb8;
  letter-spacing: 0.2em;
  text-shadow: 0 8px 16px rgba(255, 140, 190, 0.35);
}

.result-rating__comment {
  margin: 0;
  font-size: 1rem;
  color: #6a4663;
}

.result-actions {
  display: grid;
  gap: 12px;
  width: min(300px, 70vw);
}

@keyframes slot-bounce {
  from {
    transform: translateY(-2px);
  }
  to {
    transform: translateY(2px);
  }
}

@media (max-width: 480px) {
  .intro-card {
    padding: 28px 18px;
  }

  .intro-card__label {
    font-size: 1.6rem;
  }

  .dialogue-box {
    padding: 22px 20px;
  }

  .character-stage__image {
    max-height: 45vh;
  }

  .result-card {
    padding: 28px 18px;
  }

  .result-slots {
    grid-template-columns: repeat(3, minmax(86px, 1fr));
  }

  .slot {
    height: 140px;
  }
}



/* ===== ツリー：モバイルは全画面で使う ===== */
@media (max-width: 640px) {
  .tree-overlay {
    padding: 0;                 /* 余白を消して全画面に */
    align-items: stretch;
    justify-content: stretch;
  }

  .tree-panel {
    width: 100vw;
    height: 100svh;             /* Safari対策：svhを使う */
    max-height: 100svh;
    border-radius: 0;           /* 角丸を消して画面いっぱい感 */
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom)); /* 下の安全域 */
  }

  .tree-body {
    min-height: 0;              /* 重要：flex子のはみ出し防止 */
  }

  .tree-graph {
    min-height: 0;              /* 重要：スクロール領域を正しく作る */
  }
}


.tree-canvas {
  position: relative;
}

.tree-inner {
  position: relative;
  transform-origin: 0 0;
  will-change: transform;
}





/* ✅ エピローグ専用：改行を効かせる */
.tree-node--epilogue {
  white-space: pre-line;
  font-weight: 700;
  border-color: rgba(0,0,0,0.08);
}

/* ✅ 色の基本（誰とも付き合ってない＝灰色） */
.tree-node--epilogue {
  background: #d9d9d9;
}

/* loversの内容で色分け（dataset.lovers を利用） */
.tree-node--epilogue[data-lovers~="ミユ"] { --miyu: #FFE100; }
.tree-node--epilogue[data-lovers~="シオン"] { --shion: #706CAA; }
.tree-node--epilogue[data-lovers~="ナナ"] { --nana: #f4aeb3; }

/* 1人 */
.tree-node--epilogue[data-lovers="ミユ"] { background: #FFE100; }
.tree-node--epilogue[data-lovers="シオン"] { background: #706CAA; color:#fff; }
.tree-node--epilogue[data-lovers="ナナ"] { background: #f4aeb3; }

/* 2人（左右で半分） */
.tree-node--epilogue[data-lovers="ミユ,シオン"],
.tree-node--epilogue[data-lovers="シオン,ミユ"] {
  background: linear-gradient(90deg, #FFE100 0 50%, #706CAA 50% 100%);
  color:#2b2340;
}
.tree-node--epilogue[data-lovers="ミユ,ナナ"],
.tree-node--epilogue[data-lovers="ナナ,ミユ"] {
  background: linear-gradient(90deg, #FFE100 0 50%, #f4aeb3 50% 100%);
}
.tree-node--epilogue[data-lovers="シオン,ナナ"],
.tree-node--epilogue[data-lovers="ナナ,シオン"] {
  background: linear-gradient(90deg, #706CAA 0 50%, #f4aeb3 50% 100%);
  color:#fff;
}

/* 3人（3分割） */
.tree-node--epilogue[data-lovers="ミユ,ナナ,シオン"],
.tree-node--epilogue[data-lovers="ミユ,シオン,ナナ"],
.tree-node--epilogue[data-lovers="ナナ,ミユ,シオン"],
.tree-node--epilogue[data-lovers="ナナ,シオン,ミユ"],
.tree-node--epilogue[data-lovers="シオン,ミユ,ナナ"],
.tree-node--epilogue[data-lovers="シオン,ナナ,ミユ"] {
  background: linear-gradient(
    90deg,
    #FFE100 0 33.33%,
    #f4aeb3 33.33% 66.66%,
    #706CAA 66.66% 100%
  );
  color:#2b2340;
}


.is-hidden {
  display: none;
}



/* ===== ツリー：ジャンプ確認モーダル ===== */
.tree-panel {
  position: relative; /* 念のため */
}

.tree-jump-modal {
  position: fixed;            /* overlay全体を覆う */
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 232, 244, 0.75);
  z-index: 999;               /* tree-panelより上 */
}

.tree-jump-modal.is-hidden {
  display: none;
}

.tree-jump-box {
  width: min(420px, 86vw);
  padding: 22px 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 20px 40px rgba(255, 140, 190, 0.45);
  text-align: center;
}

.tree-jump-actions {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tree-jump-yes,
.tree-jump-no {
  border: none;
  border-radius: 999px;
  padding: 12px 0;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.tree-jump-yes {
  background: #ff8fc1;
  color: #fff;
}

.tree-jump-no {
  background: #ffd3e5;
  color: #6b3e58;
}
