/* 최애도쿠 — 디자인 기준: 폭 360px (원본 1080px의 1/3)
 * 버튼 색 #F78EAF · 검정 글씨 #151515 · 버튼형 버튼은 KIMM, 나머지는 에이투지체
 * 에이투지 Regular: 글자 간격 -2%, 줄 높이 140% */
@font-face { font-family: 'A2Z'; src: url('/dokugame/font/a2z-r.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'A2Z'; src: url('/dokugame/font/a2z-b.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'KIMM'; src: url('/dokugame/font/kimm-b.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --pink: #F78EAF;
  --ink: #151515;
  --bg: #F6E0EB;
  --soft: rgba(255, 255, 255, .62);
  --pop: #F5E1EC;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'A2Z', -apple-system, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  font-weight: 400; letter-spacing: -0.02em; line-height: 1.4; color: var(--ink);
  background: var(--bg) url('/dokugame/img/bg.webp') center top / 100% auto repeat-y;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; letter-spacing: inherit; cursor: pointer; }
img { display: block; }
[hidden] { display: none !important; }

.app { max-width: 430px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; }
.screen { display: none; min-height: 100vh; min-height: 100dvh; padding: calc(env(safe-area-inset-top) + 36px) 16px calc(env(safe-area-inset-bottom) + 40px); }
.screen.on { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; } }

/* ---------- 공통 ---------- */
.back { width: 32px; height: 32px; margin: 0 0 22px -4px; border: 0; padding: 4px; background: url('/dokugame/img/back.svg') center / 24px 24px no-repeat; display: block; }
.label { display: block; font-weight: 700; font-size: 14px; margin: 0 0 10px; }
.label.mt { margin-top: 28px; margin-bottom: 4px; }
.desc { font-size: 12px; margin: 0 0 16px; }
.center { text-align: center; }
.input {
  width: 100%; height: 44px; padding: 0 16px; border: 1px solid var(--pink); border-radius: 10px; background: #fff;
  font: inherit; font-size: 15px; color: var(--ink); outline: none; -webkit-appearance: none; appearance: none;
}
.input::placeholder { color: #C9C9C9; }
.input::-webkit-search-cancel-button { display: none; }
.btns { display: flex; flex-direction: column; gap: 10px; }
.btn {
  display: block; width: 100%; height: 50px; border: 0; border-radius: 25px; background: var(--pink); color: #fff;
  font-family: 'KIMM', 'A2Z', sans-serif; font-weight: 700; font-size: 17px; letter-spacing: 0;
}
.btn.white { background: #fff; color: var(--pink); }
.btn:active { transform: translateY(1px); filter: brightness(.97); }
.btn:disabled { opacity: .5; transform: none; filter: none; }
.h1 { font-weight: 700; font-size: 21px; color: var(--pink); text-align: center; margin: 0 0 24px; }

/* ---------- 첫 화면 ---------- */
/* 로고+버튼을 한 덩어리로, 아래 쿠팡 배너를 뺀 나머지 화면 가운데에 둬요 (화면이 짧아도 겹치지 않게) */
#s-intro { display: none; flex-direction: column; align-items: center; justify-content: center; padding-top: calc(env(safe-area-inset-top) + 20px); padding-bottom: 24px; }
#s-intro.on { display: flex; }
.logo { width: 276px; max-width: 78%; height: auto; margin: 0 auto; }
.intro-btns { width: 100%; margin-top: clamp(40px, 13vh, 140px); }

/* ---------- 검색 ---------- */
.sec { font-size: 14px; font-weight: 700; margin: 36px 0 12px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 14px; }
.tile { border: 0; padding: 0; background: none; min-width: 0; text-align: center; }
.tile .ph { display: block; width: 100%; aspect-ratio: 1; border-radius: 50%; border: 2px solid var(--pink); background: #fff; overflow: hidden; }
.tile .ph img { width: 100%; height: 100%; object-fit: cover; }
.tile .nm { display: block; margin-top: 6px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tiles .none { grid-column: 1 / -1; font-size: 13px; color: #9a8890; margin: 0; }

/* ---------- 게임 만들기 ---------- */
.slots { display: grid; grid-template-columns: repeat(4, 65px); gap: 14px 15px; margin: 0 0 26px; }
.slot { position: relative; width: 65px; height: 65px; }
.slot .pick {
  width: 100%; height: 100%; border-radius: 50%; border: 0; padding: 0; background: rgba(255, 255, 255, .62);
  color: rgba(247, 142, 175, .55); font-size: 22px; font-weight: 700; line-height: 1; overflow: hidden;
}
.slot.next .pick { background: #fff; color: var(--pink); box-shadow: inset 0 0 0 2px var(--pink); }
.slot.filled .pick { background: #fff; }
.slot.filled.rep .pick { box-shadow: 0 0 0 2px var(--pink); }
.slot .pick img { width: 100%; height: 100%; object-fit: cover; }
.slot .x {
  position: absolute; right: -4px; top: -4px; width: 22px; height: 22px; border-radius: 50%; border: 0; padding: 0;
  background: var(--ink); color: #fff; font-size: 13px; line-height: 22px;
}
.slot .tag { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); background: var(--pink); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 8px; white-space: nowrap; }
#f-done { margin-bottom: 14px; }

/* ---------- 최애 페이지 ---------- */
.g-photo { width: clamp(140px, calc(100vh - var(--ad-h, 0px) - 380px), 225px); width: clamp(140px, calc(100dvh - var(--ad-h, 0px) - 380px), 225px); aspect-ratio: 1; margin: 0 auto; border-radius: 50%; border: 2px solid var(--pink); background: #fff; overflow: hidden; }
.g-photo img { width: 100%; height: 100%; object-fit: cover; }
.g-name { text-align: center; font-size: 20px; margin: 16px 0 24px; word-break: keep-all; }
.del-link { display: block; margin: 18px auto 0; border: 0; background: none; color: #a38f98; font-size: 12px; text-decoration: underline; }

/* ---------- 플레이 ---------- */
#s-play { padding-left: 4px; padding-right: 4px; }
.p-top { position: relative; height: 32px; margin: 0 12px 22px; }
.p-top .back { position: absolute; left: 0; top: 0; margin: 0 0 0 -4px; }
.p-time { margin: 0; text-align: center; font-weight: 700; font-size: 21px; color: var(--pink); line-height: 32px; font-variant-numeric: tabular-nums; }
.rules { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 0 5px 16px; }
.rule { display: flex; align-items: center; gap: 4px; height: 36px; padding: 0 6px 0 7px; background: rgba(255, 255, 255, .78); border-radius: 8px; }
.rule img { width: 29px; height: 29px; flex: none; }
.rule span { flex: 1; text-align: center; font-size: 10.5px; line-height: 1.3; letter-spacing: -0.04em; white-space: nowrap; }
.pills { display: flex; justify-content: center; gap: 11px; margin-bottom: 16px; }
.pill { width: 118px; height: 35px; border-radius: 18px; background: rgba(255, 255, 255, .62); display: flex; align-items: center; padding: 0 16px; }
.p-face { width: 27px; height: 27px; border-radius: 50%; object-fit: cover; background: #D9D9D9; flex: none; }
.p-count { flex: 1; text-align: right; font-weight: 700; font-size: 15px; }
.p-count b { color: var(--pink); }
.hearts { justify-content: center; gap: 9px; padding: 0; }
.hearts img { width: 25px; height: auto; image-rendering: pixelated; }
.hearts img.lost { animation: lose .45s ease; }
@keyframes lose { 30% { transform: scale(1.35); } }

.board-wrap { position: relative; }
.board {
  --n: 6; --gap: 4px;
  display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: var(--gap); padding: 6px;
  background: #fff; border-radius: 8px; aspect-ratio: 1 / 1; margin: 0 auto;
  /* 아래 쿠팡 배너에 가리지 않게: 화면 높이에서 위쪽(시간·규칙·개수)과 RESTART 자리를 뺀 만큼까지만 커져요 */
  width: max(240px, min(100%, calc(100vh - var(--ad-h, 0px) - 252px)));
  width: max(240px, min(100%, calc(100dvh - var(--ad-h, 0px) - 252px)));
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.cell { position: relative; border: 0; padding: 0; min-width: 0; min-height: 0; border-radius: var(--r, 6px); display: flex; align-items: center; justify-content: center; }
.cell:active { filter: brightness(.95); }
.cell .mk { width: 64%; height: 64%; background: url('/dokugame/img/x.png') center / contain no-repeat; pointer-events: none; animation: pop .16s ease; }
.cell.bad .mk { background-image: url('/dokugame/img/x_dark.png'); }
.cell .face { width: 90%; height: 90%; border-radius: 50%; object-fit: cover; background: #fff; pointer-events: none; animation: pop .2s ease, bob 2.6s ease-in-out .2s infinite; }
.cell.fixed .face { box-shadow: 0 0 0 2px rgba(255, 255, 255, .9); }
@keyframes pop { from { transform: scale(.4); opacity: .3; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-1px); } }
.cell.shake { animation: shake .3s ease; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.note {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 3; pointer-events: none;
  background: rgba(21, 21, 21, .82); color: #fff; font-size: 12px; padding: 6px 14px; border-radius: 14px; white-space: nowrap; animation: fade .2s ease;
}
.note.tip { background: var(--pink); font-weight: 700; font-size: 17px; padding: 14px 24px; border-radius: 26px; box-shadow: 0 4px 12px rgba(247, 142, 175, .35); }
/* 처음 한 번: 규칙 카드 3개를 차례로 반짝 */
.rules.hl .rule { animation: rulehl 1s ease 3 both; }
.rules.hl .rule:nth-child(2) { animation-delay: .25s; }
.rules.hl .rule:nth-child(3) { animation-delay: .5s; }
@keyframes rulehl { 0%, 100% { box-shadow: 0 0 0 0 rgba(247, 142, 175, 0); transform: scale(1); } 45% { box-shadow: 0 0 0 2px var(--pink); transform: scale(1.05); } }
.board.win .face { animation: pop .2s ease, cheer .6s ease; }
@keyframes cheer { 50% { transform: scale(1.15) translateY(-3px); } }
.link { display: block; margin: 16px auto 0; border: 0; background: none; padding: 4px 8px; color: var(--pink); font-family: 'KIMM', sans-serif; font-weight: 700; font-size: 15px; text-decoration: underline; text-underline-offset: 3px; letter-spacing: 0; }
.gov .link { margin-top: 18px; }
.restart { display: block; margin: 22px auto 0; border: 0; background: none; color: var(--pink); font-family: 'KIMM', sans-serif; font-weight: 700; font-size: 15px; text-decoration: underline; text-underline-offset: 3px; letter-spacing: 0; }

/* ---------- 성공 ---------- */
#s-win .h1 { margin-top: 10px; }
.w-photo { width: 129px; height: 129px; margin: 0 auto 24px; border-radius: 50%; background: #fff; overflow: hidden; }
.w-photo img { width: 100%; height: 100%; object-fit: cover; }
.record { width: 288px; max-width: 100%; margin: 0 auto 22px; padding: 22px 0 14px; background: rgba(255, 255, 255, .62); border-radius: 8px; text-align: center; }
.r-time { margin: 0; font-weight: 700; font-size: 40px; line-height: 1.1; color: var(--pink); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.r-label { margin: 6px 0 0; font-weight: 700; font-size: 12px; color: rgba(247, 142, 175, .65); letter-spacing: 0; }

/* ---------- 랭킹 ---------- */
#s-rank .h1 { margin-top: 6px; margin-bottom: 14px; }
.ranks { list-style: none; margin: 0 9px 18px; padding: 0; }
.ranks li { display: flex; align-items: center; height: 58px; padding: 0 14px 0 13px; margin-bottom: 8px; background: rgba(255, 255, 255, .72); border-radius: 8px; }
.ranks li.me { border: 2px solid var(--pink); padding-left: 11px; padding-right: 12px; }
.ranks .no { flex: none; width: 20px; height: 20px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; letter-spacing: 0; }
.ranks .no.r1 { background: #FFD94A; } .ranks .no.r2 { background: #3E8FF2; } .ranks .no.r3 { background: #E07B3F; }
.ranks .no.other { width: 30px; height: auto; background: none; color: var(--ink); font-size: 9px; line-height: 1.2; }
.ranks .ph { flex: none; width: 47px; height: 47px; margin-left: 10px; border-radius: 50%; background: #D9D9D9; object-fit: cover; }
.ranks .nm { flex: 1; min-width: 0; text-align: center; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.ranks .tm { flex: none; font-size: 15px; font-variant-numeric: tabular-nums; }
.ranks .dots { height: 34px; margin: -2px 0 6px; background: radial-gradient(circle, #fff 2.5px, transparent 3px) center top / 6px 11px repeat-y; width: 6px; margin-left: auto; margin-right: auto; padding: 0; border-radius: 0; }

/* ---------- 팝업 ---------- */
.dim { position: fixed; inset: 0; z-index: 40; background: rgba(21, 21, 21, .35); display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .18s ease; }
.pop { width: 100%; max-width: 330px; background: var(--pop); border-radius: 16px; padding: 28px 16px; text-align: center; }
.pop h2 { margin: 0; font-weight: 700; font-size: 18px; }
.pop p { margin: 4px 0 20px; font-size: 12px; white-space: pre-line; }
.pop .input { margin-bottom: 12px; }
.pop .sq { display: block; width: 100%; height: 50px; border: 0; border-radius: 25px; background: var(--pink); color: #fff; font-family: 'KIMM', sans-serif; font-weight: 700; font-size: 16px; letter-spacing: 0; }
.pop .sq.white { background: #fff; color: var(--ink); margin-top: 8px; }
.pop .sq:disabled { opacity: .6; }
.spin { width: 34px; height: 34px; margin: 0 auto 14px; border: 3px solid rgba(247, 142, 175, .3); border-top-color: var(--pink); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 게임 오버 ---------- */
.gov { position: fixed; inset: 0; z-index: 30; background: rgba(21, 21, 21, .86); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 16px 8vh; animation: fade .4s ease; }
.gov-t { margin: 0; color: #fff; font-weight: 700; font-size: 22px; }
.gov-ph { width: 150px; height: 150px; margin: 30px 0 40px; border-radius: 50%; overflow: hidden; background: #fff; opacity: 0; animation: govph .6s ease .7s forwards; }
.gov-ph img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(.35); }
@keyframes govph { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
.gov .btn { max-width: 398px; }
.fx { position: fixed; inset: 0; z-index: 35; width: 100%; height: 100%; pointer-events: none; }

/* ---------- 사진 자르기 ---------- */
.crop { position: fixed; inset: 0; z-index: 50; background: var(--bg) url('/dokugame/img/bg.webp') center top / 100% auto repeat-y; overflow-y: auto; }
.crop-in { max-width: 430px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 40px) 16px 30px; }
.crop .h1 { margin-bottom: 6px; }
.c-stage { position: relative; width: 100%; max-width: 328px; aspect-ratio: 1; margin: 18px auto 14px; border-radius: 12px; overflow: hidden; background: #fff; touch-action: none; }
.c-stage canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.c-ring { position: absolute; inset: 0; pointer-events: none; border-radius: 12px; background: radial-gradient(circle closest-side, transparent 98%, rgba(255, 255, 255, .55) 100%); box-shadow: inset 0 0 0 0 transparent; }
.c-ring::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--pink); }
.c-tools { display: flex; align-items: center; gap: 12px; max-width: 328px; margin: 0 auto 26px; }
.c-tool { flex: none; height: 32px; padding: 0 12px; border: 1px solid var(--pink); border-radius: 16px; background: #fff; color: var(--pink); font-size: 12px; font-weight: 700; }
.c-zoom { flex: 1; accent-color: var(--pink); }

/* ---------- 알림 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 110px); transform: translateX(-50%); z-index: 60;
  max-width: 86%; background: rgba(21, 21, 21, .85); color: #fff; font-size: 13px; padding: 10px 18px; border-radius: 20px; text-align: center; animation: fade .2s ease;
}
