:root { --ink: #5a4636; --card: rgba(255, 255, 255, 0.86); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif; color: var(--ink); background: #fff4e0; touch-action: none; user-select: none; -webkit-user-select: none; }
body.ar, body.ar html { background: transparent; }
canvas#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { position: fixed; inset: 0; pointer-events: none; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.ui-hit, button { pointer-events: auto; }
.hidden { display: none !important; }

/* 시작 화면 */
#start { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; background: linear-gradient(#fff4e0, #ffe3c4); }
body.start #start { display: flex; }
body.start #top, body.start #hint, body.start #bottom { display: none; }
#start .logo { font-size: 84px; filter: drop-shadow(0 6px 8px rgba(120, 80, 40, .25)); }
#start h1 { margin: 0; font-size: 44px; letter-spacing: 2px; }
#start p { margin: 0; font-size: 18px; opacity: .8; }
#start .note { max-width: 320px; font-size: 14px; opacity: .65; }
button.big { min-width: 240px; padding: 16px 28px; font-size: 22px; font-weight: 700; color: #fff; background: #ff8a5c; border: 0; border-radius: 30px; box-shadow: 0 6px 0 #d86a3e; }
button.big.alt { background: #7cc0e8; box-shadow: 0 6px 0 #5a9cc6; }
button.big:active { transform: translateY(4px); box-shadow: 0 2px 0 #d86a3e; }

/* 위쪽 상태 */
#top { position: absolute; top: 10px; left: 10px; right: 10px; background: var(--card); border-radius: 18px; padding: 8px 12px 10px; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }
#title { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
#stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.stat { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.stat span { width: 48px; flex: none; }
.bar { flex: 1; height: 13px; border-radius: 7px; background: #e0d4c6; overflow: hidden; }
.bar i { display: block; height: 100%; width: 80%; border-radius: 7px; transition: width .4s; }
#hint { position: absolute; left: 12px; right: 12px; top: 120px; text-align: center; font-size: 20px; font-weight: 700; color: #fff; text-shadow: 0 0 3px #3a2a1e, 0 0 6px #3a2a1e, 0 0 10px #3a2a1e; min-height: 28px; pointer-events: none; }
body.preview #hint { color: var(--ink); text-shadow: 0 1px 0 #fff; }
body:not(.ar):not(.preview) #hint { display: none; }

/* 아래 버튼 */
#bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 8px 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
#care { display: flex; gap: 8px; justify-content: center; width: 100%; max-width: 560px; }
#care button { flex: 1; min-width: 0; height: 84px; font-size: 30px; line-height: 1.1; color: #fff; background: var(--c); border: 3px solid rgba(0, 0, 0, .18); border-radius: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 4px 0 rgba(0, 0, 0, .18); }
#care button span { font-size: 16px; font-weight: 800; }
#care button:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .18); }
#care button:disabled { opacity: .45; }
#tools { display: flex; gap: 8px; }
/* 관리자 */
#btn-admin { position: absolute; right: 8px; top: 130px; width: 42px; height: 42px; border-radius: 21px; border: 0; background: rgba(60, 50, 40, .55); color: #fff; font-size: 20px; z-index: 6; }
body.start #btn-admin { display: none; }
#admin { position: absolute; left: 8px; right: 8px; top: 60px; max-width: 520px; margin: 0 auto; background: rgba(255, 255, 255, .96); border-radius: 16px; padding: 10px 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, .3); z-index: 7; font-size: 14px; }
.adm-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 16px; }
.adm-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.adm-row > span { width: 38px; font-weight: 700; }
#admin button.small { background: #7a6a58; }
#admin button.small.on { background: #ff8a5c; }
#admin button.danger { background: #d9453b; }
.adm-info { margin-top: 6px; font-size: 11px; opacity: .7; word-break: break-all; }
button.small { padding: 6px 12px; font-size: 14px; border-radius: 14px; border: 0; background: rgba(60, 50, 40, .55); color: #fff; }
body.preview #btn-replace { display: none; }
body.sleeping #btn-admin { z-index: 8; }

/* 잘 때 어두워짐 */
body.sleeping #overlay::before { content: ''; position: absolute; inset: 0; background: rgba(10, 10, 40, .5); pointer-events: none; }
body.sleeping #top, body.sleeping #bottom, body.sleeping #hint { z-index: 2; }

/* 하트 */
.heart { position: absolute; font-size: 38px; color: #ff6a90; text-shadow: 0 0 4px #fff, 0 0 8px #fff; pointer-events: none; opacity: 0; animation: heart 1.6s ease-out forwards; z-index: 3; }
@keyframes heart { 0% { opacity: 0; transform: translateY(0) scale(.6); } 15% { opacity: 1; } 100% { opacity: 0; transform: translateY(-120px) scale(1.2); } }

/* 진단 줄 (폰에서 안 될 때 원인을 보려고) */
#debug { position: absolute; left: 6px; bottom: 2px; max-width: 70%; font-size: 11px; line-height: 1.2; color: #fff; background: rgba(0,0,0,.45); padding: 2px 6px; border-radius: 6px; pointer-events: none; z-index: 5; }
body.start #debug { display: block; color: #5a4636; background: rgba(255,255,255,.6); bottom: 8px; }
