/* 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;
}

/* ============================================
   공통 템플릿 스타일 — 게임 사이트 공용
   01-salary-calculator 디자인 시스템 그대로 복사
   + 테트리스 보드/다음블록/점수판 클래스 추가
   ============================================ */
: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;
  --game-maxw: 760px; /* 테트리스 게임 영역(보드 400 + 사이드패널)용 넓은 폭 */
}

/* 테트리스 게임 카드만 더 넓게 (보드 확대 수용) */
.game-card { max-width: var(--game-maxw); margin-left: auto; margin-right: auto; }

* { 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); }

.btn-ghost {
  width: 100%;
  padding: 12px;
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-top: 12px;
}
.btn-ghost:hover { border-color: var(--primary); }
.btn-ghost:active { transform: translateY(1px); }

/* 콘텐츠 영역 */
.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); }

/* ============================================
   테트리스 게임 전용 클래스
   ============================================ */
.game-toolbar { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 20px; }
.game-toolbar .field { flex: 1; margin-bottom: 0; }
.game-toolbar .btn-primary { width: auto; margin-top: 0; white-space: nowrap; padding: 12px 18px; }

.game-layout { display: flex; gap: 20px; justify-content: center; align-items: flex-start; }

/* 보드 — 확대 (캔버스 내부 해상도 400x800, 화면 표시도 크게) */
.board-wrap { position: relative; flex-shrink: 0; }
#board {
  display: block;
  background: #0b1120;
  border: 2px solid var(--border);
  border-radius: 8px;
  width: 400px;
  height: 800px;
  max-width: 100%;
  touch-action: manipulation;
}
.board-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(11, 17, 32, 0.86);
  border-radius: 8px;
  padding: 16px;
}
.board-overlay p { font-size: 1rem; font-weight: 700; color: var(--text); }
.board-overlay.hidden { display: none; }

/* 사이드 패널 */
.side-panel { flex: 1; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.next-box {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}
.panel-label { display: block; font-size: 0.8rem; color: var(--text-dim); margin-bottom: 8px; font-weight: 600; }
#next { display: block; margin: 0 auto; background: #0b1120; border-radius: 6px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-item {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}
.stat-item span { display: block; font-size: 0.75rem; color: var(--text-dim); }
.stat-item strong { display: block; font-size: 1.25rem; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* 모바일 터치 컨트롤 */
.touch-controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 20px;
}
.tc-btn {
  padding: 16px 0;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: background 0.1s;
}
.tc-btn:active { background: var(--primary); }
.tc-wide { grid-column: span 1; font-size: 0.95rem; }

/* 반응형 — 태블릿/좁은 데스크톱 */
@media (max-width: 820px) and (min-width: 641px) {
  .game-card { max-width: 100%; }
  .game-layout { flex-direction: column; align-items: center; }
  .side-panel { width: 100%; max-width: 340px; flex: none; }
  #board {
    width: auto; height: auto;
    max-width: min(400px, 92vw);
    max-height: 78vh;
    aspect-ratio: 1 / 2;
  }
}

/* 반응형 — 모바일: 보드 + 컨트롤 버튼이 스크롤 없이 한 화면에 다 들어오게 */
@media (max-width: 640px) {
  /* 위쪽 공간 최대한 압축 */
  .site-header { padding: 10px 0 6px; }
  .site-header h1 { font-size: 1.15rem; }
  .subtitle { display: none; }                 /* 부제 숨겨 공간 확보 */
  .ad-top { display: none; }                    /* 상단 광고는 모바일에서 숨김(보드 아래 하단 광고만) */
  .container { padding: 0 10px; }

  .game-card { max-width: 100%; padding: 10px; margin: 8px 0; }
  .game-toolbar { flex-direction: row; align-items: center; gap: 8px; margin-bottom: 8px; }
  .game-toolbar .field { margin-bottom: 0; }
  .game-toolbar .field label { display: none; }  /* 라벨 숨김(select만) */
  .game-toolbar .btn-primary { width: auto; margin-top: 0; padding: 10px 14px; font-size: 0.9rem; }

  /* 다음블록 + 점수를 보드 위에 가로 한 줄로 */
  .game-layout { flex-direction: column; align-items: center; gap: 6px; }
  .side-panel {
    order: -1;                                   /* 패널을 보드 위로 */
    width: 100%; max-width: 96vw; flex: none;
    flex-direction: row; flex-wrap: nowrap; gap: 6px; justify-content: center; align-items: stretch;
  }
  .next-box { padding: 4px 8px; display: flex; align-items: center; gap: 6px; }
  .next-box .panel-label { margin-bottom: 0; font-size: 0.66rem; white-space: nowrap; }
  #next { width: 44px; height: 44px; }
  .stat-grid { flex: 1; grid-template-columns: repeat(4, 1fr); gap: 4px; min-width: 0; }
  .stat-item { padding: 4px 2px; }
  .stat-item span { font-size: 0.6rem; }
  .stat-item strong { font-size: 0.85rem; margin-top: 1px; }

  /* 보드: 남은 세로 공간에 맞춰 — 헤더+툴바+패널+버튼 빼고 한 화면에 */
  #board {
    width: auto; height: auto;
    max-height: 50vh;
    max-width: 86vw;
    aspect-ratio: 1 / 2;
  }

  /* 터치 컨트롤: 작고 촘촘하게, 보드 바로 아래 */
  .touch-controls { gap: 5px; margin-top: 8px; }
  .tc-btn { padding: 9px 0; font-size: 1rem; }
  .tc-wide { font-size: 0.76rem; }
}

/* ===== 푸터 도구·게임 칩 (이모지 나열형) ===== */
.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; }
