    * { box-sizing: border-box; }
    :root {
      --panel: rgba(10, 10, 10, 0.55);
      --panel-edge: rgba(255, 255, 255, 0.10);
      --button: rgba(20, 20, 20, 0.5);
      --button-hover: rgba(40, 40, 40, 0.65);
      --text: rgba(255, 255, 255, 0.88);
      --muted: rgba(255, 255, 255, 0.5);
      --accent: #1fb5a8;
      --danger: #ff7a7a;
      scrollbar-width: thin;
      scrollbar-color: #666 #1a1a1a;
    }
    html, body { margin: 0; min-height: 100%; }
    body {
      background-color: rgba(59, 117, 114, 0.67);
      background-image: url('../assets/background.avif');
      background-attachment: fixed;
      background-size: cover;
      background-position: center;
      color: var(--text);
      font: 14px/1.45 'Inter', Arial, sans-serif;
      display: flex;
      flex-direction: column;
      min-height: 100vh;
      overflow-x: hidden;
    }
    button, input, select, textarea { font: inherit; color: inherit; }

    header {
      position: relative;
      min-height: 67px;
      padding: 11px 70px;
      background: rgba(0, 0, 0, 0.4);
      border-bottom: 1px solid #ddd;
    }
    .logo { position: absolute; left: 5px; top: 50%; width: 250px; height: 45px; margin-top: -22px; }
    .logo2 { position: absolute; right: 13px; top: 50%; width: 50px; height: 50px; margin-top: -25px; }

    /* Portrait and narrow screens: one centered column, the game on top, its
       toolbar, then Ajustes/Log (landscape layout at the end of this sheet).
       The stage is as wide as the screen allows while the whole 480:272
       picture plus the header and toolbar still fit in the viewport height. */
    :root {
      --chrome-height: 150px;
      --stage-width: min(1100px, max(320px, calc((100vh - var(--chrome-height)) * 480 / 272)));
    }
    @supports (height: 100svh) {
      :root { --stage-width: min(1100px, max(320px, calc((100svh - var(--chrome-height)) * 480 / 272))); }
    }
    .layout {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 14px;
      width: 100%;
      margin: 0 auto;
      padding: 16px 16px 30px;
    }
    .player-col { width: 100%; max-width: var(--stage-width); display: flex; flex-direction: column; }

    /* PSP screen: 480x272 */
    .player {
      position: relative;
      width: 100%;
      aspect-ratio: 480 / 272;
      background: #000;
      border-radius: 8px;
      overflow: hidden;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    }
    .player canvas {
      position: absolute; inset: 0;
      width: 100% !important; height: 100% !important;
      display: block; outline: none;
      image-rendering: pixelated;
    }
    #overlay {
      position: absolute; inset: 0;
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      gap: 12px; padding: 20px; text-align: center;
      background: radial-gradient(ellipse at center, rgba(0,0,0,0.55), rgba(0,0,0,0.88));
      cursor: pointer;
    }
    #overlay[hidden] { display: none; }
    #overlay .title { font-size: 26px; font-weight: 700; letter-spacing: 0.02em; }
    #overlay .subtitle { color: var(--muted); font-size: 13px; margin-top: -8px; }
    .load-line { width: min(360px, 90%); display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
    .load-line progress { width: 100%; height: 8px; accent-color: var(--accent); }
    #hint {
      background: var(--accent); color: #062b28; font-weight: 700;
      padding: 9px 22px; border-radius: 8px;
    }
    #hint[hidden] { display: none; }
    /* Unsupported-browser notice (js/compat.js). */
    .compat-notice {
      width: min(420px, 92%); font-size: 13px; line-height: 1.4;
      color: #fd8; background: rgba(0, 0, 0, 0.55); padding: 8px 12px; border-radius: 8px;
    }
    .compat-notice[hidden] { display: none; }
    .compat-notice.error { color: var(--danger); font-weight: 600; }

    .now-playing {
      display: flex; justify-content: space-between; gap: 10px;
      margin: 10px 2px 4px; min-height: 18px;
      font-size: 12px; color: rgba(255, 255, 255, 0.65);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .toolbar { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
    .btn {
      flex: 1 1 0;
      min-width: 120px;
      background: var(--button);
      border: none;
      border-radius: 8px;
      box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25);
      padding: 10px 16px;
      cursor: pointer;
      color: white;
      transition: background 0.15s;
    }
    .btn:hover:not(:disabled) { background: var(--button-hover); }
    .btn:disabled { opacity: 0.45; cursor: default; }
    .btn.small { flex: 0 0 auto; min-width: 0; padding: 6px 12px; font-size: 12px; }
    .btn.primary { background: var(--accent); color: #062b28; font-weight: 700; }
    .btn.primary:hover { background: #26c9bb; }

    .sidebar {
      width: 100%;
      max-width: max(var(--stage-width), min(100%, 720px));
      background: var(--panel);
      border-radius: 10px;
      box-shadow: inset 0 0 0 1.5px var(--panel-edge);
      display: flex; flex-direction: column;
    }
    /* Six tabs: they share the row on wide screens and scroll sideways on phones. */
    .tabs {
      display: flex; border-bottom: 1px solid rgba(255, 255, 255, 0.12);
      overflow-x: auto; scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab {
      flex: 1 0 auto; white-space: nowrap; background: none; border: none; cursor: pointer;
      padding: 12px 10px 10px;
      font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
      color: var(--muted); border-bottom: 2px solid transparent;
    }
    .tab.active { color: white; border-bottom-color: var(--accent); }
    .panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 12px 14px; gap: 10px; overflow-y: auto; }
    .panel[hidden] { display: none; }
    .settings-status { padding: 0 14px 10px; }
    .settings-status:empty { display: none; }
    .section-label {
      font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
      color: rgba(255, 255, 255, 0.4);
    }
    .field { display: flex; flex-direction: column; gap: 4px; }
    .field span { font-size: 12px; color: rgba(255, 255, 255, 0.75); }
    .text-input {
      width: 100%;
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid rgba(255, 255, 255, 0.18);
      border-radius: 6px;
      padding: 7px 10px;
      font-size: 13px;
      outline: none;
    }
    .text-input:focus { border-color: var(--accent); }
    .text-input::placeholder { color: rgba(255, 255, 255, 0.3); }
    .summary {
      white-space: pre-wrap; overflow-wrap: anywhere;
      font: 12px/1.45 ui-monospace, Consolas, monospace;
      background: rgba(0, 0, 0, 0.3); border-radius: 6px; padding: 8px 10px;
      color: rgba(255, 255, 255, 0.75);
    }
    .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
    .note { font-size: 12px; color: var(--muted); }
    .saveRow {
      display: flex; align-items: center; gap: 8px;
      padding: 5px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }
    .saveRow .name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font: 12px/1.3 ui-monospace, Consolas, monospace; }
    .saveRow .size { color: var(--muted); font-size: 11px; white-space: nowrap; }
    .note code { font-size: 11px; color: rgba(255, 255, 255, 0.8); }
    details summary { cursor: pointer; font-size: 12px; color: rgba(255, 255, 255, 0.7); }
    details .note { margin-top: 6px; }

    #log {
      flex: 1 1 auto; min-height: 220px; max-height: 60vh; margin: 0; padding: 8px 10px;
      overflow-y: auto; border-radius: 6px;
      background: rgba(0, 0, 0, 0.55); color: #9f9;
      font: 11.5px/1.35 ui-monospace, Consolas, monospace;
      white-space: pre-wrap; word-break: break-word;
    }
    #log[hidden] { display: none; }
    #log .err { color: var(--danger); }
    #dropped { font-size: 11px; color: var(--muted); }
    .check { display: flex; align-items: center; gap: 6px; font-size: 12px; user-select: none; }

    footer {
      text-align: center; font-size: 12px; padding: 8px 12px;
      border-top: 2px solid white; background: rgba(0, 0, 0, 0.4);
    }
    footer h3 { margin: 6px 0; font-size: 15px; font-weight: 600; }

    /* Modals */
    .modal {
      position: fixed; inset: 0; z-index: 10;
      display: flex; align-items: center; justify-content: center;
      background: rgba(0, 0, 0, 0.6);
      padding: 16px;
    }
    .modal[hidden] { display: none; }
    .modal-panel {
      width: min(540px, 100%); max-height: 86vh; overflow-y: auto;
      background: rgba(18, 18, 18, 0.95);
      border-radius: 10px; box-shadow: inset 0 0 0 1.5px var(--panel-edge), 0 20px 50px rgba(0,0,0,0.5);
      padding: 16px 18px;
    }
    .modal-panel h2 { margin: 0 0 4px; font-size: 17px; }
    .modal-panel .hint { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
    .group { margin-bottom: 14px; }
    .group h3 {
      margin: 0 0 6px; font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
      color: rgba(255, 255, 255, 0.4);
    }
    .bindRow, .setRow {
      display: flex; align-items: center; justify-content: space-between; gap: 8px;
      padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }
    .bindRow .action { flex: 1 1 auto; }
    .bindRow .current { color: #8fe3da; font: 12px/1.3 ui-monospace, Consolas, monospace; min-width: 90px; text-align: right; }
    .bindRow button, .setRow select {
      background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.18);
      border-radius: 6px; padding: 4px 10px; cursor: pointer; white-space: nowrap;
    }
    .setRow select option { background: #1b1b1b; }
    .setRow .range { display: flex; align-items: center; gap: 8px; flex: 0 1 220px; }
    .setRow .range input { flex: 1 1 auto; min-width: 0; accent-color: var(--accent); }
    .setRow .range output { min-width: 38px; text-align: right; font-size: 12px; color: rgba(255, 255, 255, 0.75); }
    .bindRow button.capturing { background: #654; border-color: #b90; color: #fd8; }
    .playerTabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
    .playerTabs button {
      flex: 1 1 0; min-width: 40px; padding: 5px 0; cursor: pointer; font-size: 12px;
      background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 6px;
    }
    .playerTabs button.active { background: var(--accent); border-color: var(--accent); color: #062b28; font-weight: 700; }
    .deviceRow .current { flex: 1 1 auto; text-align: center; }
    .bindingsTools { margin-bottom: 12px; }
    .padRow { padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
    .padRow .padName { font-weight: 600; overflow-wrap: anywhere; }
    .padRow .padMeta { color: var(--muted); font-size: 12px; }
    .padRow .padMeta.warn { color: #fd8; }
    .padRow .padLive { color: #8fe3da; font: 12px/1.3 ui-monospace, Consolas, monospace; min-height: 16px; margin: 2px 0 4px; }
    .padEmpty { color: var(--muted); font-size: 12px; }
    .padWizard { margin-top: 8px; padding: 10px; border: 1px solid var(--accent); border-radius: 8px; }
    .padWizard[hidden] { display: none; }
    .padWizard .padWizardStep { font-weight: 600; margin-bottom: 4px; }
    .padWizard .padWizardNote { color: var(--muted); font-size: 12px; min-height: 16px; margin-bottom: 8px; }
    /* Page fullscreen: the stage fills the screen and the canvas keeps the PSP aspect. */
    .player:fullscreen { width: 100vw; height: 100vh; aspect-ratio: auto; border-radius: 0; box-shadow: none; }
    .player:-webkit-full-screen { width: 100vw; height: 100vh; aspect-ratio: auto; border-radius: 0; box-shadow: none; }
    .player:fullscreen canvas { object-fit: contain; }
    .player:-webkit-full-screen canvas { object-fit: contain; }
    #settingsIni {
      width: 100%; height: 220px; margin-top: 6px; resize: vertical;
      background: rgba(0, 0, 0, 0.6); color: #9f9;
      border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 6px;
      font: 12px/1.3 ui-monospace, Consolas, monospace;
    }
    /* Savedata slot picker and result notice, drawn over the game. */
    .stage-dialog {
      position: absolute; inset: 0; z-index: 5;
      display: flex; align-items: center; justify-content: center;
      background: rgba(0, 0, 0, 0.6); padding: 12px;
    }
    .stage-dialog[hidden] { display: none; }
    .stage-dialog-panel {
      width: min(440px, 100%); max-height: 100%; display: flex; flex-direction: column;
      background: rgba(18, 18, 18, 0.95); border-radius: 10px;
      box-shadow: inset 0 0 0 1.5px var(--panel-edge), 0 20px 50px rgba(0, 0, 0, 0.5);
      padding: 14px 16px;
    }
    .stage-dialog-panel h2 { margin: 0 0 4px; font-size: 16px; }
    .stage-dialog-panel .hint { color: var(--muted); font-size: 11px; margin-bottom: 10px; }
    .savedata-list { display: flex; flex-direction: column; gap: 4px; min-height: 0; overflow-y: auto; }
    .slot {
      display: flex; justify-content: space-between; gap: 10px; text-align: left;
      padding: 7px 10px; border-radius: 6px; cursor: pointer;
      background: rgba(255, 255, 255, 0.06); border: 1px solid transparent;
    }
    .slot.selected { border-color: var(--accent); background: rgba(31, 181, 168, 0.18); }
    .slot:disabled { opacity: 0.4; cursor: default; }
    .slot .when { color: var(--muted); font-size: 12px; white-space: nowrap; }
    .toast {
      position: absolute; left: 50%; bottom: 12px; z-index: 6; transform: translateX(-50%);
      background: rgba(0, 0, 0, 0.8); padding: 8px 16px; border-radius: 8px;
      font-weight: 600; pointer-events: none; white-space: nowrap;
    }
    .toast[hidden] { display: none; }
    .toast.error { color: var(--danger); }
    /* Game data download notice (js/runtime/downloads.js). */
    .net-status {
      position: absolute; left: 50%; top: 10px; z-index: 6; transform: translateX(-50%);
      background: rgba(0, 0, 0, 0.8); padding: 6px 14px; border-radius: 8px;
      font-size: 13px; font-weight: 600; pointer-events: none; white-space: nowrap;
    }
    .net-status[hidden] { display: none; }    .net-status.warn { color: #fd8; }
    /* Whole-pak background download progress (js/pakdownload.js). */
    .pak-status {
      position: absolute; left: 10px; bottom: 10px; z-index: 6;
      background: rgba(0, 0, 0, 0.7); padding: 4px 10px; border-radius: 6px;
      font-size: 11px; color: var(--muted); pointer-events: none; white-space: nowrap;
    }
    .pak-status[hidden] { display: none; }
    .modal-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 14px; }
    .modal-status { color: var(--muted); font-size: 12px; min-height: 16px; flex: 1 1 auto; }

    /* Landscape screens from tablet width up: the game on the left and the
       Ajustes/Log panel as a fixed-width bar on the right. Portrait (9:16)
       and narrower screens keep the single column above. */
    @media (min-width: 820px) and (orientation: landscape) {
      .layout {
        flex-direction: row;
        align-items: flex-start;
        justify-content: center;
        gap: 16px;
        max-width: 1320px;
        padding: 20px 16px 30px;
      }
      .player-col { flex: 1 1 0; min-width: 0; max-width: var(--stage-width); }
      .sidebar {
        flex: 0 0 380px;
        width: 380px;
        max-width: none;
        max-height: calc(100vh - 140px);
        min-height: 420px;
      }
      /* Six tabs do not fit one row of the 380px bar: two rows of three. */
      .sidebar .tabs { display: grid; grid-template-columns: repeat(3, 1fr); overflow-x: visible; }
      .sidebar .tab { padding: 10px 6px 8px; }
    }
    @media (max-width: 768px) {
      :root { --chrome-height: 130px; }
      .layout { gap: 10px; padding: 8px 8px 22px; }
      .player { border-radius: 4px; }
      header { padding: 10px 12px; min-height: 62px; }
      .logo { width: 205px; height: 37px; left: 10px; margin-top: -18px; }
      .logo2 { width: 42px; height: 42px; right: 10px; margin-top: -21px; }
      .btn { min-width: 100px; padding: 9px 10px; }
    }

    .bindings-player-tools { margin-top: 8px; }
