.phfx-screen {
  --ink: #f3e8ca;
  --metal: #d1ac6a;
  --rim: #887048;
  --glow: 111 139 112;
  position: fixed;
  inset: 0;
  z-index: 14200;
  isolation: isolate;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  color: var(--ink);
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(48px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 50% 45%, rgb(var(--glow) / .22), transparent 52%), linear-gradient(100deg, #16120ef2, #121817df 48%, #16100cf2);
  backdrop-filter: blur(3px);
  font: 400 1rem/1.55 system-ui, sans-serif;
  overscroll-behavior: contain;
  animation: phfx-fade .24s ease-out both;
}
.phfx-screen::before, .phfx-screen::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: -1;
}
.phfx-screen::before {
  inset: 0;
  opacity: .27;
  background: repeating-linear-gradient(98deg, transparent 0 3px, #c7a3760a 4px 5px, transparent 6px 13px), repeating-linear-gradient(0deg, transparent 0 2px, #0002 2px 3px);
}
.phfx-screen::after {
  inset: clamp(9px, 2.5vw, 34px);
  border: 1px solid #aa89543b;
  outline: 1px solid #aa89541f;
  outline-offset: -5px;
}
.phfx-phase-frame {
  box-sizing: border-box;
  width: min(600px, 92%);
  max-height: 100%;
  position: relative;
  text-align: center;
  padding: clamp(12px, 4vh, 38px) 0;
  animation: phfx-rise .5s cubic-bezier(.2,.7,.2,1) both;
}
.phfx-emblem {
  width: min(24vh, 185px);
  margin: 0 auto clamp(13px, 3vh, 28px);
  color: var(--metal);
  filter: drop-shadow(0 0 15px rgb(var(--glow) / .38));
}
.phfx-emblem svg,.phfx-seal svg { width: 100%; height: auto; display: block }
.fx-mark-fine { opacity: .52; stroke-width: .8 }
.fx-mark-base { opacity: .68 }
.fx-mark-motion { transform-box: view-box; transform-origin: 50% 50% }
.phfx-lens { --metal: #c3d3a4; --glow: 89 131 108 }
.phfx-claw { --metal: #e0a181; --glow: 155 66 43 }
.phfx-clock { --metal: #e3c58c; --glow: 154 124 60 }
.phfx-moon { --metal: #bcacd5; --glow: 104 87 148 }
.phfx-lens .fx-mark-motion { animation: phfx-search 1.7s ease-in-out both }
.phfx-claw .fx-mark-slashes { fill: currentColor; animation: phfx-slash .75s ease-out both }
.phfx-clock .fx-mark-motion { animation: phfx-tick 1.45s steps(5,end) both }
.phfx-moon .fx-mark-motion { animation: phfx-eclipse 1.6s ease-out both }
.phfx-door .fx-mark-motion,.phfx-book .fx-mark-motion { animation: phfx-fade 1.3s both }
.phfx-kicker {
  display: block;
  color: var(--metal);
  font: 650 .8rem/1.4 system-ui,sans-serif;
  letter-spacing: .12em;
}
.phfx-title {
  color: var(--ink);
  font-family: "Nanum Myeongjo", "Noto Serif KR", Batang, serif;
  font-weight: 700;
  line-height: 1.22;
  word-break: keep-all;
  overflow-wrap: anywhere;
  text-shadow: 0 3px 16px #0007;
  margin: .3em 0;
}
.phfx-phase .phfx-title {
  font-size: clamp(38px, 7vw, 86px);
  letter-spacing: .045em;
}
.phfx-sub {
  display: flex;
  justify-content: center;
  align-items: center;
  color: #d2c9b7;
  font-size: clamp(.84rem, 1.8vw, 1.05rem);
  gap: 14px;
  margin: .6em auto 0;
  text-wrap: balance;
}
.phfx-sub::before,.phfx-sub::after { content: ""; width: min(6vw,55px); border-top: 1px solid var(--rim) }
.phfx-screen button {
  border: 1px solid #b69667a8;
  border-radius: 3px;
  color: #f6e7cd;
  font: 650 .88rem/1.2 system-ui,sans-serif;
  padding: .62rem 1.15rem;
  background: #332f27;
  cursor: pointer;
  touch-action: manipulation;
}
.phfx-screen button:hover { border-color: #e9cea4; color: white }
.phfx-screen button:focus-visible,.phfx-printed:focus-visible { outline: 2px solid #f4d396; outline-offset: 3px }
.phfx-screen .phfx-phase-next {
  position: absolute;
  bottom: max(22px,6vh);
  left: 50%;
  transform: translateX(-50%);
  background: #171a16;
}
.phfx-encounter { --glow: 144 96 58 }
.phfx-spread {
  position: relative;
  display: grid;
  grid-template-columns: minmax(110px, .8fr) minmax(225px, 1.25fr);
  align-items: center;
  gap: clamp(22px,4vw,60px);
  width: min(900px, 89vw);
  box-sizing: border-box;
  max-height: 100%;
}
.phfx-well {
  width: min(100%, 35vh, 325px);
  justify-self: end;
  aspect-ratio: 62 / 88;
  perspective: 1100px;
  animation: phfx-deal .55s cubic-bezier(.15,.74,.28,1) both;
}
.phfx-flipper {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .72s cubic-bezier(.25,.68,.18,1);
}
.phfx-revealed .phfx-flipper { transform: rotateY(-180deg) }
.phfx-face {
  position: absolute;
  inset: 0;
  border: 1px solid #987e59;
  border-radius: 5.4% / 3.8%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: 0 16px 35px #000a;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.phfx-back {
  background: repeating-radial-gradient(ellipse at center,#342738 0 3px,#19141d 4px 6px);
  transform: rotateY(0deg);
}
.phfx-front {
  gap: .5em;
  background: linear-gradient(140deg, #2d302d, #433428 50%, #232421);
  color: #f3dec3;
  transform: rotateY(180deg);
  text-align: center;
}
.phfx-front::before { content: ""; position: absolute; inset: 6%; border: 1px double #aa8e60; border-width: 3px; pointer-events: none }
.phfx-front strong { padding: 0 9%; font: 700 clamp(14px,2.5vw,27px)/1.35 Batang,serif; word-break: keep-all }
.phfx-seal { width: 58%; color: #bd9965 }
.phfx-scan { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; opacity: 0; }
.phfx-scan.phfx-loaded { opacity: 1 }
.phfx-panel {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  max-height: min(78dvh, 680px);
  min-height: 0;
  border-block: 1px solid #b898684f;
  padding: clamp(.8rem, 2.5vh, 1.7rem) 0;
}
.phfx-panel .phfx-title { font-size: clamp(23px, 3.4vw, 44px) }
.phfx-panel .phfx-title,.phfx-printed { visibility: hidden; opacity: 0; transition: opacity .38s ease }
.phfx-revealed .phfx-title,.phfx-revealed .phfx-printed { visibility: visible; opacity: 1 }
.phfx-printed {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #9d8459 #252520;
  max-height: 46vh;
  padding: 2px 5px 2px 0;
  text-align: left;
  font-size: clamp(.83rem, 1.5vw, 1rem);
  line-height: 1.55;
}
.phfx-printed .printed-card { margin: 0; }
.phfx-local-controls { display: flex; gap: .55rem; align-items: center; padding-top: 1rem; }
.phfx-screen .phfx-next { border-color: #b19869; background: #574531 }
.phfx-paused .phfx-pause { color: #1e1b15; background: #dec599 }
.phfx-fast .phfx-phase-frame,.phfx-fast .phfx-well,.phfx-fast .fx-mark-motion { animation-duration: .22s }
.phfx-fast .phfx-flipper { transition-duration: .29s }
@keyframes phfx-fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes phfx-rise { from { opacity: 0; transform: translateY(16px) } to { opacity: 1; transform: none } }
@keyframes phfx-deal { from { opacity: 0; transform: translate(-12vw,8vh) scale(.74) rotate(-14deg) } to { opacity: 1; transform: none } }
@keyframes phfx-search { 0% { transform: translate(-8px,6px) rotate(-9deg) } 65% { transform: translate(3px,-3px) rotate(2deg) } 100% { transform: none } }
@keyframes phfx-slash { 0% { opacity: 0; transform: translate(11px,-11px) scale(.92) } 35% { opacity: 1; transform: translate(-2px,2px) } 100% { transform: none } }
@keyframes phfx-tick { from { transform: rotate(-54deg) } to { transform: none } }
@keyframes phfx-eclipse { from { opacity: .2; transform: translateX(-12px) } to { opacity: 1; transform: none } }
@media (max-width: 600px) and (min-height: 471px) {
  .phfx-spread { grid-template-columns: 1fr; grid-template-rows: auto minmax(0,1fr); gap: 12px; width: min(90vw,440px); max-height: calc(100dvh - 88px) }
  .phfx-well { width: min(35vw,18vh); justify-self: center }
  .phfx-panel { max-height: 100%; padding: .6rem 0; }
  .phfx-printed { max-height: 34vh }
  .phfx-local-controls { padding-top: .5rem }
}
@media (max-height: 470px) {
  .phfx-screen { padding: 12px 20px 36px }
  .phfx-emblem { width: 23vh; margin-bottom: 5px }
  .phfx-phase-frame { padding: 6px 0 }
  .phfx-phase .phfx-title { font-size: 9vh }
  .phfx-screen .phfx-phase-next { bottom: 8px; padding: .35rem .9rem }
  .phfx-spread { grid-template-columns: minmax(60px,.65fr) minmax(120px,1.45fr); width: min(90vw,720px); gap: 20px }
  .phfx-well { width: min(100%,43vh) }
  .phfx-panel { max-height: 82dvh; padding: .4rem 0; }
  .phfx-printed { max-height: 42vh }
  .phfx-local-controls { padding-top: .35rem }
}
@media (prefers-reduced-motion: reduce) {
  .phfx-screen,.phfx-screen * { animation: none !important; transition: none !important }
  .phfx-flipper,.phfx-revealed .phfx-flipper,.phfx-face { transform: none }
  .phfx-front,.phfx-revealed .phfx-back { visibility: hidden }
  .phfx-revealed .phfx-front { visibility: visible }
}
