/* ⚔️ 가게게임 공방전 — 얼굴 순위·아이템 독·발동 연출·「막을까요?」 (2026-09-17)
   문제 푸는 손을 막지 않는 것이 첫째다: 연출층은 pointer-events:none,
   무대는 «문제 칸(#prompt)» 안에만 있고 정답 게임판(#arena) 위로는 절대 올라가지 않는다. */

/* ── 얼굴 한 칸 (강호행에 저장된 모습의 머리 위쪽) */
.facepic {
  display: inline-flex; align-items: center; justify-content: center;
  flex: none; position: relative; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--ink); box-shadow: 1.5px 1.5px 0 var(--ink);
  overflow: hidden; vertical-align: middle;
}
.facepic canvas { display: block; border-radius: 50%; }
.facepic[data-pending]::after {
  content: "…"; font-weight: 900; color: var(--muted); font-size: 12px;
}
.facepic.lead { border-color: var(--yel); box-shadow: 0 0 0 2px var(--yel), 1.5px 1.5px 0 var(--ink); }
.facepic.me { border-color: var(--red); }
.facepic.fin { filter: grayscale(.55) brightness(1.04); }
.facepic.off { opacity: .45; }
.facepic .crown { position: absolute; top: -3px; left: 50%; transform: translateX(-50%); font-size: 12px; line-height: 1; }
@keyframes facehit {
  0% { transform: translate(0, 0) }
  15% { transform: translate(-4px, 2px) rotate(-6deg) }
  30% { transform: translate(4px, -2px) rotate(5deg) }
  45% { transform: translate(-3px, 1px) rotate(-4deg) }
  60% { transform: translate(3px, -1px) rotate(3deg) }
  100% { transform: translate(0, 0) }
}
.facepic.hitfx { animation: facehit .55s both; border-color: var(--red); box-shadow: 0 0 0 3px #e8193c66; }
@media (prefers-reduced-motion: reduce) { .facepic.hitfx { animation: none } }

/* 순위 줄의 얼굴 — 가로(넓은 화면)에서 이름 왼쪽에 조금 크게.
   `.lb li` 는 26px/이름/점수 세 칸이라 얼굴 칸을 하나 더 둬야 한다. */
.lb li.hasface { grid-template-columns: 20px auto minmax(0, 1fr) auto; gap: 5px; }
.lb li.hasface .rk { font-size: 12px; }

/* ── 폰 세로: 게이지 아래 흰 띠에 얼굴만 (왼쪽이 1위) */
.facestrip {
  display: none; grid-column: 1 / -1; align-items: center; gap: 9px;
  padding: 5px 8px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  background: #fff; border: 2.5px solid var(--ink); border-radius: 12px; box-shadow: 3px 3px 0 var(--ink);
}
.facestrip::-webkit-scrollbar { display: none; }
.facestrip .fs {
  position: relative; flex: none; display: flex; flex-direction: column; align-items: center; gap: 1px;
  transition: transform .42s cubic-bezier(.3, 1.3, .4, 1);
  background: none; border: 0; padding: 0; cursor: pointer;
}
.facestrip .fs b { font-size: 9.5px; font-weight: 900; color: var(--muted); line-height: 1; }
.facestrip .fs.me b { color: var(--red); }
.facestrip .fs em { font-size: 9px; font-weight: 800; color: var(--ink); line-height: 1; font-style: normal; }
.facestrip .fs-rk {
  position: absolute; top: -2px; left: -2px; z-index: 2;
  min-width: 14px; height: 14px; padding: 0 2px; border-radius: 7px;
  background: var(--ink); color: #fff; font-size: 9px; font-weight: 900;
  display: flex; align-items: center; justify-content: center; border: 1.5px solid #fff;
}
.facestrip .fs.r1 .fs-rk { background: var(--yel); color: var(--ink); }
.facestrip .fs.duel .facepic { animation: facehit .5s infinite; border-color: var(--red); }
.facestrip .more { flex: none; font-size: 10px; font-weight: 800; color: var(--muted); padding: 0 4px; }

/* ── 아이템 독 (우측 가운데에 동동) */
.itemdock {
  position: absolute; top: 50%; right: 286px; transform: translateY(-50%);
  z-index: 24; display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.itemdock .dk {
  pointer-events: auto; position: relative;
  width: 62px; height: 62px; border-radius: 50%;
  border: 3px solid var(--ink); background: #fff; box-shadow: 3px 3px 0 var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  cursor: pointer; padding: 0; line-height: 1;
  animation: dkfloat 2.6s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * .22s);
}
.itemdock .dk .dk-ico { font-size: 22px; }
.itemdock .dk small { font-size: 8.5px; font-weight: 900; max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.itemdock .dk.ready { background: var(--yel); }
.itemdock .dk.ready small { color: var(--ink); }
.itemdock .dk.ready::before {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 3px solid #e8b53a88; animation: dkring 1.5s ease-out infinite;
}
.itemdock .dk.practice { background: #eef4fb; border-style: dashed; }
.itemdock .dk:disabled { opacity: .5; cursor: default; animation: none; }
.itemdock .dk:disabled::before { display: none; }
.itemdock .dk:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.itemdock .dk-label {
  pointer-events: none; font-size: 10px; font-weight: 900; color: var(--muted);
  background: #ffffffcc; border-radius: 6px; padding: 1px 5px;
}
@keyframes dkfloat { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-6px) } }
@keyframes dkring { 0% { inset: -3px; opacity: .9 } 100% { inset: -13px; opacity: 0 } }
@media (prefers-reduced-motion: reduce) {
  .itemdock .dk { animation: none } .itemdock .dk.ready::before { animation: none; opacity: .5 }
}

/* ── 발동 무대 (문제 칸 안에만) */
.duel-stage {
  position: absolute; inset: 0; z-index: 12; pointer-events: none;
  border-radius: 11px; overflow: hidden; opacity: 0; transition: opacity .14s;
}
.duel-stage.on, .duel-stage.asking { opacity: 1; }
.duel-stage .duel-cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.duel-txt {
  position: absolute; left: 0; right: 0; top: 8%; display: flex; flex-direction: column;
  align-items: center; gap: 2px; text-align: center; padding: 0 10px;
}
.duel-txt .duel-name {
  font-size: clamp(26px, 5.2vw, 52px); font-weight: 900; letter-spacing: -1.5px; color: #fff;
  -webkit-text-stroke: 2.5px var(--ink); paint-order: stroke fill;
  text-shadow: 0 0 18px var(--duel-color, #e8193c), 4px 4px 0 var(--ink);
}
.duel-txt .duel-line {
  font-style: normal; font-size: clamp(13px, 2.1vw, 20px); font-weight: 900; color: #fff;
  -webkit-text-stroke: 1.6px var(--ink); paint-order: stroke fill; text-shadow: 2px 2px 0 var(--ink);
}
.duel-txt .duel-to {
  text-decoration: none; font-size: clamp(11px, 1.7vw, 15px); font-weight: 900;
  background: var(--duel-color, #e8193c); color: #fff; border: 2px solid var(--ink);
  border-radius: 999px; padding: 1px 9px; box-shadow: 2px 2px 0 var(--ink);
}
.duel-txt.go .duel-name { animation: duelslam .5s both; }
.duel-txt.go .duel-line { animation: duelrise .45s .22s both; }
.duel-txt.go .duel-to { animation: duelrise .4s .34s both; }
@keyframes duelslam {
  0% { transform: scale(2.4) rotate(-9deg); opacity: 0; filter: blur(6px) }
  55% { transform: scale(1) rotate(0); opacity: 1; filter: blur(0) }
  70% { transform: scale(1.07) }
  100% { transform: scale(1) }
}
@keyframes duelrise { 0% { transform: translateY(12px); opacity: 0 } 100% { transform: translateY(0); opacity: 1 } }
@media (prefers-reduced-motion: reduce) {
  .duel-txt.go .duel-name, .duel-txt.go .duel-line, .duel-txt.go .duel-to { animation: none }
}

/* ── 「막을까요?」 — 1위만 버튼, 나머지는 같은 장면을 본다 */
.duel-ask { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 8px; }
.duel-ask:empty { display: none; }
.duel-card {
  pointer-events: auto; max-width: 92%; text-align: center;
  background: #fff; border: 3.5px solid var(--ink); border-radius: 15px;
  box-shadow: 5px 5px 0 var(--ink); padding: 10px 16px;
  animation: duelpop .3s cubic-bezier(.3, 1.5, .5, 1) both;
}
.duel-card.watch { background: #fff8e5; }
.duel-card > b { display: block; font-size: clamp(17px, 2.6vw, 26px); font-weight: 900; letter-spacing: -.8px; }
.duel-card > small { display: block; font-size: clamp(11px, 1.6vw, 14px); font-weight: 800; color: var(--muted); margin-top: 2px; }
.duel-card .duel-left { font-style: normal; font-weight: 900; color: var(--red); font-variant-numeric: tabular-nums; }
.duel-card .duel-btns { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }
.duel-card .duel-btns .btn { font-size: 15px; padding: 7px 14px; }
.duel-card .duel-watch { font-size: 12px; font-weight: 900; color: var(--muted); margin-top: 6px; }
@keyframes duelpop { 0% { transform: scale(.6); opacity: 0 } 100% { transform: scale(1); opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .duel-card { animation: none } }

/* ── 내 모습 작게 (가게게임 HUD) */
.hud .myface { flex: none; display: flex; align-items: center; gap: 6px; }
.hud .myface .nm { font-size: 11px; font-weight: 900; color: var(--muted); max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 넓은 화면 배치 */
@media (min-width: 821px) {
  .facestrip { display: none !important; }
}

/* ── 폰 세로 */
@media (max-width: 820px) {
  .facestrip { display: flex; }
  /* 세로: 세로 자리는 student.js 의 placeDock() 가 «게임판 가운데» 로 준다(발문 가림 방지).
     게임판을 덮는 것은 피할 수 없어서 — 폭 전체가 정답 과녁이다 — 조금 작게·조금 투명하게 둔다.
     뒤의 과녁 글씨가 비쳐 보이고, 누를 때는 또렷해진다. */
  /* 폰 세로: 문제 칸 오른쪽 «위» 에 세운다(자리는 placeDock 이 잡는다).
     translateY(-50%) 를 풀어야 준 자리가 곧 맨 위가 된다(2026-09-21 교수 지시). */
  .itemdock { right: 4px; gap: 5px; transform: none; top: 0; }
  .itemdock .dk { width: 42px; height: 42px; border-width: 2.5px; opacity: .84 }
  .itemdock .dk .dk-ico { font-size: 17px }
  .itemdock .dk small { font-size: 7px; max-width: 38px }
  .itemdock .dk.ready { opacity: 1 }
  .itemdock .dk:not(.ready):not(.practice) { opacity: .5 }
  .itemdock .dk:active { opacity: 1 }
  .itemdock .dk .dk-ico { font-size: 18px; }
  .itemdock .dk small { font-size: 7.5px; max-width: 44px; }
  .hud .myface .nm { display: none; }
  .duel-card { padding: 8px 12px; border-width: 3px; }
}

/* 자기에게 쓰는 것의 «무엇이 달라지는가» 한 줄 (2026-09-21)
   교수 지적: "대환단 이게 대체 뭔지 모르겠다." → 이름·대사만으로는 모른다. 효과를 적어 준다. */
.duel-txt .duel-eff {
  display: block; margin-top: 5px; font-style: normal; font-weight: 900;
  font-size: clamp(13px, 3.2vw, 17px); color: #fff5cf; letter-spacing: -.01em;
  background: #1b1b2288; border: 2px solid #ffffff33; border-radius: 999px;
  padding: 3px 12px; text-shadow: 0 2px 0 #00000066;
}
/* 부처님 손바닥이 뜰 때는 글이 손바닥 «위» 로 가게 (손이 화면을 덮으므로) */
.duel-stage.palm .duel-txt { z-index: 3; }
.duel-stage.palm .duel-txt .duel-name { text-shadow: 0 3px 0 #1b1b22, 0 0 24px #e8b53a; }
@media (prefers-reduced-motion: reduce) { .duel-txt .duel-eff { transition: none } }
