/* 할리갈리 연출: 헛종 난리, 카드 획득 RIZZ, 우승 매드무비.
   번쩍임은 한 번에 1~2회, 초당 3회를 넘지 않게 제한합니다. 동작 줄이기 설정에서는 흔들림·번쩍임을 끕니다. */

/* ---------- 헛종: GET OUT ---------- */
.fx-chaos {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  overflow: hidden;
  pointer-events: none;
  text-align: center;
  animation: fx-chaos-bg 2.3s steps(1, end) forwards;
}

@keyframes fx-chaos-bg {
  0% { background: rgb(184 50 63 / .78); }
  22% { background: rgb(27 33 30 / .68); }
  44% { background: rgb(184 50 63 / .6); }
  66% { background: rgb(27 33 30 / .58); }
  88% { background: rgb(27 33 30 / .5); opacity: 1; }
  100% { background: transparent; opacity: 0; }
}

.fx-getout {
  position: relative;
  color: var(--sheet);
  font-size: clamp(64px, 17vw, 240px);
  font-weight: 950;
  line-height: .9;
  letter-spacing: -.04em;
  -webkit-text-stroke: .035em var(--ink);
  paint-order: stroke fill;
  transform: skewX(-8deg);
  animation: fx-slam .32s cubic-bezier(.2, .9, .25, 1) both, fx-jitter .09s steps(2) .32s 14;
}

.fx-getout::before,
.fx-getout::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  -webkit-text-stroke: 0;
  mix-blend-mode: multiply;
}

.fx-getout::before { color: var(--gardenia); transform: translate(-.04em, .03em); z-index: -1; }
.fx-getout::after { color: var(--indigo); transform: translate(.05em, -.03em); z-index: -2; }

.fx-offender {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0 .3em;
  padding: .1em .45em;
  background: var(--ink);
  color: var(--gardenia);
  font-size: clamp(28px, 6.5vw, 76px);
  font-weight: 900;
  line-height: 1.15;
  transform: rotate(-3deg);
  animation: fx-slam .3s .18s cubic-bezier(.2, .9, .25, 1) both;
}

.fx-offender span { color: var(--sheet); font-size: .6em; }
/* 닉네임 색이 어두워도 먹 배경 위에서 읽히도록 밝은 테두리 */
.fx-offender b[style*="color"],
.fx-offender b span[style*="color"] { -webkit-text-stroke: .07em var(--sheet); paint-order: stroke fill; }

.fx-shame {
  padding: 4px 14px;
  border: 3px solid var(--ink);
  background: var(--sheet);
  color: var(--safflower);
  font-size: clamp(18px, 3.4vw, 36px);
  font-weight: 900;
  transform: rotate(4deg);
  animation: fx-slam .3s .42s cubic-bezier(.2, .9, .25, 1) both;
}

.fx-rain {
  position: absolute;
  top: -12vh;
  width: var(--size);
  height: var(--size);
  animation: fx-fall 1.7s var(--delay) cubic-bezier(.45, 0, .8, .6) both;
}

@keyframes fx-fall {
  from { transform: translateY(0) rotate(0); }
  to { transform: translateY(125vh) rotate(var(--spin)); }
}

.fx-jjok {
  position: fixed;
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border: 6px solid var(--safflower);
  border-radius: 50%;
  color: var(--safflower);
  background: rgb(242 244 239 / .85);
  font-size: 58px;
  font-weight: 950;
  translate: -50% -50%;
  animation: fx-stamp .34s .25s cubic-bezier(.2, .9, .25, 1) both;
}

@keyframes fx-stamp {
  from { transform: scale(3.2) rotate(-40deg); opacity: 0; }
  70% { transform: scale(.9) rotate(-12deg); opacity: 1; }
  to { transform: scale(1) rotate(-14deg); opacity: 1; }
}

.fx-chaos.is-mine .fx-getout { font-size: clamp(76px, 21vw, 300px); }
.fx-chaos.is-mine .fx-shame { background: var(--safflower); color: var(--sheet); border-color: var(--sheet); }

@keyframes fx-slam {
  from { transform: scale(2.6) rotate(-9deg); opacity: 0; }
  60% { transform: scale(.94) rotate(-3deg); opacity: 1; }
  to { opacity: 1; }
}

@keyframes fx-jitter {
  0% { translate: -6px 3px; }
  50% { translate: 7px -4px; }
  100% { translate: -3px -2px; }
}

body.fx-quake .halli-main { animation: fx-quake .55s cubic-bezier(.36, .07, .19, .97) both; }
body.fx-quake-hard .halli-main { animation: fx-quake-hard 1.1s cubic-bezier(.36, .07, .19, .97) both; }

@keyframes fx-quake {
  10%, 90% { transform: translate(-3px, 1px); }
  20%, 80% { transform: translate(6px, -2px); }
  30%, 50%, 70% { transform: translate(-10px, 3px) rotate(-.6deg); }
  40%, 60% { transform: translate(10px, -3px) rotate(.6deg); }
}

@keyframes fx-quake-hard {
  0% { transform: none; filter: none; }
  8% { transform: translate(-16px, 6px) rotate(-2.5deg) scale(1.02); filter: invert(1); }
  16% { transform: translate(18px, -8px) rotate(2deg); filter: none; }
  26% { transform: translate(-14px, 4px) rotate(-1.5deg) skewX(4deg); }
  38% { transform: translate(12px, -6px) rotate(1.2deg); }
  52% { transform: translate(-8px, 3px) rotate(-.8deg); }
  68% { transform: translate(5px, -2px) rotate(.4deg); }
  100% { transform: none; filter: none; }
}

/* ---------- 카드 획득: RIZZ ---------- */
.fx-rizz {
  position: fixed;
  z-index: 880;
  display: grid;
  justify-items: center;
  translate: -50% -50%;
  pointer-events: none;
  animation: fx-rizz 1.6s cubic-bezier(.2, .8, .25, 1) both;
}

.fx-rizz b {
  position: relative;
  padding: 2px 14px 4px;
  background: var(--gardenia);
  color: var(--ink);
  font-size: clamp(30px, 5vw, 54px);
  font-weight: 950;
  letter-spacing: .02em;
  transform: rotate(-6deg);
}

.fx-rizz b::before,
.fx-rizz b::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  background: var(--sheet);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: fx-sparkle .5s ease-in-out 3 alternate;
}

.fx-rizz b::before { top: -10px; right: -12px; }
.fx-rizz b::after { bottom: -8px; left: -14px; animation-delay: .2s; }

.fx-rizz span {
  margin-top: 4px;
  padding: 0 8px;
  background: var(--mugwort);
  color: var(--on-dye);
  font-size: var(--text-lg);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.fx-rizz-name {
  max-width: min(44vw, 260px);
  margin-top: 3px;
  padding: 0 8px;
  overflow: hidden;
  background: var(--sheet);
  color: var(--ink);
  font-size: var(--text-sm);
  font-style: normal;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: rotate(3deg);
}

.fx-rizz.is-mine b { font-size: clamp(40px, 8vw, 84px); }
.fx-rizz b, .fx-rizz span { white-space: nowrap; }
@media (max-width: 640px) {
  .fx-rizz b, .fx-rizz.is-mine b { padding: 2px 9px 3px; font-size: 28px; }
  .fx-rizz.is-mine b { font-size: 34px; }
  .fx-rizz span { font-size: 15px; }
}

@keyframes fx-rizz {
  from { transform: scale(.2) translateY(30px); opacity: 0; }
  18% { transform: scale(1.15) translateY(-6px); opacity: 1; }
  30% { transform: scale(1) translateY(0); }
  80% { opacity: 1; }
  to { transform: translateY(-46px); opacity: 0; }
}

@keyframes fx-sparkle {
  from { transform: scale(.4) rotate(0); }
  to { transform: scale(1.2) rotate(45deg); }
}

.fx-rizz-frame {
  position: fixed;
  inset: 0;
  z-index: 870;
  border: 10px solid var(--mugwort);
  pointer-events: none;
  animation: fx-frame .8s ease-out both;
}

@keyframes fx-frame {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ---------- 우승 매드무비 ---------- */
.vx {
  --pulse: 0;
  --intensity: 0;
  --zoom: 1;
  --dye-color: var(--ink);
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: hidden;
  background: #0b0f0d;
  color: var(--sheet);
  font-family: var(--font);
  isolation: isolate;
}

.vx[hidden] { display: none !important; }
.vx:focus { outline: none; }

.vx[data-dye="indigo"] { --dye-color: var(--indigo); }
.vx[data-dye="safflower"] { --dye-color: var(--safflower); }
.vx[data-dye="mugwort"] { --dye-color: var(--mugwort); }
.vx[data-dye="gardenia"] { --dye-color: var(--gardenia); }

/* 앞부분(pre·intro): 게임 화면이 비쳐 보이도록 투명하게 두고 가장자리만 어둡게 */
.vx[data-phase="pre"],
.vx[data-phase="intro"] { background: transparent; }

.vx-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: radial-gradient(ellipse at center, transparent 30%, rgb(5 7 6 / .88) 100%);
  opacity: var(--vignette, 0);
  pointer-events: none;
}

.vx:not([data-phase="pre"]):not([data-phase="intro"]) .vx-vignette { opacity: 0; }

.vx-bg {
  position: absolute;
  inset: 0;
  background: var(--dye-color);
  opacity: 0;
  transition: background-color 120ms linear;
}

.vx:not([data-phase="intro"]):not([data-phase="pre"]) .vx-bg { opacity: 1; }

/* 회전하는 햇살 */
.vx-rays {
  position: absolute;
  inset: -60vmax;
  background: repeating-conic-gradient(rgb(255 255 255 / .13) 0 9deg, transparent 9deg 18deg);
  opacity: 0;
  animation: vx-spin 14s linear infinite;
}

.vx:not([data-phase="intro"]):not([data-phase="pre"]) .vx-rays { opacity: calc(.45 + var(--pulse) * .4); }
.vx[data-phase="final"] .vx-rays,
.vx[data-phase="build"] .vx-rays { animation-duration: 5s; }
.vx[data-phase="end"] .vx-rays { animation-duration: 30s; }

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

/* 과일비·불꽃놀이 캔버스 (halli-victory.js가 그림) */
.vx-rain { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.vx[data-phase="pre"] .vx-rain,
.vx[data-phase="intro"] .vx-rain { display: none; }

/* 영화 화면비 띠 */
.vx-bars::before,
.vx-bars::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 11vh;
  background: #050706;
  z-index: 4;
  transition: height 600ms var(--ease);
  animation: vx-bars-in 1.6s var(--ease) both;
}

.vx-bars::before { top: 0; }
.vx-bars::after { bottom: 0; }
.vx[data-phase="build"] .vx-bars::before,
.vx[data-phase="build"] .vx-bars::after { height: calc(11vh + var(--pulse) * 3vh); transition: none; }
.vx[data-phase="final"] .vx-bars::before,
.vx[data-phase="final"] .vx-bars::after,
.vx[data-phase="end"] .vx-bars::before,
.vx[data-phase="end"] .vx-bars::after { height: 5vh; }

@keyframes vx-bars-in { from { height: 0; } }

.vx-flash {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: var(--sheet);
  opacity: 0;
  pointer-events: none;
}

.vx-frame {
  position: absolute;
  inset: 0;
  z-index: 5;
  border: calc(var(--pulse) * var(--intensity) * 18px) solid var(--gardenia);
  opacity: 0;
  pointer-events: none;
}

.vx[data-phase="build"] .vx-frame,
.vx[data-phase="final"] .vx-frame { opacity: 1; }

/* 무대 */
/* 무대: 왕관·이름·우승·한 줄·기록이 세로로 쌓입니다. 이름 크기는 --fit(halli-victory.js가 화면 높이에 맞춰 계산)으로 줄어듭니다. */
.vx-stage {
  position: absolute;
  inset: 11vh 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1.2vh, 16px);
  padding: 8px 4vw;
  text-align: center;
}

.vx-stage > * { flex: none; }
.vx[data-phase="end"] .vx-stage { bottom: calc(5vh + 84px); }

/* WAIT… WAIT… WAIT… 차곡차곡 쌓이는 말 */
.vx-words { position: absolute; inset: 0; z-index: 4; pointer-events: none; }

.vx-word {
  position: absolute;
  translate: -50% -50%;
  color: var(--sheet);
  font-size: clamp(44px, 9vw, 130px);
  font-weight: 950;
  line-height: 1;
  letter-spacing: -.02em;
  white-space: nowrap;
  -webkit-text-stroke: .035em var(--ink);
  paint-order: stroke fill;
  text-shadow: .06em .06em 0 var(--ink);
}

.vx-word[data-step="0"] { left: 22%; top: 28%; rotate: -8deg; }
.vx-word[data-step="1"] { left: 74%; top: 34%; rotate: 6deg; font-size: clamp(48px, 10vw, 145px); }
.vx-word[data-step="2"] { left: 28%; top: 58%; rotate: -4deg; font-size: clamp(52px, 11vw, 160px); color: var(--gardenia); }
.vx-word[data-step="3"] { left: 72%; top: 66%; rotate: 5deg; font-size: clamp(56px, 12vw, 175px); }
.vx-word[data-step="4"] { left: 44%; top: 42%; rotate: -3deg; font-size: clamp(64px, 14vw, 205px); color: var(--gardenia); }
.vx-word[data-step="5"] { left: 54%; top: 52%; font-size: clamp(80px, 18vw, 260px); color: var(--safflower); -webkit-text-stroke-color: var(--sheet); }

/* 축하 도중 나오는 가사 "WHAT THE HELLLLLL" */
.vx-lyric {
  position: absolute;
  left: 50%;
  top: calc(11vh + 10px);
  z-index: 4;
  translate: -50% 0;
  max-width: 96vw;
  padding: .06em .3em .1em;
  background: var(--ink);
  color: var(--sheet);
  font-size: clamp(28px, 5.4vw, 84px);
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
  text-shadow: .05em .05em 0 var(--safflower);
  rotate: -4deg;
  pointer-events: none;
}

.vx-lyric:empty { display: none; }

.vx-name,
.vx-title,
.vx-sub,
.vx-crown { opacity: 0; }

.vx:not([data-phase="intro"]):not([data-phase="pre"]) .vx-name,
.vx:not([data-phase="intro"]):not([data-phase="pre"]) .vx-title,
.vx:not([data-phase="intro"]):not([data-phase="pre"]) .vx-sub { opacity: 1; }

.vx-name {
  max-width: 96vw;
  transform: scale(calc(var(--zoom) * (1 + var(--pulse) * var(--intensity) * .07)));
  transform-origin: center;
}

.vx-name-text {
  display: block;
  font-size: calc(clamp(40px, calc(190vw / (var(--length, 4) + 1.6)), 30vh) * var(--fit, 1));
  font-weight: 950;
  line-height: .95;
  letter-spacing: -.045em;
  color: var(--sheet);
  -webkit-text-stroke: .045em var(--ink);
  paint-order: stroke fill;
  text-shadow: .07em .07em 0 var(--ink), -.035em -.035em 0 var(--gardenia);
  overflow-wrap: anywhere;
}

.vx[data-dye="gardenia"] .vx-name-text { text-shadow: .07em .07em 0 var(--ink), -.035em -.035em 0 var(--indigo); }

.vx-title {
  padding: .02em .35em .08em;
  background: var(--gardenia);
  color: var(--ink);
  font-size: clamp(30px, min(10vw, 12vh), 136px);
  font-weight: 950;
  line-height: 1.05;
  letter-spacing: .08em;
  transform: rotate(-5deg);
  border: .06em solid var(--ink);
}

.vx[data-dye="gardenia"] .vx-title { background: var(--sheet); }

.vx-sub {
  padding: 2px 12px;
  background: var(--ink);
  color: var(--sheet);
  font-size: clamp(14px, min(2.6vw, 3.6vh), 30px);
  font-weight: 850;
}

/* 기록 줄: 비어 있어도 같은 높이를 미리 잡아 두어 나타날 때 화면 밖으로 밀리지 않습니다. */
.vx-stat {
  box-sizing: content-box;
  min-height: 1.25em;
  max-width: 92vw;
  padding: .05em .5em .12em;
  border: 4px solid transparent;
  color: var(--ink);
  font-size: clamp(18px, min(4vw, 5.5vh), 52px);
  font-weight: 900;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.vx-stat:not(:empty) {
  background: var(--sheet);
  border-color: var(--ink);
  transform: rotate(2deg);
}

.vx[data-phase="b"] .vx-name { rotate: -3deg; }

/* 흐르는 띠 */
.vx-marquee {
  position: absolute;
  top: 50%;
  left: -10vw;
  right: -10vw;
  z-index: 2;
  padding: .3em 0;
  background: var(--ink);
  color: var(--gardenia);
  font-size: clamp(22px, 4vw, 48px);
  font-weight: 950;
  white-space: nowrap;
  transform: rotate(-9deg) translateY(-50%);
  opacity: 0;
  overflow: hidden;
}

.vx-marquee span { display: inline-block; animation: vx-marquee 9s linear infinite; }
.vx[data-phase="d"] .vx-marquee,
.vx[data-phase="build"] .vx-marquee,
.vx[data-phase="final"] .vx-marquee,
.vx[data-phase="end"] .vx-marquee { opacity: .92; }
.vx[data-phase="d"] .vx-stage,
.vx[data-phase="build"] .vx-stage { z-index: 3; }

@keyframes vx-marquee { to { transform: translateX(-50%); } }

/* 조각 왕관 */
.vx-crown {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: clamp(26px, 8vh, 96px);
}

.vx-crown i {
  width: clamp(16px, 2.6vw, 34px);
  background: var(--gardenia);
  border: 3px solid var(--ink);
}

.vx-crown i:nth-child(1), .vx-crown i:nth-child(5) { height: 60%; }
.vx-crown i:nth-child(2), .vx-crown i:nth-child(4) { height: 82%; background: var(--sheet); }
.vx-crown i:nth-child(3) { height: 100%; background: var(--safflower); }

.vx[data-phase="final"] .vx-crown,
.vx[data-phase="end"] .vx-crown { opacity: 1; }


.vx-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 8;
  display: flex;
  gap: 8px;
}

.vx-controls button {
  min-height: 36px;
  border-color: var(--sheet);
  background: rgb(11 15 13 / .7);
  color: var(--sheet);
}

.vx-controls button:hover:not(:disabled) { background: var(--ink); }

.vx-end {
  position: absolute;
  left: 50%;
  bottom: calc(5vh + 16px);
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  translate: -50% 0;
}

.vx-end .btn { min-height: 52px; padding: 0 24px; font-size: var(--text-md); }
.vx-end .btn:not(.primary) { background: var(--sheet); }

@media (max-width: 640px) {
  .vx-stage { inset: 9vh 0 14vh; }
  .vx-name-text { font-size: calc(clamp(40px, calc(300vw / (var(--length, 4) + 2)), 22vh) * var(--fit, 1)); }
  .vx[data-phase="end"] .vx-stage { bottom: calc(5vh + 76px); }

  .vx-end { bottom: calc(5vh + 12px); width: calc(100% - 32px); }
  .vx-end .btn { flex: 1 1 140px; }
}

/* 동작 줄이기: 흔들림·번쩍임·회전 없이 이름과 음악만 */
.vx.is-calm .vx-rays,
.vx.is-calm .vx-flash,
.vx.is-calm .vx-frame,
.vx.is-calm .vx-rain { display: none; }
.vx.is-calm .vx-name { transform: none; }
.vx.is-calm .vx-marquee span { animation: none; }

@media (prefers-reduced-motion: reduce) {
  .fx-chaos { animation: none; background: rgb(27 33 30 / .6); }
  .fx-getout, .fx-offender, .fx-shame { animation: none; }
  body.fx-quake .halli-main, body.fx-quake-hard .halli-main { animation: none; }
}
