/* Paperlogy 웹폰트 (jsDelivr CDN) */
@font-face {
  font-family: 'Paperlogy';
  src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/2408-3@1.0/Paperlogy-4Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Paperlogy';
  src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/2408-3@1.0/Paperlogy-7Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ============================================
   공통 템플릿 스타일 — 10개 사이트 공용
   색상 변수만 바꾸면 사이트별 테마 변경 가능
   ============================================ */
:root {
  --bg: #0f172a;
  --card: #1e293b;
  --card-2: #273449;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent: #22c55e;
  --border: #334155;
  --radius: 14px;
  --maxw: 720px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Paperlogy', -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* 헤더 */
.site-header { padding: 32px 0 24px; text-align: center; }
.site-header h1 { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.subtitle { color: var(--text-dim); margin-top: 8px; font-size: 0.95rem; }

/* 카드 */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin: 16px 0;
}
.card h2 { font-size: 1.2rem; margin-bottom: 16px; }
.card h3 { font-size: 1.05rem; margin: 20px 0 10px; }

/* 입력 필드 */
.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
label { display: block; font-size: 0.9rem; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
input[type="text"], input[type="number"], select {
  width: 100%;
  padding: 12px 14px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.15s;
}
input:focus, select:focus { outline: none; border-color: var(--primary); }
.hint { font-size: 0.78rem; color: var(--text-dim); margin-top: 5px; }

/* 버튼 */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 8px;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: translateY(1px); }

/* 결과 강조 */
.result-highlight {
  text-align: center;
  background: linear-gradient(135deg, rgba(34,197,94,0.12), rgba(99,102,241,0.12));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.result-label { display: block; color: var(--text-dim); font-size: 0.9rem; }
.result-value { display: block; font-size: 2.2rem; font-weight: 800; color: var(--accent); margin-top: 6px; }

/* 콘텐츠 영역 */
.content p { margin-bottom: 12px; color: var(--text); }
.content ul { margin: 10px 0 16px 20px; }
.content li { margin-bottom: 6px; }
.content details {
  background: var(--card-2); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px;
}
.content summary { cursor: pointer; font-weight: 600; }
.content details p { margin-top: 10px; color: var(--text-dim); }

/* 광고 슬롯 */
.ad-slot {
  position: relative;
  min-height: 100px;
  background: repeating-linear-gradient(45deg, #1a2438, #1a2438 10px, #1c2740 10px, #1c2740 20px);
  border: 1px dashed var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 16px auto;
}
.ad-top { margin-top: 8px; }
.ad-inline { max-width: var(--maxw); margin-left: auto; margin-right: auto; }
.ad-label { font-size: 0.72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }

/* 푸터 */
.site-footer { padding: 32px 0 40px; text-align: center; border-top: 1px solid var(--border); margin-top: 24px; }
.footer-tools { font-size: 0.88rem; color: var(--text-dim); margin-bottom: 12px; }
.footer-tools a:not(.tool-chip) { color: var(--primary); text-decoration: none; margin: 0 8px; }
.footer-tools a:not(.tool-chip):hover { text-decoration: underline; }
.copyright { font-size: 0.8rem; color: var(--text-dim); }

/* ============================================
   메모리 게임 전용 스타일
   ============================================ */

/* 상태 표시줄 */
.stat-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.stat-item {
  background: var(--card-2);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
}
.stat-label { display: block; font-size: 0.74rem; color: var(--text-dim); }
.stat-value { display: block; font-size: 1.05rem; margin-top: 4px; font-variant-numeric: tabular-nums; color: var(--accent); }

/* 카드 보드 — auto-fit으로 카드 개수에 따라 자동 배치 */
.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--card-size, 70px), 1fr));
  gap: 8px;
  margin-top: 18px;
}

/* 개별 카드 — 3D 뒤집기 컨테이너 */
.mcard {
  aspect-ratio: 3 / 4;
  perspective: 600px;
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 0;
}
.mcard:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 10px; }

.mcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.4s;
  transform-style: preserve-3d;
}
/* 뒤집힌(앞면 보임) 상태 */
.mcard.flipped .mcard-inner,
.mcard.matched .mcard-inner {
  transform: rotateY(180deg);
}

/* 앞/뒷면 공통 */
.mcard-front, .mcard-back {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border: 1px solid var(--border);
  user-select: none;
}
/* 뒷면(기본 표시) */
.mcard-back {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  font-size: 1.5rem;
  color: rgba(255,255,255,0.85);
}
/* 앞면(이모지) */
.mcard-front {
  background: var(--card-2);
  transform: rotateY(180deg);
  font-size: clamp(1.4rem, 7vw, 2.2rem);
}
/* 맞춘 카드 강조 */
.mcard.matched .mcard-front {
  background: linear-gradient(135deg, rgba(34,197,94,0.25), rgba(34,197,94,0.1));
  border-color: var(--accent);
  animation: pop 0.35s ease;
}
@keyframes pop {
  0% { transform: rotateY(180deg) scale(1); }
  50% { transform: rotateY(180deg) scale(1.08); }
  100% { transform: rotateY(180deg) scale(1); }
}
.mcard.matched { cursor: default; }

.win-detail { color: var(--text-dim); font-size: 0.9rem; text-align: center; margin-bottom: 8px; }

/* 반응형 */
@media (max-width: 480px) {
  .site-header h1 { font-size: 1.4rem; }
  .result-value { font-size: 1.8rem; }
  .stat-bar { grid-template-columns: repeat(2, 1fr); }
  .board { gap: 6px; --card-size: 56px; }
}

/* ===== 푸터 도구·게임 칩 (이모지 나열형) ===== */
.footer-tools-title { font-size: 0.95rem; font-weight: 700; color: var(--text); margin-bottom: 14px; }
.tool-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tool-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--card-2, #273449);
  border: 1px solid var(--border, #334155);
  border-radius: 999px;
  color: var(--text, #e2e8f0);
  font-size: 0.86rem; font-weight: 600;
  text-decoration: none;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.tool-chip:hover {
  transform: translateY(-2px);
  border-color: var(--primary, #6366f1);
  background: var(--card, #1e293b);
}
.tool-chip .chip-emoji { font-size: 1.05rem; line-height: 1; }
@media (max-width: 480px) {
  .tool-chip { padding: 7px 11px; font-size: 0.8rem; }
}

/* 푸터 칩 카테고리 분류 */
.chip-group { margin-bottom: 16px; }
.chip-cat {
  display: block; font-size: 0.82rem; font-weight: 700;
  color: var(--text-dim, #94a3b8); margin-bottom: 10px;
  letter-spacing: 0.02em;
}
.chip-group:last-child { margin-bottom: 0; }
