/* 집현전 한글 탐험 — 아케이드 (카드 뒤집기 / 맞춤법 두더지) */

/* ------------------------------------------------------------------ */
/* 공통: 상단 정보 알약                                                  */
/* ------------------------------------------------------------------ */
.arc-stats {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 10px;
}
.arc-pill {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 46px; padding: 4px 18px;
  background: var(--paper);
  border: 3px solid var(--ink); border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink);
  font-size: 18px; font-weight: 800; line-height: 1.2;
}
.arc-pill b {
  min-width: 1.4em; text-align: center;
  font-size: 24px; font-weight: 900; color: var(--blue);
  font-variant-numeric: tabular-nums;
}
.arc-pill .arc-of { color: var(--ink-2); font-weight: 700; }
.arc-pill-hit b { color: var(--green); }
.arc-ok-ic { color: var(--green); font-weight: 900; }

/* ------------------------------------------------------------------ */
/* 1. 카드 뒤집기                                                       */
/* ------------------------------------------------------------------ */
.arc-board {
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: min(100%, 580px, calc(100vh - 290px));
  width: min(100%, 580px, calc(100dvh - 290px));
  min-width: min(100%, 318px);
  margin: 14px auto 0;
}
.arc-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 72px;
  padding: 0; margin: 0;
  border: 0; border-radius: 16px;
  background: none;
  font: inherit; color: inherit;
  cursor: pointer;
  perspective: 900px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
}
.arc-card:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }
.arc-inner {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform .45s cubic-bezier(.4, .2, .2, 1);
}
.arc-card.flipped .arc-inner { transform: rotateY(180deg); }
.arc-face {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
  overflow: hidden;
}
/* 뒷면: 한지 + '한' 문양 */
.arc-back {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 62%),
    repeating-linear-gradient(45deg, rgba(168, 107, 51, .12) 0 5px, rgba(0, 0, 0, 0) 5px 11px),
    repeating-linear-gradient(-45deg, rgba(168, 107, 51, .08) 0 5px, rgba(0, 0, 0, 0) 5px 11px),
    linear-gradient(160deg, #f8dea8 0%, #e9b96a 100%);
  transition: filter .15s ease;
}
.arc-back::before {
  content: ""; position: absolute; inset: 6px;
  border: 2px dashed rgba(107, 74, 43, .35); border-radius: 11px;
}
.arc-back-mark {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 58%; aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: var(--paper);
  border: 3px solid var(--gold-2);
  box-shadow: inset 0 0 0 3px #fff1c4, 0 2px 0 rgba(59, 36, 18, .3);
  color: #b3261e;
  font-size: 28px; font-size: 7.5cqw;
  font-weight: 900; line-height: 1;
}
.arc-card:not(.flipped):not(:disabled):hover .arc-back { filter: brightness(1.06); }
.arc-card:not(.flipped):active .arc-back { filter: brightness(.95); }
/* 앞면 */
.arc-front {
  background: linear-gradient(180deg, #fffefa 0%, var(--paper) 100%);
  transform: rotateY(180deg);
}
.arc-pic { font-size: 44px; font-size: 12.5cqw; line-height: 1; }
.arc-word {
  font-size: 24px; font-size: 6.8cqw;
  font-weight: 900; line-height: 1.1; letter-spacing: -.02em;
  white-space: nowrap;
}
/* 짝이 아님 */
.arc-card.arc-nomatch .arc-front { border-color: var(--red); background: var(--red-soft); }
.arc-card.arc-nomatch .arc-front::after {
  content: "✕"; position: absolute; top: 4px; right: 8px;
  color: var(--red); font-weight: 900; font-size: 18px; line-height: 1;
}
/* 짝 찾음 */
.arc-card.arc-matched { cursor: default; }
.arc-card.arc-matched .arc-front {
  border-color: var(--pc, var(--green));
  background: var(--pcs, var(--green-soft));
  box-shadow: 0 4px 0 var(--pc, var(--green));
  animation: arc-glow .9s ease 2;
}
.arc-card.arc-matched .arc-front::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 45%;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .85), rgba(255, 255, 255, 0));
  transform: skewX(-15deg);
  animation: arc-shine .9s ease .15s 1 both;
  pointer-events: none;
}
.arc-badge {
  position: absolute; top: 5px; left: 5px;
  min-width: 24px; height: 24px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background: var(--pc, var(--green)); color: #fff;
  font-size: 15px; font-weight: 900; line-height: 1;
}
.arc-check {
  position: absolute; bottom: 4px; right: 7px;
  color: var(--pc, var(--green));
  font-size: 18px; font-weight: 900; line-height: 1;
}
@keyframes arc-glow {
  0%, 100% { box-shadow: 0 4px 0 var(--pc, var(--green)), 0 0 0 0 rgba(245, 184, 46, 0); }
  50% { box-shadow: 0 4px 0 var(--pc, var(--green)), 0 0 0 7px rgba(245, 184, 46, .55); }
}
@keyframes arc-shine { from { left: -60%; } to { left: 120%; } }

/* 움직임 줄이기: 3D 대신 페이드 */
.arc-rm .arc-inner { transition: none; transform: none !important; }
.arc-rm .arc-face { -webkit-backface-visibility: visible; backface-visibility: visible; transition: opacity .2s ease; }
.arc-rm .arc-front { transform: none; opacity: 0; }
.arc-rm .arc-card.flipped .arc-front { opacity: 1; }
.arc-rm .arc-card.flipped .arc-back { opacity: 0; }
.arc-rm .arc-card.arc-matched .arc-front { animation: none; }
.arc-rm .arc-card.arc-matched .arc-front::before { display: none; }

/* ------------------------------------------------------------------ */
/* 2. 맞춤법 두더지                                                     */
/* ------------------------------------------------------------------ */
.arc-molegame .arc-timer {
  width: min(100%, 640px);
  margin: 10px auto 0;
}
.arc-field {
  position: relative;
  container-type: inline-size;
  width: min(100%, 640px, calc((100vh - 310px) * 1.2));
  width: min(100%, 640px, calc((100dvh - 310px) * 1.2));
  min-width: min(100%, 300px);
  margin: 12px auto 0;
  padding: 12px;
  border: 3px solid var(--ink);
  border-radius: 24px;
  box-shadow: var(--shadow);
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, .25) 0 3px, rgba(0, 0, 0, 0) 4px),
    radial-gradient(circle at 78% 62%, rgba(255, 255, 255, .2) 0 3px, rgba(0, 0, 0, 0) 4px),
    radial-gradient(ellipse at 50% 0%, #a9dc7a 0%, rgba(169, 220, 122, 0) 70%),
    linear-gradient(180deg, #8fcb63 0%, #6fb04a 100%);
  background-size: 60px 60px, 80px 80px, 100% 100%, 100% 100%;
}
.arc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px 10px;
  transition: opacity .2s ease;
}
.arc-field.counting .arc-grid { opacity: .55; }

.arc-hole {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 5 / 4;
  padding: 0; margin: 0;
  border: 0; border-radius: 18px;
  background: none;
  font: inherit; color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
.arc-hole:disabled { cursor: default; }
.arc-hole:focus-visible { outline: 4px solid var(--blue); outline-offset: 2px; }
.arc-mound {
  position: absolute; left: 3%; right: 3%; bottom: 2%; height: 42%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 30%, #d49c63 0%, #b27640 55%, #8a5529 100%);
  box-shadow: 0 3px 0 rgba(59, 36, 18, .35);
}
.arc-pit {
  position: absolute; left: 15%; right: 15%; bottom: 12%; height: 24%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 35%, #140a03 0%, #2a170a 60%, #4a2c15 100%);
  box-shadow: inset 0 4px 6px rgba(0, 0, 0, .5);
}
.arc-clip {
  position: absolute; left: 0; right: 0; top: 0; bottom: 24%;
  overflow: hidden;
  pointer-events: none;
}
.arc-mole {
  position: absolute; left: 9%; right: 9%; top: 3%; bottom: 0;
  transform: translateY(108%);
  transition: transform .15s ease-out;
}
.arc-hole.up .arc-mole,
.arc-hole.hit .arc-mole,
.arc-hole.oops .arc-mole { transform: translateY(0); }
.arc-hole.down .arc-mole { transform: translateY(108%); transition: transform .2s ease-in; }

/* 두더지 머리 (CSS 그림) */
.arc-mole-head {
  position: absolute; left: 24%; right: 24%; top: 0; height: 52%;
  border-radius: 50% 50% 44% 44%;
  background:
    radial-gradient(circle at 34% 46%, #1b0f07 0 7%, rgba(0, 0, 0, 0) 8%),
    radial-gradient(circle at 66% 46%, #1b0f07 0 7%, rgba(0, 0, 0, 0) 8%),
    radial-gradient(circle at 36% 42%, #fff 0 2.5%, rgba(0, 0, 0, 0) 3%),
    radial-gradient(ellipse at 50% 70%, #f28b95 0 11%, rgba(0, 0, 0, 0) 12%),
    radial-gradient(ellipse at 50% 76%, #e9c6a4 0 26%, rgba(0, 0, 0, 0) 27%),
    #8a5a3b;
  border: 3px solid var(--ink);
}
.arc-sign {
  position: absolute; left: 0; right: 0; bottom: 0; height: 60%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #fffefa 0%, var(--paper) 100%);
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 3px 0 rgba(59, 36, 18, .35);
}
.arc-sign-word {
  font-size: 22px; font-size: clamp(15px, 5.2cqw, 30px);
  font-weight: 900; line-height: 1.1; letter-spacing: -.02em;
  white-space: nowrap;
}
.arc-tag:empty { display: none; }
.arc-tag {
  position: absolute; top: -14px; right: -6px;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; padding: 0 8px;
  border-radius: 999px;
  border: 2px solid #fff;
  font-size: 15px; font-weight: 900; line-height: 1; white-space: nowrap;
  color: #fff;
}
/* 틀린 말을 고침 */
.arc-hole.hit .arc-sign { background: var(--green-soft); border-color: var(--green); }
.arc-hole.hit .arc-sign-word { color: #1b5e28; }
.arc-hole.hit .arc-tag { background: var(--green); font-size: 17px; padding: 0; }
/* 바른 말을 두드림 */
.arc-hole.oops .arc-sign { background: var(--sky); border-color: var(--blue); }
.arc-hole.oops .arc-tag { background: var(--blue); }

.arc-plus {
  position: absolute; left: 50%; top: 4%;
  transform: translateX(-50%);
  color: #fff; font-size: 24px; font-weight: 900;
  -webkit-text-stroke: 1px #1b5e28;
  text-shadow: 0 2px 0 #1b5e28;
  pointer-events: none;
  animation: arc-plus .75s ease-out both;
}
@keyframes arc-plus {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(.8); }
  25% { opacity: 1; transform: translate(-50%, 0) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -26px) scale(1); }
}
.arc-num {
  display: none;
  position: absolute; left: 7%; bottom: 3%;
  font-size: 12px; font-weight: 800; line-height: 1;
  color: rgba(255, 250, 240, .8);
  pointer-events: none;
}
@media (hover: hover) and (pointer: fine) {
  .arc-num { display: block; }
}

/* 카운트다운 / 끝 */
.arc-count {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  z-index: 3;
}
.arc-count-num {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 28px;
  text-align: center;
  font-size: 88px; font-weight: 900; line-height: 1.25;
  color: var(--gold);
  -webkit-text-stroke: 3px var(--ink);
  text-shadow: 0 5px 0 var(--ink);
  background: rgba(255, 250, 240, .92);
  border: 3px solid var(--ink); border-radius: 28px;
  box-shadow: var(--shadow);
  animation: jh-pop-in .35s var(--ease-pop);
}
.arc-endcard {
  max-width: calc(100% - 16px);
  padding: 16px 28px;
  text-align: center;
  background: var(--paper);
  border: 3px solid var(--ink); border-radius: 24px;
  box-shadow: var(--shadow-lg);
  animation: jh-fade-in .28s ease both;
  pointer-events: auto;   /* .arc-count는 클릭을 통과시키지만 끝 카드의 버튼은 눌려야 한다 */
}
.arc-end-title { margin: 0; font-size: 34px; font-weight: 900; }
.arc-end-line { margin: 4px 0 0; font-size: 20px; font-weight: 800; }
.arc-end-line b { color: var(--blue); font-size: 24px; }
.arc-end-goal { margin: 8px 0 0; font-size: 18px; font-weight: 800; color: var(--ink); }
.arc-end-goal b { color: var(--red); font-size: 22px; }
.arc-end-ic { font-weight: 900; }
.arc-end-ic.ok { color: var(--green); }
.arc-end-ic.no { color: var(--red); }
.arc-end-btn { margin-top: 14px; min-height: 56px; padding: 0 24px; }

/* 움직임 줄이기: 솟아오르기 대신 나타나기 */
.arc-field.arc-rm .arc-mole,
.arc-field.arc-rm .arc-hole.down .arc-mole { transform: none; opacity: 0; transition: opacity .12s linear; }
.arc-field.arc-rm .arc-hole.up .arc-mole,
.arc-field.arc-rm .arc-hole.hit .arc-mole,
.arc-field.arc-rm .arc-hole.oops .arc-mole { opacity: 1; }
.arc-field.arc-rm .arc-count-num,
.arc-field.arc-rm .arc-endcard { animation: none; }

/* ------------------------------------------------------------------ */
/* 좁은 화면                                                            */
/* ------------------------------------------------------------------ */
@media (max-width: 600px) {
  .arc-pill { min-height: 42px; padding: 3px 14px; font-size: 16px; }
  .arc-pill b { font-size: 21px; }
  .arc-board { gap: 7px; }
  .arc-field { padding: 8px; border-radius: 18px; }
  .arc-grid { gap: 4px 6px; }
  .arc-hole { aspect-ratio: 1 / 1.05; }
  .arc-mole { top: 18%; }
  .arc-count-num { font-size: 64px; padding: 0 20px; }
  .arc-end-title { font-size: 28px; }
  .arc-endcard { padding: 12px 16px; }
  .arc-end-line { font-size: 17px; }
  .arc-end-line b { font-size: 21px; }
  .arc-end-goal { font-size: 16px; }
  .arc-end-goal b { font-size: 19px; }
  .arc-tag { height: 24px; min-width: 24px; font-size: 13px; padding: 0 6px; top: -12px; }
}
