/* 데스크펫 v1.5 — 📱 앱 모드 화면 (js/appmode.js 가 body[data-app="1"] 을 켰을 때만 적용)
 *  디자인 기준: _dev/시안/모바일앱/앱_시안.html (아래 탭바 · 스플래시 · 내 정보)
 *  - 노치·홈 바: env(safe-area-inset-*) (index.html viewport-fit=cover)
 *  - 탭바는 로비(data-scene=main)에서만 · 게임/결과/배틀 중에는 숨김 · 폰 세로 로비의 아래 링크 줄을 대신함
 *  - PC 폭 앱 창: 탭바는 가운데 560px 까지만 */

body[data-app="1"] {
  --tabh: 68px;
  --app-bar: 64px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --bar-h: calc(var(--app-bar) + var(--safe-t));   /* 상단 바 = 원래 높이 + 노치 (scene · 패널 위치가 이 값을 씀) */
}
@media (max-width: 560px) { body[data-app="1"] { --app-bar: 54px; } }
@media (max-height: 520px) and (orientation: landscape) { body[data-app="1"] { --app-bar: 48px; } }

/* ---------- 안전 영역 (노치 · 홈 바) ---------- */
body[data-app="1"] #topbar { padding-top: var(--safe-t); padding-left: max(8px, var(--safe-l)); padding-right: max(8px, var(--safe-r)); }
body[data-app="1"] .game { padding-bottom: max(8px, var(--safe-b)); }

/* ---------- 웹사이트 전용 요소 숨김 (링크 묶음은 '내 정보' 패널 안에) ---------- */
body[data-app="1"]:not([data-web]) #siteLinks,
body[data-app="1"]:not([data-web]) #installBtn { display: none !important; }
/* v1.7.3 브라우저 탭(앱 배치 기본): 아래 링크 줄은 PC 에서만 남김(애드센스) — 폰은 '내 정보' 안에 */
@media (max-width: 900px) { body[data-web="1"] #siteLinks { display: none !important; } }
/* 탭바(가운데 560px) 왼쪽까지만 — 1280 에서 탭바와 2px 겹치던 것. 좁으면 글자·간격을 줄이고, 그래도 넘치면 두 줄 */
body[data-web="1"] #siteLinks { max-width: calc(50vw - 308px); gap: 4px 10px; font-size: 12.5px; border-radius: 14px; }
html.no-install #installBtn { display: none !important; }   /* v1.5.8 폰·태블릿 브라우저 = 설치 유도 안 함 (index.html head 스크립트) */

/* ---------- 아래 탭바 ---------- */
.app-tabbar { display: none; }
body[data-app="1"][data-scene="main"]:not([data-battle]) .app-tabbar { display: flex; }
.app-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 46;   /* 패널(45) 위 · 알림 창(80) 아래 */
  max-width: 560px; margin: 0 auto;
  height: calc(var(--tabh) + var(--safe-b));
  padding: 6px max(8px, var(--safe-l)) var(--safe-b) max(8px, var(--safe-r));
  justify-content: space-around; align-items: stretch;
  background: var(--paper, #fff); border: 3px solid var(--ink); border-bottom: 0; border-radius: 26px 26px 0 0;
  box-shadow: 0 -4px 0 rgba(43,27,23,.08);
}
@media (max-width: 560px) { .app-tabbar { border-left: 0; border-right: 0; } }
.app-tab {
  position: relative; flex: 1 1 0; min-width: 0; max-width: 92px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 0; border: 0; background: none; cursor: pointer;
  font: 400 13px/1.1 var(--f-body); color: var(--sub, #7A645B); -webkit-tap-highlight-color: transparent;
}
.app-tab .at-ic { width: 46px; height: 40px; display: grid; place-items: center; border: 2px solid transparent; border-radius: 14px; transition: background .18s, transform .12s; }
.app-tab .at-ic img { width: 34px; height: 34px; object-fit: contain; }
.app-tab .at-t { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-tab.on { color: var(--ink); }
.app-tab.on .at-ic { background: var(--butter); border-color: var(--ink); box-shadow: 0 2px 0 var(--ink); }
.app-tab:active .at-ic { transform: scale(.9); }
.app-tab:focus-visible { outline: 3px solid var(--pink, #FF8FA3); outline-offset: -2px; border-radius: 16px; }
.app-tab .at-dot { position: absolute; top: 4px; left: calc(50% + 14px); width: 12px; height: 12px; border-radius: 50%; background: #FF5A6E; border: 2px solid #fff; }
:lang(en) .app-tab, :lang(ja) .app-tab { font-size: 12px; }

/* 탭바 자리만큼 로비 · 패널을 위로 (배경은 탭바 뒤까지 그대로) */
body[data-app="1"][data-scene="main"]:not([data-battle]) #scene-main { bottom: calc(var(--tabh) + var(--safe-b)); --navh: 0px; --safe-b: 0px; }
/* v1.7.5 창 뒤 어두운 막은 화면 끝까지 (예전엔 bottom 을 탭바 높이만큼 띄워 맨 아래 띠만 밝게 남던 것 — 사용자 제보).
 *   창 상자는 아래 여백으로 탭바 위에서 끝나고, 탭바(z 46)만 막 위에 또렷이 → 창을 연 채로 탭을 눌러 바꿀 수 있음 */
body[data-app="1"][data-scene="main"]:not([data-battle]) .panel-back { padding-bottom: calc(var(--tabh) + var(--safe-b) + 18px); }
@media (max-width: 900px) { body[data-app="1"][data-scene="main"]:not([data-battle]) .panel-back { padding-bottom: calc(var(--tabh) + var(--safe-b) + 8px); } }   /* mobile.css 의 창 여백과 같게 */
@media (max-width: 560px) { body[data-app="1"][data-scene="main"]:not([data-battle]) .panel-back { padding-bottom: calc(var(--tabh) + var(--safe-b) + 4px); } }
body[data-app="1"][data-scene="main"]:not([data-battle]) .fab-share { bottom: calc(var(--tabh) + var(--safe-b) + 10px); }
body[data-app="1"][data-scene="main"]:not([data-battle]) #liveCount { bottom: calc(var(--tabh) + var(--safe-b) + 10px); }
body[data-app="1"][data-scene="main"]:not([data-battle]) .emote-bar { bottom: calc(var(--tabh) + var(--safe-b) + 10px); }
body[data-app="1"] #scene-main .main-bg { position: fixed; inset: var(--bar-h) 0 0 0; }   /* 로비 그림은 탭바 뒤까지 */
@media (max-width: 560px) and (orientation: portrait) {
  body[data-app="1"][data-scene="main"]:not([data-battle]) #liveCount { bottom: auto; }   /* 세로 폰은 위 왼쪽 그대로 (mobile.css) */
  body[data-app="1"] .fab-share { display: none; }   /* 메뉴 줄을 가려서 → '내 정보'의 [공유하기] 로 */
}

/* ---------- 첫 실행 스플래시 ---------- */
.app-splash {
  position: fixed; inset: 0; z-index: 400;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: calc(24px + var(--safe-t, 0px)) 24px calc(24px + var(--safe-b, 0px));
  background: radial-gradient(circle at 50% 38%, #FFFBEF 0%, var(--cream, #FFF6DF) 45%, #FFE9B8 100%);
  font-family: var(--f-body); color: var(--ink);
  transition: opacity .3s ease, transform .3s ease;
}
.app-splash.out { opacity: 0; transform: scale(1.04); pointer-events: none; }
.app-splash .as-icon { width: 128px; height: 128px; border-radius: 30px; border: 3px solid var(--ink); box-shadow: 0 6px 0 var(--ink); animation: asBob 2.4s ease-in-out infinite; }
.app-splash .as-logo { width: min(280px, 72vw); height: auto; margin-top: 6px; }
.app-splash .as-load { width: min(250px, 70vw); text-align: center; font-size: 15px; }
.app-splash .as-bar { height: 20px; margin-top: 8px; border: 3px solid var(--ink); border-radius: 999px; background: var(--paper, #fff); overflow: hidden; }
.app-splash .as-bar i { display: block; height: 100%; width: 30%; background: repeating-linear-gradient(-45deg, var(--butter) 0 12px, #FFC94D 12px 24px); animation: asLoad 1s ease-out forwards; }
.app-splash .as-tag { position: absolute; bottom: calc(28px + var(--safe-b, 0px)); color: var(--sub, #7A645B); font-size: 13px; }
@keyframes asBob { 50% { transform: translateY(-6px); } }
@keyframes asLoad { to { width: 92%; } }
@media (prefers-reduced-motion: reduce) { .app-splash .as-icon, .app-splash .as-bar i { animation: none; } .app-splash .as-bar i { width: 80%; } }

/* ---------- '내 정보' 패널 ---------- */
.app-me { display: flex; flex-direction: column; gap: 14px; max-width: 520px; margin: 0 auto; padding-bottom: 8px; }
.app-me .id-card { margin: 0 auto; }
.am-intern { display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: var(--paper, #fff); border: 3px dashed var(--ink); border-radius: 22px; }
.am-intern .am-face { flex: none; width: 64px; height: 64px; display: grid; place-items: center; background: var(--pink); border: 2px solid var(--ink); border-radius: 16px; }
.am-intern .am-face img { width: 54px; height: 54px; object-fit: contain; }
.am-intern b { display: block; font: 400 22px/1.2 var(--f-big); }
.am-intern small { display: block; margin-top: 2px; font-size: 13px; color: var(--sub, #7A645B); line-height: 1.4; }
.am-acct { display: grid; gap: 10px; }
.am-acct.two { grid-template-columns: 1fr 1fr; }
.am-acct .btn { width: 100%; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.am-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.am-stat { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 4px; border: 3px solid var(--ink); border-radius: 18px; background: var(--paper, #fff); font: inherit; font-size: 12px; color: var(--sub, #7A645B); cursor: pointer; }
.am-stat[data-go=""] { cursor: default; }
.am-stat img { width: 34px; height: 30px; object-fit: contain; }
.am-stat b { font: 400 19px/1.2 var(--f-big); color: var(--ink); }
.am-stat:not([data-go=""]):active { transform: translateY(2px); }
.am-menu { display: flex; flex-direction: column; background: var(--paper, #fff); border: 3px solid var(--ink); border-radius: 20px; overflow: hidden; }
.am-row { display: flex; justify-content: space-between; align-items: center; min-height: 48px; padding: 0 16px; border: 0; border-top: 2px solid #EFE4D4; background: none; font: inherit; font-size: 16px; color: var(--ink); text-align: left; cursor: pointer; }
.am-row:first-child { border-top: 0; }
.am-row::after { content: "›"; font-size: 22px; color: var(--sub, #7A645B); }
.am-row:active { background: #FFF6DF; }
.am-links { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 14px; font-size: 13px; }
.am-links b { flex-basis: 100%; text-align: center; font-weight: 400; color: var(--sub, #7A645B); }
.am-links a { color: var(--sub, #7A645B); text-decoration: none; border-bottom: 1px dashed currentColor; }

/* v1.5 앱 모드 로비: 아래 탭바와 겹치는 버튼은 숨김. v1.7.3 탭바 = 홈·업적·도감·랭킹·내 정보 → 오른쪽 = [1:1 배틀][뽑기] */
body[data-app="1"] .subs #btnAch, body[data-app="1"] .subs #btnDex, body[data-app="1"] .subs #btnRank { display: none; }
body[data-app="1"] .subs #btnBattle { order: 1; } body[data-app="1"] .subs #btnGacha { order: 2; }
/* 내 정보: 단 칭호 */
body[data-app="1"] .am-title { display: flex; justify-content: center; margin: 10px auto 2px; padding: 4px; border: 0; background: none; }
body[data-app="1"] .subs { grid-template-columns: repeat(2, minmax(76px, 130px)); justify-content: center; }   /* 남은 1:1 배틀·뽑기 2개를 가운데로 (폰·태블릿 세로) */
/* v1.5.3 넓은 앱 화면(PC 앱 창 · 아이패드 가로): [간식타임 | 펫블록 | 펫 머지 | 1:1 배틀 · 업적 세로] — 버튼 칸 높이 = 게임 카드 높이 (사용자 요청) */
@media (min-width: 901px) {
  body[data-app="1"] .main-right { display: grid; grid-template-columns: minmax(0, 1fr) clamp(130px, 13vw, 170px); grid-template-rows: auto; column-gap: clamp(12px, 1.4vw, 20px); align-items: stretch; }
  body[data-app="1"] .main-right > .cards { grid-column: 1; grid-row: 1; }
  body[data-app="1"] .main-right > .subs { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; gap: 14px; margin: 0; padding: 4px 0 6px; }
  body[data-app="1"] .main-right > .subs .sub-btn { flex: 1 1 0; height: auto; width: 100%; padding: 30px 6px 8px; flex-direction: column; justify-content: center; }
  body[data-app="1"] .main-right > .subs .sub-btn > img, body[data-app="1"] .main-right > .subs .sub-btn > .sub-ico { position: static; transform: rotate(-8deg); width: 58px; height: 58px; margin: -18px 0 4px; font-size: 44px; }
  body[data-app="1"] .main-right > .subs .sub-btn > span:not(.sub-ico) { flex: none; }
  body[data-app="1"] .main-right > .cards .gc-desc { font-size: clamp(11px, .9vw, 13px); letter-spacing: -.02em; white-space: nowrap; }   /* 카드가 조금 좁아져 한 줄로 */
}


/* v1.7.6 중간 폭(폴드 펼침 가로 · 태블릿 가로 · 작은 노트북, 약 901~1200px) — 사용자 제보 "폴드 와이드 가로에서 로비가 겹치고 깨져요"
 *  · 오른쪽 큰 버튼과 화면 끝 [친구]·[접속 중] 줄 사이 여백 (1000px 에서 딱 붙어 '뽑기 가능!' 배지가 잘렸음)
 *  · 위 바 버튼 글자는 한 줄로, 좁으면 공지·바로가기는 아이콘만 (글자는 title·aria 에 남음) */
#topbar .pill, #topbar .btn, #topbar .pill > span { white-space: nowrap; }
@media (min-width: 901px) { #topbar .bar-right > .pill { flex-shrink: 0; } }   /* 글자 칸이 줄어들며 '공/지' 처럼 꺾이던 것 (좁은 화면은 예전 규칙대로 줄어듦) */
@media (min-width: 901px) and (max-width: 1100px) { body[data-app="1"] .main-right { margin-right: 16px; } }
@media (min-width: 901px) and (max-width: 1200px) { #topbar .pill .notice-t, #topbar .pill.install-pill .install-t { display: none; } #topbar .pill.notice-pill, #topbar .pill.install-pill { padding-left: 10px; padding-right: 10px; } }
/* v1.7.6 폴드 펼침·iPad 가로·itch.io 창(960×720)처럼 좁은 PC 고리: 카드를 조금 줄여 화살표가 옆 카드 위에 얹히지 않게 */
@media (min-width: 901px) and (max-width: 1100px) { .cards.carousel.cr-pc .game-card { width: clamp(205px, 46%, 253px); margin-left: calc(clamp(205px, 46%, 253px) / -2); } }
