/*! © 2026 烏蜃工房 | わたし、なに妖怪？ | 無断転載・改変再配布禁止 */
/* 配色はconfig.jsからCSS変数として設定する。 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 280px;
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--text);
  background-color: var(--background);
  background-image:
    radial-gradient(
      circle at 12% 5%,
      var(--decoration) 0,
      var(--decoration) 90px,
      transparent 91px
    ),
    radial-gradient(
      circle at 96% 42%,
      var(--decoration) 0,
      var(--decoration) 120px,
      transparent 121px
    );
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    Meiryo,
    sans-serif;
  font-size: 16px;
  line-height: 1.8;
  overflow-wrap: anywhere;
  transition:
    background-color 180ms ease,
    color 180ms ease;
}

body[data-theme="night"] {
  color-scheme: dark;
}

button,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button,
a {
  outline-offset: 5px;
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

button {
  cursor: pointer;
}

a {
  color: var(--link);
  text-underline-offset: 0.2em;
}

img {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
p,
figure {
  margin: 0;
}

h1,
h2,
h3,
button,
.site-title,
.type-badge,
.placeholder-id {
  font-family:
    "Hiragino Maru Gothic ProN",
    "Yu Gothic",
    "Hiragino Kaku Gothic ProN",
    Meiryo,
    sans-serif;
}

h1,
h2,
h3 {
  font-weight: 800;
  line-height: 1.5;
}

[hidden] {
  display: none !important;
}

.site-shell {
  width: min(100%, 760px);
  margin-inline: auto;
  padding:
    0
    max(18px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-block: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--primaryText);
  background: var(--primary);
  font-size: 20px;
  font-weight: 800;
  transform: rotate(-7deg);
}

.site-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.app {
  min-width: 0;
}

.app:focus {
  outline: none;
}

.screen {
  animation: screen-enter 180ms ease both;
}

.card {
  padding: clamp(22px, 5vw, 42px);
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 10px 32px var(--shadow);
}

.top-card {
  position: relative;
  overflow: hidden;
  padding-block: clamp(42px, 9vw, 72px);
  text-align: center;
}

.top-emblem {
  display: grid;
  place-items: center;
  width: 116px;
  height: 116px;
  margin: 0 auto 28px;
  border: 2px solid var(--border);
  border-radius: 42% 48% 44% 46%;
  color: var(--accentText);
  background-color: var(--accent);
  background-image:
    repeating-linear-gradient(
      45deg,
      transparent 0,
      transparent 12px,
      var(--pattern) 12px,
      var(--pattern) 14px
    );
  font-size: 55px;
  font-weight: 800;
  transform: rotate(-5deg);
}

.top-title {
  font-size: clamp(28px, 7.5vw, 46px);
  letter-spacing: 0.025em;
}

.top-lead {
  max-width: 28em;
  margin: 20px auto 32px;
  color: var(--muted);
  font-size: clamp(15px, 3.8vw, 17px);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  max-width: 100%;
  padding: 13px 22px;
  border: 1px solid var(--border);
  border-radius: 18px;
  font-weight: 800;
  line-height: 1.6;
  text-align: center;
  text-decoration: none;
  white-space: normal;
  transition:
    transform 120ms ease,
    background-color 120ms ease,
    border-color 120ms ease;
}

.button:active:not(:disabled) {
  transform: translateY(2px);
}

.button-primary {
  color: var(--primaryText);
  background: var(--primary);
  border-color: var(--primary);
}

.button-secondary {
  color: var(--text);
  background: var(--surfaceAlt);
}

.button-quiet {
  color: var(--muted);
  background: transparent;
}

.button-wide {
  width: 100%;
}

.top-card .button-primary {
  width: min(100%, 360px);
}

.question-progress {
  margin-bottom: 28px;
}

.progress-caption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
}

.progress-count {
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--track);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 180ms ease;
}

.question-title {
  margin-bottom: 26px;
  font-size: clamp(20px, 5.3vw, 27px);
  line-height: 1.8;
}

.answer-list {
  display: grid;
  gap: 12px;
}

.answer-button {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: 18px;
  color: var(--text);
  background: var(--surfaceAlt);
  font-weight: 800;
  line-height: 1.6;
  text-align: center;
  transition:
    border-color 120ms ease,
    background-color 120ms ease,
    transform 120ms ease;
}

.answer-button::before {
  content: "";
  display: block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--muted);
  border-radius: 50%;
}

.answer-button::after {
  content: "";
  width: 20px;
}

.answer-button[aria-pressed="true"] {
  border-color: var(--primary);
  color: var(--selectedText);
  background: var(--selected);
}

.answer-button[aria-pressed="true"]::before {
  border: 6px solid var(--primary);
  background: var(--surface);
}

.answer-button:active:not(:disabled) {
  transform: scale(0.99);
}

.question-navigation {
  margin-top: 24px;
}

.question-navigation .button {
  min-width: 110px;
}

.result-screen {
  display: grid;
  gap: 18px;
}

.result-hero {
  text-align: center;
}

.type-badge {
  display: inline-block;
  padding: 4px 15px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--accentText);
  background: var(--accent);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.result-name {
  margin-top: 14px;
  font-size: clamp(25px, 6.5vw, 37px);
}

.yokai-visual {
  position: relative;
  width: min(100%, 400px);
  aspect-ratio: 1;
  margin: 24px auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surfaceAlt);
}

.yokai-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.yokai-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  height: 100%;
  padding: 24px;
  color: var(--text);
  background-color: var(--surfaceAlt);
  background-image:
    repeating-radial-gradient(
      circle at 50% 100%,
      transparent 0,
      transparent 15px,
      var(--pattern) 16px,
      var(--pattern) 18px,
      transparent 19px,
      transparent 32px
    );
  background-size: 64px 38px;
  text-align: center;
}

.placeholder-id,
.placeholder-motif {
  max-width: 100%;
  padding: 4px 16px;
  border-radius: 12px;
  background: var(--surface);
}

.placeholder-id {
  font-size: clamp(27px, 8vw, 46px);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.placeholder-motif {
  font-size: clamp(22px, 6vw, 34px);
  font-weight: 800;
}

.result-catchphrase {
  margin-bottom: 26px;
  color: var(--highlight);
  font-size: clamp(21px, 5.6vw, 29px);
  font-weight: 800;
  line-height: 1.7;
}

.motif-introduction {
  padding: 20px;
  border-radius: 18px;
  background: var(--surfaceAlt);
  text-align: left;
}

.motif-heading {
  margin-bottom: 8px;
  font-size: 16px;
}

.section-title {
  margin-bottom: 20px;
  font-size: 21px;
}

.axis-list {
  display: grid;
  gap: 24px;
}

.axis-name {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.axis-labels {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 14px;
}

.axis-side {
  padding: 3px 7px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.axis-side:last-child {
  text-align: right;
}

.axis-side.is-selected {
  border-color: var(--primary);
  color: var(--selectedText);
  background: var(--selected);
  font-weight: 800;
}

.axis-track {
  display: flex;
  height: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--track);
}

.axis-fill-left {
  flex: 0 0 auto;
  height: 100%;
  background: var(--barLeft);
}

.axis-fill-right {
  flex: 1 0 auto;
  height: 100%;
  background: var(--barRight);
}

.description-text {
  line-height: 2;
}

.traits-grid {
  display: grid;
  gap: 18px;
}

.trait-panel {
  padding: 20px;
  border-radius: 18px;
  background: var(--surfaceAlt);
}

.trait-panel h3 {
  margin-bottom: 12px;
  font-size: 18px;
}

.trait-list {
  margin: 0;
  padding-left: 1.3em;
}

.trait-list li + li {
  margin-top: 8px;
}

.trait-list li::marker {
  color: var(--highlight);
}

.compatibility-grid {
  display: grid;
  gap: 14px;
}

.compatibility-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surfaceAlt);
}

.compatibility-level {
  display: inline-block;
  margin-bottom: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  color: var(--accentText);
  background: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.compatibility-link {
  display: block;
  min-height: 44px;
  padding-block: 6px;
  font-weight: 800;
  line-height: 1.7;
}

.compatibility-id {
  display: block;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.compatibility-reason {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.share-actions {
  display: grid;
  gap: 12px;
}

.restart-area {
  padding-block: 8px;
  text-align: center;
}

.site-footer {
  padding: 30px 12px 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.9;
  text-align: center;
}

.footer-credit {
  margin-top: 10px;
  font-weight: 700;
}

.toast {
  position: fixed;
  z-index: 10;
  right: 18px;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 18px;
  width: fit-content;
  max-width: min(560px, calc(100% - 36px));
  margin-inline: auto;
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--toastText);
  background: var(--toastBackground);
  box-shadow: 0 6px 24px var(--shadow);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 150ms ease,
    transform 150ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.manual-copy {
  margin-top: 18px;
}

.manual-copy-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

.manual-copy-text {
  display: block;
  width: 100%;
  min-height: 150px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  background: var(--surfaceAlt);
  resize: vertical;
}

.copy-helper {
  position: fixed;
  top: 0;
  left: -9999px;
  width: 1px;
  height: 1px;
}

/* トップ画面から一覧への入口。 */
.top-list-button {
  display: flex;
  width: min(100%, 360px);
  margin: 14px auto 0;
  font-size: 14px;
}

/* 結果画面の下部ボタン。 */
.result-navigation {
  display: grid;
  gap: 12px;
}

/* 妖怪一覧。昼夜のCSS変数はセクションごとにapp.jsで設定する。 */
.list-screen {
  display: grid;
  gap: 20px;
}

.list-header {
  text-align: center;
}

.list-title {
  font-size: clamp(27px, 7vw, 36px);
}

.list-own-result {
  margin-top: 18px;
}

.list-section {
  min-width: 0;
  padding: clamp(14px, 3vw, 24px);
  border: 1px solid var(--border);
  border-radius: 28px;
  color: var(--text);
  background: var(--background);
  box-shadow: 0 10px 32px var(--shadow);
}

.list-section[data-theme="day"] {
  color-scheme: light;
}

.list-section[data-theme="night"] {
  color-scheme: dark;
}

.list-section-title {
  margin-bottom: 18px;
  color: var(--highlight);
  font-size: clamp(20px, 5vw, 25px);
  text-align: center;
}

.yokai-grid {
  display: grid;
  grid-template-columns:
    repeat(var(--list-columns-mobile), minmax(0, 1fr));
  gap: 12px;
}

.yokai-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  color: var(--text);
  background: var(--surface);
  text-align: left;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background-color 120ms ease;
}

.yokai-card:active {
  transform: translateY(2px);
}

.yokai-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.yokai-card-id {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.yokai-own-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--primaryText);
  background: var(--primary);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.6;
}

.yokai-card .yokai-visual {
  width: min(100%, 160px);
  margin: 10px auto 12px;
  border-radius: 14px;
}

.yokai-card .yokai-placeholder {
  gap: 6px;
  padding: 8px;
}

.yokai-card .placeholder-id,
.yokai-card .placeholder-motif {
  padding: 2px 5px;
  border-radius: 7px;
}

.yokai-card .placeholder-id {
  font-size: clamp(13px, 3.5vw, 20px);
  letter-spacing: 0.04em;
}

.yokai-card .placeholder-motif {
  font-size: clamp(12px, 3vw, 17px);
}

.yokai-card-name {
  font-size: 16px;
  line-height: 1.6;
}

.yokai-card-catchphrase {
  margin-top: 8px;
  color: var(--highlight);
  font-size: 13px;
  line-height: 1.7;
}

@media (hover: hover) {
  .button-primary:hover:not(:disabled) {
    border-color: var(--primaryHover);
    background: var(--primaryHover);
  }

  .button-secondary:hover:not(:disabled),
  .button-quiet:hover:not(:disabled),
  .answer-button:hover:not(:disabled) {
    border-color: var(--primary);
    background: var(--selected);
    color: var(--selectedText);
  }

  .compatibility-link:hover {
    text-decoration-thickness: 2px;
  }

  .yokai-card:hover {
    border-color: var(--primary);
    background: var(--surfaceAlt);
  }
}

@media (min-width: 600px) {
  .site-header {
    padding-block: 32px;
  }

  .traits-grid,
  .compatibility-grid,
  .share-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 768px) {
  .yokai-grid {
    grid-template-columns:
      repeat(var(--list-columns-desktop), minmax(0, 1fr));
  }
}

@media (max-width: 359px) {
  .site-shell {
    padding-inline: 12px;
  }

  .card {
    padding: 20px 16px;
    border-radius: 22px;
  }

  .top-card {
    padding-block: 38px;
  }

  .axis-labels {
    gap: 4px;
    font-size: 12px;
  }

  .axis-side {
    padding-inline: 4px;
  }

  .list-section {
    padding: 12px;
  }

  .yokai-grid {
    gap: 8px;
  }

  .yokai-card {
    padding: 8px;
  }

  .yokai-card-name {
    font-size: 14px;
  }

  .yokai-card-catchphrase {
    font-size: 12px;
  }
}

@keyframes screen-enter {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* 結果カード作成ボタン。既存のシェアボタンの下に配置する。 */
.card-create-button {
  grid-column: 1 / -1;
}

/* 結果カードのプレビュー。 */
body.card-modal-open {
  overflow: hidden;
}

.card-modal {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  background: rgba(16, 17, 30, 0.72);
  overscroll-behavior: contain;
}

.card-modal-panel {
  width: min(100%, 600px);
  min-width: 0;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: clamp(16px, 4vw, 26px);
  border: 1px solid var(--border);
  border-radius: 24px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.25);
}

.card-modal-panel:focus {
  outline: none;
}

.card-modal-title {
  margin-bottom: 16px;
  font-size: 21px;
  text-align: center;
}

.card-preview-image {
  width: 100%;
  height: auto;
  margin-inline: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--background);
  -webkit-touch-callout: default;
  user-select: auto;
  -webkit-user-select: auto;
}

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

.card-modal-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.card-modal-actions .button {
  width: 100%;
}

.card-modal-status {
  margin-top: 12px;
  color: var(--highlight);
  font-size: 14px;
  text-align: center;
}

.card-modal-status:empty {
  display: none;
}

@media (min-width: 480px) {
  .card-modal-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-modal-close {
    grid-column: 1 / -1;
  }

  .card-modal-actions.is-save-only .card-save-button {
    grid-column: 1 / -1;
  }
}