:root {
  --header-end-color: #ffffffef;
  --font-base: 'LINE Seed JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans JP', sans-serif;
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-sub: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  --color-theme: #4f46e5;
  --color-theme-hover: #4338ca;
  --color-danger: #ef4444;
  --progress-bg: #e2e8f0;
  --border: #e2e8f0;
  --content-gutter: 24px;
  --width-m: 767px;
  --width-auto: min(100% - var(--content-gutter) * 2, var(--width-m));
  --width-auto-padding: max(var(--content-gutter), calc((100% - var(--width-m)) / 2));
  --modal-radius: 32px;
  --modal-padding: 24px;
  --modal-inner-radius: calc(var(--modal-radius) - var(--modal-padding));
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 30px;
  --radius-max: 999px;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --safe-top: env(safe-area-inset-top, 0px);
  --header-height: calc(60px + var(--safe-top));
  --match-my-color: #ff83b5;
  --match-my-ink: #a3265c;
  --match-my-surface: #fff0f6;
  --match-partner-color: #73b7ff;
  --match-partner-ink: #245b9b;
  --match-partner-surface: #edf6ff;
  --match-my-glow: color-mix(in srgb, var(--match-my-color) 72%, white);
  --match-my-deep: color-mix(in srgb, var(--match-my-color) 82%, var(--match-my-ink));
  --match-partner-glow: color-mix(in srgb, var(--match-partner-color) 65%, white);
  --match-partner-deep: color-mix(in srgb, var(--match-partner-color) 84%, var(--match-partner-ink));
  --match-blend: color-mix(in srgb, var(--match-my-color), var(--match-partner-color));
  --match-field: radial-gradient(ellipse at 38% 24%, var(--match-my-glow), transparent 30%),
    radial-gradient(ellipse at 64% 72%, var(--match-partner-glow), transparent 32%),
    radial-gradient(ellipse at 8% 16%, var(--match-my-deep), transparent 46%),
    radial-gradient(ellipse at 88% 12%, var(--match-partner-glow), transparent 42%),
    radial-gradient(ellipse at 67% 42%, var(--match-partner-color), transparent 48%),
    radial-gradient(ellipse at 22% 58%, var(--match-my-glow), transparent 44%),
    radial-gradient(ellipse at 90% 83%, var(--match-partner-deep), transparent 46%),
    radial-gradient(ellipse at 12% 94%, var(--match-my-color), transparent 48%),
    radial-gradient(ellipse at 52% 75%, var(--match-blend), transparent 50%),
    linear-gradient(135deg, var(--match-my-surface), var(--match-partner-surface));
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html, body {
  overflow-x: hidden;
  font-family: var(--font-base);
  line-height: 1.6;
  color: var(--text-main);
  background: var(--bg-body);
  -webkit-font-smoothing: antialiased;
  transition: color 0.3s ease;
}
a {
  text-decoration: none;
  color: inherit;
}
.menu-toggle-checkbox,
.menu-overlay {
  display: none;
}

.global-header {
  position: fixed;
  inset: 0 0 auto;
  width: 100%;
  z-index: 1000;
  height: var(--header-height);
  overflow: hidden;
  background: linear-gradient(to bottom, var(--bg-body) 0 calc(var(--safe-top) + 14px), var(--header-end-color) 100%);
  box-shadow: 0 0 20px #00000011;
  transition: height var(--transition-normal), border-radius var(--transition-normal), filter 1200ms ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  & .header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    width: 100%;
    position: relative;
    z-index: 1010;
    padding: var(--safe-top) var(--width-auto-padding) 0;
  }
  & .header-logo {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    font: 800 19px/1.6 var(--font-base);
    letter-spacing: -0.02em;
    cursor: pointer;
    border: 0;
    background: transparent;
    color: var(--color-theme);
  }
  & .header-right-tools {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 8px;
    & .header-q-counter {
      display: none;
      align-items: center;
      font-weight: 800;
      font-size: 14px;
      color: var(--header-theme-color, var(--color-theme));
      transition: color 0.4s ease;
      &.active {
        display: flex;
      }
      & .q-fixed-label {
        letter-spacing: 0.02em;
      }
      & .q-number-viewport {
        height: 1.3em;
        overflow: hidden;
        position: relative;
        display: inline-block;
        width: 1.25em;
        margin-left: 0;
        vertical-align: bottom;
        & .q-number {
          position: absolute;
          top: 0;
          left: 0;
          font-weight: 800;
          line-height: 1.3em;
          transition: transform 0.28s cubic-bezier(0.2, 1, 0.3, 1),
            filter 0.28s cubic-bezier(0.2, 1, 0.3, 1),
            opacity 0.28s cubic-bezier(0.2, 1, 0.3, 1);
          &.active {
            opacity: 1;
            transform: translateY(0);
            filter: blur(0);
          }
          &.slide-in-up, &.slide-out-down {
            opacity: 0;
            transform: translateY(100%);
            filter: blur(4px);
          }
          &.slide-in-down, &.slide-out-up {
            opacity: 0;
            transform: translateY(-100%);
            filter: blur(4px);
          }
        }
      }
    }
    & .progress-container {
      display: none;
      width: 76px;
      height: 6px;
      overflow: hidden;
      margin-right: 12px;
      background: var(--progress-bg);
      border-radius: 999px;
      &.active {
        display: block;
      }
      & .progress-bar {
        height: 100%;
        width: 0%;
        background: var(--header-theme-color, var(--color-theme));
        border-radius: 0 999px 999px 0;
        transition: width 0.3s ease, background 0.4s ease;
      }
    }
  }
  & .menu-hamburger {
    position: relative;
    display: block;
    height: 24px;
    flex-direction: column;
    flex-shrink: 0;
    justify-content: space-between;
    width: 24px;
    cursor: pointer;
    & .hamburger-line {
      position: absolute;
      left: 0;
      top: 50%;
      width: 100%;
      height: 2px;
      background-color: var(--text-main);
      transform-origin: center;
      transform: translateY(-50%);
      transition: transform var(--transition-normal), opacity var(--transition-normal);
      &:nth-child(1) {
        transform: translateY(calc(-50% - 8px));
      }
      &:nth-child(3) {
        transform: translateY(calc(-50% + 8px));
      }
    }
  }
  & .header-nav-container {
    z-index: 1;
    position: absolute;
    top: var(--header-height);
    left: 0;
    width: 100%;
    height: auto;
    max-height: calc(85svh - var(--header-height));
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--transition-normal), visibility 0s linear .3s;
    & .header-nav {
      width: min(100%, calc(var(--width-m) + var(--content-gutter) * 2));
      margin-inline: auto;
      transform: translateY(-16px);
      transition: transform var(--transition-normal);
      & .nav-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        padding: 12px var(--content-gutter) 24px;
        list-style: none;
        & .nav-item {
          width: 100%;
          min-width: 0;
          & button, & a.header-nav-action {
            position: relative;
            overflow: hidden;
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            justify-content: center;
            gap: 12px;
            min-height: 112px;
            height: 100%;
            padding: 20px;
            text-align: left;
            font-weight: 600;
            font-size: 15px;
            line-height: 1.5;
            border: 0;
            border-radius: 16px;
            background: color-mix(in srgb, var(--color-theme) 5%, white);
            box-shadow: 0 5px 16px #00000005;
            color: var(--text-main);
            cursor: pointer;
            transition: background .2s ease;
            &:hover {
              background: color-mix(in srgb, var(--color-theme) 12%, white);
            }
            & .nav-icon {
              width: 26px;
              height: 26px;
              color: var(--color-theme);
            }
          }
          &.nav-policy {
            grid-column: 1 / -1;
            & a {
              display: block;
              width: fit-content;
              padding: 8px 0 0;
              font-size: 12px;
              font-weight: 400;
              color: var(--text-muted);
            }
          }
          &:has(> button[style*="display: none"]) {
            display: none;
          }
        }
      }
    }
  }
}
.menu-toggle-checkbox:checked {
  & ~ .menu-overlay {
    opacity: 1;
    visibility: visible;
  }
  & ~ .global-header {
    height: var(--header-menu-height, 380px);
    max-height: 85svh;
    border-radius: 0 0 30px 30px;
    & .header-nav-container {
      opacity: 1;
      visibility: visible;
      transition-delay: 0s;
      & .header-nav {
        transform: translateY(0);
      }
      pointer-events: auto;
    }
    & .menu-hamburger {
      & .hamburger-line:nth-child(1) {
        transform: translateY(-50%) rotate(45deg);
      }
      & .hamburger-line:nth-child(2) {
        opacity: 0;
      }
      & .hamburger-line:nth-child(3) {
        transform: translateY(-50%) rotate(-45deg);
      }
    }
  }
}
html:has(.menu-toggle-checkbox:checked) {
  overflow: hidden;
}
.article-modalToggle {
  display: none;
}
.article-modalLayer {
  position: fixed;
  inset: 0;
  z-index: 1020;
  pointer-events: none;
}
.article-modalBackdrop {
  position: absolute;
  inset: 0;
  background: transparent;
  cursor: pointer;
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition: background 0.25s ease, backdrop-filter 0.25s ease, -webkit-backdrop-filter 0.25s ease;
}
.article-modalCenter {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.article-modalPanel {
  position: relative;
  z-index: 1;
  width: min(100% - 24px, 480px);
  max-height: 90svh;
  overflow: auto;
  padding: var(--modal-padding);
  border-radius: var(--modal-radius);
  background: var(--bg-surface);
  opacity: 0;
  transform: scale(0.96) translateY(8px);
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.2, 1, 0.3, 1);
}
.article-modalTitle {
  margin: 0 0 20px;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
}
.article-modalCloseIcon {
  position: absolute;
  top: 24px;
  right: 24px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.2s;
  &:hover {
    color: var(--text-main);
  }
}
.article-modalToggle:checked + .article-modalLayer {
  pointer-events: auto;
  & .article-modalBackdrop {
    background: rgba(0, 10, 30, 0.25);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
  & .article-modalPanel {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
html:has(.article-modalToggle:checked) {
  overflow: hidden;
}
.app-view {
  display: none;
  min-height: 100vh;
  padding-top: var(--header-height);
  transition: filter 1200ms ease;
  &.active {
    display: block;
  }
}
#view-top {
  & .top-container {
    width: var(--width-auto);
    display: flex;
    flex-direction: column;
    gap: 32px;
    margin: 24px auto 60px;
    padding: 0;
  }
  & .hero-section {
    padding: 0;
    text-align: center;
    & .top-characters-hero {
      display: block;
      width: 100%;
      height: auto;
      margin: 0 auto 28px;
    }
    & .top-introduction {
      margin-bottom: 28px;
      text-align: left;
      font-size: 16px;
      line-height: 2;
      & p + p {
        margin-top: 16px;
      }
    }
    & .top-answer-note {
      max-width: 480px;
      margin: 14px auto 0;
      font-size: 12px;
      line-height: 1.8;
      color: var(--text-muted);
    }
    & .start-quiz-trigger {
      display: block;
      width: 100%;
      max-width: 480px;
      margin-inline: auto;
      padding: 18px 24px;
      font-size: 17px;
      font-weight: 700;
      background: var(--color-theme);
      color: var(--text-inverse);
      border: none;
      border-radius: var(--radius-md);
      cursor: pointer;
      transition: background var(--transition-fast);
      &:hover {
        background: var(--color-theme-hover);
      }
    }
  }
  & .top-type-grid {
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    padding: 24px 12px;
    &::before {
      position: absolute;
      z-index: -1;
      inset: -25px -12px;
      content: "";
      border-radius: 40%;
      filter: blur(24px);
      animation: top-colors-drift 14s ease-in-out infinite alternate;
    }
  }
  & .top-color-box {
    min-width: 0;
  }
  & .top-color-characters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 12px;
    & figure {
      min-width: 0;
      margin: 0;
      text-align: center;
    }
    & img {
      display: block;
      width: 100%;
      height: auto;
      aspect-ratio: 1;
      object-fit: contain;
    }
    & figcaption {
      min-height: 2.8em;
      overflow-wrap: anywhere;
      margin-top: 4px;
      font-size: 13px;
      font-weight: 700;
      line-height: 1.4;
      text-wrap: balance;
      color: var(--group-ink);
    }
  }
  @media (max-width: 480px) {
    & .hero-section .top-introduction {
      font-size: 14px;
    }
    & .top-type-grid {
      gap: 12px;
    }
    & .top-color-characters {
      gap: 10px 6px;
    }
    & .top-color-characters figcaption {
      font-size: 10px;
    }
  }
  & .top-type-grid::before {
    background: radial-gradient(ellipse at 10% 16%, #ff83b5c0, transparent 52%),
      radial-gradient(ellipse at 32% 30%, #ffa8dcaa, transparent 43%),
      radial-gradient(ellipse at 88% 12%, #73b7ffd0, transparent 52%),
      radial-gradient(ellipse at 72% 37%, #98dcffaa, transparent 40%),
      radial-gradient(ellipse at 12% 90%, #ffae65c0, transparent 52%),
      radial-gradient(ellipse at 35% 72%, #ffcc93aa, transparent 40%),
      radial-gradient(ellipse at 90% 86%, #e3ff48c0, transparent 52%),
      radial-gradient(ellipse at 65% 70%, #efffa0aa, transparent 42%);
  }
}
#view-quiz {
  --quiz-wave-offset: 36px;
  height: 100dvh;
  overflow-y: scroll;
  overflow-anchor: none;
  padding-top: var(--header-height);
  scroll-padding-top: calc(var(--header-height) + var(--quiz-wave-offset));
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  background: transparent;
  & .snap-card {
    --card-surface: color-mix(in srgb, var(--card-base) 28%, white);
    --next-card-surface: color-mix(in srgb, var(--next-card-base) 28%, white);
    --wave-height: clamp(120px, 22dvh, 190px);
    height: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    width: 100%;
    min-height: calc(100dvh - var(--header-height));
    margin: 0;
    padding: clamp(88px, 16dvh, 150px) var(--content-gutter);
    padding-block-start: calc(clamp(88px, 16dvh, 150px) - var(--quiz-wave-offset) * 2);
    box-sizing: border-box;
    &:first-child {
      padding-block-start: clamp(88px, 16dvh, 150px);
    }
    border-radius: 0;
    background: linear-gradient(to bottom, var(--card-surface) 0 calc(100% - var(--wave-height) / 2), var(--next-card-surface) calc(100% - var(--wave-height) / 2) 100%);
    scroll-snap-align: start;
    & .question-text {
      width: min(100%, var(--width-m));
      align-self: center;
      margin-bottom: 28px;
      font-size: clamp(20px, 4.5vw, 26px);
      font-weight: 700;
      line-height: 1.4;
      color: var(--card-text, var(--text-main));
    }
    & .question-char {
      display: inline-block;
      white-space: pre;
      transform: translateY(0);
    }
    & .options-bars {
      position: relative;
      z-index: 2;
      display: grid;
      grid-auto-flow: column;
      grid-auto-columns: minmax(0, 1fr);
      gap: clamp(8px, 2vw, 16px);
      width: 100%;
      max-width: var(--width-m);
      margin: 8px auto 0;
      & .answer-option {
        display: grid;
        grid-template-rows: 132px auto;
        gap: 12px;
        min-width: 0;
      }
      & .opt-btn {
        align-self: end;
        width: 100%;
        height: var(--answer-height);
        min-height: 44px;
        display: grid;
        place-items: center;
        position: relative;
        padding: 0;
        cursor: pointer;
        color: var(--card-text);
        border: 0;
        border-radius: 0;
        background: transparent;
        transition: transform .1s ease, color .2s ease;
        & .answer-shape {
          position: absolute;
          inset: 0;
          width: 100%;
          height: 100%;
          overflow: visible;
          pointer-events: none;
        }
        & .answer-shape path {
          fill: color-mix(in srgb, var(--card-base) 15%, white);
          stroke: var(--card-base);
          stroke-width: 1.5;
          transition: fill 0.2s ease;
        }
        & .scale-check {
          position: absolute;
          left: 50%;
          top: 50%;
          z-index: 1;
          font-size: 24px;
          line-height: 1;
          opacity: 0;
          transform: translate(-50%, -50%);
        }
        &:hover {
          background: transparent;
          & .answer-shape path {
            fill: color-mix(in srgb, var(--card-base) 28%, white);
          }
        }
        &.selected {
          background: transparent;
          color: #fff;
          & .answer-shape path {
            fill: var(--card-base);
          }
          & .scale-check {
            opacity: 1;
          }
        }
        &:focus-visible {
          outline: 3px solid var(--card-text);
          outline-offset: 4px;
        }
        &:active {
          transform: scale(.99);
        }
      }
      & .answer-label {
        overflow-wrap: anywhere;
        text-align: center;
        font-size: 13px;
        font-weight: 600;
        line-height: 1.5;
        color: var(--card-text);
        & small {
          display: block;
          margin-top: 4px;
          font-size: 11px;
          font-weight: 400;
        }
      }
      &:has(.answer-option:nth-child(6)) {
        gap: 6px;
        & .answer-label {
          font-size: 11px;
        }
      }
    }
    &:not(:last-child)::after {
      position: absolute;
      left: 0;
      bottom: calc(var(--wave-height) / -2);
      width: 100%;
      height: var(--wave-height);
      z-index: 1;
      content: "";
      background: var(--card-surface);
      pointer-events: none;
      mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 80' preserveAspectRatio='none'%3E%3Cpath fill='white' d='M0 0H1440V40C1200 0 1080 80 720 40S240 0 0 40Z'/%3E%3C/svg%3E") 0 0 / 200% 100% no-repeat;
      animation: question-wave-drift 18s ease-in-out infinite alternate;
    }
    &.question-animate .question-char {
      animation: question-letter-bounce 760ms cubic-bezier(.33, .05, .25, 1) both;
      animation-delay: calc(var(--char-index) * 32ms);
    }
  }
}
.analysis-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
  overflow: hidden;
  isolation: isolate;
  background: transparent;
  opacity: 1;
  transition: opacity 450ms ease;
  & .analysis-text {
    font-weight: 700;
    font-size: clamp(16px, 3vw, 20px);
    color: #33304a;
  }
  & .analysis-field {
    inset: -10%;
    position: absolute;
    overflow: hidden;
    background: #fff;
    filter: blur(28px);
    mask-image: radial-gradient(ellipse at center, transparent var(--analysis-opening), #000 calc(var(--analysis-opening) + 18%));
    animation: analysis-edge-enter 1500ms ease-out both;
    & span {
      width: 78vmax;
      height: 78vmax;
      position: absolute;
      left: var(--blob-x);
      top: var(--blob-y);
      opacity: .78;
      border-radius: 45%;
      background: radial-gradient(ellipse, var(--blob-color) 0% 20%, transparent 72%);
      transform: translate(-50%, -50%);
      animation: analysis-color-sway 3.8s ease-in-out infinite alternate;
      animation-delay: var(--blob-delay);
    }
    & span:nth-child(1) { --blob-color: #ff83b5; --blob-x: 0%; --blob-y: 0%; --blob-delay: -1s; }
    & span:nth-child(2) { --blob-color: #73b7ff; --blob-x: 100%; --blob-y: 0%; --blob-delay: -2.8s; }
    & span:nth-child(3) { --blob-color: #ffae65; --blob-x: 0%; --blob-y: 100%; --blob-delay: -1.8s; }
    & span:nth-child(4) { --blob-color: #e3ff48; --blob-x: 100%; --blob-y: 100%; --blob-delay: -3.5s; }
    & span:nth-child(5) { --blob-color: #73b7ff; --blob-x: 45%; --blob-y: 42%; --blob-delay: -2.2s; }
    & span:nth-child(6) { --blob-color: #ff83b5; --blob-x: 82%; --blob-y: 40%; --blob-delay: -0.8s; }

  }
  &::after {
    z-index: 2;
    position: absolute;
    inset: -140px;
    opacity: 0;
    content: "";
    background: var(--result-color);
    mask-image: radial-gradient(ellipse at 48% 46%, #000 0%, rgb(0 0 0 / var(--wash-edge-alpha)) 85%);
    filter: blur(60px);
  }
  & .analysis-copy {
    z-index: 3;
    position: relative;
    margin: 24px;
    text-align: center;
    animation: analysis-copy-enter 900ms 150ms ease both;
    transition: opacity 650ms ease, transform 450ms ease;
  }
  &.analysis-settling::after {
    animation: analysis-center-fade 1800ms ease-in-out both;
  }
  &.analysis-revealing {
    opacity: 1;
    pointer-events: none;
    mask-image: linear-gradient(#000, #000), url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20100%20100%22%3E%3Cdefs%3E%3Cfilter%20id%3D%22soft%22%20x%3D%22-30%25%22%20y%3D%22-30%25%22%20width%3D%22160%25%22%20height%3D%22160%25%22%3E%3CfeGaussianBlur%20stdDeviation%3D%225%22%2F%3E%3C%2Ffilter%3E%3C%2Fdefs%3E%3Cpath%20fill%3D%22white%22%20filter%3D%22url%28%23soft%29%22%20d%3D%22M50%209C61%203%2064%2019%2076%2014S96%2031%2088%2043S99%2062%2083%2072S75%2097%2059%2090S40%20101%2030%2087S6%2080%2015%2062S2%2043%2014%2032S20%2010%2035%2016S41%206%2050%209Z%22%2F%3E%3C%2Fsvg%3E");
    mask-size: 100% 100%, var(--result-reveal-radius) var(--result-reveal-radius);
    mask-position: center;
    mask-repeat: no-repeat;
    mask-composite: exclude;
    animation: analysis-result-reveal 3200ms linear both;
    & .analysis-copy {
      opacity: 0;
      animation: none;
      transform: translateY(-8px);
    }
  }
  &::before {
    position: absolute;
    inset: -140px;
    z-index: 1;
    opacity: 0;
    content: "";
    background: #fff;
    mask-image: radial-gradient(ellipse at 48% 46%, #000 0%, rgb(0 0 0 / var(--wash-edge-alpha)) 85%);
    filter: blur(60px);
  }
  &.analysis-white::before {
    animation: analysis-center-fade 1800ms ease-in-out both;
  }
}
#view-result {
  --result-background: color-mix(in srgb, var(--result-color) 80%, white);
  --color-theme: var(--result-ink);
  --color-theme-hover: var(--result-ink);
  position: relative;
  isolation: isolate;
  overflow: clip;
  padding-bottom: 60px;
  background: var(--result-background);
  & .result-container {
    width: var(--width-auto);
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin: 24px auto;
    padding: 0;
  }
  & .result-main-card {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    padding: 32px 24px;
    text-align: center;
    border: 1px solid #ffffffaa;
    border-radius: 28px;
    background: #fffffff0;
    box-shadow: 0 20px 60px color-mix(in srgb, var(--result-ink) 15%, transparent);
    & .result-hero {
      position: relative;
      isolation: isolate;
      margin-bottom: 20px;
      container-type: inline-size;
      &::after {
        position: absolute;
        inset: auto -24px -32px;
        height: 180px;
        z-index: 2;
        content: "";
        pointer-events: none;
        background: linear-gradient(to bottom, #ffffff00, #ffffffb3 55%, #fffffff5);
        -webkit-backdrop-filter: blur(8px);
        backdrop-filter: blur(8px);
        -webkit-mask-image: radial-gradient(ellipse at 50% 48%, black 20%, transparent 72%);
        mask-image: radial-gradient(ellipse at 50% 48%, black 20%, transparent 72%);
      }
      &:has(.character-image[hidden])::after {
        display: none;
      }
    }
    & .type-english {
      position: absolute;
      inset: 0 -12px auto;
      z-index: 0;
      font-family: Impact, "Arial Black", sans-serif;
      font-size: clamp(36px, 24cqw, 140px);
      font-weight: 900;
      line-height: .92;
      letter-spacing: -.035em;
      white-space: pre-line;
      user-select: none;
      color: var(--result-color);
      opacity: .75;
      pointer-events: none;
    }
    & .character-image {
      position: relative;
      z-index: 1;
      display: block;
      width: 100%;
      height: clamp(260px, 65vw, 360px);
      object-fit: contain;
      object-position: center bottom;
      filter: drop-shadow(0 0 12px white) drop-shadow(0 0 24px white);
      &[hidden] {
        display: none;
      }
    }
    & .result-heading {
      position: relative;
      z-index: 3;
      margin-top: -64px;
      text-shadow: 0 1px 4px white, 0 0 12px white, 0 0 24px white;
    }
    & .character-image[hidden] + .result-heading {
      margin-top: 0;
    }
    & .user-badge {
      margin-bottom: 8px;
      font-size: 13px;
      font-weight: 600;
      color: var(--result-ink);
    }
    & .type-name {
      margin-bottom: 12px;
      font-size: clamp(28px, 6vw, 40px);
      font-weight: 900;
      line-height: 1.2;
      color: var(--result-ink);
    }
    & .type-desc {
      padding: 20px;
      font-size: 15px;
      line-height: 1.8;
      text-align: left;
      border-radius: var(--radius-md);
      background: var(--result-surface);
    }
    &::before {
      position: absolute;
      z-index: -1;
      width: 260px;
      height: 260px;
      top: -150px;
      right: -90px;
      content: "";
      border-radius: 50%;
      background: color-mix(in srgb, var(--result-color) 35%, transparent);
    }
  }
  & .result-axes {
    margin-top: 28px;
    text-align: left;
    & .axis-chart-list {
      display: grid;
      gap: 20px;
    }
    & .axis-chart-labels {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 8px;
    }
    & .axis-chart-label {
      --label-enter-x: 12px;
      font-size: 13px;
      font-weight: 400;
      color: var(--text-muted);
      &.is-dominant {
        font-weight: 800;
        color: var(--result-ink);
      }
      &:last-child {
        --label-enter-x: -12px;
      }
    }
    & .axis-chart-track {
      height: 16px;
      position: relative;
      overflow: hidden;
      border-radius: 999px;
      background: color-mix(in srgb, var(--result-color) 30%, white);
      &::after {
        position: absolute;
        inset: 0 auto 0 50%;
        width: 2px;
        z-index: 2;
        content: "";
        background: #ffffffbb;
        transform: translateX(-50%);
      }
    }
    & .axis-chart-marker {
      position: absolute;
      left: clamp(8px, var(--axis-position), calc(100% - 8px));
      top: 50%;
      width: 12px;
      height: 12px;
      z-index: 3;
      border-radius: 50%;
      background: white;
      box-shadow: 0 0 0 2px var(--result-ink), 0 1px 4px #0003;
      transform: translate(-50%, -50%);
    }
    & .axis-chart-negative, & .axis-chart-positive {
      position: absolute;
      inset-block: 0;
      background: var(--result-color);
    }
    & .axis-chart-negative {
      --axis-width: var(--axis-position);
      left: 0;
      width: var(--axis-width);
    }
    & .axis-chart-positive {
      --axis-width: calc(100% - var(--axis-position));
      right: 0;
      width: var(--axis-width);
    }
    & [data-dominant="negative"] .axis-chart-negative,
      & [data-dominant="positive"] .axis-chart-positive {
      background: var(--result-ink);
    }
    & .axes-pending {
      & .axis-chart-negative, & .axis-chart-positive {
        width: 0;
      }
      & .axis-chart-marker {
        opacity: 0;
      }
      & .axis-chart-label {
        opacity: 0;
        filter: blur(10px);
        transform: translateX(var(--label-enter-x));
      }
    }
    & .axes-entering {
      & .axis-chart-marker {
        animation: axis-marker-reveal 540ms ease-out var(--axis-delay) both;
      }
      & .axis-chart-negative {
        animation: axis-bar-reveal 540ms cubic-bezier(.12, .9, .22, 1) var(--axis-delay) both;
      }
      & .axis-chart-positive {
        animation: axis-bar-reveal 540ms cubic-bezier(.12, .9, .22, 1) var(--axis-delay) both;
      }
      & .axis-chart-label {
        animation: axis-label-reveal 540ms ease-out var(--axis-delay) both;
      }
    }
  }
  & .result-connect-card {
    padding: 24px 20px;
    border: 1px solid #ffffffaa;
    border-radius: 28px;
    background: #fffffff0;
    box-shadow: 0 12px 32px color-mix(in srgb, var(--result-ink) 10%, transparent);
  }
  & .encounter-guide {
    margin-bottom: 24px;
    padding: 0;
    text-align: left;
    &[hidden] {
      display: none;
    }
    & h3 {
      font-size: 18px;
      line-height: 1.5;
      color: var(--result-ink);
    }
    & .encounter-colors {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 12px;
      margin: 24px 0;
    }
    & .encounter-color-item {
      display: grid;
      gap: 8px;
      flex: 1;
      min-width: 0;
      justify-items: center;
    }
    & .encounter-label {
      font-size: 12px;
      line-height: 20px;
      color: var(--text-muted);
    }
    & .encounter-color {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      max-width: 180px;
      min-height: 52px;
      overflow-wrap: anywhere;
      padding: 10px 12px;
      font-size: 17px;
      font-weight: 800;
      line-height: 1.5;
      text-align: center;
      border-radius: 999px;
      &[hidden] {
        display: none;
      }
    }
    & .encounter-targets {
      display: grid;
      gap: 8px;
      width: 100%;
      justify-items: center;
    }
    & .own-color {
      width: fit-content;
      min-width: min(180px, 100%);
      max-width: min(240px, 100%);
      gap: 8px;
      padding: 6px 10px 6px 6px;
      font-size: 14px;
      text-align: center;
      background: var(--result-color);
      color: var(--result-ink);
      & #res-own-color {
        flex: 1;
        min-width: 0;
        text-align: center;
        text-wrap: balance;
      }
    }
    & .encounter-avatar {
      position: relative;
      flex: 0 0 44px;
      width: 44px;
      height: 44px;
      overflow: hidden;
      border-radius: 50%;
      background: #fff;
      & img {
        position: absolute;
        left: 50%;
        top: 50%;
        width: var(--avatar-scale, 240%);
        max-width: none;
        height: auto;
        transform: translate(calc(-1 * var(--avatar-x, 50%)), calc(-1 * var(--avatar-y, 30%)));
      }
    }
    & .target-color {
      background: var(--target-color);
      color: var(--target-ink);
    }
    & .encounter-arrow {
      align-self: stretch;
      display: grid;
      place-items: center;
      padding-top: 28px;
      font-size: 24px;
      line-height: 1;
      color: var(--result-ink);
    }
    @media (max-width: 600px) {
      & .encounter-colors {
        flex-direction: column;
        gap: 16px;
      }
      & .encounter-color-item {
        flex: none;
        width: 100%;
      }
      & .own-color {
        font-size: 15px;
      }
      & .encounter-arrow {
        align-self: center;
        padding-top: 0;
        transform: rotate(90deg);
      }
      & .encounter-targets {
        display: flex;
        justify-content: center;
        gap: 10px;
      }
      & .target-color {
        width: auto;
        min-width: 100px;
        max-width: 150px;
      }
    }
    & h4 {
      margin-bottom: 10px;
      font-size: 14px;
      color: var(--result-ink);
    }
    & .encounter-personality {
      font-size: 16px;
      font-weight: 700;
      line-height: 1.8;
      white-space: pre-line;
    }
  }
  & .dual-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    & button {
      flex: 1;
      padding: 16px;
      font-size: 15px;
      font-weight: 700;
      border: none;
      border-radius: var(--radius-md);
      cursor: pointer;
      transition: background 0.15s ease;
    }
    & .share-trigger-btn {
      background: var(--color-theme);
      color: var(--text-inverse);
      &:hover {
        background: var(--color-theme-hover);
      }
    }
    & .match-trigger-btn {
      color: var(--result-ink);
      background: var(--result-surface);
      border: 2px solid var(--result-ink);
      &:hover {
        background: var(--result-color);
      }
      &:focus-visible {
        outline: 3px solid var(--result-ink);
        outline-offset: 3px;
      }
    }
    @media (max-width: 420px) {
      flex-direction: column;
      & button {
        padding: 16px;
        font-size: 14px;
      }
    }
  }
  & .match-history-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 12px;
    & .section-title {
      font-size: 16px;
      font-weight: 800;
      color: var(--result-ink);
    }
    & .match-history-list {
      display: flex;
      flex-direction: column;
      gap: 10px;
      & .match-history-card {
        gap: 10px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 20px;
        cursor: pointer;
        background: #ffffffcc;
        border-radius: 16px;
        &:hover {
          background: var(--history-surface);
        }
        & .match-info {
          flex: 1;
          flex-direction: column;
          min-width: 0;
          overflow-wrap: anywhere;
          display: flex;
          gap: 1px;
          line-height: 1.35;
          & .match-type { font-size: 13px; color: var(--history-ink); }
          & .match-target-code {
            font-size: 15px;
            font-weight: 700;
            font-family: 'Courier New', monospace;
            color: var(--text-main);
          }
          & .match-date {
            font-size: 10px;
            color: var(--text-muted);
          }
        }
        & .match-score-badge {
          flex-shrink: 0;
          font-size: 20px;
          font-weight: 900;
          color: var(--history-ink, var(--color-theme));
        }
      }
      & .no-match-history {
        padding: 24px;
        text-align: center;
        font-size: 14px;
        color: var(--text-muted);
        background: #ffffffcc;
        border-radius: 16px;
      }
    }
  }
  &::before {
    position: absolute;
    inset: -15%;
    z-index: -1;
    content: "";
    pointer-events: none;
    background: radial-gradient(ellipse at 12% 15%, #ffffffaa, transparent 55%), radial-gradient(ellipse at 90% 30%, color-mix(in srgb, var(--result-color) 65%, var(--result-ink)), transparent 60%), radial-gradient(ellipse at 40% 95%, var(--result-surface), transparent 65%);
    filter: blur(45px);
    animation: result-color-drift 22s ease-in-out infinite alternate;
  }
  & .dual-actions button small {
    display: block;
    margin-top: 5px;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.5;
    opacity: .85;
  }
}
.share-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  & .qr-box {
    width: 200px;
    height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: #ffffff;
    border-radius: 0 !important;
    & img, & canvas {
      width: 100%;
      height: 100%;
      object-fit: contain;
      border-radius: 0 !important;
    }
  }
  & .standalone-code-wrapper {
    width: 100%;
    min-width: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6px 0;
    user-select: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
    &:hover {
      background: var(--bg-sub);
    }
    & .standalone-code-text {
      font-size: clamp(15px, 4.4vw, 28px);
      font-family: 'Courier New', monospace;
      font-weight: 800;
      letter-spacing: .035em;
      white-space: nowrap;
      text-align: center;
      line-height: 1.2;
      color: var(--text-main);
      transition: color 0.2s ease;
    }
  }
  & .insta-action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    width: 100%;
    margin-top: 6px;
    & .insta-btn {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding: 14px 4px;
      background: var(--bg-sub);
      border: none;
      border-radius: var(--modal-inner-radius);
      color: var(--text-main);
      cursor: pointer;
      transition: background 0.15s ease, transform 0.1s ease;
      &:hover {
        background: #e2e8f0;
      }
      &:active {
        transform: scale(0.97);
      }
      & svg {
        width: 22px;
        height: 22px;
        stroke: var(--text-main);
      }
      & span {
        font-size: 11px;
        font-weight: 700;
        white-space: nowrap;
      }
    }
  }
}
#view-match {
  padding-bottom: 80px;
  & .match-page-container {
    width: var(--width-auto);
    display: flex;
    flex-direction: column;
    gap: 28px;
    margin: 28px auto;
    padding: 0;
  }
  & .match-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    & .back-to-result-btn {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 8px 14px;
      font-size: 13px;
      font-weight: 600;
      background: transparent;
      border: none;
      border-radius: var(--radius-sm);
      color: #30364a;
      cursor: pointer;
      &:hover {
        color: var(--text-main);
        background: transparent;
      }
    }
  }
  & .match-score-hero-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    & .match-score-title {
      font-size: 15px;
      font-weight: 700;
      letter-spacing: 0.05em;
      color: #30364a;
    }
    & .score-num {
      display: inline-flex;
      align-items: baseline;
      justify-content: center;
      font-weight: 900;
      line-height: 1;
      & .score-percent {
        margin-left: 2px;
        font-size: 0.8em;
      }
      font-size: clamp(88px, 19vw, 128px);
      font-variant-numeric: tabular-nums;
      color: #202536;
      text-shadow: 0 2px 24px #ffffff70;
    }
    padding: 32px 0 0;
  }
  & .match-details-reveal {
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    &.show {
      opacity: 1;
      pointer-events: auto;
      transform: translateY(0);
    }
    & .advice-card {
      background: transparent;
      border-radius: var(--radius-md);
      & .advice-text {
        font-size: 15px;
        line-height: 1.8;
        color: var(--text-main);
      }
    }
    & .match-axis-insights {
      display: grid;
      &[hidden] {
        display: none;
      }
      gap: 36px;
    }
    & .match-axis-insight {
      border-radius: var(--radius-md);
      background: transparent;
      & h3 {
        font-size: 18px;
      }
    }
    & .match-axis-pattern {
      margin: 6px 0 14px;
      font-size: 13px;
      color: #30364a;
    }
    & .match-axis-text {
      font-size: 15px;
      line-height: 1.9;
    }
    & .match-pair-card {
      align-items: flex-start;
      justify-content: space-between;
      background: transparent;
      border-radius: var(--radius-md);
      & .pair-profile {
        flex: 1;
        flex-direction: column;
        display: flex;
        align-items: center;
        text-align: center;
        & .pair-name {
          margin-top: 2px;
          font-size: 18px;
          font-weight: 900;
          word-break: break-all;
          color: var(--text-main);
        }
        & .pair-type {
          font-size: 14px;
          font-weight: 700;
          color: #202536;
        }
        & .pair-desc {
          width: 100%;
          margin-top: 6px;
          font-size: 12px;
          line-height: 1.6;
          text-align: left;
          color: #30364a;
          background: transparent;
          border-radius: var(--radius-sm);
        }
      }
      & .pair-vs {
        flex-shrink: 0;
        margin-top: 36px;
        font-weight: 900;
        user-select: none;
        color: #30364a;
      }
      padding: 0;
      & .pair-type {
        color: #202536;
      }
      & .pair-desc {
        padding: 0;
        background: transparent;
        color: #30364a;
      }
    }
    gap: 40px;
    & .advice-card, & .match-axis-insight {
      padding: 0;
    }
    & .match-axis-insight h3 {
      color: #202536;
    }
  }
  --color-theme: var(--match-my-ink);
  --color-theme-hover: var(--match-my-ink);
  position: relative;
  isolation: isolate;
  overflow: clip;
  min-height: calc(100svh - var(--header-height));
  background: linear-gradient(135deg, var(--match-my-surface), var(--match-partner-surface));
  &::before {
    position: fixed;
    inset: -12%;
    z-index: -1;
    content: "";
    pointer-events: none;
    background: var(--match-field);
    filter: blur(36px);
    animation: result-color-drift 18s ease-in-out infinite alternate;
  }
  & .match-score-hero-card,
  & .advice-card,
  & .match-axis-insight,
  & .match-pair-card {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
  & .pair-profile:last-child {
    & .pair-type {
      color: var(--match-partner-ink);
    }
  }
  color: #202536;
  & .match-color-field {
    position: fixed;
    inset: -15%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    filter: blur(32px);
    & span {
      position: absolute;
      left: var(--spot-x);
      top: var(--spot-y);
      width: 68vmax;
      height: 58vmax;
      opacity: .68;
      border-radius: 45%;
      background: radial-gradient(ellipse, var(--spot-color) 0%, transparent 68%);
      animation: match-spot-orbit var(--spot-duration) ease-in-out infinite alternate;
      animation-delay: var(--spot-delay);
    }
    & span:nth-child(1) {
      --spot-color: var(--match-my-deep);
      --spot-x: 8%;
      --spot-y: 24%;
      --spot-duration: 13s;
      --spot-delay: -4s;
    }
    & span:nth-child(2) {
      --spot-color: var(--match-partner-color);
      --spot-x: 75%;
      --spot-y: 18%;
      --spot-duration: 17s;
      --spot-delay: -11s;
      animation-direction: alternate-reverse;
    }
    & span:nth-child(3) {
      --spot-color: var(--match-my-glow);
      --spot-x: 55%;
      --spot-y: 60%;
      --spot-duration: 11s;
      --spot-delay: -7s;
    }
    & span:nth-child(4) {
      --spot-color: var(--match-partner-deep);
      --spot-x: 30%;
      --spot-y: 72%;
      --spot-duration: 19s;
      --spot-delay: -3s;
      animation-direction: alternate-reverse;
    }
    & span:nth-child(5) {
      --spot-color: var(--match-my-color);
      --spot-x: 85%;
      --spot-y: 80%;
      --spot-duration: 15s;
      --spot-delay: -12s;
    }
    & span:nth-child(6) {
      --spot-color: var(--match-partner-glow);
      --spot-x: 20%;
      --spot-y: 5%;
      --spot-duration: 21s;
      --spot-delay: -9s;
      animation-direction: alternate-reverse;
    }
  }
  & .match-details-reveal .match-pair-card {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
    & .pair-profile {
      min-width: 0;
      gap: 12px;
      & .pair-hero {
        position: relative;
        isolation: isolate;
        width: 100%;
        &::after {
          position: absolute;
          inset: auto 0 0;
          height: 48%;
          z-index: 2;
          content: "";
          pointer-events: none;
          background: transparent;
          backdrop-filter: blur(10px);
          -webkit-backdrop-filter: blur(10px);
          mask-image: linear-gradient(to bottom, transparent, #000 75%);
          -webkit-mask-image: linear-gradient(to bottom, transparent, #000 75%);
        }
        &:has(.pair-image[hidden])::after {
          display: none;
        }
        & .pair-image {
          display: block;
          width: 100%;
          height: clamp(180px, 38vw, 310px);
          object-fit: contain;
          object-position: center bottom;
          filter: none;
          mask-image: linear-gradient(to bottom, #000 65%, rgb(0 0 0 / .65) 82%, transparent);
          -webkit-mask-image: linear-gradient(to bottom, #000 65%, rgb(0 0 0 / .65) 82%, transparent);
          &[hidden] {
            display: none;
          }
        }
        & .pair-heading {
          position: relative;
          z-index: 3;
          min-height: 64px;
          margin-top: -45px;
          padding: 4px 2px 12px;
          text-shadow: none;
          & .pair-name {
            overflow-wrap: anywhere;
            margin: 0 0 6px;
            font-size: 11px;
            font-weight: 600;
            color: #30364a;
          }
          & .pair-type {
            overflow-wrap: anywhere;
            font-size: clamp(17px, 3.5vw, 26px);
            font-weight: 900;
            line-height: 1.3;
            color: #202536;
          }
        }
      }
      & .pair-desc {
        padding: 0;
        margin: 0;
      }
    }
    & .pair-vs {
      position: absolute;
      left: 50%;
      top: clamp(90px, 19vw, 155px);
      margin: 0;
      font-size: 20px;
      transform: translate(-50%, -50%);
    }
  }
}
.match-modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  & .match-input-label {
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    color: var(--text-muted);
  }
  & .input-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    align-items: center;
    width: 100%;
    & .input-clear-wrapper {
      min-width: 0;
      position: relative;
      flex: 1;
      & input[type="text"] {
        width: 100%;
        padding: 16px 40px 16px 16px;
        font-size: clamp(14px, 4vw, 20px);
        font-family: 'Courier New', monospace;
        font-weight: 700;
        letter-spacing: .015em;
        text-align: center;
        background: var(--bg-sub);
        border: none;
        border-radius: var(--modal-inner-radius);
        text-transform: uppercase;
        outline: none;
      }
      & .input-clear-btn {
        display: none;
        position: absolute;
        right: 12px;
        top: 50%;
        width: 22px;
        height: 22px;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        line-height: 1;
        background: #cbd5e1;
        border: none;
        border-radius: 50%;
        color: #475569;
        cursor: pointer;
        transform: translateY(-50%);
        &.show {
          display: flex;
        }
      }
    }
    & .camera-scan-btn {
      width: 56px;
      height: 56px;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      background: var(--bg-sub);
      color: var(--text-main);
      border: none;
      border-radius: var(--modal-inner-radius);
      cursor: pointer;
      &:hover {
        background: #e2e8f0;
      }
      & svg {
        width: 24px;
        height: 24px;
      }
    }
  }
  & .field-error-msg {
    display: none;
    margin-left: 2px;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    color: var(--color-danger);
    &.show {
      display: block;
    }
  }
  & .calc-btn {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    font-weight: 700;
    background: var(--color-theme);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--modal-inner-radius);
    cursor: pointer;
    transition: background 0.15s ease;
    &:hover {
      background: var(--color-theme-hover);
    }
  }
  & #qr-reader-viewport {
    display: none;
    width: 100%;
    overflow: hidden;
    border-radius: var(--modal-inner-radius);
    background: #000;
  }
}
.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  & .history-item {
    gap: 12px;
    flex-wrap: wrap;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg-sub);
    border-radius: var(--modal-inner-radius);
    cursor: pointer;
    &:hover {
      background: #e2e8f0;
    }
    & .item-info {
      font-size: 14px;
      & .item-date {
        font-size: 12px;
        color: var(--text-muted);
      }
    }
    & .item-type {
      font-size: clamp(12px, 3.5vw, 15px);
      font-weight: 700;
      white-space: nowrap;
      letter-spacing: 0;
      color: var(--color-theme);
    }
  }
}
.menu-overlay {
  display: block;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  z-index: 999;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}
@keyframes question-wave-drift {
  from {
    mask-position: 0% 0;
  }
  to {
    mask-position: 100% 0;
  }
}
@keyframes question-letter-bounce {
  0%, 12% {
    color: var(--card-text);
    text-shadow: none;
    transform: translateY(0);
  }
  30% {
    color: var(--card-text);
    transform: translateY(-10px) rotate(-2deg);
  }
  48% {
    color: var(--card-text);
    transform: translateY(0) rotate(0deg);
  }
  62%, 72% {
    color: var(--card-base);
    text-shadow: 0 0 12px color-mix(in srgb, var(--card-base) 60%, transparent);
    transform: translateY(0);
  }
  100% {
    color: var(--card-text);
    text-shadow: none;
    transform: translateY(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  #view-quiz .snap-card::after,
  #view-quiz .snap-card.question-animate .question-char {
    animation: none;
  }
  .analysis-overlay {
    & .analysis-field, & .analysis-copy, & .analysis-field span {
      animation: none;
    }
  }
  #view-result::before {
    animation: none;
  }
  .analysis-overlay .analysis-field {
    animation: none;
    mask-image: none;
  }
  .analysis-overlay.analysis-revealing {
    opacity: 0;
    animation: none;
    mask-image: none;
  }
}
@keyframes analysis-color-sway {
  0% {
    transform: translate(-65%, -55%) rotate(-18deg) scale(.85);
  }
  55% {
    transform: translate(-35%, -70%) rotate(14deg) scale(1.2);
  }
  100% {
    transform: translate(-45%, -30%) rotate(28deg) scale(1.05);
  }
}
body:has(#view-result.active) {
  --color-theme: var(--result-ink);
  --color-theme-hover: var(--result-ink);
  background: var(--bg-body);
  & .global-header {
    --header-end-color: color-mix(in srgb, var(--result-color) 18%, white);
    & .header-logo {
      color: var(--result-ink);
    }
  }
}
.privacy-container {
  width: var(--width-auto);
  margin: 0 auto;
  padding: calc(var(--header-height) + 40px) 0 48px;
  background: transparent;
  & h1 {
    margin-bottom: 24px;
    font: 700 24px/1.3 var(--font-base);
    color: var(--text-main);
  }
  & h2 {
    margin: 24px 0 8px;
    font: 700 16px/1.4 var(--font-base);
    color: var(--text-main);
  }
  & p {
    margin-bottom: 12px;
    font: 400 14px/1.8 var(--font-base);
    color: var(--text-main);
  }
}
@keyframes analysis-copy-enter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
body:has(#analysis-overlay[style*="flex"]:not(.analysis-revealing)) {
  & .app-view, & .global-header {
    filter: blur(14px);
  }
}
@property --analysis-opening {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 78%;
}
@keyframes analysis-edge-enter {
  from {
    --analysis-opening: 78%;
    opacity: 0;
  }
  to {
    --analysis-opening: -20%;
    opacity: 1;
  }
}
@keyframes result-color-drift {
  0% {
    transform: translate(-3%, -2%) rotate(-6deg) scale(1);
  }
  50% {
    transform: translate(4%, 3%) rotate(8deg) scale(1.12);
  }
  100% {
    transform: translate(-2%, 5%) rotate(-3deg) scale(1.04);
  }
}
.field-hint {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}
@media (max-width: 420px) {
  .match-modal-body .input-row {
    gap: 8px;
    & .input-clear-wrapper {
      flex: 1 1 0;
      & input[type="text"] {
        min-height: 48px;
        padding: 14px 36px 14px 8px;
        font-size: 16px;
        letter-spacing: 0;
      }
    }
    & .camera-scan-btn {
      width: 48px;
      height: 48px;
    }
  }
}
@property --result-reveal-radius {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}
@keyframes analysis-result-reveal {
  from {
    --result-reveal-radius: 0px;
    opacity: 1;
  }
  75% {
    opacity: 1;
  }
  to {
    --result-reveal-radius: 260vmax;
    opacity: 0;
  }
}
@property --wash-edge-alpha {
  syntax: "<number>";
  inherits: false;
  initial-value: 0;
}
@keyframes analysis-center-fade {
  from {
    --wash-edge-alpha: 0;
    opacity: 0;
  }
  60% {
    --wash-edge-alpha: .55;
    opacity: .8;
  }
  to {
    --wash-edge-alpha: 1;
    opacity: 1;
  }
}
body:has(.analysis-overlay.analysis-white) .analysis-copy {
  opacity: 0;
  animation: none;
}
body:has(#analysis-overlay.analysis-revealing) {
  & #view-result, & .global-header {
    animation: result-unblur 3200ms ease-in-out both;
  }
}
@keyframes result-unblur {
  from {
    filter: blur(14px);
  }
  to {
    filter: blur(0);
  }
}
@keyframes axis-bar-reveal {
  from {
    width: 0;
  }
  to {
    width: var(--axis-width);
  }
}

@keyframes axis-label-reveal {
  from {
    opacity: 0;
    filter: blur(10px);
    transform: translateX(var(--label-enter-x));
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: translateX(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  #view-result .result-axes {
    & .axes-pending, & .axes-entering {
      & .axis-chart-negative {
        width: var(--axis-width);
        animation: none;
      }
      & .axis-chart-positive {
        width: var(--axis-width);
        animation: none;
      }
      & .axis-chart-label {
        opacity: 1;
        animation: none;
        filter: none;
        transform: none;
      }
      & .axis-chart-marker {
        opacity: 1;
        animation: none;
      }
    }
  }
  .analysis-overlay.analysis-white::before,
  .analysis-overlay.analysis-settling::after {
    opacity: 1;
    animation: none;
    mask-image: none;
  }
  body:has(#analysis-overlay.analysis-revealing) {
    & #view-result, & .global-header {
      animation: none;
    }
  }
}
.match-analysis-overlay {
  background: transparent;
  &::after {
    background: radial-gradient(ellipse at 32% 42%, var(--match-my-glow), transparent 65%),
      radial-gradient(ellipse at 12% 78%, var(--match-my-deep), transparent 66%),
      var(--match-my-color);
  }
  & .match-partner-wash {
    position: absolute;
    inset: -140px;
    z-index: 3;
    opacity: 0;
    background: var(--match-field);
    filter: blur(60px);
    mask-image: radial-gradient(ellipse at 65% 48%, #000 0%, rgb(0 0 0 / var(--wash-edge-alpha)) 85%);
  }
  mask-image: radial-gradient(circle at var(--match-origin-x, 50vw) var(--match-origin-y, 50vh),
    #000 max(0px, calc(var(--match-cover-radius) - 90px)), transparent calc(var(--match-cover-radius) + 110px));
  animation: match-button-cover 1250ms ease-out both;
  & .analysis-field {
    inset: -10%;
    background: linear-gradient(135deg, #ff83b5, #ffae65 30%, #e3ff48 60%, #73b7ff);
    animation: none;
    mask-image: none;
    clip-path: none;
  }
  & .analysis-field span {
    animation-duration: 2.8s;
  }
  &.match-partner .match-partner-wash {
    mask-image: none;
    animation: match-palette-mix 1300ms linear both;
  }
  &.analysis-revealing {
    mask-image: radial-gradient(circle at 50% 42%, transparent var(--result-reveal-radius), #000 calc(var(--result-reveal-radius) + 140px));
    mask-size: auto;
    mask-composite: add;
    animation: match-center-open 1700ms ease-out both;
  }
}
html:has(#view-match.active), body:has(#view-match.active) {
  --bg-body: var(--match-top-color, #f8fafc);
  background-color: var(--bg-body);
}
body:has(#view-match.active) .global-header {
  --header-end-color: transparent;
  box-shadow: none;
}
body:has(.match-analysis-overlay[style*="flex"]:not(.analysis-revealing)) {
  & .app-view.active {
    filter: blur(14px);
    transition-duration: 1250ms;
  }
}
body:has(.match-analysis-overlay.analysis-revealing) {
  & #view-match .match-page-container {
    animation: result-unblur 1700ms ease-in-out both;
    animation-duration: 1700ms;
  }
}
@media (prefers-reduced-motion: reduce) {
  #view-match::before,
  body:has(.match-analysis-overlay.analysis-revealing) #view-match {
    animation: none;
  }
  #view-match .match-details-reveal {
    transition: none;
    transform: none;
  }
  .match-analysis-overlay.match-partner .match-partner-wash {
    mask-image: none;
  }
}
body:has(.match-analysis-overlay[style*="flex"]) {
  overflow: hidden;
}
#match-score-card:focus {
  outline: none;
}
@keyframes match-spot-orbit {
  0% {
    transform: translate(-75%, -60%) rotate(-25deg) scale(.8);
  }
  35% {
    transform: translate(-20%, -85%) rotate(30deg) scale(1.15, .9);
  }
  70% {
    transform: translate(-65%, -10%) rotate(-10deg) scale(.95, 1.2);
  }
  100% {
    transform: translate(-10%, -45%) rotate(45deg) scale(1.15);
  }
}
@media (prefers-reduced-motion: reduce) {
  #view-match .match-color-field span {
    animation: none;
    transform: translate(-50%, -50%);
  }
}
@media (prefers-reduced-motion: reduce) {
  body:has(.match-analysis-overlay.analysis-revealing) {
    & #view-match .match-page-container {
      animation: none;
    }
  }
}
@keyframes match-center-open {
  from {
    --result-reveal-radius: 0px;
    opacity: 1;
  }
  65% {
    opacity: 1;
  }
  to {
    --result-reveal-radius: 150vmax;
    opacity: 0;
  }
}
::view-transition-group(match-history-return) {
  animation-duration: 500ms;
  animation-timing-function: cubic-bezier(.2,.7,.2,1);
}
::view-transition-old(match-history-return),
::view-transition-new(match-history-return) {
  height: 100%;
  object-fit: contain;
}
.match-history-card:focus {
  outline: none;
}
@media (prefers-reduced-motion: reduce) {
  .match-analysis-overlay.analysis-revealing {
    opacity: 0;
    animation: none;
    mask-image: none;
  }
  ::view-transition-group(match-history-return) {
    animation-duration: 0s;
  }
}
::view-transition-old(match-history-return) {
  animation: match-return-out 500ms ease both;
}
::view-transition-new(match-history-return) {
  animation: match-return-in 500ms ease both;
}
@keyframes match-return-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
@keyframes match-return-in {
  0%, 55% {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes match-palette-mix {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .match-analysis-overlay.match-partner .match-partner-wash {
    opacity: 1;
    animation: none;
  }
}
.shared-match-invite {
  padding: 22px 24px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 8px 30px #4f46e512;
  & h2 {
    margin: 0 0 8px;
    font-size: 20px;
    line-height: 1.5;
  }
  & p {
    margin: 0;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-muted);
  }
  &[hidden] {
    display: none;
  }
}
@property --match-cover-radius {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}
@keyframes match-button-cover {
  from {
    --match-cover-radius: 0px;
    opacity: 0;
  }
  to {
    --match-cover-radius: 150vmax;
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .match-analysis-overlay .analysis-field {
    animation: none;
    clip-path: none;
  }
}
@keyframes top-colors-drift {
  from {
    transform: translate(-1%, -1%) scale(1);
  }
  to {
    transform: translate(1%, 1%) scale(1.06) rotate(2deg);
  }
}
.shared-character-name {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 5px;
  padding: 3px 8px;
  font-size: 12px;
  border-radius: 999px;
  background: #ffffffe0;
}
.site-footer {
  position: relative;
  width: min(767px, calc(100% - 40px));
  margin: 48px auto 0;
  padding: 24px 0 30px;
  font-size: 12px;
  line-height: 1.9;
  border-top: 1px solid #64748b26;
  color: var(--text-muted);
  & p {
    margin: 0 0 16px;
  }
  & .footer-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  & a {
    text-underline-offset: 3px;
    color: inherit;
  }
}
.match-history-avatar {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  overflow: hidden;
  border: 3px solid var(--history-color);
  border-radius: 50%;
  background: #fff;
  color: var(--history-ink);
  & img {
    position: absolute;
    left: 50%;
    top: 50%;
    width: var(--avatar-scale, 240%);
    max-width: none;
    height: auto;
    max-height: none;
    object-fit: contain;
    align-self: start;
    transform: translate(calc(-1 * var(--avatar-x, 50%)), calc(-1 * var(--avatar-y, 30%)));
  }
}
@media (prefers-reduced-motion: reduce) {
  #view-top .top-type-grid::before {
    animation: none;
  }
}
body:has(#view-top.active), body.privacy-page {
  background: radial-gradient(ellipse at 0% 5%, #ffe4f180, transparent 55%),
    radial-gradient(ellipse at 100% 24%, #e0efff90, transparent 55%),
    radial-gradient(ellipse at 0% 75%, #fff0e380, transparent 55%),
    radial-gradient(ellipse at 100% 100%, #f5ffd780, transparent 55%), #fff;
  background-attachment: fixed;
}
.field-error {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.6;
  color: #b91c1c;
  &[hidden] {
    display: none;
  }
}
#btn-start-questions {
  width: 100%;
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  background: var(--color-theme);
  color: #fff;
  border: none;
  border-radius: var(--modal-inner-radius);
  cursor: pointer;
  transition: background 0.15s ease;
  &:disabled {
    background: #e2e8f0;
    color: #64748b;
    cursor: not-allowed;
  }
}
.privacy-page {
  --header-menu-height: calc(var(--header-height) + 200px);
  & .header-logo {
    text-decoration: none;
  }
  & .header-nav-action {
    text-decoration: none;
  }
}
@keyframes axis-marker-reveal {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.start-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  & .field-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 700;
  }
  & .nickname-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: none;
    border-radius: var(--modal-inner-radius);
    background: var(--bg-sub);
    outline: none;
    &[aria-invalid="true"] { box-shadow: inset 0 0 0 1px #b91c1c; }
  }
  & .privacy-consent {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted);
    & .privacy-checkbox {
      width: 18px;
      height: 18px;
      margin-top: 2px;
      accent-color: var(--color-theme);
      cursor: pointer;
    }
    & .privacy-link {
      text-decoration: underline;
      color: var(--color-theme);
    }
  }
}
.history-empty {
  font-size: 14px;
  color: var(--text-muted);
}

.match-history-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.match-history-heading .section-title { margin: 0; }
#match-history-count { font-size: 14px; font-weight: 700; color: var(--result-ink); }
.match-score-badge small { margin-left: 2px; font-size: .65em; }
#share-image-status, .offline-status { margin: 6px 0; text-align: center; font-size: 12px; color: var(--text-muted); }
#share-image-status:empty, .offline-status:empty { display: none; }
body:has(.match-analysis-overlay[style*="flex"]) .global-header { filter: none; animation: none; }
body:has(.match-analysis-overlay.analysis-revealing) #view-match { filter: none; transition: none; }

.more-match-history { padding: 12px; border: 0; border-radius: 12px; background: #ffffffcc; color: var(--result-ink); font: inherit; font-weight: 700; cursor: pointer; }
.more-match-history[hidden] { display: none; }
#match-history-status { font-size: 12px; color: #a3265c; }
#match-history-status:empty { display: none; }

.match-history-tools { display: flex; align-items: center; gap: 10px; }
#btn-new-matches { border: 0; border-radius: 99px; padding: 5px 10px; background: var(--result-ink); color: white; font: inherit; font-size: 12px; cursor: pointer; }
#btn-new-matches[hidden] { display: none; }

.back-chevron { font-size: 24px; line-height: 1; font-weight: 400; }
.match-measurement-details { margin-top: 32px; padding-top: 20px; border-top: 1px solid #20253618; font-size: 10px; color: #20253699; }
.match-measurement-details > div { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 4px 0; }
.match-measurement-details dt { min-width: 104px; }
.match-measurement-details dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.share-image-layer { z-index: 1030; }
.share-image-panel { width: min(100% - 24px, 360px); }
.share-image-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.share-image-options button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 148px;
  padding: 20px 12px;
  border: 1px solid var(--result-color);
  border-radius: 16px;
  background: var(--result-surface);
  color: var(--result-ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, transform .2s;
}
.share-image-options button:hover { background: color-mix(in srgb, var(--result-color) 20%, var(--result-surface)); }
.share-image-options button:active { transform: scale(.97); }
.share-image-options button:disabled { opacity: .5; cursor: wait; }
.share-image-options small { font-size: 11px; font-weight: 500; margin-left: 4px; }
.image-format-slot { display: flex; align-items: center; justify-content: center; height: 64px; }
.image-format-icon { display: block; border: 2px solid currentColor; border-radius: 4px; }
.image-format-landscape { width: 64px; aspect-ratio: 16 / 9; }
.image-format-portrait { height: 64px; aspect-ratio: 9 / 16; }
#share-image-dialog-status { margin: 12px 0 0; font-size: 12px; }
#share-image-dialog-status:empty { display: none; }

.domain-transfer-link { display: inline-block; margin: 12px 0; font-size: 12px; color: var(--text-muted); text-decoration: underline; }
.domain-transfer-status, #domain-transfer-status { font-size: 12px; }
.domain-transfer-status:empty, #domain-transfer-status:empty { display: none; }
.domain-transfer-page { max-width: 440px; margin: 15vh auto; padding: 24px; }
.domain-transfer-page h1 { font-size: 22px; margin-bottom: 16px; }
.domain-transfer-page p { margin-bottom: 20px; }
.domain-transfer-page button { padding: 16px 24px; border: 0; border-radius: 12px; background: var(--color-theme); color: white; font: inherit; cursor: pointer; }

/* One neutral logo mask, tinted by the surrounding header theme. */
.brand-logo {
  display: block;
  width: 146px;
  aspect-ratio: 32 / 7;
  background: currentColor;
  mask: url('./img/lovefest-logo-mask.webp') center / contain no-repeat;
  -webkit-mask: url('./img/lovefest-logo-mask.webp') center / contain no-repeat;
}
body:has(#view-match.active) .header-logo { color: var(--match-my-ink); }
@media (max-width: 360px) { .brand-logo { width: 128px; } }
