/* ============================================================
   网页复古游戏机 · 样式
   设计令牌与 docs/tech-comparison.html 保持一致
   ============================================================ */

:root {
  color-scheme: dark;
  --page:           #0d0d0d;
  --surface-1:      #1a1a19;
  --surface-2:      #232322;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --muted:          #898781;
  --grid:           #2c2c2a;
  --axis:           #383835;
  --border:         rgba(255, 255, 255, 0.10);
  --border-strong:  rgba(255, 255, 255, 0.18);

  --accent:         #3987e5;
  --accent-soft:    #184f95;
  --good:           #0ca30c;
  --warning:        #fab219;
  --serious:        #ec835a;
  --critical:       #d03b3b;

  --font: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* ───────────────── 按钮 ───────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1;
  padding: 9px 15px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-primary);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, opacity .12s ease;
  white-space: nowrap;
}
.btn:hover { background: #2f2f2d; border-color: rgba(255,255,255,.28); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #4b93ea; border-color: #4b93ea; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-primary); }

.btn-danger:hover { background: rgba(208,59,59,.18); border-color: var(--critical); color: #ffd9d9; }

.btn-sm { padding: 6px 11px; font-size: 12.5px; }

/* ───────────────── 布局 ───────────────── */

.shell { max-width: 1080px; margin: 0 auto; padding: 26px 24px 80px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.brand { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.brand h1 { font-size: 21px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
.brand .tag { font-size: 12.5px; color: var(--muted); }

/* ───────────────── 状态徽章 ───────────────── */

.badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
}
.badge .dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--muted);
}
.badge.ok   .dot { background: var(--good); }
.badge.warn .dot { background: var(--warning); }
.badge.bad  .dot { background: var(--critical); }
.badge.ok   { color: #a8e6a8; }
.badge.warn { color: #f4d18a; }
.badge.bad  { color: #f0a6a6; }

/* ───────────────── 提示条 ───────────────── */

.notice {
  border-left: 3px solid var(--axis);
  background: var(--surface-1);
  border-radius: 0 8px 8px 0;
  padding: 13px 18px;
  margin: 0 0 22px;
  font-size: 13.5px;
  color: var(--text-secondary);
}
.notice strong { color: var(--text-primary); font-weight: 650; }
.notice.warn  { border-left-color: var(--warning); }
.notice.crit  { border-left-color: var(--critical); }
.notice p { margin: 0; }
.notice p + p { margin-top: 7px; }

/* ───────────────── 拖放区 ───────────────── */

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-1);
  padding: 44px 24px;
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
  cursor: pointer;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.drag { border-color: var(--accent); background: rgba(57,135,229,.10); }
.dropzone .big { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.dropzone .sub { font-size: 13px; color: var(--muted); }
.dropzone .sub code {
  font-family: var(--mono); font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
}

/* ───────────────── 游戏列表 ───────────────── */

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin: 32px 0 14px;
}
.section-head h2 { font-size: 16px; font-weight: 650; margin: 0; }
.section-head .count { color: var(--muted); font-weight: 400; font-size: 14px; }

.games { display: grid; gap: 10px; }

.game {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  transition: border-color .12s ease;
}
.game:hover { border-color: var(--border-strong); }

.game .meta { min-width: 0; }
.game .name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.game .sub {
  font-size: 12.5px;
  color: var(--muted);
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
.game .sys {
  display: inline-block;
  font-size: 11.5px;
  padding: 1px 8px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: #d6e6fb;
  border: 1px solid rgba(57,135,229,.45);
}
.game .actions { display: flex; gap: 8px; align-items: center; }

.game select {
  font-family: var(--font);
  font-size: 12.5px;
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  max-width: 210px;
}

/* 按机种分组的组标题 */
.sys-group-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px;
  margin: 22px 0 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.sys-group-head:first-child { margin-top: 4px; }
.sys-group-head .label { font-size: 13px; font-weight: 650; color: var(--text-secondary); }
.sys-group-head .count { font-size: 12px; color: var(--muted); }

/* 来自 roms/ 文件夹的标记 */
.game .origin {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* roms/ 文件夹区块 */
.folder-hint {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.65;
  margin: -4px 0 0;
  word-break: break-all;
}

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  padding: 30px 0;
}

/* ───────────────── 继续游戏 ───────────────── */

.resume {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 18px 22px;
  margin-bottom: 22px;
  border-radius: var(--radius);
  border: 1px solid rgba(57, 135, 229, .45);
  background: linear-gradient(135deg, rgba(57, 135, 229, .16), rgba(57, 135, 229, .03));
}
.resume .label {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .08em;
  color: var(--accent);
  margin-bottom: 5px;
}
.resume .name {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.resume .sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.resume .play { padding: 12px 24px; font-size: 14.5px; }

/* ───────────────── 内置游戏 ───────────────── */

#builtinSection { margin-bottom: 8px; }

.builtins {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 10px;
}

.builtin {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.builtin:hover { border-color: var(--accent); background: var(--surface-2); }
.builtin:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.builtin[disabled] { opacity: .5; cursor: progress; }

.builtin .title { font-size: 14px; font-weight: 600; }
.builtin .desc {
  font-size: 12px; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.builtin .row { display: flex; align-items: center; gap: 7px; margin-top: 3px; }
.builtin .sys {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: #d6e6fb;
  border: 1px solid rgba(57, 135, 229, .45);
}
.builtin .size { font-size: 11.5px; color: var(--muted); }
.builtin .state { font-size: 11.5px; color: var(--accent); margin-left: auto; }

/* ───────────────── 列表交互 ───────────────── */

.game.selected { border-color: var(--accent); }

.game .name { display: flex; align-items: center; gap: 9px; }
.game .name .text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.game .key {
  flex: none;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 5px;
  min-width: 20px;
  text-align: center;
}

.star {
  flex: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 6px 5px;
  border-radius: 6px;
  color: var(--muted);          /* 别用 --axis，那个色号在卡片上几乎看不见 */
  transition: color .12s ease, background .12s ease;
}
.star:hover { color: var(--warning); background: var(--surface-2); }
.star.on { color: var(--warning); }
.star:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.kbd {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-secondary);
}

/* ───────────────── 播放器覆盖层 ───────────────── */

.player-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  display: none;
  flex-direction: column;
}
.player-overlay.open { display: flex; }

.player-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: #111;
  border-bottom: 1px solid rgba(255,255,255,.10);
  flex: none;
}
.player-bar .title {
  font-size: 14px; font-weight: 600; color: #eee;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.player-bar .spacer { flex: 1; }
.player-bar .hint { font-size: 12.5px; color: var(--muted); }

.player-frame { flex: 1; border: 0; width: 100%; display: block; background: #000; }

/* ───────────────── 页脚 ───────────────── */

.footer {
  margin-top: 44px; padding-top: 22px;
  border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--muted);
}
.footer p { margin: 6px 0; }

/* ───────────────── 播放器页专用 ───────────────── */

body.player {
  background: #000;
  overflow: hidden;
}
#game {
  width: 100%;
  height: 100%;
}
.player-status {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  color: var(--text-secondary);
  font-size: 14px;
  background: #000;
  z-index: 10;
}
.player-status.hidden { display: none; }
.player-status .spin {
  width: 26px; height: 26px;
  border: 2.5px solid rgba(255,255,255,.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.player-error { max-width: 560px; text-align: center; line-height: 1.7; }
.player-error code {
  font-family: var(--mono); font-size: 12px;
  background: #1a1a19; border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
