/* ============================================================
   呪いの神経衰弱 / Curse Memory — style.css
   ダークホラー、和風、4×4 神経衰弱
   ============================================================ */

:root {
  --ink: #f3e6d8;
  --ink-dim: #c0a898;
  --muted: #8a7a6a;
  --paper: #d8c2a0;
  --paper-dim: #a48a64;
  --blood: #8a1010;
  --blood-bright: #c01818;
  --blood-deep: #4a0808;
  --bg: #0a0606;
  --bg-2: #160c0c;
  --bg-3: #200e0e;
  --line: rgba(180, 140, 100, 0.14);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.6);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, 0.55);
  --radius-md: 14px;
  --radius-lg: 22px;

  --asset-card-back: url("./assets/images/card-back.svg");
  --asset-room: url("./assets/images/bg-room.svg");

  --curse-hue: 0;
  --shake: 0px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #050202;
}

body {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP",
    "Trebuchet MS", serif;
  color: var(--ink);
  letter-spacing: 0.03em;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% 38%, rgba(60, 14, 14, 0.7), transparent 60%),
    radial-gradient(circle at 18% 110%, rgba(40, 8, 8, 0.6), transparent 50%),
    linear-gradient(180deg, #0a0404 0%, #050202 100%);
  min-height: 100dvh;
  position: relative;
  transition: background 0.6s ease;
}

/* ----- NEW: difficulty + mute UI ----- */
.difficulty {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 6px auto 14px;
  flex-wrap: wrap;
}

.diff-btn {
  font-family: inherit;
  cursor: pointer;
  background: rgba(20, 8, 8, 0.55);
  border: 1px solid rgba(180, 130, 90, 0.3);
  color: var(--ink-dim);
  padding: 8px 14px;
  border-radius: 12px;
  min-width: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}
.diff-btn b { font-size: 14px; color: var(--paper); letter-spacing: 0.2em; }
.diff-btn small { font-size: 10.5px; color: var(--muted); letter-spacing: 0.1em; }
.diff-btn.is-selected {
  border-color: rgba(220, 30, 30, 0.7);
  background: linear-gradient(180deg, rgba(80, 10, 10, 0.7), rgba(30, 4, 4, 0.7));
  box-shadow: 0 0 0 1px rgba(200, 20, 20, 0.4), 0 0 22px rgba(200, 14, 14, 0.35);
}
.diff-btn.is-selected b { color: #ffd0d0; text-shadow: 0 0 8px rgba(220, 30, 30, 0.5); }
.diff-btn:hover { transform: translateY(-1px); }

.diff-badge {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 11px;
  letter-spacing: 0.25em;
  color: var(--muted);
  padding: 3px 10px;
  border: 1px solid rgba(140, 60, 30, 0.35);
  border-radius: 999px;
  background: rgba(8, 4, 4, 0.7);
  z-index: 12;
  pointer-events: none;
}
.diff-badge.is-insane {
  color: #ff8080;
  border-color: rgba(220, 30, 30, 0.55);
  animation: pulseRed 1.2s ease infinite;
}

/* ----- background layers ----- */
.bg-room {
  position: fixed;
  inset: 0;
  background: var(--asset-room) center/cover no-repeat;
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
  transition: filter 0.6s ease, opacity 0.6s ease;
}

.bg-noise {
  position: fixed;
  inset: -2%;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2' seed='3'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 0.7  0 0 0 0 0.5  0 0 0 0.5 0'/></filter><rect width='200' height='200' filter='url(%23n)' opacity='0.6'/></svg>");
  mix-blend-mode: overlay;
  transition: opacity 0.5s ease;
  animation: noiseShift 0.18s steps(2) infinite;
}

@keyframes noiseShift {
  0% { transform: translate(0, 0); }
  50% { transform: translate(-2%, 1%); }
  100% { transform: translate(1%, -1%); }
}

.bg-redshift {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(circle at 50% 50%, rgba(140, 12, 12, 0.0), rgba(60, 4, 4, 0.0));
  transition: background 0.6s ease;
}

.screen-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  background: rgba(200, 12, 12, 0);
  transition: background 0.18s ease;
}

.screen-flash.is-flash {
  background: rgba(200, 12, 12, 0.18);
}

/* ----- NEW: red mist along the bottom ----- */
.bg-mist {
  position: fixed;
  left: -10%;
  right: -10%;
  bottom: -10%;
  height: 38vh;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  background:
    radial-gradient(ellipse at 30% 90%, rgba(180, 14, 14, 0.35), transparent 60%),
    radial-gradient(ellipse at 70% 100%, rgba(120, 8, 8, 0.4), transparent 65%),
    linear-gradient(0deg, rgba(80, 6, 6, 0.5), transparent 90%);
  filter: blur(12px);
  transition: opacity 0.6s ease;
  animation: mistDrift 14s ease-in-out infinite alternate;
}
@keyframes mistDrift {
  from { transform: translateX(-4%); }
  to { transform: translateX(4%); }
}
body.curse-stage-2 .bg-mist { opacity: 0.5; }
body.curse-stage-3 .bg-mist { opacity: 0.9; }

/* ----- NEW: SVG corner cracks ----- */
.bg-cracks {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.6s ease;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'><g stroke='%23ff3030' stroke-width='0.8' fill='none' opacity='0.9'><path d='M0 0 L30 18 L24 36 L42 52 L36 70 L58 82'/><path d='M30 18 L46 6 L60 22'/><path d='M42 52 L62 44 L78 54'/></g></svg>"),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'><g stroke='%23ff3030' stroke-width='0.8' fill='none' opacity='0.85'><path d='M200 200 L168 184 L176 168 L156 152 L168 130 L142 120'/><path d='M168 184 L182 196'/><path d='M156 152 L138 158 L122 144'/></g></svg>");
  background-repeat: no-repeat, no-repeat;
  background-position: top left, bottom right;
  background-size: 220px, 220px;
  mix-blend-mode: screen;
  filter: drop-shadow(0 0 6px rgba(220, 20, 20, 0.5));
}
body.curse-stage-2 .bg-cracks { opacity: 0.55; }
body.curse-stage-3 .bg-cracks {
  opacity: 0.9;
  animation: crackTwitch 0.8s steps(2) infinite;
}
@keyframes crackTwitch {
  0%, 100% { transform: translate(0,0); }
  50% { transform: translate(1px, -1px); }
}

/* ----- NEW: eye watching from a corner ----- */
.bg-eye {
  position: fixed;
  top: 32%;
  right: -50px;
  width: 80px;
  height: 80px;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 80'><defs><radialGradient id='eg' cx='50%25' cy='50%25' r='50%25'><stop offset='0' stop-color='%23fff5b0'/><stop offset='0.5' stop-color='%23d8a020'/><stop offset='1' stop-color='%236a3008'/></radialGradient></defs><ellipse cx='40' cy='40' rx='34' ry='14' fill='%23080202'/><ellipse cx='40' cy='40' rx='14' ry='12' fill='url(%23eg)'/><circle cx='40' cy='40' r='4' fill='%23110404'/><circle cx='42' cy='38' r='1' fill='%23fff' opacity='0.7'/></svg>");
  background-size: contain;
  background-repeat: no-repeat;
  transition: opacity 0.4s ease, right 1.2s ease;
  filter: drop-shadow(0 0 18px rgba(220, 60, 60, 0.5));
}
.bg-eye.is-watching { opacity: 0.85; right: -22px; }
.bg-eye.is-blink { animation: eyeBlink 0.4s ease; }
@keyframes eyeBlink {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.06); }
}

/* ----- NEW: shadow figure overlay ----- */
.bg-shadow-figure {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 7;
  opacity: 0;
  transition: opacity 0.35s ease;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 600' preserveAspectRatio='xMidYMid meet'><g fill='%23030000' opacity='0.92'><path d='M200 110 Q170 110 150 80 Q140 60 152 38 Q174 14 200 14 Q226 14 248 38 Q260 60 250 80 Q230 110 200 110 Z'/><path d='M120 160 Q120 130 200 122 Q280 130 280 160 L300 360 Q310 470 280 540 Q200 580 120 540 Q90 470 100 360 Z'/><path d='M100 300 Q40 360 30 460 Q40 510 60 520 Q80 460 110 380 Z'/><path d='M300 300 Q360 360 370 460 Q360 510 340 520 Q320 460 290 380 Z'/></g><g stroke='%231a0000' stroke-width='1' fill='none' opacity='0.4'><path d='M150 200 Q200 220 250 200'/></g></svg>");
  background-position: center 30%;
  background-size: auto 95vh;
  background-repeat: no-repeat;
  filter: blur(1.5px);
}
.bg-shadow-figure.is-show {
  opacity: 0.92;
  animation: figureLean 1.4s ease;
}
@keyframes figureLean {
  0% { opacity: 0; transform: translateY(40px) scale(1.04); }
  25% { opacity: 0.92; }
  85% { opacity: 0.92; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-10px) scale(0.98); }
}

/* ----- NEW: blink (eyelid) overlay ----- */
.bg-blink {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 70;
  background: #000;
  opacity: 0;
  transition: opacity 0.05s linear;
}
.bg-blink.is-blink {
  animation: blinkLid 0.42s ease;
}
@keyframes blinkLid {
  0% { opacity: 0; transform: scaleY(0); transform-origin: 50% 0%; }
  35% { opacity: 1; transform: scaleY(1); transform-origin: 50% 0%; }
  65% { opacity: 1; transform: scaleY(1); transform-origin: 50% 100%; }
  100% { opacity: 0; transform: scaleY(0); transform-origin: 50% 100%; }
}

/* ----- curse-stage modifiers on <body> ----- */
body.curse-stage-1 .bg-noise { opacity: 0.18; }
body.curse-stage-2 .bg-noise { opacity: 0.32; }
body.curse-stage-2 .bg-redshift { background: radial-gradient(circle at 50% 50%, rgba(140, 12, 12, 0.18), rgba(60, 4, 4, 0.05)); }
body.curse-stage-3 .bg-noise { opacity: 0.55; }
body.curse-stage-3 .bg-redshift { background: radial-gradient(circle at 50% 50%, rgba(200, 14, 14, 0.36), rgba(80, 4, 4, 0.22)); }
body.curse-stage-3 .bg-room { filter: hue-rotate(-14deg) saturate(0.65) brightness(0.55); }
body.curse-stage-3 .card:not(.is-matched):not(.is-flipped) .card__inner {
  animation: cardTremor 0.4s ease-in-out infinite alternate;
}
body.curse-stage-2 .card:not(.is-matched):not(.is-flipped) .card__inner {
  animation: cardTremor 0.9s ease-in-out infinite alternate;
}
@keyframes cardTremor {
  0%   { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(0.6px, -0.4px) rotate(0.15deg); }
}
/* matched card occasionally flickers back to its back (memory pressure) */
body.curse-stage-2 .card.is-matched.is-flicker .card__inner { transform: rotateY(0deg); transition: transform 0.18s ease; }

body.is-shake .app { animation: shakeIt 0.4s ease; }

@keyframes shakeIt {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-3px, 2px); }
  40% { transform: translate(4px, -2px); }
  60% { transform: translate(-2px, 3px); }
  80% { transform: translate(3px, 1px); }
}

/* ----- app shell / screens ----- */
.app {
  position: relative;
  z-index: 5;
  max-width: 720px;
  margin: 0 auto;
  padding: 22px 16px 56px;
  min-height: 100dvh;
}

.screen {
  display: none;
  animation: fadeIn 0.5s ease;
}

.screen.is-active {
  display: block;
}

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

/* ----- title screen ----- */
.title-wrap {
  text-align: center;
  padding: 56px 8px 28px;
}

.title {
  margin: 0 0 24px;
  font-weight: 900;
  line-height: 1.05;
}

.title-jp {
  position: relative;
  display: block;
  font-size: clamp(38px, 8vw, 72px);
  color: var(--paper);
  text-shadow:
    0 0 18px rgba(160, 14, 14, 0.6),
    0 2px 0 #2a0808,
    0 0 2px rgba(0, 0, 0, 0.7);
  letter-spacing: 0.08em;
}

.title-jp::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  color: rgba(200, 18, 18, 0.55);
  transform: translate(2px, 1px);
  filter: blur(0.6px);
  z-index: -1;
  pointer-events: none;
  animation: titleGhost 3.4s ease-in-out infinite;
}

@keyframes titleGhost {
  0%, 100% { transform: translate(2px, 1px); opacity: 0.55; }
  50% { transform: translate(-2px, -1px); opacity: 0.8; }
}

.title-en {
  display: block;
  font-size: 14px;
  letter-spacing: 0.4em;
  color: var(--muted);
  margin-top: 6px;
}

.lead {
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink-dim);
  margin: 0 auto 18px;
  max-width: 30em;
}

.lead em {
  font-style: normal;
  color: #e8b0b0;
  text-shadow: 0 0 8px rgba(200, 20, 20, 0.5);
}

.rules {
  list-style: none;
  padding: 14px 18px;
  margin: 0 auto 26px;
  border: 1px solid var(--line);
  background: rgba(20, 8, 8, 0.55);
  border-radius: var(--radius-md);
  max-width: 30em;
  font-size: 13.5px;
  color: var(--ink-dim);
  text-align: left;
}

.rules li + li {
  margin-top: 6px;
}

.rules b {
  color: var(--paper);
}

/* ----- buttons ----- */
.btn {
  font-family: inherit;
  cursor: pointer;
  padding: 12px 26px;
  border-radius: 999px;
  font-size: 15px;
  letter-spacing: 0.18em;
  border: 1px solid rgba(200, 30, 30, 0.45);
  background: linear-gradient(180deg, rgba(60, 10, 10, 0.9), rgba(20, 4, 4, 0.9));
  color: var(--paper);
  box-shadow: var(--shadow-md);
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
  margin: 6px;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

.btn:hover, .btn:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(160, 14, 14, 0.35);
  outline: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: linear-gradient(180deg, #8a1010, #4a0606);
  border-color: #c01818;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.btn--ghost {
  background: rgba(20, 8, 8, 0.55);
  border-color: rgba(180, 130, 90, 0.3);
  color: var(--ink-dim);
}

.best-line {
  margin-top: 22px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.15em;
  min-height: 1.2em;
}

.best-line b {
  color: var(--paper);
  font-weight: 700;
}

/* =====================================================
   GAME SCREEN
   ===================================================== */
.hud {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, rgba(8, 4, 4, 0.92), rgba(8, 4, 4, 0.7));
  backdrop-filter: blur(4px);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px 14px;
  margin-bottom: 14px;
}

.hud-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
  gap: 8px;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 2px;
  border-radius: 10px;
  background: rgba(20, 6, 6, 0.55);
}

.hud-label {
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.2em;
}

.hud-value {
  font-size: 22px;
  font-weight: 900;
  color: var(--paper);
  line-height: 1;
  text-shadow: 0 0 8px rgba(180, 20, 20, 0.3);
}

.hud-unit {
  font-size: 11px;
  color: var(--muted);
}

.hud-stat--time .hud-value.low {
  color: #ff7070;
  animation: pulseRed 1s ease infinite;
}

@keyframes pulseRed {
  0%, 100% { text-shadow: 0 0 6px rgba(255, 60, 60, 0.6); }
  50% { text-shadow: 0 0 18px rgba(255, 60, 60, 0.9); }
}

/* ----- curse meter ----- */
.curse-meter {
  margin-top: 12px;
  position: relative;
}

.curse-meter__track {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, #1a0606, #0a0202);
  border: 1px solid rgba(140, 30, 30, 0.4);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}

.curse-meter__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5a0808 0%, #c01818 60%, #ff5555 100%);
  box-shadow: 0 0 16px rgba(220, 20, 20, 0.6);
  transition: width 0.5s ease, background 0.4s ease;
  position: relative;
}

.curse-meter__fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 40%, rgba(255, 200, 200, 0.25) 50%, transparent 60%);
  animation: shimmer 2.2s linear infinite;
}

@keyframes shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

.curse-meter__ticks {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  pointer-events: none;
}

.curse-meter__ticks span {
  border-right: 1px dashed rgba(255, 255, 255, 0.1);
}

.curse-meter__ticks span:last-child { border-right: none; }

.curse-meter__label {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 11px;
  letter-spacing: 0.25em;
  color: var(--muted);
}

.curse-meter__label b {
  color: var(--paper);
  font-size: 13px;
}

body.curse-stage-2 .curse-meter__label b { color: #ffb0b0; }
body.curse-stage-3 .curse-meter__label b {
  color: #ff6060;
  animation: pulseRed 0.8s ease infinite;
}

/* =====================================================
   BOARD / CARDS
   ===================================================== */
.board-wrap {
  position: relative;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(6px, 1.5vw, 12px);
  margin: 0 auto;
}

.card {
  position: relative;
  aspect-ratio: 1 / 1.18;
  perspective: 900px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  /* reset default button styling */
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  appearance: none;
  -webkit-appearance: none;
}

.card:focus-visible {
  outline: 2px solid rgba(255, 176, 176, 0.7);
  outline-offset: 2px;
  border-radius: 12px;
}

.card__inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.3, 0.7, 0.2, 1);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
}

.card.is-flipped .card__inner,
.card.is-matched .card__inner {
  transform: rotateY(180deg);
}

.card__face {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border: 1px solid rgba(0, 0, 0, 0.6);
}

.card__face--back {
  background-image: var(--asset-card-back);
  background-color: #1a0c08;
}

.card__face--front {
  transform: rotateY(180deg);
  background-color: #0c0606;
  filter: saturate(0.85) contrast(1.1);
}

.card__face--front::after {
  /* old-photo overlay */
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.55) 100%),
    linear-gradient(180deg, rgba(140, 20, 20, 0.08), rgba(20, 4, 4, 0.18));
  pointer-events: none;
}

.card__fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 14px;
  color: var(--paper-dim);
  background: linear-gradient(180deg, #2a1810, #0e0606);
  letter-spacing: 0.2em;
  padding: 6px;
}

.card.is-matched .card__inner {
  filter: grayscale(0.4) brightness(0.65);
  box-shadow: 0 0 0 1px rgba(140, 30, 30, 0.4);
}

.card.is-matched::after {
  content: "封";
  position: absolute;
  top: 4px;
  right: 6px;
  font-family: serif;
  font-size: 14px;
  color: rgba(200, 30, 30, 0.85);
  text-shadow: 0 0 6px rgba(200, 30, 30, 0.6);
  z-index: 4;
  pointer-events: none;
}

.card.is-seal-slam .card__inner {
  animation: sealSlam 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes sealSlam {
  0% { transform: rotateY(180deg) scale(1.0); }
  35% { transform: rotateY(180deg) scale(1.12); filter: brightness(1.4); }
  65% { transform: rotateY(180deg) scale(0.96); filter: brightness(0.85); }
  100% { transform: rotateY(180deg) scale(1.0); filter: brightness(1); }
}

.card.is-locked { pointer-events: none; }

.card.is-just-mismatched .card__inner {
  animation: cardShake 0.3s ease;
}

@keyframes cardShake {
  0%, 100% { transform: rotateY(180deg) translate(0, 0); }
  25% { transform: rotateY(180deg) translate(-4px, 0); }
  75% { transform: rotateY(180deg) translate(4px, 0); }
}

/* whisper text on card back when curse rises */
.card__face--back::before {
  content: attr(data-whisper);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(220, 60, 60, 0);
  font-size: 18px;
  letter-spacing: 0.4em;
  font-weight: 900;
  pointer-events: none;
  transition: color 0.15s ease;
  text-shadow: 0 0 8px rgba(200, 0, 0, 0.6);
}

.card.is-whisper:not(.is-flipped):not(.is-matched) .card__face--back::before {
  color: rgba(220, 60, 60, 0.85);
  animation: whisperFlick 0.6s ease;
}

@keyframes whisperFlick {
  0% { color: rgba(220, 60, 60, 0); }
  30% { color: rgba(220, 60, 60, 0.9); }
  100% { color: rgba(220, 60, 60, 0); }
}

/* board overlay (for swap & gameover messages) */
.board-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 8;
}

.board-overlay.is-show {
  opacity: 1;
}

.overlay-text {
  font-size: clamp(18px, 4.5vw, 28px);
  color: #ffb0b0;
  letter-spacing: 0.25em;
  font-weight: 900;
  text-shadow:
    0 0 12px rgba(200, 20, 20, 0.7),
    0 0 32px rgba(120, 8, 8, 0.6);
  background: rgba(8, 0, 0, 0.55);
  padding: 16px 22px;
  border: 1px solid rgba(200, 30, 30, 0.5);
  border-radius: 12px;
  backdrop-filter: blur(2px);
  animation: overlayPulse 0.6s ease;
}

@keyframes overlayPulse {
  0% { transform: scale(0.92); opacity: 0; }
  50% { transform: scale(1.03); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* =====================================================
   MEMORY LOG
   ===================================================== */
.memlog {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 12px 12px;
  background: rgba(12, 6, 6, 0.65);
}

.memlog__head {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--muted);
  margin-bottom: 6px;
}

.memlog__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.memlog__list li {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(40, 14, 14, 0.5);
  border: 1px solid rgba(140, 60, 30, 0.18);
  color: var(--ink-dim);
}

.memlog__list li.corrupt {
  color: #ff8888;
  letter-spacing: 0.25em;
  background: rgba(80, 8, 8, 0.6);
  border-color: rgba(200, 30, 30, 0.4);
  animation: corruptFlick 1.4s ease infinite;
}

@keyframes corruptFlick {
  0%, 100% { opacity: 0.95; }
  50% { opacity: 0.55; }
}

.game-controls {
  text-align: center;
  margin-top: 12px;
}

/* =====================================================
   RESULT SCREEN
   ===================================================== */
.result-wrap {
  text-align: center;
  padding: 22px 6px 8px;
}

.result-title {
  font-size: clamp(28px, 6vw, 44px);
  margin: 6px 0 12px;
  color: var(--paper);
  text-shadow: 0 0 14px rgba(200, 20, 20, 0.5);
  letter-spacing: 0.15em;
}

.result-title.is-over {
  color: #ff7070;
  text-shadow: 0 0 16px rgba(255, 30, 30, 0.7);
}

.result-score {
  margin: 6px 0 18px;
}

.result-score__label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.35em;
  color: var(--muted);
}

.result-score__value {
  display: block;
  font-size: clamp(48px, 12vw, 84px);
  font-weight: 900;
  color: var(--paper);
  text-shadow: 0 0 18px rgba(200, 30, 30, 0.5);
  letter-spacing: 0.04em;
}

.result-stats {
  list-style: none;
  padding: 12px 14px;
  margin: 0 auto 14px;
  max-width: 30em;
  background: rgba(14, 6, 6, 0.6);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  color: var(--ink-dim);
}

.result-stats li {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed rgba(180, 130, 90, 0.15);
}

.result-stats li:last-child { border-bottom: none; }
.result-stats b { color: var(--paper); }

.result-title-tag {
  display: inline-block;
  margin: 6px auto 14px;
  padding: 8px 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(80, 8, 8, 0.7), rgba(40, 4, 4, 0.7));
  border: 1px solid rgba(200, 30, 30, 0.5);
  color: #ffd0d0;
  font-size: 13px;
  letter-spacing: 0.2em;
}

.result-best {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.result-best b {
  color: var(--paper);
}

.rank-table {
  margin: 18px auto;
  max-width: 30em;
  text-align: left;
  background: rgba(10, 4, 4, 0.65);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.rank-table__head {
  font-size: 11.5px;
  letter-spacing: 0.3em;
  color: var(--muted);
  margin-bottom: 8px;
}

.rank-list {
  margin: 0;
  padding: 0 0 0 22px;
  font-size: 12.5px;
  color: var(--ink-dim);
}

.rank-list li {
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.rank-list li.me {
  color: #ffe0c0;
  text-shadow: 0 0 8px rgba(200, 30, 30, 0.4);
}

.rank-list .score {
  font-variant-numeric: tabular-nums;
  color: var(--paper);
}

.result-actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

/* =====================================================
   MODAL
   ===================================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal[hidden] { display: none; }

.modal__panel {
  background: linear-gradient(180deg, #1c0c0c, #0a0404);
  border: 1px solid rgba(200, 30, 30, 0.45);
  border-radius: var(--radius-lg);
  padding: 22px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}

.modal__panel h3 {
  margin: 0 0 12px;
  color: var(--paper);
  letter-spacing: 0.2em;
}

.modal__panel ul {
  text-align: left;
  font-size: 13.5px;
  color: var(--ink-dim);
  margin: 0 0 14px;
  padding-left: 1.2em;
  line-height: 1.7;
}

.modal__panel ul b { color: #ffd0d0; }

/* =====================================================
   WHISPER LAYER (floating ghost text)
   ===================================================== */
.whisper-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  overflow: hidden;
}

.whisper {
  position: absolute;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.3em;
  color: rgba(220, 30, 30, 0.85);
  text-shadow: 0 0 12px rgba(200, 0, 0, 0.6);
  opacity: 0;
  animation: whisperFloat 1.6s ease forwards;
  white-space: nowrap;
}

@keyframes whisperFloat {
  0% { opacity: 0; transform: translateY(8px) scale(0.95); }
  20% { opacity: 0.9; }
  100% { opacity: 0; transform: translateY(-22px) scale(1.05); }
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 480px) {
  .app { padding: 12px 8px 56px; }
  .hud-row { grid-template-columns: 1fr 1fr 1fr 1fr; }
  .hud-value { font-size: 18px; }
  .hud-label { font-size: 9.5px; }
  .board { gap: 6px; }
  .title-jp { font-size: 38px; }
  .rules { font-size: 12.5px; }
  .btn { padding: 12px 22px; font-size: 14px; }
}

@media (max-height: 720px) {
  .title-wrap { padding-top: 22px; }
}

/* a11y */
.btn:focus-visible {
  outline: 2px solid #ffb0b0;
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus { left: 12px; top: 12px; background: #000; color: #fff; padding: 6px 10px; }

/* ============================================================
   ===== ENHANCED HORROR LAYERS (J-horror max edition) =====
   ============================================================ */

/* warning line on title */
.warning-line {
  font-size: 11.5px;
  letter-spacing: 0.25em;
  color: #b88080;
  margin: -10px 0 14px;
  opacity: 0.9;
}
.warning-line .warn-icon {
  color: #ff7070;
  margin-right: 6px;
  text-shadow: 0 0 8px rgba(255, 60, 60, 0.6);
}

/* ----- 髪の毛のカーテン（天井から垂れる長い髪） ----- */
.bg-hair-curtain {
  position: fixed;
  left: 0; right: 0; top: -40vh;
  height: 70vh;
  pointer-events: none;
  z-index: 3;
  background: url("./assets/images/hair-curtain.svg") top center / cover no-repeat;
  opacity: 0;
  transform: translateY(-8vh);
  transition: opacity 0.6s ease, transform 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 0 18px rgba(0, 0, 0, 0.9));
}
body.curse-stage-1 .bg-hair-curtain { opacity: 0.22; transform: translateY(-4vh); }
body.curse-stage-2 .bg-hair-curtain { opacity: 0.55; transform: translateY(0); }
body.curse-stage-3 .bg-hair-curtain {
  opacity: 0.88;
  transform: translateY(4vh);
  animation: hairSway 6s ease-in-out infinite alternate;
}
@keyframes hairSway {
  0%   { transform: translate(-8px, 4vh) skewX(0.6deg); }
  100% { transform: translate(8px, 5vh) skewX(-0.6deg); }
}

/* ----- 壁の血痕（左右の縁） ----- */
.bg-blood-smear {
  position: fixed;
  top: 0; bottom: 0;
  width: 18vw;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  background: url("./assets/images/blood-smear.svg") center / cover no-repeat;
  mix-blend-mode: multiply;
  filter: drop-shadow(0 0 12px rgba(80, 0, 0, 0.6));
  transition: opacity 0.8s ease;
}
.bg-blood-smear--left { left: -4vw; }
.bg-blood-smear--right { right: -4vw; transform: scaleX(-1); }
body.curse-stage-2 .bg-blood-smear { opacity: 0.4; }
body.curse-stage-3 .bg-blood-smear { opacity: 0.8; }

/* ----- 暗闇から覗く顔（周辺視野） ----- */
.bg-face-stare {
  position: fixed;
  top: 50%;
  left: 50%;
  width: clamp(220px, 38vw, 380px);
  height: clamp(220px, 38vw, 380px);
  transform: translate(-50%, -50%) scale(0.85);
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  background: url("./assets/images/face-stare.svg") center / contain no-repeat;
  filter: blur(1px);
  mix-blend-mode: screen;
  transition: opacity 1.4s ease, transform 1.4s ease;
}
body.curse-stage-2 .bg-face-stare {
  opacity: 0.22;
  transform: translate(-50%, -50%) scale(1);
}
body.curse-stage-3 .bg-face-stare {
  opacity: 0.55;
  transform: translate(-50%, -50%) scale(1.08);
  animation: faceBreathe 8s ease-in-out infinite alternate;
}
@keyframes faceBreathe {
  0%   { opacity: 0.45; transform: translate(-50%, -50%) scale(1.04); }
  50%  { opacity: 0.72; transform: translate(-50%, -50%) scale(1.10); }
  100% { opacity: 0.40; transform: translate(-50%, -50%) scale(1.06); }
}
.bg-face-stare.is-pulse { animation: facePulse 0.6s ease; }
@keyframes facePulse {
  0%   { opacity: 0.5; transform: translate(-50%, -50%) scale(1.0); }
  40%  { opacity: 0.92; transform: translate(-50%, -50%) scale(1.18); }
  100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1.06); }
}

/* ----- 白い着物の女（八尺様風） 徐々に近づく ----- */
.bg-ghost-woman {
  position: fixed;
  left: 50%;
  bottom: -12vh;
  width: clamp(180px, 28vw, 320px);
  height: 78vh;
  transform: translate(-50%, 0) scale(0.4);
  transform-origin: 50% 100%;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  background: url("./assets/images/ghost-woman.svg") center bottom / contain no-repeat;
  filter: drop-shadow(0 0 24px rgba(0, 0, 0, 0.95)) blur(0.5px);
  transition: opacity 1.8s ease, transform 6s cubic-bezier(0.42, 0, 0.58, 1);
}
.bg-ghost-woman.is-distance-1 { opacity: 0.18; transform: translate(-50%, 0) scale(0.55); }
.bg-ghost-woman.is-distance-2 { opacity: 0.45; transform: translate(-50%, 0) scale(0.78); }
.bg-ghost-woman.is-distance-3 { opacity: 0.78; transform: translate(-50%, 0) scale(1.0); }
.bg-ghost-woman.is-distance-4 {
  opacity: 0.95;
  transform: translate(-50%, 0) scale(1.25);
  animation: ghostTwitch 0.4s steps(2) infinite;
}
@keyframes ghostTwitch {
  0%, 100% { filter: drop-shadow(0 0 24px rgba(0, 0, 0, 0.95)) blur(0.5px); }
  50%      { filter: drop-shadow(0 0 32px rgba(200, 0, 0, 0.6)) blur(0px); }
}
/* sway side to side subtly */
.bg-ghost-woman.is-sway {
  animation: ghostSway 4.5s ease-in-out infinite alternate;
}
@keyframes ghostSway {
  0%   { margin-left: -8px; }
  100% { margin-left: 8px; }
}

/* ----- CRT スキャンライン ----- */
.bg-scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.18) 3px,
      rgba(0, 0, 0, 0) 4px
    );
  mix-blend-mode: multiply;
  transition: opacity 0.5s ease;
}
body.curse-stage-1 .bg-scanlines { opacity: 0.22; }
body.curse-stage-2 .bg-scanlines { opacity: 0.45; }
body.curse-stage-3 .bg-scanlines { opacity: 0.7; animation: scanlineDrift 1.2s linear infinite; }
@keyframes scanlineDrift {
  0%   { background-position-y: 0; }
  100% { background-position-y: 4px; }
}

/* ----- VHS トラッキングずれ ----- */
.bg-vhs-tear {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 51;
  opacity: 0;
  background: linear-gradient(
    180deg,
    transparent 0%, transparent 49.6%,
    rgba(255, 60, 60, 0.18) 49.7%, rgba(80, 200, 255, 0.18) 49.95%,
    transparent 50%, transparent 100%
  );
  background-size: 100% 240%;
  mix-blend-mode: screen;
  transition: opacity 0.3s ease;
}
.bg-vhs-tear.is-tear {
  opacity: 1;
  animation: vhsTear 0.42s ease-out;
}
@keyframes vhsTear {
  0%   { background-position-y: -100%; opacity: 1; }
  60%  { background-position-y: 100%; opacity: 1; }
  100% { background-position-y: 200%; opacity: 0; }
}

/* ----- 砂嵐オーバーレイ（呪い極大時） ----- */
.static-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 52;
  opacity: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 300'><filter id='s'><feTurbulence type='fractalNoise' baseFrequency='2.2' numOctaves='1' stitchTiles='stitch' seed='5'/><feColorMatrix values='0 0 0 0 0.9  0 0 0 0 0.85  0 0 0 0 0.85  0 0 0 0.9 0'/></filter><rect width='300' height='300' filter='url(%23s)'/></svg>");
  background-size: 220px;
  mix-blend-mode: screen;
  transition: opacity 0.3s ease;
  animation: staticShift 0.06s steps(2) infinite;
}
@keyframes staticShift {
  0%   { background-position: 0 0; }
  50%  { background-position: -30px 18px; }
  100% { background-position: 22px -26px; }
}
body.curse-stage-3 .static-overlay { opacity: 0.10; }
.static-overlay.is-burst { opacity: 0.85 !important; transition: opacity 0.05s linear; }

/* ----- 般若フラッシュ（ジャンプスケア） ----- */
.hannya-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
  opacity: 0;
  background: #000 url("./assets/images/hannya.svg") center / contain no-repeat;
  transform: scale(1.5);
  filter: brightness(1.4) saturate(1.2);
}
.hannya-flash.is-flash {
  animation: hannyaFlash 0.42s steps(3);
}
@keyframes hannyaFlash {
  0%   { opacity: 0; transform: scale(2.0); }
  10%  { opacity: 1; transform: scale(1.05); }
  60%  { opacity: 1; transform: scale(1.0); }
  100% { opacity: 0; transform: scale(0.95); }
}
.hannya-flash.is-subliminal {
  /* extremely brief subliminal frame */
  animation: hannyaSubliminal 0.08s linear;
}
@keyframes hannyaSubliminal {
  0%, 100% { opacity: 0; }
  50%      { opacity: 1; }
}
.hannya-flash.is-hold {
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.4s ease;
}

/* ----- ゴーストカーソル（半瞬遅れて追う第二のカーソル） ----- */
.ghost-cursor {
  position: fixed;
  width: 14px;
  height: 14px;
  pointer-events: none;
  z-index: 95;
  opacity: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(220, 30, 30, 0.85) 0%, rgba(120, 0, 0, 0.6) 50%, transparent 75%);
  filter: blur(1px);
  transform: translate(-50%, -50%);
  transition: opacity 0.6s ease;
  mix-blend-mode: screen;
}
.ghost-cursor.is-active { opacity: 0.85; }

/* ----- カード裏の写り込み（影の顔） ----- */
body.curse-stage-2 .card:not(.is-flipped):not(.is-matched) .card__face--back::after {
  content: "";
  position: absolute;
  inset: 8%;
  background: radial-gradient(circle at 50% 45%, rgba(160, 130, 110, 0.18) 0%, rgba(40, 20, 20, 0) 55%);
  pointer-events: none;
  opacity: 0;
  animation: faceWashIn 6s ease-in-out infinite;
  border-radius: 50%;
}
body.curse-stage-3 .card:not(.is-flipped):not(.is-matched) .card__face--back::after {
  background:
    radial-gradient(ellipse at 38% 42%, rgba(20, 0, 0, 0.85) 0%, transparent 12%),
    radial-gradient(ellipse at 62% 42%, rgba(20, 0, 0, 0.85) 0%, transparent 12%),
    radial-gradient(circle at 50% 45%, rgba(190, 160, 140, 0.4) 0%, rgba(40, 20, 20, 0) 55%);
  opacity: 0.85;
  animation: faceWashIn 4s ease-in-out infinite;
}
@keyframes faceWashIn {
  0%, 100% { opacity: 0; transform: scale(0.92); }
  50%      { opacity: 1; transform: scale(1); }
}

/* ----- カードホバー長押し時の「中から顔」 ----- */
.card.is-haunted .card__face--back {
  animation: cardHaunted 0.9s ease;
}
@keyframes cardHaunted {
  0%   { filter: none; }
  40%  { filter: invert(0.6) hue-rotate(180deg) brightness(1.1); }
  80%  { filter: invert(0.2) hue-rotate(90deg); }
  100% { filter: none; }
}

/* ----- HUD: 呪い極大時の歪み ----- */
body.curse-stage-3 .hud {
  animation: hudGlitch 5s ease-in-out infinite;
}
@keyframes hudGlitch {
  0%, 92%, 100% { transform: translate(0, 0); filter: none; }
  93%           { transform: translate(-2px, 1px); filter: hue-rotate(20deg); }
  94%           { transform: translate(3px, -2px); filter: hue-rotate(-20deg) saturate(1.5); }
  95%           { transform: translate(-1px, 0); filter: none; }
}

/* ----- 時計の逆走（瞬間） ----- */
.hud-stat--time.is-glitch .hud-value {
  animation: timeGlitch 0.3s steps(2);
}
@keyframes timeGlitch {
  0%, 100% { color: var(--paper); transform: translateX(0); }
  50%      { color: #ff4040; transform: translateX(2px); text-shadow: -2px 0 #00d0ff, 2px 0 #ff0040; }
}

/* ----- タイトル文字の崩壊 ----- */
body.curse-stage-3 .title-jp {
  animation: titleCrack 4s ease-in-out infinite;
}
@keyframes titleCrack {
  0%, 88%, 100% { letter-spacing: 0.08em; }
  90%           { letter-spacing: 0.18em; transform: skewX(2deg); }
  92%           { letter-spacing: 0.02em; transform: skewX(-2deg); }
}

/* ----- 御札（祈祷札）封印演出 ----- */
.card.is-matched::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28%;
  height: 90%;
  background: url("./assets/images/talisman-overlay.svg") center / contain no-repeat;
  transform: translate(-50%, -50%) rotate(-12deg);
  opacity: 0;
  animation: ofudaSlap 0.6s 0.05s cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
  pointer-events: none;
  z-index: 3;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6));
}
@keyframes ofudaSlap {
  0%   { opacity: 0; transform: translate(-50%, -160%) rotate(-32deg) scale(1.6); }
  60%  { opacity: 1; transform: translate(-50%, -50%) rotate(-10deg) scale(1.05); }
  100% { opacity: 0.92; transform: translate(-50%, -50%) rotate(-12deg) scale(1); }
}

/* ----- 結果画面：般若の薄い背景 ----- */
.screen--result.is-doomed::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("./assets/images/hannya.svg") center / contain no-repeat;
  opacity: 0.08;
  pointer-events: none;
  z-index: 0;
  filter: blur(1px);
  animation: doomBreath 6s ease-in-out infinite;
}
@keyframes doomBreath {
  0%, 100% { opacity: 0.06; transform: scale(1); }
  50%      { opacity: 0.15; transform: scale(1.02); }
}

/* ----- 文字エフェクト：被害者の名前 ----- */
.whisper.is-name {
  font-size: 32px;
  color: rgba(255, 220, 220, 0.95);
  text-shadow: 0 0 20px rgba(200, 0, 0, 0.85);
  letter-spacing: 0.5em;
}
.whisper.is-large {
  font-size: 56px;
  letter-spacing: 0.6em;
  color: rgba(255, 60, 60, 0.95);
}

/* ----- 呪い極大時の画面歪曲 ----- */
body.curse-stage-3 .app {
  filter: url(#chromAb);
}
body.curse-stage-3 .board {
  filter: contrast(1.1) saturate(1.15);
}

/* ----- 呪われた手の影（縁から伸びる） ----- */
body.curse-stage-3::before {
  content: "";
  position: fixed;
  left: -20px; top: 30%;
  width: 140px; height: 40vh;
  background: radial-gradient(ellipse at left center, rgba(0,0,0,0.85), transparent 70%);
  pointer-events: none;
  z-index: 8;
  animation: handReach 7s ease-in-out infinite;
}
body.curse-stage-3::after {
  content: "";
  position: fixed;
  right: -20px; bottom: 20%;
  width: 140px; height: 40vh;
  background: radial-gradient(ellipse at right center, rgba(0,0,0,0.85), transparent 70%);
  pointer-events: none;
  z-index: 8;
  animation: handReach 9s ease-in-out infinite reverse;
}
@keyframes handReach {
  0%, 100% { transform: translateX(0); opacity: 0.5; }
  50%      { transform: translateX(40px); opacity: 0.9; }
}

/* ----- カードの「歪み」フィルター（呪い極大） ----- */
body.curse-stage-3 .card:not(.is-matched):not(.is-flipped) {
  filter: url(#distort);
}

/* ----- フラッシュ：強い赤発色 ----- */
.screen-flash.is-flash-strong {
  background: rgba(255, 30, 30, 0.55);
}

/* ----- 「振り向くな」テキスト ----- */
.dont-look {
  position: fixed;
  top: 32%;
  left: 50%;
  transform: translate(-50%, 0);
  font-size: clamp(22px, 5vw, 38px);
  font-weight: 900;
  letter-spacing: 0.55em;
  color: rgba(255, 240, 240, 0.95);
  text-shadow:
    0 0 18px rgba(200, 0, 0, 0.95),
    0 0 40px rgba(140, 0, 0, 0.8);
  pointer-events: none;
  z-index: 96;
  opacity: 0;
  white-space: nowrap;
}
.dont-look.is-show {
  animation: dontLookShow 1.6s ease;
}
@keyframes dontLookShow {
  0%   { opacity: 0; transform: translate(-50%, 12px) scale(0.92); filter: blur(8px); }
  20%  { opacity: 1; transform: translate(-50%, 0) scale(1); filter: blur(0); }
  80%  { opacity: 1; transform: translate(-50%, 0) scale(1); filter: blur(0); }
  100% { opacity: 0; transform: translate(-50%, -8px) scale(1.04); filter: blur(4px); }
}

/* ----- レスポンシブ調整 ----- */
@media (max-width: 480px) {
  .bg-ghost-woman { width: 60vw; }
  .bg-face-stare { width: 70vw; height: 70vw; }
  .dont-look { letter-spacing: 0.4em; }
}

/* ----- 縮小表示（タイトル文字に血の滴り） ----- */
.title-jp::before {
  content: "";
  position: absolute;
  top: 100%;
  left: 12%;
  width: 76%;
  height: 12px;
  background:
    radial-gradient(circle at 14% 30%, rgba(200, 8, 8, 0.85) 0%, transparent 30%),
    radial-gradient(circle at 38% 60%, rgba(200, 8, 8, 0.75) 0%, transparent 28%),
    radial-gradient(circle at 70% 40%, rgba(200, 8, 8, 0.85) 0%, transparent 30%);
  filter: blur(1px);
  opacity: 0;
  transition: opacity 1.2s ease;
}
body.curse-stage-2 .title-jp::before { opacity: 0.55; }
body.curse-stage-3 .title-jp::before { opacity: 0.95; }

/* ----- prefers-reduced-motion ----- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.05s !important;
  }
  .hannya-flash.is-flash { opacity: 0 !important; }
  .bg-ghost-woman { display: none; }
}
