.emu-page {
    width: min(1700px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 18px 0 48px 0;
    color: var(--text, #f3f4f6);
}

.emu-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 18px;
    align-items: start;
}

.emu-panel {
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 22px;
    background: rgba(20, 24, 32, 0.82);
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.26);
    backdrop-filter: blur(14px);
}

.emu-main {
    padding: 18px;
}

.emu-library {
    padding: 16px;
    position: sticky;
    top: 82px;
    max-height: calc(100vh - 110px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.emu-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.emu-kicker {
    margin: 0 0 4px 0;
    color: #f2ad22;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.emu-panel h1,
.emu-panel h2 {
    margin: 0;
    color: #ffffff;
    line-height: 1.1;
}

.emu-panel h1 {
    font-size: clamp(28px, 4vw, 48px);
}

.emu-panel h2 {
    font-size: 22px;
}

.emu-main-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.emu-btn {
    border: 0;
    border-radius: 14px;
    padding: 11px 15px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.emu-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.emu-btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.emu-btn-primary {
    background: #f2ad22;
    color: #111827;
}

.emu-btn-secondary {
    background: rgba(255, 255, 255, 0.09);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

/*
   GBA: 240x160 = 3:2

   Wichtig:
   Keine Regeln auf #emulator-player > *
   Keine Regeln auf .ejs_*
   Keine Regeln auf [class*="bar"] / [class*="control"]

   EmulatorJS muss sein eigenes internes Layout behalten,
   sonst landet die Toolbar wieder falsch.
*/
.emu-player-box {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 2;
    min-height: 0;
    border-radius: 20px;
    overflow: hidden;
    background: #05070b;
    border: 1px solid rgba(255, 255, 255, 0.10);
}

.emu-runtime {
    position: absolute;
    inset: 0;
    z-index: 5;
    width: 100%;
    height: 100%;
    overflow: hidden;
    outline: none;
}

#emulator-player {
    width: 100%;
    height: 100%;
    outline: none;
}

#emulator-player canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.emu-placeholder {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: grid;
    place-content: center;
    gap: 8px;
    text-align: center;
    color: rgba(255, 255, 255, 0.78);
    pointer-events: none;
}

.emu-placeholder strong {
    color: #ffffff;
    font-size: 24px;
}

.emu-preview-cover,
.emu-preview-video {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #05070b;
}

.emu-preview-cover[hidden],
.emu-preview-video[hidden] {
    display: none !important;
}

.emu-drop-hint {
    position: absolute;
    inset: 18px;
    z-index: 10;
    border: 2px dashed rgba(242, 173, 34, 0.75);
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: rgba(5, 7, 11, 0.76);
    color: #ffffff;
    font-weight: 900;
    font-size: 22px;
}

.emu-drop-hint[hidden] {
    display: none !important;
}

.emu-player-box.is-dragover {
    border-color: #f2ad22;
    background: rgba(242, 173, 34, 0.10);
}

.emu-selected-card,
.emu-local-card,
.emu-controls-card {
    margin-top: 16px;
    padding: 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid rgba(255, 255, 255, 0.09);
}

.emu-selected-card h2 {
    margin: 0 0 6px 0;
    font-size: 22px;
}

.emu-selected-card p:last-child,
.emu-local-card p:last-child,
.emu-controls-card p:last-child {
    margin-bottom: 0;
}

.emu-controls-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.emu-controls-grid div {
    border-radius: 14px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.emu-controls-grid strong {
    display: block;
    color: #ffffff;
    font-size: 14px;
    font-weight: 900;
}

.emu-controls-grid span {
    display: block;
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.68);
    font-size: 12px;
    font-weight: 700;
}

.emu-rom-drop {
    min-height: 82px;
    border: 1px dashed rgba(255, 255, 255, 0.22);
    border-radius: 16px;
    display: grid;
    place-content: center;
    gap: 4px;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.045);
}

.emu-rom-drop:hover,
.emu-rom-drop.is-dragover {
    border-color: #f2ad22;
    background: rgba(242, 173, 34, 0.10);
}

.emu-rom-drop.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.emu-message {
    margin-top: 14px;
    white-space: pre-wrap;
    border-radius: 14px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.emu-message[hidden] {
    display: none !important;
}

.emu-message.is-error {
    background: rgba(220, 38, 38, 0.18);
    border: 1px solid rgba(248, 113, 113, 0.35);
}

.emu-count {
    min-width: 42px;
    height: 42px;
    padding: 0 12px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: rgba(242, 173, 34, 0.18);
    color: #f2ad22;
    font-weight: 900;
}

.emu-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: 8px;
    margin-bottom: 12px;
}

.emu-search input {
    min-width: 0;
    height: 42px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.11);
    background: rgba(255, 255, 255, 0.07);
    color: #ffffff;
    padding: 0 13px;
    outline: none;
}

.emu-search input:focus {
    border-color: rgba(242, 173, 34, 0.75);
}

.emu-search button {
    border: 0;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-size: 22px;
    cursor: pointer;
}

.emu-game-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px 6px 12px 0;
    min-height: 0;
    flex: 1 1 auto;
    background: transparent;
}

.emu-game-card {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    min-width: 0;
    min-height: 118px;
    margin: 0;
    padding: 0;
    display: block;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.055);
    color: #ffffff;
    cursor: pointer;
    overflow: hidden;
    box-sizing: border-box;
    text-align: initial;
    line-height: normal;
    transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.emu-game-card:hover {
    border-color: rgba(242, 173, 34, 0.75);
    background: rgba(242, 173, 34, 0.11);
    transform: translateY(-1px);
}

.emu-game-card.is-active {
    border-color: #f2ad22;
    background: rgba(242, 173, 34, 0.18);
}

.emu-game-info,
.emu-game-title,
.emu-game-meta {
    display: none !important;
}

.emu-game-thumb-wrap {
    width: 100%;
    min-height: 118px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 17px;
    overflow: hidden;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.24);
}

.emu-game-thumb {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: none;
    display: block;
    object-fit: contain;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.emu-game-thumb[hidden] {
    display: none !important;
}

.emu-game-thumb-placeholder {
    width: 100%;
    min-height: 118px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f2ad22;
    font-size: 15px;
    font-weight: 900;
    letter-spacing: 0.03em;
    line-height: 1.25;
    text-align: center;
    background:
        linear-gradient(135deg, rgba(242, 173, 34, 0.20), rgba(242, 173, 34, 0.05)),
        rgba(0, 0, 0, 0.28);
}

.emu-game-thumb-placeholder[hidden] {
    display: none !important;
}

.emu-empty-state {
    padding: 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.055);
    color: rgba(255, 255, 255, 0.75);
}

.emu-empty-state[hidden] {
    display: none !important;
}

.emu-touch-controls,
.emu-touch-toggle {
    display: none !important;
}

.emu-confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.66);
    backdrop-filter: blur(8px);
}

.emu-confirm-backdrop[hidden] {
    display: none !important;
}

.emu-confirm-dialog {
    width: min(540px, calc(100vw - 32px));
    border-radius: 22px;
    padding: 22px;
    background: rgba(20, 24, 32, 0.98);
    border: 1px solid rgba(242, 173, 34, 0.35);
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.62);
    color: #ffffff;
}

.emu-confirm-dialog h2 {
    margin: 0 0 10px 0;
    color: #f2ad22;
    font-size: 26px;
}

.emu-confirm-dialog p {
    margin: 0;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1.45;
}

.emu-confirm-actions {
    margin-top: 22px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

@media (max-width: 1100px) {
    .emu-shell {
        grid-template-columns: 1fr;
    }

    .emu-library {
        position: static;
        max-height: none;
    }
}

@media (max-width: 720px) {
    .emu-page {
        width: min(100vw - 18px, 100%);
        padding-bottom: 48px;
    }

    .emu-main-actions {
        width: 100%;
        justify-content: stretch;
    }

    .emu-btn {
        flex: 1;
    }

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

    .emu-game-card {
        height: 96px;
        min-height: 96px;
        max-height: 96px;
        flex-basis: 96px;
    }

    .emu-game-thumb-wrap,
    .emu-game-thumb-placeholder {
        min-height: 94px;
    }
}

body.light-mode .emu-panel,
html[data-theme="light"] .emu-panel {
    background: rgba(255, 255, 255, 0.84);
    color: #111827;
}

body.light-mode .emu-panel h1,
body.light-mode .emu-panel h2,
html[data-theme="light"] .emu-panel h1,
html[data-theme="light"] .emu-panel h2 {
    color: #111827;
}

body.light-mode .emu-game-card,
html[data-theme="light"] .emu-game-card {
    background: rgba(17, 24, 39, 0.045);
    color: #111827;
    border-color: rgba(17, 24, 39, 0.12);
}

body.light-mode .emu-controls-grid strong,
html[data-theme="light"] .emu-controls-grid strong {
    color: #111827;
}

body.light-mode .emu-controls-grid span,
html[data-theme="light"] .emu-controls-grid span {
    color: rgba(17, 24, 39, 0.68);
}

body.light-mode .emu-search input,
html[data-theme="light"] .emu-search input {
    background: rgba(17, 24, 39, 0.055);
    color: #111827;
    border-color: rgba(17, 24, 39, 0.14);
}

body.light-mode .emu-search button,
html[data-theme="light"] .emu-search button {
    background: rgba(17, 24, 39, 0.07);
    color: #111827;
}

body.light-mode .emu-rom-drop,
html[data-theme="light"] .emu-rom-drop,
body.light-mode .emu-selected-card,
html[data-theme="light"] .emu-selected-card,
body.light-mode .emu-local-card,
html[data-theme="light"] .emu-local-card,
body.light-mode .emu-controls-card,
html[data-theme="light"] .emu-controls-card {
    background: rgba(17, 24, 39, 0.045);
    border-color: rgba(17, 24, 39, 0.10);
}

body.light-mode .emu-confirm-dialog,
html[data-theme="light"] .emu-confirm-dialog {
    background: rgba(255, 255, 255, 0.98);
    color: #111827;
}

body.light-mode .emu-confirm-dialog p,
html[data-theme="light"] .emu-confirm-dialog p {
    color: rgba(17, 24, 39, 0.72);
}

/* =========================================================
   ROM-Bibliothek: Logos vollständig anzeigen
   Muss ganz am Ende der emulator.css stehen.
   ========================================================= */

.emu-game-card {
    min-height: 128px !important;
    height: 128px !important;
    max-height: none !important;
    flex: 0 0 128px !important;
    overflow: hidden !important;
}

.emu-game-thumb-wrap {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    padding: 10px !important;
    box-sizing: border-box !important;

    overflow: hidden !important;
}

.emu-game-thumb {
    width: auto !important;
    height: auto !important;

    max-width: 100% !important;
    max-height: 100% !important;

    object-fit: contain !important;
    object-position: center center !important;

    display: block !important;
    border: 0 !important;
    background: transparent !important;
}

.emu-game-thumb[hidden] {
    display: none !important;
}

.emu-game-thumb-placeholder {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;

    padding: 16px !important;
    box-sizing: border-box !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    text-align: center !important;
    line-height: 1.25 !important;
    overflow-wrap: anywhere !important;
}

.emu-game-thumb-placeholder[hidden] {
    display: none !important;
}

/* =========================================================
   Emulator Touch-Steuerung für Smartphone / Tablet
   ========================================================= */

.emu-mobile-controls-bar {
    display: none;
    margin-top: 14px;
}

.emu-touch-toggle {
    border: 0;
    border-radius: 999px;
    padding: 11px 16px;
    background: rgba(242, 173, 34, 0.16);
    color: #f2ad22;
    font-weight: 900;
    cursor: pointer;
    border: 1px solid rgba(242, 173, 34, 0.35);
}

.emu-touch-toggle:hover {
    background: rgba(242, 173, 34, 0.24);
}

.emu-touch-controls {
    position: fixed;
    left: 50%;
    bottom: 18px;
    z-index: 9000;
    width: min(760px, calc(100vw - 24px));
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: 170px minmax(120px, 1fr) 190px;
    gap: 14px;
    align-items: end;
    padding: 14px;
    border-radius: 24px;
    background: rgba(20, 24, 32, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 18px 70px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(14px);
    touch-action: none;
    user-select: none;
}

.emu-touch-controls[hidden] {
    display: none !important;
}

.emu-touch-left {
    position: relative;
    width: 160px;
    height: 160px;
}

.emu-touch-btn,
.emu-touch-action,
.emu-touch-small,
.emu-touch-shoulder {
    border: 0;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.14);
    font-weight: 900;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.emu-touch-btn:active,
.emu-touch-btn.is-pressed,
.emu-touch-action:active,
.emu-touch-action.is-pressed,
.emu-touch-small:active,
.emu-touch-small.is-pressed,
.emu-touch-shoulder:active,
.emu-touch-shoulder.is-pressed {
    background: #f2ad22;
    color: #111827;
    transform: scale(0.96);
}

.emu-touch-btn {
    position: absolute;
    width: 54px;
    height: 54px;
    border-radius: 18px;
    font-size: 20px;
}

.emu-touch-up {
    left: 53px;
    top: 0;
}

.emu-touch-left-btn {
    left: 0;
    top: 53px;
}

.emu-touch-right-btn {
    right: 0;
    top: 53px;
}

.emu-touch-down {
    left: 53px;
    bottom: 0;
}

.emu-touch-middle {
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 10px;
    padding-bottom: 12px;
}

.emu-touch-small {
    min-width: 76px;
    height: 42px;
    border-radius: 999px;
    font-size: 12px;
}

.emu-touch-right {
    position: relative;
    width: 180px;
    height: 160px;
}

.emu-touch-action {
    position: absolute;
    width: 68px;
    height: 68px;
    border-radius: 999px;
    font-size: 22px;
}

.emu-touch-a {
    right: 8px;
    top: 42px;
    background: rgba(242, 173, 34, 0.78);
    color: #111827;
}

.emu-touch-b {
    left: 26px;
    top: 72px;
}

.emu-touch-shoulder {
    position: absolute;
    width: 64px;
    height: 38px;
    border-radius: 999px;
    font-size: 13px;
}

.emu-touch-shoulder[data-emu-key="e"] {
    left: 8px;
    top: 0;
}

.emu-touch-shoulder[data-emu-key="r"] {
    right: 8px;
    top: 0;
}

@media (max-width: 900px),
(pointer: coarse) {
    .emu-mobile-controls-bar {
        display: flex;
        justify-content: center;
    }
}

@media (max-width: 620px) {
    .emu-touch-controls {
        grid-template-columns: 136px 1fr 150px;
        gap: 8px;
        padding: 10px;
        bottom: 10px;
    }

    .emu-touch-left {
        width: 132px;
        height: 132px;
    }

    .emu-touch-btn {
        width: 46px;
        height: 46px;
        border-radius: 15px;
    }

    .emu-touch-up {
        left: 43px;
    }

    .emu-touch-left-btn {
        top: 43px;
    }

    .emu-touch-right-btn {
        top: 43px;
    }

    .emu-touch-down {
        left: 43px;
    }

    .emu-touch-right {
        width: 142px;
        height: 132px;
    }

    .emu-touch-action {
        width: 58px;
        height: 58px;
    }

    .emu-touch-a {
        right: 0;
        top: 36px;
    }

    .emu-touch-b {
        left: 10px;
        top: 62px;
    }

    .emu-touch-shoulder {
        width: 52px;
        height: 34px;
    }

    .emu-touch-small {
        min-width: 62px;
        height: 36px;
        font-size: 11px;
    }
}

.emu-savestate-card {
    margin-top: 16px;
    padding: 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid rgba(255, 255, 255, 0.09);
}

.emu-savestate-status {
    margin-top: 8px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 14px;
    line-height: 1.4;
}

.emu-savestate-actions {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.emu-savestate-hint {
    margin: 12px 0 0 0;
    color: rgba(255, 255, 255, 0.62);
    font-size: 13px;
    line-height: 1.45;
}

body.light-mode .emu-savestate-card,
html[data-theme="light"] .emu-savestate-card {
    background: rgba(17, 24, 39, 0.045);
    border-color: rgba(17, 24, 39, 0.10);
}

body.light-mode .emu-savestate-status,
html[data-theme="light"] .emu-savestate-status {
    color: rgba(17, 24, 39, 0.74);
}

body.light-mode .emu-savestate-hint,
html[data-theme="light"] .emu-savestate-hint {
    color: rgba(17, 24, 39, 0.58);
}

.emu-savestate-manager-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.66);
    backdrop-filter: blur(8px);
}

.emu-savestate-manager-backdrop[hidden] {
    display: none !important;
}

.emu-savestate-manager-dialog {
    width: min(860px, calc(100vw - 32px));
    max-height: min(760px, calc(100vh - 32px));
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 22px;
    padding: 18px;
    background: rgba(20, 24, 32, 0.98);
    border: 1px solid rgba(242, 173, 34, 0.35);
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.62);
    color: #ffffff;
}

.emu-savestate-manager-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.emu-savestate-manager-head h2 {
    margin: 0;
    color: #ffffff;
    font-size: 26px;
}

.emu-savestate-manager-close {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.emu-savestate-manager-status {
    margin-bottom: 12px;
    color: rgba(255, 255, 255, 0.74);
    font-size: 14px;
}

.emu-savestate-manager-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding-right: 4px;
}

.emu-savestate-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid rgba(255, 255, 255, 0.09);
}

.emu-savestate-row-title {
    font-weight: 900;
    color: #ffffff;
    overflow-wrap: anywhere;
}

.emu-savestate-row-meta {
    margin-top: 4px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.62);
}

.emu-savestate-row-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.emu-savestate-danger {
    background: rgba(220, 38, 38, 0.20);
    color: #ffffff;
    border: 1px solid rgba(248, 113, 113, 0.32);
}

@media (max-width: 720px) {
    .emu-savestate-row {
        grid-template-columns: 1fr;
    }

    .emu-savestate-row-actions {
        justify-content: stretch;
    }

    .emu-savestate-row-actions .emu-btn {
        flex: 1;
    }
}

body.light-mode .emu-speed-card,
html[data-theme="light"] .emu-speed-card,
body.light-mode .emu-savestate-row,
html[data-theme="light"] .emu-savestate-row {
    background: rgba(17, 24, 39, 0.045);
    border-color: rgba(17, 24, 39, 0.10);
}

body.light-mode .emu-savestate-manager-dialog,
html[data-theme="light"] .emu-savestate-manager-dialog {
    background: rgba(255, 255, 255, 0.98);
    color: #111827;
}

body.light-mode .emu-savestate-manager-head h2,
html[data-theme="light"] .emu-savestate-manager-head h2,
body.light-mode .emu-savestate-row-title,
html[data-theme="light"] .emu-savestate-row-title {
    color: #111827;
}

body.light-mode .emu-savestate-manager-status,
html[data-theme="light"] .emu-savestate-manager-status,
body.light-mode .emu-savestate-row-meta,
html[data-theme="light"] .emu-savestate-row-meta {
    color: rgba(17, 24, 39, 0.64);
}

.emu-control-actions {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.emu-control-actions .emu-btn[aria-pressed="true"] {
    background: #f2ad22;
    color: #111827;
}

@media (max-width: 720px) {
    .emu-control-actions .emu-btn {
        flex: 1;
    }
}

.emu-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.emu-icon {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    font-size: 16px;
    line-height: 1;
}

.emu-control-icon {
    display: inline-block;
    min-width: 22px;
    margin-right: 6px;
    color: #f2ad22;
}

.emu-speed-actions .emu-btn[aria-pressed="true"],
.emu-savestate-actions .emu-btn[aria-pressed="true"],
.emu-control-actions .emu-btn[aria-pressed="true"] {
    background: #f2ad22;
    color: #111827;
}

.emu-speed-actions .emu-btn[aria-pressed="true"] .emu-icon,
.emu-savestate-actions .emu-btn[aria-pressed="true"] .emu-icon,
.emu-control-actions .emu-btn[aria-pressed="true"] .emu-icon {
    color: #111827;
}

/* =========================================================
   Layout-Fix: ROM-Bibliothek oben bündig zum Emulator
   ========================================================= */

.emu-shell {
    align-items: start !important;
}

.emu-main {
    align-self: start !important;
    margin-top: 0 !important;
    transform: none !important;
}

.emu-library {
    align-self: start !important;
    margin-top: 0 !important;
    transform: none !important;
}

/*
   Sticky darf bleiben, aber nur fürs spätere Scroll-Verhalten.
   Falls die Bibliothek direkt beim Laden versetzt klebt,
   ist top: 82px zu aggressiv.
*/
.emu-library {
    top: 0 !important;
}

/* =========================================================
   Layout-Fix: ROM-Bibliothek gleiche Höhe wie linke Emulator-Seite
   ========================================================= */

.emu-shell {
    align-items: stretch !important;
}

.emu-main {
    align-self: stretch !important;
    margin-top: 0 !important;
    transform: none !important;
}

.emu-library {
    align-self: stretch !important;
    margin-top: 0 !important;
    transform: none !important;

    height: auto !important;
    min-height: 100% !important;
    max-height: none !important;

    position: sticky !important;
    top: 64px !important;
}

.emu-game-list {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
}

/* =========================================================
   ROM-Bibliothek: Höhe auf linken Emulator-Inhalt begrenzen
   ========================================================= */

.emu-shell {
    align-items: start !important;
}

.emu-main {
    align-self: start !important;
    margin-top: 0 !important;
    transform: none !important;
}

.emu-library {
    align-self: start !important;
    margin-top: 0 !important;
    transform: none !important;

    height: var(--emu-main-height, auto) !important;
    max-height: var(--emu-main-height, none) !important;
    min-height: 0 !important;

    position: sticky !important;
    top: 64px !important;

    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.emu-game-list {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* =========================================================
   Layout-Fix: gleicher Außenabstand links und rechts
   ========================================================= */

.emu-page {
    width: 100% !important;
    max-width: 1700px !important;
    margin: 0 auto !important;
    padding: 18px 32px 48px 32px !important;
    box-sizing: border-box !important;
}

.emu-shell {
    width: 100% !important;
    box-sizing: border-box !important;
}

@media (max-width: 720px) {
    .emu-page {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
}

.emu-empty-state {
    margin-top: 8px !important;
    padding: 18px !important;
    border-radius: 16px !important;
    background: rgba(242, 173, 34, 0.10) !important;
    border: 1px solid rgba(242, 173, 34, 0.28) !important;
    color: rgba(255, 255, 255, 0.86) !important;
    line-height: 1.45 !important;
    font-weight: 700 !important;
}

/* =========================================================
   ROM-Bibliothek: Empty-/Berechtigungs-Hinweis direkt oben anzeigen
   ========================================================= */

.emu-library:has(.emu-empty-state:not([hidden])) .emu-game-list {
    flex: 0 0 auto !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
}

.emu-library:has(.emu-empty-state:not([hidden])) .emu-empty-state {
    margin-top: 8px !important;
    margin-bottom: 0 !important;
}

/* =========================================================
   Touch-Steuerung final: Fast/Slow weg, Start/Select unten
   Muss ganz am Ende stehen.
   ========================================================= */

.emu-touch-toggle {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.emu-touch-controls {
    position: fixed !important;
    left: 50% !important;
    bottom: 18px !important;
    z-index: 9000 !important;
    width: min(760px, calc(100vw - 24px)) !important;
    transform: translateX(-50%) !important;

    display: grid !important;
    grid-template-columns: 170px minmax(120px, 1fr) 190px !important;
    gap: 14px !important;
    align-items: end !important;

    padding: 14px !important;
    border-radius: 24px !important;
    background: rgba(20, 24, 32, 0.82) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 18px 70px rgba(0, 0, 0, 0.45) !important;
    backdrop-filter: blur(14px) !important;

    touch-action: none !important;
    user-select: none !important;
}

.emu-touch-controls[hidden] {
    display: none !important;
}

.emu-touch-middle {
    display: none !important;
}

.emu-touch-start-select {
    display: flex !important;
    align-items: end !important;
    justify-content: center !important;
    gap: 10px !important;
    padding-bottom: 2px !important;
}

.emu-touch-start-select .emu-touch-small {
    min-width: 76px !important;
    height: 42px !important;
    border-radius: 999px !important;
    font-size: 12px !important;
}

.emu-touch-shoulder-l,
.emu-touch-shoulder[data-emu-key="e"] {
    left: 8px !important;
    top: 0 !important;
}

.emu-touch-shoulder-r,
.emu-touch-shoulder[data-emu-key="r"] {
    right: 8px !important;
    top: 0 !important;
}

@media (max-width: 900px),
(pointer: coarse) {
    .emu-mobile-controls-bar {
        display: flex !important;
        justify-content: center !important;
    }
}

@media (max-width: 620px) {
    .emu-touch-controls {
        grid-template-columns: 136px 1fr 150px !important;
        gap: 8px !important;
        padding: 10px !important;
        bottom: 10px !important;
    }

    .emu-touch-start-select .emu-touch-small {
        min-width: 62px !important;
        height: 36px !important;
        font-size: 11px !important;
    }
}

/* =========================================================
   Lightmode-Fix: Emulator-Seite lesbar machen
   Muss ganz am Ende stehen.
   ========================================================= */

body.light-mode .emu-page,
html[data-theme="light"] .emu-page {
    color: #111827 !important;
}

body.light-mode .emu-panel,
html[data-theme="light"] .emu-panel,
body.light-mode .emu-main,
html[data-theme="light"] .emu-main,
body.light-mode .emu-library,
html[data-theme="light"] .emu-library {
    background: rgba(255, 255, 255, 0.92) !important;
    border-color: rgba(17, 24, 39, 0.14) !important;
    color: #111827 !important;
}

body.light-mode .emu-panel h1,
html[data-theme="light"] .emu-panel h1,
body.light-mode .emu-panel h2,
html[data-theme="light"] .emu-panel h2 {
    color: #111827 !important;
}

body.light-mode .emu-kicker,
html[data-theme="light"] .emu-kicker {
    color: #b77900 !important;
}

body.light-mode .emu-player-box,
html[data-theme="light"] .emu-player-box {
    background: #05070b !important;
    border-color: rgba(17, 24, 39, 0.18) !important;
}

body.light-mode .emu-placeholder,
html[data-theme="light"] .emu-placeholder {
    color: rgba(255, 255, 255, 0.78) !important;
}

body.light-mode .emu-placeholder strong,
html[data-theme="light"] .emu-placeholder strong {
    color: #ffffff !important;
}

body.light-mode .emu-savestate-card,
html[data-theme="light"] .emu-savestate-card,
body.light-mode .emu-controls-card,
html[data-theme="light"] .emu-controls-card,
body.light-mode .emu-selected-card,
html[data-theme="light"] .emu-selected-card,
body.light-mode .emu-local-card,
html[data-theme="light"] .emu-local-card {
    background: rgba(17, 24, 39, 0.055) !important;
    border-color: rgba(17, 24, 39, 0.14) !important;
    color: #111827 !important;
}

body.light-mode .emu-savestate-status,
html[data-theme="light"] .emu-savestate-status {
    color: #374151 !important;
}

body.light-mode .emu-savestate-hint,
html[data-theme="light"] .emu-savestate-hint {
    color: #4b5563 !important;
}

body.light-mode .emu-controls-grid div,
html[data-theme="light"] .emu-controls-grid div {
    background: rgba(17, 24, 39, 0.075) !important;
    border-color: rgba(17, 24, 39, 0.12) !important;
}

body.light-mode .emu-controls-grid strong,
html[data-theme="light"] .emu-controls-grid strong {
    color: #111827 !important;
}

body.light-mode .emu-controls-grid span,
html[data-theme="light"] .emu-controls-grid span {
    color: #4b5563 !important;
}

body.light-mode .emu-btn-primary,
html[data-theme="light"] .emu-btn-primary {
    background: #f2ad22 !important;
    color: #111827 !important;
}

body.light-mode .emu-btn-secondary,
html[data-theme="light"] .emu-btn-secondary {
    background: rgba(17, 24, 39, 0.11) !important;
    color: #111827 !important;
    border-color: rgba(17, 24, 39, 0.14) !important;
}

body.light-mode .emu-btn-secondary:hover:not(:disabled),
html[data-theme="light"] .emu-btn-secondary:hover:not(:disabled) {
    background: rgba(17, 24, 39, 0.17) !important;
}

body.light-mode .emu-btn:disabled,
html[data-theme="light"] .emu-btn:disabled {
    opacity: 0.58 !important;
    color: rgba(17, 24, 39, 0.72) !important;
}

body.light-mode .emu-btn-secondary:disabled,
html[data-theme="light"] .emu-btn-secondary:disabled {
    background: rgba(17, 24, 39, 0.08) !important;
    color: rgba(17, 24, 39, 0.62) !important;
    border-color: rgba(17, 24, 39, 0.10) !important;
}

body.light-mode .emu-icon,
html[data-theme="light"] .emu-icon {
    color: inherit !important;
}

body.light-mode .emu-search input,
html[data-theme="light"] .emu-search input {
    background: rgba(255, 255, 255, 0.78) !important;
    color: #111827 !important;
    border-color: rgba(17, 24, 39, 0.18) !important;
}

body.light-mode .emu-search input::placeholder,
html[data-theme="light"] .emu-search input::placeholder {
    color: rgba(17, 24, 39, 0.58) !important;
}

body.light-mode .emu-search button,
html[data-theme="light"] .emu-search button {
    background: rgba(17, 24, 39, 0.10) !important;
    color: #111827 !important;
}

body.light-mode .emu-count,
html[data-theme="light"] .emu-count {
    background: rgba(242, 173, 34, 0.20) !important;
    color: #9a6500 !important;
}

body.light-mode .emu-game-card,
html[data-theme="light"] .emu-game-card {
    background: rgba(17, 24, 39, 0.16) !important;
    border-color: rgba(17, 24, 39, 0.16) !important;
    color: #111827 !important;
}

body.light-mode .emu-game-card:hover,
html[data-theme="light"] .emu-game-card:hover {
    background: rgba(242, 173, 34, 0.20) !important;
    border-color: rgba(242, 173, 34, 0.85) !important;
}

body.light-mode .emu-game-card.is-active,
html[data-theme="light"] .emu-game-card.is-active {
    background: rgba(242, 173, 34, 0.28) !important;
    border-color: #f2ad22 !important;
}

body.light-mode .emu-game-thumb-wrap,
html[data-theme="light"] .emu-game-thumb-wrap {
    background: rgba(17, 24, 39, 0.12) !important;
}

body.light-mode .emu-game-thumb-placeholder,
html[data-theme="light"] .emu-game-thumb-placeholder {
    background:
        linear-gradient(135deg, rgba(242, 173, 34, 0.24), rgba(242, 173, 34, 0.10)),
        rgba(17, 24, 39, 0.10) !important;
    color: #8a5a00 !important;
}

body.light-mode .emu-empty-state,
html[data-theme="light"] .emu-empty-state {
    background: rgba(242, 173, 34, 0.16) !important;
    border-color: rgba(180, 117, 0, 0.35) !important;
    color: #3f2b00 !important;
}

body.light-mode .emu-message,
html[data-theme="light"] .emu-message {
    background: rgba(17, 24, 39, 0.08) !important;
    color: #111827 !important;
    border: 1px solid rgba(17, 24, 39, 0.12) !important;
}

body.light-mode .emu-message.is-error,
html[data-theme="light"] .emu-message.is-error {
    background: rgba(220, 38, 38, 0.12) !important;
    color: #7f1d1d !important;
    border-color: rgba(220, 38, 38, 0.30) !important;
}

body.light-mode .emu-savestate-manager-dialog,
html[data-theme="light"] .emu-savestate-manager-dialog {
    background: rgba(255, 255, 255, 0.98) !important;
    color: #111827 !important;
    border-color: rgba(180, 117, 0, 0.35) !important;
}

body.light-mode .emu-savestate-manager-close,
html[data-theme="light"] .emu-savestate-manager-close {
    background: rgba(17, 24, 39, 0.10) !important;
    color: #111827 !important;
}

body.light-mode .emu-savestate-row,
html[data-theme="light"] .emu-savestate-row {
    background: rgba(17, 24, 39, 0.065) !important;
    border-color: rgba(17, 24, 39, 0.13) !important;
}

body.light-mode .emu-savestate-row-title,
html[data-theme="light"] .emu-savestate-row-title {
    color: #111827 !important;
}

body.light-mode .emu-savestate-row-meta,
html[data-theme="light"] .emu-savestate-row-meta,
body.light-mode .emu-savestate-manager-status,
html[data-theme="light"] .emu-savestate-manager-status {
    color: #4b5563 !important;
}

body.light-mode .emu-touch-controls,
html[data-theme="light"] .emu-touch-controls {
    background: rgba(255, 255, 255, 0.88) !important;
    border-color: rgba(17, 24, 39, 0.14) !important;
}

body.light-mode .emu-touch-btn,
body.light-mode .emu-touch-action,
body.light-mode .emu-touch-small,
body.light-mode .emu-touch-shoulder,
html[data-theme="light"] .emu-touch-btn,
html[data-theme="light"] .emu-touch-action,
html[data-theme="light"] .emu-touch-small,
html[data-theme="light"] .emu-touch-shoulder {
    background: rgba(17, 24, 39, 0.14) !important;
    border-color: rgba(17, 24, 39, 0.20) !important;
    color: #111827 !important;
}

body.light-mode .emu-touch-btn:active,
body.light-mode .emu-touch-btn.is-pressed,
body.light-mode .emu-touch-action:active,
body.light-mode .emu-touch-action.is-pressed,
body.light-mode .emu-touch-small:active,
body.light-mode .emu-touch-small.is-pressed,
body.light-mode .emu-touch-shoulder:active,
body.light-mode .emu-touch-shoulder.is-pressed,
html[data-theme="light"] .emu-touch-btn:active,
html[data-theme="light"] .emu-touch-btn.is-pressed,
html[data-theme="light"] .emu-touch-action:active,
html[data-theme="light"] .emu-touch-action.is-pressed,
html[data-theme="light"] .emu-touch-small:active,
html[data-theme="light"] .emu-touch-small.is-pressed,
html[data-theme="light"] .emu-touch-shoulder:active,
html[data-theme="light"] .emu-touch-shoulder.is-pressed {
    background: #f2ad22 !important;
    color: #111827 !important;
}