/* =========================================================
   OUR HUB — 로그인 전 전체 비공개 잠금 게이트
   ─────────────────────────────────────────────────────────
   이 파일 하나로 9개 페이지가 모두 같은 잠금 화면을 쓴다.
   · 로그인 전: 본문(body 의 모든 자식)은 visibility:hidden —
     자리는 남겨 두어 캔버스·편집실이 크기를 0으로 재지 않게 한다.
   · 잠금 화면은 JS(auth-gate.js)가 <body> 끝에 붙인다.
     #lphAuthGate 만 예외로 보이게 둔다.
   ========================================================= */

/* ① 잠금 상태 — 본문을 아예 보이지 않게 (게이트 말고 전부) */
html:not(.ag-authed) body > *:not(#lphAuthGate) {
  visibility: hidden !important;
}

/* 잠금 화면 자체는 항상 보이게 (visibility 는 상속되므로 명시) */
.ag-gate {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: center;
  padding: 26px 18px calc(26px + env(safe-area-inset-bottom, 0px));
  overflow: auto;
  overscroll-behavior: contain;
  background: #06080c;
  color: var(--text, #eef3fb);
  font-family: var(--font-body, 'Pretendard Variable', Pretendard, -apple-system,
    BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif);
  -webkit-font-smoothing: antialiased;
  visibility: visible !important;
  isolation: isolate;
}

/* ② 바탕 — 다크 + 핑크 번짐 + 아주 옅은 모눈 */
.ag-gate::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(58vw 46vh at 8% -6%, rgba(59, 130, 246, .20), transparent 66%),
    radial-gradient(48vw 38vh at 102% 8%, rgba(29, 78, 216, .13), transparent 70%),
    radial-gradient(70vw 52vh at 50% 118%, rgba(59, 130, 246, .14), transparent 72%),
    linear-gradient(180deg, #080a0f 0%, #06080c 48%, #04060a 100%);
}

.ag-gate::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .5;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 34px 34px;
  -webkit-mask-image: radial-gradient(74% 62% at 50% 46%, #000 0%, rgba(0, 0, 0, .35) 62%, transparent 100%);
  mask-image: radial-gradient(74% 62% at 50% 46%, #000 0%, rgba(0, 0, 0, .35) 62%, transparent 100%);
}

/* 천천히 떠다니는 핑크 빛덩이 */
.ag-orb {
  position: fixed;
  z-index: -1;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(70px);
  opacity: .5;
}
.ag-orb--a {
  top: -22vmax;
  left: -16vmax;
  background: radial-gradient(circle, rgba(59, 130, 246, .34), transparent 66%);
  animation: ag-drift-a 18s ease-in-out infinite alternate;
}
.ag-orb--b {
  right: -18vmax;
  bottom: -24vmax;
  background: radial-gradient(circle, rgba(170, 110, 255, .22), transparent 68%);
  animation: ag-drift-b 22s ease-in-out infinite alternate;
}
@keyframes ag-drift-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(3vmax, 2vmax, 0) scale(1.08); }
}
@keyframes ag-drift-b {
  from { transform: translate3d(0, 0, 0) scale(1.04); }
  to   { transform: translate3d(-3vmax, -2vmax, 0) scale(1); }
}

/* ③ 가운데 카드 */
.ag-shell {
  position: relative;
  z-index: 1;
  width: min(432px, 100%);
  margin: auto;
  text-align: center;
}

.ag-card {
  position: relative;
  padding: 42px 30px 22px;
  border: 1px solid rgba(96, 165, 250, .26);
  border-radius: 28px;
  background:
    radial-gradient(120% 96% at 100% -8%, rgba(59, 130, 246, .17), transparent 62%),
    linear-gradient(168deg, #1d1626 0%, #141019 56%, #0d0a12 100%);
  box-shadow:
    0 50px 120px -56px #000,
    0 0 0 1px rgba(255, 255, 255, .03),
    inset 0 1px 0 rgba(255, 255, 255, .08);
  animation: ag-card-in .46s cubic-bezier(.22, 1, .36, 1) both;
}
/* 카드 위쪽 핑크 테이프 */
.ag-card::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  width: 84px;
  height: 17px;
  transform: translateX(-50%) rotate(-1.5deg);
  border-radius: 3px;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0) 0 6px, rgba(255, 255, 255, .13) 6px 12px),
    linear-gradient(180deg, rgba(59, 130, 246, .52), rgba(59, 130, 246, .3));
  opacity: .92;
}
/* 오른쪽 아래 은은한 핑크 번짐 */
.ag-card::after {
  content: "";
  position: absolute;
  right: -30px;
  bottom: -40px;
  width: 150px;
  height: 150px;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, .20), transparent 68%);
  pointer-events: none;
}
@keyframes ag-card-in {
  from { opacity: 0; transform: translateY(16px) scale(.975); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* 초대장이 열린 뒤 확인 카드가 부드럽게 펼쳐져 들어온다 */
.ag-card.is-revealed { animation: ag-card-in .52s cubic-bezier(.22, 1, .36, 1) both; }

.ag-kicker {
  margin: 0 0 16px;
  font-size: 10px;
  line-height: 1;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--pink-2, #60a5fa);
}

/* 자물쇠 배지 */
.ag-badge {
  position: relative;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin: 0 auto 16px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(59, 130, 246, .24), rgba(59, 130, 246, .07));
  box-shadow:
    inset 0 0 0 1px rgba(96, 165, 250, .36),
    0 16px 30px -20px rgba(59, 130, 246, .7);
}
.ag-badge svg { width: 27px; height: 27px; color: var(--pink-2, #60a5fa); }
/* 아주 천천히 번지는 테두리 */
.ag-badge::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 25px;
  border: 1px solid rgba(96, 165, 250, .3);
  animation: ag-ring 3.4s ease-in-out infinite;
}
@keyframes ag-ring {
  0%, 100% { opacity: .55; transform: scale(1); }
  50%      { opacity: .12; transform: scale(1.06); }
}

.ag-brand {
  margin: 0 0 14px;
  font-family: var(--font-title, 'Gowun Dodum', sans-serif);
  font-size: 12.5px;
  line-height: 1;
  letter-spacing: .2em;
  color: var(--text-3, #93a4bb);
  text-transform: uppercase;
}
.ag-brand em {
  font-style: normal;
  color: var(--pink, #3b82f6);
}

.ag-title {
  margin: 0;
  font-family: var(--font-title, 'Gowun Dodum', sans-serif);
  font-size: 21px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: -.01em;
  color: var(--text, #eef3fb);
  word-break: keep-all;
}
.ag-sub {
  margin: 8px 0 24px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-3, #93a4bb);
  word-break: keep-all;
}

/* =========================================================
   0단계 — 초대장 인트로 (봉투가 열리면 아래 확인 카드가 나온다)
   ========================================================= */
.ag-card--intro { padding-bottom: 20px; }
.ag-card--intro:focus { outline: none; }

.ag-env {
  position: relative;
  width: 138px;
  height: 92px;
  margin: 2px auto 20px;
  perspective: 620px;
}
/* 봉투 뒤 은은한 빛 */
.ag-env::before {
  content: "";
  position: absolute;
  inset: -20px -26px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, .22), transparent 68%);
  pointer-events: none;
}

/* 봉투 앞면 */
.ag-env-body {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 12px;
  background: linear-gradient(180deg, #16233a, #0d1219);
  box-shadow:
    inset 0 0 0 1px rgba(96, 165, 250, .38),
    0 22px 36px -26px #000;
}
/* 앞면 V자 접힘 — 아래 두 모서리에서 가운데로 */
.ag-env-body::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background:
    linear-gradient(to top right, transparent calc(50% - 1px), rgba(147, 197, 253, .34) 50%, transparent calc(50% + 1px)),
    linear-gradient(to top left, transparent calc(50% - 1px), rgba(147, 197, 253, .34) 50%, transparent calc(50% + 1px));
}
/* 앞면 아래쪽 입구 그림자 */
.ag-env-body::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 5px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, .5), transparent 70%);
}

/* 봉투에서 나오는 편지 */
.ag-env-letter {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  height: 70px;
  z-index: 2;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #f7fbff, #dbeafe);
  box-shadow: 0 12px 22px -16px #000, inset 0 0 0 1px rgba(255, 255, 255, .6);
  opacity: 0;
  transform: translateY(12px) scale(.94);
  transition: transform .52s cubic-bezier(.2, .9, .25, 1), opacity .3s ease;
}
.ag-env-letter::before {
  content: "";
  position: absolute;
  inset: 15px 14px auto;
  height: 1px;
  background: rgba(59, 130, 246, .38);
  box-shadow: 0 10px 0 rgba(59, 130, 246, .24), 0 20px 0 rgba(59, 130, 246, .16);
}

/* 봉투 플랩 — 빛을 받은 뚜껑처럼 보이게 */
.ag-env-flap {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 54%;
  z-index: 3;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(180deg, #1e3a5f 0%, #16273d 62%, #101a29 100%);
  box-shadow:
    inset 0 0 0 1px rgba(147, 197, 253, .45),
    0 10px 18px -12px rgba(0, 0, 0, .95);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  transform: rotateX(-7deg);
  transition: transform .54s cubic-bezier(.34, .9, .3, 1);
}

/* 왁스 실 */
.ag-env-seal {
  position: absolute;
  left: 50%;
  top: 46%;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #93c5fd, #1d4ed8 62%, #122a63);
  box-shadow: 0 7px 14px -7px #000, inset 0 1px 0 rgba(255, 255, 255, .45);
  color: #eff6ff;
  font-size: 15px;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  transition: opacity .28s ease, transform .36s ease;
}

/* 키보드 포커스 — 기본 테두리 대신 은은한 링 */
.ag-open:focus-visible {
  outline: 2px solid rgba(147, 197, 253, .9);
  outline-offset: 3px;
}

/* 버튼에 마우스를 올리면 플랩이 살짝 더 열린다 */
.ag-card--intro:has(.ag-open:hover):not(.is-opening) .ag-env-flap {
  transform: rotateX(-19deg);
}

/* 초대장 열기 — 플랩이 젖혀지고 편지가 올라오며 인트로 카드가 사라진다 */
.ag-card--intro.is-opening .ag-env-flap { transform: rotateX(-172deg); }
.ag-card--intro.is-opening .ag-env-letter { opacity: 1; transform: translateY(-36px) scale(1); }
.ag-card--intro.is-opening .ag-env-seal {
  opacity: 0;
  transform: translate(-50%, -50%) scale(.5) rotate(-22deg);
}
.ag-card--intro.is-opening { animation: ag-intro-out .5s .14s ease forwards; }
@keyframes ag-intro-out {
  to { opacity: 0; transform: translateY(-12px) scale(.975); }
}

.ag-open { margin-top: 2px; }
.ag-open span { margin-right: 6px; }
.ag-card--intro .ag-sub { margin-bottom: 18px; }

/* ④ 입력 */
.ag-form { margin: 0; }

.ag-label {
  display: block;
  margin: 0 2px 7px;
  font-size: 10.5px;
  line-height: 1;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-4, #6b7a90);
  text-align: left;
}

.ag-field {
  position: relative;
  display: flex;
  align-items: center;
}

.ag-input {
  width: 100%;
  padding: 15px 52px 15px 16px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 14px;
  background: rgba(255, 255, 255, .045);
  color: var(--text, #eef3fb);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: .18em;
  transition: border-color .18s, background .18s, box-shadow .18s;
}
.ag-input::placeholder {
  color: var(--text-4, #6b7a90);
  letter-spacing: -.01em;
}
.ag-input:hover { border-color: rgba(96, 165, 250, .32); }
.ag-input:focus {
  outline: none;
  border-color: rgba(96, 165, 250, .7);
  background: rgba(255, 255, 255, .06);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}

.ag-eye {
  position: absolute;
  right: 6px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--text-3, #93a4bb);
  cursor: pointer;
  transition: color .16s, background .16s;
}
.ag-eye:hover { color: var(--pink-2, #60a5fa); background: rgba(59, 130, 246, .1); }
.ag-eye svg { width: 18px; height: 18px; }
.ag-eye[aria-pressed="true"] { color: var(--pink-2, #60a5fa); }

.ag-error {
  min-height: 18px;
  margin: 8px 2px 0;
  font-size: 12px;
  line-height: 1.45;
  color: #fca5a5;
  text-align: left;
}

.ag-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 50px;
  margin-top: 6px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--pink-2, #60a5fa), var(--pink, #3b82f6));
  color: #04122b;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -.01em;
  cursor: pointer;
  box-shadow:
    0 16px 30px -18px rgba(59, 130, 246, .85),
    inset 0 1px 0 rgba(255, 255, 255, .35);
  transition: transform .16s, box-shadow .16s, filter .16s;
}
.ag-submit:hover { filter: brightness(1.06); transform: translateY(-1px); }
.ag-submit:active { transform: translateY(0) scale(.99); }
.ag-submit[aria-busy="true"] { opacity: .72; cursor: progress; }

.ag-foot {
  margin: 18px 0 0;
  padding-top: 13px;
  border-top: 1px dashed rgba(255, 255, 255, .08);
  font-size: 10.5px;
  line-height: 1.5;
  letter-spacing: .01em;
  color: var(--text-4, #6b7a90);
}

/* 잘못된 암호 — 카드가 살짝 흔들린다 */
.ag-card.is-error { animation: ag-shake .32s ease-in-out; }
@keyframes ag-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  45% { transform: translateX(6px); }
  70% { transform: translateX(-3px); }
}

.ag-watermark {
  margin: 18px 0 0;
  font-size: 9.5px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .18);
}

/* =========================================================
   ④-2 사람 확인 — ① 보안문자 ② 조각 맞추기 ③ 암호
   ========================================================= */

.ag-check { margin: 0 0 15px; }

.ag-check-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 2px 8px;
}
.ag-step {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: rgba(59, 130, 246, .16);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, .42);
  color: var(--pink-2, #60a5fa);
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.ag-check-head .ag-label { margin: 0; }

.ag-refresh {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border: 1px solid rgba(96, 165, 250, .3);
  border-radius: 999px;
  background: rgba(59, 130, 246, .08);
  color: var(--pink-3, #93c5fd);
  font-family: inherit;
  font-size: 10.5px;
  line-height: 1;
  letter-spacing: -.01em;
  cursor: pointer;
  transition: color .16s, border-color .16s, background .16s, transform .16s;
}
.ag-refresh:hover {
  color: var(--pink-2, #60a5fa);
  border-color: rgba(96, 165, 250, .6);
  background: rgba(59, 130, 246, .16);
  transform: translateY(-1px);
}
.ag-refresh:active { transform: translateY(0); }

.ag-canvas {
  display: block;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 13px;
  background: #10151f;
}
.ag-canvas--cap { height: 70px; }
.ag-canvas--puzzle { height: 86px; margin-bottom: 7px; }

.ag-input--cap {
  margin-top: 8px;
  padding: 12px 14px;
  text-align: center;
  text-transform: uppercase;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .24em;
}

.ag-range {
  display: block;
  width: 100%;
  height: 30px;
  margin: 0;
  padding: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  touch-action: pan-y;
}
.ag-range::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(59, 130, 246, .8), rgba(96, 165, 250, .34));
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .05);
}
.ag-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -9px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #dbeafe, #60a5fa 46%, #2563eb 100%);
  box-shadow: 0 6px 14px -6px rgba(59, 130, 246, .95), inset 0 1px 0 rgba(255, 255, 255, .55);
  transition: transform .14s, box-shadow .14s;
}
.ag-range:active::-webkit-slider-thumb { transform: scale(1.08); }
.ag-range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(59, 130, 246, .22), 0 6px 14px -6px rgba(59, 130, 246, .95);
}
.ag-range::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(59, 130, 246, .8), rgba(96, 165, 250, .34));
}
.ag-range::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #dbeafe, #60a5fa 46%, #2563eb 100%);
  box-shadow: 0 6px 14px -6px rgba(59, 130, 246, .95);
}

.ag-puzzle-state {
  margin: 0 2px 8px;
  font-size: 10.5px;
  line-height: 1.35;
  color: var(--text-4, #6b7a90);
  text-align: right;
  word-break: keep-all;      /* 한 글자만 다음 줄로 떨어지지 않게 */
  overflow-wrap: normal;
}
.ag-check-head + .ag-puzzle-state { margin-top: -2px; }
.ag-puzzle-state.is-ok { color: #ffd9a8; font-weight: 600; }

/* 5회 연속 틀림 — 30초 동안 입력을 잠근다 */
.ag-cooldown {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 10px 0 0;
  padding: 9px 12px;
  border: 1px solid rgba(255, 120, 90, .38);
  border-radius: 12px;
  background: rgba(255, 90, 70, .1);
  color: #ffb59c;
  font-size: 11.5px;
  line-height: 1.4;
}
.ag-cooldown-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #ffd0bd;
}
.ag-card.is-cooldown .ag-form input,
.ag-card.is-cooldown .ag-form button {
  opacity: .5;
  pointer-events: none;
}

/* 누적 15회 — 이 브라우저에서는 아예 들어올 수 없다 */
.ag-blocked {
  margin: 10px 0 0;
  padding: 12px 13px;
  border: 1px solid rgba(255, 80, 110, .46);
  border-radius: 12px;
  background: rgba(255, 60, 90, .13);
  color: #ffb3c0;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.55;
  text-align: center;
  word-break: keep-all;
}
.ag-card.is-blocked .ag-form input,
.ag-card.is-blocked .ag-form button {
  opacity: .32;
  pointer-events: none;
  filter: grayscale(.45);
}
.ag-card.is-blocked .ag-check-head,
.ag-card.is-blocked .ag-canvas,
.ag-card.is-blocked .ag-puzzle-state { opacity: .45; }

/* ⑤ 잠금 해제 뒤 — 오른쪽 위 잠금 버튼 (index 는 상단 바 버튼을 씀) */
.ag-relock {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(14px + env(safe-area-inset-right, 0px));
  z-index: 105;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px 9px 13px;
  border: 1px solid rgba(96, 165, 250, .32);
  border-radius: 999px;
  background: rgba(20, 16, 26, .84);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--text-2, #c3cee0);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -.01em;
  cursor: pointer;
  box-shadow: 0 12px 26px -20px #000;
  transition: color .16s, border-color .16s, background .16s, transform .16s;
  animation: ag-pill-in .4s .18s cubic-bezier(.22, 1, .36, 1) both;
}
.ag-relock:hover {
  color: var(--text, #eef3fb);
  border-color: rgba(96, 165, 250, .6);
  background: rgba(28, 22, 36, .92);
  transform: translateY(-1px);
}
.ag-relock-ico { font-size: 12px; line-height: 1; }
@keyframes ag-pill-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 페이지 위에 모달·리더·라이트박스가 열리면 잠금 버튼은 비켜 준다 */
html:has(dialog[open]) .ag-relock,
html:has(.modal:not([hidden])) .ag-relock,
html:has(.lightbox:not([hidden])) .ag-relock,
html:has(.reader:not([hidden])) .ag-relock {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ⑥ 잠금이 풀렸다는 짧은 안내 */
.ag-flash {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  z-index: 410;
  max-width: calc(100vw - 32px);
  padding: 11px 18px;
  border: 1px solid rgba(96, 165, 250, .3);
  border-radius: 999px;
  background: rgba(22, 17, 28, .94);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--text, #eef3fb);
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 22px 44px -26px #000;
  transform: translateX(-50%);
  visibility: visible !important;
  animation: ag-flash-in .3s cubic-bezier(.22, 1, .36, 1) both,
             ag-flash-out .3s 2s ease both;
  pointer-events: none;
}
@keyframes ag-flash-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes ag-flash-out {
  to { opacity: 0; transform: translate(-50%, 6px); }
}

/* ⑦ 작은 화면 · 움직임 줄이기 */
@media (max-width: 460px) {
  .ag-gate { padding: 18px 14px calc(18px + env(safe-area-inset-bottom, 0px)); }
  .ag-card { padding: 36px 20px 18px; border-radius: 24px; }
  .ag-title { font-size: 19px; }
  .ag-sub { font-size: 12px; margin-bottom: 20px; }
  .ag-submit { height: 48px; }
  .ag-relock { top: calc(10px + env(safe-area-inset-top, 0px)); right: 10px; padding: 8px 12px; font-size: 11.5px; }

  .ag-canvas--cap { height: 64px; }
  .ag-canvas--puzzle { height: 78px; }
  .ag-input--cap { font-size: 14px; }
  .ag-puzzle-state { font-size: 9.8px; }
  .ag-cooldown { font-size: 11px; padding: 8px 10px; }
  .ag-env { width: 116px; height: 78px; margin-bottom: 16px; }
  .ag-env-letter { height: 60px; }
}
@media (max-height: 640px) {
  .ag-badge { width: 52px; height: 52px; margin-bottom: 12px; }
  .ag-badge svg { width: 23px; height: 23px; }
  .ag-card { padding-top: 32px; }
  .ag-kicker { margin-bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .ag-card,
  .ag-relock,
  .ag-flash,
  .ag-orb,
  .ag-badge::after,
  .ag-card.is-error { animation: none !important; }
  .ag-env-flap,
  .ag-env-letter,
  .ag-env-seal,
  .ag-card--intro { transition: none !important; }
}
