/* =====================================================================
   화면 꾸미기 (색, 버튼, 메뉴 창 모양)
   ===================================================================== */
:root {
  --green: #5aa845;
  --green-dark: #3f7d30;
  --cream: #fffaf0;
  --ink: #2d2a26;
  --muted: #7a736a;
  --line: #e6dccb;
  --accent: #f0a93b;
  --danger: #d9534f;
  --panel-bg: #fffdf8;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  color: var(--ink);
  background: #7cc35f;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
.hidden { display: none !important; }

button {
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
}
button:hover { filter: brightness(0.97); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--green); border-color: var(--green-dark); color: #fff; font-weight: 700; }
button.danger { background: #fff; border-color: var(--danger); color: var(--danger); }
button.small { padding: 5px 10px; font-size: 13px; border-radius: 9px; }

input, select {
  font: inherit;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  margin-top: 6px;
}

/* ---------- 입장 화면들 ---------- */
.screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: linear-gradient(#bfe6ff, #dff3c8 60%, #9ed27f);
  overflow-y: auto;
  touch-action: auto;
}
.card {
  background: var(--cream);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  padding: 24px;
  width: 100%;
  max-width: 380px;
  margin: auto;
}
.card.wide { max-width: 520px; }
.card.center { text-align: center; }
.card h1 { margin: 4px 0; font-size: 24px; text-align: center; }
.card h2 { margin: 0 0 12px; font-size: 20px; text-align: center; }
.card label { display: block; margin: 14px 0; font-weight: 600; font-size: 14px; }
.card .primary { width: 100%; margin-top: 6px; padding: 13px; }
.logo { font-size: 44px; text-align: center; }
.sub { text-align: center; color: var(--muted); margin: 4px 0 10px; }
.err { color: var(--danger); min-height: 20px; font-size: 14px; margin: 6px 0; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

#avatar-preview {
  display: block; margin: 0 auto 8px;
  background: radial-gradient(#e8f6dc, #cbe8b3);
  border-radius: 16px;
}
.opt-group { margin: 10px 0; }
.opt-group .opt-title { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.opt-list { display: flex; flex-wrap: wrap; gap: 6px; }
.opt {
  padding: 6px 10px; border-radius: 10px; font-size: 13px;
  border: 2px solid var(--line); background: #fff;
}
.opt.selected { border-color: var(--green); background: #eef8e8; font-weight: 700; }
.opt.swatch { width: 34px; height: 34px; padding: 0; border-radius: 50%; }
.opt.swatch.selected { box-shadow: 0 0 0 3px var(--green); border-color: #fff; }

/* ---------- 게임 화면 ---------- */
#game { position: fixed; inset: 0; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  padding: 10px; padding-top: max(10px, env(safe-area-inset-top));
  pointer-events: none;
}
#hud > * { pointer-events: auto; }
#hud-me {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 253, 248, 0.92);
  border-radius: 14px; padding: 6px 12px 6px 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  font-size: 14px;
}
#hud-avatar { background: #e8f6dc; border-radius: 10px; }
#hud-stats { font-size: 12px; color: var(--muted); margin-top: 2px; }
#hud-menu { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
#hud-menu button {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  font-size: 20px; padding: 6px 8px; min-width: 52px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
#hud-menu button span { font-size: 11px; margin-top: 1px; }
.dot { position: absolute; top: 4px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); }

#online {
  position: absolute; left: 10px; top: 72px;
  background: rgba(0, 0, 0, 0.35); color: #fff;
  font-size: 12px; padding: 3px 9px; border-radius: 10px;
}
#help {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.35); color: #fff; font-size: 12px;
  padding: 4px 10px; border-radius: 10px; white-space: nowrap;
}
body.touch #help { display: none; }

#announce {
  position: absolute; top: 110px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, #ffe08a, #ffb84d);
  color: #4a3200; font-weight: 800; font-size: 17px;
  padding: 14px 22px; border-radius: 16px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  text-align: center; max-width: calc(100% - 32px);
  animation: pop 0.4s ease-out;
}
@keyframes pop { from { transform: translateX(-50%) scale(0.7); opacity: 0; } }

#toasts {
  position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; align-items: center; gap: 6px;
  pointer-events: none; width: calc(100% - 32px);
}
.toast {
  background: rgba(30, 30, 30, 0.82); color: #fff;
  padding: 8px 14px; border-radius: 12px; font-size: 14px;
  animation: toastIn 0.2s ease-out; text-align: center; max-width: 100%;
}
.toast.good { background: rgba(46, 125, 50, 0.92); }
.toast.bad { background: rgba(160, 50, 40, 0.9); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

#btn-action {
  position: absolute; right: 20px; bottom: max(26px, env(safe-area-inset-bottom));
  min-width: 96px; min-height: 96px; border-radius: 50%;
  background: var(--accent); border: 4px solid #fff; color: #fff;
  font-weight: 800; font-size: 15px; line-height: 1.2; padding: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  max-width: 130px; word-break: keep-all;
}
#btn-action:active { transform: scale(0.95); }
#btn-action.wait { background: #b7a89a; }
body:not(.touch) #btn-action {
  border-radius: 16px; min-height: 0; min-width: 0; max-width: none;
  bottom: 44px; right: 50%; transform: translateX(50%);
  padding: 10px 18px; font-size: 15px;
}
body:not(.touch) #btn-action::after { content: " (Space)"; font-weight: 400; opacity: 0.85; }

#joystick {
  position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.6);
  pointer-events: none;
}
#joy-knob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.85);
}

/* ---------- 메뉴 창 ---------- */
#panel {
  position: absolute; inset: 0; background: rgba(0, 0, 0, 0.3);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  touch-action: auto;
}
.panel-box {
  background: var(--panel-bg); border-radius: 18px;
  width: 100%; max-width: 480px; max-height: calc(100% - 20px);
  display: flex; flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.panel-head h3 { margin: 0; font-size: 18px; }
#panel-close { border: none; background: none; font-size: 20px; padding: 4px 8px; }
#panel-body { padding: 14px 16px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#panel-body h4 { margin: 16px 0 8px; font-size: 15px; }
#panel-body h4:first-child { margin-top: 0; }
.muted { color: var(--muted); font-size: 13px; }

.mat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mat {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 8px; text-align: center;
}
.mat .e { font-size: 22px; }
.mat .n { font-size: 12px; color: var(--muted); }
.mat .v { font-weight: 800; font-size: 16px; }

.bar { height: 12px; background: #eee6d8; border-radius: 6px; overflow: hidden; margin: 4px 0; }
.bar > i { display: block; height: 100%; background: var(--green); border-radius: 6px; }
.bar.gold > i { background: var(--accent); }

.cost-row { display: grid; grid-template-columns: 90px 1fr 92px; align-items: center; gap: 8px; font-size: 13px; margin: 6px 0; }
.cost-row .num { text-align: right; font-variant-numeric: tabular-nums; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 800; margin-top: 2px; }

.list { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.list li:last-child { border-bottom: none; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 8px; background: #eee6d8; color: var(--muted); }
.tag.on { background: #dff1d6; color: var(--green-dark); }
.tag.bad { background: #f8dcda; color: var(--danger); }
.tag.admin { background: #fff0cc; color: #8a5d00; }

.floors { display: flex; flex-direction: column-reverse; gap: 4px; }
.floor-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.floor-row .cells { display: flex; gap: 3px; }
.floor-row .cell { width: 18px; height: 14px; border-radius: 3px; background: #e6dccb; }
.floor-row .cell.on { background: #c98e5a; }
.floor-row .cell.next { background: repeating-linear-gradient(45deg, #f0a93b, #f0a93b 3px, #fff3dc 3px, #fff3dc 6px); }
.floor-row .fname { width: 130px; flex-shrink: 0; }

.inline-form { display: flex; gap: 6px; margin-top: 8px; }
.inline-form input, .inline-form select { margin-top: 0; }
.inline-form button { flex-shrink: 0; }

.milestones { display: flex; gap: 6px; flex-wrap: wrap; }
.milestone { flex: 1; min-width: 70px; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; font-size: 12px; }
.milestone.done { background: #fff3dc; border-color: var(--accent); }
.milestone b { display: block; font-size: 15px; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { flex: 1; padding: 8px; }
.tabs button.on { background: var(--green); color: #fff; border-color: var(--green-dark); }

/* ---------- 2차: 방, 꾸미기, 옷장 ---------- */
#room-bar {
  position: absolute; left: 50%; transform: translateX(-50%); top: 96px;
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 253, 248, 0.94); border-radius: 14px; padding: 6px 8px 6px 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); white-space: nowrap; font-size: 14px;
}
#room-bar button { padding: 6px 10px; font-size: 13px; }

#decor {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: rgba(255, 253, 248, 0.97); border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.18);
  padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  touch-action: auto;
}
#decor-hint { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
#decor-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
#decor-actions:empty { display: none; }
#decor-list { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.decor-item {
  flex-shrink: 0; width: 76px; padding: 4px; border-radius: 12px; border: 2px solid var(--line);
  background: #fff; text-align: center; font-size: 11px; position: relative;
}
.decor-item.selected { border-color: var(--accent); background: #fff3dc; }
.decor-item .cnt { position: absolute; top: 2px; right: 6px; font-weight: 800; font-size: 12px; }
body.editing #btn-action, body.editing #help { display: none !important; }
body.editing #toasts { bottom: 210px; }

.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.item-card {
  position: relative; background: #fff; border: 2px solid var(--line); border-radius: 12px;
  padding: 6px 4px; text-align: center; font-size: 12px; cursor: pointer;
}
.item-card.equipped { border-color: var(--green); background: #eef8e8; }
.item-card.locked { opacity: 0.45; }
.item-card canvas, .decor-item canvas { display: block; margin: 0 auto 2px; }
.item-card .rar { font-size: 10px; font-weight: 700; }
.item-card .qty { position: absolute; top: 3px; right: 6px; font-weight: 800; }
.item-card button { margin-top: 4px; width: 100%; }

.slot-row { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.slot-row button { padding: 6px 10px; font-size: 13px; }
.slot-row button.on { background: var(--green); color: #fff; border-color: var(--green-dark); }

.box-card { display: flex; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.box-card .big { font-size: 40px; }
.box-card .info { flex: 1; }
.box-card .btns { display: flex; flex-direction: column; gap: 6px; }
.box-result { text-align: center; background: #fff8e6; border: 2px solid var(--accent); border-radius: 14px; padding: 12px; margin-bottom: 12px; animation: pop2 0.35s ease-out; }
@keyframes pop2 { from { transform: scale(0.7); opacity: 0; } }
.odds { width: 100%; border-collapse: collapse; font-size: 13px; }
.odds td, .odds th { padding: 5px 4px; border-bottom: 1px solid var(--line); text-align: left; }

.wallet { display: flex; gap: 10px; flex-wrap: wrap; font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.wallet span { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 5px 10px; }

.quest { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.quest.done { background: #eef8e8; border-color: #b7dfa6; }
.quest .qtop { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.quest .qreward { font-size: 12px; color: var(--muted); white-space: nowrap; }

.award-cat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.award-cat .names { font-weight: 800; margin-top: 4px; }

/* ---------- 3차: 채팅, 벽화 ---------- */
#btn-chat {
  position: absolute; left: 12px; bottom: max(14px, env(safe-area-inset-bottom));
  width: 48px; height: 48px; border-radius: 50%; padding: 0; font-size: 22px;
  background: rgba(255, 253, 248, 0.94); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
#chat {
  position: absolute; left: 12px; bottom: 70px; width: min(360px, calc(100% - 140px));
  pointer-events: none; display: flex; flex-direction: column; gap: 6px;
}
#chat.open { pointer-events: auto; width: min(420px, calc(100% - 24px)); }
#chat-log { display: flex; flex-direction: column; gap: 3px; max-height: 40vh; overflow-y: auto; }
#chat.open #chat-log { background: rgba(0, 0, 0, 0.45); border-radius: 12px; padding: 8px; }
.chat-line {
  color: #fff; font-size: 13px; line-height: 1.35; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  background: rgba(0, 0, 0, 0.28); border-radius: 8px; padding: 2px 8px; align-self: flex-start;
  transition: opacity 0.6s; word-break: break-all;
}
#chat.open .chat-line { background: none; padding: 1px 2px; }
.chat-line.old { opacity: 0; }
#chat.open .chat-line.old { opacity: 1; }
.chat-line b { color: #ffe680; margin-right: 4px; }
.chat-line .rep { display: none; margin-left: 6px; border: none; background: none; padding: 0 2px; font-size: 12px; cursor: pointer; }
#chat.open .chat-line .rep { display: inline; }
#chat-form { display: flex; gap: 6px; }
#chat-form input { margin: 0; }
body.editing #chat, body.editing #btn-chat { display: none; }
body.touch #toasts { bottom: 140px; }

.mural-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.note {
  border-radius: 6px; padding: 10px 10px 6px; min-height: 96px; display: flex; flex-direction: column;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12); font-size: 14px; word-break: break-all;
}
.note .txt { flex: 1; white-space: pre-wrap; }
.note .meta { font-size: 11px; color: rgba(0, 0, 0, 0.55); margin-top: 6px; }
.note .acts { display: flex; gap: 4px; margin-top: 6px; }
.note .acts button { padding: 3px 7px; font-size: 12px; border-radius: 8px; background: rgba(255, 255, 255, 0.7); }
.note .acts button.on { background: #ffd6de; border-color: #ff8fab; }
.colors { display: flex; gap: 6px; }
.colors button { width: 30px; height: 30px; border-radius: 50%; padding: 0; border: 2px solid var(--line); }
.colors button.on { box-shadow: 0 0 0 3px var(--green); border-color: #fff; }

/* ---------- 4차: 미니게임, 감정 표현, 해금, 시즌 ---------- */
#btn-emote {
  position: absolute; left: 68px; bottom: max(14px, env(safe-area-inset-bottom));
  width: 48px; height: 48px; border-radius: 50%; padding: 0; font-size: 22px;
  background: rgba(255, 253, 248, 0.94); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
#emote-bar {
  position: absolute; left: 12px; bottom: 72px; display: flex; flex-wrap: wrap; gap: 4px; max-width: 280px;
  background: rgba(255, 253, 248, 0.96); border-radius: 14px; padding: 6px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
#emote-bar button { font-size: 22px; padding: 4px 6px; border: none; background: none; }
body.editing #btn-emote { display: none; }

#mg-banner {
  position: absolute; left: 50%; transform: translateX(-50%); top: 150px; width: min(520px, calc(100% - 24px));
  background: rgba(255, 253, 248, 0.97); border-radius: 16px; padding: 12px 16px; text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22); pointer-events: none;
}
#mg-banner .mg-q { font-size: 17px; font-weight: 800; margin: 6px 0; word-break: keep-all; }
#mg-banner .mg-time { font-size: 28px; font-weight: 900; color: var(--accent); }
#mg-banner .mg-ans { font-size: 22px; font-weight: 900; }
#mg-banner .mg-sub { font-size: 13px; color: var(--muted); }
#mg-banner ol { text-align: left; margin: 6px auto 0; padding-left: 22px; max-width: 320px; font-size: 14px; }

#season-pill {
  position: absolute; left: 10px; top: 98px; font-size: 12px; font-weight: 700;
  background: linear-gradient(135deg, #ffe08a, #ffb84d); color: #4a3200; padding: 3px 10px; border-radius: 10px;
}
body.inroom #season-pill { display: none !important; }
#fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

#unlock {
  position: absolute; inset: 0; background: rgba(20, 10, 0, 0.55); display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 50;
}
.unlock-box {
  background: var(--cream); border-radius: 24px; padding: 28px 24px; text-align: center; max-width: 380px; width: 100%;
  box-shadow: 0 0 0 6px #ffd166, 0 20px 50px rgba(0, 0, 0, 0.4); animation: unlockIn 0.6s cubic-bezier(.2, 1.6, .4, 1);
}
.unlock-emoji { font-size: 72px; animation: bounce 1.2s ease-in-out infinite; }
.unlock-tag { color: #c47f00; font-weight: 800; font-size: 13px; letter-spacing: 1px; margin-top: 4px; }
.unlock-box h2 { margin: 8px 0; }
.unlock-box p { color: var(--muted); }
.unlock-box .primary { width: 100%; margin-top: 8px; padding: 12px; }
@keyframes unlockIn { from { transform: scale(0.3) rotate(-8deg); opacity: 0; } }
@keyframes bounce { 50% { transform: translateY(-10px) scale(1.08); } }

@media (max-width: 520px) {
  #room-bar { top: 118px; }
  #season-pill { top: 98px; }
  #mg-banner { top: 168px; }
  #hud-menu button { min-width: 44px; padding: 5px 6px; font-size: 18px; }
  #hud-me { font-size: 13px; }
  .cost-row { grid-template-columns: 74px 1fr 84px; }
  .floor-row .fname { width: 104px; }
}

/* =====================================================================
   다듬기: 글꼴, 입체감 있는 버튼, 메뉴 창 (아래 내용이 위의 기본 모양을 덮어씀)
   ===================================================================== */
:root {
  --game-font: "Jua", "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --shadow-soft: 0 4px 14px rgba(60, 40, 10, 0.14);
}
h1, h2, h3, h4, .logo, .opt-title, .tabs button, #hud-name, #hud-menu button span,
button.primary, #btn-action, #announce, .unlock-box h2, .mg-q, .mg-time, .stat .v, .milestone b,
#room-name, .box-card b, .award-cat b, #season-pill, #online { font-family: var(--game-font); font-weight: 400; }

/* 입체감 있는 버튼 (아래쪽에 두꺼운 테두리) */
button {
  border-bottom-width: 3px;
  transition: transform 0.06s, filter 0.1s;
}
button:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 1px; margin-bottom: 2px; }
button.primary {
  background: linear-gradient(#6cbb55, #56a442);
  border-color: #3f7d30;
  font-size: 16px;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}
button.small { font-size: 13px; }
button.small.primary { font-size: 14px; }

/* 입장 화면 */
.screen { background: radial-gradient(circle at 50% 0%, #d9f1ff, #bfe6ff 30%, #dff3c8 65%, #9ed27f); }
.card { border: 3px solid #fff; box-shadow: 0 14px 40px rgba(60, 90, 30, 0.22); }
.card h1 { font-size: 28px; color: #4a3a22; }
.card h2 { font-size: 22px; color: #4a3a22; }
.logo { font-size: 52px; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.15)); }
input, select { border-width: 2px; }
input:focus, select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(90, 168, 69, 0.2); }

/* 캐릭터 고르기 */
#avatar-preview, .look-preview {
  display: block; margin: 0 auto 10px;
  background: radial-gradient(ellipse at 50% 85%, #b9df9c, #dff2cd 55%, #eef8e6);
  border: 3px solid #fff; border-radius: 18px; box-shadow: var(--shadow-soft);
}
.opt-group .opt-title { font-size: 15px; color: #6b5a40; }
.opt { border-bottom-width: 3px; }
.opt.gender { padding: 10px 22px; font-size: 16px; font-family: var(--game-font); }
.opt.swatch { border-width: 3px; }

/* 상단 정보 */
#hud-me { border: 2px solid #fff; box-shadow: var(--shadow-soft); }
#hud-name { font-size: 16px; color: #4a3a22; }
#hud-menu button {
  border: 2px solid #fff; border-bottom: 4px solid #e2d6c0;
  border-radius: 14px; box-shadow: var(--shadow-soft);
}
#hud-menu button span { font-size: 12px; color: #6b5a40; }
#online, #help { background: rgba(40, 30, 15, 0.45); }

/* 행동 버튼 */
#btn-action {
  background: linear-gradient(#ffc15e, #f0a93b);
  border: 3px solid #fff; border-bottom: 6px solid #c98a24;
  color: #5a3a00; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
  font-size: 17px;
}
#btn-action.wait { background: linear-gradient(#d8ccc0, #b7a89a); border-bottom-color: #8d8074; color: #4a4038; }

/* 메뉴 창 */
#panel { background: rgba(40, 30, 10, 0.35); backdrop-filter: blur(2px); }
.panel-box { border: 3px solid #fff; border-radius: 22px; overflow: hidden; }
.panel-head { background: linear-gradient(#fff4dc, #ffeccc); border-bottom: 2px solid #f0dcb4; }
.panel-head h3 { font-size: 20px; color: #5a3a10; }
.tabs button { border-radius: 12px; }
.tabs button.on { background: linear-gradient(#6cbb55, #56a442); }
.stat, .mat, .quest, .award-cat, .box-card, .item-card { border-width: 2px; border-radius: 14px; }
.stat .v { font-size: 22px; color: #4a3a22; }
.bar { height: 14px; border-radius: 7px; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12); }
.bar > i { background: linear-gradient(#7cc964, #56a442); }
.bar.gold > i { background: linear-gradient(#ffc96b, #f0a93b); }

.toast { border-radius: 14px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); font-size: 15px; }
#room-bar { border: 2px solid #fff; box-shadow: var(--shadow-soft); }
#room-name { font-size: 16px; color: #4a3a22; }

/* =====================================================================
   휴대폰 화면: 프로필 아래에 메뉴 버튼을 한 줄로 펼치고, 겹치지 않게 위치 조정
   ===================================================================== */
@media (max-width: 520px) {
  #hud { flex-direction: column; align-items: stretch; gap: 6px; padding: 8px; padding-top: max(8px, env(safe-area-inset-top)); }
  #hud-me { align-self: flex-start; max-width: calc(100% - 110px); white-space: nowrap; padding: 4px 10px 4px 4px; }
  #hud-me > div { min-width: 0; }
  #hud-name { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
  #hud-avatar { width: 38px; height: 38px; }
  #hud-menu { flex-wrap: nowrap; justify-content: space-between; gap: 4px; }
  #hud-menu button { flex: 1 1 0; min-width: 0; padding: 4px 2px 3px; font-size: 18px; border-radius: 12px; }
  #hud-menu button span { font-size: 11px; white-space: nowrap; }
  #hud-menu button.hidden { display: none; }
  .dot { top: 3px; right: 4px; }
  /* 접속자 수는 프로필 오른쪽, 시즌 안내는 메뉴 아래 */
  #online { left: auto; right: 8px; top: max(18px, calc(env(safe-area-inset-top) + 10px)); }
  #season-pill { left: 8px; top: 118px; }
  #room-bar { top: 118px; }
  #announce { top: 150px; max-width: calc(100% - 24px); }
  #mg-banner { top: 172px; }
  .tabs { gap: 4px; }
  .tabs button { padding: 8px 2px; font-size: 14px; white-space: nowrap; min-width: 0; }
}

/* =====================================================================
   글꼴 · 자간 정리 (본문은 Pretendard, 제목·버튼은 Jua)
   - 한글은 단어 중간에서 줄이 바뀌지 않게 (keep-all)
   - 본문은 자간을 아주 살짝 좁혀 또렷하게, 제목은 살짝 넓혀 둥근 글꼴이 답답하지 않게
   ===================================================================== */
:root {
  --body-font: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}
html, body {
  font-family: var(--body-font);
  letter-spacing: -0.012em;
  line-height: 1.5;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, .logo, .opt-title, .tabs button, #hud-name, #hud-menu button span, button.primary, #btn-action,
#announce, .unlock-box h2, .mg-q, .mg-time, .stat .v, .milestone b, #room-name, .box-card b, .award-cat b, #season-pill, #online,
.acc-name {
  letter-spacing: 0.01em;
  line-height: 1.3;
}
input, select, textarea { letter-spacing: 0; }
.muted { line-height: 1.6; }
#panel-body p { margin: 8px 0; }
.list li span { line-height: 1.4; }
.item-card { line-height: 1.3; }
.item-card .iname { min-height: 2.6em; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.item-card .perk { font-size: 10px; font-weight: 700; color: #0a7f9a; margin-top: 1px; }
.toast, .chat-line { letter-spacing: -0.005em; }
.stat .k, .mat .n, .wallet span { letter-spacing: 0; }

/* 왼쪽 위 내 프로필 (누르면 내 정보 · 계정) */
#hud-me { font: inherit; text-align: left; cursor: pointer; color: var(--ink); }
#hud-me:active { transform: translateY(1px); }
#hud-me .gear { font-size: 12px; opacity: 0.55; align-self: flex-start; margin-left: 2px; }

/* 입장 화면: 로그인 코드로 들어가기 */
button.link {
  background: none; border: none; box-shadow: none; color: var(--green-dark);
  text-decoration: underline; text-underline-offset: 3px; width: 100%; margin-top: 12px; padding: 6px; font-size: 14px;
}
button.link:active { transform: none; }
.hint { font-size: 13px; color: var(--muted); text-align: center; margin: 10px 0 0; line-height: 1.55; }

/* 내 정보 · 계정 */
.account-top { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; }
.account-top canvas { background: radial-gradient(ellipse at 50% 85%, #b9df9c, #dff2cd 60%, #eef8e6); border: 3px solid #fff; border-radius: 16px; box-shadow: var(--shadow-soft); }
.acc-name { font-family: var(--game-font); font-size: 21px; color: #4a3a22; }
.login-code {
  font-family: ui-monospace, Consolas, "D2Coding", monospace; font-size: 26px; font-weight: 800; letter-spacing: 0.14em;
  text-align: center; background: #fff; border: 2px dashed var(--accent); border-radius: 14px; padding: 10px; color: #5a3a10;
  user-select: all;
}

/* =====================================================================
   6차: 마을 지도, 미니게임 고르기
   ===================================================================== */
.map-wrap { width: 100%; border-radius: 14px; overflow: hidden; border: 3px solid #fff; box-shadow: var(--shadow-soft); background: #76b94e; line-height: 0; }
.map-wrap canvas { display: block; width: 100%; image-rendering: pixelated; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 12px; color: var(--muted); }
.map-legend span { display: inline-flex; align-items: center; gap: 4px; }
.map-legend i { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.2); display: inline-block; }

.hourly { background: #fff7e0; border: 2px solid #f3d38a; border-radius: 12px; padding: 8px 12px; font-size: 13px; }
.pick-grid { display: flex; flex-direction: column; gap: 10px; }
.pick-row { background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 10px; }
.pick-row > b { font-family: var(--game-font); font-weight: 400; font-size: 16px; color: #4a3a22; }
.pick-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; }
.pick { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; }
.pick .lv { font-family: var(--game-font); font-size: 18px; }
.pick .rw { font-size: 11px; color: var(--muted); letter-spacing: -0.02em; }
.pick.lv-easy { background: #eef8e8; border-color: #b7dfa6; }
.pick.lv-normal { background: #fff5d6; border-color: #f3d38a; }
.pick.lv-hard { background: #ffe3dc; border-color: #f2a593; }
.track-list { display: flex; flex-direction: column; gap: 8px; }
.track-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 12px 14px; }
.track-btn .tname { font-family: var(--game-font); font-size: 17px; color: #4a3a22; }

/* 도트 그림은 흐리지 않게 */
#world, #hud-avatar, #avatar-preview, .look-preview, .item-card canvas, .decor-item canvas, .box-result canvas, .account-top canvas { image-rendering: pixelated; }

/* =====================================================================
   7차: 접속자 목록, 스페셜 미션 안내판
   ===================================================================== */
#online { cursor: pointer; pointer-events: auto; }
#online:hover { background: rgba(40, 30, 15, 0.6); }
.board-note {
  font-family: var(--game-font); font-size: 18px; color: #5a3a10; text-align: center;
  background: #f3e3c3; border: 3px solid #b07d4f; border-radius: 12px; padding: 14px 12px; margin-bottom: 8px;
  box-shadow: inset 0 0 0 2px #fff7e0;
}
.mission-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.mstep { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 8px 4px; text-align: center; font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mstep.done { border-color: var(--green); background: #eef8e8; }
.mstep .q { font-size: 30px; line-height: 56px; height: 56px; opacity: 0.6; }
.mstep canvas { image-rendering: pixelated; }
