/* GGGom Color — 어르신·아이용: 큰 글씨, 큰 버튼(최소 56px), 부드러운 색 */
:root {
  --bg: #FFF6E9; --card: #fff; --ink: #2E2A3A; --soft: #7A7186; --accent: #FF7A59; --accent2: #6C63FF; --line: #EADFCF;
  --sat: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px));
  --sab: max(env(safe-area-inset-bottom, 0px), var(--safe-area-inset-bottom, 0px));
  --ui: 'CN Jua', 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--ui); font-size: 20px; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
button { font-family: inherit; font-size: 1rem; color: inherit; cursor: pointer; border: 0; }
[hidden] { display: none !important; }
.screen { min-height: 100%; height: 100%; padding: calc(var(--sat) + 10px) 14px calc(var(--sab) + 12px); display: flex; flex-direction: column; gap: 12px; max-width: 980px; margin: 0 auto; }
#home, #pick { overflow-y: auto; height: auto; }

/* 처음 화면 */
.hero { text-align: center; padding: 10px 0 2px; }
.hero h1 { margin: 0; font-size: 2.3rem; letter-spacing: .5px; background: linear-gradient(90deg, #FF6B8B, #FF9F43, #F7C531, #4CB963, #4CC9F0, #8B6CF0); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin: 4px 0 0; color: var(--soft); font-size: 1.1rem; }
.cats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.cat { background: var(--card); border-radius: 24px; padding: 14px 8px; min-height: 140px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; box-shadow: 0 4px 0 var(--line); }
.cat:active, .tile:active, .big-btn:active, .piece:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.cat-icon { font-size: 3.6rem; line-height: 1.05; color: var(--accent2); }
.cat:nth-child(2) .cat-icon { color: #FF6B8B; } .cat:nth-child(3) .cat-icon { color: #36A35B; } .cat:nth-child(4) .cat-icon { color: #FF9F43; } .cat:nth-child(5) .cat-icon { color: #3E9BD6; }
.cat b { font-size: 1.2rem; font-weight: normal; } .cat small { color: #E0A100; font-size: 1rem; }
.cats .cat:last-child:nth-child(odd) { grid-column: span 2; min-height: 110px; flex-direction: row; gap: 14px; }
.big-btn { min-height: 64px; border-radius: 20px; background: var(--accent); color: #fff; font-size: 1.2rem; padding: 10px 18px; box-shadow: 0 4px 0 #D9573A; width: 100%; }
.big-btn.plain { background: var(--card); color: var(--ink); box-shadow: 0 4px 0 var(--line); }
.challenge-btn { display: flex; align-items: center; gap: 14px; text-align: left; min-height: 84px; background: linear-gradient(135deg, #8B6CF0, #FF7AB6); box-shadow: 0 4px 0 #6A4FCC; }
.challenge-btn b { display: block; font-size: 1.45rem; font-weight: normal; } .challenge-btn small { font-size: 1rem; opacity: .95; }
.cb-icon { font-size: 2.4rem; }

/* 위 막대 */
.bar { display: flex; align-items: center; gap: 10px; min-height: 60px; }
.bar h2 { margin: 0; font-size: 1.5rem; font-weight: normal; flex: 1; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.bar h2 span { font-size: 2.2rem; line-height: 1; } .bar h2 small { font-size: 1.05rem; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { min-height: 56px; min-width: 88px; border-radius: 18px; background: var(--card); box-shadow: 0 3px 0 var(--line); padding: 0 12px; font-size: 1.05rem; }
.tool { min-height: 56px; min-width: 56px; border-radius: 18px; background: var(--card); box-shadow: 0 3px 0 var(--line); padding: 4px 14px; font-size: 1.05rem; }
.font-btn { font-size: .78rem; line-height: 1.2; color: var(--soft); padding: 4px 10px; } .font-btn b { font-weight: normal; color: var(--ink); font-size: .95rem; }

/* 글자 고르기 */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; padding-bottom: 12px; }
.tile { position: relative; aspect-ratio: 1; background: var(--card); border-radius: 22px; box-shadow: 0 4px 0 var(--line); font-size: 3.2rem; color: #5B4E7A; display: flex; align-items: center; justify-content: center; }
.tile.done { background: #FFF3C4; box-shadow: 0 4px 0 #F2D27A; }
.tile .star { position: absolute; top: 4px; right: 8px; font-style: normal; font-size: 1.6rem; color: #F2A20C; text-shadow: 0 1px 0 #fff; }

/* 색칠하기 */
#play, #challenge { overflow: hidden; }
.seg { display: flex; background: #F1E6D6; border-radius: 20px; padding: 4px; gap: 4px; }
.seg button { flex: 1; min-height: 56px; border-radius: 16px; background: transparent; font-size: 1.1rem; color: var(--soft); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.seg.small button { font-size: 1rem; }
.stage { flex: 1; min-height: 160px; display: flex; align-items: center; justify-content: center; touch-action: none; }
.stage canvas { touch-action: none; display: block; }
.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sizes { display: flex; gap: 6px; margin-left: auto; }
.sizes button { min-height: 56px; min-width: 64px; border-radius: 16px; background: var(--card); box-shadow: 0 3px 0 var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: .8rem; gap: 2px; padding: 4px 8px; }
.sizes i { width: var(--d); height: var(--d); border-radius: 50%; background: var(--ink); display: block; }
.sizes button.on { outline: 4px solid var(--accent2); }
.palette { display: grid; grid-template-columns: repeat(var(--n, 6), 1fr); gap: 8px; }
.sw { aspect-ratio: 1; min-height: 56px; max-height: 96px; border-radius: 50%; box-shadow: inset 0 -5px 0 rgba(0,0,0,.14), 0 3px 0 var(--line); display: flex; align-items: center; justify-content: center; position: relative; transition: transform .12s; justify-self: center; width: 100%; max-width: 96px; }
.sw b { font-size: 1.9rem; font-weight: normal; text-shadow: 0 0 3px rgba(0,0,0,.25); }
.sw.on { transform: scale(1.1); outline: 5px solid var(--ink); outline-offset: 3px; }
.sw.fin::after { content: '✓'; position: absolute; right: -4px; top: -6px; background: #36A35B; color: #fff; border-radius: 50%; width: 26px; height: 26px; font-size: .9rem; display: flex; align-items: center; justify-content: center; }
.wiggle { animation: wiggle .7s ease 2; }
@keyframes wiggle { 0%,100% { transform: scale(1.12) rotate(0); } 25% { transform: scale(1.25) rotate(-10deg); } 75% { transform: scale(1.25) rotate(10deg); } }

/* 가로 화면: 색칠판 왼쪽, 도구 오른쪽 */
@media (orientation: landscape) and (min-aspect-ratio: 5/4) {
  #play { display: grid; grid-template-columns: 1fr minmax(260px, 36%); grid-template-rows: auto auto 1fr auto; grid-template-areas: "bar bar" "stage seg" "stage pal" "stage tools"; max-width: none; }
  #play .bar { grid-area: bar; } #play .seg { grid-area: seg; } #play .stage { grid-area: stage; min-height: 0; } #play .tools { grid-area: tools; } #play .palette { grid-area: pal; align-content: start; grid-template-columns: repeat(3, 1fr); }
}

/* 연달아 도전 */
.streak { display: flex; align-items: baseline; gap: 6px; background: #FFF3C4; border-radius: 18px; padding: 4px 14px; box-shadow: 0 3px 0 #F2D27A; }
.streak span { font-size: 1rem; color: #A07400; } .streak b { font-size: 2.2rem; font-weight: normal; color: #E07A00; line-height: 1.1; display: inline-block; }
.streak b.bump { animation: bump .6s ease; } @keyframes bump { 40% { transform: scale(1.6); } }
.hearts { margin-left: auto; font-size: 1.8rem; letter-spacing: 2px; } .hearts span { color: #E3D7E8; } .hearts span.on { color: #FF5D7A; }
#challenge { gap: 8px; }
.example { position: relative; align-self: center; background: var(--card); border-radius: 20px; padding: 8px; box-shadow: 0 4px 0 var(--line); }
.example canvas { display: block; background: #FFFDF8; border-radius: 12px; }
.ex-tag { position: absolute; left: -6px; top: -10px; background: var(--accent2); color: #fff; border-radius: 12px; padding: 2px 12px; font-size: 1rem; z-index: 1; }
.ch-say { margin: 0; text-align: center; font-size: 1.1rem; color: var(--soft); min-height: 1.3em; }
.slots { display: flex; justify-content: center; gap: 16px; padding: 8px; border: 3px dashed #E2CFB5; border-radius: 22px; flex-wrap: wrap; }
.slot-group { display: flex; gap: 5px; padding: 4px; border-radius: 16px; background: #FBF4EA; }
.slot { width: var(--cell, 64px); height: var(--cell, 64px); border-radius: 14px; background: #F1E6D6; display: flex; align-items: center; justify-content: center; font-size: calc(var(--cell, 64px) * .62); }
.slot.next { outline: 4px solid #FFB703; outline-offset: 1px; animation: glow 1.4s ease-in-out infinite; }
@keyframes glow { 50% { outline-color: #FFE08A; } }
.slot.filled { background: #fff; } .slot span { color: #4B3F72; }
.scene-stage { min-height: 120px; }
.scene-stage canvas { background: #FFFDF8; border: 3px solid #EADFCF; border-radius: 20px; }
.scene-stage.hover canvas { border-color: var(--accent); background: #FFF0D6; }
.choices { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.piece { width: 70px; height: 70px; border-radius: 20px; background: var(--card); box-shadow: 0 4px 0 var(--line); font-size: 2.5rem; color: #4B3F72; touch-action: none; display: flex; align-items: center; justify-content: center; }
.piece.used { visibility: hidden; } .piece.lifted { opacity: .35; }
.piece.ghost { position: fixed; z-index: 50; pointer-events: none; transform: scale(1.15) rotate(-4deg); box-shadow: 0 10px 20px rgba(0,0,0,.18); }
.piece.shake { animation: shake .5s; } @keyframes shake { 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }
.piece.hint { animation: hintGlow 1.2s ease 3; } @keyframes hintGlow { 50% { background: #FFE08A; transform: scale(1.12); } }
.ch-tools { justify-content: center; gap: 8px; flex-wrap: nowrap; }
.ch-tools .tool { min-width: 56px; padding: 4px 10px; font-size: 1.5rem; } .ch-tools [data-t=hint] { font-size: 1.05rem; }
#challenge .palette { grid-template-columns: repeat(var(--n, 6), minmax(0, 72px)); justify-content: center; }

/* 설정·완성 창 */
.sheet { position: fixed; inset: 0; background: rgba(46, 42, 58, .45); display: flex; align-items: center; justify-content: center; padding: calc(var(--sat) + 12px) 12px calc(var(--sab) + 12px); z-index: 20; }
.sheet-card { background: var(--card); border-radius: 28px; padding: 20px 18px; width: 100%; max-width: 520px; max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.sheet-card h2 { margin: 0; text-align: center; font-weight: normal; font-size: 1.6rem; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 1.2rem; min-height: 60px; }
.set-col { display: flex; flex-direction: column; gap: 8px; font-size: 1.1rem; }
.switch { min-width: 104px; min-height: 56px; border-radius: 30px; background: #E6DED3; color: var(--soft); font-size: 1.1rem; }
.switch.on { background: #36A35B; color: #fff; }
.slider-row { display: flex; flex-direction: column; gap: 6px; font-size: 1.05rem; color: var(--soft); padding: 0 4px 6px; }
.slider-row b { color: var(--ink); font-weight: normal; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 56px; background: transparent; touch-action: none; }
input[type=range]::-webkit-slider-runnable-track { height: 18px; border-radius: 10px; background: linear-gradient(90deg, #FF9F43 0 var(--v, 50%), #EADFCF var(--v, 50%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 48px; height: 48px; margin-top: -15px; border-radius: 50%; background: #fff; border: 5px solid #FF7A59; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
input[type=range]:disabled { opacity: .4; }
.note { margin: 0; color: var(--soft); font-size: .95rem; text-align: center; }
.done-card { text-align: center; align-items: center; }
.stamp { font-size: 4.6rem; color: #F7B500; line-height: 1; animation: stamp .7s cubic-bezier(.3,1.8,.5,1); text-shadow: 0 4px 0 #F2D27A; }
@keyframes stamp { 0% { transform: scale(0) rotate(-40deg); } 100% { transform: scale(1) rotate(0); } }
#doneImg { max-width: 70%; max-height: 32vh; }
.done-name { margin: 0; font-size: 1.6rem; } .done-name span { font-size: 2.4rem; }
.done-say { margin: 0; font-size: 1.35rem; color: #E0602F; min-height: 1.4em; }
.done-btns { display: flex; flex-direction: column; gap: 10px; width: 100%; } .done-btns.row { flex-direction: row; }
#done.grand .sheet-card { background: linear-gradient(180deg, #FFF8D6, #fff); }

/* 칭찬 자막 */
.bubble { position: fixed; left: 50%; top: calc(var(--sat) + 74px); transform: translate(-50%, -20px) scale(.9); background: #fff; border-radius: 22px; padding: 12px 20px; font-size: 1.35rem; box-shadow: 0 6px 18px rgba(0,0,0,.14); opacity: 0; transition: opacity .25s, transform .3s cubic-bezier(.3,1.6,.5,1); z-index: 30; pointer-events: none; max-width: 92vw; text-align: center; color: #E0602F; }
.bubble.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.veil { position: fixed; inset: 0; background: rgba(255,246,233,.7); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; z-index: 25; }
#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 40; }

/* 자유 꾸미기 */
.free-btn { display: flex; align-items: center; gap: 14px; text-align: left; min-height: 84px; background: linear-gradient(135deg, #36C2A0, #4CC9F0); box-shadow: 0 4px 0 #2A9C82; }
.free-btn b { display: block; font-size: 1.45rem; font-weight: normal; } .free-btn small { font-size: 1rem; opacity: .95; }
#free { gap: 8px; }
.seg.tri button { font-size: 1.05rem; }
#freeTools, #chTools { overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
#freeTools .tool { flex: 0 0 auto; min-width: 56px; font-size: 1.45rem; padding: 4px 8px; }
#freePalette { display: flex; gap: 8px; overflow-x: auto; padding: 6px 4px; }
#freePalette .sw { flex: 0 0 56px; width: 56px; height: 56px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs button { flex: 0 0 auto; min-height: 48px; padding: 0 14px; border-radius: 16px; background: #F1E6D6; color: var(--soft); font-size: 1.05rem; }
.tabs button.on { background: var(--accent2); color: #fff; }
.tray { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; min-height: 84px; align-items: center; }
.tray .piece { flex: 0 0 70px; }
.tray .note { padding: 0 10px; }
.work { flex: 0 0 auto; padding: 4px; border-radius: 14px; background: var(--card); box-shadow: 0 3px 0 var(--line); min-height: 64px; }
.work img { height: 64px; display: block; border-radius: 10px; }
.save-btn { background: #36A35B; color: #fff; box-shadow: 0 3px 0 #2A7F47; }
.own-thumb { display: block; }
.cat-icon .own-thumb, .tile .own-thumb { margin: 0 auto; }
.pt-g { display: inline-flex; vertical-align: middle; }
.skip { position: fixed; inset: 0; z-index: 35; display: flex; align-items: flex-end; justify-content: center; padding-bottom: calc(var(--sab) + 18px); }
.skip span { background: rgba(46,42,58,.6); color: #fff; border-radius: 16px; padding: 6px 14px; font-size: .95rem; }

#ptext { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 39; }
.bar h2.nowrap { white-space: nowrap; }

/* 사람(프로필) */
.who-chip { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 64px; border-radius: 22px; background: var(--card); box-shadow: 0 4px 0 var(--line); padding: 8px 16px; font-size: 1.25rem; color: var(--ink); }
.who-chip .av { font-size: 2.1rem; line-height: 1; } .who-chip b { flex: 1; text-align: left; font-weight: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .who-chip small { color: var(--soft); font-size: 1rem; white-space: nowrap; }
.who-list { display: flex; flex-direction: column; gap: 10px; }
.who-row { display: flex; gap: 8px; }
.who-row .pick { flex: 1; display: flex; align-items: center; gap: 12px; min-height: 76px; border-radius: 22px; background: #FFF4E4; box-shadow: 0 4px 0 var(--line); padding: 8px 14px; font-size: 1.3rem; color: var(--ink); text-align: left; }
.who-row .pick.on { background: #FFE2C6; outline: 3px solid var(--accent); }
.who-row .pick .av { font-size: 2.4rem; line-height: 1; } .who-row .pick small { display: block; color: var(--soft); font-size: .95rem; }
.who-row .edit { width: 76px; min-height: 76px; border-radius: 22px; background: var(--card); box-shadow: 0 4px 0 var(--line); font-size: 1rem; color: var(--ink); }
.who-row .edit b { display: block; font-size: 1.6rem; font-weight: normal; }
#prof input[type=text] { font: inherit; font-size: 1.3rem; min-height: 60px; border-radius: 18px; border: 3px solid var(--line); padding: 6px 16px; background: #FFFDF8; color: var(--ink); }
#prof input[type=text]:focus { outline: none; border-color: var(--accent); }
.titles { display: flex; flex-wrap: wrap; gap: 8px; }
.titles button { min-height: 52px; padding: 6px 14px; border-radius: 16px; background: #F1E6D6; font-size: 1.1rem; color: var(--ink); }
.titles button.fit { background: #FFF0DC; } .titles button.on { background: var(--accent); color: #fff; box-shadow: 0 3px 0 #D9573A; }
.titles .more { background: transparent; color: var(--soft); text-decoration: underline; }
.big-btn.danger { background: #fff; color: #D64545; box-shadow: 0 4px 0 #F2C4C4; }
.note.center { text-align: center; margin: -6px 0 0; } .soft { color: var(--soft); font-size: .95rem; }
#confirmText { white-space: pre-line; }
/* 언어·앱 정보 */
.about { background: #FFF4E4; border-radius: 18px; padding: 10px 14px; font-size: 1rem; }
.about summary { font-size: 1.1rem; min-height: 44px; display: flex; align-items: center; cursor: pointer; }
.about p { margin: 8px 0 0; line-height: 1.45; text-align: left; }
.home-group { margin: 6px 4px -4px; font-size: 1.15rem; color: var(--soft); grid-column: 1 / -1; }
/* 영어 화면: 둥근 라틴 글꼴(Fredoka), 없는 글자는 주아로 */
html.lang-en { --ui: 'CN Fredoka', 'CN Jua', system-ui, sans-serif; }
html.lang-en .who-chip b, html.lang-en .big-btn b { letter-spacing: .2px; }
/* English sentences are longer: wider, slightly smaller speech bubble */
html.lang-en .bubble { width: max-content; max-width: min(92vw, 560px); font-size: 1.2rem; line-height: 1.3; }
/* 목소리 종류 (아이 목소리 · 여자아이/남자아이 · 어른) */
.vtype button:disabled { opacity: .45; }
.vnote { font-size: .85rem; margin-top: 4px; }
.seg.vtype button { white-space: nowrap; padding-left: 2px; padding-right: 2px; font-size: .95rem; letter-spacing: -.02em; }
