/* 썰물 장터 — 배치(style.css). 생김(색 · 테두리 · 글꼴 · 그림 부품)은 art.css(아트 디렉터) 몫.
   기본 생김은 모두 :where() 안(특정도 0) — art.css가 어느 쪽에 있든 덮어쓴다.
   진짜 특정도를 갖는 것은 자리 · 크기 · 겹침 순서뿐. */

:root {
  --바다: #2f6f86; --모래: #e9d8b4; --먹: #2b2340; --종이: #fbf3e2; --강조: #e0893a; --위험: #c0463b;
  --윗줄높이: 56px; --틈: 8px;
  --안위: env(safe-area-inset-top, 0px); --안아래: env(safe-area-inset-bottom, 0px);
}

/* ── 틀(배치) ── */
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
button { font: inherit; }

.무대 { position: fixed; inset: 0; overflow: hidden; }
.배경 { position: absolute; inset: 0; z-index: 0; }
.배경 img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#배경물 { opacity: 0; transition: opacity .6s linear; }
.무대:not([data-screen="market"]) #배경물 { display: none; }
.무대[data-screen="shop"] #배경그림 { filter: brightness(.55) saturate(.8); }
.무대[data-screen="bench"] #배경그림 { filter: brightness(.7); }

.물 { position: absolute; left: 0; right: 0; top: 0; height: 0; z-index: 3; pointer-events: none; }

.윗줄 { position: absolute; left: 0; right: 0; top: 0; z-index: 5; display: flex; align-items: center; gap: var(--틈);
  height: calc(var(--윗줄높이) + var(--안위)); padding: var(--안위) 12px 0; max-width: 960px; margin: 0 auto; }
.윗줄-빈칸 { flex: 1; }
.윗줄 > :not(.윗줄-빈칸) { flex: none; white-space: nowrap; }
.작은단추 { white-space: nowrap; }
@media (max-width: 430px) { .윗줄 { gap: 6px; padding-left: 8px; padding-right: 8px; } .윗줄 .말 { display: none; } }
@media (max-width: 380px) { .윗줄 { gap: 4px; padding-left: 6px; padding-right: 6px; } .윗줄 .칩 { padding-left: 8px; padding-right: 8px; } .윗줄 .작은단추 { padding-left: 8px; padding-right: 8px; } }

.판 { position: absolute; z-index: 2; left: 0; right: 0; top: calc(var(--윗줄높이) + var(--안위)); bottom: 0;
  margin: 0 auto; max-width: 960px; padding: var(--틈) 12px calc(12px + var(--안아래));
  display: flex; flex-direction: column; overflow-y: auto; scrollbar-width: thin; }
.무대[data-screen="title"] .판, .무대[data-screen="end"] .판 { top: var(--안위); justify-content: center; }

.막 { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 16px; }
#고양이막 { z-index: 12; align-items: flex-end; }
.창틀 { width: 100%; max-width: 560px; max-height: calc(100dvh - 32px); overflow-y: auto; scrollbar-width: thin; }
.알림 { position: fixed; z-index: 20; left: 50%; bottom: calc(96px + var(--안아래)); transform: translate(-50%, 12px);
  max-width: min(90vw, 480px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.알림.켜짐 { opacity: 1; transform: translate(-50%, 0); }

.단추줄 { display: flex; flex-wrap: wrap; gap: var(--틈); }
.단추줄 > .단추 { flex: 1 1 auto; }
.단추세로 { display: flex; flex-direction: column; gap: var(--틈); }

/* ── 표지 · 끝 ── */
.표지, .끝 { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; margin: auto; max-width: 520px; width: 100%; }
.표지 .단추.주 { min-width: 220px; }
.표지-아래 { display: flex; gap: var(--틈); align-items: center; flex-wrap: wrap; justify-content: center; }
.끝 .얼굴 { width: 120px; height: 120px; object-fit: contain; }
.기록 { display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: center; padding: 0; margin: 0; list-style: none; }

/* ── 장터 ── */
.장터 { flex: 1; display: flex; flex-direction: column; gap: var(--틈); min-height: 0; }
.물때줄 { display: flex; align-items: center; gap: var(--틈); }
.물때줄 i { flex: 1; height: 10px; display: block; overflow: hidden; }
.물때줄 b { display: block; height: 100%; width: 100%; }
.좌판 { flex: 1; display: flex; flex-direction: column; gap: var(--틈); min-height: 0; }
.좌판줄 { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: var(--틈); min-height: 64px; }
.타일 { position: relative; min-height: 64px; display: flex; align-items: center; justify-content: center; padding: 4px; overflow: hidden; }
.타일 > img:first-child { max-width: 70%; max-height: calc(100% - 28px); object-fit: contain; }
.타일 .값 { position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); white-space: nowrap; }
.타일-맞수 { position: absolute; right: 2px; top: 2px; height: 70%; max-height: 120px; object-fit: contain; }
.아래줄 { display: flex; align-items: center; gap: var(--틈); }
.보따리 { flex: 1; display: flex; gap: 4px; min-width: 0; }
.보따리-칸 { width: 44px; height: 44px; flex: 0 1 44px; display: flex; align-items: center; justify-content: center; }
.보따리-칸 img { max-width: 90%; max-height: 90%; object-fit: contain; }

/* 좌판 창 */
.좌판창 { display: flex; flex-direction: column; gap: 12px; }
.좌판창-위, .좌판창-물건, .손님 { display: flex; gap: 12px; align-items: center; }
.좌판창 .얼굴, .손님 .얼굴 { width: 88px; height: 88px; flex: none; object-fit: contain; }
.좌판창-물건 img { width: 72px; height: 72px; flex: none; object-fit: contain; }
.좌판창 p, .손님 p { margin: 4px 0; }

/* ── 작업대 · 가게 ── */
.작업대, .가게 { flex: 1; display: flex; flex-direction: column; gap: var(--틈); min-height: 0; }
.작업대-위 { display: flex; justify-content: space-between; align-items: center; }
.카드줄 { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); grid-auto-rows: min-content; align-content: start; gap: var(--틈); }
.카드 { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; min-height: 44px; text-align: center; }
.카드-그림 { height: 56px; display: flex; align-items: center; justify-content: center; }
.카드-그림 img { height: 100%; object-fit: contain; }
.카드-그림.둘 img { height: 80%; margin: 0 -6px; }
.카드-배지 { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.행동 { display: flex; flex-direction: column; gap: var(--틈); }
.행동 p, .행동 b { margin: 0; }
.잠자리 { align-self: stretch; }
.손님 { position: relative; }
.손님 > div { flex: 1; min-width: 0; }
.손님수 { position: absolute; right: 8px; top: 8px; }
.빈선반 { margin: 0; text-align: center; }

/* 결과 창 */
.사건그림 { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.사건얼굴 { display: flex; justify-content: center; gap: 8px; }
.사건얼굴 img { width: 96px; height: 96px; object-fit: contain; }

/* 수첩 */
.수첩 section { margin-bottom: 12px; }
.수첩 ul { margin: 0; padding-left: 18px; }
.수첩 li { margin: 4px 0; }
.알아낸 img { width: 28px; height: 28px; object-fit: contain; vertical-align: middle; }
.소문줄 { display: flex; align-items: center; justify-content: space-between; gap: var(--틈); list-style: none; margin-left: -18px; }
.수첩 > .단추줄:last-child { position: sticky; bottom: -16px; margin: 0 -16px -16px; padding: 10px 16px 16px; z-index: 1; }
.키안내 { display: none; }
@media (hover: hover) and (pointer: fine) { .키안내 { display: block; } }

/* 고양이 */
.고양이 { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; align-items: center; width: 100%; max-width: 560px; margin-bottom: calc(16px + var(--안아래)); }
.고양이 img { width: 96px; height: 96px; object-fit: contain; grid-row: span 2; }
.고양이 .말풍선 { margin: 0; }
.고양이 .단추 { justify-self: end; }

/* ── 누름 크기(배치 규칙: 44px) ── */
.단추, .작은단추, .카드, .타일 { min-height: 44px; min-width: 44px; cursor: pointer; }
:disabled { cursor: default; }

/* ── 가로 폰(낮은 화면): 두 칸 ── */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --윗줄높이: 48px; }
  .좌판줄 { grid-template-columns: 1fr 1fr 1fr 1fr; }
  .좌판 { display: grid; grid-template-rows: repeat(3, 1fr); }
  .좌판줄 { grid-template-columns: 1fr 1fr; }
  .장터 { display: grid; grid-template-columns: 1fr 220px; grid-template-rows: auto 1fr; }
  .물때줄 { grid-column: 1 / -1; }
  .아래줄 { flex-direction: column; align-items: stretch; }
  .보따리 { flex-wrap: wrap; }
  .작업대, .가게 { display: grid; grid-template-columns: 1fr minmax(240px, 40%); grid-auto-rows: min-content; align-content: start; }
  .작업대 > .카드줄, .가게 > .카드줄 { grid-column: 1; grid-row: 1 / span 3; }
  .작업대-위, .행동, .잠자리, .손님 { grid-column: 2; }
  .카드-그림 { height: 44px; }
  .타일 > img:first-child { max-width: 50%; max-height: calc(100% - 6px); margin-right: 30%; }
  .타일 .값 { left: auto; right: 6px; bottom: 50%; transform: translateY(50%); }
  .알림 { bottom: calc(12px + var(--안아래)); }
  .끝 { display: grid; grid-template-columns: 110px 1fr; column-gap: 20px; row-gap: 6px; max-width: 720px; text-align: left; align-items: center; }
  .끝 > * { grid-column: 2; margin: 0; }
  .끝 .얼굴 { grid-column: 1; grid-row: 1 / span 6; width: 110px; height: 110px; }
  .끝 .기록, .끝 .단추줄 { justify-content: flex-start; }
  .끝 .별 { font-size: 30px; }
  .좌판창 .얼굴, .손님 .얼굴 { width: 64px; height: 64px; }
  .사건그림 { max-height: 150px; }
  .사건얼굴 img { width: 64px; height: 64px; }
  .고양이 { grid-template-columns: 72px 1fr; }
  .고양이 img { width: 72px; height: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}

/* ═══ 기본 생김 — 특정도 0. art.css가 덮어쓴다 ═══ */
:where(body) { background: var(--먹); color: var(--먹); font-family: "GowunDodum", "Noto Sans KR", system-ui, sans-serif; font-size: 16px; line-height: 1.45; }
:where(.제목) { font-family: "NanumMyeongjo", serif; font-size: 44px; margin: 0; color: var(--종이); text-shadow: 0 2px 0 var(--먹), 0 0 18px rgba(0,0,0,.5); }
:where(.끝 .제목, .판넬 .제목) { color: var(--먹); text-shadow: none; }
:where(h2) { font-size: 22px; margin: 0 0 8px; }
:where(h3) { font-size: 18px; margin: 0 0 4px; }
:where(small) { font-size: 14px; }
:where(.판넬, .창틀) { background: var(--종이); border: 2px solid var(--먹); border-radius: 10px; padding: 10px 12px; box-shadow: 0 3px 0 rgba(43,35,64,.45); }
:where(.창틀) { padding: 16px; }
:where(.막) { background: rgba(20,16,32,.55); }
:where(.단추, .작은단추, .카드, .타일) { border: 2px solid var(--먹); border-radius: 10px; background: var(--모래); color: var(--먹); padding: 8px 14px; font-size: 16px; }
:where(.작은단추) { padding: 6px 10px; font-size: 14px; background: var(--종이); }
:where(.단추.주) { background: var(--강조); color: #fff; font-weight: 700; font-size: 18px; box-shadow: 0 3px 0 var(--먹); }
:where(.단추, .작은단추, .카드, .타일):where(:hover:not(:disabled)) { filter: brightness(1.08); }
:where(.단추, .작은단추, .카드, .타일):where(:active:not(:disabled)) { transform: translateY(2px); }
:where(.단추, .작은단추, .카드, .타일):where(:focus-visible) { outline: 3px solid var(--강조); outline-offset: 2px; }
:where(:disabled) { opacity: .5; }
:where(.칩) { display: inline-flex; align-items: center; min-height: 32px; padding: 2px 10px; border-radius: 999px; background: var(--종이); border: 2px solid var(--먹); font-size: 14px; white-space: nowrap; }
:where(.배지) { display: inline-block; padding: 0 6px; border-radius: 6px; font-size: 14px; background: var(--종이); border: 1px solid var(--먹); }
:where(.배지.힘) { background: var(--바다); color: #fff; }
:where(.배지.흠) { background: var(--위험); color: #fff; }
:where(.배지.모름) { opacity: .75; }
:where(.말풍선) { background: #fff; border: 2px solid var(--먹); border-radius: 12px; padding: 8px 12px; }
:where(.이름표) { font-size: 16px; }
:where(.카드) { background: var(--종이); padding: 6px; }
:where(.카드.고름) { outline: 3px solid var(--강조); outline-offset: 1px; background: #fff; }
:where(.카드-이름) { font-size: 14px; line-height: 1.2; }
:where(.타일) { background: rgba(251,243,226,.88); }
:where(.물) { background: linear-gradient(to bottom, rgba(47,111,134,.55), rgba(70,150,170,.5) 85%, rgba(220,240,240,.75)); border-bottom: 3px solid rgba(255,255,255,.7); }
:where(.물때줄 i) { background: rgba(43,35,64,.2); border-radius: 5px; }
:where(.물때줄 b) { background: var(--바다); }
:where(.보따리-칸) { border: 2px dashed rgba(43,35,64,.4); border-radius: 8px; background: rgba(255,255,255,.4); }
:where(.보따리-칸.빈) { opacity: .6; }
:where(.알림) { background: var(--먹); color: var(--종이); padding: 10px 16px; border-radius: 10px; font-size: 16px; }
:where(.별) { font-size: 40px; color: var(--강조); margin: 0; }
.끝 .별 small { color: var(--먹-흐림); font-size: 16px; }
:where(.큰돈) { font-size: 28px; font-weight: 700; margin: 0; }
:where(.값줄) { font-size: 20px; font-weight: 700; }
:where(.수첩 > .단추줄:last-child) { background: linear-gradient(to bottom, rgba(251,243,226,0), var(--종이) 30%); }
:where(.드러남) { background: #fff; }
:where(.초) { font-size: 20px; }
:where(.초.꺼짐) { opacity: .4; }
:where(.부제) { max-width: 420px; }
:where(.창틀 ::-webkit-scrollbar, .판::-webkit-scrollbar) { width: 6px; }
:where(.창틀 ::-webkit-scrollbar-thumb, .판::-webkit-scrollbar-thumb) { background: rgba(43,35,64,.35); border-radius: 3px; }
