:root { --ink: #4a3428; --cream: #fff8ea; --green: #6cc24a; --leaf: #9be27c; --yellow: #ffd23f; --pink: #ff6fa0; --sky: #84d4ff; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--sky); color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; cursor: pointer; color: var(--ink); }
.hidden { display: none !important; }

/* 공통 */
.ov { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); overflow-y: auto; background: rgba(60,40,30,0.35); }
.ov.dim { background: rgba(60,40,30,0.55); z-index: 40; }
#ov-title { background: none; }
.box { width: 100%; max-width: 440px; text-align: center; margin: auto; }
.panel { background: var(--cream); border: 5px solid var(--ink); border-radius: 28px; padding: 18px 16px; box-shadow: 0 8px 0 var(--ink); }
.panel.wide { max-width: 760px; }
h2 { margin: 2px 0 8px; font-size: 26px; font-weight: 900; }
h3 { margin: 12px 0 4px; font-size: 17px; }
.btn { display: block; width: 100%; max-width: 300px; margin: 10px auto; padding: 12px 16px; font-size: 19px; font-weight: 900; background: #fff; border: 4px solid var(--ink); border-radius: 18px; box-shadow: 0 5px 0 var(--ink); transition: transform .06s; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.big { background: var(--leaf); font-size: 23px; padding: 14px; }
.btn.ad { background: #bfe6ff; }
.btn.ghost { background: transparent; box-shadow: none; border-color: rgba(74,52,40,0.4); font-size: 16px; padding: 8px; }
.btn:disabled { background: #eee3d6; color: #a08a78; box-shadow: 0 5px 0 #b8a593; border-color: #b8a593; cursor: default; }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.chip { border: 3px solid var(--ink); border-radius: 999px; background: #fff; font-weight: 800; font-size: 15px; padding: 6px 14px; }
.chip.off { opacity: 0.45; text-decoration: line-through; }
.note { font-size: 14px; color: #7a6352; margin: 4px 0; }
.phead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.phead h2 { margin: 0; }
.pc { font-weight: 900; font-size: 16px; background: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 4px 12px; white-space: nowrap; }
.tabs { display: flex; gap: 6px; justify-content: center; margin: 10px 0 2px; }
.tabs button { border: 3px solid var(--ink); border-radius: 12px; background: #fff; font-weight: 900; font-size: 15px; padding: 6px 12px; }
.tabs button.on { background: var(--yellow); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 10px 0; max-height: 58vh; overflow-y: auto; padding: 2px; }
.cell { background: #fff; border: 4px solid var(--ink); border-radius: 18px; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; }
.cell canvas { width: 100px; height: 84px; }
.cell b { font-size: 16px; line-height: 1.15; }
.cell .perk { font-size: 12px; color: #7a6352; line-height: 1.3; min-height: 16px; }
.cell .ic { font-size: 34px; line-height: 1.1; }
.cell button { width: 100%; padding: 7px; border: 3px solid var(--ink); border-radius: 12px; background: var(--yellow); font-weight: 900; font-size: 14px; margin-top: auto; }
.cell button:disabled { background: #eee3d6; color: #a08a78; cursor: default; }
.cell.sel { background: #fff4c2; }
.cell.done { background: #e9fbe2; }
.cell.dim { opacity: 0.7; }
.cell.dim .ic { filter: grayscale(1); }
.cell.unknown canvas { filter: brightness(0) opacity(0.25); }
.cell .new { position: absolute; top: -8px; right: -6px; background: var(--pink); color: #fff; border: 3px solid var(--ink); border-radius: 999px; font-size: 12px; font-weight: 900; padding: 1px 7px; }
.bar { width: 100%; height: 10px; border: 2px solid var(--ink); border-radius: 999px; background: #efe4d4; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--pink); color: #fff; font-size: 12px; line-height: 19px; border: 2px solid var(--ink); font-weight: 900; }

/* 제목 */
.title .logo { margin: 0; line-height: 0.92; font-size: clamp(54px, 15vw, 92px); font-weight: 900; letter-spacing: 1px; }
.logo span { display: block; -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; text-shadow: 0 7px 0 var(--ink); }
.logo span:first-child { color: #ffb347; } .logo span:last-child { color: #8be36b; }
.tag { font-size: 18px; font-weight: 800; color: #fff; text-shadow: 0 2px 0 var(--ink), 0 0 6px rgba(74,52,40,0.6); margin: 10px 0 6px; }
#title-art { width: min(100%, 520px); height: auto; aspect-ratio: 560 / 220; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud button, #hud #seeds, #hud .pill { pointer-events: auto; }
#top { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 8px; right: 8px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pill { background: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 4px 12px; font-size: 18px; font-weight: 800; box-shadow: 0 3px 0 var(--ink); white-space: nowrap; }
.pill b { font-weight: 900; }
#lvbox { display: flex; align-items: center; background: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 2px 10px 2px 2px; box-shadow: 0 3px 0 var(--ink); }
#lv { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; border-radius: 50%; background: var(--leaf); border: 3px solid var(--ink); font-weight: 900; font-size: 16px; margin-right: 6px; }
#xpbar { width: 90px; height: 12px; border: 2px solid var(--ink); border-radius: 999px; background: #efe4d4; overflow: hidden; }
#xpfill { display: block; height: 100%; width: 0; background: var(--green); transition: width .2s; }
#weather { font-size: 15px; margin-left: auto; }
#side { position: absolute; right: max(8px, env(safe-area-inset-right)); top: 64px; display: flex; flex-direction: column; gap: 8px; }
.side { width: 60px; height: 60px; border: 3px solid var(--ink); border-radius: 18px; background: #fff; box-shadow: 0 4px 0 var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; position: relative; }
.side span { font-size: 25px; line-height: 1; }
.side small { font-size: 10px; font-weight: 900; margin-top: 2px; }
.side .badge { position: absolute; top: -8px; right: -8px; }
#bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 8px max(8px, env(safe-area-inset-bottom)); }
#tools { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.tool { border: 3px solid var(--ink); border-radius: 14px; background: #fff; box-shadow: 0 3px 0 var(--ink); font-size: 20px; padding: 3px 10px; display: flex; align-items: center; gap: 4px; }
.tool small { font-size: 12px; font-weight: 900; }
.tool.off { opacity: 0.5; }
.tool.ad { background: #bfe6ff; }
#boost-on { background: #bfe6ff; border: 3px solid var(--ink); border-radius: 14px; font-weight: 900; font-size: 14px; padding: 5px 10px; pointer-events: none; }
#seeds { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 6px; scrollbar-width: none; touch-action: pan-x; }
#seeds::-webkit-scrollbar { display: none; }
.seed { flex: 0 0 auto; width: 82px; border: 3px solid var(--ink); border-radius: 16px; background: #fff; box-shadow: 0 4px 0 var(--ink); padding: 3px 2px 4px; display: flex; flex-direction: column; align-items: center; }
.seed canvas { width: 52px; height: 46px; }
.seed b { font-size: 11px; font-weight: 900; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 76px; }
.seed small { font-size: 12px; font-weight: 900; }
.seed.sel { background: var(--yellow); transform: translateY(-4px); }
.seed.lock { background: #eee3d6; color: #a08a78; }
.seed.lock canvas { filter: grayscale(1) opacity(0.5); }
.seed.poor small { color: #d0453a; }
#banner { position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-size: clamp(30px, 8vw, 54px); font-weight: 900; color: #fff;
  -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); opacity: 0; transform: scale(0.6); pointer-events: none; }
#banner.show { animation: bannerin 2.2s forwards; }
@keyframes bannerin { 0% { opacity: 0; transform: scale(0.5); } 12% { opacity: 1; transform: scale(1.08); } 20% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-20px); } }
#hint { position: absolute; left: 50%; transform: translateX(-50%); background: #fff; border: 4px solid var(--ink); border-radius: 18px; padding: 8px 14px; font-weight: 900; font-size: 17px; box-shadow: 0 4px 0 var(--ink); white-space: nowrap; animation: hintbob 1.2s ease-in-out infinite; }
#hint::after { content: ''; position: absolute; left: 50%; bottom: -14px; margin-left: -10px; border: 10px solid transparent; border-top-color: var(--ink); border-bottom: 0; }
@keyframes hintbob { 50% { margin-top: -6px; } }

/* 친구 */
#friend-art, #pop-art { width: 200px; height: auto; aspect-ratio: 240 / 200; display: block; margin: 0 auto; }
#pop-art { aspect-ratio: 240 / 190; }
.boostbox { background: #e9fbe2; border: 3px solid var(--ink); border-radius: 14px; padding: 8px; font-weight: 800; font-size: 15px; margin: 8px auto; max-width: 320px; }
.hearts { font-size: 22px; letter-spacing: 2px; }
.hatrow { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 6px 0; }
.hatrow button { border: 3px solid var(--ink); border-radius: 12px; background: #fff; font-weight: 800; font-size: 13px; padding: 4px 8px; }
.hatrow button.on { background: var(--yellow); }
#pop-body { font-weight: 800; font-size: 16px; line-height: 1.45; }
#pop-body .big { font-size: 28px; font-weight: 900; color: #e08a00; }
.pop-in { animation: popin 0.35s cubic-bezier(.2,1.6,.4,1); }
@keyframes popin { from { transform: scale(0.4); opacity: 0; } }

/* 미션 · 출석 */
.mis { display: flex; align-items: center; gap: 10px; background: #fff; border: 4px solid var(--ink); border-radius: 16px; padding: 8px 10px; margin: 8px 0; text-align: left; }
.mis .mt { flex: 1; font-weight: 800; font-size: 15px; }
.mis .mt small { display: block; font-weight: 700; color: #7a6352; font-size: 12px; margin: 3px 0; }
.mis button { border: 3px solid var(--ink); border-radius: 12px; background: var(--yellow); font-weight: 900; font-size: 14px; padding: 7px 10px; white-space: nowrap; }
.mis button:disabled { background: #eee3d6; color: #a08a78; }
.mis.done { background: #e9fbe2; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin: 6px 0 8px; }
.cal div { background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 5px 2px; font-size: 11px; font-weight: 900; }
.cal div b { display: block; font-size: 12px; }
.cal div.got { background: #e9fbe2; color: #3a8a2f; }
.cal div.now { background: var(--yellow); transform: scale(1.08); }
.how { text-align: left; padding-left: 4px; list-style: none; font-size: 15px; line-height: 1.5; margin: 12px 0; }
.how li { margin: 6px 0; }

/* 알림 */
#toasts { position: fixed; top: calc(70px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: #fff4c2; border: 4px solid var(--ink); border-radius: 16px; padding: 7px 14px; font-weight: 900; font-size: 15px; box-shadow: 0 4px 0 var(--ink); animation: popin 0.35s cubic-bezier(.2,1.6,.4,1); white-space: nowrap; transition: opacity .4s; }
.toast.out { opacity: 0; }
#ad-block { position: fixed; inset: 0; z-index: 60; background: rgba(60,40,30,0.8); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 900; font-size: 22px; }

@media (max-width: 560px) {
  .pill { font-size: 15px; padding: 3px 9px; }
  #xpbar { width: 56px; }
  #weather { font-size: 13px; }
  .side { width: 50px; height: 50px; border-radius: 15px; } .side span { font-size: 21px; } .side small { font-size: 9px; }
  .seed { width: 70px; } .seed canvas { width: 44px; height: 40px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
  h2 { font-size: 22px; }
  #hint { font-size: 15px; }
}
@media (max-height: 520px) {
  #side { top: 54px; gap: 5px; } .side { width: 46px; height: 46px; } .side small { display: none; }
  .seed canvas { height: 34px; } .grid { max-height: 50vh; }
}
/* 세로 화면: 메뉴를 위쪽 한 줄로 (섬을 가리지 않게) */
@media (max-aspect-ratio: 4/5) {
  #side { top: calc(max(8px, env(safe-area-inset-top)) + 52px); left: 8px; right: 8px; flex-direction: row; justify-content: center; gap: 8px; }
  .side { width: 54px; height: 52px; }
  .side small { font-size: 9px; }
}
@media (max-aspect-ratio: 4/5) { #toasts { top: calc(124px + env(safe-area-inset-top)); } }

/* 도감 */
.dex { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 8px; max-height: 46vh; overflow-y: auto; margin: 8px 0; padding: 2px; }
.dexrow { display: flex; align-items: center; gap: 6px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 4px 8px; }
.dexrow b { width: 92px; font-size: 13px; text-align: left; line-height: 1.1; }
.dexrow .slot { width: 52px; height: 48px; border-radius: 10px; background: #f6efe2; position: relative; }
.dexrow .slot canvas { width: 52px; height: 46px; }
.dexrow .slot.no canvas { filter: brightness(0) opacity(0.18); }
.dexrow .slot small { position: absolute; bottom: -2px; left: 0; right: 0; font-size: 9px; font-weight: 900; color: #7a6352; }
.dexrow.full { background: #e9fbe2; }
.muts { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; margin: 6px 0; }
.muts div { background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 5px; font-weight: 900; font-size: 13px; }
.muts div span { display: block; font-size: 24px; }
.muts div.no { opacity: 0.45; }
.muts div.no span { filter: grayscale(1); }
#banner.rank { font-size: clamp(40px, 11vw, 78px); }
@media (max-width: 560px) { .dex { grid-template-columns: 1fr; } .dexrow b { width: 70px; } .dexrow .slot, .dexrow .slot canvas { width: 46px; height: 42px; } }
