/* 구황작물단 오락실 — 모바일(≤768px) 앱 쉘 (푸망 레이아웃 × 손그림 크림 다꾸 스타일) */

.m-app-only,
.m-bottom-nav,
.m-search-drawer,
.m-install-btn {
  display: none !important;
}

@media (max-width: 768px) {
  .m-app-only {
    display: block !important;
  }
  .m-icon-btn.m-app-only {
    display: inline-flex !important;
  }
  .m-install-btn.is-ready {
    display: inline-flex !important;
  }

  html {
    overflow-x: clip;
  }

  body {
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important;
    overflow-x: clip;
  }

  /* ── 홈 페이지 앱 컨테이너 전환 ── */
  body.is-portal-home {
    padding: 0 0 calc(84px + env(safe-area-inset-bottom, 0px)) !important;
    background: var(--paper) !important;
  }

  body.is-portal-home .poster-sheet {
    max-width: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0 0 24px;
    background: var(--paper);
    overflow-x: clip;
  }

  body.is-portal-home .poster-sheet::before {
    display: none;
  }

  /* 상단 슬림 스티키 앱 바 */
  body.is-portal-home .topbar {
    position: sticky;
    top: 0;
    z-index: 600;
    height: 54px;
    padding: 8px 14px;
    background: rgba(255, 254, 249, 0.96);
    backdrop-filter: blur(8px);
    border-bottom: 2.5px solid var(--ink);
    flex-wrap: nowrap;
    gap: 8px;
  }

  body.is-portal-home .brand-pill {
    padding: 4px 11px;
    font-size: 15.5px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  body.is-portal-home .top-actions {
    flex-wrap: nowrap;
    gap: 6px;
    margin-left: auto;
  }

  body.is-portal-home .top-actions .tests-pill,
  body.is-portal-home .top-actions .fortune-pill,
  body.is-portal-home .top-actions .mbti-pill,
  body.is-portal-home .top-actions .id-pill,
  body.is-portal-home .top-actions a[href="#hall"],
  body.is-portal-home .top-actions a[href="#guestbook"] {
    display: none !important;
  }

  body.is-portal-home .top-actions .sticker-btn {
    padding: 5px 10px;
    font-size: 12.5px;
    white-space: nowrap;
  }

  .m-icon-btn {
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0 !important;
    border-radius: 999px;
    background: var(--cream);
    border: 2.3px solid var(--ink);
    box-shadow: 2px 2px 0 var(--ink);
    color: var(--ink);
    font-size: 15px;
    cursor: pointer;
    flex-shrink: 0;
  }

  /* 기존 데스크톱 히어로 블록 숨김 (앱 피드와 중복 방지) */
  body.is-portal-home .hero {
    padding: 4px 0 0;
  }

  body.is-portal-home .hero-kicker,
  body.is-portal-home .hero h1,
  body.is-portal-home .speech-bubble,
  body.is-portal-home .hero-art,
  body.is-portal-home .memo-box,
  body.is-portal-home #testsBanner,
  body.is-portal-home #mbtiBanner,
  body.is-portal-home #fortuneBanner {
    display: none !important;
  }

  /* ── 앱 홈 피드 ── */
  .m-app-home {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  /* 1) 스와이프 히어로 배너 캐러셀 */
  .m-carousel-wrap {
    position: relative;
    width: 100%;
  }

  .m-carousel-track {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 14px;
    padding: 12px 14px 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .m-carousel-track::-webkit-scrollbar { display: none; }

  .m-slide {
    flex: 0 0 100%;
    scroll-snap-align: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 162px;
    padding: 16px 16px 18px;
    border: 2.8px solid var(--ink);
    border-radius: 20px;
    box-shadow: 4px 4px 0 var(--ink);
    text-decoration: none;
    color: var(--ink);
    overflow: hidden;
  }

  .m-slide-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    min-width: 0;
    flex: 1;
    z-index: 2;
  }

  .m-slide-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
  }

  .m-slide-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1.8px solid var(--ink);
    background: #fff;
    font-family: "Jua", sans-serif;
    font-size: 11.5px;
    line-height: 1.3;
  }
  .m-slide-tag.is-hot {
    background: #ee5a4f;
    color: #fff;
  }

  .m-slide-title {
    margin: 0;
    font-family: "Jua", sans-serif;
    font-size: 20px;
    line-height: 1.22;
    word-break: keep-all;
  }

  .m-slide-desc {
    margin: 0;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--muted);
    line-height: 1.4;
    word-break: keep-all;
  }

  .m-slide-cta {
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--ink);
    color: #fffef9;
    font-family: "Jua", sans-serif;
    font-size: 12.5px;
  }

  .m-slide-art {
    flex-shrink: 0;
    width: 82px;
    height: 82px;
    border-radius: 16px;
    border: 2.3px solid var(--ink);
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 2.5px 2.5px 0 var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 42px;
  }
  .m-slide-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .m-carousel-counter {
    position: absolute;
    right: 22px;
    bottom: 16px;
    z-index: 5;
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(47, 34, 25, 0.84);
    color: #fffef9;
    font-family: "Jua", sans-serif;
    font-size: 11.5px;
    pointer-events: none;
  }

  /* 2) 푸망 스타일 카테고리 밑줄 탭 바 */
  .m-cat-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    padding: 4px 12px 0;
    border-bottom: 2px solid rgba(47, 34, 25, 0.14);
    scrollbar-width: none;
  }
  .m-cat-tabs::-webkit-scrollbar { display: none; }

  .m-cat-tab {
    flex: 0 0 auto;
    border: 0;
    background: transparent;
    padding: 10px 10px 9px;
    font-family: "Jua", sans-serif;
    font-size: 14.5px;
    color: var(--muted);
    cursor: pointer;
    position: relative;
    white-space: nowrap;
  }

  .m-cat-tab.is-active {
    color: var(--ink);
  }
  .m-cat-tab.is-active::after {
    content: "";
    position: absolute;
    left: 6px;
    right: 6px;
    bottom: -2px;
    height: 3.5px;
    border-radius: 999px;
    background: var(--accent);
  }

  /* 3) 가로 스와이프 3:4 카드 레일 */
  .m-rail-section {
    padding: 16px 0 4px;
  }

  .m-rail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px 8px;
  }

  .m-rail-title {
    margin: 0;
    font-family: "Jua", sans-serif;
    font-size: 18px;
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  .m-rail-more {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2.2px solid var(--ink);
    background: var(--cream);
    box-shadow: 2px 2px 0 var(--ink);
    color: var(--ink);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: "Jua", sans-serif;
    font-size: 16px;
  }

  .m-card-rail {
    display: flex;
    gap: 11px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding: 4px 14px 10px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .m-card-rail::-webkit-scrollbar { display: none; }

  .m-rail-card {
    flex: 0 0 132px;
    scroll-snap-align: start;
    text-decoration: none;
    color: var(--ink);
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  .m-rail-cover {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 15px;
    border: 2.5px solid var(--ink);
    box-shadow: 3px 3px 0 var(--ink);
    padding: 10px 9px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
  }

  .m-rail-badge {
    align-self: flex-start;
    padding: 2px 7px;
    border-radius: 999px;
    border: 1.6px solid var(--ink);
    background: rgba(255, 255, 255, 0.92);
    font-family: "Jua", sans-serif;
    font-size: 10.5px;
    line-height: 1.25;
  }

  .m-rail-emoji {
    font-size: 40px;
    line-height: 1;
    text-align: center;
    margin: auto 0;
  }

  .m-rail-cover-title {
    font-family: "Jua", sans-serif;
    font-size: 14px;
    line-height: 1.22;
    text-align: center;
    word-break: keep-all;
    background: rgba(255, 254, 249, 0.88);
    border: 1.6px solid var(--ink);
    border-radius: 9px;
    padding: 4px 5px;
  }

  .m-rail-name {
    margin: 2px 0 0;
    font-family: "Jua", sans-serif;
    font-size: 13.5px;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .m-rail-meta {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--muted);
  }
  .m-rail-meta.is-done {
    color: #2f7d32;
  }

  /* 4) 오늘의 운세 · 점술관 4칩 스트립 */
  .m-fortune-strip {
    margin: 6px 14px 4px;
    padding: 12px 12px;
    border: 2.5px solid var(--ink);
    border-radius: 18px;
    background: linear-gradient(135deg, #f3eaff 0%, #fff4cc 65%, #dff4ff 100%);
    box-shadow: 3px 3px 0 var(--ink);
  }

  .m-fortune-strip-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 9px;
  }

  .m-fortune-strip-head strong {
    font-family: "Jua", sans-serif;
    font-size: 15.5px;
  }

  .m-fortune-strip-head a {
    font-family: "Jua", sans-serif;
    font-size: 12.5px;
    color: #5b38a3;
    text-decoration: none;
  }

  .m-fortune-chips {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
  }

  .m-f-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 4px;
    border-radius: 12px;
    border: 2px solid var(--ink);
    background: #fffef9;
    box-shadow: 2px 2px 0 var(--ink);
    text-decoration: none;
    color: var(--ink);
    font-family: "Jua", sans-serif;
    font-size: 12px;
    text-align: center;
  }
  .m-f-chip span:first-child { font-size: 18px; line-height: 1; }

  /* 5) 출석 도장판 컴팩트 여백 */
  body.is-portal-home .stamp-card {
    margin: 14px 14px 6px;
    padding: 12px 13px;
    border-radius: 16px;
  }
  body.is-portal-home .stamp-title { font-size: 15.5px; }
  body.is-portal-home .stamp-slots { gap: 5px; }
  body.is-portal-home .stamp-slot { font-size: 11px; }

  /* 6) 게임 5종 2열 컴팩트 카드 그리드 */
  body.is-portal-home .sec-title-wrap {
    margin: 20px 14px 12px;
    text-align: left;
  }
  body.is-portal-home .sec-title {
    font-size: 19px;
  }

  body.is-portal-home .filter-bar {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0 14px 6px;
    margin-bottom: 12px;
    scrollbar-width: none;
  }
  body.is-portal-home .filter-bar::-webkit-scrollbar { display: none; }
  body.is-portal-home .filter-chip {
    flex: 0 0 auto;
    padding: 6px 13px;
    font-size: 13px;
  }

  body.is-portal-home #gameGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 11px;
    padding: 0 14px;
  }

  body.is-portal-home #gameGrid .card {
    padding: 13px 10px 11px;
    border-radius: 16px;
    gap: 6px;
    border-width: 2.5px;
    box-shadow: 3px 3px 0 var(--ink);
  }
  body.is-portal-home #gameGrid .card::before {
    width: 56px;
    height: 14px;
    top: -8px;
  }
  body.is-portal-home #gameGrid .today-stamp {
    top: 8px;
    right: 6px;
    font-size: 10.5px;
    padding: 2px 6px;
  }
  body.is-portal-home #gameGrid .thumb {
    height: 106px;
    border-radius: 11px;
    border-width: 2px;
  }
  body.is-portal-home #gameGrid .genre-pill {
    font-size: 10.5px;
    padding: 2px 7px;
  }
  body.is-portal-home #gameGrid .my-best {
    font-size: 10.5px;
    padding: 1px 6px;
  }
  body.is-portal-home #gameGrid .card h2 {
    font-size: 16px;
    line-height: 1.25;
  }
  body.is-portal-home #gameGrid .card p {
    font-size: 12px;
    line-height: 1.42;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  body.is-portal-home #gameGrid .play-btn {
    padding: 8px 10px;
    font-size: 13.5px;
    border-radius: 10px;
    box-shadow: 2px 2px 0 var(--ink);
  }

  /* 7) 명예의 전당 · 방명록 · 푸터 모바일 여백 */
  body.is-portal-home .hall-section,
  body.is-portal-home .guest-section {
    margin-top: 26px;
    padding: 20px 14px 0;
  }
  body.is-portal-home .hall-section .sec-title-wrap,
  body.is-portal-home .guest-section .sec-title-wrap {
    margin: 0 0 12px;
  }
  body.is-portal-home .podium-img {
    max-width: 260px;
  }
  body.is-portal-home .podium-memo {
    padding: 15px 13px;
  }
  body.is-portal-home .postit-wall {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 10px;
  }
  body.is-portal-home footer {
    margin-top: 24px;
    padding: 10px 14px 4px;
  }

  /* 카테고리 필터 숨김 유틸 */
  .m-sec-hidden {
    display: none !important;
  }

  /* ── 검색 드로어 ── */
  .m-search-drawer {
    display: none !important;
    position: fixed;
    inset: 0;
    z-index: 950;
    background: rgba(47, 34, 25, 0.45);
    padding: 16px 14px 90px;
    overflow-y: auto;
  }
  .m-search-drawer.is-open {
    display: block !important;
  }

  .m-search-panel {
    max-width: 520px;
    margin: 0 auto;
    background: var(--paper);
    border: 3px solid var(--ink);
    border-radius: 20px;
    box-shadow: 5px 5px 0 var(--ink);
    padding: 14px;
  }

  .m-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
  }

  .m-search-input {
    flex: 1;
    min-width: 0;
    padding: 9px 12px;
    border-radius: 12px;
    border: 2.4px solid var(--ink);
    background: #fff;
    font-family: inherit;
    font-size: 14.5px;
    color: var(--ink);
  }

  .m-search-close {
    padding: 8px 12px;
    border-radius: 12px;
    border: 2.2px solid var(--ink);
    background: var(--cream);
    font-family: "Jua", sans-serif;
    font-size: 13.5px;
    color: var(--ink);
    cursor: pointer;
    flex-shrink: 0;
  }

  .m-search-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 60vh;
    overflow-y: auto;
  }

  .m-search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border-radius: 13px;
    border: 2px solid var(--ink);
    background: #fff;
    text-decoration: none;
    color: var(--ink);
    box-shadow: 2px 2px 0 rgba(47, 34, 25, 0.16);
  }
  .m-search-item-ico {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 2px solid var(--ink);
    background: var(--cream);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
  }
  .m-search-item-txt {
    min-width: 0;
    flex: 1;
  }
  .m-search-item-txt strong {
    display: block;
    font-family: "Jua", sans-serif;
    font-size: 14.5px;
  }
  .m-search-item-txt span {
    display: block;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .m-search-empty {
    text-align: center;
    padding: 20px 10px;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--muted);
  }

  /* ── 하단 고정 5탭 내비게이션 ── */
  .m-bottom-nav {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    background: rgba(255, 254, 249, 0.98);
    backdrop-filter: blur(8px);
    border-top: 2.8px solid var(--ink);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 14px rgba(47, 34, 25, 0.08);
  }

  .m-tab-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 5px 2px;
    border-radius: 12px;
    border: 2px solid transparent;
    text-decoration: none;
    color: var(--muted);
    font-family: "Jua", sans-serif;
    font-size: 11.5px;
    line-height: 1.15;
    transition: transform 0.12s ease, background-color 0.12s ease;
  }

  .m-tab-ico {
    font-size: 18px;
    line-height: 1;
  }

  .m-tab-btn.is-active {
    background: #fff1b8;
    border-color: var(--ink);
    color: var(--ink);
    box-shadow: 2px 2px 0 var(--ink);
    transform: translateY(-2px);
  }

  .m-tab-badge {
    position: absolute;
    top: 2px;
    right: 10px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: #ee5a4f;
    border: 1.5px solid var(--ink);
    color: #fff;
    font-size: 9.5px;
    line-height: 13px;
    text-align: center;
  }
}
