*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #0f0f1a;
    color: #e0e0e8;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
  }

  /* ===== App Container ===== */
  .app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding-bottom: 100px; }

  /* ===== Status Bar / Top Nav ===== */
  .top-bar {
    position: sticky; top: 0; z-index: 50;
    background: rgba(15,15,26,.92); backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 14px 20px 10px;
    border-bottom: 1px solid rgba(255,255,255,.06);
  }
  .top-bar-inner { display: flex; align-items: center; justify-content: space-between; }
  .app-title { font-size: 1.3rem; font-weight: 700; color: #fff; letter-spacing: -.02em; }
  .card-count-badge {
    font-size: 0.72rem; font-weight: 600; color: #b0b0c0;
    background: rgba(255,255,255,.1); padding: 6px 14px; border-radius: 20px;
    border: 1px solid rgba(255,255,255,.08);
  }

  /* ===== Horizontally Scrollable Filter Chips ===== */
  .filter-scroll {
    padding: 14px 20px 6px; overflow-x: auto;
    white-space: nowrap; -ms-overflow-style: none; scrollbar-width: none;
  }
  .filter-scroll::-webkit-scrollbar { display: none; }
  .filter-scroll-inner { display: inline-flex; gap: 8px; }
  .filter-chip {
    flex-shrink: 0; padding: 9px 20px; border-radius: 22px;
    font-size: 0.84rem; font-weight: 600; border: 1.5px solid rgba(255,255,255,.12); cursor: pointer;
    background: rgba(255,255,255,.08); color: #c0c0d0;
    transition: all .25s; font-family: inherit; white-space: nowrap;
    text-decoration: none; display: inline-flex; align-items: center;
  }
  .filter-chip:hover { background: rgba(255,255,255,.14); color: #e0e0f0; border-color: rgba(255,255,255,.2); }
  .filter-chip:active { transform: scale(.94); }
  .filter-chip.active {
    background: linear-gradient(135deg, #7C6FF7, #5B4FCF); color: #fff; font-weight: 700;
    border-color: transparent; box-shadow: 0 4px 18px rgba(108,92,231,.45);
  }
  .filter-chip .chip-count { font-size: 0.68rem; opacity: .65; margin-left: 3px; }
  .filter-chip.active .chip-count { opacity: .85; }

  /* ===== Section Headers ===== */
  .section-header {
    padding: 20px 20px 6px; display: flex; align-items: baseline; gap: 8px;
  }
  .section-title { font-size: 0.78rem; font-weight: 600; color: #6C5CE7; text-transform: uppercase; letter-spacing: .08em; }
  .section-line { flex: 1; height: 1px; background: rgba(255,255,255,.06); }

  /* ===== Card Grid ===== */
  .card-grid {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 12px; padding: 10px 16px;
  }

  /* ===== Card ===== */
  .card {
    position: relative; border-radius: 14px; overflow: hidden;
    aspect-ratio: 3 / 5; cursor: pointer;
    background: #1a1a2e;
    box-shadow: 0 2px 12px rgba(0,0,0,.3);
    transition: transform .2s, box-shadow .2s;
  }
  .card:active { transform: scale(.96); box-shadow: 0 1px 6px rgba(0,0,0,.4); }
  .card-img {
    width: 100%; height: 100%; object-fit: cover; display: block;
    transition: transform .4s ease;
  }
  .card:hover .card-img { transform: scale(1.03); }
  .card-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(transparent 20%, rgba(0,0,0,.8) 100%);
    padding: 28px 10px 10px; pointer-events: none;
  }
  .card-num {
    position: absolute; top: 8px; left: 10px;
    font-size: 0.68rem; font-weight: 600; color: #fff;
    background: rgba(0,0,0,.55); padding: 3px 8px; border-radius: 8px;
    backdrop-filter: blur(6px); z-index: 2;
  }
  .card-name {
    font-size: 0.78rem; font-weight: 600; color: #fff;
    letter-spacing: .03em; text-shadow: 0 1px 3px rgba(0,0,0,.6);
  }
  .card-en {
    font-size: 0.62rem; color: rgba(255,255,255,.55);
    margin-top: 2px; letter-spacing: .02em;
  }

  /* Suit accent dots */
  .card::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 3px; z-index: 3;
    background: var(--accent); border-radius: 14px 14px 0 0;
  }
  .suit-major { --accent: #c9a84c; }
  .suit-wands { --accent: #e85d4a; }
  .suit-cups { --accent: #4a90e8; }
  .suit-swords { --accent: #a0b0d0; }
  .suit-pentacles { --accent: #5cba6e; }

  /* ===== Bottom Sheet Modal ===== */
  .sheet-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0; visibility: hidden; transition: all .35s;
  }
  .sheet-overlay.open { opacity: 1; visibility: visible; }
  .sheet {
    position: fixed; bottom: 0; left: 50%; transform: translate(-50%, 100%);
    width: 100%; max-width: 480px; max-height: 85vh;
    background: #1a1a2e; border-radius: 24px 24px 0 0;
    z-index: 201; overflow: hidden;
    display: flex; flex-direction: column;
    transition: transform .4s cubic-bezier(.32,.72,0,1);
    box-shadow: 0 -8px 40px rgba(0,0,0,.5);
  }
  .sheet-overlay.open .sheet { transform: translate(-50%, 0); }
  .sheet-handle {
    width: 36px; height: 4px; background: rgba(255,255,255,.2);
    border-radius: 2px; margin: 12px auto 0; flex-shrink: 0;
  }
  .sheet-header { padding: 16px 20px 6px; text-align: center; flex-shrink: 0; }
  .sheet-img-wrapper {
    margin: 0 auto 12px; width: 140px; height: 210px; border-radius: 12px;
    overflow: hidden; box-shadow: 0 8px 30px rgba(0,0,0,.5);
  }
  .sheet-img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .sheet-title { font-size: 1.3rem; font-weight: 700; color: #fff; }
  .sheet-en { font-size: 0.82rem; color: #888; margin-top: 4px; }
  .sheet-num-tag {
    display: inline-block; margin-top: 8px; padding: 4px 14px;
    font-size: 0.7rem; font-weight: 600; color: #6C5CE7;
    background: rgba(108,92,231,.12); border-radius: 12px; letter-spacing: .06em;
  }
  .sheet-body {
    padding: 6px 20px 16px;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    flex: 1; min-height: 0;
  }
  .sheet-desc {
    font-size: 0.9rem; color: #aaa; line-height: 1.75;
    text-align: left;
  }
  .sheet-keywords { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
  .sheet-keyword {
    padding: 6px 14px; border-radius: 16px;
    font-size: 0.78rem; font-weight: 500;
    background: rgba(108,92,231,.1); color: #a79ff7;
    border: 1px solid rgba(108,92,231,.15);
  }
  .sheet-footer {
    flex-shrink: 0;
    padding: 12px 20px max(16px, env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255,255,255,.06);
    background: #1a1a2e;
  }

  /* ===== Bottom Tab Bar ===== */
  .tab-bar {
    position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 480px; z-index: 100;
    background: rgba(20,20,32,.94); backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,.06);
    display: flex; padding: 6px 8px max(6px, env(safe-area-inset-bottom));
  }
  .tab-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    gap: 3px; padding: 7px 4px; border: none; background: none;
    cursor: pointer; color: #888; font-family: inherit;
    transition: color .25s; -webkit-tap-highlight-color: transparent;
    text-decoration: none;
  }
  .tab-btn:hover { color: #b8b8d0; }
  .tab-btn:active { opacity: .7; }
  .tab-btn.active { color: #8B7CF6; }
  .tab-icon { font-size: 1.3rem; }
  .tab-label { font-size: 0.62rem; font-weight: 600; letter-spacing: .04em; }

  /* ===== Empty State ===== */
  .empty { text-align: center; padding: 40px 20px; color: #555; font-size: 0.9rem; }

  /* ===== Scroll-To-Top FAB ===== */
  .fab {
    position: fixed; bottom: 90px; right: calc(50% - 220px);
    width: 44px; height: 44px; border-radius: 50%; z-index: 99;
    background: linear-gradient(135deg, #7C6FF7, #5B4FCF); border: none; cursor: pointer;
    color: #fff; font-size: 1.2rem; display: flex; align-items: center;
    justify-content: center; box-shadow: 0 6px 20px rgba(108,92,231,.5);
    opacity: 0; visibility: hidden; transition: all .3s;
  }
  .fab.visible { opacity: 1; visibility: visible; }
  @media (min-width: 481px) {
    .fab { right: calc(50% - 230px); }
  }

  /* ===== Detail Page ===== */
  .detail-page {
    position: fixed; inset: 0; z-index: 300;
    background: #0f0f1a; overflow-y: auto;
    transform: translateX(100%); transition: transform .35s cubic-bezier(.32,.72,0,1);
    max-width: 480px; margin: 0 auto;
  }
  .detail-page.open { transform: translateX(0); }
  .detail-top { position: sticky; top: 0; z-index: 10; background: rgba(15,15,26,.95); backdrop-filter: blur(20px); padding: 14px 16px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.06); }
  .detail-back { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.08); border: none; color: #ccc; font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center; text-decoration: none; }
  .detail-back:active { opacity: .6; }
  .detail-top-title { font-size: 1rem; font-weight: 700; color: #fff; flex: 1; }
  .detail-hero {
    position: relative;
    display: flex; flex-direction: column; align-items: center;
    padding: 18px 24px 8px;
    background: radial-gradient(ellipse at 50% 30%, #1c1c32 0%, #0f0f1a 68%);
  }
  .detail-hero-img {
    width: min(56vw, 210px); height: auto;
    aspect-ratio: 3 / 5; object-fit: contain; object-position: center;
    display: block; border-radius: 10px;
    box-shadow: 0 14px 40px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.08);
    transition: transform .45s cubic-bezier(.32,.72,0,1);
    transform-origin: center center; background: #151525;
  }
  .detail-hero-img.is-reversed { transform: rotate(180deg); }
  .detail-hero-overlay {
    position: static; width: 100%; text-align: center;
    padding: 14px 8px 4px; background: none;
  }
  .detail-hero-num {
    display: inline-block; font-size: 0.72rem; font-weight: 700;
    color: rgba(255,255,255,.45); letter-spacing: .06em;
    margin-bottom: 4px;
  }
  .detail-hero-name { font-size: 1.35rem; font-weight: 700; color: #fff; }
  .detail-hero-en { font-size: 0.78rem; color: rgba(255,255,255,.45); margin-top: 2px; }
  .detail-body { padding: 20px 20px 60px; }
  .detail-tabs { display: flex; gap: 0; margin-bottom: 20px; background: rgba(255,255,255,.04); border-radius: 12px; padding: 4px; }
  .detail-tab { flex: 1; padding: 10px; text-align: center; font-size: 0.85rem; font-weight: 600; border: none; background: none; color: #777; cursor: pointer; border-radius: 10px; transition: all .25s; font-family: inherit; text-decoration: none; }
  .detail-tab.active { background: rgba(108,92,231,.2); color: #a79ff7; }
  .detail-section {
    margin-bottom: 18px;
    padding: 16px;
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 16px;
  }
  .detail-section-title {
    font-size: 0.92rem; font-weight: 700; color: #e8e8f4;
    margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
    padding-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,.06);
  }
  .detail-section-icon { font-size: 1rem; }
  .detail-section-text { font-size: 0.86rem; color: #b8b8c8; line-height: 1.85; word-break: break-word; }
  .detail-section-text p { margin: 0 0 10px; }
  .detail-section-text p:last-child { margin-bottom: 0; }
  .detail-keywords { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
  .detail-kw {
    font-size: 0.7rem; font-weight: 600; padding: 5px 10px; border-radius: 999px;
    background: rgba(108,92,231,.12); color: #b4acf8;
    border: 1px solid rgba(108,92,231,.18); line-height: 1.3;
  }
  .detail-prompt {
    font-size: 0.8rem; color: #9a9ab0; line-height: 1.7;
    padding: 10px 12px; margin-bottom: 12px;
    background: rgba(108,92,231,.08); border-radius: 10px;
    border-left: 3px solid rgba(108,92,231,.45);
  }
  .detail-subs { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
  .detail-sub {
    background: rgba(0,0,0,.22); border-radius: 12px; padding: 12px 14px;
    border: 1px solid rgba(255,255,255,.04);
  }
  .detail-sub-title {
    font-size: 0.72rem; font-weight: 700; letter-spacing: .04em;
    color: #a79ff7; margin-bottom: 6px; text-transform: none;
  }
  .detail-sub-text { font-size: 0.82rem; color: #a8a8b8; line-height: 1.7; }
  .detail-other-list { display: flex; flex-direction: column; gap: 8px; }
  .detail-other-item {
    display: flex; flex-direction: column; align-items: center;
    gap: 6px; padding: 12px 14px; border-radius: 12px;
    background: rgba(0,0,0,.2); border: 1px solid rgba(255,255,255,.04);
    text-align: center;
  }
  .detail-other-label {
    font-size: 0.72rem; font-weight: 700; color: #c9a84c;
    line-height: 1.4; letter-spacing: .04em;
  }
  .detail-other-body { font-size: 0.8rem; color: #a8a8b8; line-height: 1.7; text-align: center; }
  .detail-desc-text {
    font-size: 0.86rem; color: #b8b8c8; line-height: 1.85;
  }
  .detail-desc-text p { margin: 0 0 12px; }
  .detail-desc-text p:last-child { margin-bottom: 0; }
  .detail-source { text-align: center; padding: 20px; font-size: 0.7rem; color: #555; }
  .detail-source a { color: #777; }

  /* ===== Sheet Detail Button ===== */
  .sheet-detail-btn {
    display: block; width: 100%; padding: 14px 16px; margin: 0;
    background: linear-gradient(135deg, #7C6FF7, #5B4FCF); color: #fff;
    border: none; border-radius: 14px; font-size: 0.9rem; font-weight: 700;
    cursor: pointer; font-family: inherit; letter-spacing: .03em;
    box-shadow: 0 4px 16px rgba(108,92,231,.35); transition: all .2s;
    text-align: center; text-decoration: none; box-sizing: border-box;
  }
  .sheet-detail-btn:active { transform: scale(.97); opacity: .8; }

  /* ===== Scrollbar ===== */
  ::-webkit-scrollbar { width: 0; height: 0; }

/* ===== Standalone detail page (牌名.html) ===== */
body.page-detail {
  overflow-x: hidden;
}
body.page-detail .detail-page {
  position: relative;
  inset: auto;
  transform: none !important;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  z-index: 1;
}
body.page-detail .detail-page.open {
  transform: none !important;
}
body.page-home .detail-page { display: none !important; }
