/* Remaster Launcher: dark, modern, no external fonts or assets. */

:root {
  --bg: #0a0c11;
  --bg-2: #0f1218;
  --panel: #12161e;
  --panel-2: #171c26;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #e9ecf2;
  --muted: #9aa3b2;
  --faint: #6b7385;
  --accent: #7c9cff;
  --accent-2: #b28dff;
  --ok: #3ecf8e;
  --warn: #f5b84a;
  --err: #ff6b6b;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124, 156, 255, 0.12), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(178, 141, 255, 0.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.in-player { overflow: hidden; background: #000; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.noscript { padding: 40px; text-align: center; }
kbd {
  font-family: var(--mono); font-size: 12px; padding: 2px 6px; border-radius: 6px;
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line-2); border-bottom-width: 2px;
}
code.hash { font-family: var(--mono); font-size: 12px; word-break: break-all; color: var(--muted); }
.icon { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: 11px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line-2);
  font-weight: 600; font-size: 14px; letter-spacing: 0.01em; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space: nowrap; text-decoration: none; user-select: none;
}
.btn:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.22); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #0b0d14;
  box-shadow: 0 6px 20px rgba(124, 156, 255, 0.25);
}
.btn-primary:hover { background: linear-gradient(135deg, #93adff, #c2a3ff); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.btn-danger { background: rgba(255, 107, 107, 0.12); border-color: rgba(255, 107, 107, 0.35); color: #ffb3b3; }
.btn-danger:hover { background: rgba(255, 107, 107, 0.2); border-color: rgba(255, 107, 107, 0.5); }
.btn-icon { padding: 0; width: 40px; min-width: 40px; }
.btn-small { min-height: 32px; padding: 4px 12px; font-size: 13px; border-radius: 9px; }
.btn-small.btn-icon { width: 32px; min-width: 32px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.row-actions:first-child { margin-top: 0; }

/* ------------------------------------------------------------ launcher */

.launcher { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px max(20px, env(safe-area-inset-right)) 14px max(20px, env(safe-area-inset-left));
  background: rgba(10, 12, 17, 0.72); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark { display: inline-flex; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -0.01em; }
.brand-sub { font-weight: 500; font-size: 18px; color: var(--muted); margin-left: -4px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.mock-badge {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--warn); border: 1px solid rgba(245, 184, 74, 0.4); border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}

.launcher-main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 32px 20px 48px; }
.launcher-foot { text-align: center; color: var(--faint); font-size: 12.5px; padding: 0 20px 28px; }
.launcher-foot p { margin: 0 auto; max-width: 720px; }

.eyebrow { margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.14em; font-size: 12px; font-weight: 700; color: var(--accent); }
.grad { background: linear-gradient(135deg, var(--accent), var(--accent-2) 50%, #ff8fb1); -webkit-background-clip: text; background-clip: text; color: transparent; }

.welcome { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 48px; align-items: start; padding-top: 24px; }
.hero h1 { font-size: clamp(32px, 5vw, 54px); line-height: 1.06; letter-spacing: -0.03em; margin: 0 0 18px; font-weight: 800; }
.lede { font-size: 17px; color: var(--muted); max-width: 620px; margin: 0 0 28px; }
.dropzone {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 34px 24px; border-radius: var(--radius-lg); cursor: pointer;
  border: 1.5px dashed rgba(124, 156, 255, 0.45);
  background: linear-gradient(180deg, rgba(124, 156, 255, 0.08), rgba(124, 156, 255, 0.02));
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.dropzone:hover { border-color: var(--accent); background: linear-gradient(180deg, rgba(124, 156, 255, 0.14), rgba(124, 156, 255, 0.04)); }
.dz-icon { color: var(--accent); margin-bottom: 6px; }
.dz-title { font-size: 19px; font-weight: 700; }
.dz-sub { color: var(--muted); font-size: 14px; }
.privacy {
  display: flex; gap: 14px; margin-top: 18px; padding: 16px 18px; border-radius: var(--radius);
  background: rgba(62, 207, 142, 0.07); border: 1px solid rgba(62, 207, 142, 0.25);
}
.privacy-icon { color: var(--ok); flex: none; padding-top: 2px; }
.privacy strong { display: block; margin-bottom: 4px; }
.privacy p { margin: 0; color: var(--muted); font-size: 14px; }
#btn-mock-carts, #btn-mock-carts-2 { margin-top: 14px; }

.supported { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; }
.supported-title { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.supported-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.supported-list li {
  display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-items: center;
  padding: 10px; border-radius: 14px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line);
}
.supported-list li strong { align-self: end; }
.supported-list li span:last-child { grid-column: 2; align-self: start; color: var(--muted); font-size: 13px; }
.sup-art {
  grid-row: span 2; width: 84px; aspect-ratio: 16 / 10; border-radius: 9px; overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4), 0 0 0 1px color-mix(in srgb, var(--ga) 30%, transparent);
}
.sup-art .cover-art { transform: none; }

.library-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.library-head h1 { margin: 0; font-size: 30px; letter-spacing: -0.02em; }
.library-note { margin: 0; color: var(--muted); font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.library-note .icon { color: var(--ok); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 24px; }
.card {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--radius-lg); background: linear-gradient(180deg, color-mix(in srgb, var(--gd) 70%, #10131a), #0e1117 60%);
  border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s;
}
.card:hover, .card:focus-within {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--ga) 45%, transparent);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5), 0 0 0 1px color-mix(in srgb, var(--ga) 25%, transparent), 0 10px 40px color-mix(in srgb, var(--gb) 22%, transparent);
}
.card-art { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: var(--gd); }
.cover-art { display: block; width: 100%; height: 100%; transform: scale(1.02); transition: transform 0.6s ease; }
.card:hover .cover-art { transform: scale(1.06); }
.card-art-shade { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 45%, rgba(10, 12, 17, 0.85)); pointer-events: none; }
.card-empty .cover-art { filter: grayscale(0.7) brightness(0.55); }
.card-missing {
  position: absolute; inset: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px dashed rgba(255, 255, 255, 0.35); border-radius: 14px; color: rgba(255, 255, 255, 0.85); font-weight: 600;
}
.card-continue {
  position: absolute; right: 12px; bottom: 12px; margin: 0; width: 38%; max-width: 160px;
  border-radius: 10px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6); background: #000;
}
.card-continue img { display: block; width: 100%; height: auto; image-rendering: auto; }
.card-continue figcaption { font-size: 11px; padding: 4px 8px; background: rgba(0, 0, 0, 0.75); color: #ddd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-body { display: flex; flex-direction: column; gap: 8px; padding: 18px 20px 20px; flex: 1; }
.card-kicker { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.card-title { margin: 0; font-size: 24px; letter-spacing: -0.02em; line-height: 1.15; }
.card-blurb { margin: 0; color: var(--muted); font-size: 14px; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; padding: 0; }
.chips li {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--ga) 12%, transparent); color: color-mix(in srgb, var(--ga) 70%, #fff);
  border: 1px solid color-mix(in srgb, var(--ga) 28%, transparent);
}
.card-status { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-top: 4px; }
.card-status.ok { color: var(--ok); }
.card-status.warn { color: var(--warn); }
.card-status.muted { color: var(--faint); }
.card-actions { display: flex; gap: 10px; margin-top: auto; padding-top: 10px; }
.card-actions .btn-primary { flex: 1; background: linear-gradient(135deg, var(--ga), var(--gb)); color: #120d08; box-shadow: 0 6px 20px color-mix(in srgb, var(--gb) 30%, transparent); }
.card-actions .btn-primary:hover { filter: brightness(1.08); }

/* ------------------------------------------------------------ dialogs and panels */

dialog.dialog {
  border: none; padding: 0; background: transparent; color: var(--text);
  width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: visible;
}
dialog.dialog-wide { width: min(960px, calc(100vw - 24px)); }
dialog.dialog-small { width: min(460px, calc(100vw - 24px)); }
dialog.dialog-menu { width: min(380px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(4, 6, 10, 0.68); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
dialog[open] { animation: pop 0.18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line-2);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  max-height: calc(100dvh - 24px); overflow: auto; overscroll-behavior: contain;
}
.panel-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px 12px 22px; background: linear-gradient(180deg, var(--panel-2) 70%, transparent);
}
.panel-head h2 { margin: 0; font-size: 19px; letter-spacing: -0.01em; }
.panel-body { padding: 4px 22px 22px; }
.set-text { margin: 0 0 12px; color: var(--text); }
.set-note { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.set-note.warn { color: var(--warn); }
.set-hint { color: var(--faint); font-size: 12.5px; margin: 2px 0 0; }
.notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: rgba(124, 156, 255, 0.08); border: 1px solid rgba(124, 156, 255, 0.3); }
.notice-error { justify-content: flex-start; background: rgba(255, 107, 107, 0.08); border-color: rgba(255, 107, 107, 0.35); color: #ffc2c2; margin: 0 0 14px; }
.error-detail { max-height: 180px; overflow: auto; font-family: var(--mono); font-size: 12px; background: rgba(0, 0, 0, 0.35); padding: 10px; border-radius: 10px; color: #ffc2c2; white-space: pre-wrap; }

.menu-panel { padding: 22px; }
.menu-head { margin-bottom: 14px; }
.menu-head h2 { margin: 0; font-size: 22px; }
.menu-net { color: var(--ok); font-size: 13px; margin: 6px 0 0; }
.menu-list { display: grid; gap: 6px; }
.menu-item {
  text-align: left; padding: 12px 16px; border-radius: 12px; border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03); font-weight: 600; font-size: 15px; cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.menu-item:hover, .menu-item:focus-visible { background: rgba(124, 156, 255, 0.12); border-color: rgba(124, 156, 255, 0.4); outline: none; }
.menu-item.primary { background: linear-gradient(135deg, rgba(124, 156, 255, 0.25), rgba(178, 141, 255, 0.2)); }
.menu-item[disabled] { opacity: 0.55; cursor: default; }
.menu-item .mi-label, .menu-item .mi-detail { display: block; }
.menu-item .mi-detail { margin-top: 2px; color: var(--muted); font-size: 12.5px; font-weight: 500; }

/* game-module menu (web/ui/module-panel.js) */
.module-panel { padding: 0 22px 22px; }
.module-panel .module-head { padding-left: 0; padding-right: 0; }
.module-list { max-height: min(62vh, 560px); overflow-y: auto; padding-right: 4px; }
.module-group { margin: 10px 2px 2px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }

/* settings */
.settings-layout { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 8px; padding: 0 12px 12px; }
.tabs { display: flex; flex-direction: column; gap: 2px; padding: 4px 0; position: sticky; top: 60px; align-self: start; }
.tab {
  text-align: left; padding: 9px 14px; border-radius: 10px; border: none; background: transparent;
  color: var(--muted); font-weight: 600; cursor: pointer;
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.tab.active { color: var(--text); background: rgba(124, 156, 255, 0.14); box-shadow: inset 2px 0 0 var(--accent); }
.settings-panel .panel-body { padding: 0 10px 12px; min-height: 420px; }
.set-section { padding: 10px 0 14px; border-bottom: 1px solid var(--line); }
.set-section:last-child { border-bottom: none; }
.set-heading { margin: 6px 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.set-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 16px; align-items: center; padding: 9px 0; }
.set-label label, .set-label span { font-weight: 600; }
.set-control { display: flex; justify-content: flex-end; min-width: 0; }

.select, .input {
  width: 100%; max-width: 340px; min-height: 38px; padding: 7px 12px; border-radius: 10px;
  background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line-2);
}
.select:focus, .input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(124, 156, 255, 0.2); }
.select option { background: #161a22; }
.range { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 340px; }
.range input { flex: 1; accent-color: var(--accent); }
.range-value { min-width: 64px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.switch { position: relative; display: inline-flex; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track { width: 46px; height: 26px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); transition: background 0.15s; position: relative; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); }
.switch input:checked + .switch-track { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Controls a netplay guest cannot change (the host's settings apply). */
.switch.is-disabled, .switch input:disabled { cursor: not-allowed; }
.switch.is-disabled .switch-track { opacity: 0.45; }
.select:disabled { opacity: 0.55; cursor: not-allowed; }
/* Settings > Game > Enhancements: the measured effect for this game, under the description. */
.set-hint-note { display: block; margin-top: 4px; color: var(--muted, var(--faint)); }

.segmented { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 10px; margin-bottom: 8px; }
.seg-option {
  position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px; cursor: pointer;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line-2); transition: border-color 0.15s, background 0.15s;
}
.seg-option input { position: absolute; opacity: 0; pointer-events: none; }
.seg-option:hover { background: rgba(255, 255, 255, 0.06); }
.seg-option:has(input:checked) { border-color: var(--accent); background: rgba(124, 156, 255, 0.12); }
.seg-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg-title { font-weight: 700; }
.seg-hint { font-size: 12.5px; color: var(--muted); }

.pill-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: rgba(0, 0, 0, 0.3); margin: 8px 0 4px; }
.pill { border: none; background: transparent; padding: 7px 16px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; }
.pill.active { background: rgba(124, 156, 255, 0.2); color: var(--text); }

.bind-table { display: grid; gap: 4px; margin-top: 8px; }
.bind-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: center; }
.bind-head { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--faint); padding: 0 4px; }
.bind-name { display: flex; align-items: center; }
.snes-btn {
  display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 26px; padding: 0 8px;
  border-radius: 999px; font-size: 12px; font-weight: 800; background: #2a3040; color: #dfe4ee;
}
.snes-a { background: #c8364a; color: #fff; } .snes-b { background: #d8a62a; color: #1b1406; }
.snes-x { background: #2c5fc6; color: #fff; } .snes-y { background: #2f9a52; color: #fff; }
.snes-l, .snes-r { background: #59617a; }
.snes-start, .snes-select { background: #3a4052; font-size: 11px; }
.bind-cell {
  text-align: left; min-height: 36px; padding: 6px 12px; border-radius: 9px; cursor: pointer;
  background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bind-cell:hover { border-color: var(--line-2); background: rgba(255, 255, 255, 0.05); }
.bind-cell.empty { color: var(--faint); }
.bind-cell.listening { border-color: var(--accent); background: rgba(124, 156, 255, 0.15); color: var(--text); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(124, 156, 255, 0.18); } }
.hotkeys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.hotkeys dd { margin: 0; color: var(--muted); }

/* states */
.states-panel .panel-body, .states-panel > .set-note, .states-panel > .set-hint { padding: 0 22px; }
.states-panel > .set-hint { padding-bottom: 20px; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; padding: 4px 22px 14px; }
.slot { display: flex; flex-direction: column; border-radius: 14px; overflow: hidden; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); }
.slot-thumb { aspect-ratio: 8 / 7; background: #05060a; display: flex; align-items: center; justify-content: center; }
.slot-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.slot-empty { color: var(--faint); font-size: 13px; }
.slot-meta { display: flex; flex-direction: column; padding: 10px 12px 0; }
.slot-meta span { color: var(--muted); font-size: 12.5px; }
.slot-actions { display: flex; gap: 6px; padding: 10px 12px 12px; }

/* netplay */
.np-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.np-card { padding: 16px; border-radius: 14px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.np-card h3 { margin: 0; font-size: 16px; }
.np-card .set-hint { flex: 1; }
.code-input { font-family: var(--mono); font-size: 18px; letter-spacing: 0.25em; text-align: center; text-transform: uppercase; max-width: none; }
.np-advanced { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.np-advanced summary { cursor: pointer; color: var(--muted); font-weight: 600; padding: 4px 0; }
.np-status { color: var(--muted); font-size: 14px; margin: 12px 0 0; }
.np-code { text-align: center; padding: 18px; border-radius: 16px; background: rgba(124, 156, 255, 0.08); border: 1px solid rgba(124, 156, 255, 0.25); }
.np-code-label { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; }
.np-code-value { display: block; font-family: var(--mono); font-size: 36px; letter-spacing: 0.3em; margin: 6px 0 4px; }
.np-code .row-actions { justify-content: center; }
.np-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin: 14px 0; }
.np-stats dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--faint); }
.np-stats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.np-turn { flex-direction: column; align-items: flex-end; gap: 6px; }

.info-list { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 16px; margin: 0 0 8px; font-size: 14px; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; }

/* ------------------------------------------------------------ player */

.player { position: fixed; inset: 0; background: #000; user-select: none; -webkit-user-select: none; touch-action: none; }
.stage { position: absolute; inset: 0; }
.screen-canvas { display: block; width: 100%; height: 100%; outline: none; }
.hud {
  position: absolute; left: 0; right: 0; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 28px max(14px, env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0.35) 60%, transparent);
  transition: opacity 0.3s ease;
}
.hud-left, .hud-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hud-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.hud-title strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-title span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.hud-btn { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.12); backdrop-filter: blur(8px); }
.player.hud-hidden .hud { opacity: 0; pointer-events: none; }
.player.hud-hidden { cursor: none; }
.net-badge { font-size: 12.5px; font-weight: 700; padding: 5px 12px; border-radius: 999px; background: rgba(62, 207, 142, 0.16); color: var(--ok); border: 1px solid rgba(62, 207, 142, 0.35); white-space: nowrap; }
.net-badge.waiting { background: rgba(245, 184, 74, 0.14); color: var(--warn); border-color: rgba(245, 184, 74, 0.35); }
/* Repeated netplay desyncs: stays visible while the HUD is hidden (web/ui/netplay-panel.js DesyncNotifier). */
.net-sync {
  position: absolute; left: 50%; top: calc(max(10px, env(safe-area-inset-top)) + 52px); transform: translateX(-50%); z-index: 5;
  max-width: calc(100vw - 32px); padding: 6px 14px; border-radius: 999px; pointer-events: none;
  font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: rgba(30, 22, 6, 0.82); color: var(--warn); border: 1px solid rgba(245, 184, 74, 0.5);
}
.net-sync.severe { background: rgba(40, 10, 10, 0.86); color: #ff9b8f; border-color: rgba(255, 110, 96, 0.55); }
.stats-overlay {
  position: absolute; left: max(12px, env(safe-area-inset-left)); top: 70px; z-index: 4;
  font-family: var(--mono); font-size: 12px; line-height: 1.5; white-space: pre; color: #d7f5e3;
  background: rgba(0, 0, 0, 0.6); padding: 8px 10px; border-radius: 10px; pointer-events: none;
}
.indicator {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 4;
  display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.65); font-weight: 700; font-size: 14px; pointer-events: none;
}
.paused-badge {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 4;
  padding: 16px 28px; border-radius: 16px; background: rgba(0, 0, 0, 0.7); font-size: 22px; font-weight: 800; text-align: center;
  pointer-events: none;
}
.paused-badge small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.controls-hint {
  /* Centered with auto margins, not a transform, so the pop animation can't shift it. */
  position: absolute; left: 16px; right: 16px; bottom: max(24px, env(safe-area-inset-bottom)); margin: 0 auto; z-index: 4;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px;
  width: max-content; max-width: calc(100% - 32px); padding: 10px 12px 10px 18px; border-radius: 16px;
  background: rgba(8, 10, 15, 0.82); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  font-size: 13px; color: var(--muted); animation: pop 0.25s ease-out;
}
.ch-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.ch-item kbd { color: var(--text); }
.ch-item .snes-btn { height: 22px; min-width: 26px; font-size: 11px; }
.ch-close { margin-left: 2px; }

/* touch gamepad */
.touch-root { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.touchpad { position: absolute; inset: 0; display: none; }
.touchpad.visible { display: block; }
.touchpad > * { pointer-events: auto; touch-action: none; }
.tp-dpad {
  position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: max(24px, env(safe-area-inset-bottom));
  width: 156px; height: 156px; border-radius: 50%; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12);
}
.tp-dpad-arm, .tp-dpad-hub { position: absolute; background: rgba(255, 255, 255, 0.18); border: 1px solid rgba(255, 255, 255, 0.22); }
.tp-dpad-hub { left: 52px; top: 52px; width: 52px; height: 52px; border: none; }
.tp-up { left: 52px; top: 10px; width: 52px; height: 44px; border-radius: 10px 10px 2px 2px; }
.tp-down { left: 52px; bottom: 10px; width: 52px; height: 44px; border-radius: 2px 2px 10px 10px; }
.tp-left { top: 52px; left: 10px; width: 44px; height: 52px; border-radius: 10px 2px 2px 10px; }
.tp-right { top: 52px; right: 10px; width: 44px; height: 52px; border-radius: 2px 10px 10px 2px; }
.tp-dpad[data-dir*="u"] .tp-up, .tp-dpad[data-dir*="d"] .tp-down, .tp-dpad[data-dir*="l"] .tp-left, .tp-dpad[data-dir*="r"] .tp-right { background: rgba(124, 156, 255, 0.55); }
.tp-face { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(24px, env(safe-area-inset-bottom)); width: 170px; height: 170px; }
.tp-btn {
  position: absolute; width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; color: rgba(255, 255, 255, 0.9); border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12); transition: transform 0.05s, background 0.05s;
}
.tp-x { left: 55px; top: 0; } .tp-y { left: 0; top: 55px; } .tp-a { right: 0; top: 55px; } .tp-b { left: 55px; bottom: 0; }
.tp-a { background: rgba(200, 54, 74, 0.45); } .tp-b { background: rgba(216, 166, 42, 0.45); }
.tp-x { background: rgba(44, 95, 198, 0.45); } .tp-y { background: rgba(47, 154, 82, 0.45); }
.tp-btn.on, .tp-shoulder.on, .tp-pill.on { transform: scale(0.92); background: rgba(255, 255, 255, 0.45); }
.tp-shoulder {
  position: absolute; top: max(78px, calc(env(safe-area-inset-top) + 68px)); width: 92px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-weight: 800;
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2);
}
.tp-l { left: max(18px, env(safe-area-inset-left)); } .tp-r { right: max(18px, env(safe-area-inset-right)); }
.tp-center { position: absolute; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 14px; }
.tp-pill { padding: 6px 16px; border-radius: 999px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); }
.tp-menu {
  position: absolute; left: 50%; top: max(12px, env(safe-area-inset-top)); transform: translateX(-50%);
  width: 44px; height: 32px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(0, 0, 0, 0.4); font-size: 16px;
}
.player.with-touch .hud { display: none; }
@media (orientation: portrait) {
  .player.with-touch .stage { bottom: 42%; top: max(48px, env(safe-area-inset-top)); }
  .player.with-touch .tp-shoulder { top: auto; bottom: calc(max(24px, env(safe-area-inset-bottom)) + 196px); width: 84px; }
  .player.with-touch .tp-center { bottom: calc(max(24px, env(safe-area-inset-bottom)) + 202px); gap: 8px; }
  .player.with-touch .tp-pill { padding: 6px 10px; font-size: 11px; }
}
@media (orientation: portrait) and (max-width: 360px) {
  .tp-dpad { width: 140px; height: 140px; }
  .tp-dpad .tp-up, .tp-dpad .tp-down { left: 46px; width: 48px; }
  .tp-dpad .tp-left, .tp-dpad .tp-right { top: 46px; height: 48px; }
  .tp-dpad .tp-dpad-hub { left: 46px; top: 46px; width: 48px; height: 48px; }
  .tp-face { width: 156px; height: 156px; }
  .tp-btn { width: 54px; height: 54px; }
  .tp-x, .tp-b { left: 51px; } .tp-y, .tp-a { top: 51px; }
}

/* ------------------------------------------------------------ misc overlays */

.toasts { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: min(560px, calc(100vw - 24px)); }
.toast {
  pointer-events: auto; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  background: rgba(23, 28, 38, 0.96); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; text-align: center;
}
.toast.show { opacity: 1; transform: none; }
.toast-ok { border-color: rgba(62, 207, 142, 0.45); }
.toast-warn { border-color: rgba(245, 184, 74, 0.5); }
.toast-error { border-color: rgba(255, 107, 107, 0.55); color: #ffd0d0; }
.drop-overlay { position: fixed; inset: 0; z-index: 900; display: flex; align-items: center; justify-content: center; background: rgba(6, 8, 12, 0.75); backdrop-filter: blur(4px); pointer-events: none; }
.drop-card { padding: 48px 64px; border-radius: 24px; border: 2px dashed var(--accent); font-size: 22px; font-weight: 700; background: rgba(124, 156, 255, 0.08); }
.boot { position: fixed; inset: 0; z-index: 800; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(10, 12, 17, 0.82); color: var(--muted); }
.boot.boot-error { color: #ffc2c2; }
.boot-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.12); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ responsive */

@media (max-width: 900px) {
  .welcome { grid-template-columns: 1fr; gap: 28px; }
}
@media (max-width: 720px) {
  .launcher-main { padding: 20px 14px 36px; }
  .cards { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; padding: 0 8px 8px; }
  .tabs { flex-direction: row; overflow-x: auto; position: static; padding-bottom: 6px; scrollbar-width: none; }
  .tab { white-space: nowrap; }
  .tab.active { box-shadow: inset 0 -2px 0 var(--accent); }
  .set-row { grid-template-columns: 1fr; gap: 6px; }
  .set-control { justify-content: flex-start; }
  .select, .input, .range { max-width: none; }
  .segmented { grid-template-columns: 1fr 1fr; }
  .np-cards { grid-template-columns: 1fr; }
  .bind-row { grid-template-columns: 70px minmax(0, 1fr) minmax(0, 1fr); }
  .hud-title span { display: none; }
  .brand-sub { display: none; }
  .settings-panel .panel-body { min-height: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
