:root {
  color-scheme: dark;
  --ps2-bg: #050711;
  --ps2-panel: rgba(9, 12, 28, 0.88);
  --ps2-panel-strong: rgba(13, 18, 38, 0.95);
  --ps2-line: rgba(118, 145, 230, 0.28);
  --ps2-line-hot: rgba(99, 229, 255, 0.62);
  --ps2-text: #f4f7ff;
  --ps2-muted: #98a3c5;
  --ps2-cyan: #63e5ff;
  --ps2-pink: #ff4da6;
  --ps2-green: #8cff6a;
  --ps2-gold: #ffc857;
  --ps2-red: #ff6f91;
  --ps2-radius: 14px;
  --ps2-ui: Rajdhani, Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ps2-display: Orbitron, Inter, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 16% 0%, rgba(99, 229, 255, 0.1), transparent 34%),
    radial-gradient(circle at 88% 12%, rgba(255, 77, 166, 0.08), transparent 30%),
    linear-gradient(180deg, #070a19 0%, #050711 48%, #03040a 100%);
  background-size: auto;
  color: var(--ps2-text);
  font-family: var(--ps2-ui);
}

body {
  overflow-x: hidden;
}

body::before {
  content: "";
  display: none;
}

button,
input {
  font: inherit;
}

.ps2-shell {
  position: relative;
  z-index: 1;
  width: min(1460px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px 18px 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 354px;
  align-items: start;
  gap: 14px;
}

.ps2-stage {
  min-width: 0;
  min-height: auto;
  display: grid;
  grid-template-rows: auto auto auto;
  align-self: start;
  gap: 12px;
}

.ps2-topbar,
.ps2-side,
.ps2-bottom {
  contain: layout paint style;
  border: 1px solid var(--ps2-line);
  background:
    linear-gradient(180deg, rgba(16, 20, 44, 0.96), rgba(8, 10, 24, 0.92)),
    var(--ps2-panel);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 18px 44px rgba(0, 0, 0, 0.46),
    0 0 28px rgba(99, 229, 255, 0.07);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.ps2-topbar {
  position: relative;
  min-height: 78px;
  border-radius: var(--ps2-radius);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.ps2-topbar::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99, 229, 255, 0.72), rgba(255, 77, 166, 0.56), transparent);
}

.ps2-title-block {
  min-width: 0;
}

.ps2-brand-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.ps2-mark {
  position: relative;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid rgba(99, 229, 255, 0.5);
  border-radius: 50%;
  background:
    conic-gradient(from 45deg, var(--ps2-cyan), transparent 30%, var(--ps2-pink), transparent 68%, var(--ps2-cyan)),
    rgba(5, 7, 17, 0.88);
  box-shadow:
    0 0 0 3px rgba(99, 229, 255, 0.07),
    0 0 24px rgba(99, 229, 255, 0.22);
}

.ps2-mark::before,
.ps2-mark::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px solid rgba(244, 247, 255, 0.9);
  border-radius: 50%;
}

.ps2-mark::after {
  inset: 12px 8px 8px 12px;
  border-color: transparent var(--ps2-cyan) var(--ps2-pink) transparent;
  border-radius: 4px 50% 50% 50%;
}

.ps2-kicker {
  margin: 0;
  color: var(--ps2-cyan);
  font: 800 11px/1 var(--ps2-display);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.ps2-title {
  margin: 6px 0 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: #fff;
  font: 900 29px/1.02 var(--ps2-display);
  letter-spacing: 0;
  text-shadow: 0 0 22px rgba(99, 229, 255, 0.16);
}

.ps2-meta {
  margin: 6px 0 0;
  color: var(--ps2-muted);
  overflow-wrap: anywhere;
  font-size: 16px;
  font-weight: 700;
}

.ps2-stat {
  min-width: 84px;
  height: 44px;
  border: 1px solid rgba(140, 255, 106, 0.35);
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--ps2-green);
  font: 900 17px/1 var(--ps2-display);
  background:
    linear-gradient(180deg, rgba(140, 255, 106, 0.13), rgba(99, 229, 255, 0.035)),
    rgba(5, 7, 17, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.ps2-stat[data-tone="warn"] {
  border-color: rgba(255, 200, 87, 0.48);
  color: var(--ps2-gold);
  background:
    linear-gradient(180deg, rgba(255, 200, 87, 0.16), rgba(99, 229, 255, 0.03)),
    rgba(5, 7, 17, 0.84);
}

.ps2-stat[data-tone="low"] {
  border-color: rgba(255, 111, 145, 0.48);
  color: #ff93b7;
  background:
    linear-gradient(180deg, rgba(255, 111, 145, 0.16), rgba(99, 229, 255, 0.02)),
    rgba(5, 7, 17, 0.84);
}

.ps2-canvas-wrap {
  position: relative;
  contain: layout paint style;
  min-height: min(520px, calc(100vh - 220px));
  height: min(520px, calc(100vh - 220px));
  align-self: start;
  border-radius: var(--ps2-radius);
  border: 1px solid rgba(118, 145, 230, 0.22);
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #000;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.025),
    0 18px 54px rgba(0, 0, 0, 0.52);
}

.ps2-canvas-wrap::before {
  content: "";
  display: none;
}

#outputCanvas {
  position: relative;
  z-index: 1;
  display: block;
  width: var(--ps2-canvas-css-width, min(100%, 512px, calc((100vh - 206px) * 1.3333)));
  height: var(--ps2-canvas-css-height, auto);
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 4 / 3;
  outline: none;
  image-rendering: auto;
  background: #000;
  box-shadow: none;
  contain: strict;
}

.ps2-filter-canvas {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  display: none;
  width: var(--ps2-canvas-css-width, min(100%, 512px, calc((100vh - 206px) * 1.3333)));
  height: var(--ps2-canvas-css-height, auto);
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 4 / 3;
  pointer-events: none;
  background: transparent;
  transform: none;
}

body.ps2-line-filter-active .ps2-filter-canvas {
  display: block;
}

body.ps2-performance-active {
  background:
    radial-gradient(circle at 12% 0%, rgba(99, 229, 255, 0.08), transparent 32%),
    linear-gradient(180deg, #060817 0%, #040610 100%);
  background-size: auto;
}

body.ps2-performance-active::before {
  display: none;
}

body.ps2-performance-active .ps2-topbar,
body.ps2-performance-active .ps2-side,
body.ps2-performance-active .ps2-bottom {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.045),
    0 10px 24px rgba(0, 0, 0, 0.34);
}

body.ps2-performance-active .ps2-canvas-wrap {
  background: #000;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.025);
}

body.ps2-performance-active .ps2-canvas-wrap::before,
body.ps2-performance-active .ps2-cover-box::after,
body.ps2-performance-active #liveChat .live-chat-bg-canvas,
body.ps2-performance-active #liveChat .live-chat-bg-overlay {
  display: none !important;
}

body.ps2-performance-active .ps2-mark,
body.ps2-performance-active #outputCanvas {
  box-shadow: none;
}

body.ps2-game-running .ps2-shell {
  --ps2-running-tune-width: 272px;
  --ps2-running-tune-gap: 10px;
  --ps2-running-left: clamp(8px, 2vw, 54px);
  width: min(1280px, calc(100vw - var(--ps2-running-tune-width) - var(--ps2-running-tune-gap) - var(--ps2-running-left)));
  margin: 0 auto 0 var(--ps2-running-left);
  grid-template-columns: minmax(0, 1fr);
  padding: 14px;
  background: #03040a;
}

body.ps2-game-running.ps2-tune-collapsed .ps2-shell {
  --ps2-running-tune-width: 0px;
  --ps2-running-tune-gap: 0px;
  width: min(1180px, calc(100vw - 20px));
  margin: 0 auto;
}

body.ps2-game-running .ps2-stage {
  position: relative;
  min-height: auto;
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
}

body.ps2-game-running .ps2-side,
.ps2-speed-card {
  display: none !important;
}

body.nexus-skin.ps2-game-running #liveChat,
body.nexus-skin.ps2-game-running #liveChat.live-chat,
body.nexus-skin.ps2-game-running #chatToggleBtn,
body.nexus-skin.ps2-game-running #chatToggleBtn.chat-toggle-btn {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

body.ps2-game-running *,
body.ps2-game-running *::before,
body.ps2-game-running *::after {
  animation: none !important;
  transition: none !important;
}

body.ps2-game-running .ps2-topbar,
body.ps2-game-running .ps2-bottom {
  position: absolute;
  z-index: 3;
  border: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  pointer-events: none;
  box-shadow: none;
}

body.ps2-game-running .ps2-topbar {
  top: 10px;
  right: 10px;
  left: auto;
  min-height: 0;
  padding: 0;
  display: block;
  background: transparent;
}

body.ps2-game-running .ps2-title-block,
body.ps2-game-running .ps2-brand-row {
  display: none;
}

body.ps2-game-running .ps2-title {
  margin: 0;
  font-size: 19px;
  line-height: 1.05;
}

body.ps2-game-running .ps2-meta {
  display: none;
}

body.ps2-game-running .ps2-stat {
  height: 36px;
  min-width: 74px;
  border-radius: 8px;
  border-color: rgba(140, 255, 106, 0.42);
  font-size: 15px;
  background: rgba(0, 0, 0, 0.54);
}

body.ps2-game-running .ps2-bottom {
  display: none;
}

body.ps2-game-running .ps2-status {
  font-size: 15px;
}

body.ps2-game-running .ps2-progress {
  margin-top: 1px;
  min-height: 14px;
  font-size: 12px;
}

body.ps2-game-running .ps2-actions {
  display: none;
}

body.ps2-game-running .ps2-canvas-wrap {
  min-height: min(520px, calc(100vh - 120px));
  height: min(520px, calc(100vh - 120px));
  border: 1px solid rgba(99, 229, 255, 0.20);
  border-radius: 10px;
  background: #000;
  box-shadow: none;
}

body.ps2-game-running.ps2-tune-collapsed .ps2-canvas-wrap {
  min-height: min(620px, calc(100vh - 82px));
  height: min(620px, calc(100vh - 82px));
}

body.ps2-game-running #outputCanvas,
body.ps2-game-running .ps2-filter-canvas {
  width: var(--ps2-canvas-css-width, min(100%, 512px));
  height: var(--ps2-canvas-css-height, auto);
  max-width: 100%;
  max-height: 100%;
  image-rendering: auto;
  filter: none;
  transform: none;
  will-change: auto;
}

body.ps2-performance-active #chatToggleBtn .chat-toggle-ring,
body.ps2-performance-active #chatToggleBtn .chat-toggle-ring-2 {
  display: none !important;
}

body.ps2-low-fps .ps2-side {
  content-visibility: auto;
  contain-intrinsic-size: 354px 780px;
}

.ps2-tune-panel {
  position: fixed;
  top: 12px;
  right: 10px;
  z-index: 10050;
  width: min(306px, calc(100vw - 20px));
  max-height: calc(100vh - 24px);
  overflow: hidden;
  border: 1px solid rgba(99, 229, 255, 0.38);
  border-radius: 10px;
  color: #f4f7ff;
  background: rgba(3, 5, 12, 0.78);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-family: var(--ps2-ui);
}

.ps2-tune-toggle {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-bottom: 1px solid rgba(99, 229, 255, 0.18);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ps2-cyan);
  background: rgba(3, 5, 12, 0.94);
  cursor: pointer;
}

.ps2-tune-toggle span {
  font: 900 12px/1 var(--ps2-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ps2-tune-toggle strong {
  color: var(--ps2-green);
  font: 900 12px/1 var(--ps2-display);
}

.ps2-tune-body {
  padding: 8px;
  max-height: calc(100vh - 78px);
  overflow: auto;
  overscroll-behavior: contain;
}

.ps2-tune-panel[data-open="false"] .ps2-tune-body {
  display: none;
}

.ps2-preset-strip {
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(2, auto);
  gap: 6px;
  align-items: end;
  padding: 7px;
  border: 1px solid rgba(99, 229, 255, 0.26);
  border-radius: 9px;
  background: rgba(99, 229, 255, 0.055);
}

.ps2-preset-strip label {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.ps2-preset-strip span,
.ps2-tune-heading {
  color: var(--ps2-cyan);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ps2-preset-strip select,
.ps2-preset-strip button,
.ps2-import-label {
  min-height: 30px;
  border: 1px solid rgba(118, 145, 230, 0.30);
  border-radius: 8px;
  padding: 0 8px;
  color: #fff;
  background: rgba(11, 15, 34, 0.96);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.ps2-preset-strip select {
  width: 100%;
}

.ps2-preset-strip button,
.ps2-import-label {
  display: grid;
  place-items: center;
  cursor: pointer;
}

.ps2-preset-strip [data-ps2-reset-clean] {
  grid-column: 1 / -1;
  width: 100%;
}

.ps2-import-label input {
  display: none;
}

.ps2-tune-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.ps2-tune-heading {
  margin-top: 4px;
  padding: 7px 8px 3px;
  border-top: 1px solid rgba(99, 229, 255, 0.18);
}

.ps2-tune-grid label {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.ps2-tune-grid span {
  color: var(--ps2-muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ps2-tune-grid select,
.ps2-free-pref input,
.ps2-free-pref select {
  width: 100%;
  min-height: 30px;
  border: 1px solid rgba(118, 145, 230, 0.28);
  border-radius: 8px;
  padding: 0 8px;
  color: #fff;
  background: rgba(11, 15, 34, 0.96);
  font-size: 12px;
  font-weight: 800;
}

.ps2-free-pref {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.ps2-free-pref button {
  min-height: 34px;
  border: 1px solid rgba(99, 229, 255, 0.36);
  border-radius: 8px;
  color: #eaf4ff;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.ps2-tune-metrics {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.ps2-tune-metrics div {
  min-width: 0;
  border: 1px solid rgba(118, 145, 230, 0.20);
  border-radius: 8px;
  padding: 6px 7px;
  background: rgba(255, 255, 255, 0.055);
}

.ps2-tune-metrics span,
.ps2-tune-metrics strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ps2-tune-metrics span {
  color: var(--ps2-muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ps2-tune-metrics strong {
  margin-top: 2px;
  color: #eaf4ff;
  font-size: 11px;
  font-weight: 900;
}

.ps2-tune-actions {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.ps2-tune-actions button {
  min-height: 32px;
  border: 1px solid rgba(99, 229, 255, 0.36);
  border-radius: 8px;
  color: #eaf4ff;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.ps2-tune-panel p {
  margin: 8px 0 0;
  min-height: 16px;
  color: #bdefff;
  overflow-wrap: anywhere;
  font: 800 12px/1.35 var(--ps2-ui);
}

body.ps2-game-running .ps2-tune-panel {
  top: 8px;
  right: 8px;
  left: auto;
  width: min(272px, calc(100vw - 16px));
  max-height: min(76vh, calc(100vh - 16px));
  background: rgba(0, 0, 0, 0.70);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.ps2-game-running .ps2-tune-body {
  max-height: min(66vh, calc(100vh - 82px));
  padding: 7px;
}

body.ps2-game-running.ps2-tune-collapsed .ps2-tune-panel {
  width: min(230px, calc(100vw - 20px));
}

.ps2-debug-panel {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 20;
  width: min(430px, calc(100vw - 24px));
  max-height: min(48vh, 380px);
  overflow: auto;
  border: 1px solid rgba(99, 229, 255, 0.38);
  border-radius: 10px;
  background: rgba(3, 5, 12, 0.84);
  color: #f4f7ff;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-family: var(--ps2-ui);
}

body:not(.ps2-debug-perf) .ps2-debug-panel {
  display: none;
}

.ps2-debug-head {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 34px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(99, 229, 255, 0.2);
  background: rgba(3, 5, 12, 0.96);
}

.ps2-debug-head strong {
  color: var(--ps2-cyan);
  font: 900 12px/1 var(--ps2-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ps2-debug-head button {
  min-height: 24px;
  border: 1px solid rgba(118, 145, 230, 0.34);
  border-radius: 7px;
  padding: 0 8px;
  color: #eaf4ff;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.ps2-debug-grid {
  padding: 9px 10px 4px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.ps2-debug-grid div {
  min-width: 0;
  min-height: 48px;
  padding: 7px;
  border: 1px solid rgba(118, 145, 230, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.ps2-debug-grid span,
.ps2-debug-grid strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ps2-debug-grid span {
  margin-bottom: 4px;
  color: var(--ps2-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.ps2-debug-grid strong {
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.ps2-debug-panel pre {
  margin: 0;
  padding: 8px 10px 10px;
  max-height: 132px;
  overflow: auto;
  color: #bdefff;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 700 11px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

body.ps2-lite-effects::before,
body.ps2-lite-effects .ps2-canvas-wrap::before,
body.ps2-lite-effects .ps2-cover-box::after,
body.ps2-lite-effects #liveChat .live-chat-bg-canvas,
body.ps2-lite-effects #liveChat .live-chat-bg-overlay {
  display: none !important;
}

body.ps2-lite-effects .ps2-topbar,
body.ps2-lite-effects .ps2-side,
body.ps2-lite-effects .ps2-bottom {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.ps2-minimal-ui {
  background: #03040a;
}

body.ps2-minimal-ui::before,
body.ps2-minimal-ui .ps2-side {
  display: none !important;
}

body.ps2-minimal-ui .ps2-shell {
  width: min(1180px, 100%);
  grid-template-columns: minmax(0, 1fr);
  padding: 10px;
}

body.ps2-minimal-ui .ps2-stage {
  min-height: calc(100vh - 20px);
}

body.ps2-minimal-ui .ps2-topbar,
body.ps2-minimal-ui .ps2-bottom {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

body.ps2-minimal-ui #outputCanvas {
  width: min(100%, 960px, calc((100vh - 170px) * 1.3333));
  max-height: min(720px, calc(100vh - 170px));
}

.ps2-bottom {
  border-radius: var(--ps2-radius);
  min-height: 70px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.ps2-status {
  margin: 0;
  color: var(--ps2-text);
  font-weight: 800;
  font-size: 18px;
}

.ps2-status[data-tone="ok"] {
  color: var(--ps2-green);
}

.ps2-status[data-tone="error"] {
  color: #ff93b7;
}

.ps2-progress {
  margin-top: 3px;
  min-height: 18px;
  color: var(--ps2-muted);
  font-size: 15px;
  font-weight: 700;
}

.ps2-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ps2-button,
.ps2-file-label {
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(118, 145, 230, 0.32);
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ps2-text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0)),
    rgba(9, 12, 28, 0.9);
  cursor: pointer;
  font-family: var(--ps2-display);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

.ps2-button {
  border-color: rgba(99, 229, 255, 0.78);
  background: linear-gradient(135deg, rgba(99, 229, 255, 0.98), rgba(126, 137, 255, 0.92));
  color: #06101f;
  box-shadow:
    0 0 22px rgba(99, 229, 255, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.ps2-button:hover,
.ps2-file-label:hover {
  border-color: var(--ps2-line-hot);
  color: #fff;
  background:
    linear-gradient(180deg, rgba(99, 229, 255, 0.13), rgba(255, 77, 166, 0.045)),
    rgba(12, 16, 35, 0.94);
}

.ps2-button:hover {
  color: #06101f;
  background: linear-gradient(135deg, #8ff1ff, #ff75bd);
}

.ps2-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.ps2-file-label {
  position: relative;
}

.ps2-file-label input {
  position: absolute;
  inset: 0 auto auto 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

.ps2-side {
  min-height: calc(100vh - 32px);
  border-radius: var(--ps2-radius);
  padding: 14px;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 12px;
}

.ps2-cover-box {
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(99, 229, 255, 0.16);
  background:
    linear-gradient(140deg, rgba(99, 229, 255, 0.13), transparent 42%),
    linear-gradient(320deg, rgba(255, 77, 166, 0.12), transparent 48%),
    #0a0d18;
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.ps2-cover-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ps2-badge-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.ps2-badge {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(118, 145, 230, 0.24);
  display: grid;
  place-items: center;
  color: var(--ps2-muted);
  background: rgba(5, 7, 17, 0.72);
  font: 900 0.76rem/1 var(--ps2-display);
  letter-spacing: 0.08em;
}

.ps2-gamepad-card {
  border: 1px solid rgba(118, 145, 230, 0.22);
  border-radius: 12px;
  padding: 11px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015)),
    rgba(5, 7, 17, 0.76);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

.ps2-gamepad-card[data-state="connected"] {
  border-color: rgba(140, 255, 106, 0.42);
}

.ps2-gamepad-card[data-state="unsupported"],
.ps2-gamepad-card[data-state="disconnected"] {
  border-color: rgba(255, 111, 145, 0.32);
}

.ps2-gamepad-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
}

.ps2-gamepad-top span {
  color: var(--ps2-cyan);
  font: 900 0.68rem/1 var(--ps2-display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.ps2-gamepad-top strong {
  min-width: 0;
  overflow: hidden;
  color: #fff;
  font-size: 0.92rem;
  font-weight: 800;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ps2-gamepad-meter {
  height: 5px;
  margin: 10px 0 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.ps2-gamepad-meter i {
  display: block;
  width: 34%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ps2-cyan), var(--ps2-pink));
  transform: translateX(-120%);
  animation: ps2GamepadScan 1.6s ease-in-out infinite;
}

.ps2-gamepad-card[data-state="connected"] .ps2-gamepad-meter i {
  width: 100%;
  transform: none;
  animation: none;
  background: linear-gradient(90deg, var(--ps2-green), var(--ps2-cyan));
}

.ps2-gamepad-card p {
  margin: 0;
  min-height: 18px;
  color: var(--ps2-muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.ps2-gamepad-select-wrap {
  margin-top: 9px;
  display: grid;
  gap: 5px;
}

.ps2-gamepad-select-wrap span {
  color: var(--ps2-muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ps2-gamepad-select-wrap select {
  width: 100%;
  min-height: 32px;
  border: 1px solid rgba(118, 145, 230, 0.28);
  border-radius: 8px;
  padding: 0 9px;
  color: #fff;
  background: rgba(11, 15, 34, 0.96);
  font-size: 12px;
  font-weight: 800;
}

@keyframes ps2GamepadScan {
  0% {
    transform: translateX(-120%);
  }
  50% {
    transform: translateX(110%);
  }
  100% {
    transform: translateX(260%);
  }
}

.ps2-pad {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-content: start;
}

.ps2-pad-group {
  min-width: 0;
}

.ps2-pad-label {
  margin: 0 0 8px;
  color: var(--ps2-cyan);
  font: 900 11px/1 var(--ps2-display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.ps2-dpad,
.ps2-face {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  gap: 6px;
}

.ps2-face {
  margin-left: auto;
}

.ps2-key,
.ps2-rect-key {
  border: 1px solid rgba(118, 145, 230, 0.32);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.015)),
    rgba(10, 14, 31, 0.94);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 8px 20px rgba(0, 0, 0, 0.22);
}

.ps2-key {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1rem;
}

.ps2-key:hover,
.ps2-rect-key:hover {
  border-color: var(--ps2-line-hot);
  background:
    linear-gradient(180deg, rgba(99, 229, 255, 0.16), rgba(255, 77, 166, 0.04)),
    rgba(12, 16, 35, 0.96);
}

.ps2-key.is-pressed,
.ps2-key:active,
.ps2-rect-key.is-pressed,
.ps2-rect-key:active {
  transform: translateY(1px) scale(0.97);
  border-color: rgba(140, 255, 106, 0.5);
  background:
    linear-gradient(135deg, rgba(99, 229, 255, 0.28), rgba(255, 77, 166, 0.14)),
    rgba(12, 16, 35, 0.98);
}

.ps2-key.up { grid-column: 2; grid-row: 1; }
.ps2-key.left { grid-column: 1; grid-row: 2; }
.ps2-key.right { grid-column: 3; grid-row: 2; }
.ps2-key.down { grid-column: 2; grid-row: 3; }
.ps2-key.tri { grid-column: 2; grid-row: 1; color: var(--ps2-green); }
.ps2-key.sqr { grid-column: 1; grid-row: 2; color: var(--ps2-pink); }
.ps2-key.cir { grid-column: 3; grid-row: 2; color: var(--ps2-red); }
.ps2-key.crs { grid-column: 2; grid-row: 3; color: var(--ps2-cyan); }

.ps2-shoulders,
.ps2-system {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.ps2-system {
  grid-template-columns: repeat(2, 1fr);
}

.ps2-rect-key {
  min-height: 42px;
  border-radius: 12px;
  color: #fff;
  font: 900 0.82rem/1 var(--ps2-display);
}

.ps2-note {
  margin: 0;
  color: var(--ps2-muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

@media (max-width: 1060px) {
  .ps2-shell {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .ps2-stage,
  .ps2-side {
    min-height: auto;
  }

  .ps2-side {
    grid-template-rows: auto auto auto auto auto;
  }

  .ps2-cover-box {
    display: none;
  }

  #outputCanvas,
  .ps2-filter-canvas {
    width: 100%;
    max-height: none;
  }
}

@media (max-width: 680px) {
  .ps2-topbar,
  .ps2-bottom {
    grid-template-columns: 1fr;
  }

  .ps2-title {
    font-size: 22px;
  }

  .ps2-stat {
    justify-self: start;
  }

  .ps2-actions {
    justify-content: stretch;
  }

  .ps2-button,
  .ps2-file-label {
    flex: 1 1 148px;
  }

  .ps2-pad {
    grid-template-columns: 1fr;
  }

  .ps2-face {
    margin-left: 0;
  }

  .ps2-gamepad-top {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .ps2-gamepad-top strong {
    text-align: left;
  }

  .ps2-tune-panel {
    top: 8px;
    left: 8px;
    right: 8px;
    width: auto;
    max-height: calc(100vh - 16px);
    overflow: hidden;
  }

  body.ps2-game-running .ps2-tune-panel {
    left: auto;
    right: 8px;
    width: min(272px, calc(100vw - 16px));
    max-height: min(76vh, calc(100vh - 16px));
  }

  body.ps2-game-running .ps2-tune-body {
    max-height: min(66vh, calc(100vh - 82px));
  }

  body.ps2-game-running.ps2-tune-collapsed .ps2-tune-panel {
    left: auto;
    right: 8px;
    width: min(230px, calc(100vw - 16px));
  }

  body.ps2-game-running.ps2-tune-collapsed .ps2-shell {
    width: calc(100vw - 16px);
    margin: 0 auto;
    padding: 8px 8px 10px;
  }

  body.ps2-game-running.ps2-tune-collapsed .ps2-canvas-wrap {
    min-height: min(620px, calc(100vh - 72px));
    height: min(620px, calc(100vh - 72px));
  }

  .ps2-tune-grid {
    grid-template-columns: 1fr;
  }

  .ps2-free-pref,
  .ps2-tune-actions {
    grid-template-columns: 1fr;
  }

  .ps2-tune-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ps2-debug-panel {
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    max-height: 44vh;
  }

  .ps2-debug-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
