* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
}

body {
  background: #170d22;
  color: #fff;
  font-family: "Yu Gothic", "Meiryo", sans-serif;
}

button,
a {
  font: inherit;
}

.adv-page {
  min-height: 100svh;
}

.adv-stage {
  position: relative;
  width: 100%;
  min-height: 100svh;
  overflow: hidden;

  background-image:
    linear-gradient(rgba(20, 10, 30, 0.02), rgba(20, 10, 30, 0.10)),
    url("../img/bg/profile-adv-sakura.png");
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-color: #d9b8cf;
}

.adv-character {
  position: absolute;
  left: 50%;
  bottom: -3%;
  transform: translateX(-50%);
  z-index: 2;

  height: min(94svh, 980px);
  width: auto;
  max-width: none;

  object-fit: contain;
  object-position: center bottom;

  pointer-events: none;
  user-select: none;

  filter: drop-shadow(0 10px 18px rgba(50, 25, 35, 0.18));
}

.adv-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(10, 5, 18, 0.03) 0%,
    rgba(10, 5, 18, 0.00) 55%,
    rgba(10, 5, 18, 0.20) 100%
  );
  z-index: 1;
}

.opening-screen {
  position: absolute;
  inset: 0;
  z-index: 20;

  width: 100%;
  height: 100%;
  min-height: 100svh;

  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;

  opacity: 1;
  transition: opacity 0.45s ease;
}

.opening-screen.is-leaving {
  opacity: 0;
  pointer-events: none;
}

.touch-prompt {
  position: absolute;
  left: 50%;
  bottom: max(28px, calc(env(safe-area-inset-bottom) + 18px));
  transform: translateX(-50%);

  display: inline-block;
  padding: 10px 20px;

  border: 1px solid rgba(255, 235, 248, 0.72);
  border-radius: 999px;

  background: rgba(38, 21, 45, 0.72);
  color: #fff;

  font-size: 15px;
  font-weight: bold;
  letter-spacing: 0.04em;
  white-space: nowrap;

  box-shadow: 0 6px 20px rgba(20, 8, 28, 0.30);
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.75);

  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);

  animation: touch-float 1.6s ease-in-out infinite;
}

.touch-prompt::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%) rotate(45deg);

  width: 14px;
  height: 14px;

  border-right: 1px solid rgba(255, 235, 248, 0.72);
  border-bottom: 1px solid rgba(255, 235, 248, 0.72);
  background: rgba(38, 21, 45, 0.72);
}

@keyframes touch-float {
  0%,
  100% {
    translate: 0 0;
  }

  50% {
    translate: 0 -5px;
  }
}

.adv-top-controls {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 10;

  display: flex;
  gap: 8px;
}

.adv-small-button {
  border: 1px solid rgba(255, 240, 250, 0.76);
  border-radius: 999px;
  padding: 7px 12px;

  background: rgba(35, 18, 42, 0.58);
  color: #fff;
  text-decoration: none;
  cursor: pointer;

  font-size: 12px;
  font-weight: bold;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(7px);
}

.adv-small-button:hover {
  background: rgba(255, 160, 215, 0.62);
}

.message-window {
  position: absolute;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 5;

  width: min(860px, calc(100% - 48px));
  min-height: 166px;
  padding: 20px 26px 52px;

  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 18px;

  background: rgba(239, 242, 248, 0.72);
  color: #2a2430;

  box-shadow:
    0 12px 38px rgba(25, 10, 35, 0.32),
    inset 0 0 20px rgba(255, 255, 255, 0.20);

  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.speaker {
  display: inline-block;
  margin: 0;
  padding: 7px 16px;

  border-radius: 999px;
  background: rgba(255, 157, 213, 0.82);
  color: #fff;

  font-size: 14px;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(190, 70, 140, 0.20);
}

.voice-button {
  flex: 0 0 auto;
  border: 1px solid rgba(120, 75, 115, 0.24);
  border-radius: 999px;
  padding: 6px 11px;

  background: rgba(255, 255, 255, 0.44);
  color: #6a5367;

  font-size: 12px;
  font-weight: bold;
}

.voice-button:disabled {
  opacity: 0.52;
  cursor: default;
}

.message-text {
  margin: 18px 0 0;
  padding-right: 26px;
  padding-left: 1em;
  text-indent: -1em;

  color: #2a2430;
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 600;
  line-height: 1.85;
  white-space: pre-line;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.40);
}

.next-button {
  position: absolute;
  right: 24px;
  bottom: 14px;

  border: 0;
  padding: 8px 12px;

  background: transparent;
  color: #d052a0;

  font-size: 24px;
  cursor: pointer;
  animation: next-float 1.25s ease-in-out infinite;
}

.next-button:hover {
  transform: scale(1.12);
}

@keyframes next-float {
  0%,
  100% {
    opacity: 0.45;
    translate: 0 0;
  }

  50% {
    opacity: 1;
    translate: 0 4px;
  }
}

.choice-panel {
  position: absolute;
  left: 50%;
  bottom: max(220px, calc(env(safe-area-inset-bottom) + 210px));
  transform: translateX(-50%);
  z-index: 6;

  width: min(660px, calc(100% - 48px));
  padding: 16px;

  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 18px;
  background: rgba(32, 18, 42, 0.70);

  box-shadow: 0 12px 32px rgba(20, 8, 28, 0.34);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.choice-title {
  margin: 0 0 11px;
  color: #fff;
  text-align: center;
  font-size: 14px;
  font-weight: bold;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.8);
}

.choice-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.choice-button {
  min-height: 48px;
  border: 1px solid rgba(255, 213, 238, 0.64);
  border-radius: 12px;
  padding: 10px 14px;

  background: rgba(255, 228, 244, 0.16);
  color: #fff;

  cursor: pointer;
  font-weight: bold;
  text-align: left;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.72);
}

.choice-button:hover,
.choice-button:focus-visible {
  background: rgba(255, 168, 218, 0.46);
  outline: none;
}

.choice-button.visited::before {
  content: "✓ ";
  color: #ffd2ec;
}

.choice-button.secret {
  grid-column: 1 / -1;
  text-align: center;
  border-color: rgba(255, 199, 233, 0.92);
  background: rgba(226, 82, 165, 0.32);
  box-shadow: 0 0 18px rgba(255, 122, 202, 0.20);
}

.unlock-notice {
  position: absolute;
  top: max(70px, calc(env(safe-area-inset-top) + 56px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;

  width: max-content;
  max-width: calc(100% - 40px);
  padding: 9px 16px;
  border-radius: 999px;

  background: rgba(35, 18, 42, 0.75);
  color: #ffd2ec;

  font-size: 13px;
  font-weight: bold;
  text-align: center;

  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.unlock-notice.show {
  opacity: 1;
}

.ending-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 7;

  width: min(620px, calc(100% - 48px));
  padding: 26px;

  border: 1px solid rgba(255, 255, 255, 0.70);
  border-radius: 20px;
  background: rgba(239, 242, 248, 0.80);
  color: #2a2430;

  box-shadow: 0 12px 38px rgba(25, 10, 35, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.ending-title {
  display: inline-block;
  margin: 0 0 12px;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(255, 157, 213, 0.82);
  color: #fff;
  font-weight: bold;
}

.ending-panel p {
  line-height: 1.8;
  font-weight: 600;
}

.ending-buttons {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.ending-buttons button,
.ending-buttons a {
  border: 1px solid rgba(210, 100, 165, 0.42);
  border-radius: 999px;
  padding: 11px 16px;

  background: rgba(255, 185, 225, 0.32);
  color: #433343;
  text-align: center;
  text-decoration: none;
  font-weight: bold;
  cursor: pointer;
}

.ending-buttons button:hover,
.ending-buttons a:hover {
  background: rgba(255, 155, 213, 0.55);
}

[hidden] {
  display: none !important;
}

/* PC：中央をスマホ風ADV画面にして、左右をぼかし背景で埋める */
@media (min-width: 951px) {
  body {
    overflow: hidden;
  }

  .adv-page {
    position: relative;
    display: flex;
    justify-content: center;
    min-height: 100svh;
    overflow: hidden;
    background: #c9a9c3;
  }

  .adv-page::before {
    content: "";
    position: fixed;
    inset: -36px;
    z-index: 0;
    pointer-events: none;

    background-image:
      linear-gradient(rgba(20, 10, 30, 0.12), rgba(20, 10, 30, 0.22)),
      url("../img/bg/profile-adv-sakura.png");
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;

    filter: blur(22px);
    transform: scale(1.08);
  }

  .adv-stage {
    z-index: 1;
    width: min(480px, 100%);
    min-height: 100svh;

    background-size: cover;
    background-position: center center;

    box-shadow:
      -18px 0 36px rgba(30, 12, 36, 0.22),
      18px 0 36px rgba(30, 12, 36, 0.22);
  }

  .adv-character {
    height: 86svh;
    max-height: none;
    bottom: -1%;
  }

  .message-window {
    width: calc(100% - 24px);
    bottom: 12px;
    min-height: 152px;
    padding: 16px 18px 46px;
    border-radius: 16px;
  }

  .speaker {
    padding: 6px 13px;
    font-size: 13px;
  }

  .voice-button {
    padding: 5px 9px;
    font-size: 11px;
  }

  .message-text {
    margin-top: 14px;
    padding-right: 20px;
    font-size: 16px;
    line-height: 1.75;
  }

  .next-button {
    right: 14px;
    bottom: 8px;
    font-size: 22px;
  }

  .choice-panel {
    width: calc(100% - 24px);
    bottom: 178px;
    padding: 12px;
  }

  .choice-list {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .choice-button {
    min-height: 42px;
    padding: 8px 12px;
    font-size: 14px;
  }

  .ending-panel {
    width: calc(100% - 24px);
    max-height: calc(100svh - 40px);
    overflow-y: auto;
    padding: 20px;
  }
}

@media (max-width: 768px) and (orientation: portrait) {
  /* スマホ縦：開始前の吹き出し */
  .touch-prompt {
    bottom: max(24px, calc(env(safe-area-inset-bottom) + 16px));
    padding: 9px 18px;
    font-size: 14px;
  }
}

@media (max-width: 768px) and (orientation: portrait) {
  .adv-stage {
    min-height: 100dvh;
    background-size: cover;
    background-position: center center;
  }

  .adv-character {
    bottom: -1%;
    height: 86dvh;
  }

  .adv-top-controls {
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
  }

  .adv-small-button {
    padding: 6px 10px;
    font-size: 11px;
  }

  .message-window {
    width: calc(100% - 24px);
    bottom: max(12px, env(safe-area-inset-bottom));
    min-height: 152px;
    padding: 16px 18px 46px;
    border-radius: 16px;
  }

  .speaker {
    padding: 6px 13px;
    font-size: 13px;
  }

  .voice-button {
    padding: 5px 9px;
    font-size: 11px;
  }

  .message-text {
    margin-top: 14px;
    padding-right: 20px;
    font-size: 16px;
    line-height: 1.75;
  }

  .next-button {
    right: 14px;
    bottom: 8px;
    font-size: 22px;
  }

  .choice-panel {
    width: calc(100% - 24px);
    bottom: max(178px, calc(env(safe-area-inset-bottom) + 170px));
    padding: 12px;
  }

  .choice-list {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .choice-button {
    min-height: 42px;
    padding: 8px 12px;
    font-size: 14px;
  }

  .ending-panel {
    width: calc(100% - 24px);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    padding: 20px;
  }
}

@media (max-width: 950px) and (orientation: landscape) {
  .adv-character {
    bottom: -10%;
    height: 112vh;
  }

  .message-window {
    bottom: 12px;
    min-height: 118px;
    padding: 12px 20px 36px;
  }

  .message-text {
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.45;
  }

  .speaker {
    padding: 4px 11px;
    font-size: 12px;
  }

  .voice-button {
    padding: 4px 8px;
    font-size: 10px;
  }

  .next-button {
    bottom: 5px;
    font-size: 19px;
  }

  .choice-panel {
    width: min(650px, 76%);
    bottom: 138px;
    padding: 10px;
  }

  .choice-list {
    gap: 7px;
  }

  .choice-button {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 12px;
  }
}
