/*
  PLAYSHELF の見た目（全ページで 1 つ）。
  明るいテーマは白が基調。パステルは大きなべた塗りにせず、淡い面（札・ジャンルの色・ボタン）として使う。暗いテーマは同じ並びを落ち着かせた版。
  文字は濃い色で 4.5:1 以上。主ボタンは 1 色。スマホが主・PC が従。
  余白は 4px の尺度・同じ物は同じ寸法・絵文字なし・線のアイコン 1 セット・ウェイトは 400 と 500（順位の数字とロゴだけ 600）。
  作りの丁寧さの決まりは unslop（Damir Sokolovsky / @heydamir、CC BY 4.0）に従った。
*/

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --raised: #f5f6f9;
  --hover: #eceef3;
  --text: #1f2133;
  --text-2: #4b4f63;
  --muted: #646879;        /* 白で 5.6:1 */
  --line: rgba(31, 33, 51, .09);
  --line-strong: rgba(31, 33, 51, .16);

  /* 淡い面（ジャンルの色は近い仲間で分け合う） */
  --t-peach: #ffe6db;
  --t-apricot: #ffedd3;
  --t-lemon: #fff4cf;
  --t-mint: #dcf5e8;
  --t-aqua: #d8f3f3;
  --t-sky: #e0edfd;
  --t-pink: #ffe4ee;
  --t-sand: #eeeae2;
  --soft: #fff0f5;         /* おまかせの入口の淡い面 */

  /* 主ボタン（1 色）と、選んだ物の文字 */
  --primary: #c42a62;      /* 白い文字で 5.4:1 */
  --on-primary: #ffffff;
  --primary-hover: #ad2155;
  --accent-ink: #a8255a;   /* 淡いピンクの上で 5.6:1 */
  --focus: #c42a62;

  --scrim: rgba(31, 33, 51, .42);
  --shadow-sm: 0 1px 2px rgba(31, 33, 51, .06);
  --shadow-md: 0 4px 16px rgba(31, 33, 51, .08), 0 1px 2px rgba(31, 33, 51, .05);
  --shadow-float: 0 12px 32px rgba(31, 33, 51, .14), 0 1px 2px rgba(31, 33, 51, .06);

  --font: "Inter", "Zen Maru Gothic", "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --t-fast: 160ms;
  --t-menu: 220ms;
  --t-enter: 360ms;

  --r-small: 8px;
  --r-control: 10px;
  --r-card: 16px;
  --r-panel: 24px;
  --topbar-h: 60px;
  --page-x: 24px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #12131c;
  --surface: #191b26;
  --raised: #20222f;
  --hover: #2a2d3d;
  --text: #eef0f7;
  --text-2: #b8bccd;
  --muted: #9095aa;
  --line: rgba(238, 240, 247, .09);
  --line-strong: rgba(238, 240, 247, .16);

  --t-peach: #3a2a23;
  --t-apricot: #382d20;
  --t-lemon: #34301f;
  --t-mint: #1f3229;
  --t-aqua: #1d3234;
  --t-sky: #1f2b3d;
  --t-pink: #36242e;
  --t-sand: #2d2a26;
  --soft: #2e2230;

  --primary: #f28cb1;
  --on-primary: #1a0f15;
  --primary-hover: #f5a3c1;
  --accent-ink: #f4a3c1;
  --focus: #f28cb1;

  --scrim: rgba(0, 0, 0, .6);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .35);
  --shadow-float: 0 12px 32px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--topbar-h) + 8px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-width: 320px; overflow-x: hidden;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.7;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
body.locked { overflow: hidden; }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
b { font-weight: 500; }
img { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-small); }
.only-m, .only-s { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 線のアイコン：16px・線幅 1.5・文字の色 */
.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* キーボードの近道の印（控えめに） */
.key {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 4px;
  font: 500 12px/1 var(--font); color: var(--muted);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px;
}

/* ---- ボタン ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--r-control);
  font-weight: 500; font-size: 14px; white-space: nowrap; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong);
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn:hover { background: var(--raised); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: default; transform: none; background: var(--surface); }
.btn .i { color: var(--text-2); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.btn.primary .i { color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.quiet:hover { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text); }
.btn.icon { width: 40px; padding: 0; }
.btn.small { min-height: 32px; padding: 0 12px; gap: 4px; font-size: 13px; }
.btn.big { min-height: 48px; padding: 0 20px; font-size: 15px; }
/* おまかせ：2 番目に目立つ入口（淡いピンクの面にピンクの字） */
.btn.soft { background: var(--soft); color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent-ink) 24%, transparent); }
.btn.soft .i { color: var(--accent-ink); }
.btn.soft:hover { background: color-mix(in srgb, var(--soft) 80%, var(--accent-ink)); }
.btn .key { margin-left: 4px; margin-right: -4px; }
.link { color: var(--text-2); font-size: 13px; min-height: 32px; padding: 0 4px; transition: color var(--t-fast) var(--ease); }
.link:hover { color: var(--text); }

/* ---- 上の棒（細く。右上は後で入るログインの場所として空けておく） ---- */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--bg); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.topbar-inner {
  position: relative; max-width: 1440px; height: var(--topbar-h); margin: 0 auto; padding: 0 var(--page-x);
  display: flex; align-items: center; gap: 16px;
}
.logo { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 600; font-size: 16px; letter-spacing: .02em; flex: none; }
.logo-mark { width: 20px; height: 20px; color: var(--primary); }
.search {
  flex: 1; max-width: 520px; margin: 0 auto; min-width: 0;
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px 0 12px;
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-control);
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.search:hover { border-color: var(--line-strong); }
.search:focus-within { border-color: var(--focus); background: var(--surface); }
.search .i { color: var(--muted); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; font-size: 15px; }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }
.search:focus-within .key { display: none; }
.topbar-actions { display: flex; gap: 8px; flex: none; margin-left: auto; }
:root[data-theme="dark"] .theme-light, :root:not([data-theme="dark"]) .theme-dark { display: none; }

/* ---- トップの段 ---- */
.shelves { max-width: 1440px; margin: 0 auto; padding: 0 var(--page-x); }
.shelf, .ranking, .genre-strip { margin-top: 40px; }
.ranking { margin-top: 16px; }
.genre-strip { margin-top: 32px; }
.shelf-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.shelf-title { min-width: 0; }
.shelf-title h2 { font-size: 22px; line-height: 1.3; font-weight: 500; }
.shelf-title p { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.shelf-nav { display: flex; align-items: center; gap: 8px; flex: none; }
.shelf-nav .more .i { width: 14px; height: 14px; }

/* 横に流れる棚（つかんで動かせる・指で流せる・スナップで止まる） */
.shelf-row {
  display: grid; grid-auto-flow: column; grid-auto-columns: 264px; gap: 16px;
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scrollbar-width: none;
  padding: 4px; margin: -4px; border-radius: var(--r-card);
  scroll-padding: 0 4px;
}
.shelf-row.dragging { cursor: grabbing; scroll-snap-type: none; user-select: none; -webkit-user-select: none; }
@media (hover: hover) and (pointer: fine) { .shelf-row { cursor: grab; } }
.shelf-card { scroll-snap-align: start; }
.shelf-card .card-body { padding: 12px 4px 0; gap: 4px; }

/* 人気ランキング：1 位を大きく、2〜5 位を 2×2（スマホは 2 位から横に流す） */
.rank-feature { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 24px; align-items: start; }
.rank-rest { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-columns: auto; overflow: visible; scroll-snap-type: none; cursor: auto; gap: 20px 16px; }
.rank-rest .shelf-card:nth-child(n+7) { display: none; }
.lead-card .media { border-radius: 20px; }
.lead-card .shot { animation: drift 24s var(--ease) infinite alternate; }
@keyframes drift { from { transform: scale(1.02) translate(0, 0); } to { transform: scale(1.1) translate(-3%, 2%); } }
.lead-card .card-body { padding: 16px 4px 0; gap: 8px; }
.lead-card h3 { font-size: 22px; line-height: 1.35; white-space: normal; }
.lead-card .desc { font-size: 14px; line-height: 22px; -webkit-line-clamp: 2; line-clamp: 2; }
.lead-card .play { position: relative; z-index: 2; }

/* 順位の札（絵の左上の角） */
.rank-tag {
  position: absolute; top: 8px; left: 8px; z-index: 1;
  display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0 8px; border-radius: var(--r-small);
  font: 600 16px/1 "Inter", sans-serif; color: var(--text); background: var(--surface); box-shadow: var(--shadow-sm);
}
.rank-1 { background: var(--primary); color: var(--on-primary); min-width: 40px; height: 40px; font-size: 20px; border-radius: 10px; }
.rank-2, .rank-3 { background: var(--text); color: var(--bg); }

/* ジャンルの札の列 */
.genre-row { grid-auto-columns: max-content; gap: 8px; }
.genre-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px;
  font-size: 14px; white-space: nowrap; color: var(--text); background: var(--tone);
  scroll-snap-align: start; border: 1px solid transparent;
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.genre-chip .i { color: var(--text-2); }
.genre-chip .count { font-size: 12px; color: var(--text-2); }
.genre-chip:hover { border-color: var(--line-strong); }
.genre-chip.is-current { border-color: var(--text); }

/* ---- 表紙（本物の画面。無い時はジャンルの淡い色の面に題名） ---- */
.tone-peach   { --tone: var(--t-peach);   --pat: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16'><path d='M-4 4 4-4M0 16 16 0M12 20 20 12' stroke='black' stroke-width='1.5'/></svg>"); }
.tone-apricot { --tone: var(--t-apricot); --pat: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='12'><path d='M0 9 6 3 12 9 18 3 24 9' stroke='black' stroke-width='1.5' fill='none'/></svg>"); }
.tone-lemon   { --tone: var(--t-lemon);   --pat: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20'><rect x='4' y='4' width='12' height='12' stroke='black' stroke-width='1.5' fill='none'/></svg>"); }
.tone-mint    { --tone: var(--t-mint);    --pat: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32'><circle cx='16' cy='16' r='10' stroke='black' stroke-width='1.5' fill='none'/></svg>"); }
.tone-aqua    { --tone: var(--t-aqua);    --pat: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24'><path d='M12 4 20 12 12 20 4 12Z' stroke='black' stroke-width='1.5' fill='none'/></svg>"); }
.tone-sky     { --tone: var(--t-sky);     --pat: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24'><path d='M0 .75H24M.75 0V24' stroke='black' stroke-width='1.5' fill='none'/></svg>"); }
.tone-pink    { --tone: var(--t-pink);    --pat: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16'><circle cx='8' cy='8' r='1.5' fill='black'/></svg>"); }
.tone-sand    { --tone: var(--t-sand);    --pat: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12'><path d='M0 6H12' stroke='black' stroke-width='1.5'/></svg>"); }

.media {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--r-card);
  background: var(--tone, var(--raised));
}
/* 枠の細線は絵の上に重ねる（白い画面でも枠が分かるように） */
.media::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--line); pointer-events: none; }
.poster { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; padding: 16px; color: var(--text); }
.poster::before {
  content: ""; position: absolute; top: 0; right: 0; width: 60%; height: 70%;
  background: var(--text); opacity: .07;
  -webkit-mask-image: var(--pat); mask-image: var(--pat);
  -webkit-mask-position: right top; mask-position: right top;
}
.poster-genre { position: relative; font-size: 12px; color: var(--text-2); }
.poster-title {
  position: relative; font-size: 20px; line-height: 1.25; font-weight: 500; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.shot {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top center;
  transition: transform 2400ms var(--ease);
}
.preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity var(--t-fast) var(--ease); }
.media.playing .preview { opacity: 1; }
@media (hover: hover) {
  .card:hover .media:not([data-preview]) .shot { transform: scale(1.06) translate(-1.5%, 1.5%); }
}
.has-preview {
  position: absolute; right: 8px; bottom: 8px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface); color: var(--text-2); box-shadow: var(--shadow-sm); transition: opacity var(--t-fast) var(--ease);
}
.has-preview .i { width: 12px; height: 12px; }
.media.playing .has-preview { opacity: 0; }

/* お気に入り：表紙の右上（カードのリンクより上に出す） */
.fav { display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: var(--text-2); }
.card > .fav {
  position: absolute; z-index: 2; top: 6px; right: 6px; width: 44px; height: 44px; border-radius: 12px; background: transparent;
}
.card > .fav::before {
  content: ""; position: absolute; inset: 6px; border-radius: var(--r-small); background: var(--surface); box-shadow: var(--shadow-sm);
  transition: background-color var(--t-fast) var(--ease);
}
.card > .fav .i { position: relative; }
.card > .fav:hover::before { background: var(--raised); }
.card > .fav:active { transform: scale(.94); }
.fav.on, .fav.on .i { color: var(--primary); }
.fav.on .i { fill: currentColor; }

/* ---- カード（題名のリンクがカード全体に広がる） ---- */
.card { position: relative; display: flex; flex-direction: column; border-radius: var(--r-card); }
.card-link::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: var(--r-card); }
.card-link:focus-visible { outline: none; }
.card-link:focus-visible::after { outline: 2px solid var(--focus); outline-offset: 4px; }
.card .media { transition: box-shadow var(--t-fast) var(--ease); }
.card:hover .media { box-shadow: inset 0 0 0 1px var(--line-strong), 0 0 0 4px color-mix(in srgb, var(--text) 6%, transparent); }
.card-body { display: flex; flex-direction: column; gap: 4px; padding: 12px 4px 0; flex: 1; min-width: 0; }
.card h3 { font-size: 15px; font-weight: 500; line-height: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.byline { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 13px; line-height: 20px; }
.creator { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.host { color: var(--muted); white-space: nowrap; }
.flag { flex: none; padding: 0 6px; border-radius: 6px; font-size: 12px; line-height: 20px; color: var(--accent-ink); background: var(--t-pink); }
.byline .flag:first-of-type { margin-left: auto; }
.desc { font-size: 13px; line-height: 20px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.points { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; line-height: 16px; color: var(--text-2); min-width: 0; }
.points span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.points .i { width: 14px; height: 14px; color: var(--muted); }
.card-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 8px; }
.card-foot .points { flex: 1; }
.play { position: relative; z-index: 2; }
.play .i { width: 14px; height: 14px; }

/* ---- すべてのゲームを探す ---- */
.browse { max-width: 1440px; margin: 64px auto 0; padding: 0 var(--page-x) 64px; }
.browse-head { display: flex; align-items: baseline; gap: 12px; padding: 24px 0; border-top: 1px solid var(--line); }
.browse-head h2 { font-size: 26px; line-height: 1.3; font-weight: 500; }
.browse-head p { font-size: 13px; color: var(--muted); }
.layout { display: grid; grid-template-columns: 256px minmax(0, 1fr); gap: 32px; align-items: start; }
.results { min-width: 0; }

.filters {
  position: sticky; top: calc(var(--topbar-h) + 16px);
  max-height: calc(100vh - var(--topbar-h) - 32px); overflow-y: auto;
  padding: 16px; background: var(--raised); border-radius: 20px;
}
.filters-head { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.filters-head h2 { font-size: 15px; font-weight: 500; flex: 1; }
.filters section { padding: 16px 0; border-top: 1px solid var(--line); }
.filters section:first-child { border-top: 0; padding-top: 8px; }
.filters h3 { font-size: 12px; font-weight: 400; color: var(--muted); margin-bottom: 8px; }
.sheet-grip { display: none; }

.rows { display: flex; flex-direction: column; gap: 2px; }
.row {
  display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 10px; border-radius: var(--r-control);
  font-size: 14px; text-align: left; color: var(--text-2);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.row:hover { background: var(--hover); color: var(--text); }
.row.empty-row { opacity: .5; }
.row-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { font-size: 12px; color: var(--muted); }
.row.on { background: var(--surface); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent-ink); opacity: 1; }
.row.on .count { color: var(--accent-ink); }
.swatch { width: 12px; height: 12px; border-radius: 4px; flex: none; background: var(--tone); box-shadow: inset 0 0 0 1px var(--line-strong); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 36px; padding: 0 12px; border-radius: var(--r-control); font-size: 13px; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--line-strong);
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--text-2); }
.chip.on { border-color: var(--accent-ink); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent-ink); }

.switch { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; font-size: 14px; color: var(--text-2); }
.switch input { position: absolute; opacity: 0; }
.switch span {
  flex: none; width: 40px; height: 24px; border-radius: 12px; background: var(--hover); position: relative;
  box-shadow: inset 0 0 0 1px var(--line-strong); transition: background-color var(--t-fast) var(--ease);
}
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow-sm); transition: transform var(--t-fast) var(--ease);
}
.switch input:checked + span { background: var(--primary); box-shadow: none; }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; padding: 4px; background: var(--raised); border-radius: 12px; }
.tabs button {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 36px; padding: 0 12px; border-radius: var(--r-small); font-size: 13px; font-weight: 500; color: var(--muted);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line); }
.tabs b, .toolbar b { font-size: 12px; color: var(--muted); }
.toolbar-right { display: flex; gap: 8px; align-items: center; }
.select { position: relative; display: inline-flex; }
.select select {
  appearance: none; -webkit-appearance: none;
  height: 40px; padding: 0 36px 0 12px; border-radius: var(--r-control);
  border: 1px solid var(--line-strong); background: var(--surface); font-size: 14px; cursor: pointer;
}
.select select:disabled { opacity: .5; cursor: default; }
.select .i { position: absolute; right: 12px; top: 12px; color: var(--muted); pointer-events: none; }
.status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 32px; margin: 16px 0 20px; }
#count { font-size: 13px; color: var(--muted); }
.active { display: flex; flex-wrap: wrap; gap: 8px; }
.token {
  display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 0 8px 0 12px;
  border-radius: var(--r-small); font-size: 13px; color: var(--accent-ink); background: var(--t-pink);
}
.token .i { width: 14px; height: 14px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 32px 20px; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 64px 24px; color: var(--text-2); background: var(--raised); border-radius: 20px; }
.empty .i { width: 18px; height: 18px; color: var(--muted); }

/* 広告の枠（設定がある時だけ。カードと同じ大きさを先に取って、並びがずれないように） */
.ad { display: flex; flex-direction: column; gap: 4px; min-height: 280px; }
.ad-label { font-size: 12px; color: var(--muted); }
.ad-feed { min-height: 240px; }
.ad-article { margin: 40px 0 0; min-height: 280px; }

/* ---- 作品ページ ---- */
.gpage, .listpage, .docpage { max-width: 960px; margin: 0 auto; padding: 16px var(--page-x) 64px; }
.listpage { max-width: 1440px; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 13px; color: var(--muted); min-height: 32px; margin-bottom: 12px; }
.crumbs a { color: var(--text-2); padding: 4px 0; }
.crumbs a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.crumbs .i { width: 14px; height: 14px; }
.crumbs span[aria-current] { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }
.g-media .media { border-radius: 20px; }
.g-media .poster { padding: 24px; }
.g-media .poster-title { font-size: 32px; }
.g-head { display: flex; flex-direction: column; gap: 4px; margin-top: 20px; }
.g-head h1 { font-size: 30px; line-height: 1.3; font-weight: 500; overflow-wrap: anywhere; }
.g-head .byline { font-size: 14px; flex-wrap: wrap; }
.g-head .byline .host::before { content: "·"; margin-right: 8px; color: var(--muted); }
.xstats { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--muted); }
.xstats span { display: inline-flex; align-items: center; gap: 4px; }
.xstats .i { width: 14px; height: 14px; }
.g-actions { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
.g-play { min-width: 220px; }
.g-host { font-weight: 400; font-size: 12px; opacity: .85; }
.d-points { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-top: 24px; }
.d-points li { display: grid; grid-template-columns: 16px minmax(0, 1fr); column-gap: 8px; padding: 12px; border-radius: 12px; background: var(--raised); }
.d-points .i { color: var(--text-2); grid-row: span 2; margin-top: 2px; }
.pt-label { font-size: 12px; line-height: 16px; color: var(--muted); }
.pt-value { font-size: 14px; line-height: 20px; overflow-wrap: anywhere; }
.g-section { margin-top: 32px; }
.g-section h2 { font-size: 18px; font-weight: 500; margin-bottom: 12px; }
.g-about { color: var(--text-2); font-size: 16px; line-height: 1.85; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: var(--r-control);
  font-size: 14px; color: var(--text-2); background: var(--raised);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.tag:hover { color: var(--text); background: var(--hover); }
.tag-genre { color: var(--text); }
.g-meta { margin-top: 24px; font-size: 13px; color: var(--muted); }
.g-meta a { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; min-height: 32px; }
.g-meta a .i { width: 12px; height: 12px; }
.similar { margin-top: 48px; }
.similar-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.similar-head h2 { margin: 0; }
.grid-similar { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* 一覧・決まりの頁 */
.list-head { margin: 8px 0 24px; }
.list-head h1 { font-size: 28px; line-height: 1.3; font-weight: 500; }
.list-head p { margin-top: 4px; color: var(--text-2); font-size: 14px; }
.listpage .genre-strip { margin: 0 0 24px; }
.doc { max-width: 720px; }
.doc h1 { font-size: 28px; font-weight: 500; line-height: 1.3; margin-bottom: 24px; }
.doc h2 { font-size: 18px; font-weight: 500; margin: 32px 0 8px; }
.doc p { color: var(--text-2); font-size: 16px; line-height: 1.9; }
.doc p + p { margin-top: 12px; }
.doc a:not(.btn) { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.doc-dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; color: var(--text-2); }
.doc-dl dt { color: var(--muted); }
.doc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }

/* ---- おかえりの帯（「遊ぶ」から戻った時に 1 回だけ） ---- */
.welcome {
  position: fixed; z-index: 60; right: 24px; bottom: calc(24px + var(--safe-b)); width: min(400px, calc(100vw - 32px));
  padding: 16px; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-float); border: 1px solid var(--line);
  animation: rise var(--t-enter) var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.welcome-head { display: flex; align-items: center; justify-content: space-between; margin: -4px -4px 4px 0; }
.welcome-title { font-size: 16px; font-weight: 500; }
.welcome-played { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--text-2); }
.welcome-played p { min-width: 0; overflow-wrap: anywhere; }
.welcome-sub { margin-top: 16px; font-size: 12px; color: var(--muted); }
.welcome-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.welcome-list a { display: flex; flex-direction: column; gap: 4px; }
.welcome-pic { display: block; aspect-ratio: 16 / 9; border-radius: var(--r-small); overflow: hidden; background: var(--tone, var(--raised)); }
.welcome-pic img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.welcome-name { font-size: 12px; line-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* おまかせの浮かぶボタン（スマホ・親指の届く右下） */
.fab {
  position: fixed; z-index: 40; right: 16px; bottom: calc(16px + var(--safe-b));
  min-height: 52px; padding: 0 20px; border-radius: 26px; box-shadow: var(--shadow-float);
}

/* ---- お知らせ・足元 ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); z-index: 100;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: 14px; box-shadow: var(--shadow-float);
  animation: toast var(--t-menu) var(--ease);
}
@keyframes toast { from { opacity: 0; transform: translate(-50%, 8px); } }
.footer { border-top: 1px solid var(--line); padding: 40px var(--page-x) calc(40px + var(--safe-b)); margin-top: 32px; }
.footer-inner { max-width: 1440px; margin: 0 auto; display: grid; grid-template-columns: 2fr 1fr; gap: 24px 48px; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 4px 20px; align-content: start; }
.footer-nav h2 { width: 100%; font-size: 12px; font-weight: 400; color: var(--muted); margin-bottom: 4px; }
.footer-nav a { font-size: 14px; color: var(--text-2); min-height: 36px; display: inline-flex; align-items: center; }
.footer-nav a:hover { color: var(--text); }
.footer-note { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }

/* ---- 狭い画面 ---- */
@media (max-width: 1100px) {
  .rank-feature { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .rank-rest { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rank-rest .shelf-card:nth-child(n+5) { display: none; }
  .rank-rest .card-body .points span:nth-child(3) { display: none; }
}
@media (max-width: 920px) {
  .only-m { display: inline-flex !important; }
  .hide-m { display: none !important; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  /* 絞り込みは下からの引き出し（親指で届く・後ろは動かない・閉じやすい） */
  .filters {
    position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; top: auto;
    max-height: 85dvh; padding: 8px 16px 0; overflow: hidden;
    display: flex; flex-direction: column;
    background: var(--surface); border-radius: var(--r-panel) var(--r-panel) 0 0; box-shadow: var(--shadow-float);
    transform: translateY(100%); visibility: hidden;
    transition: transform var(--t-enter) var(--ease), visibility 0s linear var(--t-enter);
  }
  .filters.open { transform: none; visibility: visible; transition: transform var(--t-enter) var(--ease), visibility 0s; }
  .sheet-grip { display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 0 auto 8px; flex: none; }
  .filters-head { flex: none; }
  .filters-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .filters-foot { display: block !important; flex: none; padding: 12px 0 calc(12px + var(--safe-b)); border-top: 1px solid var(--line); }
  .filters-foot .btn { width: 100%; }
  .row { min-height: 44px; }
  .chip { min-height: 44px; }
  .backdrop { position: fixed; inset: 0; z-index: 45; background: var(--scrim); }
  .rank-feature { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .rank-rest {
    grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 42%;
    overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px;
  }
  .rank-rest .shelf-card:nth-child(n) { display: flex; }
  .footer-inner { grid-template-columns: minmax(0, 1fr); }
  /* 作品ページ：「遊ぶ」は下に固定 */
  .page-game { padding-bottom: calc(80px + var(--safe-b)); }
  .g-actions {
    position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; margin: 0;
    padding: 12px 16px calc(12px + var(--safe-b)); background: var(--surface); border-top: 1px solid var(--line); box-shadow: var(--shadow-float);
  }
  .g-play { flex: 1; min-width: 0; }
  .page-game .toast { bottom: calc(96px + var(--safe-b)); }
  .page-game .welcome { bottom: calc(88px + var(--safe-b)); }
  .welcome { left: 16px; right: 16px; width: auto; }
  body:not(.page-game) .welcome { bottom: calc(84px + var(--safe-b)); }
}
@media (max-width: 600px) {
  :root { --page-x: 16px; --topbar-h: 56px; }
  .only-s { display: inline-flex !important; }
  .hide-s { display: none !important; }
  body { font-size: 16px; }
  .topbar-inner { gap: 8px; }
  /* 検索は虫めがねで、棒いっぱいの欄を開く */
  .search { display: none; }
  .topbar.search-open .search {
    display: flex; position: absolute; inset: 8px 12px; max-width: none; margin: 0; z-index: 2; height: auto;
    background: var(--surface); border-color: var(--focus);
  }
  .search input { font-size: 16px; }
  .shelf, .genre-strip { margin-top: 32px; }
  .ranking { margin-top: 12px; }
  .shelf-title h2 { font-size: 19px; }
  .shelf-title p { font-size: 12px; }
  .shelf-nav .nav-btn { display: none; }
  .shelf-row { grid-auto-columns: 42%; gap: 12px; margin: -4px -16px; padding: 4px 16px; scroll-padding: 0 16px; }
  .rank-rest { grid-auto-columns: 42%; margin: -4px -16px; padding: 4px 16px; scroll-padding: 0 16px; }
  .genre-row { grid-auto-columns: max-content; }
  .shelf-card h3 { font-size: 14px; line-height: 20px; }
  .shelf-card .points span:nth-child(3) { display: none; }
  .lead-card h3 { font-size: 19px; }
  .lead-card .media { border-radius: 16px; }
  .lead-card .card-foot { flex-wrap: wrap; }
  .lead-card .play { min-height: 44px; }
  .rank-tag { min-width: 28px; height: 28px; font-size: 14px; }
  .rank-1 { min-width: 36px; height: 36px; font-size: 18px; }
  .browse { margin-top: 48px; padding-bottom: 48px; }
  .browse-head h2 { font-size: 21px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 12px; }
  .grid .desc, .grid .byline .flag { display: none; }
  .grid .card-foot { flex-direction: column; align-items: stretch; }
  .grid .points span:nth-child(3) { display: none; }
  .grid .play { min-height: 40px; }
  .card h3 { font-size: 14px; line-height: 20px; }
  .poster { padding: 10px; }
  .poster-title { font-size: 15px; }
  .card > .fav { top: 2px; right: 2px; }
  .tabs button { padding: 0 10px; }
  .toolbar-right { width: 100%; justify-content: space-between; }
  .select select { font-size: 16px; }
  .g-head h1 { font-size: 24px; }
  .g-media { margin: 0 -16px; }
  .g-media .media { border-radius: 0; box-shadow: none; }
  .g-media .poster-title { font-size: 24px; }
  .d-points { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-similar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .list-head h1 { font-size: 22px; }
  .doc h1 { font-size: 24px; }
  .crumbs span[aria-current] { max-width: 40vw; }
}
@media (max-width: 920px) and (orientation: landscape) and (max-height: 500px) {
  .filters { max-height: 92dvh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .card:hover .media .shot { transform: none !important; }
}

/* 順位の札がある時は、代わりの表紙のジャンル名を出さない（札と重ならないように） */
.media:has(.rank-tag) .poster-genre { display: none; }

/* タブレットの幅：1 位のカードは絵と文を横に並べて、高くなりすぎないように */
@media (min-width: 601px) and (max-width: 920px) {
  .lead-card { display: grid; grid-template-columns: 58% minmax(0, 1fr); gap: 16px; align-items: start; }
  .lead-card .card-body { padding-top: 4px; }
  .lead-card > .fav { right: calc(42% + 6px); }
  .lead-card .card-foot { flex-wrap: wrap; }
}
@media (max-width: 600px) { .g-host { display: none; } }

/* ==== 見出しの段：全面の背景に、奥へ倒した画面の札の壁 ==== */
.page-top .hero {
  position: relative; isolation: isolate; overflow: hidden;
  height: calc(var(--topbar-h) + 360px);
  margin-top: calc(-1 * var(--topbar-h) - 1px - env(safe-area-inset-top, 0px));
}
.hero-wall {
  position: absolute; inset: 0; z-index: -1; perspective: 1400px; perspective-origin: 70% 30%;
  /* 左と下（と上の棒の裏）へ向かって、背景の色へなだらかに消える（透明度で消す） */
  -webkit-mask-image: linear-gradient(90deg, transparent 8%, rgba(0, 0, 0, .1) 34%, rgba(0, 0, 0, .9) 62%, #000 80%), linear-gradient(180deg, rgba(0, 0, 0, .25) 0, #000 26%, #000 52%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 8%, rgba(0, 0, 0, .1) 34%, rgba(0, 0, 0, .9) 62%, #000 80%), linear-gradient(180deg, rgba(0, 0, 0, .25) 0, #000 26%, #000 52%, transparent 100%);
  -webkit-mask-composite: source-in; mask-composite: intersect;
}
:root:not([data-theme="dark"]) .hero-wall::after { content: ""; position: absolute; inset: 0; background: var(--t-pink); opacity: .28; pointer-events: none; }
.wall-plane {
  position: absolute; top: -70%; left: 30%; width: 92%; height: 260%;
  display: flex; gap: 20px; transform-origin: 50% 40%;
  transform: rotateX(42deg) rotateZ(-20deg);
}
.wall-col { flex: 1; min-width: 0; }
.wall-track { display: flex; flex-direction: column; will-change: transform; }
.wall-set { display: flex; flex-direction: column; gap: 20px; padding-bottom: 20px; }
.wall-tile {
  position: relative; display: block; border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow-md); outline-offset: 3px;
  transition: box-shadow var(--t-fast) var(--ease);
}
.wall-tile:hover, .wall-tile:focus-visible { box-shadow: var(--shadow-float), 0 0 0 2px var(--surface); }
.wall-pic { display: block; aspect-ratio: 16 / 9; background: var(--tone, var(--raised)); }
.wall-pic img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.wall-name {
  position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); padding: 2px 8px; border-radius: 6px;
  font-size: 12px; line-height: 20px; background: var(--surface); color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  opacity: 0; transition: opacity var(--t-fast) var(--ease);
}
.wall-tile:hover .wall-name, .wall-tile:focus-visible .wall-name { opacity: 1; }
.hero-inner {
  position: relative; max-width: 1440px; height: 100%; margin: 0 auto;
  padding: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 52px) var(--page-x) 0;
  display: flex; flex-direction: column; align-items: flex-start; gap: 16px;
}
.hero-inner h1 .nowrap { display: inline-block; }
.hero-inner h1 { font-size: 44px; line-height: 1.2; font-weight: 500; letter-spacing: -.025em; max-width: 18em; }
.hero-facts { display: flex; flex-wrap: wrap; gap: 4px 16px; font: 400 13px/20px "JetBrains Mono", var(--font); color: var(--muted); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.hero-actions .key { color: var(--on-primary); background: transparent; border-color: color-mix(in srgb, var(--on-primary) 45%, transparent); }
.hero-to-rank { background: color-mix(in srgb, var(--surface) 88%, transparent); }

/* ランキングの段は、見出しの段の下の端に少し重ねて立ち上げる */
.page-top .ranking { position: relative; margin-top: -40px; }

/* ==== 上の棒：最初は境界なしで溶け、スクロールすると細い境界と薄いぼかし ==== */
.topbar { background: transparent; border-bottom-color: transparent; transition: background-color var(--t-menu) var(--ease), border-color var(--t-menu) var(--ease); }
body:not(.page-top) .topbar { background: var(--bg); }
.topbar.scrolled {
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom-color: var(--line);
}

/* ==== 段の見出し：少し大きく、詰めた字間。補足は mono の小さな淡い字 ==== */
.shelf-title h2, .browse-head h2 { font-size: 28px; line-height: 1.25; letter-spacing: -.02em; }
.shelf-title p, .browse-head p, .list-head p { font-family: "JetBrains Mono", var(--font); font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ==== 余白の拍子：段と段は広く、段の中は詰める ==== */
.shelf, .genre-strip { margin-top: 80px; }
.browse { margin-top: 96px; }

/* ==== カード：hover で絵の上に「見る」の矢印・枠の色が変わる（浮かせない・拡大しない） ==== */
.card:hover .media { box-shadow: none; }
.media::after { transition: box-shadow var(--t-fast) var(--ease); }
.card:hover .media::after, .card:focus-within .media::after { box-shadow: inset 0 0 0 2px var(--accent-ink); }
.go {
  position: absolute; right: 8px; bottom: 8px; z-index: 1; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm);
  opacity: 0; transform: translateX(-4px); transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.card:hover .go, .card:focus-within .go { opacity: 1; transform: none; }
.has-preview { right: auto; left: 8px; }
.media:has(.rank-tag) .has-preview { left: auto; right: 48px; }

/* ==== 絵は読み終わってから短くフェードで出る（JS が無い時はそのまま見える） ==== */
.shot, .wall-pic img { transition: opacity 320ms var(--ease), transform 2400ms var(--ease); }
.js .shot:not(.loaded), .js .wall-pic img:not(.loaded) { opacity: 0; }

/* ==== ページの行き来：押したカードの絵と作品ページの大きな絵をつなぐ（使えるブラウザだけ） ==== */
@view-transition { navigation: auto; }
.g-media .media { view-transition-name: game-shot; }
::view-transition-group(game-shot) { animation-duration: 380ms; animation-timing-function: cubic-bezier(.22, 1, .36, 1); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 220ms; }

/* ==== スマホ：右下のおまかせは、見出しの段のボタンが画面から出た後にだけ ==== */
.page-top .fab { opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity var(--t-menu) var(--ease), transform var(--t-menu) var(--ease); }
.page-top.hero-gone .fab { opacity: 1; transform: none; pointer-events: auto; }

@media (max-width: 1100px) {
  .hero-inner h1 { font-size: 38px; }
  .wall-plane { left: 22%; }
}
@media (max-width: 920px) {
  .shelf, .genre-strip { margin-top: 56px; }
}
@media (max-width: 600px) {
  .page-top .hero { height: auto; }
  .hero-wall {
    -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, .08) 0, rgba(0, 0, 0, .22) 30%, rgba(0, 0, 0, .22) 60%, transparent 100%);
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, .08) 0, rgba(0, 0, 0, .22) 30%, rgba(0, 0, 0, .22) 60%, transparent 100%);
  }
  .wall-plane { left: -10%; width: 140%; gap: 12px; }
  .wall-set { gap: 12px; padding-bottom: 12px; }
  .wall-col-5, .wall-col-6 { display: none; }
  .wall-set li:nth-child(n+4) { display: none; }
  .wall-tile { border-radius: 8px; }
  .hero-inner { height: auto; padding-top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 20px); padding-bottom: 40px; gap: 10px; }
  .hero-inner h1 { font-size: 24px; line-height: 1.32; }
  .hero-facts { font-size: 12px; gap: 2px 12px; }
  .hero-actions { gap: 8px; margin-top: 4px; width: 100%; }
  .hero-actions .btn { flex: 1; min-height: 48px; padding: 0 12px; font-size: 14px; }
  .page-top .ranking { margin-top: -20px; }
  .shelf-title h2, .browse-head h2 { font-size: 22px; }
  .shelf, .genre-strip { margin-top: 44px; }
  .browse { margin-top: 56px; }
  .go { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .wall-track { will-change: auto; }
}

/* 作品ページ：ひとこと・タグ（ジャンルは上の要点とパンくずに出すので、ここはタグだけ。# つきの静かな字） */
.g-comment { font-size: 17px; line-height: 1.8; color: var(--text); padding-left: 16px; border-left: 3px solid var(--t-pink); }
.g-tags { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.g-tags a { display: inline-flex; align-items: center; min-height: 36px; font-size: 15px; color: var(--text-2); }
.g-tags a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

/* ==== 見出しの段：文の入れ物はクリックを通し、ボタンとリンクだけ押せる（後ろの壁の札をどれも押せるように） ==== */
.hero-inner { pointer-events: none; }
.hero-inner a, .hero-inner button { pointer-events: auto; }

/* ==== 1〜3 位の札に金の王冠 ==== */
:root { --gold: #e3a92b; --gold-edge: #b9811a; }
.rank-tag { overflow: visible; }
.rank-1, .rank-2, .rank-3 { top: 16px; }
.crown { position: absolute; left: 50%; top: -10px; width: 18px; height: 12px; transform: translateX(-50%) rotate(-10deg); fill: var(--gold); stroke: var(--gold-edge); stroke-width: .8; stroke-linejoin: round; }
.rank-1 .crown { top: -17px; left: 34%; width: 28px; height: 19px; transform: translateX(-50%) rotate(-18deg); }

/* ==== 作品ページ：作者の X・ファンの作品・X で話題の行 ==== */
.creator-x { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; color: var(--text-2); white-space: nowrap; }
.creator-x .i { width: 14px; height: 14px; }
.creator-x:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.g-head .byline .creator-x + .host::before, .g-head .byline .creator + .host::before { content: "·"; margin-right: 8px; color: var(--muted); }
.xstats { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.xstats .i { width: 14px; height: 14px; flex: none; }
.g-fanwork { margin-top: 12px; font-size: 13px; color: var(--muted); }

/* ==== 格子の「もっと見る」 ==== */
.more-wrap { display: flex; justify-content: center; margin-top: 32px; }
.more-count { font-weight: 400; font-size: 13px; color: var(--muted); }

/* 長い題名：棚とカードは 2 行で切る */
.card h3 { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.g-head h1 { overflow-wrap: anywhere; }
.rank-1 { top: 22px; }

/* ロゴの副題（小さく静かな字） */
.logo-sub { font-size: 12px; font-weight: 400; letter-spacing: .04em; color: var(--muted); margin-left: 2px; }
@media (max-width: 360px) { .logo-sub { display: none; } }

/* ==== 言語ごとの書体（そのページの言語の書体だけを読む） ==== */
:root:lang(en), :root:lang(es), :root:lang(fr), :root:lang(de), :root:lang(it), :root:lang(id), :root:lang(vi), :root:lang(pl), :root:lang(nl) { --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; }
:root:lang(zh-Hans) { --font: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif; }
:root:lang(zh-Hant) { --font: "Inter", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif; }
:root:lang(ko) { --font: "Inter", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; }
:root:lang(th) { --font: "Inter", "Noto Sans Thai", "Leelawadee UI", sans-serif; }
:root:lang(hi) { --font: "Inter", "Noto Sans Devanagari", "Nirmala UI", sans-serif; }
[lang="ja"] { font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", var(--font); }

/* ==== 言語の切り替え（2 列の小さな板） ==== */
.lang-switch { position: relative; }
.lang-btn { gap: 6px; padding: 0 12px; }
.lang-btn span { font-size: 13px; }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; width: 300px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; padding: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-float);
  animation: rise var(--t-menu) var(--ease);
}
.lang-menu a { display: flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: var(--r-small); font-size: 14px; color: var(--text-2); }
.lang-menu a:hover { background: var(--raised); color: var(--text); }
.lang-menu a[aria-current] { color: var(--accent-ink); background: var(--t-pink); }
.footer-langs a[aria-current] { color: var(--text); font-weight: 500; }
.lang-hint {
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  padding: 6px 16px; font-size: 13px; color: var(--text-2); background: var(--raised); border-bottom: 1px solid var(--line);
  position: relative; z-index: 31;
}

/* ==== 日本語が読めなくても遊べるか・題名の訳 ==== */
.lang-badge { align-self: flex-start; display: inline-flex; padding: 0 8px; border-radius: 6px; font-size: 12px; line-height: 22px; color: var(--text-2); background: var(--raised); }
.lang-badge.ok { color: var(--accent-ink); background: var(--t-pink); }
.title-note { font-size: 12px; line-height: 16px; color: var(--muted); margin-top: -2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-head .title-note { font-size: 14px; line-height: 20px; white-space: normal; }
.g-langnote { margin-top: 12px; }

@media (max-width: 600px) {
  .lang-btn { padding: 0 10px; min-width: 40px; }
  .lang-btn span { font-size: 12px; }
  .lang-menu { position: fixed; left: 12px; right: 12px; top: calc(var(--topbar-h) + 8px); width: auto; }
  .lang-menu a { min-height: 44px; }
}

/* 狭いスマホ：上の棒と「遊ぶ」の帯が入りきるように */
@media (max-width: 480px) {
  .logo-sub { display: none; }
}
@media (max-width: 420px) {
  .g-actions .fav-label { display: none; }
  .g-actions .fav.btn { width: 48px; padding: 0; }
  .g-actions .g-share { width: 48px; padding: 0; }
}
@media (max-width: 380px) {
  .lang-btn span { display: none; }
  .lang-btn { width: 40px; padding: 0; }
}

/* X で話題の行：長い言語でも印と文字を 1 つの並びに（印だけが別の行に落ちないように） */
.xstats { flex-wrap: nowrap; align-items: flex-start; }
.xstats .i { margin-top: 3px; }

/* 漢字・ハングル・タイ文字・デーヴァナーガリーの言語では、補足の字を mono にしない（等幅の空白で間が開きすぎるため） */
:root:lang(ko) :is(.shelf-title p, .browse-head p, .list-head p, .hero-facts),
:root:lang(zh-Hans) :is(.shelf-title p, .browse-head p, .list-head p, .hero-facts),
:root:lang(zh-Hant) :is(.shelf-title p, .browse-head p, .list-head p, .hero-facts),
:root:lang(th) :is(.shelf-title p, .browse-head p, .list-head p, .hero-facts),
:root:lang(hi) :is(.shelf-title p, .browse-head p, .list-head p, .hero-facts) { font-family: var(--font); }
