/* 색칠 대결 화면. 밝은 흰·파스텔 + 파랑/빨강. 계정 키트(kit.css)와 같은 색을 씀 */
:root { --blue: #2f7dff; --red: #ff4d5e; --violet: #7c5cff; --ink: #2f3550; --muted: #6b7290; --line: #e6e8f5; --b: 56px; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Pretendard Variable", "Pretendard", -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; color: var(--ink); word-break: keep-all;
  background:
    radial-gradient(ellipse 60% 40% at 0% 0%, #dbe8ff 0%, transparent 70%),
    radial-gradient(ellipse 55% 40% at 100% 15%, #ffe0e4 0%, transparent 70%),
    radial-gradient(ellipse 70% 40% at 50% 100%, #ece6ff 0%, transparent 70%),
    #f8f9ff;
  background-attachment: fixed;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- 첫 화면 ---------- */
#home { max-width: 480px; margin: 0 auto; padding: max(10px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); min-height: 100%; display: flex; flex-direction: column; gap: 12px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; row-gap: 6px; }
#accountSlot { margin-left: auto; max-width: 100%; }
.logo { display: flex; align-items: center; gap: 6px; }
.logo h1 { margin: 0; font-size: 24px; white-space: nowrap; font-weight: 900; letter-spacing: -1px; background: linear-gradient(90deg, var(--blue), var(--violet) 55%, var(--red)); -webkit-background-clip: text; background-clip: text; color: transparent; }
@media (max-width: 420px) { .logo svg { width: 34px; height: 34px; } .logo h1 { font-size: 21px; } }
.hero { position: relative; display: flex; align-items: stretch; gap: 8px; height: min(30vh, 250px); min-height: 180px; border-radius: 26px; overflow: hidden; padding: 8px 8px 8px 16px;
  background: linear-gradient(160deg, rgba(255,255,255,.92), rgba(240,243,255,.85)); border: 1px solid var(--line); box-shadow: 0 14px 40px rgba(90, 100, 190, .14); }
.hero-text { flex: 0 1 46%; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.hero-title { margin: 0 0 10px; font-size: 21px; font-weight: 900; line-height: 1.25; letter-spacing: -0.5px; }
.hero-title b { font-size: 33px; background: linear-gradient(90deg, var(--blue), var(--red)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 12.5px; font-weight: 700; color: #4f5675; }
.hero canvas { flex: 1 1 54%; min-width: 0; height: 100%; display: block; }
@media (max-width: 380px) { .hero { padding-left: 12px; } .hero ul { font-size: 11.5px; } .hero-title { font-size: 18px; } .hero-title b { font-size: 28px; } }
.menu { display: grid; gap: 10px; }
.card { display: block; width: 100%; text-align: left; border-radius: 22px; padding: 14px; background: rgba(255,255,255,.95); border: 1.5px solid var(--line); box-shadow: 0 8px 24px rgba(90, 100, 190, .1); min-height: 64px; }
.tile { display: flex; align-items: center; gap: 12px; transition: transform .1s; }
.card .ico { width: 46px; height: 46px; flex: none; display: grid; place-items: center; font-size: 25px; border-radius: 15px; background: #e8f0ff; }
.card.duo .ico { background: #ffe6ea; }
.card b { display: block; font-size: 17px; font-weight: 900; }
.card small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; font-weight: 600; }
.tile:active, .btn:active { transform: scale(.97); }
.tile > div { flex: 1; min-width: 0; }
.tile .go { font-size: 28px; font-weight: 900; color: #c3c8ea; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn { border: 1.5px solid var(--line); background: #fff; border-radius: 16px; padding: 13px 10px; min-height: 48px; font-weight: 900; font-size: 15.5px; color: var(--violet); transition: transform .1s; }
.btn.gold { border: 0; color: #6b4400; background: linear-gradient(135deg, #ffe08a, #ffc24b); }
.soon { margin: 0; text-align: center; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.foot { text-align: center; margin: 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 12px; }
.link { border: 0; background: none; color: var(--muted); font-weight: 700; font-size: 13px; padding: 6px 16px; min-height: 44px; }
#helpBtn { min-height: 48px; }
.credit { font-size: 13px; font-weight: 700; color: #8a7bd8; }

/* 고르기 창 (컴퓨터 난이도 등) */
.pick { display: grid; gap: 8px; margin: 10px 0; }
.pick button { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 56px; border-radius: 16px; border: 1.5px solid var(--line); background: #fff; text-align: left; color: var(--ink); }
.pick button.on { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(124,92,255,.18); background: #faf8ff; }
.pick .lv { font-size: 24px; }
.pick b { display: block; font-size: 16px; }
.pick small { color: var(--muted); font-size: 12.5px; }
.pick .gold { margin-left: auto; color: #b57400; font-weight: 900; font-size: 13px; white-space: nowrap; }
.set-label { font-size: 13px; font-weight: 800; color: var(--muted); margin: 12px 0 6px; }
.howto { display: grid; gap: 10px; margin: 8px 0; padding: 0; list-style: none; }
.howto li { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: start; font-size: 14.5px; line-height: 1.55; }
.howto .n { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 12px; background: #eef1ff; font-size: 18px; }
.howto b { color: var(--violet); }
.result-big { text-align: center; font-size: 46px; margin: 0; }
.result-score { display: flex; justify-content: center; align-items: flex-start; gap: 14px; margin: 6px 0; }
.result-score > div { text-align: center; min-width: 96px; }
.result-score b { display: block; font-size: 46px; font-weight: 900; line-height: 1.05; }
.result-score .vs { font-size: 28px; font-weight: 900; color: #c3c8ea; margin-top: 8px; }
.result-score small { display: block; font-size: 13px; color: var(--muted); font-weight: 700; }
.result-score .b1 b { color: var(--blue); } .result-score .b2 b { color: var(--red); }
.result-gold { text-align: center; font-weight: 900; color: #b57400; font-size: 18px; margin: 4px 0; }
.result-note { text-align: center; font-size: 13px; color: var(--muted); margin: 2px 0; font-weight: 600; }

/* ---------- 게임 화면 ---------- */
#play { position: fixed; inset: 0; display: flex; flex-direction: column; touch-action: none; user-select: none; -webkit-user-select: none;
  padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
.hud { flex: none; display: grid; grid-template-columns: auto 1fr auto 1fr; align-items: center; gap: 6px; max-width: 760px; width: 100%; margin: 0 auto; }
.hud-btns { display: flex; gap: 6px; }
.pbtn { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line); background: rgba(255,255,255,.95); font-size: 16px; font-weight: 900; color: var(--muted); box-shadow: 0 4px 12px rgba(60,60,120,.12); padding: 0; }
.pbtn.off { opacity: .55; }
.score { display: flex; align-items: center; gap: 6px; min-width: 0; height: 44px; padding: 0 10px; border-radius: 14px; background: #fff; border: 1.5px solid var(--line); box-shadow: 0 4px 12px rgba(60,60,120,.08); }
.score i { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.score .nm { font-size: 12.5px; font-weight: 800; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.score b { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.s1 i { background: var(--blue); } .s1 b { color: var(--blue); margin-left: auto; }
.s2 { justify-content: flex-end; } .s2 i { background: var(--red); } .s2 b { color: var(--red); margin-right: auto; }
.s1.lead { box-shadow: 0 0 0 2.5px rgba(47,125,255,.45); } .s2.lead { box-shadow: 0 0 0 2.5px rgba(255,77,94,.45); }
.timer { grid-column: 3; grid-row: 1; min-width: 58px; height: 44px; display: grid; place-items: center; padding: 0 8px; border-radius: 14px; background: #2f3550; color: #fff; font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.hud .s2 { grid-column: 4; }
.hud .s1 { grid-column: 2; }
.hud { grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); }
.timer.hot { background: var(--red); animation: hot .5s ease-in-out infinite alternate; }
@keyframes hot { to { transform: scale(1.08); } }
@media (max-width: 420px) { .score .nm { display: none; } .score { padding: 0 8px; } .timer { min-width: 50px; font-size: 20px; } .score b { font-size: 20px; } }
@media (prefers-reduced-motion: reduce) { .timer.hot { animation: none; } }

.stage { flex: 1; min-height: 0; display: grid; gap: 10px; margin-top: 6px; align-items: center; justify-items: center; grid-template-columns: minmax(0, 1fr); grid-template-areas: "board"; }
#board { grid-area: board; width: 100%; height: 100%; min-height: 0; display: block; touch-action: none; }
.pad { display: none; grid-template-columns: repeat(3, var(--b)); grid-template-rows: repeat(3, var(--b)); gap: 2px; touch-action: none; }
.pad button { width: var(--b); height: var(--b); border-radius: 16px; border: 0; font-size: calc(var(--b) * .38); font-weight: 900; color: #fff; padding: 0; box-shadow: 0 4px 0 rgba(0,0,0,.14); touch-action: none; }
.pad button[data-d="3"] { grid-column: 2; grid-row: 1; } .pad button[data-d="2"] { grid-column: 1; grid-row: 2; }
.pad button[data-d="0"] { grid-column: 3; grid-row: 2; } .pad button[data-d="1"] { grid-column: 2; grid-row: 3; }
.pad.p1 button { background: linear-gradient(160deg, #5c9bff, var(--blue)); }
.pad.p2 button { background: linear-gradient(160deg, #ff7b88, var(--red)); }
.pad button.on { transform: translateY(2px) scale(.95); box-shadow: 0 1px 0 rgba(0,0,0,.14); filter: brightness(1.1); }

/* 손가락 기기: 방향 버튼 보이기 */
body.touch .stage.two .pad { display: grid; }
body.touch .stage.one .pad.p1 { display: grid; }
/* 가로 화면: [파랑 버튼] [판] [빨강 버튼] · 컴퓨터와: [판] [버튼] */
@media (orientation: landscape) {
  body.touch .stage.two { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "p1 board p2"; }
  body.touch .stage.one { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "board p1"; }
  .pad.p1 { grid-area: p1; } .pad.p2 { grid-area: p2; }
}
/* 세로 화면: 판 아래에 버튼 */
@media (orientation: portrait) {
  :root { --b: clamp(44px, calc((100vw - 52px) / 6), 64px); }
  body.touch .stage.two { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; grid-template-areas: "board board" "p1 p2"; align-content: space-evenly; }
  body.touch .stage.one { grid-template-rows: auto auto; grid-template-areas: "board" "p1"; align-content: space-evenly; }
  body.touch .stage #board { height: auto; aspect-ratio: 3 / 2; max-height: 62vh; }
  .pad.p1 { grid-area: p1; } .pad.p2 { grid-area: p2; }
  body.touch .stage.one .pad.p1 { --b: clamp(52px, 17vw, 72px); }
}
@media (orientation: landscape) and (max-height: 430px) { :root { --b: 50px; } .hud .score { height: 40px; } .pbtn { width: 44px; height: 44px; } }
