:root {
  --paper: #f0f2ee;
  --paper-deep: #dfe3df;
  --ink: #082b79;
  --muted: #385081;
  --primary: #0b3fc6;
  --primary-dark: #062b82;
  --secondary: #2458d4;
  --line: #0b3fc6;
  --surface: #fafbf7;
  --shadow-soft: 4px 4px 0 #062b82;
  --shadow-card: 8px 8px 0 #062b82;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(rgba(6, 43, 130, 0.12) 0.55px, transparent 0.65px);
  background-size: 5px 5px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  touch-action: manipulation;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 14px;
  color: #fff;
  background: var(--primary-dark);
  border-radius: 0;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.profile-switcher {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  min-height: 80px;
  padding: 12px 18px;
  grid-template-columns: minmax(56px, 1fr) minmax(0, 510px) minmax(56px, 1fr);
  align-items: center;
  background: rgba(240, 242, 238, 0.96);
  border-bottom: 1px solid var(--primary);
}

.profile-switcher::after {
  content: "";
}

.home-link {
  display: inline-flex;
  width: max-content;
  min-height: 44px;
  padding: 0 14px;
  align-items: center;
  gap: 8px;
  color: var(--primary-dark);
  background: var(--surface);
  border: 1px solid var(--primary);
  box-shadow: 4px 4px 0 var(--primary-dark);
  font-weight: 800;
  text-decoration: none;
  transition: color 180ms ease, background-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.home-link:hover {
  color: #fff;
  background: var(--primary);
}

.home-link:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--primary-dark);
}

.home-link:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.home-link svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.profile-tabs {
  position: relative;
  display: grid;
  width: min(510px, 100%);
  padding: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.profile-tab {
  min-height: 48px;
  padding: 0 18px;
  color: var(--primary-dark);
  background: var(--surface);
  border: 1px solid var(--primary);
  border-radius: 0;
  cursor: pointer;
  font-size: 17px;
  font-weight: 800;
  transition: color 180ms ease, background-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.profile-tab:hover {
  color: #fff;
  background: var(--primary);
}

.profile-tab:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--primary-dark);
}

.profile-tab[aria-selected="true"] {
  color: #fff;
  background: var(--primary);
  box-shadow: var(--shadow-soft);
}

.profile-tab:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

h2 {
  margin: 0;
  font-family: inherit;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.questionnaire {
  outline: none;
}

.profile-hint {
  width: min(calc(100% - 24px), 720px);
  margin: 8px auto 2px;
  color: rgba(56, 80, 129, 0.62);
  font-size: 14px;
  font-style: italic;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
}

.groups {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 0 12px;
}

.choice-group {
  position: relative;
  padding: 4px 0 2px;
}

.choice-group__title {
  display: flex;
  width: min(100%, var(--desktop-grid-width));
  margin: 0 auto 1px;
  align-items: center;
  gap: 10px;
  color: var(--primary-dark);
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0.08em;
  text-align: center;
  white-space: nowrap;
}

.choice-group__title::before,
.choice-group__title::after {
  height: 1px;
  flex: 1;
  background: var(--line);
  content: "";
}

.options {
  display: grid;
  width: min(100%, var(--desktop-grid-width));
  margin: 0;
  padding: 0;
  grid-template-columns: repeat(var(--desktop-columns), minmax(0, 1fr));
  gap: 4px;
  list-style: none;
  margin-inline: auto;
}

.option-button {
  position: relative;
  display: flex;
  width: 100%;
  min-width: 44px;
  min-height: 112px;
  padding: 2px;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  transition: background-color 180ms ease, transform 180ms ease, filter 180ms ease;
}

.option-button:hover {
  background: transparent;
  box-shadow: none;
}

.option-button[aria-pressed="true"] {
  background: transparent;
  box-shadow: none;
}

.option-button:active {
  transform: translate(1px, 1px);
}

.option-button:focus-visible,
.action-button:focus-visible,
.link-row button:focus-visible,
.download-button:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 4px;
}

.option-art {
  display: block;
  transform-origin: bottom center;
  filter: drop-shadow(0 2px 0 rgba(255, 255, 255, 0.7));
  transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1), filter 220ms ease;
}

.option-image {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 108px;
  object-fit: contain;
}

.sprite-art {
  width: min(100%, var(--sprite-width));
  aspect-ratio: var(--sprite-ratio);
  background-repeat: no-repeat;
}

.choice-group[data-group-key="dick_length"] .option-button,
.choice-group[data-group-key="dick_girth"] .option-button {
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
}

.choice-group[data-group-key="dick_length"] .sprite-art {
  width: 60px;
  flex: none;
}

.option-label {
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.option-button:hover .option-art {
  transform: translateY(-2px);
}

.option-button[aria-pressed="true"] .option-art {
  transform: translateY(-3px);
  filter: drop-shadow(2px 3px 0 rgba(6, 43, 130, 0.18));
}

.selection-mark {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--primary);
  border: 2px solid var(--surface);
  border-radius: 0;
  box-shadow: 2px 2px 0 var(--primary-dark);
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  transform: scale(0.65) rotate(-12deg);
  transition: opacity 180ms ease, transform 220ms cubic-bezier(0.2, 0.9, 0.2, 1.3);
}

.option-button[aria-pressed="true"] .selection-mark {
  opacity: 1;
  transform: scale(1) rotate(0);
}

.submit-panel {
  width: min(860px, calc(100% - 36px));
  margin: 28px auto 64px;
  padding: clamp(32px, 5vw, 48px);
  text-align: center;
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: 0;
  box-shadow: var(--shadow-card);
}

.submit-panel h2 {
  font-size: clamp(28px, 4vw, 42px);
}

.submit-panel > p:not(.eyebrow) {
  max-width: 600px;
  margin: 16px auto 28px;
  color: var(--muted);
}

.submit-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.action-button {
  display: inline-flex;
  min-height: 52px;
  padding: 0 22px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--primary-dark);
  border-radius: 0;
  box-shadow: 6px 6px 0 var(--primary-dark);
  cursor: pointer;
  font-weight: 800;
  transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.action-button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 9px 9px 0 var(--primary-dark);
}

.action-button:active {
  transform: translate(2px, 2px);
  box-shadow: 3px 3px 0 var(--primary-dark);
}

.action-button:disabled {
  cursor: wait;
  opacity: 0.66;
  transform: none;
  box-shadow: none;
}

.action-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.action-button--primary {
  color: #fff;
  background: var(--primary);
}

.action-button--secondary {
  color: var(--primary-dark);
  background: var(--surface);
  border: 1px solid var(--line);
}

.result-card {
  margin-top: 28px;
  padding: 20px;
  background: #e8edff;
  border: 1px solid var(--line);
  border-radius: 0;
  text-align: left;
}

.result-card label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 800;
}

.link-row {
  display: flex;
  gap: 10px;
}

.link-row input {
  min-width: 0;
  min-height: 48px;
  flex: 1;
  padding: 0 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
}

.link-row button,
.download-button {
  display: inline-flex;
  min-width: 74px;
  min-height: 48px;
  padding: 0 16px;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--primary-dark);
  border: 1px solid var(--primary-dark);
  border-radius: 0;
  box-shadow: 4px 4px 0 var(--primary-dark);
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.status {
  min-height: 22px;
  margin: 8px 0 0;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 700;
}

.image-result {
  width: 100%;
  margin: 0;
  padding: 0 0 32px;
  background: transparent;
  border: 0;
  text-align: center;
}

.image-result img {
  display: block;
  width: 100%;
  max-height: none;
  margin: 0;
  cursor: zoom-in;
  object-fit: contain;
  background: transparent;
  border: 0;
  border-radius: 0;
  -webkit-touch-callout: default;
  -webkit-user-select: auto;
  user-select: auto;
}

.image-status {
  margin: 14px 16px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.image-actions {
  display: flex;
  margin-top: 16px;
  padding: 0 16px;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.image-actions .download-button {
  width: auto;
  margin: 0;
}

footer {
  display: flex;
  min-height: 72px;
  padding: 14px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 13px;
  text-align: center;
}

footer img {
  border-radius: 50%;
}

.load-error {
  margin: 60px auto;
  padding: 28px;
  color: var(--primary-dark);
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .profile-switcher {
    min-height: 70px;
    padding: 9px 12px;
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    gap: 6px;
  }

  .home-link {
    width: 44px;
    min-height: 44px;
    padding: 0;
    justify-content: center;
  }

  .home-link span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .groups {
    padding: 0 8px;
  }

  .choice-group {
    padding: 3px 0 1px;
  }

  .choice-group__title {
    width: min(100%, var(--mobile-grid-width));
    margin-bottom: 1px;
    gap: 8px;
  }

  .options {
    width: min(100%, var(--mobile-grid-width));
    grid-template-columns: repeat(var(--mobile-columns), minmax(0, 1fr));
    gap: 4px;
  }

  .option-button {
    min-height: 92px;
    padding: 2px;
    align-items: center;
    background: transparent;
  }

  .option-image {
    max-height: 88px;
  }

  .sprite-art {
    width: min(100%, var(--sprite-mobile-width));
  }

  .choice-group[data-group-key="dick_length"] .sprite-art {
    width: 48px;
  }

  .selection-mark {
    top: 3px;
    right: 3px;
  }

  .submit-panel {
    border-radius: 0;
  }

  .action-button {
    width: 100%;
  }

  .image-actions {
    flex-direction: column;
  }

  .image-actions .download-button {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .profile-tab {
    min-height: 50px;
    padding: 0 12px;
    font-size: 16px;
  }

  .submit-panel {
    width: calc(100% - 24px);
    padding: 34px 18px;
  }

  .link-row {
    flex-direction: column;
  }

  .link-row button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
