/*
 * [INPUT]: 依赖 templates.mjs 的语义结构与 app.js 的状态属性。
 * [OUTPUT]: 提供首页拼贴、游戏播放器、交互状态及响应式布局。
 * [POS]: 唯一视觉入口，以内容封面为视觉中心，不依赖第三方字体或样式服务。
 * [PROTOCOL]: 变更时更新此头部，然后检查 CLAUDE.md
 */
:root {
  --sky: #e8f5ff; --paper: #fff; --blue: #1677ff; --ink: #082c59;
  --orange: #ffb84c; --mint: #a1e7d8; --muted: #52708c; --rail: 100px;
  font-family: 'Trebuchet MS', 'Microsoft YaHei UI', 'Microsoft YaHei', sans-serif;
  color: var(--ink); background: var(--sky); font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; opacity: .4; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button, input { border: 0; }
button { background: none; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #034dcb; outline-offset: 5px; }
.icon { width: 23px; height: 23px; flex-shrink: 0; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: fixed; top: -70px; left: 120px; z-index: 20; padding: 12px; background: white; border-radius: 8px; }
.skip-link:focus { top: 10px; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--rail); background: var(--paper); display: flex; flex-direction: column; align-items: center; padding: 26px 10px 20px; z-index: 5; border-right: 1px solid #d8eaf6; }
.brand { display: flex; align-items: center; flex-direction: column; margin-bottom: 32px; }
.brand-symbol { display: grid; place-items: center; width: 53px; height: 47px; background: var(--blue); color: white; border-radius: 17px 17px 17px 5px; transform: rotate(-6deg); margin-bottom: 11px; box-shadow: 3px 4px 0 #c4e2ff; }
.brand-symbol .icon { width: 32px; height: 32px; transform: rotate(6deg); }
.brand b { font-size: 19px; letter-spacing: -1px; }
.brand small { font-size: 8px; letter-spacing: 2px; margin-top: 3px; font-weight: 800; }
.sidebar nav { width: 100%; display: flex; flex-direction: column; gap: 7px; }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 13px 3px; border-radius: 15px; color: var(--muted); font-size: 11px; font-weight: 700; }
.nav-item:hover { background: #f1f8ff; color: var(--blue); }
.nav-item.active { background: #e8f2ff; color: #0861d6; }
.nav-divider { height: 1px; background: #e9f0f7; margin: 10px 12px; }
.sidebar-random { margin-top: auto; padding: 14px; color: var(--blue); border-radius: 16px; }
.sidebar-random:hover { background: var(--sky); }
.sidebar-caption { font-size: 10px; color: var(--muted); margin-top: 7px; }
.site-wrap { margin-left: var(--rail); padding: 0 34px; max-width: 1850px; }
.topbar { min-height: 100px; display: flex; gap: 22px; align-items: center; border-bottom: 1px solid #d4e7f6; }
.topbar-title { font-size: 14px; font-weight: 700; white-space: nowrap; }
.tiny-spark { margin-left: 12px; color: var(--blue); font-size: 21px; }
.search { margin-left: auto; width: min(370px, 40%); height: 46px; border-radius: 14px; background: white; display: flex; align-items: center; padding: 0 15px; gap: 10px; border: 1px solid #d8e9f6; }
.search:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px #1677ff16; }
.search .icon { width: 19px; color: #6886a3; }
.search input { width: 100%; min-width: 0; outline: none; background: transparent; color: var(--ink); font-size: 13px; }
.search input::placeholder { color: #73899e; }
.search kbd { font-family: inherit; font-size: 12px; padding: 1px 7px; color: #708da4; background: #f1f7fc; border-radius: 5px; }
.random-top { display: flex; gap: 9px; align-items: center; font-size: 13px; font-weight: 700; padding: 12px 0 12px 4px; white-space: nowrap; }
.random-top:hover { color: var(--blue); }
main { padding-top: 34px; }
.welcome { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
h1, h2, p { margin: 0; }
.welcome h1 { font-size: clamp(25px, 2.45vw, 38px); font-weight: 900; letter-spacing: -1.6px; line-height: 1.5; }
.heading-spark { font-size: 36px; color: var(--blue); margin-left: 14px; vertical-align: middle; }
.welcome p { margin-top: 5px; font-size: 13px; color: var(--muted); }
.game-count { display: flex; gap: 7px; align-items: center; font-size: 12px; color: var(--muted); padding-top: 10px; }
.game-count .icon { color: var(--blue); margin-right: 2px; }
.game-count b { color: var(--ink); font-size: 17px; }
.categories { display: flex; gap: 10px; overflow-x: auto; padding: 3px 3px 9px; margin-left: -3px; margin-bottom: 22px; scrollbar-width: none; }
.categories::-webkit-scrollbar { display: none; }
.category { display: flex; flex-shrink: 0; align-items: center; gap: 8px; padding: 12px 17px; background: white; border: 1px solid #d8e8f4; border-radius: 13px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.category .icon { width: 19px; height: 19px; }
.category.selected { background: var(--blue); color: white; border-color: var(--blue); box-shadow: 0 4px 10px #1677ff23; }
.category:hover:not(.selected) { border-color: #90bced; background: #f7fcff; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 17px; gap: 16px; }
.section-heading h2 { font-size: 18px; letter-spacing: -.3px; font-weight: 800; }
.section-heading > span { color: var(--muted); font-size: 12px; }
.game-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 15px; }
.game-grid.mosaic { grid-auto-flow: dense; grid-auto-rows: clamp(145px, 13.7vw, 230px); }
.game-card { position: relative; display: block; overflow: hidden; border-radius: 19px; background: var(--card-color, #b8d4eb); aspect-ratio: 1.14; isolation: isolate; box-shadow: 0 3px 0 #092c5910; }
.mosaic .game-card { aspect-ratio: auto; }
.mosaic .game-card-large { grid-column: span 2; grid-row: span 2; }
.game-card img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .24s ease; }
.game-card::after { content: ''; position: absolute; inset: 20% 0 0; background: linear-gradient(transparent 30%, #061329b8 100%); pointer-events: none; }
.game-card:hover img { transform: scale(1.045); }
.game-card:hover { outline: 3px solid white; box-shadow: 0 5px 16px #285f8433; }
.card-caption { position: absolute; left: 13px; right: 12px; bottom: 12px; z-index: 1; color: white; display: flex; align-items: end; justify-content: space-between; gap: 6px; text-shadow: 0 1px 3px #0005; }
.card-caption strong { display: block; font-size: 13px; line-height: 1.4; }
.card-caption small { display: block; font-size: 10px; margin-top: 3px; color: #ffffffe0; }
.mosaic .game-card-large .card-caption { left: 23px; bottom: 22px; right: 22px; }
.mosaic .game-card-large strong { font-size: 26px; letter-spacing: -.5px; }
.mosaic .game-card-large small { font-size: 13px; margin-top: 5px; }
.card-play { display: flex; flex-shrink: 0; align-items: center; justify-content: center; width: 29px; height: 29px; background: #ffffff2b; border: 1px solid #ffffff55; border-radius: 50%; }
.card-play .icon { width: 17px; height: 17px; }
.mosaic .game-card-large .card-play { width: 45px; height: 45px; background: white; color: var(--blue); border: 0; }
.mosaic .game-card-large .card-play .icon { width: 26px; height: 26px; }
.card-badge { position: absolute; top: 11px; left: 11px; padding: 5px 9px; background: #fff; color: var(--ink); z-index: 1; font-size: 10px; font-weight: 800; border-radius: 7px; box-shadow: 0 2px 5px #0001; }
.mosaic .game-card-large .card-badge { top: 17px; left: 17px; background: var(--orange); font-size: 11px; padding: 7px 11px; transform: rotate(-3deg); }
.card-saved { position: absolute; right: 10px; top: 10px; z-index: 2; color: #ed4474; background: white; padding: 6px; border-radius: 50%; }
.card-saved .icon { width: 15px; height: 15px; fill: currentColor; display: block; }
.mood-section { margin-top: 34px; }
.mood-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.mood-card { display: flex; gap: 14px; align-items: center; border-radius: 18px; padding: 23px 19px; }
.mood-card > .icon { width: 18px; margin-left: auto; }
.mood-race { background: #ffe3bf; }
.mood-puzzle { background: #d7dcff; }
.mood-friends { background: #c4eee5; }
.mood-card:hover { box-shadow: inset 0 0 0 2px #082c5926; }
.mood-icon { background: #ffffff65; border-radius: 13px; width: 45px; height: 45px; display: grid; place-items: center; flex-shrink: 0; }
.mood-icon .icon { width: 28px; height: 28px; }
.mood-card strong { font-size: 15px; display: block; }
.mood-card small { display: block; font-size: 11px; color: #415a77; margin-top: 6px; }
footer { display: flex; align-items: center; flex-wrap: wrap; gap: 18px; padding: 29px 0; margin-top: 34px; border-top: 1px solid #cfe4f3; color: var(--muted); font-size: 11px; }
.footer-brand { color: var(--ink); font-size: 17px; font-weight: 900; }
.footer-brand span { font-size: 9px; margin-left: 7px; letter-spacing: 1px; }
.empty-state { padding: 65px 20px; text-align: center; min-height: 320px; background: #ffffff70; border-radius: 20px; }
.empty-state > .icon { width: 42px; height: 42px; color: var(--blue); margin-bottom: 16px; }
.empty-state h2 { font-size: 21px; }
.empty-state p { font-size: 14px; color: var(--muted); margin: 12px 0 24px; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 13px 23px; font-size: 14px; border-radius: 13px; font-weight: 700; color: white; background: var(--blue); }
.primary-button:hover { background: #0961d8; }
.breadcrumbs { display: flex; align-items: center; gap: 15px; margin-bottom: 23px; font-size: 13px; color: var(--muted); }
.breadcrumbs a { color: var(--ink); display: inline-flex; align-items: center; gap: 8px; }
.breadcrumbs .icon { width: 17px; height: 17px; }
.play-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 25px; }
.play-main { min-width: 0; }
.player-shell { background: white; border-radius: 22px; overflow: hidden; box-shadow: 0 6px 20px #15427310; }
.player-stage { width: 100%; aspect-ratio: var(--game-ratio); max-height: 72vh; min-height: 300px; background: #163854; position: relative; }
.player-cover { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; flex-direction: column; position: absolute; inset: 0; overflow: hidden; color: white; padding: 22px; isolation: isolate; }
.player-cover::before { content: ''; position: absolute; inset: -30px; background: linear-gradient(#092440a3, #092440e6), var(--cover) center/cover; filter: blur(8px); z-index: -1; }
.player-thumbnail { width: 150px; height: 112px; object-fit: cover; border-radius: 19px; border: 3px solid #ffffff4a; box-shadow: 0 8px 30px #0003; margin-bottom: 17px; }
.player-cover h1 { font-size: 27px; line-height: 1.4; text-align: center; }
.player-cover p { margin: 7px 0 21px; color: #d5e7f4; font-size: 12px; }
.play-button { background: var(--orange); color: #382109; min-width: 170px; font-size: 17px; box-shadow: 0 5px 0 #cc8830; }
.play-button:hover { background: #ffc76e; }
.desktop-notice { font-size: 11px; margin-top: 10px; color: #fff3cd; }
#game-frame { border: 0; width: 100%; height: 100%; display: block; position: absolute; inset: 0; background: #fff; }
.player-stage:fullscreen { max-height: none; width: 100vw; height: 100vh; background: #000; }
.player-toolbar { min-height: 79px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 18px; }
.player-game-title { display: flex; align-items: center; gap: 11px; min-width: 0; }
.player-game-title img { width: 43px; height: 43px; object-fit: cover; border-radius: 10px; }
.player-game-title strong { font-size: 14px; display: block; }
.player-game-title small { font-size: 10px; color: var(--muted); display: block; margin-top: 3px; }
.player-actions { display: flex; align-items: center; gap: 5px; }
.icon-button { border-radius: 10px; padding: 10px; display: inline-flex; }
.icon-button:hover { background: #edf5fc; }
.icon-button[aria-pressed="true"] { color: #e93871; }
.icon-button[aria-pressed="true"] .icon { fill: currentColor; }
.icon-button .icon { width: 21px; height: 21px; }
.fullscreen-button { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; background: #e9f3ff; color: #1167d6; border-radius: 10px; padding: 11px; margin-left: 4px; }
.fullscreen-button .icon { width: 19px; height: 19px; }
.load-help { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin: 14px 3px 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.load-help a { color: #0759bd; text-decoration: underline; }
.game-info { display: grid; gap: 25px; padding: 27px 3px; }
.game-info h2 { font-size: 17px; margin-bottom: 9px; }
.game-info p { font-size: 13px; color: var(--muted); line-height: 1.9; max-width: 70ch; }
.related-games h2 { font-size: 16px; margin: 0 0 17px; }
.related-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.related-grid .game-card { border-radius: 14px; aspect-ratio: .9; }
.related-grid .card-caption { left: 9px; bottom: 10px; right: 9px; }
.related-grid .card-caption strong { font-size: 11px; }
.related-grid .card-caption small, .related-grid .card-play, .related-grid .card-badge { display: none; }
.random-related { width: 100%; margin-top: 17px; padding: 14px; background: white; border-radius: 13px; display: flex; gap: 10px; justify-content: center; align-items: center; font-size: 12px; font-weight: 700; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 25px; transform: translateX(-50%); background: var(--ink); color: white; border-radius: 13px; padding: 14px 22px; box-shadow: 0 6px 25px #082c5933; max-width: calc(100% - 28px); width: max-content; font-size: 13px; }
dialog { border: 0; border-radius: 22px; padding: 32px; width: min(460px, calc(100% - 30px)); color: var(--ink); box-shadow: 0 15px 80px #082c5940; }
dialog::backdrop { background: #082c5966; backdrop-filter: blur(4px); }
dialog h2 { font-size: 23px; margin-top: 10px; }
dialog p { font-size: 13px; color: var(--muted); margin: 13px 0; }
dialog input { width: 100%; border: 1px solid #c8dded; padding: 13px; border-radius: 9px; color: var(--ink); font-size: 12px; margin-bottom: 19px; }
.dialog-close { position: absolute; top: 10px; right: 10px; }
.not-found { text-align: center; padding: 90px 0; }
.not-found > .icon { width: 75px; height: 75px; color: var(--blue); margin-bottom: 25px; }
.not-found p { margin: 16px 0 25px; color: var(--muted); }
.noscript { padding: 15px; background: white; margin: 15px; }
@media (min-width: 1600px) { .site-wrap { padding: 0 50px; } .game-grid { gap: 19px; } }
@media (max-width: 1180px) {
  :root { --rail: 86px; }
  .site-wrap { padding: 0 24px; }
  .topbar-title { font-size: 12px; }
  .game-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .game-grid.mosaic { grid-auto-rows: clamp(140px, 17vw, 200px); }
  .category { padding: 11px 13px; }
  .mood-card { padding: 18px 14px; gap: 10px; }
  .mood-card > .icon { display: none; }
  .mood-card strong { font-size: 13px; }
  .mood-icon { width: 35px; height: 40px; }
  .mood-card small { font-size: 10px; }
  .play-layout { grid-template-columns: minmax(0, 1fr) 210px; gap: 18px; }
  .player-game-title img { display: none; }
  .player-toolbar { padding: 12px; }
  .fullscreen-button span { display: none; }
}
@media (max-width: 850px) {
  .topbar-title { display: none; }
  .search { margin-left: 0; width: auto; flex: 1; }
  .topbar { min-height: 80px; }
  .game-count { display: none; }
  .mood-grid { grid-template-columns: 1fr; gap: 10px; }
  .mood-card > .icon { display: block; }
  .mood-card { padding: 16px; }
  .mood-card strong { font-size: 15px; }
  .mood-card small { font-size: 12px; }
  .play-layout { grid-template-columns: minmax(0, 1fr); }
  .related-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .related-grid .game-card { aspect-ratio: 1.2; }
  .related-grid .card-caption strong { font-size: 13px; }
  .player-game-title img { display: block; }
}
@media (max-width: 600px) {
  :root { --rail: 0px; }
  .sidebar { position: static; width: 100%; height: 68px; padding: 0 16px; flex-direction: row; border-right: none; border-bottom: 1px solid #d8eaf6; gap: 20px; }
  .brand { flex-direction: row; margin: 0 auto 0 0; gap: 9px; }
  .brand-symbol { width: 35px; height: 34px; border-radius: 12px 12px 12px 4px; margin-bottom: 0; }
  .brand-symbol .icon { width: 24px; height: 24px; }
  .brand b { font-size: 20px; }
  .brand small { display: none; }
  .sidebar nav { width: auto; flex-direction: row; gap: 4px; }
  .nav-item { padding: 9px; border-radius: 11px; }
  .nav-item span, .nav-divider, .sidebar-random, .sidebar-caption, .sidebar nav > a:nth-of-type(n+4) { display: none; }
  .nav-item .icon { width: 22px; height: 22px; }
  .nav-item::after { content: attr(aria-label); display: none; }
  .site-wrap { padding: 0 16px; }
  .topbar { min-height: 76px; gap: 12px; border-bottom: none; }
  .search { height: 43px; }
  .search kbd { display: none; }
  .random-top { gap: 5px; font-size: 11px; }
  .random-top .icon { width: 20px; }
  main { padding-top: 7px; }
  .welcome { margin-bottom: 19px; }
  .welcome h1 { font-size: 27px; letter-spacing: -1px; }
  .heading-spark { font-size: 28px; margin-left: 9px; }
  .welcome p { font-size: 11px; margin-top: 5px; }
  .categories { margin-right: -16px; padding-right: 16px; margin-bottom: 17px; gap: 8px; }
  .category { padding: 10px 12px; font-size: 12px; border-radius: 11px; }
  .section-heading { margin-bottom: 13px; }
  .section-heading h2 { font-size: 15px; }
  .section-heading > span { font-size: 10px; }
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .game-grid.mosaic { grid-auto-rows: auto; }
  .mosaic .game-card { aspect-ratio: 1.1; }
  .mosaic .game-card-large { grid-column: span 2; grid-row: auto; aspect-ratio: 1.85; }
  .game-card { border-radius: 16px; }
  .mosaic .game-card-large .card-caption { left: 17px; bottom: 16px; right: 17px; }
  .mosaic .game-card-large strong { font-size: 23px; }
  .mosaic .game-card-large small { font-size: 11px; }
  .mosaic .game-card-large .card-badge { left: 13px; top: 13px; }
  .mood-section { margin-top: 27px; }
  .mood-section .section-heading > span { display: none; }
  footer { gap: 12px; padding: 22px 0; margin-top: 25px; }
  footer p { font-size: 10px; }
  .breadcrumbs { font-size: 11px; margin-bottom: 16px; }
  .player-shell { border-radius: 17px; }
  .player-stage { min-height: 310px; max-height: none; }
  .player-thumbnail { width: 105px; height: 79px; margin-bottom: 12px; }
  .player-cover h1 { font-size: 23px; }
  .player-cover p { margin-bottom: 16px; }
  .player-toolbar { flex-wrap: wrap; gap: 9px; }
  .player-game-title { flex: 1; }
  .player-game-title img { display: none; }
  .player-game-title strong { font-size: 11px; }
  .player-actions { gap: 0; }
  .icon-button { padding: 9px; }
  .icon-button .icon { width: 18px; height: 18px; }
  .fullscreen-button { padding: 9px; margin-left: 0; }
  .game-info { padding: 22px 0 12px; gap: 21px; }
  .game-info p { font-size: 12px; }
  .related-grid { gap: 10px; }
  .related-grid .game-card { aspect-ratio: .92; }
  .related-grid .card-caption strong { font-size: 11px; }
  .toast { bottom: 15px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
