* {
  box-sizing: border-box;
}

:root {
  --bg: #120f22;
  --bg2: #2b1d3d;
  --text: #fff8ff;
  --sub: #dfd2ef;
  --purple: #a985ff;
  --pink: #ff7fac;
  --green: #b9ff68;
  --gold: #ffd76d;
  --blue: #78d8ff;
  --line: rgba(255, 255, 255, 0.2);
  --box: rgba(18, 14, 31, 0.88);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

html {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    "Hiragino Maru Gothic ProN",
    "Yu Gothic",
    system-ui,
    sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 16% 12%, rgba(185, 255, 104, 0.28), transparent 30%),
    radial-gradient(circle at 80% 18%, rgba(169, 133, 255, 0.34), transparent 32%),
    linear-gradient(145deg, var(--bg), var(--bg2));
  overflow: hidden;
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.screen {
  display: none;
  min-height: 100vh;
  width: min(1080px, calc(100% - 24px));
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.screen.active {
  display: block;
}

.title-screen {
  text-align: center;
  align-content: center;
  padding: 42px 0;
}

.label {
  margin: 0;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

h1 {
  margin: 18px 0 0;
  font-size: clamp(3rem, 10vw, 7rem);
  line-height: 0.95;
  letter-spacing: -0.08em;
  text-shadow:
    0 0 22px rgba(169, 133, 255, 0.58),
    0 0 58px rgba(185, 255, 104, 0.26);
}

.catch {
  margin: 22px 0 0;
  color: var(--sub);
  font-size: clamp(1.05rem, 3vw, 1.55rem);
  font-weight: 900;
}

.credit-box {
  width: min(520px, 100%);
  margin: 28px auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.credit-box p {
  margin: 6px 0;
  color: var(--sub);
  font-weight: 800;
}

.main-btn,
.next-btn,
.sub-btn,
.choice-btn {
  border: 0;
  border-radius: 999px;
  font-weight: 900;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform 0.16s ease, background 0.16s ease;
}

.main-btn,
.next-btn {
  min-height: 50px;
  padding: 0 28px;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

.sub-btn {
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.11);
}

.main-btn:hover,
.next-btn:hover,
.sub-btn:hover,
.choice-btn:hover {
  transform: translateY(-2px);
}

.back-link {
  display: block;
  width: fit-content;
  margin: 18px auto 0;
  color: rgba(255, 248, 255, 0.72);
  font-weight: 800;
}

.novel-screen.active {
  display: grid;
  align-content: end;
  padding: 24px 0;
}

.stage {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-layer {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, rgba(18, 15, 34, 0.08), rgba(18, 15, 34, 0.9)),
    radial-gradient(circle at 50% 32%, rgba(185, 255, 104, 0.16), transparent 28%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 0 1px, transparent 1px 120px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 120px),
    linear-gradient(135deg, #30204a, #10101f);
}

.bg-layer::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(120, 216, 255, 0.18), transparent 26%),
    radial-gradient(circle at 78% 18%, rgba(185, 255, 104, 0.16), transparent 30%);
}

.character {
  position: fixed;
  z-index: 1;
  bottom: 178px;
  max-height: 62vh;
  object-fit: contain;
  filter:
    drop-shadow(0 26px 34px rgba(0, 0, 0, 0.46))
    drop-shadow(0 0 18px rgba(169, 133, 255, 0.22));
  transition:
    transform 0.2s ease,
    opacity 0.2s ease,
    filter 0.2s ease;
}

.sara {
  left: 12%;
  max-width: min(330px, 38vw);
}

.saku {
  right: 10%;
  max-width: min(390px, 44vw);
}

.character.speaking {
  transform: translateY(-12px) scale(1.03);
  filter:
    drop-shadow(0 26px 34px rgba(0, 0, 0, 0.46))
    drop-shadow(0 0 22px rgba(255, 215, 109, 0.46));
}

.character.dim {
  opacity: 0.55;
}

.status-panel {
  position: fixed;
  z-index: 3;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: min(680px, calc(100% - 24px));
  display: flex;
  justify-content: center;
  gap: 12px;
  pointer-events: none;
}

.status-panel span {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(18, 15, 31, 0.62);
  backdrop-filter: blur(12px);
  color: var(--sub);
  font-size: 0.86rem;
  font-weight: 900;
}

.message-box {
  position: relative;
  z-index: 4;
  width: min(920px, 100%);
  margin: auto auto 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--box);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.name-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.speaker-name {
  color: var(--gold);
  font-size: 1.08rem;
  font-weight: 900;
}

.message-text {
  min-height: 108px;
  margin: 0;
  font-size: 1.06rem;
  line-height: 1.9;
  font-weight: 800;
  white-space: pre-line;
}

.choices {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.choice-btn {
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  color: var(--text);
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.11);
}

.choice-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.next-btn {
  min-width: 120px;
}

@media (max-width: 760px) {
  html,
  body {
    min-height: 100dvh;
    overflow: hidden;
  }

  .novel-screen.active {
    min-height: 100dvh;
    padding: 12px 0 max(12px, env(safe-area-inset-bottom));
    align-content: end;
  }

  .status-panel {
    top: 10px;
    gap: 8px;
  }

  .status-panel span {
    font-size: 0.78rem;
    padding: 7px 10px;
  }

  .character {
    bottom: 270px;
    max-height: 37dvh;
  }

  .sara {
    left: -4%;
    max-width: 52vw;
  }

  .saku {
    right: -8%;
    max-width: 58vw;
  }

  .message-box {
    max-height: 45dvh;
    overflow-y: auto;
    padding: 16px;
    border-radius: 22px;
  }

  .message-text {
    min-height: 96px;
    font-size: 0.96rem;
    line-height: 1.75;
  }

  .actions {
    flex-direction: row;
  }

  .sub-btn,
  .next-btn {
    flex: 1;
    min-height: 42px;
    padding: 0 14px;
  }
}

.bg-layer {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, rgba(18, 15, 34, 0.08), rgba(18, 15, 34, 0.86)),
    url("./img/bg-lab.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.bg-layer::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(120, 216, 255, 0.12), transparent 26%),
    radial-gradient(circle at 78% 18%, rgba(185, 255, 104, 0.12), transparent 30%);
  pointer-events: none;
}
