/* 2314 MOON_TETRIS — 레이아웃·컴포넌트
 * 극단 미니멀 모노크롬 프레임(순백/순흑·헤어라인·여백·평면). 블록만 선명 7색(캔버스).
 * Inter + JetBrains Mono. 라이트 기본 + 다크 토글.
 */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background-color: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; }
.mono, .timer, .big-time, .hud-item b, .cover-big { font-family: 'JetBrains Mono', ui-monospace, monospace; }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 18px; }
.sr-title, .sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 헤더 ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky; top: 0; z-index: 30;
}
.header-in { display: flex; align-items: center; gap: 16px; height: 58px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.brand .mark {
  display: grid; grid-template-columns: repeat(2, 7px); grid-template-rows: repeat(2, 7px);
  gap: 2px; padding: 4px; border: 1px solid var(--line-strong); border-radius: 5px;
}
.brand .mark i { display: block; width: 7px; height: 7px; background: var(--line-strong); }
.brand .mark i.c1 { background: #9C55D4; }
.brand .mark i.c2 { background: #22B8CF; }
.brand .mark i.c3 { background: #E8833A; }
.header-nav { display: flex; gap: 4px; margin-left: 10px; flex: 1; }
.header-nav a { padding: 7px 11px; font-size: 14px; color: var(--ink-2); border-radius: 6px; font-weight: 600; }
.header-nav a:hover { color: var(--ink); background: var(--surface-2); }
.header-tools { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 7px; cursor: pointer; font-size: 15px;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.lang-select {
  height: 36px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 7px; padding: 0 8px; font-size: 13px; font-family: inherit; cursor: pointer; max-width: 130px;
}

/* ---------- 게임 메인 ---------- */
.play-main { padding: 14px 0 26px; }
.play-top {
  display: flex; align-items: center; justify-content: center; gap: 12px; margin: 0 auto 12px; max-width: 560px;
}
.hud-mode {
  font-size: 12px; font-weight: 700; color: var(--ink-2); padding: 4px 11px;
  border: 1px solid var(--line); border-radius: 999px; text-transform: uppercase; letter-spacing: 0.05em;
}
.timer, .stat-main {
  font-size: 19px; font-weight: 600; color: var(--ink); min-width: 96px; text-align: center;
  font-variant-numeric: tabular-nums;
}

.play-grid { display: flex; gap: 14px; justify-content: center; align-items: flex-start; }
.side { display: flex; flex-direction: column; gap: 12px; width: 100px; flex: none; }
.side-left { order: 1; }
.board-wrap { order: 2; position: relative; flex: none; }
.side-right { order: 3; }

/* 보드 캔버스 */
#board { display: block; background: var(--board-bg); border: 1px solid var(--board-edge); border-radius: 3px; touch-action: none; }
.board-cover {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: color-mix(in srgb, var(--board-bg) 82%, transparent); cursor: pointer; z-index: 5; border-radius: 3px;
}
.cover-big { font-size: clamp(22px, 6vw, 34px); font-weight: 800; letter-spacing: 0.02em; color: var(--ink); }
.cover-sub { font-size: 12px; color: var(--ink-3); }

/* HOLD / NEXT 미니 */
.mini { display: flex; flex-direction: column; gap: 5px; }
.mini-label { font-size: 10px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; }
.mini canvas { display: block; background: var(--grid-panel); border: 1px solid var(--line); border-radius: 4px; }

/* HUD */
.hud { display: flex; flex-direction: column; gap: 8px; }
.hud-item { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.hud-item span { font-size: 10px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.07em; }
.hud-item b { font-size: 18px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

/* 일시정지 버튼 */
#pauseBtn { font-size: 13px; }

/* ---------- 터치 컨트롤 ---------- */
.touch { display: none; }
.touch-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 52px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: 10px; cursor: pointer; font-size: 20px; font-family: inherit; -webkit-user-select: none; user-select: none;
  touch-action: none;
}
.touch-btn:active { background: var(--surface-2); }
.touch-btn.wide { font-size: 15px; font-weight: 700; letter-spacing: 0.04em; }

/* ---------- 광고 (애드핏 규정: 래퍼 border-radius/overflow 금지) ---------- */
.ad-wrap { margin: 26px auto 4px; display: flex; justify-content: center; }
.ad-grid { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; max-width: 672px; margin: 0 auto; }
.ad-grid[data-ad-layout="mixed"] { max-width: 760px; }
.ad-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; width: 100%; }
.ad-cell { min-height: 50px; }

/* ---------- FAB · 패널 ---------- */
.fab-stack { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 40; }
.fab {
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 15px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: 999px; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600;
}
.fab svg { width: 18px; height: 18px; }
.fab:hover { border-color: var(--accent-line); }

.side-panel {
  position: fixed; right: 18px; bottom: 84px; width: 300px; max-width: calc(100vw - 36px);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; z-index: 45; overflow: hidden;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 15px; }
.panel-close { border: 0; background: none; color: var(--ink-3); font-size: 16px; cursor: pointer; }
.panel-body { padding: 15px; }
.set-block { margin-bottom: 16px; }
.set-label { font-size: 11px; color: var(--ink-3); font-weight: 700; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.05em; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg .tab {
  padding: 9px 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 12px; font-weight: 600; text-align: center;
}
.seg .tab.active { color: var(--ink); border-color: var(--accent-line); background: var(--accent-soft); }
.set-label.sub { margin-top: 12px; }
.seg-algo .tab { font-size: 11px; padding: 8px 2px; letter-spacing: -0.02em; }

/* 자동 플레이 바 (테트리스 판 하단) */
.auto-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; column-gap: 14px; row-gap: 10px; max-width: 560px; margin: 16px auto 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.auto-label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.abtns { display: flex; flex-wrap: wrap; gap: 10px; }
.abtn-grp { display: inline-flex; gap: 5px; }
.abtn { padding: 7px 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 12px; font-weight: 600; white-space: nowrap; }
.abtn:hover { border-color: var(--line-strong); }
.abtn.active { color: var(--ink); border-color: var(--accent-line); background: var(--accent-soft); }
.set-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }
.set-row .lab { font-size: 14px; font-weight: 600; }
.switch { position: relative; width: 42px; height: 24px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface-2); cursor: pointer; flex: none; }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink-3); transition: .18s; }
.switch.on { background: var(--accent-soft); border-color: var(--accent-line); }
.switch.on .knob { left: 20px; background: var(--accent); }
.keyhelp { margin-top: 8px; font-size: 12px; color: var(--ink-2); line-height: 1.9; }
.keyhelp kbd { font-family: 'JetBrains Mono', monospace; font-size: 11px; padding: 1px 6px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface-2); color: var(--ink); }
.row-btns { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 14px; }
.ghost-btn { padding: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600; }
.ghost-btn:hover { border-color: var(--line-strong); }
.panel-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.28); z-index: 42; }

/* ---------- 오버레이 ---------- */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,0.42); z-index: 60; padding: 20px; }
.overlay-card { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; padding: 26px; width: 340px; max-width: 100%; text-align: center; }
.overlay-card h2 { margin: 0 0 4px; font-size: 22px; }
.big-time { font-size: 38px; font-weight: 700; color: var(--ink); margin: 8px 0 2px; font-variant-numeric: tabular-nums; }
.ov-sub { font-size: 11px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; }
.ov-meta { color: var(--ink-2); font-size: 13px; margin: 12px 0 16px; }
.btn-primary { display: inline-block; padding: 12px 20px; border: 0; border-radius: 10px; background: var(--accent); color: var(--bg); font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer; }
.ov-actions { display: flex; gap: 10px; justify-content: center; }
.ov-actions .ghost-btn, .ov-actions .btn-primary { flex: 1; }

/* ---------- 문서 페이지 ---------- */
main.doc-main { padding: 26px 0 40px; }
.doc { max-width: 760px; margin: 0 auto; }
.doc h1 { font-size: 30px; margin: 4px 0 10px; }
.doc h2 { font-size: 20px; margin: 30px 0 12px; padding-top: 8px; border-top: 1px solid var(--line); }
.doc p { margin: 0 0 14px; color: var(--ink); }
.doc ul, .doc ol { margin: 0 0 16px; padding-left: 20px; }
.doc li { margin: 6px 0; }
.lead { font-size: 17px; color: var(--ink-2); }
.muted { color: var(--ink-3); font-size: 13px; }
.breadcrumb { font-size: 13px; color: var(--ink-3); margin-bottom: 10px; }
.breadcrumb a { color: var(--ink-2); }
.breadcrumb a:hover { color: var(--ink); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 6px 0 18px; }
.card { display: block; padding: 15px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.card:hover { border-color: var(--accent-line); }
.card .tag { display: inline-block; font-size: 11px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.card h3 { margin: 0 0 5px; font-size: 16px; }
.card p { margin: 0; font-size: 13px; color: var(--ink-2); }
/* 조각 미니 아이콘(테트로미노 사전 카드) */
.pmini { display: inline-grid; gap: 2px; margin-bottom: 8px; }
.pmini i { width: 12px; height: 12px; border-radius: 2px; }
.faq details { border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px; margin-bottom: 8px; background: var(--surface); }
.faq summary { padding: 11px 0; font-weight: 600; cursor: pointer; }
.faq .a { padding: 0 0 12px; color: var(--ink-2); }
.pager { display: flex; justify-content: space-between; gap: 12px; margin: 22px 0; font-size: 14px; }
.pager a { color: var(--ink); font-weight: 600; }
.start-link { display: inline-block; margin-top: 6px; padding: 10px 18px; border-radius: 9px; background: var(--accent); color: var(--bg); font-weight: 700; }

/* ---------- 푸터 ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 20px; }
.site-footer.mini { position: static; }
.footer-in { padding: 26px 0 20px; }
.footer-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; max-width: 620px; }
.footer-cols h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); }
.footer-cols a { display: block; padding: 3px 0; font-size: 14px; color: var(--ink-2); }
.footer-cols a:hover { color: var(--ink); }
.copyright { margin-top: 18px; padding: 14px 0 0; font-size: 12px; color: var(--ink-3); }
.site-footer.mini .copyright { margin: 0; padding: 14px 0; text-align: center; }

/* ---------- 반응형 ---------- */
@media (max-width: 720px) {
  .header-nav { display: none; }
  .footer-cols { grid-template-columns: 1fr 1fr; }
  .side { width: 56px; gap: 6px; }
  .play-grid { gap: 8px; }
  .hud-item { padding: 6px 5px; }
  .hud-item b { font-size: 14px; }
  .hud-item span { font-size: 9px; }
  .mini-label { font-size: 9px; }
  .abtns { flex-basis: 100%; justify-content: center; }
  .touch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 380px; margin: 14px auto 0; }
  .touch .wide { grid-column: 1 / -1; }
  .doc h1 { font-size: 25px; }
}
@media (pointer: coarse) and (min-width: 721px) {
  .touch { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; max-width: 520px; margin: 14px auto 0; }
}
@media (max-width: 420px) {
  .footer-cols { grid-template-columns: 1fr; }
  .side { gap: 6px; }
}
