:root {
  --wall: #e8e1d3;
  --ink: #2b2723;
  --muted: #7a7166;
  --panel: #fffdf8;
  --line: #d9d0bf;
  --accent: #d64933;
}
* { box-sizing: border-box; }
/* 길게 눌러도 글자 선택·돋보기·메뉴가 뜨지 않게 (휴대폰) */
html, body, canvas, button, .toolbar, .navi, .title, .hint { -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
input { -webkit-user-select: text; user-select: text; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--wall); color: var(--ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='48'%3E%3Cpath d='M6 14q4-4 8 0t8 0M42 38q4-4 8 0t8 0' fill='none' stroke='%23c9bda8' stroke-width='1.4' stroke-linecap='round' opacity='.55'/%3E%3C/svg%3E");
  font-family: 'Gaegu', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif; }
#board { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; cursor: crosshair; }
#board.zoomin { cursor: zoom-in; }
#board.hand { cursor: grab; }
#board.hand.dragging { cursor: grabbing; }

.title { position: fixed; top: 16px; left: 20px; pointer-events: none; }
.title h1 { margin: 0; font-size: 34px; font-weight: 700; line-height: 1; transform: rotate(-2deg); }
.title p { margin: 6px 0 0 4px; font-size: 18px; color: var(--muted); }
.title h1, .title p { position: relative; }
.doodles { position: absolute; left: -8px; top: -6px; width: 400px; height: 120px; overflow: visible; }
.doodles path { fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 400; stroke-dashoffset: 400;
  animation: scribble 1.1s ease-out forwards; }
.doodles .d2 { animation-delay: .5s; } .doodles .d3 { animation-delay: .8s; } .doodles .d4 { animation-delay: 1.1s; } .doodles .d5 { animation-delay: 1.4s; }
.doodles .d2 { fill: #e9c04633; } .doodles .d3 { fill: #e07fae2e; }
.doodles .d6 { display: none; animation-delay: .9s; }   /* 휴대폰 전용: 부제목 아래에서 지도로 내려가는 화살표 */
@keyframes scribble { to { stroke-dashoffset: 0; } }

.status { position: fixed; top: 20px; right: 20px; display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1.5px solid var(--line); border-radius: 999px; padding: 4px 14px 4px 10px; font-size: 18px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #bbb; }
.dot.on { background: #3fa34d; box-shadow: 0 0 0 3px #3fa34d33; }

.toolbar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; gap: 6px; align-items: center;
  background: var(--panel); border: 1.5px solid var(--line); border-radius: 18px; padding: 6px;
  box-shadow: 0 6px 24px #5a4a3022; max-width: calc(100vw - 32px); overflow-x: auto; scrollbar-width: none; }
.toolbar::-webkit-scrollbar { display: none; }
.group { display: flex; gap: 4px; align-items: center; padding: 0 4px; }
.group + .group { border-left: 1.5px solid var(--line); padding-left: 10px; }
.toolbar button { flex: none; width: 40px; height: 40px; border: 0; border-radius: 12px; background: transparent; color: var(--ink);
  display: grid; place-items: center; cursor: pointer; padding: 0; }
.toolbar button:hover { background: #f1ebdf; }
.toolbar button.active { background: var(--ink); color: var(--panel); }
.toolbar button[hidden] { display: none; }
.toolbar button.danger { color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.toolbar button.danger:hover { background: #fbe9e5; }

.credit { position: fixed; left: 12px; bottom: 6px; font-family: "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; font-size: 10.5px; color: var(--muted); opacity: .8; }
.credit a { color: inherit; }
@media (max-width: 600px) { .credit { bottom: auto; top: 76px; left: 16px; font-size: 9.5px; } }

/* 확인창 */
.dialog { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: #2b272355; padding: 16px; }
.dialog[hidden] { display: none; }
.dialog > div { background: var(--panel); border: 1.5px solid var(--line); border-radius: 16px; padding: 20px 20px 16px; width: min(340px, 100%);
  box-shadow: 0 12px 40px #2b272333; font-family: "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; }
.dialog h2 { margin: 0 0 6px; font-size: 17px; }
.dialog p { margin: 0 0 16px; font-size: 14px; color: var(--muted); line-height: 1.5; }
.dialog input { width: 100%; font: inherit; font-size: 15px; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px; margin: -6px 0 14px; }
.dialog .row { display: flex; gap: 8px; justify-content: flex-end; }
.dialog button { font: inherit; font-size: 14px; font-weight: 600; border-radius: 10px; padding: 8px 14px; cursor: pointer; border: 1.5px solid var(--line); background: #fff; color: var(--ink); }
.dialog button.ok { background: var(--accent); border-color: var(--accent); color: #fff; }
.dialog button.ok:disabled { opacity: .4; cursor: default; }
.toast { position: fixed; left: 50%; top: 20px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--panel);
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; font-size: 14px; padding: 8px 16px; border-radius: 999px; transition: opacity .4s; }
.toast.hide { opacity: 0; pointer-events: none; }
.toolbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.colors button { width: 30px; height: 30px; border-radius: 50%; }
.colors button span { width: 22px; height: 22px; border-radius: 50%; display: block; box-shadow: inset 0 0 0 1px #0002; }
.colors button.active { background: transparent; box-shadow: 0 0 0 2px var(--ink); }
.colors label { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; position: relative;
  background: conic-gradient(#e53, #fc3, #5c5, #3be, #75f, #e4a, #e53); }
.colors label.active { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--ink); }
.colors input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; }

.sizes button span { display: block; border-radius: 50%; background: currentColor; }
.sizes button.active { background: #f1ebdf; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }

.hint { position: fixed; left: 50%; bottom: 82px; transform: translateX(-50%); font-size: 17px; color: var(--muted);
  background: #fffdf8cc; padding: 2px 12px; border-radius: 999px; transition: opacity .6s; pointer-events: none; white-space: nowrap; }
.hint.hide { opacity: 0; }
/* 못 그리는 상태: 안내를 눈에 띄게 고정, 펜·색·굵기는 흐리게 */
.hint.locked { z-index: 20; color: #fff; background: #2b2723e6; font-weight: 700; padding: 5px 16px; }
.hint.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(calc(-50% - 6px)); } 40%, 80% { transform: translateX(calc(-50% + 6px)); } }
body.nodraw .colors, body.nodraw .sizes { opacity: .3; filter: grayscale(.6); }
body.nodraw .tool[data-tool=pen] { opacity: .4; position: relative; }
body.nodraw .tool[data-tool=pen]::after { content: '🔒'; position: absolute; right: 1px; bottom: 0; font-size: 12px; }
body.nodraw .tool[data-tool=pen].active { background: #8a8178; }

/* 미니맵 + 확대/축소 */
.navi { position: fixed; right: 16px; bottom: 88px; background: var(--panel); border: 1.5px solid var(--line); border-radius: 16px;
  padding: 8px 10px 8px 8px; box-shadow: 0 6px 24px #5a4a3022; display: flex; flex-direction: column; gap: 6px; }
.place { font-family: "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; font-size: 13px; font-weight: 600; color: var(--ink);
  max-width: 190px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 2px; }
.navi-body { display: flex; gap: 6px; align-items: flex-start; }
.zoom { display: flex; flex-direction: column; gap: 4px; }
.zoom button { width: 32px; height: 32px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
  display: grid; place-items: center; cursor: pointer; padding: 0; }
.zoom button:hover { background: #f1ebdf; }
.zoom button:disabled { opacity: .35; cursor: default; }
.zoom svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#mini { width: 140px; height: 148px; display: block; border-radius: 8px; background: #efe9dd; cursor: pointer; touch-action: none; }
.scale { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); padding-left: 2px; pointer-events: none; }
.scale i { display: block; height: 6px; border: 1.5px solid var(--muted); border-top: 0; transition: width .15s; }
.scale b { font-weight: 400; }

@media (max-width: 600px) {
  .navi { top: 80px; bottom: auto; right: 12px; padding: 6px; gap: 4px; border-radius: 12px; }
  #mini { width: 84px; height: 89px; }
  .zoom { display: grid; grid-template-columns: 28px 28px; gap: 4px; align-content: start; }
  .zoom button { width: 28px; height: 28px; border-radius: 8px; }
  .place { max-width: 118px; font-size: 12px; }
  .scale { font-size: 12px; }
}
@media (max-width: 600px) {
  .title { top: 12px; left: 16px; }
  .title h1 { font-size: 26px; }
  .doodles { transform: scale(.78); transform-origin: 0 0; }
  .doodles .d3, .doodles .d4, .doodles .d5 { display: none; }   /* 휴대폰: 오른쪽 위 상태 표시와 겹치지 않게 */
  .doodles .d6 { display: inline; }
  .title p { font-size: 15px; }
  .status { top: 14px; right: 16px; font-size: 15px; }
  /* 휴대폰: 도구를 두 줄로 (위: 펜·굵기·지우기, 아래: 색) — 가로 스크롤 없이 한눈에 */
  .toolbar { bottom: 10px; flex-wrap: wrap; justify-content: center; overflow: visible; row-gap: 6px;
    width: calc(100vw - 20px); max-width: 400px; padding: 6px 4px; border-radius: 16px; }
  .toolbar > .group { order: 1; }
  .toolbar > .colors { order: 2; flex-basis: 100%; justify-content: center; border-left: 0; padding: 6px 0 0;
    border-top: 1.5px solid var(--line); gap: 5px; }
  .toolbar button { width: 34px; height: 36px; }
  .colors button, .colors label { width: 30px; height: 30px; }
  .toolbar > .group { padding: 0 2px; gap: 2px; }
  .group + .group { padding-left: 4px; }
  .hint { bottom: 122px; font-size: 14px; }
}
@media (max-width: 350px) {
  .toolbar button { width: 32px; height: 32px; }
  .colors button, .colors label { width: 27px; height: 27px; }
  .colors button span { width: 20px; height: 20px; }
  .toolbar > .colors { gap: 3px; }
}

/* 그리기 설정 */
.prefs { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); z-index: 30; background: var(--panel);
  border: 1.5px solid var(--line); border-radius: 16px; padding: 12px 14px 8px; box-shadow: 0 8px 28px #5a4a3033;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; font-size: 13px; width: min(330px, calc(100vw - 24px)); }
.prefs[hidden] { display: none; }
.prow { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.prow > span { color: var(--ink); font-weight: 600; white-space: nowrap; }
.seg { display: flex; background: #efe9dd; border-radius: 10px; padding: 2px; }
.seg button { font: inherit; font-size: 12.5px; border: 0; background: transparent; color: var(--muted); padding: 5px 10px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px #0002; }
.ptip { margin: 2px 0 2px; color: var(--muted); font-size: 12px; }
@media (max-width: 600px) { .prefs { bottom: 124px; } }
/* 그리는 동안: 도구·미니맵을 흐리게 (화면을 넓게) */
.toolbar, .navi { transition: opacity .2s; }
body.drawing-now .toolbar, body.drawing-now .navi, body.drawing-now .hint { opacity: .18; pointer-events: none; }

/* 위쪽 공유하기 버튼 (접속자 표시 옆) */
.share-top { display: inline-flex; align-items: center; justify-content: center; gap: 4px; margin-left: 6px; width: 30px; height: 26px; padding: 0; border: 0; border-radius: 999px;
  background: var(--accent); color: #fff; font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; }
.share-top:hover { filter: brightness(1.06); }
.share-top svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.status { padding-right: 4px; }
@media (max-width: 600px) {
  .doodles .d2 { display: none; }   /* 휴대폰: 공유 버튼과 겹치지 않게 별 숨김 */
}
@media (max-width: 400px) { .status .long { display: none; } }   /* 좁은 휴대폰: '3명'만 */

/* 지난 낙서판 */
.hist-btn { display: inline-flex; align-items: center; justify-content: center; margin-left: 6px; width: 30px; height: 26px; padding: 0;
  border: 1.5px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); cursor: pointer; }
.hist-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.share-top { margin-left: 4px; }
.history { position: fixed; top: 60px; right: 16px; z-index: 40; width: min(300px, calc(100vw - 24px)); max-height: min(70vh, 520px); overflow: auto;
  background: var(--panel); border: 1.5px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: 0 10px 32px #5a4a3033;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; }
.history[hidden] { display: none; }
.history h3 { margin: 0 0 4px; font-size: 15px; }
.hnote { margin: 0 0 10px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.hlist { display: flex; flex-direction: column; gap: 6px; }
.hitem { display: block; padding: 9px 12px; border-radius: 12px; background: #f6f1e7; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 14px; }
.hitem small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }
.hitem:hover { background: #efe6d6; }
.hitem.on { background: var(--ink); color: var(--panel); }
.hitem.on small { color: #d9d0bf; }
.archive-banner { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20; display: flex; gap: 12px; align-items: center;
  background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 999px; box-shadow: 0 6px 24px #2b272344;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; font-size: 14px; white-space: nowrap; max-width: calc(100vw - 20px); }
.archive-banner[hidden] { display: none; }
.archive-banner b { overflow: hidden; text-overflow: ellipsis; }
.archive-banner a { color: #ffd38a; font-weight: 700; text-decoration: none; }
body.archive .toolbar, body.archive .hint { display: none; }
@media (max-width: 600px) { .history { top: 56px; right: 10px; } .archive-banner { font-size: 13px; bottom: 14px; } }

/* 이번 주 낙서한 사람 수 */
.title p.people { margin-top: 2px; font-size: 16px; color: #c8664f; font-weight: 700; }
.title p.people:empty { display: none; }
@media (max-width: 600px) { .title p.people { font-size: 13.5px; } }

/* '낙서 중' = 누르면 낙서하는 곳으로 날아가는 버튼처럼 */
.watch { display: inline-flex; align-items: center; gap: 7px; padding: 2px 8px 2px 6px; margin-left: -4px; border-radius: 999px;
  background: #f1ebdf; border: 1.5px dashed #cdbfa8; cursor: pointer; transition: background .15s, border-color .15s; outline: none; }
.watch:hover, .watch:focus-visible { background: #e9f4ea; border-color: #3fa34d; border-style: solid; }
.watch:active { transform: scale(.96); }
.watch .eye { width: 16px; height: 16px; fill: none; stroke: #3f7d4a; stroke-width: 2; stroke-linejoin: round; }
body.archive .watch { cursor: default; border-style: solid; }
body.archive .watch .eye { display: none; }
/* 다른 사람이 있으면 초록 점이 두근두근 */
.dot.on.busy { animation: beat 1.6s ease-in-out infinite; }
@keyframes beat { 0%, 100% { box-shadow: 0 0 0 3px #3fa34d33; } 50% { box-shadow: 0 0 0 7px #3fa34d22; } }
/* 처음 한 번 알려주는 말풍선 */
.status { z-index: 46; }
.coach { position: fixed; top: 0; right: 12px; width: max-content; max-width: min(260px, calc(100vw - 24px)); background: var(--ink); color: var(--panel);
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; font-size: 13px; line-height: 1.4; padding: 8px 12px; border-radius: 12px;
  box-shadow: 0 6px 20px #2b272344; animation: pop .35s ease-out; cursor: pointer; z-index: 45; }
.coach::before { content: ''; position: absolute; top: -6px; left: calc(var(--ax, 28px) - 6px); border: 6px solid transparent; border-top: 0; border-bottom-color: var(--ink); }
.coach[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.96); } }

/* 둘러보기: 초록 칩으로 확실히 버튼처럼 */
.watch { background: transparent; border: 0; padding: 0 0 0 2px; margin-left: 0; gap: 6px; }
.watch:hover, .watch:focus-visible { background: transparent; }
.watch .go { display: inline-flex; align-items: center; gap: 4px; background: #3fa34d; color: #fff; border-radius: 999px;
  padding: 2px 10px 2px 7px; font-weight: 700; font-size: 15px; box-shadow: 0 2px 0 #2c7a37; transition: transform .1s, box-shadow .1s; }
.watch .go b { font-weight: 700; }
.watch .go .eye { stroke: #fff; width: 15px; height: 15px; animation: peek 5s ease-in-out infinite; }
.watch:hover .go { background: #36923f; }
.watch:active .go { transform: translateY(2px); box-shadow: 0 0 0 #2c7a37; }
@keyframes peek { 0%, 88%, 100% { transform: scaleY(1); } 92% { transform: scaleY(.15); } }
body.archive .watch .go { display: none; }
@media (max-width: 600px) { .watch .go { font-size: 13px; padding: 2px 8px 2px 6px; } }
@media (max-width: 360px) { .watch .go b { display: none; } }

/* 둘러보기: 글자 없이 눈 아이콘만 */
.watch .go b { display: none; }
.watch .go { padding: 3px 7px; }
