.cheat-dialog {
  --cheat-ink: #17264f; --cheat-muted: #586477; --cheat-line: #dccdbb; --cheat-surface: #fffdf7;
  box-sizing: border-box; width: min(680px, var(--stage-width, 94vw)); max-width: var(--stage-width, 94vw);
  height: min(360px, var(--stage-height, 90vh)); max-height: var(--stage-height, 90vh);
  margin: auto; padding: 14px; border: 2px solid var(--cheat-line); border-radius: 18px;
  background: var(--cheat-surface); color: var(--cheat-ink); overflow: hidden;
  font: 14px/1.5 "Microsoft YaHei UI", "PingFang SC", sans-serif;
  box-shadow: 0 16px 64px #07112555; text-align: left; touch-action: pan-y;
}
.cheat-dialog[open] { display: flex; flex-direction: column; gap: 10px; }
.cheat-dialog.cheat-management { height: min(620px, var(--stage-height, 90vh)); }
.cheat-dialog::backdrop { background: #101a37a3; }
.cheat-dialog *, .cheat-dialog *::before, .cheat-dialog *::after { box-sizing: border-box; }
.cheat-dialog [hidden] { display: none !important; }
.cheat-dialog button, .cheat-dialog input, .cheat-dialog select, .cheat-dialog textarea { font: inherit; }
.cheat-dialog button { min-height: 44px; padding: 8px 14px; border: 1px solid var(--cheat-line); border-radius: 12px; color: var(--cheat-ink); background: #f5f1e8; cursor: pointer; touch-action: manipulation; }
.cheat-dialog button:disabled { opacity: .55; cursor: default; }
.cheat-dialog :focus-visible { outline: 3px solid #3772b7; outline-offset: 3px; }
.cheat-dialog h2, .cheat-dialog h3, .cheat-dialog p { margin: 0; }
.cheat-header, .cheat-rom, .cheat-navigation, .cheat-status, .cheat-footnote { flex: none; }
.cheat-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.cheat-header h2 { font-size: 20px; letter-spacing: .04em; }
.cheat-header button { flex: none; }
.cheat-subtitle, .cheat-footnote, .cheat-help { color: var(--cheat-muted); font-size: 12px; }
.cheat-dialog .cheat-primary { background: #f8ce67; border-color: #cfaa4f; font-weight: 700; }
.cheat-rom { color: var(--cheat-muted); font-size: 12px; overflow-wrap: anywhere; }
.cheat-navigation { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.cheat-tabs, .cheat-toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.cheat-tabs button[aria-pressed="true"] { background: var(--cheat-ink); color: #fffdf7; border-color: var(--cheat-ink); }
.cheat-toolbar button { font-size: 12px; }
.cheat-list-pane, .cheat-form-pane { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 3px 6px 3px 3px; }
.cheat-list-pane::-webkit-scrollbar, .cheat-form-pane::-webkit-scrollbar { width: 6px; }
.cheat-list-pane::-webkit-scrollbar-thumb, .cheat-form-pane::-webkit-scrollbar-thumb { background: #bcae9b; border-radius: 6px; }
.cheat-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 8px; }
.cheat-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 12px; padding: 10px 12px; border: 1px solid var(--cheat-line); border-radius: 12px; background: #fff; }
.cheat-card-body { min-width: 0; overflow-wrap: anywhere; }
.cheat-card h3 { font-size: 15px; color: var(--cheat-ink); }
.cheat-card-body > p { margin-top: 3px; }
.cheat-card-body > p:not(.cheat-reason) { color: var(--cheat-muted); }
.cheat-custom { display: block; margin-top: 3px; color: var(--cheat-muted); font-size: 12px; }
.cheat-instructions { font-size: 12px; }
.cheat-reason { color: #985218; font-size: 12px; }
.cheat-card-actions { display: flex; flex-direction: column; gap: 6px; }
.cheat-card-actions > button { min-width: 72px; padding-inline: 10px; }
.cheat-toggle[aria-pressed="true"] { background: #d7efdf; border-color: #82b59a; color: #205c40; }
.cheat-dialog .cheat-delete { color: #9b3940; background: transparent; }
.cheat-status { color: #205c40; overflow-wrap: anywhere; font-size: 12px; max-height: 4.5em; overflow-y: auto; }
.cheat-status:empty { display: none; }
.cheat-status[data-failed="true"] { color: #a5343c; }
.cheat-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cheat-field { display: flex; flex-direction: column; gap: 5px; font-weight: 600; min-width: 0; }
.cheat-field input, .cheat-field select, .cheat-field textarea { width: 100%; min-height: 44px; padding: 9px 10px; border: 1px solid #a9b1bb; border-radius: 8px; background: #fff; color: var(--cheat-ink); user-select: text; }
.cheat-field textarea { resize: vertical; line-height: 1.5; }
.cheat-form .cheat-field-wide, .cheat-form .cheat-help { grid-column: 1 / -1; }
.cheat-form [name="codes"] { font-family: Consolas, monospace; }
.cheat-import { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--cheat-line); }
.cheat-import > * { margin-bottom: 10px; }
.cheat-import > button { margin-right: 8px; }
.cheat-empty { padding: 20px 12px; color: var(--cheat-muted); border: 1px dashed var(--cheat-line); border-radius: 12px; }
.viewport-player .cheat-dialog { width: min(680px, calc(var(--view-width) - 24px)); max-width: min(680px, calc(var(--view-width) - 24px)); }
@media (max-height: 430px) {
  .cheat-dialog { padding: 10px 14px; border-radius: 16px; }
  .cheat-dialog[open] { gap: 6px; }
  .cheat-card { padding: 10px 12px; gap: 8px; }
  .cheat-toolbar button { padding-inline: 10px; }
}
@media (max-width: 480px) {
  .cheat-dialog { padding: 14px; }
  .cheat-header { gap: 8px; }
  .cheat-header h2 { font-size: 20px; }
  .cheat-navigation { gap: 6px; }
  .cheat-card { padding: 10px; gap: 8px; }
  .cheat-card-actions > button { min-width: 66px; padding-inline: 10px; }
  .cheat-form { grid-template-columns: 1fr; }
}
