* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  background: #F6F4EF; color: #222;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
.screen { position: fixed; inset: 0; }

/* ───────── 엄마 화면 ───────── */
#mom { display: flex; flex-direction: column; background: #F6F4EF; }
.mom-top { padding: 14px 16px 8px; padding-top: max(14px, env(safe-area-inset-top)); }
.mom-top h1 { margin: 0; font-size: 22px; }
.mom-top small { font-size: 14px; color: #888; font-weight: 600; margin-left: 6px; }
.mom-body { flex: 1; overflow-y: auto; padding: 4px 12px 16px; display: grid; gap: 12px; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.box { background: #fff; border-radius: 16px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.box h2 { margin: 0 0 8px; font-size: 17px; }
.box h2 small { font-size: 13px; color: #777; font-weight: 500; margin-left: 4px; }
.tip { font-size: 13px; color: #777; margin: 4px 0 8px; line-height: 1.5; }
.msg { font-size: 14px; margin: 6px 0 0; min-height: 1em; }
.msg.bad { color: #C0392B; } .msg.good { color: #2E8B57; }
.row { display: flex; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row input { flex: 1; min-width: 0; font-size: 16px; padding: 11px 12px; border: 2px solid #ddd; border-radius: 12px; }
.row input:focus { outline: none; border-color: #E8473B; }
.btn { border: 0; border-radius: 12px; padding: 11px 16px; font-size: 16px; font-weight: 700; background: #EDEBE5; color: #222; }
.btn.main { background: #E8473B; color: #fff; }
.btn.big { padding: 15px 24px; font-size: 19px; }
.btn.huge { padding: 20px 34px; font-size: 26px; border-radius: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 2px solid #ddd; background: #fff; border-radius: 999px; padding: 8px 16px; font-size: 16px; font-weight: 700; }
.chip.on { background: #222; color: #fff; border-color: #222; }
.video-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 10px; }
.vitem { position: relative; border-radius: 10px; overflow: hidden; background: #000; aspect-ratio: 16/9; }
.vitem img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vitem .del { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 16px; }
.vitem .bad { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(192,57,43,.9); color: #fff; font-size: 12px; padding: 3px 6px; }
.vempty { font-size: 14px; color: #999; margin: 8px 0 0; }
.level { margin-top: 10px; }
.level h3 { font-size: 14px; margin: 0 0 6px; color: #555; }
.wchips { display: flex; flex-wrap: wrap; gap: 6px; }
.wchip { border: 2px solid #e2e2e2; background: #fff; border-radius: 10px; padding: 5px 10px; font-size: 16px; font-weight: 700; }
.wchip.done { color: #aaa; }
.wchip.next { background: #FFE9A8; border-color: #F2B705; }
.now { font-size: 16px; margin: 0 0 10px; }
.help summary { font-weight: 700; font-size: 15px; margin-top: 12px; color: #C0392B; }
.help ol { padding-left: 20px; line-height: 1.7; font-size: 15px; }
.help p { font-size: 15px; line-height: 1.6; }
.mom-foot { padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: #F6F4EF; border-top: 1px solid #e5e2da; }
.mom-foot .btn { width: 100%; }

/* ───────── 아이 화면 ───────── */
#kid { background: #1E1E24; color: #fff; display: flex; flex-direction: column; user-select: none; -webkit-user-select: none; }
.kid-part { flex: 1; min-height: 0; position: relative; }

/* 영상 고르기 */
#pick { overflow-y: auto; padding: 14px 14px 8px; padding-top: max(14px, env(safe-area-inset-top)); }
.pick-title { margin: 0 56px 12px 4px; font-size: 26px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(46%, 260px), 1fr)); gap: 12px; }
.pcard { border: 0; padding: 0; border-radius: 16px; overflow: hidden; background: #000; aspect-ratio: 16/9; position: relative; box-shadow: 0 3px 0 #000; }
.pcard img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcard:active { transform: scale(.97); }
.pick-empty { text-align: center; font-size: 22px; margin-top: 30vh; color: #ccc; }

/* 영상 보기 */
#watch { background: #000; }
#playerWrap { position: absolute; inset: 0; }
#playerWrap iframe, #ytPlayer { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
#shield { position: absolute; inset: 0; z-index: 2; }
#bigPlay { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 3; pointer-events: none;
  width: 110px; height: 110px; border-radius: 50%; background: rgba(232,71,59,.92); font-size: 52px; display: grid; place-items: center; padding-left: 8px; }
#vidError { position: absolute; inset: 0; z-index: 4; background: #1E1E24; display: grid; place-content: center; text-align: center; gap: 16px; font-size: 22px; }
.float-btn { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 10px; z-index: 5; border: 0; border-radius: 999px;
  padding: 9px 16px; font-size: 16px; font-weight: 700; background: rgba(255,255,255,.88); color: #222; }

/* 시간 막대 */
#timebar { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 14px; padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: #2A2A33; }
.tb-ico, .tb-end { font-size: 26px; line-height: 1; }
.tb-track { flex: 1; height: 22px; border-radius: 999px; background: #44444F; overflow: hidden; }
.tb-fill { height: 100%; width: 100%; border-radius: 999px; background: #5BC46A; transition: width .25s linear, background-color .6s; }
#timebar.warn .tb-fill { background: #F39C2D; }
#timebar.warn .tb-end { animation: wiggle 1s ease-in-out infinite; }
.tb-text { font-size: 16px; font-weight: 800; min-width: 62px; text-align: right; }
@keyframes wiggle { 0%,100% { transform: rotate(0) } 25% { transform: rotate(-12deg) scale(1.15) } 75% { transform: rotate(12deg) scale(1.15) } }

/* 잠금 버튼 (2초 누르기) */
.lock-btn { position: absolute; top: max(8px, env(safe-area-inset-top)); right: 8px; z-index: 20; width: 46px; height: 46px; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.12); color: #fff; font-size: 20px; padding: 0; display: grid; place-items: center; touch-action: none; }
.lock-btn span { grid-area: 1/1; }
.lock-btn svg { grid-area: 1/1; width: 46px; height: 46px; transform: rotate(-90deg); }
.lock-btn circle { fill: none; stroke: #fff; stroke-width: 3; stroke-dasharray: 107; stroke-dashoffset: 107; }
.lock-btn.holding circle { transition: stroke-dashoffset 2s linear; stroke-dashoffset: 0; }

/* 게임 시간 알림 */
#splash { position: absolute; inset: 0; z-index: 10; background: #1E1E24; display: grid; place-items: center; text-align: center; }
.splash-in p, .done-in p { font-size: 34px; font-weight: 800; margin: 6px 0 18px; }
.splash-big { font-size: 90px; line-height: 1.1; animation: pop .6s ease-out; }
@keyframes pop { 0% { transform: scale(.3); opacity: 0 } 70% { transform: scale(1.15) } 100% { transform: scale(1); opacity: 1 } }
.first-then { display: inline-flex; align-items: center; gap: 10px; }
.ft { background: #3A3A45; border-radius: 14px; padding: 10px 16px; font-size: 22px; font-weight: 800; opacity: .7; }
.ft.now { background: #F2B705; color: #222; opacity: 1; }
.ft-arrow { font-size: 26px; }
.first-then.small .ft { font-size: 15px; padding: 5px 10px; border-radius: 10px; }
.first-then.small .ft-arrow { font-size: 16px; }

/* 게임 */
#game { background: #FFF8E7; color: #222; display: flex; flex-direction: column; align-items: center; justify-content: space-evenly;
  padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: max(10px, env(safe-area-inset-bottom));
  --n: 3; --cw: min(calc((100vw - 28px - (var(--n) - 1) * 12px) / var(--n)), 24vh * 1.6, 240px); --ch: calc(var(--cw) * .62);
  touch-action: none; overflow: hidden; }
.g-top { display: flex; align-items: center; gap: 14px; margin-right: 50px; }
.g-dots { display: flex; gap: 8px; }
.g-dots i { width: 16px; height: 16px; border-radius: 50%; background: #E2DCCB; }
.g-dots i.done { background: #5BC46A; }
.g-dots i.cur { background: #F2B705; }
.g-board { display: flex; align-items: center; justify-content: center; gap: min(6vw, 40px); }
.g-pic { width: min(40vh, 42vw, 360px); height: min(40vh, 42vw, 360px); object-fit: contain; background: #fff; border-radius: 22px;
  box-shadow: 0 4px 0 #E8DFC6; }
.g-choices { display: flex; justify-content: center; gap: 12px; flex-wrap: nowrap; }
@media (orientation: portrait) {
  .g-board { flex-direction: column; gap: 18px; }
  .g-pic { width: min(34vh, 66vw, 360px); height: min(34vh, 66vw, 360px); }
  #game { --cw: min(calc((100vw - 28px - (var(--n) - 1) * 12px) / var(--n)), 200px); }
}
.wcard { width: var(--cw); height: var(--ch); border-radius: 18px; background: #fff; border: 4px solid #3B3B3B;
  display: grid; place-items: center; font-weight: 900; color: #1E1E24; white-space: nowrap;
  font-size: calc(var(--cw) * var(--fs, .3)); box-shadow: 0 5px 0 #3B3B3B; }
.wcard.choice { position: relative; touch-action: none; z-index: 1; }
.wcard.choice.drag { z-index: 30; box-shadow: 0 14px 24px rgba(0,0,0,.25); transition: none !important; }
.wcard.choice.back { transition: transform .35s cubic-bezier(.3,1.4,.5,1); }
.wcard.choice.snap { transition: transform .25s ease-out; z-index: 25; box-shadow: none; }
.wcard.choice.hint { animation: glow 1.1s ease-in-out infinite; }
@keyframes glow { 0%,100% { box-shadow: 0 5px 0 #3B3B3B, 0 0 0 0 rgba(242,183,5,.0) } 50% { box-shadow: 0 5px 0 #3B3B3B, 0 0 0 12px rgba(242,183,5,.55) } }
.wcard.slot { border: 4px dashed #B9B2A0; color: #B9B2A0; box-shadow: none; background: #FFFDF6; position: relative; }
.wcard.slot.over { border-color: #F2B705; background: #FFF3C4; }
.wcard.slot.win { border-style: solid; border-color: #5BC46A; }
.spark { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; pointer-events: none; z-index: 40;
  animation: burst 1.2s cubic-bezier(.15,.7,.3,1) both; }
@keyframes burst {
  0% { transform: translate(0, 0) scale(1.3); opacity: 1 }
  70% { opacity: 1 }
  100% { transform: translate(var(--dx), calc(var(--dy) + 50px)) scale(.3); opacity: 0 } }
.cheer-pop { position: absolute; left: 50%; top: 9%; z-index: 45; pointer-events: none; white-space: nowrap;
  font-size: clamp(44px, 11vmin, 90px); font-weight: 900; color: #FF4D6D;
  text-shadow: 0 4px 0 #fff, 0 -2px 0 #fff, 3px 0 0 #fff, -3px 0 0 #fff, 0 8px 14px rgba(0,0,0,.15);
  animation: cheer 1.5s ease-out both; }
@keyframes cheer {
  0% { transform: translateX(-50%) scale(.2) rotate(-12deg); opacity: 0 }
  22% { transform: translateX(-50%) scale(1.25) rotate(5deg); opacity: 1 }
  38% { transform: translateX(-50%) scale(1) rotate(0) }
  85% { opacity: 1 }
  100% { transform: translateX(-50%) scale(1) translateY(-12px); opacity: 0 } }
.star { position: absolute; font-size: 34px; pointer-events: none; z-index: 40; animation: fly .9s ease-out forwards; }
@keyframes fly { 0% { transform: translate(0,0) scale(.4); opacity: 1 } 100% { transform: translate(var(--dx), var(--dy)) scale(1.2); opacity: 0 } }
#gDone { position: absolute; inset: 0; z-index: 35; background: rgba(255,248,231,.97); display: grid; place-items: center; text-align: center; }

/* ───────── 핸드폰 · 노트북 구분 ───────── */
.admin-only { display: none !important; }
body.admin .admin-only { display: revert !important; }
body.admin .admin-bar.admin-only { display: flex !important; }
body.admin .phone-only { display: none !important; }
.admin-bar { align-items: center; justify-content: space-between; gap: 10px; font-size: 16px; max-width: 1200px; margin: 0 auto; }
.mom-foot .admin-bar .btn { width: auto; flex: none; }
.admin-bar b.saving { color: #C27C00; } .admin-bar b.bad { color: #C0392B; } .admin-bar b.ok { color: #2E8B57; }
body.admin .mom-body { max-width: 1200px; margin: 0 auto; width: 100%; }
body.admin .mom-top { max-width: 1200px; margin: 0 auto; width: 100%; }
.sync-code { font-size: 30px; font-weight: 900; letter-spacing: 3px; background: #FFF3C4; border-radius: 12px; padding: 8px 14px; display: inline-block; margin: 4px 0 8px; }
.sync-url { font-size: 15px; word-break: break-all; }
.sync-url b { color: #E8473B; }
.adm-input { display: block; width: 100%; font-size: 20px; padding: 13px 14px; border-radius: 12px; border: 2px solid #44444F; background: #26262E; color: #fff; margin: 0 0 10px; text-align: center; }
.adm-input:focus { outline: none; border-color: #F2B705; }

/* ───────── 처음 설정 ───────── */
#adminLogin { position: fixed; inset: 0; z-index: 95; background: #1E1E24; color: #fff; display: grid; place-items: center; overflow-y: auto; }
#setupVol { position: fixed; inset: 0; z-index: 90; background: rgba(20,20,26,.96); color: #fff; display: grid; place-items: center; overflow-y: auto; }
.setup-in { text-align: center; width: min(92vw, 460px); padding: 20px 0; }
.setup-step { font-size: 14px; color: #aaa; margin: 0 0 6px; }
.setup-in h2 { font-size: 26px; margin: 0 0 10px; }
.setup-tip { font-size: 16px; line-height: 1.6; color: #ddd; margin: 0 0 16px; }
.setup-tip.small { font-size: 13px; color: #999; margin-top: 14px; }
.setup-chips { justify-content: center; }
.setup-chips .chip { font-size: 18px; padding: 10px 18px; background: #34343F; color: #fff; border-color: #34343F; }
.setup-chips .chip.on { background: #F2B705; color: #222; border-color: #F2B705; }
#setupVolNext { min-width: 200px; }

/* ───────── 비밀번호 ───────── */
#pin { position: fixed; inset: 0; z-index: 100; background: rgba(20,20,26,.96); color: #fff; display: grid; place-items: center; }
.pin-in { text-align: center; width: min(92vw, 340px); }
.pin-title { font-size: 22px; font-weight: 800; margin: 0 0 14px; }
.pin-dots { display: flex; justify-content: center; gap: 16px; }
.pin-dots i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; }
.pin-dots i.on { background: #fff; }
.pin-msg { min-height: 22px; font-size: 15px; color: #F5A39C; margin: 10px 0; }
.pin-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-keys button { border: 0; border-radius: 16px; background: #34343F; color: #fff; font-size: 26px; font-weight: 700; padding: min(16px, 2.4vh) 0; }
.pin-keys button.sub { font-size: 18px; background: #26262E; }
.pin-keys button:active { background: #4A4A58; }
.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-10px) } 40%,80% { transform: translateX(10px) } }

@media (orientation: landscape) and (max-height: 500px) {
  .pin-in { display: grid; grid-template-columns: 1fr 1.3fr; gap: 20px; align-items: center; width: min(92vw, 620px); }
  .pin-keys button { padding: 8px 0; font-size: 22px; }
  .splash-big { font-size: 64px; }
  .splash-in p, .done-in p { font-size: 28px; margin: 4px 0 12px; }
}
