/* 공통 바탕: 리셋, 글꼴, 상단 바(로고·메뉴), 알림, 음악 위젯 */
*, *::before, *::after { box-sizing: border-box; }

/* 마우스 커서: 코지 UI 팩 Cursor2 고정 (손가락 끝 2,2). 링크·버튼·입력창·지도 끌기 등 모든 곳에서 같은 모양,
   누르고 있는 동안만 눌린 모양. 다른 규칙의 cursor: pointer/text/grab 보다 앞서도록 !important */
html, *, *::before, *::after { cursor: url("../img/ui/cozy/cursor.png") 2 2, auto !important; }
html:active, *:active, *:active::before, *:active::after { cursor: url("../img/ui/cozy/cursor-down.png") 2 2, auto !important; }
html { -webkit-text-size-adjust: 100%; font-size: var(--ui-scale, 16px); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.6;
  color: var(--color-text);
  word-break: keep-all;
}
h1, h2, h3, h4, legend, dialog > header, .page-header h1, .region-label, .district-label { font-family: var(--font-display); }
h1, h2, h3 { font-weight: 700; line-height: 1.3; margin: 0 0 var(--space-3); letter-spacing: -.01em; }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
p { margin: 0 0 var(--space-3); }
a { color: var(--color-leaf-deep); }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--color-sky); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ui-icon { display: inline-grid; place-items: center; line-height: 1; }
img.ui-icon { width: 1.4em; height: 1.4em; object-fit: contain; }
[id] { scroll-margin-top: 120px; }

/* 상단 바: 로고 + 내 정보 / 메뉴 한 줄 */
.life-hud { position: sticky; top: 0; z-index: 40; }
.hud-top, .game-nav { width: min(var(--content-width), calc(100% - 2 * var(--space-4))); margin: 0 auto; }
.hud-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-2) 0; }
.life-logo { display: inline-flex; align-items: center; }
.life-logo img { display: block; height: 38px; width: auto; }
.hud-player { display: flex; align-items: center; gap: var(--space-3); }
.hud-player form { margin: 0; }
.hud-player strong, .hud-player small { display: block; line-height: 1.3; }
.hud-player strong { font-size: var(--text-sm); }
.hud-player small { font-size: var(--text-xs); }
.hud-face { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.game-nav { display: flex; gap: var(--space-1); overflow-x: auto; scrollbar-width: none; }
.game-nav::-webkit-scrollbar { display: none; }
.game-nav a { flex: 0 0 auto; font-size: var(--text-sm); text-decoration: none; white-space: nowrap; }
.game-nav a[aria-current="page"] { border-bottom-color: var(--color-leaf); font-weight: 700; }

/* 본문 */
.game-stage { margin: 0 auto; padding: var(--space-5) 0 var(--space-7); }
.toast { width: min(600px, 100%); margin: 0 auto var(--space-4); }

/* 음악 위젯 */
.music-widget { position: fixed; z-index: 35; bottom: var(--space-4); right: auto; left: var(--space-3); }
.music-widget .bgm { display: flex; align-items: center; gap: var(--space-2); }
.music-widget .bgm:empty { display: none; }
.bgm-player { display: flex; align-items: center; gap: var(--space-1); max-width: min(380px, calc(100vw - 2 * var(--space-3))); padding: var(--space-1) var(--space-2); background: var(--color-surface); border: var(--border-card); box-shadow: 0 2px 8px var(--color-shadow); }
.bgm-player input[type="range"] { width: 72px; flex: 0 0 auto; }
.bgm-title { min-width: 0; overflow: hidden; color: var(--color-text-muted); white-space: nowrap; text-overflow: ellipsis; }
.bgm-error { color: var(--color-danger, #b3261e); }
/* YouTube 영상 화면은 숨기고 소리만 (재생에는 iframe 이 화면에 있어야 해서 밖으로 밀어 둔다) */
.bgm-frame { position: fixed; left: -9999px; bottom: 0; width: 200px; height: 200px; border: 0; opacity: 0; pointer-events: none; }

@media (max-width: 760px) {
  .life-hud { position: relative; }
  .life-logo img { height: 34px; }
  .hud-player div { display: none; }
  .music-widget { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* 오른쪽 아래 채팅·쪽지 창 */
.social-dock { position: fixed; z-index: 45; right: var(--space-4); bottom: var(--space-4); display: grid; justify-items: end; gap: var(--space-2); }
.social-toggle { align-items: center; cursor: pointer; }
.social-toggle[aria-expanded="true"] { display: none; }
.social-badge { min-width: 18px; padding: 0 5px; border-radius: var(--radius-pill); color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.social-panel { display: flex; flex-direction: column; width: min(360px, calc(100vw - 2 * var(--space-4))); height: min(520px, calc(100vh - 120px)); background: var(--color-surface); overflow: hidden; }
.social-panel[hidden] { display: none; }
.social-tabs { display: flex; }
.social-tabs [role="tab"] { display: inline-flex; align-items: center; gap: 4px; background: none; font: 500 var(--text-sm) var(--font-body); cursor: pointer; }
.social-tabs [aria-selected="true"] { border-bottom-color: var(--color-leaf); font-weight: 700; }
.social-close { margin-left: auto; }
.social-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.social-body[hidden], [data-dm-list][hidden], [data-dm-thread][hidden] { display: none; }
[data-dm-list], [data-dm-thread] { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-log { flex: 1; margin: 0; padding: var(--space-3); overflow-y: auto; list-style: none; display: grid; align-content: start; gap: var(--space-2); }
.chat-line { display: flex; gap: var(--space-2); align-items: flex-start; }
.chat-line img, .chat-face-empty { flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%; background: var(--color-surface-alt); object-fit: cover; }
.chat-line p { margin: 0; padding: 6px 10px; border-radius: 12px; background: var(--color-surface-alt); font-size: var(--text-sm); white-space: pre-wrap; word-break: break-word; }
.chat-line.is-mine { flex-direction: row-reverse; }
.chat-line.is-mine > div { text-align: right; }
.chat-line.is-mine p { background: var(--color-leaf-soft); }
.chat-meta { display: block; font-size: 11px; color: var(--color-text-muted); }
.social-form { display: flex; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-top: 1px solid var(--color-border); }
.social-form input { flex: 1; min-width: 0; }
.dm-new { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3); font-size: var(--text-sm); border-bottom: 1px solid var(--color-border); }
.dm-new select { flex: 1; }
.dm-threads { flex: 1; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.dm-threads button { display: flex; align-items: center; gap: var(--space-2); width: 100%; padding: var(--space-2) var(--space-3); border: 0; border-bottom: 1px solid var(--color-border); background: none; font: inherit; text-align: left; color: var(--color-text); cursor: pointer; }
.dm-threads button:hover { background: var(--color-surface-alt); }
.dm-threads img, .dm-threads .chat-face-empty { flex: 0 0 34px; display: block; width: 34px; height: 34px; aspect-ratio: 1; border-radius: 50%; background: var(--color-surface-alt); object-fit: cover; }
.dm-threads span:not(.chat-face-empty):not(.social-badge) { flex: 1; min-width: 0; display: grid; }
.dm-threads small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-text-muted); }
.dm-threads time { font-size: 11px; }
.dm-head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-border); }
.social-error { margin: 0; padding: var(--space-2) var(--space-3); background: var(--color-berry-soft); color: var(--color-berry); font-size: var(--text-sm); }
@media (max-width: 760px) { .social-dock { right: var(--space-2); } .social-panel { height: calc(100vh - 90px); } }
.game-nav a i { margin-right: 5px; opacity: .75; }
.game-nav a[aria-current="page"] i { opacity: 1; }

/* ── 한눈에 보기 배치 (넓은 화면, 1200px 이상) ──
   상단 바를 한 줄(로고 · 메뉴 · 내 정보)로 줄이고, 본문을 넓게 쓴다.
   .is-board 화면의 칸 배치는 아래 960px 규칙을 본다. */
@media (min-width: 1200px) {
  :root { --wide-width: min(1480px, calc(100vw - 2 * var(--space-5))); }
  .life-hud { display: flex; align-items: center; gap: var(--space-4); height: var(--hud-h); padding: 0 max(var(--space-5), calc((100vw - var(--wide-width)) / 2)); }
  .hud-top { display: contents; }
  .life-logo { order: 1; flex: 0 0 auto; }
  .life-logo img { height: 34px; }
  .game-nav { order: 2; flex: 1 1 auto; width: auto; margin: 0; align-self: stretch; }
  .game-nav a { display: flex; align-items: center; }
  .hud-player { order: 3; flex: 0 0 auto; }
}

/* .is-board 화면 (960px 이상): 칸(panel)들을 왼쪽→오른쪽 순서로 두 칸씩 나란히 놓는다.
   길어지는 목록은 칸 안에서 스크롤해서, 화면 전체가 세로로 길게 늘어나지 않게 한다.
   칸 하나를 전체 폭으로 쓰려면 .panel--wide */
@media (min-width: 960px) {
  .game-stage.is-board { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); align-items: start; }
  .game-stage.is-board > * { min-width: 0; margin: 0; }
  .game-stage.is-board > :is(.page-header, .toast, .panel--wide, .panel-grid, .memo-board),
  .game-stage.is-board > .panel:has(.card-grid, .photo-grid, .house-grid, .memo-wall, .fish-book, .garden) { grid-column: 1 / -1; }  /* 카드·사진 목록이 든 칸은 한 줄을 다 쓴다 */
  .game-stage.is-board > :not(.panel) > .panel { margin-top: 0; }
  .game-stage.is-board .feed, .game-stage.is-board .memo-wall, .game-stage.is-board .photo-grid { max-height: var(--board-list-h, 560px); overflow-y: auto; overscroll-behavior: contain; }
}

/* ── 스크롤바: 얇고 둥근 막대. 칸 안 스크롤(목록·채팅)도 같은 모양 ── */
* { scrollbar-width: thin; }
::-webkit-scrollbar-corner { background: transparent; }

/* ── 슬라이더 손잡이: 둥근 손잡이 + 아랫면 그림자, 지나온 쪽은 포인트 색 ── */
input[type="range"] { -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; accent-color: var(--color-leaf); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--color-sky); outline-offset: 2px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--color-leaf); }
::selection { background: var(--color-leaf-soft); color: var(--color-text); }
