/* sj-sandbox — 게임 화면.
   아이가 태블릿으로도 여니 터치 스크롤·확대를 막고 화면을 꽉 채운다. */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
	width: 100%;
	height: 100%;
	overflow: hidden;
	background: #87ceeb;
	font-family: -apple-system, BlinkMacSystemFont, 'Malgun Gothic', '맑은 고딕', sans-serif;
	/* 태블릿에서 두 손가락 확대·당겨서 새로고침을 막는다 */
	touch-action: none;
	-webkit-user-select: none;
	user-select: none;
	overscroll-behavior: none;
}

#scene {
	display: block;
	width: 100%;
	height: 100%;
	/* 캔버스를 클릭해도 텍스트 커서가 안 뜨게 */
	cursor: grab;
}
#scene:active { cursor: grabbing; }

#loading {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #87ceeb;
	color: #2c3e50;
	font-size: 24px;
	font-weight: 700;
	z-index: 10;
	transition: opacity .3s;
}
#loading.done { opacity: 0; pointer-events: none; }

#hud {
	position: fixed;
	top: 10px;
	left: 12px;
	padding: 6px 10px;
	background: rgba(0, 0, 0, .35);
	color: #fff;
	font-size: 13px;
	line-height: 1.5;
	border-radius: 6px;
	white-space: pre;
	pointer-events: none;
	z-index: 5;
}

/* ── 채팅 UI ──────────────────────────────────────────────────────────
   다섯 살이 태블릿으로 만진다. 버튼은 크고(최소 56px), 글자는 굵고,
   눌렀을 때 반응이 분명해야 한다. 색은 게임 화면 위에 떠도 읽히게 어둡게. */

#chat {
	position: fixed;
	left: 0; right: 0; bottom: 0;
	z-index: 20;
	pointer-events: none;              /* 패널만 클릭을 받는다 */
	font-size: 15px;
}
#chat button, #chat input { pointer-events: auto; }

#chat-hint {
	pointer-events: none;
	margin: 0 auto 14px;
	width: max-content;
	padding: 8px 16px;
	background: rgba(0, 0, 0, .4);
	color: #fff;
	border-radius: 999px;
	font-weight: 600;
}

/* 말풍선 — say 응답. 아이가 읽는다(TTS 는 보조) */
#chat-say {
	pointer-events: none;
	margin: 0 auto 12px;
	max-width: min(680px, 92vw);
	padding: 14px 20px;
	background: rgba(255, 255, 255, .95);
	color: #1e2b3a;
	border-radius: 18px;
	font-size: 20px;
	font-weight: 700;
	line-height: 1.4;
	text-align: center;
	box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}

#chat-panel {
	pointer-events: auto;
	background: rgba(18, 26, 38, .93);
	backdrop-filter: blur(8px);
	border-radius: 20px 20px 0 0;
	padding: 14px 16px 16px;
	max-width: 920px;
	margin: 0 auto;
	box-shadow: 0 -8px 32px rgba(0, 0, 0, .35);
}

.chat-row {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
	margin-bottom: 10px;
}
.chat-row.chat-small { gap: 6px; margin-bottom: 8px; }
.chat-row:empty { display: none; margin: 0; }

/* 최근 문장·목소리 칩 */
#chat button.chip {
	padding: 8px 14px;
	background: #34465e;
	color: #fff;
	border: none;
	border-radius: 999px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
}
#chat button.chip:active { transform: scale(.94); }
#chat button.chip.warn { background: #6b3a3a; }
#chat button.chip.ghost { background: #263349; color: #b9c7d8; font-weight: 500; }

/* 입력줄 */
.chat-input {
	display: flex;
	gap: 8px;
	align-items: center;
	margin-bottom: 8px;
}
#chat-text {
	flex: 1;
	min-width: 0;
	padding: 14px 16px;
	background: #fff;
	border: 3px solid transparent;
	border-radius: 14px;
	font-size: 19px;
	font-weight: 600;
	color: #1e2b3a;
	outline: none;
}
#chat-text:focus { border-color: #4fc3f7; }

#chat-mic, #chat-send {
	width: 56px; height: 56px;
	flex: 0 0 auto;
	background: #34465e;
	color: #fff;
	border: none;
	border-radius: 14px;
	font-size: 24px;
	cursor: pointer;
}
#chat-send { background: #2f7fe0; }
#chat-mic:active, #chat-send:active { transform: scale(.94); }
/* 녹음 중 — 눈에 확 띄어야 아이가 상태를 안다 */
#chat-mic.rec {
	background: #e8483d;
	animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
	0%, 100% { box-shadow: 0 0 0 0 rgba(232, 72, 61, .7); }
	50%      { box-shadow: 0 0 0 10px rgba(232, 72, 61, 0); }
}

@media (max-width: 560px) {
	#chat-say { font-size: 17px; }
	#chat-text { font-size: 17px; padding: 12px 14px; }
}
