:root {
  --bg: #0e0d12;
  --panel: #17151d;
  --line: #2a2732;
  --text: #ece8e1;
  --muted: #9a94a3;
  --accent: #c9a26b;
  --accent-ink: #1a1408;
  --danger: #e07a6b;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #2a1f2e 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* 顶栏 */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px max(20px, env(safe-area-inset-left)) 14px max(20px, env(safe-area-inset-right));
  background: rgba(14, 13, 18, .82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .12em; }
.top-nav { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.who { color: var(--muted); max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 10px 18px; min-height: 44px; transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { border-color: #4a4552; }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link { background: none; border: 0; padding: 4px 2px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--text); }

/* 首屏 */
main { max-width: 1120px; margin: 0 auto; padding: 0 20px 40px; }
.hero { padding: 56px 0 36px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 12px; letter-spacing: .3em; }
.hero h1 { margin: 0 0 12px; font-size: clamp(30px, 6vw, 48px); line-height: 1.2; letter-spacing: .04em; }
.lead { margin: 0; max-width: 36em; color: var(--muted); }

/* 游戏卡片 */
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.cover { aspect-ratio: 16 / 9; background: linear-gradient(135deg, #1e2a33, #101418 70%); position: relative; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: #4f5a63; font-size: 28px; letter-spacing: .4em; }
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h3 { margin: 0; font-size: 20px; }
.tag { color: var(--accent); font-size: 13px; }
.blurb { margin: 0; color: var(--muted); font-size: 15px; flex: 1; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.save-hint { color: var(--muted); font-size: 13px; }

.foot { text-align: center; color: #5d5866; font-size: 13px; padding: 24px 20px calc(24px + var(--safe-b)); }

/* 弹层：桌面居中卡片，手机从底部升起 */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; padding: 20px; }
.sheet[hidden] { display: none; }
.sheet-card {
  position: relative; width: 100%; max-width: 400px; max-height: 90vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 24px 24px;
}
.wide-card { max-width: 640px; }
.sheet-card h2 { margin: 0 0 4px; font-size: 20px; }
.close { position: absolute; right: 10px; top: 8px; width: 40px; height: 40px; border: 0; background: none; font-size: 24px; color: var(--muted); }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: none; border: 0; padding: 10px 0; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
form label { display: block; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
form label[hidden] { display: none; }
input {
  display: block; width: 100%; margin-top: 6px; min-height: 46px; padding: 10px 12px;
  background: #0f0e13; border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-size: 16px; /* 16px 防 iOS 聚焦放大 */
}
input:focus { outline: none; border-color: var(--accent); }
.row { display: flex; gap: 8px; margin-top: 6px; }
.row input { margin-top: 0; flex: 1; min-width: 0; }
.row .btn { white-space: nowrap; border-radius: 10px; }
.msg { min-height: 1.4em; margin: 0 0 10px; color: var(--danger); font-size: 14px; }
.msg.ok { color: #8fc49a; }
.sub { margin: 12px 0 0; text-align: center; font-size: 14px; color: var(--muted); }

/* 存档列表 */
.save-game { margin-top: 20px; }
.save-game h4 { margin: 0 0 8px; font-size: 15px; }
.slot { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.slot img, .slot .ph { width: 96px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; background: #0f0e13; flex: none; }
.slot .info { flex: 1; min-width: 0; font-size: 14px; }
.slot .info b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .info span { color: var(--muted); font-size: 13px; }
.slot .del { color: var(--danger); }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); z-index: 30;
  background: #26232c; border: 1px solid var(--line); border-radius: 999px; padding: 10px 18px; font-size: 14px;
}

@media (max-width: 640px) {
  .hero { padding: 32px 0 24px; }
  .games { grid-template-columns: 1fr; gap: 16px; }
  .who { display: none !important; }
  .sheet { align-items: flex-end; padding: 0; }
  .sheet-card { max-width: none; border-radius: 18px 18px 0 0; padding-bottom: calc(24px + var(--safe-b)); max-height: 92vh; }
}
@media (prefers-reduced-motion: no-preference) {
  .card { transition: transform .2s, border-color .2s; }
  .card:hover { transform: translateY(-2px); border-color: #3a3542; }
}
