:root {
  color-scheme: light;
  --page: #faf8f7;
  --surface: #fff;
  --text: #191919;
  --muted: #6b6866;
  --border: #e4e1df;
  --divider: #eeecea;
  --primary: #171717;
  --primary-hover: #303030;
  --selected: #f3f2f0;
  --selected-border: #242424;
  --danger: #b42318;
  --danger-hover: #912018;
  --focus: #2374d4;
  --focus-background: #f2f7ff;
  --game-background: #000;
  --dialog-shadow: 0 12px 48px #00000026;
  --display-selected-shadow: 0 1px 3px #00000014;
  --dialog-backdrop: #00000040;
  --radius-panel: calc(2px + 0.625rem);
  --radius-button: var(--radius-panel);
  --radius-tooltip: var(--radius-panel);
  --text-body: 16px;
  --text-small: 14px;
  --text-title: 22px;
  --text-sidebar: 14px;
  --text-sidebar-small: 12px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;
  --page-gutter: clamp(16px, 1.6vw, 32px);
  --duration: 140ms;
  font-family: system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: var(--text-body);
  color: var(--text);
  background: var(--page);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button { font: inherit; cursor: pointer; color: inherit; }
button:disabled { cursor: not-allowed; opacity: .45; }
button:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: var(--space-6); height: var(--space-6); flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.launcher { display: grid; min-height: 100dvh; align-items: start; grid-template-columns: minmax(0, 1fr) clamp(300px, 24vw, 480px); gap: clamp(32px, 3.5vw, 72px); padding: var(--page-gutter); }
.game-panel { position: relative; min-width: 0; min-height: 520px; height: calc(100dvh - var(--page-gutter) - var(--page-gutter)); border: 1px solid var(--border); border-radius: var(--radius-panel); overflow: hidden; background: var(--surface); }
.game-panel[data-ratio="1:1"] { align-self: center; justify-self: center; width: calc(100dvh - var(--page-gutter) * 2); max-width: 100%; height: auto; min-height: 0; aspect-ratio: 1; }
.game-panel[data-ratio="4:3"] { align-self: center; justify-self: center; width: calc((100dvh - var(--page-gutter) * 2) * 4 / 3); max-width: 100%; height: auto; min-height: 0; aspect-ratio: 4 / 3; }
.game-panel[data-ratio="16:9"] { align-self: center; justify-self: center; width: calc((100dvh - var(--page-gutter) * 2) * 16 / 9); max-width: 100%; height: auto; min-height: 0; aspect-ratio: 16 / 9; }
.game-container, .launch-cover { position: absolute; inset: 0; }
.game-frame { display: block; width: 100%; height: 100%; border: 0; opacity: 0; }
.game-frame.ready { opacity: 1; }
.launch-cover { display: grid; place-items: center; padding: var(--space-8); background: var(--surface); }
.launch-content { width: 100%; text-align: center; }
.launch-content h1 { font-size: var(--text-title); font-weight: 600; line-height: 1.4; margin: 0 0 var(--space-2); }
.launch-content p { margin: 0; color: var(--muted); line-height: 1.6; text-wrap: pretty; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: var(--space-2); min-height: 44px; padding: var(--space-3) var(--space-5); border: 1px solid var(--border); border-radius: var(--radius-button); background: var(--surface); font-weight: 500; line-height: 1.4; transition: background-color var(--duration), color var(--duration), opacity var(--duration); }
.button:not(:disabled):hover { background: var(--selected); }
.button-primary { color: var(--surface); border-color: var(--primary); background: var(--primary); }
.button-primary:not(:disabled):hover { background: var(--primary-hover); }
.start-button { min-height: 56px; margin-top: var(--space-6); padding-inline: var(--space-8); font-weight: 600; }
.launch-cover.is-loading .launch-content h1 { display: inline-flex; align-items: center; gap: var(--space-4); margin: 0; color: var(--muted); font-weight: 400; }
.launch-cover.is-loading .launch-content h1::before { content: ""; flex: none; width: var(--space-6); height: var(--space-6); box-sizing: border-box; border: 2px solid var(--muted); border-right-color: transparent; border-radius: 50%; animation: startup-spin 850ms linear infinite; }
.launch-cover.is-loading .launch-content p { display: none; }
.launch-cover.is-downloading .launch-content h1 { margin: 0; }
.launch-cover.is-downloading .launch-content h1::before { display: none; }
.download-progress { width: min(100%, 320px); margin: var(--space-6) auto 0; }
.download-progress progress { display: block; width: 100%; height: var(--space-2); appearance: none; border: 0; border-radius: var(--radius-panel); overflow: hidden; background: var(--divider); accent-color: var(--primary); }
.download-progress progress::-webkit-progress-bar { background: var(--divider); border-radius: var(--radius-panel); }
.download-progress progress::-webkit-progress-value { background: var(--primary); border-radius: var(--radius-panel); }
.download-progress progress::-moz-progress-bar { background: var(--primary); border-radius: var(--radius-panel); }
.download-numbers { display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); color: var(--muted); font-size: var(--text-small); font-variant-numeric: tabular-nums; }
@keyframes startup-spin { to { transform: rotate(360deg); } }
.sidebar { min-width: 0; align-self: start; font-size: var(--text-sidebar); }
.display-section { margin-top: var(--space-8); }
.display-card { padding: var(--space-5); border: 1px solid var(--border); border-radius: var(--radius-panel); background: var(--surface); }
.display-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.display-label { float: left; width: 100%; margin: 0 0 var(--space-5); padding: 0; font-size: var(--text-sidebar); font-weight: 500; line-height: 1.4; color: var(--text); }
.segmented-group { display: grid; clear: both; width: fit-content; max-width: 100%; grid-auto-flow: column; grid-auto-columns: auto; gap: 0; padding: var(--space-1); border-radius: var(--radius-panel); background: var(--divider); }
.display-field + .display-field { margin-top: var(--space-5); }
.segmented-button { min-width: 0; min-height: 40px; padding: 0 var(--space-3); border: 1px solid transparent; border-radius: var(--radius-button); background: transparent; color: var(--muted); font-weight: 400; white-space: nowrap; transition: background-color var(--duration), color var(--duration); }
.segmented-button:not([aria-pressed="true"]):not(:disabled):hover { background: var(--selected); }
.segmented-button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--display-selected-shadow); }
.save-section { margin-top: var(--space-8); }
.control-section h2 { margin: 0 0 var(--space-5); padding-inline: var(--space-3); font-size: var(--text-sidebar); font-weight: 500; line-height: 1.4; color: var(--muted); }
.fullscreen-button { width: 100%; min-height: 52px; }
.save-card { display: grid; gap: var(--space-1); padding: var(--space-1); border-radius: var(--radius-panel); background: var(--divider); }
.save-row { position: relative; min-width: 0; }
.save-select { display: flex; justify-content: flex-start; align-items: center; width: 100%; min-height: 52px; padding: var(--space-3) var(--space-12) var(--space-3) var(--space-4); border: 1px solid transparent; border-radius: var(--radius-button); background: transparent; text-align: left; transition: background-color var(--duration), border-color var(--duration); }
.save-select:not([aria-pressed="true"]):not(:disabled):hover { background: var(--selected); }
.save-select[aria-pressed="true"] { background: var(--surface); border-color: var(--border); }
.save-name { white-space: nowrap; }
.reset-button { position: absolute; top: var(--space-1); right: var(--space-1); width: 44px; height: 44px; padding: 0; border-color: transparent; background: transparent; color: var(--muted); font-size: var(--text-sidebar-small); opacity: 0; visibility: hidden; pointer-events: none; }
.save-row:hover .reset-button, .save-row:focus-within .reset-button { opacity: 1; visibility: visible; pointer-events: auto; }
.reset-button .icon { width: var(--space-4); height: var(--space-4); }
.reset-button:not(:disabled):hover { color: var(--danger); }
.reset-tooltip { position: absolute; right: 0; bottom: calc(100% + var(--space-2)); z-index: 3; padding: var(--space-1) var(--space-2); border-radius: var(--radius-tooltip); background: var(--primary); color: var(--surface); font-weight: 400; white-space: nowrap; opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(var(--space-1)); transition: opacity var(--duration), transform var(--duration); }
.reset-button:hover .reset-tooltip, .reset-button:focus-visible .reset-tooltip { opacity: 1; visibility: visible; transform: translateY(0); }
.status-text { margin: var(--space-4) var(--space-3) 0; color: var(--muted); font-size: var(--text-sidebar-small); line-height: 1.6; overflow-wrap: anywhere; }
.game-panel:fullscreen { width: 100%; height: 100%; margin: 0; min-height: 0; border: 0; border-radius: var(--radius-panel); background: var(--game-background); }
.reset-dialog { width: min(440px, calc(100% - 32px)); padding: var(--space-8); border: 1px solid var(--border); border-radius: var(--radius-panel); color: var(--text); box-shadow: var(--dialog-shadow); }
.reset-dialog::backdrop { background: var(--dialog-backdrop); }
.reset-dialog h2 { margin: 0 0 var(--space-3); font-size: var(--text-title); line-height: 1.4; }
.reset-dialog p { margin: 0; color: var(--muted); line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-6); }
.button-danger { background: var(--danger); color: var(--surface); border-color: var(--danger); }
.button-danger:not(:disabled):hover { background: var(--danger-hover); }
@media (min-width: 1800px) { :root { --text-body: 20px; --text-small: 16px; --text-title: 26px; } }
@media (min-width: 760px) and (max-width: 1099px) {
  .launcher { grid-template-columns: minmax(0, 1fr) 260px; gap: var(--space-6); }
}
@media (max-width: 759px) {
  .launcher { --page-gutter: var(--space-4); min-height: auto; grid-template-columns: minmax(0, 1fr); gap: var(--space-8); }
  .game-panel { height: min(65dvh, 560px); min-height: 400px; }
  .launch-cover { padding: var(--space-6); }
  .launch-content p { font-size: var(--text-small); }
  .display-section { margin-top: var(--space-6); }
  .save-section { margin-top: var(--space-6); }
}
@media (hover: none) {
  .save-select[aria-pressed="true"] + .reset-button { opacity: 1; visibility: visible; pointer-events: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .launch-cover.is-loading .launch-content h1::before { animation: none; }
}
