:root {
  --ink: #fff7ed;
  --muted: #d7c9df;
  --line: rgba(255, 255, 255, 0.16);
  --panel: rgba(14, 12, 24, 0.68);
  --panel-strong: rgba(18, 16, 30, 0.84);
  --gold: #f5d376;
  --violet: #c4a7ff;
  --rose: #f49abc;
  --cyan: #8bd3ff;
  --green: #88e0bd;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "M PLUS Rounded 1c", "Noto Sans JP", system-ui, sans-serif;
  background: #0b0812;
  color: var(--ink);
}

body {
  width: 100%;
  max-width: 100%;
  min-height: 100dvh;
  overflow: hidden;
}

.mystery-shell {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto auto 1fr;
  isolation: isolate;
}

.scene-bg {
  position: fixed;
  inset: 0;
  z-index: -3;
  background: #14111f center / cover no-repeat;
  transform: scale(1.02);
  transition: background-image 0.5s ease, filter 0.4s ease;
  filter: saturate(1.05) contrast(1.04);
}

.scene-scrim {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 30% 18%, rgba(196, 167, 255, 0.18), transparent 32%),
    linear-gradient(90deg, rgba(8, 7, 15, 0.9), rgba(8, 7, 15, 0.52) 46%, rgba(8, 7, 15, 0.88));
}

.topbar {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  gap: 12px;
  align-items: center;
  padding: 16px clamp(14px, 3vw, 28px);
}

.topbar p {
  margin: 0;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: clamp(18px, 3vw, 25px);
  line-height: 1.2;
}

.back-link,
.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 30px;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.icon-button {
  font-size: 20px;
}

.progress-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 0 clamp(14px, 3vw, 28px) 12px;
}

.progress-bar {
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.progress-bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--violet), var(--gold), var(--rose));
  transition: width 0.35s ease;
}

#progressLabel {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.content-panel {
  width: min(768px, calc(100% - 28px));
  align-self: center;
  margin: 0 auto 28px;
  max-height: calc(100dvh - 132px);
  overflow: auto;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.05)), var(--panel);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(18px);
}

.fade {
  animation: fade 0.32s ease both;
}

@keyframes fade {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.scene-label {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}

h2 {
  margin: 0 0 14px;
  font-size: clamp(27px, 5vw, 44px);
  line-height: 1.15;
}

h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.9;
}

.story-text p:last-child,
.result-reading p:last-child {
  margin-bottom: 0;
}

.choice-grid,
.answer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.profile-grid {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.profile-question {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.18);
}

.profile-question strong {
  display: block;
  margin-bottom: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

button,
.button-link {
  appearance: none;
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  color: #16121e;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: transform 0.16s ease, filter 0.16s ease, background 0.16s ease;
}

button:hover,
.button-link:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

button:active,
.button-link:active {
  transform: translateY(1px);
}

.primary {
  width: 100%;
  margin-top: 18px;
  background: linear-gradient(135deg, var(--violet), var(--gold));
}

.answer-yes { background: var(--green); }
.answer-no { background: var(--rose); }

.choice {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
  border: 1px solid var(--line);
}

.choice.is-selected {
  background: linear-gradient(135deg, rgba(196, 167, 255, 0.8), rgba(245, 211, 118, 0.82));
  color: #16121e;
}

.question-card,
.result-card {
  margin-top: 18px;
  padding: clamp(16px, 3vw, 22px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel-strong);
}

.question-card {
  touch-action: none;
  user-select: none;
  transition: transform 0.12s, opacity 0.12s;
}

.hint {
  color: #bcaed7;
  font-size: 13px;
  font-weight: 700;
}

.question {
  margin: 10px 0 18px;
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 900;
  line-height: 1.5;
}

.swipe-guide {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(196, 167, 255, 0.32);
  color: #eadcff;
  background: rgba(196, 167, 255, 0.15);
  font-size: 12px;
  font-weight: 800;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.result-card {
  margin-top: 0;
}

.mask-list {
  display: grid;
  gap: 10px;
}

.mask-item {
  padding: 11px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.mask-item:first-child { border-top: 0; }

.mask-name {
  color: var(--gold);
  font-size: 20px;
  font-weight: 900;
}

.mask-score {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.mask-name-btn {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--gold);
  font-size: 20px;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  text-align: left;
}
.mask-name-btn:hover { opacity: .75; }

.mask-pic-modal[hidden] { display: none; }
.mask-pic-modal {
  position: fixed; inset: 0; z-index: 300;
  display: grid; place-items: center; padding: 18px;
}
.mask-pic-backdrop {
  position: absolute; inset: 0;
  background: rgba(4, 5, 10, .75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.mask-pic-panel {
  position: relative; z-index: 1;
  width: min(520px, 100%); height: min(82dvh, 760px);
  border-radius: 18px; overflow: hidden;
  display: flex; flex-direction: column;
  background: rgba(14, 13, 20, .97);
  border: 1px solid rgba(255, 255, 255, .12);
}
.mask-pic-header {
  display: flex; align-items: center;
  justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  color: #fff;
}
.mask-pic-close {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 8px;
  background: rgba(255, 255, 255, .06);
  color: #aaa; font-size: 20px; font-weight: 800;
  cursor: pointer; flex-shrink: 0;
}
.mask-pic-close:hover { color: #fff; }
.mask-pic-frame { width: 100%; flex: 1; border: 0; background: #0b1020; }

.meter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  font-weight: 900;
  margin-bottom: 6px;
}

.meter {
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.13);
}

.meter i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold));
}

.meter--curse i {
  background: linear-gradient(90deg, var(--cyan), var(--rose));
}

.result-reading {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.2);
}

.mask-map {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.mask-map-node {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 216, 138, .32);
  color: #ffe4a8;
  background: rgba(255, 216, 138, .12);
  font-size: 12px;
  font-weight: 900;
}

.mask-map-arrow {
  color: var(--muted);
  font-weight: 900;
}

.mask-properties {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.mask-property-group {
  border-top: 1px solid rgba(255,255,255,.12);
  padding-top: 12px;
}

.mask-property-group h4 {
  margin: 0 0 10px;
  color: rgba(255,255,255,.78);
  font-size: 12px;
  letter-spacing: .04em;
}

.mask-property-item {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.mask-property-item strong {
  color: #fff;
  font-size: 13px;
}

.save-status {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.secondary {
  background: rgba(255, 255, 255, 0.13);
  color: var(--ink);
  border: 1px solid var(--line);
}

@media (max-width: 680px) {
  body { overflow: auto; }
  .mystery-shell { min-height: 100svh; }
  .topbar { grid-template-columns: 38px 1fr 38px; }
  .back-link,
  .icon-button { width: 38px; height: 38px; }
  .content-panel {
    align-self: start;
    max-height: none;
    margin-bottom: 18px;
  }
  .choice-grid,
  .answer-grid,
  .result-grid,
  .meter-grid,
  .result-actions {
    grid-template-columns: 1fr;
  }
}
