/* =========================================================================
 * 全站共用样式 · 玩点什么
 * 主页与所有游戏页共用这一份：设计变量、顶栏、按钮、页脚、Toast、卡片。
 * 游戏各自的专属样式写在自己目录下的 style.css 里。
 * ========================================================================= */

:root {
  --paper:    #f7f4ed;
  --paper-2:  #fffdf8;
  --ink:      #1f2328;
  --ink-2:    #4a5058;
  --ink-3:    #858c95;
  --line:     #ddd6c8;
  --line-2:   #c9c0ae;
  --red:      #c8442e;
  --red-soft: #fbeeea;
  --blue:     #2f5d8c;
  --blue-soft:#eaf0f7;
  --green:    #2e7d5b;
  --green-soft:#e8f3ee;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 999px;

  --sh-1: 0 1px 2px rgba(31,35,40,.06);
  --sh-2: 0 4px 16px rgba(31,35,40,.10);

  --dur: 200ms;
  --ease: cubic-bezier(.2,.7,.3,1);

  --col: 480px;
  --pad: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; background: var(--paper); color: var(--ink); }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: rgba(47,93,140,.12);
}

img { max-width: 100%; height: auto; display: block; }
button { font: inherit; color: inherit; }
a { color: var(--blue); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 60;
  background: var(--ink); color: var(--paper);
  padding: 10px 14px; border-radius: 0 0 var(--r-sm) 0;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; max-width: var(--col); margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) var(--pad) 10px;
  background: rgba(247,244,237,.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; min-height: 40px; }

.brand {
  background: none; border: 0; padding: 6px 4px; margin: 0;
  font-size: 16px; font-weight: 700; letter-spacing: .06em;
  cursor: pointer; min-height: 40px; text-decoration: none; color: inherit;
  display: inline-flex; align-items: center;
}

/* 每个游戏页左上角的「‹ 全部游戏」入口 */
.backlink {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 40px; padding: 4px 12px 4px 8px;
  border: 1px solid var(--line-2); border-radius: var(--r-pill);
  background: var(--paper-2); color: var(--ink-2);
  font-size: 14px; text-decoration: none;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.backlink:hover { border-color: var(--ink-3); color: var(--ink); }

/* ---------------------------------------------------------------- 声音 */
.sound-btn {
  width: 40px; height: 40px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); border-radius: 50%;
  background: var(--paper-2); cursor: pointer; padding: 0;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.sound-btn:hover { border-color: var(--ink-3); }
.sound-btn.is-on { border-color: var(--green); background: var(--green-soft); }

/* 音符图标：纯 CSS，不引任何图 */
.sound-icon {
  position: relative; display: block;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--ink-2);
  margin: 5px 6px 0 0;
}
.sound-icon::before {
  content: ''; position: absolute; left: 4px; bottom: 2px;
  width: 1.6px; height: 13px; background: var(--ink-2);
}
.sound-icon::after {
  content: ''; position: absolute; left: 4px; bottom: 11px;
  width: 7px; height: 4px;
  border-top: 1.6px solid var(--ink-2);
  border-right: 1.6px solid var(--ink-2);
  border-top-right-radius: 5px;
}
.sound-btn.is-on .sound-icon,
.sound-btn.is-on .sound-icon::before { background: var(--green); }
.sound-btn.is-on .sound-icon::after { border-color: var(--green); }

.sound-panel {
  position: absolute; top: calc(100% + 8px); right: var(--pad);
  z-index: 50;
  width: min(260px, calc(100vw - 32px));
  background: var(--paper-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  box-shadow: var(--sh-2);
  padding: 6px 14px 12px;
  animation: viewIn 160ms var(--ease) both;
}
.sound-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; min-height: 44px;
}
.sound-row + .sound-row { border-top: 1px solid var(--line); }
.sound-label { font-size: 15px; color: var(--ink); }

.switch {
  flex: none; width: 46px; height: 27px; padding: 0;
  border: 1px solid var(--line-2); border-radius: var(--r-pill);
  background: #e7e1d4; cursor: pointer; position: relative;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.switch-knob {
  position: absolute; top: 2px; left: 2px;
  width: 21px; height: 21px; border-radius: 50%;
  background: var(--paper-2); box-shadow: var(--sh-1);
  transition: transform var(--dur) var(--ease);
}
.switch[aria-checked="true"] { background: var(--green); border-color: var(--green); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(19px); }

#volRange {
  flex: 1 1 auto; min-width: 0; max-width: 130px;
  accent-color: var(--green);
  height: 24px;
}

.sound-note {
  margin: 8px 0 0; padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-3); line-height: 1.6;
}

.reduced-motion .sound-panel { animation: none; }
.reduced-motion .switch-knob { transition: none; }

/* ---------------------------------------------------------------- 主区 */
main { width: 100%; max-width: var(--col); margin: 0 auto; padding: 0 var(--pad); }
[hidden] { display: none !important; }

.view { padding: 22px 0 40px; animation: viewIn var(--dur) var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 10px 20px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-2);
  background: var(--paper-2);
  color: var(--ink);
  font-size: 15px; font-weight: 500;
  cursor: pointer; touch-action: manipulation; text-decoration: none;
  transition: transform 120ms var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn:active { transform: scale(.975); }
.btn:hover { border-color: var(--ink-3); }
.btn-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 650; }
.btn-primary:hover { background: #2c333b; border-color: #2c333b; }
.btn-lg { min-height: 54px; padding: 12px 46px; font-size: 17px; }

/* ---------------------------------------------------------------- 主页 */
.hub-hero { text-align: center; padding: 8px 0 30px; }
.hub-title { font-size: 32px; margin: 0 0 10px; letter-spacing: .1em; font-weight: 700; }
.hub-sub { margin: 0 0 6px; font-size: 16px; color: var(--ink-2); }
.hub-meta { margin: 0; font-size: 13px; color: var(--ink-3); }

.hub-sec-title {
  font-size: 13px; color: var(--ink-3); letter-spacing: .16em;
  margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}

.game-list { list-style: none; margin: 0 0 30px; padding: 0; display: flex; flex-direction: column; gap: 12px; }

.game-card {
  display: flex; align-items: stretch; gap: 14px;
  padding: 14px;
  background: var(--paper-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  color: inherit; text-decoration: none;
  transition: transform 120ms var(--ease), border-color var(--dur) var(--ease);
}
a.game-card:active { transform: scale(.99); }
a.game-card:hover { border-color: var(--ink-3); }

.game-card.is-soon { opacity: .78; border-style: dashed; box-shadow: none; }

.game-thumb {
  flex: none; width: 76px; border-radius: var(--r-sm);
  background: var(--paper);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.game-thumb svg { width: 100%; height: 100%; display: block; }

.game-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.game-name { font-size: 18px; font-weight: 650; overflow-wrap: anywhere; }
.game-desc { font-size: 14px; color: var(--ink-2); line-height: 1.55; overflow-wrap: anywhere; }
.game-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag {
  font-size: 12px; color: var(--ink-3);
  border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: 1px 9px; background: var(--paper);
}
.tag-live { color: var(--green); border-color: #bcdccc; background: var(--green-soft); }
.tag-soon { color: var(--ink-3); }

/* ---------------------------------------------------------------- 页脚 */
.sitefoot {
  max-width: var(--col); margin: 30px auto 0;
  padding: 16px var(--pad) calc(env(safe-area-inset-bottom, 0px) + 28px);
  border-top: 1px solid var(--line);
  color: var(--ink-3); font-size: 12px; line-height: 1.7;
}
.sitefoot p { margin: 0 0 4px; }
.sitefoot-brand {
  margin-top: 10px !important; padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 4px 12px; letter-spacing: .04em;
}
.sitefoot-brand a { color: var(--ink-3); text-decoration: none; }
.sitefoot-brand a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 26px);
  transform: translateX(-50%); z-index: 70;
  max-width: min(88vw, 420px);
  background: var(--ink); color: var(--paper);
  padding: 10px 16px; border-radius: var(--r-pill);
  font-size: 14px; box-shadow: var(--sh-2);
  animation: toastIn 180ms var(--ease) both;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------------------------------------------------------------- 宽屏 */
@media (min-width: 700px) {
  :root { --col: 560px; }
}
@media (min-width: 1100px) {
  :root { --col: 620px; }
  body { background: #efe9dc; }
  main, .topbar, .sitefoot {
    background: var(--paper);
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
  main { min-height: 58vh; }
  .sitefoot { margin-top: 0; border-bottom: 1px solid var(--line); border-radius: 0 0 var(--r-lg) var(--r-lg); }
}

/* ---------------------------------------------------------------- 降级 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
.reduced-motion .view { animation: none; }
.reduced-motion .btn:active,
.reduced-motion a.game-card:active { transform: none; }

@media (prefers-contrast: more) {
  :root { --ink-2: #2b3037; --ink-3: #565d66; --line: #b9b1a1; --line-2: #8d8577; }
}
