/* 서체: 제목과 이름은 메이플스토리 Bold(넥슨코리아), 버튼과 대사는 동물의 숲 UI처럼 둥근 고딕인 나눔스퀘어라운드(네이버) */
@font-face { font-family: 'Maplestory'; src: url('https://fastly.jsdelivr.net/gh/projectnoonnu/noonfonts_20-04@2.1/MaplestoryOTFBold.woff') format('woff'); font-weight: normal; font-display: swap; }
@font-face { font-family: 'NanumSquareRound'; src: url('https://hangeul.pstatic.net/hangeul_static/webfont/NanumSquareRound/NanumSquareRoundR.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'NanumSquareRound'; src: url('https://hangeul.pstatic.net/hangeul_static/webfont/NanumSquareRound/NanumSquareRoundB.woff2') format('woff2'); font-weight: 700; font-display: swap; }
:root {
  --font-title: 'Maplestory', 'NanumSquareRound', 'Malgun Gothic', sans-serif;
  --font-ui: 'NanumSquareRound', 'Malgun Gothic', sans-serif;
  --paper: #fff8ec;
  --paper2: #f7ead2;
  --ink: #3b3226;
  --ink2: #6d5d48;
  --wood: #b9834f;
  --accent: #f08a5d;
  --sea: #2f8fa8;
  --shadow: 0 6px 18px rgba(30, 40, 60, 0.22);
  --r: 16px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #7ec8d8;
  font-family: var(--font-ui);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
.hidden { display: none !important; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#badge {
  position: absolute; left: 14px; top: 14px;
  background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 10px 14px 9px; pointer-events: auto; min-width: 210px;
  border: 2px solid #f1dfbf;
}
.b-title { font-family: var(--font-title); font-size: 19px; color: #4a3a28; letter-spacing: 0.5px; }
.b-title small { font-family: var(--font-ui); font-size: 12px; color: var(--ink2); margin-left: 4px; }
.b-row { display: flex; gap: 10px; align-items: center; margin-top: 4px; font-size: 14px; color: var(--ink2); }
#tName { font-family: var(--font-title); color: #2f7f94; font-size: 16px; }
#depth { color: #2f6fa0; }

#modeTip {
  position: absolute; left: 50%; top: 104px; transform: translateX(-50%);
  background: rgba(255, 248, 236, 0.92); border-radius: 999px; padding: 7px 16px;
  font-size: 14px; color: var(--ink2); box-shadow: var(--shadow);
  opacity: 0; transition: opacity 0.6s; white-space: nowrap;
}
#modeTip.show { opacity: 1; }

#dock {
  position: absolute; right: 14px; bottom: 14px; display: flex; gap: 8px; pointer-events: auto;
  background: rgba(255, 248, 236, 0.9); padding: 8px; border-radius: 20px; box-shadow: var(--shadow);
  border: 2px solid #f1dfbf;
}
#dock button {
  width: 62px; height: 60px; border: none; border-radius: 14px; cursor: pointer;
  background: var(--paper2); font-size: 22px; line-height: 1; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  transition: transform 0.12s, background 0.2s;
  font-family: var(--font-ui);
}
#dock button span { font-size: 12px; font-weight: 700; color: var(--ink2); }
#dock button:hover { transform: translateY(-2px); background: #fde9c8; }
#dock button:active { transform: translateY(1px); }
#dock button.on { background: #ffd9a8; box-shadow: inset 0 0 0 2px #f0a35e; }

#info {
  position: absolute; left: 14px; bottom: 14px; width: min(340px, calc(100% - 28px));
  background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 14px 16px 14px; pointer-events: auto; border: 2px solid #f1dfbf;
}
#info h3 { margin: 0 0 4px; font-family: var(--font-title); font-size: 20px; color: #4a3a28; font-weight: normal; }
#info p { margin: 4px 0 0; font-size: 14px; line-height: 1.55; color: var(--ink2); }
#info .tag { display: inline-block; font-size: 12px; background: #e9f5f0; color: #2f7f6a; border-radius: 999px; padding: 2px 8px; margin-top: 8px; }
.x {
  position: absolute; right: 8px; top: 8px; width: 28px; height: 28px; border-radius: 50%;
  border: none; background: var(--paper2); cursor: pointer; color: var(--ink2); font-size: 14px;
}

#nbr { color: #2f7f94; font-family: var(--font-title); display: inline-block; }
#nbr.pop { animation: pop 0.45s ease-out; }
#jelly { color: #c0577e; font-family: var(--font-title); display: inline-block; }
#jelly.pop { animation: pop 0.45s ease-out; }
#trash { color: #4f8a35; font-family: var(--font-title); display: inline-block; }
#trash.pop { animation: pop 0.45s ease-out; }
.b-row { flex-wrap: wrap; row-gap: 2px; }
#mood { display: inline-flex; align-items: center; gap: 5px; }
#mood .mbar { display: inline-block; width: 56px; height: 9px; border-radius: 999px; background: #f1dfbf; overflow: hidden; }
#mood .mbar i { display: block; height: 100%; width: 60%; border-radius: 999px; background: linear-gradient(90deg, #ffb3c7, #ff7f9f); transition: width 0.6s; }
#mood em { font-style: normal; font-family: var(--font-title); font-size: 14px; color: #c0577e; }

/* 거북과 이웃의 말풍선 */
#say, #say2 {
  position: absolute; left: 0; top: 0; max-width: min(460px, 80vw); width: max-content; text-align: center; word-break: keep-all;
  background: var(--paper); border: 2px solid #f1dfbf; border-radius: 16px; box-shadow: var(--shadow);
  padding: 8px 14px; font-size: 15px; line-height: 1.4; color: var(--ink);
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
#say.show, #say2.show { opacity: 1; }
#say::after, #say2::after {
  content: ''; position: absolute; left: 50%; bottom: -10px; margin-left: -9px;
  border-width: 10px 9px 0; border-style: solid; border-color: var(--paper) transparent transparent;
}
#say.pinned::after { display: none; }
#say.pinned::before { content: attr(data-who) ' '; font-family: var(--font-title); color: #2f7f94; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.45); } 100% { transform: scale(1); } }

#compass {
  position: absolute; left: 50%; top: 64px; transform: translateX(-50%);
  background: rgba(10, 30, 60, 0.72); color: #bff6ff; border-radius: 999px; padding: 6px 14px;
  font-size: 14px; display: flex; gap: 8px; align-items: center; border: 1px solid rgba(160, 240, 255, 0.4);
}
#compass .arrow { display: inline-block; font-size: 16px; color: #9ffcff; }

#toast {
  position: absolute; left: 50%; bottom: 96px; z-index: 3; max-width: calc(100% - 28px); text-align: center; transform: translateX(-50%);
  background: rgba(59, 50, 38, 0.86); color: #fff8ec; border-radius: 999px; padding: 8px 16px;
  font-size: 15px; opacity: 0; transition: opacity 0.4s; pointer-events: none; width: max-content;
}
#toast.show { opacity: 1; }

#joy {
  position: absolute; left: 22px; bottom: 22px; width: 132px; height: 132px; border-radius: 50%;
  background: rgba(255, 248, 236, 0.35); border: 2px solid rgba(255, 248, 236, 0.7);
  pointer-events: auto; touch-action: none;
}
#joyKnob {
  position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px;
  border-radius: 50%; background: rgba(255, 248, 236, 0.9); box-shadow: var(--shadow);
}

/* 겹창 */
.overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(20, 50, 70, 0.15), rgba(20, 40, 60, 0.45));
  z-index: 10; padding: 16px;
}
.card {
  position: relative; touch-action: pan-y; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  background: var(--paper); border-radius: 22px; box-shadow: 0 12px 40px rgba(20, 30, 50, 0.35);
  padding: 26px 28px; max-width: 560px; width: 100%; border: 3px solid #f1dfbf; text-align: center;
  max-height: calc(100vh - 32px); overflow: auto;
}
.card h2 { font-family: var(--font-title); font-weight: normal; margin: 0 0 12px; color: #4a3a28; }
.card table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; margin-bottom: 16px; }
.card th { width: 108px; color: #2f7f94; font-weight: normal; font-family: var(--font-title); padding: 6px 4px; vertical-align: top; }
.card td { color: var(--ink2); padding: 6px 4px; line-height: 1.45; }
.card tr + tr { border-top: 1px dashed #ead8b6; }

.title-card { padding: 34px 30px 26px; }
.logo small { display: block; font-size: clamp(12px, 3.5vw, 14px); color: var(--ink2); letter-spacing: 0.5px; word-break: keep-all; }
.logo h1 { font-family: var(--font-title); font-weight: normal; font-size: clamp(30px, 9.4vw, 46px); margin: 6px 0 2px; color: #3f6f7a; letter-spacing: 1px; white-space: nowrap;
  text-shadow: 0 3px 0 #f6d9a8; }
.logo .ver { display: inline-block; font-size: 12px; background: #ffe2b8; color: #a2643a; padding: 3px 10px; border-radius: 999px; }
.lead { font-size: 16px; color: var(--ink2); margin: 18px 0 20px; line-height: 1.6; word-break: keep-all; }
.tip { font-size: 13px; color: #8a7a62; margin: 14px 0 0; word-break: keep-all; }
.small { font-size: 12.5px; color: #8a7a62; margin: 8px 0; line-height: 1.5; word-break: keep-all; }
button.big {
  font-family: var(--font-title); font-size: 22px; border: none; border-radius: 999px; cursor: pointer;
  padding: 12px 36px; background: linear-gradient(#ffb27a, #f08a5d); color: #fff; box-shadow: 0 5px 0 #c8653c;
  transition: transform 0.1s;
}
button.big:active { transform: translateY(3px); box-shadow: 0 2px 0 #c8653c; }
button.big:disabled { filter: grayscale(0.6) brightness(1.05); cursor: wait; }

/* 일 버튼: 다가가면 나타난다 */
#act {
  position: absolute; right: 14px; bottom: 96px; min-width: 150px; max-width: calc(100% - 170px); min-height: 64px; padding: 8px 18px 8px 12px;
  display: flex; align-items: center; gap: 8px; overflow: hidden; pointer-events: auto; cursor: pointer;
  border: 3px solid #f0a35e; border-radius: 22px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow);
  font-family: var(--font-title); font-size: 17px; line-height: 1.2; text-align: left; word-break: keep-all; touch-action: manipulation;
}
#act i { font-style: normal; font-size: 28px; line-height: 1; }
#act em { font-family: var(--font-ui); font-style: normal; font-size: 11px; color: #8a7a62; margin-left: auto; padding-left: 6px; white-space: nowrap; }
#act .prog { position: absolute; left: 0; bottom: 0; height: 6px; width: 0; background: #f0a35e; }
#act.wait { border-color: #e4d4b6; background: #f6efe0; color: #8a7a62; cursor: default; }
#act.hot { border-color: #ff6a4d; background: #fff0da; animation: actPulse 0.42s ease-in-out infinite alternate; }
#act:active { transform: translateY(2px); }
@keyframes actPulse { from { transform: scale(1); } to { transform: scale(1.06); } }
body.touch #act em { display: none; }

/* 할 수 있는 곳 표시 */
.pin {
  position: absolute; left: 0; top: 0; width: 34px; height: 34px; border-radius: 50%; pointer-events: none;
  display: flex; align-items: center; justify-content: center; font-size: 18px; line-height: 1;
  background: rgba(255, 248, 236, 0.92); border: 2px solid #f0a35e; box-shadow: 0 2px 6px rgba(30, 40, 60, 0.25);
}

/* 다음 할 일 안내 */
#goal {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%); max-width: calc(100% - 28px); width: max-content;
  background: rgba(255, 248, 236, 0.94); border: 2px solid #f1dfbf; border-radius: 999px; padding: 6px 14px; box-shadow: var(--shadow);
  display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink2); word-break: keep-all;
}
#goal .arrow { display: inline-block; color: #f08a5d; font-size: 15px; line-height: 1; }

/* 판: 소리 크기, 낚시 기록, 편지 고르기 */
.panel {
  position: absolute; right: 14px; bottom: 96px; width: min(320px, calc(100% - 28px)); z-index: 4; pointer-events: auto;
  background: var(--paper); border: 2px solid #f1dfbf; border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px;
}
.panel h3 { margin: 0 0 8px; font-family: var(--font-title); font-weight: normal; font-size: 19px; color: #4a3a28; }
.slide { display: grid; grid-template-columns: 74px 1fr 34px; align-items: center; gap: 6px; font-size: 14px; color: var(--ink2); min-height: 48px; }
.slide b { font-weight: 700; font-size: 13px; text-align: right; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; margin: 0; background: transparent; cursor: pointer; touch-action: none; }
input[type=range]::-webkit-slider-runnable-track { height: 10px; border-radius: 999px; background: #f1dfbf; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; margin-top: -10px; border-radius: 50%; background: #f08a5d; border: 3px solid #fff8ec; box-shadow: 0 2px 5px rgba(30, 40, 60, 0.3); }
input[type=range]::-moz-range-track { height: 10px; border-radius: 999px; background: #f1dfbf; }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #f08a5d; border: 3px solid #fff8ec; box-shadow: 0 2px 5px rgba(30, 40, 60, 0.3); }
button.soft {
  font-family: var(--font-ui); font-size: 14px; font-weight: 700; border: none; border-radius: 12px; padding: 11px 14px; cursor: pointer;
  background: var(--paper2); color: var(--ink2); touch-action: manipulation;
}
button.soft:active { transform: translateY(1px); }
button.soft.on { background: #ffd9a8; box-shadow: inset 0 0 0 2px #f0a35e; }
#soundMute { width: 100%; margin-top: 4px; }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }

#cardBox { left: 50%; right: auto; transform: translateX(-50%); bottom: 96px; text-align: center; }
#cardArt { font-size: 40px; line-height: 1.2; }
#cardBox p { margin: 4px 0 12px; font-size: 14px; line-height: 1.5; color: var(--ink2); word-break: keep-all; }
#cardBtns { display: flex; flex-direction: column; gap: 8px; }
#cardBtns button { width: 100%; }

/* 이름 짓기 */
.overlay.top { align-items: flex-start; background: none; padding-top: max(16px, 4vh); }
.name-card { max-width: 440px; padding: 18px 20px; }
.name-card h2 { font-size: 20px; line-height: 1.35; margin-bottom: 10px; word-break: keep-all; }
#nameInput {
  width: 100%; height: 50px; font-family: var(--font-title); font-size: 20px; text-align: center; color: #2f7f94; background: #fff;
  border: 2px solid #e8d7b0; border-radius: 14px; outline: none; user-select: text; -webkit-user-select: text; touch-action: manipulation;
}
#nameInput:focus { border-color: #f0a35e; }
#nameErr { min-height: 18px; color: #c8604a; margin: 6px 0; }
#nameChips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
#nameChips button { font-family: var(--font-title); font-size: 15px; border: none; border-radius: 999px; padding: 9px 14px; background: var(--paper2); color: #4a3a28; cursor: pointer; touch-action: manipulation; }
#nameChips button.more { background: #e9f5f0; color: #2f7f6a; }
.name-card button.big { font-size: 19px; padding: 11px 26px; }
#tName { max-width: 11em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 기록 */
.journal-card h3 { font-family: var(--font-title); font-weight: normal; margin: 14px 0 6px; color: #4a3a28; font-size: 17px; }
#jStats { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 6px; }
#jStats div { background: var(--paper2); border-radius: 12px; padding: 8px 4px; font-size: 12.5px; color: var(--ink2); }
#jStats b { display: block; font-family: var(--font-title); font-weight: normal; font-size: 18px; color: #2f7f94; }
#jFish { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 6px; margin-bottom: 14px; }
#jFish div { background: #eef7f6; border-radius: 12px; padding: 7px 6px; font-size: 12.5px; color: var(--ink2); line-height: 1.35; word-break: keep-all; }
#jFish div.none { background: #f4efe4; color: #b3a68e; }
#jFish b { display: block; font-weight: 700; color: #2f6f7a; }

/* 모드별로 보이는 버튼 */
#hud[data-mode=walk] [data-show=sea], #hud[data-mode=boat] [data-show=sea] { display: none; }
#hud[data-mode=sea] [data-show=walk], #hud[data-mode=boat] [data-show=walk] { display: none; }

@media (max-width: 760px) {
  #badge { min-width: 0; padding: 8px 11px 7px; }
  .b-title { font-size: 16px; }
  #dock { gap: 4px; padding: 5px; right: 8px; bottom: 8px; max-width: calc(100% - 16px); }
  #dock button { width: 44px; height: 50px; font-size: 19px; flex: 0 1 44px; min-width: 0; }
  #dock button span { font-size: 10px; white-space: nowrap; letter-spacing: -0.5px; }
  .title-card { padding: 26px 18px 22px; }
  #help .card { padding: 18px 14px; }
  .card table { font-size: 13px; margin-bottom: 8px; }
  .card th { width: 76px; font-size: 13px; }
  .lead { font-size: 15px; }
  #act { right: 8px; bottom: 80px; max-width: calc(100% - 150px); min-width: 0; font-size: 15px; min-height: 60px; }
  .panel { right: 8px; bottom: 80px; }
  #cardBox { bottom: 80px; }
  #toast { bottom: 150px; font-size: 14px; }
  #goal { top: 108px; font-size: 13px; }
  #info { top: 138px; bottom: auto; }
  #joy { bottom: 84px; left: 14px; width: 116px; height: 116px; }
  #modeTip { top: 196px; white-space: normal; width: max-content; max-width: calc(100% - 28px); text-align: center; }
  #compass { top: 116px; }
  #say, #say2 { font-size: 14px; max-width: 76vw; }
  .pin { width: 30px; height: 30px; font-size: 16px; }
}

/* 다 자란 거북에서 아기 거북으로 넘어갈 때 잠깐 물빛으로 */
#fade { position: fixed; inset: 0; background: #bfe6ee; opacity: 0; pointer-events: none; transition: opacity 0.42s ease; z-index: 30; }
#fade.on { opacity: 1; }
/* 등에 따개비가 오기 전에는 마을 구경이 없다 */
#hud[data-friend="0"] #btnWalk { display: none; }

/* 처음 와 본 곳의 이름 */
#place { position: absolute; left: 50%; top: 16%; transform: translate(-50%, 8px); text-align: center; pointer-events: none; opacity: 0; transition: opacity 0.6s ease, transform 0.6s ease; color: #fffdf6; text-shadow: 0 2px 10px rgba(10, 40, 60, 0.75); width: 90vw; }
#place.show { opacity: 1; transform: translate(-50%, 0); }
#place b { display: block; font-family: var(--font-title); font-size: 34px; font-weight: normal; letter-spacing: 0.02em; }
#place span { display: block; margin-top: 2px; font-size: 15px; word-break: keep-all; }
/* 못 가 본 곳 표시 */
.mapPin { position: absolute; left: 0; top: 0; padding: 3px 9px; border-radius: 14px; background: rgba(255, 250, 238, 0.86); color: #3a5a66; font-size: 12px; font-weight: 700; pointer-events: none; white-space: nowrap; box-shadow: 0 2px 6px rgba(20, 50, 70, 0.25); }

/* 넓은 화면의 시작 화면: 카드는 왼쪽에 */
@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  #start { justify-content: flex-start; padding-left: 6vw; background: none; }
  #start .title-card { max-width: 440px; }
}

/* 곳 이름 배너를 안내 줄에서 띄운다 (휴대폰) */
@media (max-width: 600px) {
  #place { top: calc(16% + 18px); }
  #modeTip { top: 224px; }
}
