/* 나혼자 에듀 포털 — 폰·태블릿 가변폭 */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: clamp(14px, calc(10px + 1.25vmin), 26px); }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: var(--font); color: var(--ink); background: var(--sky);
  touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
button, input { font-family: inherit; color: inherit; }
input { -webkit-user-select: text; user-select: text; }
svg { display: block; }

#scene { position: fixed; inset: 0; z-index: 0; }
#scene svg { width: 100%; height: 100%; }
.cloud { animation: drift 70s ease-in-out infinite alternate; }
.cloud.c2 { animation-duration: 90s; animation-delay: -20s; }
.cloud.c3 { animation-duration: 110s; animation-delay: -50s; }
@keyframes drift { from { transform: translateX(-60px); } to { transform: translateX(90px); } }

#app { position: fixed; inset: 0; z-index: 1; }
.view {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: .8rem; overflow: auto; overscroll-behavior: contain;
  padding: max(.9rem, env(safe-area-inset-top)) max(.9rem, env(safe-area-inset-right)) max(.9rem, env(safe-area-inset-bottom)) max(.9rem, env(safe-area-inset-left));
}
.center { align-items: center; justify-content: center; text-align: center; }

.outline { color: #fff; -webkit-text-stroke: .32rem var(--ink); paint-order: stroke fill; text-shadow: 0 .18rem 0 var(--ink); letter-spacing: .02em; }
h1, h2 { margin: 0; font-weight: 700; line-height: 1.15; }
.title { font-size: 2.6rem; }
.sub { font-size: 1.1rem; margin: 0; opacity: .85; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; font-weight: 700; font-size: 1.2rem;
  min-height: 3.6rem; min-width: 3.6rem; padding: .4rem 1.4rem; background: var(--yellow); color: var(--ink);
  border: .2rem solid var(--ink); border-radius: 99px; box-shadow: 0 .28rem 0 var(--ink); cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(.22rem); box-shadow: 0 .06rem 0 var(--ink); }
.btn.purple { background: var(--purple); color: #fff; }
.btn.pink { background: var(--pink); color: #fff; }
.btn.green { background: var(--green); color: #fff; }
.btn.white { background: #fff; }
.btn.small { min-height: 2.8rem; font-size: 1rem; padding: .2rem 1rem; }
.btn.wide { width: 100%; }
.btn svg { width: 1.5rem; height: 1.5rem; }
.btn, .chip { white-space: nowrap; }
@media (max-width: 520px) { .fsbtn span { display: none; } .fsbtn { padding: .2rem .7rem; } }
.btn[disabled] { opacity: .5; pointer-events: none; }

.chip {
  display: inline-flex; align-items: center; gap: .4rem; background: #fff; border: .2rem solid var(--ink); border-radius: 99px;
  padding: .25rem .9rem .25rem .35rem; box-shadow: 0 .22rem 0 var(--ink); font-weight: 700; font-size: 1.1rem; min-height: 3.2rem;
}
.chip.star { padding-left: .6rem; }
.chip svg.st { width: 1.7rem; height: 1.7rem; }
button.chip { cursor: pointer; }
button.chip:active { transform: translateY(.18rem); box-shadow: 0 .04rem 0 var(--ink); }

/* 상단 줄 */
.top { display: flex; align-items: center; gap: .7rem; flex: none; }
.top .grow { flex: 1; min-width: 0; }
.top .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9rem; }

/* 아바타 */
.av { aspect-ratio: 1; border-radius: 50%; border: .2rem solid var(--ink); overflow: hidden; background: var(--bg, #e6d9ff); box-shadow: 0 .22rem 0 var(--ink); flex: none; }
.av svg { width: 100%; height: 100%; }
.chip .av { width: 2.5rem; box-shadow: none; border-width: .15rem; }

/* 동동이와 말풍선 */
.dd { width: 100%; height: auto; }
.dd-arm { transform-origin: 118px 124px; animation: wave 1.6s ease-in-out infinite; }
.dd { animation: bob 3.2s ease-in-out infinite; }
@keyframes wave { 0%,100% { transform: rotate(0); } 50% { transform: rotate(-22deg); } }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-.35rem); } }
.greet { display: flex; align-items: center; gap: .8rem; flex: none; }
.greet .mascot { width: 5.2rem; flex: none; }
.bubble { position: relative; background: #fff; border: .2rem solid var(--ink); border-radius: 1.4rem; padding: .7rem 1.1rem; font-size: 1.35rem; font-weight: 700; box-shadow: 0 .25rem 0 var(--ink); }
.bubble::before { content: ""; position: absolute; left: -.62rem; top: 50%; width: 1rem; height: 1rem; background: #fff; border-left: .2rem solid var(--ink); border-bottom: .2rem solid var(--ink); transform: translateY(-50%) rotate(45deg); }

/* 카테고리 카드 */
.cats { flex: 1; min-height: 0; display: grid; gap: .9rem; grid-template-columns: repeat(2, 1fr); grid-auto-rows: minmax(11rem, 1fr); }
@media (orientation: landscape) and (min-aspect-ratio: 3/2) { .cats { grid-template-columns: repeat(4, 1fr); grid-auto-rows: auto; } }
.cat {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: space-between; min-height: 0; padding: .6rem .6rem .8rem;
  background: var(--c); border: .22rem solid var(--ink); border-radius: 1.6rem; box-shadow: 0 .42rem 0 var(--ink); cursor: pointer; overflow: hidden;
  transition: transform .08s, box-shadow .08s; font-size: inherit;
}
.cat:active { transform: translateY(.3rem); box-shadow: 0 .1rem 0 var(--ink); }
.cat::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.45), transparent 55%); pointer-events: none; }
.cat .artbox { flex: 1; min-height: 0; width: 100%; display: flex; }
.cat svg.art { width: 100%; height: 100%; }
.cat .cname { font-size: 2.3rem; font-weight: 700; line-height: 1.1; }
.cat.world .cname { font-size: 1.75rem; text-align: center; }
.cat .meta { position: absolute; top: .55rem; right: .55rem; background: #fff; border: .16rem solid var(--ink); border-radius: 99px; padding: .1rem .7rem .1rem .3rem; font-weight: 700; font-size: 1rem; display: flex; align-items: center; gap: .2rem; }
.cat .meta svg { width: 1.4rem; height: 1.4rem; }
.cat.soon .artbox { filter: saturate(.75); opacity: .9; }
.cat .ribbon { position: absolute; top: .6rem; left: .6rem; background: var(--ink); color: #fff; border-radius: 99px; padding: .15rem .8rem; font-size: .95rem; font-weight: 700; }

/* 프로필 선택 */
.profiles { flex: 1; display: flex; flex-wrap: wrap; gap: 1.4rem 1.6rem; justify-content: center; align-content: center; padding: .5rem 0; }
.pf { width: clamp(7rem, 24vmin, 12rem); display: flex; flex-direction: column; align-items: center; gap: .6rem; background: none; border: 0; cursor: pointer; padding: 0; font-size: inherit; }
.pf .av { width: 100%; }
.pf:active .av { transform: translateY(.2rem); box-shadow: 0 .04rem 0 var(--ink); }
.pf .pname { font-size: 1.6rem; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf.add .av { background: #fff; display: grid; place-items: center; font-size: 4rem; color: var(--purple); border-style: dashed; }

/* 로그인 카드 */
.card { width: min(30rem, 100%); background: var(--paper); border: .22rem solid var(--ink); border-radius: 1.6rem; box-shadow: 0 .45rem 0 var(--ink); padding: 1.1rem; display: flex; flex-direction: column; gap: .8rem; text-align: left; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.seg .btn { box-shadow: none; background: #fff; min-height: 3rem; font-size: 1.05rem; }
.seg .btn.on { background: var(--purple); color: #fff; }
label.f { display: flex; flex-direction: column; gap: .3rem; font-weight: 700; font-size: 1rem; }
input.in { font-size: 1.2rem; min-height: 3.4rem; width: 100%; border: .2rem solid var(--ink); border-radius: 1rem; padding: .3rem 1rem; background: #fff; outline: none; }
input.in:focus { border-color: var(--purple); box-shadow: 0 0 0 .25rem rgba(155,123,255,.35); }
.msg { min-height: 1.3rem; font-size: 1rem; font-weight: 700; color: #d6336c; margin: 0; }
.note { font-size: .9rem; opacity: .75; margin: 0; }

/* 모달 */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(59,42,107,.55); display: flex; align-items: center; justify-content: center; padding: 1rem; overflow: auto; }
.sheet { width: min(34rem, 100%); max-height: 100%; overflow: auto; background: var(--paper); border: .22rem solid var(--ink); border-radius: 1.6rem; box-shadow: 0 .5rem 0 var(--ink); padding: 1.1rem; display: flex; flex-direction: column; gap: .8rem; }
.sheet h2 { font-size: 1.6rem; }
.avpick { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.avpick button { background: none; border: .2rem solid transparent; border-radius: 1.2rem; padding: .2rem; cursor: pointer; }
.avpick button.on { border-color: var(--purple); background: rgba(155,123,255,.18); }
.avpick .av { width: 100%; box-shadow: none; }
.row { display: flex; gap: .6rem; align-items: center; }
.row.end { justify-content: flex-end; }
.row .grow { flex: 1; }
.plist { display: flex; flex-direction: column; gap: .5rem; }
.plist .item { display: flex; align-items: center; gap: .6rem; background: #fff; border: .18rem solid var(--ink); border-radius: 1.1rem; padding: .35rem .6rem; }
.plist .item .av { width: 2.8rem; box-shadow: none; border-width: .15rem; }
.plist .item .grow { flex: 1; font-weight: 700; font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-weight: 700; }
.sw input { width: 1.8rem; height: 1.8rem; accent-color: var(--purple); }
.help li { margin: .35rem 0; }

/* 부모 버튼 (길게 눌러야 열림) */
.gear { position: relative; overflow: hidden; width: 3.2rem; height: 3.2rem; border-radius: 50%; padding: 0; background: rgba(255,255,255,.85); border: .18rem solid var(--ink); display: grid; place-items: center; cursor: pointer; box-shadow: 0 .18rem 0 var(--ink); flex: none; }
.gear svg { width: 1.6rem; height: 1.6rem; position: relative; }
.gear::after { content: ""; position: absolute; left: 0; bottom: 0; height: 0; width: 100%; background: rgba(155,123,255,.55); }
.gear.hold::after { animation: fill 1.5s linear forwards; }
@keyframes fill { to { height: 100%; } }
.gearhint { font-size: .85rem; opacity: .7; text-align: center; margin: 0; }

/* 모듈 화면 */
.modview { padding: 0; gap: 0; background: var(--paper); }
.modbar { flex: none; display: flex; align-items: center; gap: .6rem; padding: .4rem .7rem; padding-top: max(.4rem, env(safe-area-inset-top)); padding-left: max(.7rem, env(safe-area-inset-left)); padding-right: max(.7rem, env(safe-area-inset-right));
  background: var(--purple); border-bottom: .2rem solid var(--ink); color: #fff; }
.modbar .mtitle { flex: 1; font-size: 1.4rem; font-weight: 700; text-align: center; }
.modbar .btn { min-height: 2.9rem; padding: .1rem 1rem; font-size: 1rem; }
.modframe { flex: 1; width: 100%; border: 0; background: #fff; min-height: 0; }

#toast { position: fixed; left: 50%; bottom: max(1.6rem, env(safe-area-inset-bottom)); transform: translate(-50%, 6rem); z-index: 60; background: var(--ink); color: #fff; padding: .8rem 1.4rem; border-radius: 99px; font-weight: 700; font-size: 1.15rem; transition: transform .25s; max-width: 90vw; text-align: center; pointer-events: none; }
#toast.on { transform: translate(-50%, 0); }
.rotate-hint { display: none; }

@media (max-height: 430px) {
  .title { font-size: 2rem; }
  .greet .mascot { width: 3.6rem; }
  .bubble { font-size: 1.1rem; padding: .4rem .8rem; }
  .cat .cname { font-size: 1.7rem; }
  .btn { min-height: 3rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
