@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

:root {
    --bg-color: #e5d9f2;
    --gb-shell: #68217a;
    --gb-bezel: #222;
    --gb-screen-bg: #333;
    --gb-accent: #222;
    --pixel-border: 4px solid #000;
    --font-pixel: 'VT323', monospace;
}

body.gb-theme {
    user-select: none;
    -webkit-user-select: none;
    background-color: var(--bg-color);
    background-image:
        linear-gradient(rgba(211, 191, 166, 0.8) 1px, transparent 1px),
        linear-gradient(90deg, rgba(211, 191, 166, 0.8) 1px, transparent 1px),
        linear-gradient(rgba(211, 191, 166, 0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(211, 191, 166, 0.3) 1px, transparent 1px);
    background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
    font-family: var(--font-pixel);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow-x: hidden;
    margin: 0;
    padding: 40px 0;
    box-sizing: border-box;
    -webkit-font-smoothing: none;
}



.rom-loader {
    margin-bottom: -15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 0;
}

.rom-loader input[type="file"] {
    display: none;
}

.custom-file-upload {
    background-color: #999;
    color: #fff;
    border: var(--pixel-border);
    border-bottom: none;
    border-radius: 15px 15px 0 0;
    padding: 20px 30px 30px 30px;
    font-size: 1.5rem;
    cursor: pointer;
    text-align: center;
    text-transform: uppercase;
    width: 250px;
    box-shadow:
        inset 0px 5px 10px rgba(255, 255, 255, 0.2),
        15px 15px 0px #000;
    transition: background-color 0.1s;
}

.custom-file-upload:hover {
    background-color: #aaa;
}

.custom-file-upload:active {
    background-color: #777;
}

.gameboy {
    background-color: var(--gb-shell);
    width: 510px;
    height: 870px;
    border-radius: 10px 10px 80px 10px;
    border: var(--pixel-border);
    box-shadow:
        15px 15px 0px #000,
        inset -20px -20px 0px rgba(0, 0, 0, 0.15),
        inset 10px 10px 20px rgba(255, 255, 255, 0.3);
    /* glossy edge reflection */
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 10;
}

.gameboy::before {
    content: "";
    position: absolute;
    top: -4px;
    left: 20px;
    right: 20px;
    height: 20px;
    border-bottom: var(--pixel-border);
    border-left: var(--pixel-border);
    border-right: var(--pixel-border);
    background-color: var(--gb-shell);
}

.bezel {
    background-color: var(--gb-bezel);
    width: 440px;
    height: 430px;
    margin-top: 55px;
    border-radius: 10px 10px 50px 10px;
    border: var(--pixel-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.battery-light {
    position: absolute;
    left: 4px;
    top: 145px;
    width: 8px;
    height: 8px;
    background-color: #ff3b30;
    border-radius: 50%;
    box-shadow: 0 0 4px #ff3b30;
}

.battery-waves {
    position: absolute;
    left: 18px;
    top: 141px;
    color: #a0a0a0;
    font-size: 0.9rem;
    font-weight: bold;
}

.battery-text {
    position: absolute;
    left: 3px;
    top: 168px;
    color: #a0a0a0;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

.screen-glass {
    margin-top: 24px;
    border: var(--pixel-border);
    background-color: var(--gb-screen-bg);
}

#canvas {
    display: block;
    image-rendering: pixelated;
    background-color: var(--gb-screen-bg);
    width: 360px;
    height: 324px;
}

.gb-logo {
    position: absolute;
    bottom: 18px;
    font-size: 1.8rem;
    text-align: center;
    width: 100%;
    letter-spacing: 2px;
}

.gb-font {
    font-family: 'Arial Black', Impact, sans-serif;
    font-style: italic;
    font-weight: 900;
    color: #e0e0e0;
    /* Light silver/grey */
}

.gbc-text {
    font-family: sans-serif;
    font-style: italic;
    font-weight: 800;
    font-size: 1.8rem;
    letter-spacing: 0;
    margin-left: 2px;
}

.c-c {
    color: #e80033;
}

.c-o1 {
    color: #f89d00;
}

.c-l {
    color: #92c900;
}

.c-o2 {
    color: #008db6;
}

.c-r {
    color: #9e59d9;
}

.controls-area {
    position: relative;
    width: 100%;
    height: 250px;
    margin-top: 20px;
}

.dpad {
    position: absolute;
    left: 40px;
    top: 30px;
    width: 120px;
    height: 120px;
    filter: drop-shadow(4px 4px 0px #000);
}

.dpad-cross {
    position: absolute;
    background-color: var(--gb-accent);
}

.dpad-v {
    left: 40px;
    top: 0;
    width: 40px;
    height: 120px;
}

.dpad-h {
    left: 0;
    top: 40px;
    width: 120px;
    height: 40px;
}

.dpad-arr {
    position: absolute;
    color: #fff;
    font-size: 1.5rem;
    pointer-events: none;
    line-height: 1;
}

.arr-up {
    top: 7px;
    left: 52px;
}

.arr-down {
    bottom: 7px;
    left: 52px;
}

.arr-left {
    top: 47px;
    left: 10px;
}

.arr-right {
    top: 47px;
    right: 10px;
}

.ab-buttons {
    position: absolute;
    right: 40px;
    top: 70px;
    width: 130px;
    height: 60px;
    transform: rotate(-10deg);
}

.action-btn {
    position: absolute;
    width: 50px;
    height: 50px;
    background-color: var(--gb-accent);
    border: var(--pixel-border);
    border-radius: 50%;
    box-shadow: 4px 4px 0px #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn span {
    color: #e5d9f2;
    font-size: 2rem;
    font-weight: bold;
    transform: rotate(10deg);
}

.btn-b {
    left: 0;
    top: 20px;
}

.btn-a {
    right: 0;
    top: 0px;
}

.system-buttons {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 30px;
}

.sys-btn-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.sys-btn {
    width: 60px;
    height: 16px;
    background-color: var(--gb-accent);
    border-radius: 20px;
    box-shadow: 4px 4px 0px #000;
}

.sys-label {
    margin-top: 5px;
    color: #e5d9f2;
    font-size: 1.5rem;
    font-weight: bold;
}

.speaker {
    position: absolute;
    bottom: -20px;
    right: 40px;
    width: 75px;
    height: 75px;
    background-image: radial-gradient(circle, #000 3px, transparent 4px);
    background-size: 15px 15px;
    background-position: center;
    border-radius: 50%;
}

.speaker .grill {
    display: none;
}

.layout-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 30px;
    width: 100%;
    max-width: 1400px;
}

.center-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: scale(0.95);
}

.side-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 380px;
    gap: 20px;
}

.right-panel {
    margin-top: 50px;
}

.emulator-note {
    background-color: var(--gb-shell);
    color: #e5d9f2;
    border: var(--pixel-border);
    box-shadow: 10px 10px 0px #000;
    padding: 20px;
    border-radius: 5px 30px 5px 30px;
    font-size: 1.1rem;
    line-height: 1.4;
    width: 380px;
    box-sizing: border-box;
}

.emulator-note a {
    color: #92c900;
    text-decoration: none;
}

.emulator-note a:hover {
    text-decoration: underline;
}

.credits-panel {
    background-color: #1a241a;
    color: #d4e5c3;
    border-radius: 30px 5px 30px 5px;
    padding: 18px 20px;
}

.credits-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    border-bottom: 2px solid rgba(146, 201, 0, 0.25);
    padding-bottom: 6px;
}

.emulator-note.credits-panel h2,
.credits-panel h2 {
    color: #92c900;
    font-size: 1.8rem;
    margin: 0;
    letter-spacing: 1px;
    border-bottom: none;
    padding-bottom: 0;
}

.credits-badge {
    font-size: 0.85rem;
    color: #0f240f;
    background: #92c900;
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: bold;
    letter-spacing: 0.5px;
    box-shadow: 1px 1px 0px #000;
}

.credits-list {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.credits-list li {
    background: rgba(0, 0, 0, 0.35);
    padding: 7px 10px;
    border-radius: 6px;
    border: 1px solid rgba(146, 201, 0, 0.15);
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: background 0.15s, border-color 0.15s;
}

.credits-list li:hover {
    background: rgba(0, 0, 0, 0.55);
    border-color: rgba(146, 201, 0, 0.4);
}

.credit-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.credit-item a,
.credit-item .credit-title {
    color: #92c900;
    font-weight: bold;
    font-size: 1.15rem;
    text-decoration: none;
}

.credit-item a:hover {
    text-decoration: underline;
}

.credit-by {
    color: #8da47e;
    font-size: 0.95rem;
    white-space: nowrap;
}

.credit-desc {
    color: #b5c7a5;
    font-size: 0.95rem;
    line-height: 1.25;
}

.rom-library-panel {
    background-color: #2b2b2b;
    border-color: #000;
}

.emulator-note:not(.credits-panel) h2 {
    margin-top: 0;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid rgba(229, 217, 242, 0.25);
    font-size: 2.2rem;
    text-transform: uppercase;
}

.emulator-note p {
    margin-top: 10px;
}

.note-mw {
    color: #e5d9f2;
    /* Lavender */
}

.emulator-note ul {
    list-style-type: square;
    padding-left: 20px;
}

.emulator-note li {
    margin-bottom: 8px;
}

.return-btn {
    position: fixed;
    top: 50%;
    left: 20px;
    transform: translateY(-50%) rotate(180deg);
    z-index: 100;
    font-family: var(--font-pixel);
    background-color: #fff;
    color: #000;
    padding: 30px 10px;
    border: var(--pixel-border);
    text-decoration: none;
    font-size: 1.8rem;
    box-shadow: -6px -6px 0px #000; /* Flips to +6 +6 on screen when rotated 180 */
    transition: transform 0.1s, box-shadow 0.1s, background-color 0.2s;
    text-transform: uppercase;
    
    /* Text sideways (reads top-to-bottom natively, flipped to bottom-to-top by rotate) */
    writing-mode: vertical-rl;
}

.return-btn:hover {
    transform: translate(2px, calc(-50% + 2px)) rotate(180deg);
    box-shadow: -4px -4px 0px #000;
    background-color: #f0f0f0;
}

.return-btn:active {
    transform: translate(6px, calc(-50% + 6px)) rotate(180deg);
    box-shadow: 0px 0px 0px #000;
}

.divider {
    height: 4px;
    background: repeating-linear-gradient(90deg, #e5d9f2 0, #e5d9f2 4px, transparent 4px, transparent 8px);
    margin: 20px 0;
    width: 100%;
}

.rom-library {
    list-style: none !important;
    padding: 0 !important;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rom-library li {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.rom-btn {
    font-family: var(--font-pixel);
    background: #e5d9f2;
    color: #000;
    border: 2px solid #000;
    padding: 4px 10px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 2px 2px 0 #000;
    margin-right: 12px;
    transition: transform 0.1s, box-shadow 0.1s, background 0.2s;
}

.rom-btn:hover {
    background: #92c900;
}

.rom-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 0 0 0 #000;
}

.rom-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.rom-title {
    font-size: 1.3rem;
    font-weight: bold;
    color: #e5d9f2;
    white-space: nowrap;
}

.rom-author {
    font-size: 1rem;
    color: #a0a0a0;
}

.rom-author a {
    color: #92c900;
    text-decoration: none;
}

.rom-author a:hover {
    text-decoration: underline;
}

.rom-btn.active {
    background: #92c900;
    box-shadow: 0 0 0 #000;
    transform: translate(1px, 1px);
}

.rom-tag {
    display: inline-block;
    font-size: 0.75rem;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: bold;
    margin-left: 6px;
    vertical-align: middle;
    letter-spacing: 0.5px;
    line-height: 1.2;
    white-space: nowrap;
}

.rom-tag.dmg {
    background: #8bac0f;
    color: #0f380f;
    border: 1px solid #306230;
}

.rom-tag.gbc {
    background: #5a1e6b;
    color: #f3ebfa;
    border: 1px solid #9c44b3;
    font-weight: bold;
}

/* ─── RESPONSIVE ─────────────────────────────────────────────── */

@media (max-width: 1300px) {
    .layout-container {
        flex-direction: column;
        gap: 20px;
        padding: 20px 10px;
        align-items: center;
    }

    .return-btn {
        position: static;
        transform: none;
        writing-mode: horizontal-tb;
        padding: 8px 26px;
        font-size: 1.3rem;
        box-shadow: 4px 4px 0px #000;
        margin-bottom: 10px;
        align-self: center;
    }

    .return-btn:hover {
        transform: translate(2px, 2px);
        box-shadow: 2px 2px 0px #000;
    }

    .side-panel {
        width: 100%;
        max-width: 480px;
    }

    .right-panel {
        margin-top: 0;
    }

    .emulator-note {
        width: 100%;
        max-width: 480px;
    }
}

@media (max-width: 520px) {
    body.gb-theme {
        padding: 15px 0;
        overflow-x: hidden;
    }

    .layout-container {
        padding: 10px 5px;
        gap: 15px;
    }

    .center-panel {
        transform: scale(0.72);
        transform-origin: top center;
        margin-bottom: -230px;
    }

    .side-panel {
        width: 92vw;
        max-width: 360px;
    }

    .emulator-note {
        width: 100%;
        padding: 16px;
        font-size: 1rem;
    }

    .emulator-note h2 {
        font-size: 1.6rem;
    }

    .credits-panel h2 {
        font-size: 1.4rem;
    }
}

@media (max-width: 375px) {
    .center-panel {
        transform: scale(0.64);
        transform-origin: top center;
        margin-bottom: -300px;
    }
}