/* ===== CSS Variables (Base Theme) ===== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --card-border: #d3d3d3;
  --card-shadow: rgba(0, 0, 0, 0.08);
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --accent: #4285f4;
  --accent-hover: #3367d6;
  --success: #34a853;
  --error: #ea4335;
  --tile-border: #dadce0;
  --tile-selected: #4285f4;
  --progress-bg: #e0e0e0;
  --progress-fill: #4285f4;
  --header-bg: #4285f4;
  --header-text: #ffffff;
  --overlay-bg: rgba(255, 255, 255, 0.92);
  --spinner-color: #4285f4;

  font-family: 'Roboto', 'Noto Sans JP', system-ui, -apple-system, sans-serif;
  background: var(--bg) url('../images/bg.jpg') center / cover no-repeat fixed;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== Card Container ===== */

.captcha-card {
  width: 100%;
  max-width: 480px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 3px;
  box-shadow: 0 2px 6px var(--card-shadow);
  overflow: hidden;
  margin: 20px;
  transition: background 0.6s ease, border-color 0.6s ease, box-shadow 0.6s ease;
  position: relative;
}

/* ===== Header ===== */

.captcha-header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.6s ease, color 0.6s ease;
}

.captcha-header__title {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.captcha-header__step {
  font-size: 12px;
  opacity: 0.85;
}

/* ===== Progress Bar ===== */

.progress-bar {
  height: 3px;
  background: var(--progress-bg);
  position: relative;
}

.progress-bar__fill {
  height: 100%;
  background: var(--progress-fill);
  transition: width 0.4s ease;
  border-radius: 0 2px 2px 0;
}

/* ===== Content Area ===== */

.captcha-body {
  padding: 24px 20px;
  min-height: 280px;
  position: relative;
}

.captcha-instruction {
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 20px;
  font-weight: 500;
}

/* ===== Title Screen ===== */

.title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 20px;
  padding: 32px 20px;
}

.title-screen__shield {
  width: 64px;
  height: 64px;
  margin-bottom: 4px;
}

.title-screen__icon {
  width: 100%;
  height: 100%;
}

.title-screen__circle {
  animation: titleCircleDraw 1.2s ease-out 0.3s forwards;
}

@keyframes titleCircleDraw {
  to { stroke-dashoffset: 0; }
}

.title-screen__check {
  opacity: 0;
  animation: titleCheckFade 0.4s ease-out 1.4s forwards;
}

@keyframes titleCheckFade {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: scale(1); }
}

.title-screen__main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  opacity: 0;
  animation: titleFadeUp 0.6s ease-out 0.5s forwards;
}

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

.title-screen__line {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.06em;
  line-height: 1.5;
}

.title-screen__line--indent {
  /* 中央揃え */
}

.title-screen__sub {
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0;
  animation: titleFadeUp 0.5s ease-out 0.9s forwards;
}

.title-screen__btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 40px;
  background: var(--accent);
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(66, 133, 244, 0.25);
  opacity: 0;
  animation: titleFadeUp 0.5s ease-out 1.6s forwards;
}

.title-screen__btn:hover {
  background: #3b78e7;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(66, 133, 244, 0.35);
}

.title-screen__btn:active {
  transform: translateY(0);
}

.title-screen__btn-arrow {
  transition: transform 0.2s;
}

.title-screen__btn:hover .title-screen__btn-arrow {
  transform: translateX(3px);
}

.title-screen__footer {
  font-size: 10px;
  color: var(--text-secondary);
  opacity: 0;
  animation: titleFadeUp 0.4s ease-out 1.8s forwards;
}

/* ===== Q1: Checkbox ===== */

.checkbox-widget {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border: 2px solid var(--card-border);
  border-radius: 3px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.15s;
  user-select: none;
}

.checkbox-widget:hover {
  border-color: #bbb;
  background: rgba(128, 128, 128, 0.05);
}

.checkbox-box {
  width: 28px;
  height: 28px;
  border: 2px solid #c1c1c1;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--card-bg);
  transition: border-color 0.2s, background 0.2s;
}

.checkbox-widget.checked .checkbox-box {
  border-color: var(--success);
  background: var(--success);
}

.checkbox-check {
  display: none;
  color: #fff;
  font-size: 18px;
  line-height: 1;
}

.checkbox-widget.checked .checkbox-check {
  display: block;
  animation: checkPop 0.3s ease;
}

.checkbox-label {
  font-size: 14px;
  color: var(--text-primary);
}

.checkbox-branding {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.checkbox-branding__icon {
  width: 32px;
  height: 32px;
}

.checkbox-branding__text {
  font-size: 8px;
  color: #9aa0a6;
  letter-spacing: 0.02em;
}

.checkbox-branding__sub {
  font-size: 7px;
  color: #bbb;
}

@keyframes checkPop {
  0% { transform: scale(0); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ===== Q2: Tile Select ===== */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0px;
  margin-bottom: 16px;
}

.tile-cell {
  aspect-ratio: 1;
  border: 1px solid #7f8080;
  border-radius: 0;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.tile-cell:hover {
  border-color: var(--text-secondary);
}

.tile-cell.selected {
  border-color: var(--tile-selected);
  border-width: 3px;
}

.tile-cell__overlay {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  background: var(--tile-selected);
  border-radius: 50%;
  color: #fff;
  font-size: 14px;
  line-height: 24px;
  text-align: center;
}

.tile-cell.selected .tile-cell__overlay {
  display: block;
  animation: checkPop 0.2s ease;
}

.tile-cell__bg {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  background: rgba(128, 128, 128, 0.05);
  gap: 2px;
}

.tile-cell__label {
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1;
}

/* Special tile (Q15: checkbox mimic) */
.tile-cell--special {
  border-style: dashed;
}

.tile-cell--special .tile-cell__bg {
  background: rgba(128, 128, 128, 0.08);
}

.tile-cell--split {
  background-color: #ccc;
  background-repeat: no-repeat;
}

/* ===== Q3: Text Input (Distorted CAPTCHA) ===== */

.captcha-display {
  background: #fff url('../images/q3.jpg') center / cover no-repeat;
  border: 1px solid var(--tile-border);
  border-radius: 4px;
  padding: 20px;
  text-align: center;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.captcha-display::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(0, 0, 0, 0.03) 3px,
      rgba(0, 0, 0, 0.03) 4px
    );
  pointer-events: none;
}

.captcha-display::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      45deg,
      transparent 30%,
      rgba(0, 0, 0, 0.02) 50%,
      transparent 70%
    );
  pointer-events: none;
}

/* Distortion levels */
.captcha-display--distort-1 {
  background: rgba(80, 60, 40, 0.08);
  border-color: rgba(139, 115, 85, 0.3);
}

.captcha-display--distort-1 .captcha-char {
  animation: charFlicker 3s ease infinite;
}

.captcha-display--distort-2 {
  background: rgba(100, 20, 20, 0.1);
  border-color: rgba(139, 32, 32, 0.3);
}

.captcha-display--distort-2 .captcha-char {
  animation: charDistort 1.5s ease infinite;
  text-shadow: 2px 0 rgba(139, 32, 32, 0.3), -2px 0 rgba(32, 32, 139, 0.2);
}

@keyframes charFlicker {
  0%, 90%, 100% { opacity: 1; }
  92% { opacity: 0.4; }
  94% { opacity: 0.9; }
  96% { opacity: 0.3; }
}

@keyframes charDistort {
  0%, 100% { transform: var(--char-base-transform); filter: none; }
  25% { filter: blur(0.5px); }
  50% { transform: var(--char-base-transform) skewX(3deg); }
  75% { filter: blur(1px); }
}

.captcha-noise-line {
  position: absolute;
  height: 2px;
  background: rgba(0, 0, 0, 0.12);
  z-index: 1;
  pointer-events: none;
}

.captcha-char {
  display: inline-block;
  font-size: 48px;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  color: #333;
  margin: 0 2px;
  position: relative;
  z-index: 2;
  text-shadow:
    1px 1px 0 rgba(255,255,255,0.8),
    -1px -1px 0 rgba(255,255,255,0.8),
    1px -1px 0 rgba(255,255,255,0.8),
    -1px 1px 0 rgba(255,255,255,0.8);
}

.text-input-field {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--tile-border);
  border-radius: 4px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  background: var(--card-bg);
  color: var(--text-primary);
}

.text-input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.15);
}

/* ===== Q4: Jigsaw Puzzle ===== */

.jigsaw-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  margin-bottom: 16px;
  touch-action: none;
}

.jigsaw-piece {
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 2px;
  cursor: grab;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  transition: transform 0.15s, box-shadow 0.15s;
  user-select: none;
}

.jigsaw-piece:active {
  cursor: grabbing;
}

.jigsaw-piece.dragging {
  opacity: 0.5;
  transform: scale(0.95);
}

.jigsaw-piece.drag-over {
  box-shadow: inset 0 0 0 2px var(--accent);
  transform: scale(1.05);
}

/* ===== Q5: Oath Input (Final Auth) ===== */

.oath-display {
  margin-bottom: 20px;
  padding: 24px;
  text-align: center;
  position: relative;
}

.oath-display svg {
  width: 100%;
  max-width: 300px;
  height: 80px;
}

.oath-input-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  font-size: 20px;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.oath-prefix {
  white-space: nowrap;
  padding-right: 4px;
}

.oath-field {
  flex: 0 1 100px;
  padding: 8px 12px;
  border: none;
  border-bottom: 2px solid var(--tile-border);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  text-align: center;
  background: transparent;
  transition: border-color 0.2s;
  min-width: 60px;
  color: var(--text-primary);
}

.oath-field:focus {
  border-bottom-color: var(--accent);
}

.oath-suffix {
  white-space: nowrap;
  padding-left: 4px;
}

/* ===== Q8: Slider ===== */

.slider-container {
  padding: 20px 0;
}

.slider-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--progress-bg);
  outline: none;
  cursor: pointer;
}

.slider-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.15s;
}

.slider-range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.slider-range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.slider-value-display {
  text-align: center;
  margin-top: 16px;
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  transition: color 0.3s;
  min-height: 44px;
}

/* ===== Q11: Redacted Input ===== */

.redacted-wrapper {
  position: relative;
  margin-bottom: 16px;
}

.redacted-display {
  min-height: 48px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
  font-size: 20px;
  letter-spacing: 2px;
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1;
}

.redacted-char {
  display: inline-block;
  width: 0.7em;
  height: 1.3em;
  background: var(--text-primary);
  border-radius: 1px;
  animation: redactAppear 0.15s ease;
}

@keyframes redactAppear {
  from { transform: scaleY(0); opacity: 0; }
  to { transform: scaleY(1); opacity: 1; }
}

.redacted-input-field {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--tile-border);
  border-radius: 4px;
  font-size: 20px;
  font-family: inherit;
  outline: none;
  background: rgba(128, 128, 128, 0.06);
  color: transparent;
  caret-color: var(--text-secondary);
  letter-spacing: 2px;
  position: relative;
  z-index: 2;
}

.redacted-input-field::placeholder {
  color: var(--text-secondary);
  opacity: 0.5;
}

.redacted-input-field:focus {
  border-color: var(--accent);
}

.redacted-prompt {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* ===== Q12: Comparison Cards ===== */

.comparison-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.comparison-card {
  padding: 0;
  border: 2px solid var(--tile-border);
  border-radius: 2px;
  position: relative;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, background 0.2s;
  user-select: none;
  overflow: hidden;
  aspect-ratio: 1/1;
}

.comparison-card:hover {
  border-color: var(--accent);
  transform: scale(1.02);
}

.comparison-card.selected {
  border: 2px solid var(--tile-selected);
}

.comparison-card__check {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  background: var(--tile-selected);
  color: #fff;
  border-radius: 50%;
  font-size: 14px;
  line-height: 24px;
  text-align: center;
}

.comparison-card.selected .comparison-card__check {
  display: block;
  animation: checkPop 0.2s ease;
}

.comparison-cards:has(.selected) .comparison-card:not(.selected) {
  opacity: 0.4;
}

.comparison-card__image {
  font-size: 48px;
  margin-bottom: 8px;
  line-height: 1.2;
}

.comparison-card__photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.comparison-card__label {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.comparison-card__desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== Q18: Draw Canvas (Star) ===== */

.draw-container {
  width: 100%;
  max-width: 300px;
  margin: 0 auto 16px;
}

.draw-canvas {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--tile-border);
  border-radius: 4px;
  background: rgba(10, 5, 5, 0.4);
  display: block;
}

.draw-canvas .draw-point {
  cursor: pointer;
  transition: r 0.15s, fill 0.15s;
}

.draw-canvas .draw-point:hover {
  r: 12;
}

.draw-canvas .draw-point--active {
  fill: var(--accent);
  r: 10;
}

.draw-canvas .draw-point--next {
  fill: var(--accent);
  opacity: 0.5;
  animation: pointPulse 1.2s ease infinite;
}

.draw-canvas .draw-line {
  stroke: var(--accent);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
}

.draw-canvas .draw-line--complete {
  stroke: #cc3333;
  stroke-width: 2.5;
  filter: drop-shadow(0 0 4px rgba(200, 30, 30, 0.6));
}

@keyframes pointPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

.draw-progress {
  text-align: center;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== Q18: Seal Break (お札を破く) ===== */

.seal-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  margin: 24px 0;
  background: #333;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.seal-container:active {
  cursor: grabbing;
}

.seal-paper {
  position: relative;
  width: 220px;
  height: 140px;
}

.seal-half {
  position: absolute;
  top: 0;
  width: 54%;
  height: 100%;
  background-color: #f5f0e8;
  overflow: hidden;
  transition: transform 0.1s ease, opacity 0.1s ease;
}

.seal-half--left {
  left: 0;
  border-radius: 4px 0 0 4px;
  border-right: none;
  clip-path: polygon(
    0% 0%, 93% 0%, 100% 5%, 93% 10%, 100% 15%, 93% 20%,
    100% 25%, 93% 30%, 100% 35%, 93% 40%, 100% 45%, 93% 50%,
    100% 55%, 93% 60%, 100% 65%, 93% 70%, 100% 75%, 93% 80%,
    100% 85%, 93% 90%, 100% 95%, 93% 100%, 0% 100%
  );
}

.seal-half--right {
  right: 0;
  border-radius: 0 4px 4px 0;
  border-left: none;
  clip-path: polygon(
    7% 0%, 100% 0%, 100% 100%, 7% 100%, 0% 95%, 7% 90%,
    0% 85%, 7% 80%, 0% 75%, 7% 70%, 0% 65%, 7% 60%,
    0% 55%, 7% 50%, 0% 45%, 7% 40%, 0% 35%, 7% 30%,
    0% 25%, 7% 20%, 0% 15%, 7% 10%, 0% 5%
  );
}

.seal-text-clip {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 220px;
  text-align: center;
  transform: translate(-50%, -50%);
  font-size: 20px;
  font-weight: 700;
  color: #8b4513;
  opacity: 0.4;
  letter-spacing: 0.15em;
  pointer-events: none;
}

.seal-half--left .seal-text-clip {
  left: 100%;
}

.seal-half--right .seal-text-clip {
  left: 0%;
}

.seal-drag-line {
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  transform: translateX(-50%);
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 4px,
    rgba(139, 69, 19, 0.2) 4px,
    rgba(139, 69, 19, 0.2) 8px
  );
}

.seal-drag-line.active {
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 4px,
    rgba(139, 69, 19, 0.5) 4px,
    rgba(139, 69, 19, 0.5) 8px
  );
}

.seal-half.torn {
  transition: transform 0.6s ease, opacity 0.8s ease;
}

.seal-half--left.torn {
  transform: translateX(-80px) rotate(-12deg) !important;
  opacity: 0 !important;
}

.seal-half--right.torn {
  transform: translateX(80px) rotate(12deg) !important;
  opacity: 0 !important;
}

.seal-result {
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0;
  transition: opacity 0.6s ease;
  margin-top: 8px;
}

.seal-result.visible {
  opacity: 1;
}

/* ===== Q20: Judgment Sequence ===== */

.judgment-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0a0a0a;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.judgment-dark {
  background: #0a0a0a !important;
}

.judgment-sequence {
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px;
  gap: 4px;
}

.judgment-line {
  font-size: 18px;
  color: #777;
  line-height: 2;
  min-height: 1.4em;
}

.judgment-line--emphasis {
  color: #aaa;
  font-size: 18px;
  font-weight: 700;
  margin-top: 4px;
}

.judgment-final-check {
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.judgment-final-check .checkbox-widget {
  border-color: #333;
  background: transparent;
}

.judgment-final-check .checkbox-label {
  color: #888;
}

.judgment-line--final {
  color: #ddd;
  font-size: 18px;
  font-weight: 700;
  margin-top: 2px;
}

/* ===== Noise Wave (Q8 effect) ===== */

.captcha-card.noise-active {
  animation: noiseShake var(--noise-speed, 0.15s) infinite;
}

@keyframes noiseShake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(var(--noise-x, 1px), var(--noise-y, -1px)); }
  50% { transform: translate(calc(var(--noise-x, 1px) * -1), var(--noise-y, 1px)); }
  75% { transform: translate(var(--noise-x, -1px), calc(var(--noise-y, -1px) * -1)); }
}

.captcha-card.noise-active .captcha-body {
  filter: contrast(var(--noise-contrast, 1)) brightness(var(--noise-brightness, 1));
  transition: filter 0.1s;
}

/* ===== Glitch Overlay ===== */

.glitch-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  pointer-events: none;
  overflow: hidden;
}

.glitch-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 4px
  );
  animation: glitchScan 0.15s linear infinite;
}

.glitch-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    transparent 40%,
    rgba(255, 0, 0, 0.03) 40%,
    rgba(0, 255, 0, 0.02) 45%,
    transparent 45%
  );
  animation: glitchBar 0.3s ease infinite;
}

@keyframes glitchScan {
  0% { transform: translateY(0); }
  100% { transform: translateY(4px); }
}

@keyframes glitchBar {
  0% { top: -10%; }
  100% { top: 110%; }
}

/* ===== Face Blackout (Q13 effect) ===== */

.face-blackout-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  z-index: 5;
  pointer-events: none;
}

.face-blackout-block {
  background: #000;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.face-blackout-block.visible {
  opacity: 1;
}

/* ===== Cursor Manipulation (Q19) ===== */

.fake-cursor {
  position: fixed;
  pointer-events: none;
  z-index: 300;
  width: 24px;
  height: 24px;
  transition: none;
}

.fake-cursor svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, 0.3));
}

body.cursor-hidden,
body.cursor-hidden * {
  cursor: none !important;
}

/* ===== Text Erosion (Q20 effect) ===== */

.erosion-char {
  display: inline-block;
  transition: all 0.3s ease;
  position: relative;
}

.erosion-char.eroding {
  animation: erode 0.4s ease forwards;
}

.erosion-char.eroded {
  background: var(--text-primary);
  color: transparent;
  border-radius: 1px;
  min-width: 0.6em;
}

@keyframes erode {
  0% { transform: none; }
  30% { transform: translateY(-2px) scaleY(1.1); }
  60% { transform: translateY(1px) scaleX(1.2); }
  100% { background: var(--text-primary); color: transparent; border-radius: 1px; }
}

/* ===== Q6: Puzzle Slide (Capy CAPTCHA) ===== */

.puzzle-slide-container {
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.puzzle-slide-image {
  width: 100%;
  aspect-ratio: 5 / 3;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  transition: filter 1s ease;
}

.puzzle-slide-image--faded {
  filter: grayscale(1) brightness(0.7);
}

.puzzle-slide-slot {
  position: absolute;
  background: rgba(0, 0, 0, 0.35);
  border: 2px dashed rgba(255, 255, 255, 0.4);
  border-radius: 3px;
}

.puzzle-slide-piece {
  position: absolute;
  border-radius: 3px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: left 0.05s linear;
}

.puzzle-slide-piece--correct {
  border-color: var(--success);
  box-shadow: 0 0 12px rgba(52, 168, 83, 0.4);
}

.puzzle-slide-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--progress-bg);
  outline: none;
  cursor: pointer;
  margin-top: 16px;
}

.puzzle-slide-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.puzzle-slide-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

/* ===== Q9: Rotate (FunCAPTCHA) ===== */

.rotate-container {
  width: 100%;
  max-width: 260px;
  margin: 0 auto;
}

.rotate-frame {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid var(--tile-border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url('../images/q9.jpg') center/cover no-repeat;
  margin-bottom: 16px;
}

.rotate-image {
  width: 85%;
  height: 85%;
  border-radius: 50%;
  background: none;
  position: relative;
  transition: transform 0.3s ease;
  overflow: hidden;
}

.rotate-image--correct {
  box-shadow: 0 0 0 4px var(--success);
}

.rotate-image__photo {
  width: 117.65%;
  height: 117.65%;
  object-fit: cover;
  display: block;
  position: relative;
  left: -8.825%;
  top: -8.825%;
}

.rotate-controls {
  display: flex;
  gap: 8px;
}

.rotate-btn {
  flex: 1;
  padding: 10px;
  background: var(--card-bg);
  border: 1px solid var(--tile-border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.2s, background 0.15s;
}

.rotate-btn:hover {
  border-color: var(--accent);
  background: rgba(128, 128, 128, 0.08);
}

/* ===== Q15: Icon Match (Checklist) ===== */

.icon-match-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  max-height: 320px;
  overflow-y: auto;
}

.icon-match-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--tile-border);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}

.icon-match-item:hover {
  border-color: var(--text-secondary);
  background: rgba(128, 128, 128, 0.04);
}

.icon-match-item.selected {
  border-color: var(--tile-selected);
  background: rgba(139, 32, 32, 0.06);
}

.icon-match-item--special {
  border-style: dashed;
}

.icon-match-item__icon {
  font-size: 22px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}

.icon-match-item__label {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
}

.icon-match-item__radio {
  width: 20px;
  height: 20px;
  border: 2px solid var(--tile-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s;
}

.icon-match-item__radio-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: transparent;
  transition: background 0.15s;
}

.icon-match-item.selected .icon-match-item__radio {
  border-color: var(--tile-selected);
}

.icon-match-item.selected .icon-match-item__label {
  font-weight: 700;
}

.icon-match-item.selected .icon-match-item__radio-dot {
  background: var(--tile-selected);
}

/* ===== Q17: Grid Photo (Photo Cell Select) ===== */

.grid-photo-container {
  margin-bottom: 16px;
}

.grid-photo-image {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(128, 128, 128, 0.1);
}

.grid-photo-cell {
  aspect-ratio: 1;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(128, 128, 128, 0.08) 0%, rgba(128, 128, 128, 0.03) 100%);
}

.grid-photo-cell__content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: opacity 0.15s;
}

.grid-photo-cell__icon {
  font-size: 32px;
}

.grid-photo-cell__label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  line-height: 1.4;
  text-align: center;
}

.grid-photo-cell__overlay {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  background: var(--tile-selected);
  border-radius: 50%;
  color: #fff;
  font-size: 14px;
  line-height: 24px;
  text-align: center;
  z-index: 2;
}

.grid-photo-cell.selected .grid-photo-cell__overlay {
  display: block;
  animation: checkPop 0.2s ease;
}

.grid-photo-cell.selected {
  box-shadow: inset 0 0 0 3px var(--tile-selected);
}

/* ===== Correct Modal ===== */

.correct-modal {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.correct-modal.visible {
  opacity: 1;
}

.correct-modal__content {
  text-align: center;
  transform: scale(0.6);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.correct-modal.visible .correct-modal__content {
  transform: scale(1);
}

.correct-modal__loader {
  margin-bottom: 12px;
}

.correct-modal__loader .spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto;
}

.correct-modal__verifying {
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}

.correct-modal__content--result .correct-modal__icon {
  animation: correctPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes correctPop {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); }
}

.correct-modal__icon {
  font-size: 80px;
  color: var(--success);
  line-height: 1;
  margin-bottom: 12px;
}

.correct-modal__text {
  font-size: 32px;
  font-weight: 700;
  color: var(--success);
  letter-spacing: 0.08em;
}

.correct-modal__msg {
  margin-top: 12px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary);
}

.correct-modal__btn {
  margin-top: 28px;
  padding: 12px 48px;
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: 3px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s;
  letter-spacing: 0.04em;
}

.correct-modal__btn:hover {
  opacity: 0.85;
}

/* ===== Buttons ===== */

.submit-btn {
  display: block;
  width: 100%;
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 3px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  letter-spacing: 0.02em;
}

.submit-btn:hover {
  background: var(--accent-hover);
}

.submit-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* ===== Feedback ===== */

.feedback {
  text-align: center;
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

.feedback--success {
  color: var(--success);
}

.feedback--error {
  color: var(--error);
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ===== Transitions & Loading ===== */

.transition-overlay {
  position: absolute;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.transition-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--progress-bg);
  border-top-color: var(--spinner-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Freeze Overlay (Q5) ===== */

.freeze-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s;
}

.freeze-overlay.visible {
  opacity: 1;
}

.freeze-text {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ===== Footer (reCAPTCHA branding) ===== */

.captcha-footer {
  padding: 8px 20px 12px;
  border-top: 1px solid rgba(128, 128, 128, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color 0.6s ease;
}

.captcha-footer__logo {
  display: flex;
  align-items: center;
  gap: 6px;
}

.captcha-footer__logo svg {
  width: 24px;
  height: 24px;
}

.captcha-footer__logo span {
  font-size: 10px;
  color: #9aa0a6;
  font-weight: 500;
}

.captcha-footer__links {
  display: flex;
  gap: 12px;
}

.captcha-footer__links a {
  font-size: 10px;
  color: #9aa0a6;
  text-decoration: none;
}

.captcha-footer__links a:hover {
  text-decoration: underline;
}

/* ===== Phase Complete / Ending ===== */

.phase-complete {
  text-align: center;
  padding: 40px 20px;
}

.phase-complete__icon {
  font-size: 48px;
  color: var(--success);
  margin-bottom: 16px;
}

.phase-complete__title {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 8px;
}

.phase-complete__text {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Ending: 中間画面「認証が完了しました。」 */
.ending-complete {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  animation: fadeIn 0.8s ease;
}

.ending-complete__text {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Ending (Phase 4 complete) */
.ending {
  text-align: center;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
}

.ending-checkbox {
  width: 100%;
  max-width: 360px;
  transition: border-color 0.3s;
}

.ending-checkbox.checked {
  border-color: #4caf50;
}

.ending-checkbox .checkbox-box {
  transition: border-color 0.3s, background 0.3s;
}

.ending-checkbox.checked .checkbox-box {
  border-color: #4caf50 !important;
  background: #4caf50 !important;
}

.ending-checkbox .checkbox-check {
  display: none;
}

.ending-checkbox.checked .checkbox-check {
  display: block;
  animation: checkPop 0.3s ease;
}

.ending-checkbox.checked .checkbox-label {
  color: #333;
}

.ending .checkbox-label {
  color: #888;
  font-weight: 700;
}

/* Strikethrough animation (salvation route) */
.strikethrough-anim {
  position: relative;
  opacity: 0.5;
  transition: opacity 0.6s ease;
}

.strikethrough-anim::after {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  height: 1.5px;
  background: currentColor;
  animation: strikeExpand 0.8s ease forwards;
}

@keyframes strikeExpand {
  from { width: 0; }
  to { width: 100%; }
}

.ending-share {
  display: inline-block;
  margin-top: 0;
  font-size: 11px;
  color: var(--accent);
  text-decoration: underline;
  letter-spacing: 0.02em;
  transition: opacity 0.8s ease, color 0.2s;
}

.ending-share:hover {
  color: #ccc;
}

.ending__rebel {
  font-size: 14px;
  color: #ddd;
  margin-top: 16px;
  transition: opacity 0.8s ease;
}

.ending__sub {
  font-size: 12px;
  color: #444;
}

.retry-btn {
  margin-top: 12px;
  padding: 8px 32px;
  background: none;
  border: 1px solid #333;
  border-radius: 3px;
  font-size: 12px;
  font-family: inherit;
  color: #555;
  cursor: pointer;
  transition: opacity 1.2s ease, border-color 0.2s, color 0.2s;
  letter-spacing: 0.04em;
}

.retry-btn:hover {
  border-color: #666;
  color: #888;
}

/* ===== Legal Modal ===== */

.legal-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}

.legal-modal.visible {
  display: flex;
}

.legal-modal__content {
  background: #fff;
  border-radius: 4px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

.legal-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.legal-modal__title {
  font-size: 14px;
  font-weight: 700;
  color: #202124;
}

.legal-modal__close {
  background: none;
  border: none;
  font-size: 22px;
  color: #5f6368;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.legal-modal__close:hover {
  color: #202124;
}

.legal-modal__body {
  padding: 20px;
  overflow-y: auto;
  font-size: 12px;
  color: #5f6368;
  line-height: 1.8;
}

.legal-modal__body h3 {
  font-size: 13px;
  color: #202124;
  margin: 16px 0 6px;
  font-weight: 700;
}

.legal-modal__body h3:first-child {
  margin-top: 0;
}

.legal-modal__body p {
  margin: 0 0 8px;
}

.legal-modal__body ul {
  margin: 0 0 8px;
  padding-left: 20px;
}

.legal-modal__body li {
  margin-bottom: 4px;
}

/* ===== Site Credit ===== */

.site-credit {
  position: fixed;
  bottom: 12px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  color: #9aa0a6;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.site-credit a {
  color: #9aa0a6;
  text-decoration: none;
  pointer-events: auto;
}

.site-credit a:hover {
  text-decoration: underline;
}

/* ===== Responsive ===== */

@media (max-width: 440px) {
  .captcha-card {
    margin: 12px;
    border-radius: 2px;
  }

  .captcha-body {
    padding: 20px 16px;
  }

  .tile-cell__bg {
    font-size: 28px;
  }

  .captcha-char {
    font-size: 28px;
  }

  .comparison-card {
    padding: 0;
  }

  .comparison-card__image {
    font-size: 36px;
  }

  .draw-container {
    max-width: 260px;
  }

  .slider-value-display {
    font-size: 22px;
  }

  .rotate-container {
    max-width: 220px;
  }

  .puzzle-slide-container {
    max-width: 280px;
  }

  .grid-photo-cell__icon {
    font-size: 26px;
  }
}
