:root {
    --header-bg: #F86888;
    --header-tab: #D8D8A8;
    --bg-light: #88A060;
    --bg-dark: #789050;
    --left-panel-bg: rgba(255, 255, 255, 0.2);
    --box-outer: #E8D888;
    --box-border: #88A8C8;
    --box-inner: #F8F8A8;
    --list-bg-normal: #C0C098;
    --list-bg-selected: #F8F8C8;
    --text-blue: #405078;
    --text-white: #FFFFFF;
    --text-shadow: 2px 2px 0 #000;
    --footer-bg: #D0B050;
    --pokeball-red: #E83030;
    --pokeball-white: #F8F8F8;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Press Start 2P', monospace;
    background-color: #000;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-blue);
    font-size: 12px;
}

#app {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: repeating-linear-gradient(0deg, var(--bg-light), var(--bg-light) 4px, var(--bg-dark) 4px, var(--bg-dark) 8px);
    position: relative;
}

/* HEADER */
header {
    height: 12vh;
    min-height: 60px;
    background: var(--header-bg);
    display: flex;
    align-items: center;
    padding: 0 4vw;
    border-bottom: 6px solid #484848;
    position: relative;
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: clamp(20px, 4vh, 40px);
    color: var(--text-white);
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
    margin: 0 auto 0 20px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.header-tab {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 15vw;
    background-color: var(--header-tab);
    border-left: 6px solid #484848;
}

.pokeball-icon-header {
    width: clamp(30px, 5vh, 50px);
    height: clamp(30px, 5vh, 50px);
    background: linear-gradient(to bottom, var(--pokeball-red) 45%, #000 45%, #000 55%, var(--pokeball-white) 55%);
    border: 4px solid #000;
    border-radius: 50%;
    display: inline-block;
    position: relative;
}

.pokeball-icon-header::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 25%;
    height: 25%;
    background: var(--pokeball-white);
    border: 3px solid #000;
    border-radius: 50%;
}

/* MIDDLE LAYOUT */
main {
    flex: 1;
    display: grid;
    grid-template-columns: 45% 55%;
    overflow: hidden;
    padding: 2vh;
    gap: 2vh;
    min-height: 0;
}

/* LEFT PANEL */
#left-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    min-height: 0;
}

.image-container-outer {
    background-color: var(--box-outer);
    padding: 3vh;
    border-radius: 20px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.4), 4px 4px 0 rgba(0, 0, 0, 0.2);
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 65vh;
    max-height: 65vh;
    position: relative;
}

.dot {
    position: absolute;
    width: clamp(6px, 1.2vh, 12px);
    height: clamp(6px, 1.2vh, 12px);
    background: #A09050;
    border-radius: 2px;
}

.dot.top-left {
    top: 1.5vh;
    left: 1.5vh;
}

.dot.top-right {
    top: 1.5vh;
    right: 1.5vh;
}

.dot.bottom-left {
    bottom: 1.5vh;
    left: 1.5vh;
}

.dot.bottom-right {
    bottom: 1.5vh;
    right: 1.5vh;
}

.image-container-inner {
    background-color: var(--text-white);
    border: 8px solid var(--box-border);
    border-radius: 12px;
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.image-container-inner::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 4px solid var(--box-inner);
    border-radius: 4px;
    pointer-events: none;
    z-index: 2;
}

.image-container-inner img {
    width: 90%;
    height: 90%;
    object-fit: contain;
    image-rendering: auto;
    z-index: 1;
}

.image-bg-lines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(0deg, var(--text-white), var(--text-white) 15px, #E8F0F8 15px, #E8F0F8 20px);
    z-index: 0;
}

/* RIGHT PANEL (LIST) */
#right-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#list-container {
    flex: 1;
    min-height: 0;
    overflow-y: scroll;
    padding-right: 20px;
    padding-left: 10px;
    display: flex;
    flex-direction: column;
    gap: 1.5vh;
    scroll-behavior: smooth;
}

#list-container::-webkit-scrollbar {
    width: 32px;
    background: #507878;
    border-left: 2px solid #305050;
}

#list-container::-webkit-scrollbar-thumb {
    background: #A0D8D8;
    border: 4px solid #E8F8F8;
    box-shadow: inset 3px 3px 0 #408888, inset -3px -3px 0 #408888;
}

#list-container::-webkit-scrollbar-button:single-button {
    background-color: #507878;
    display: block;
    height: 32px;
}

#list-container::-webkit-scrollbar-button:single-button:vertical:decrement {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="white"><path d="M10 4l6 10H4z"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
}

#list-container::-webkit-scrollbar-button:single-button:vertical:increment {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="white"><path d="M10 16L4 6h12z"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
}

.list-item {
    background-color: var(--list-bg-normal);
    border: 4px solid transparent;
    border-radius: 40px 15px 15px 40px;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
    min-height: 10vh;
    width: 95%;
    /* Limit width to avoid clipping in right panel */
    position: relative;
    transition: all 0.1s;
}

.list-item:not(.selected) {
    opacity: 0.85;
}

.list-item:hover,
.list-item.selected {
    background-color: var(--list-bg-selected);
    border-color: #FFF;
    border-width: 4px;
    border-style: solid;
    transform: translateX(-15px);
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.pokeball-list-icon {
    width: clamp(24px, 4vh, 40px);
    height: clamp(24px, 4vh, 40px);
    background: linear-gradient(to bottom, var(--pokeball-red) 45%, #000 45%, #000 55%, var(--pokeball-white) 55%);
    border: 3px solid #000;
    border-radius: 50%;
    margin-right: 1.5vw;
    position: relative;
    opacity: 0.6;
}

.pokeball-list-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30%;
    height: 30%;
    background: var(--pokeball-white);
    border: 2px solid #000;
    border-radius: 50%;
}

.list-item.selected .pokeball-list-icon {
    opacity: 1;
}

.item-number {
    font-size: clamp(14px, 2.5vh, 28px);
    margin-right: 1vw;
    color: #607090;
}

.item-name {
    font-size: clamp(14px, 2.5vh, 28px);
    text-transform: uppercase;
}

.selected-indicator {
    display: none;
    position: absolute;
    right: -30px;
    border-top: 15px solid transparent;
    border-bottom: 15px solid transparent;
    border-left: 20px solid var(--pokeball-red);
}

.list-item.selected .selected-indicator {
    display: block;
}

/* FOOTER */
footer {
    height: 12vh;
    min-height: 80px;
    background-color: var(--footer-bg);
    border-top: 6px solid #484848;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 40px;
    box-shadow: inset 0 4px 0 rgba(0, 0, 0, 0.1);
}

.counter-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5vh;
}

.counter-label {
    font-size: clamp(12px, 2vh, 20px);
    text-transform: uppercase;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.5);
}

.counter-value {
    font-size: clamp(16px, 3.5vh, 32px);
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .8);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    z-index: 100;
}

.modal.activo {
    display: flex;
}

.modal-contenido {
    background: #E8D888;
    /* Match yellow backgroud screenshot */
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
    border: 8px solid #98B8D8;
    /* Thick light blue border */
    border-radius: 8px;
    box-shadow: 0 0 0 4px #000, 0 0 30px rgba(0, 0, 0, 0.5);
    /* Black outline */
}

/* Scrollbar for modal */
.modal-contenido::-webkit-scrollbar {
    width: 20px;
    background: #E8D888;
}

.modal-contenido::-webkit-scrollbar-thumb {
    background: #D8C878;
    border: 4px solid #E8D888;
    border-radius: 8px;
}

#details-name {
    font-size: clamp(16px, 3vh, 24px);
    margin-bottom: 20px;
    text-transform: uppercase;
    color: var(--text-blue);
}

#details-content {
    font-size: clamp(12px, 2vh, 18px);
    line-height: 1.8;
    margin-bottom: 20px;
    color: var(--text-blue);
}

#details-content p {
    margin-bottom: 12px;
}

#details-content strong {
    color: var(--text-blue);
}

#details-content .seccion {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 4px dashed #98B8D8;
}

#details-content .seccion h3 {
    font-size: clamp(14px, 2.5vh, 20px);
    margin-bottom: 15px;
    text-transform: uppercase;
}

#details-content .modal-slider {
    position: relative;
    max-width: 100%;
    margin: 20px 0;
    background: #FFF;
    border: 6px solid var(--box-border);
    border-radius: 12px;
    padding: 10px;
    text-align: center;
}

#details-content .modal-slider img {
    width: 100%;
    height: 40vh;
    object-fit: contain;
    border-radius: 4px;
    image-rendering: auto;
    display: block;
    margin: 0 auto;
}

#details-content .modal-slider button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #FFF;
    border: 4px solid #000;
    padding: 10px 15px;
    cursor: pointer;
    font-family: inherit;
    font-size: 16px;
}

#details-content .modal-slider button:hover {
    background: var(--pokeball-red);
}

#details-content .modal-slider .prev {
    left: 10px;
}

#details-content .modal-slider .next {
    right: 10px;
}

/* Marcas in details - much larger */
#details-marcas .marca-icon {
    width: clamp(40px, 8vh, 80px);
    height: clamp(40px, 8vh, 80px);
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    border: 4px solid var(--text-blue);
    padding: 4px;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1);
}

.btn-retro {
    font-family: 'Press Start 2P', monospace;
    background: var(--header-bg);
    color: #FFF;
    border: 4px solid #000;
    padding: 15px;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 16px;
    margin-top: 10px;
    box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.3);
}

.btn-retro:hover {
    background: #E83030;
    transform: scale(1.02);
}

.cat-section {
    margin-top: 15px;
    margin-bottom: 5px;
}

.cat-filter-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

.cat-filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.cat-filter-label {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    color: var(--text-blue);
    min-width: 60px;
}

.cat-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    padding: 6px 10px;
    border: 3px solid var(--box-border);
    border-radius: 6px;
    background: var(--list-bg-normal);
    color: var(--text-blue);
    cursor: pointer;
    transition: all 0.15s;
    width: auto;
}

.cat-btn.cat-btn-img {
    padding: 0;
    line-height: 0;
    overflow: hidden;
    border-radius: 6px;
}

.cat-btn.cat-btn-img img {
    width: 100%;
    height: 100%;
    min-width: 80px;
    min-height: 80px;
    max-width: 120px;
    max-height: 120px;
    object-fit: cover;
    display: block;
}

.cat-btn:hover {
    background: var(--list-bg-selected);
    border-color: var(--text-blue);
}

.cat-btn.active {
    background: var(--header-bg);
    color: #FFF;
    border-color: #000;
    box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.2);
}

.cat-viewer {
    text-align: center;
    margin-top: 10px;
}

.cat-viewer-main {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #FFF;
    border: 6px solid var(--box-border);
    border-radius: 12px;
    padding: 10px;
    height: 40vh;
    max-width: 100%;
}

.cat-viewer-main img {
    width: 100%;
    height: 40vh;
    object-fit: contain;
    border-radius: 4px;
    image-rendering: auto;
    display: block;
}

.cat-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #FFF;
    border: 4px solid #000;
    padding: 10px 15px;
    cursor: pointer;
    font-family: inherit;
    font-size: 16px;
    z-index: 2;
    width: auto;
}

.cat-nav-btn:hover {
    background: var(--pokeball-red);
}

.cat-nav-prev {
    left: 10px;
}

.cat-nav-next {
    right: 10px;
}

.cat-viewer-label {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: var(--text-blue);
    margin-top: 8px;
}

.cat-viewer-counter {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    color: #607090;
    margin-top: 4px;
}

/* Family filter bar */
#family-filter-bar {
    margin-bottom: 8px;
    flex-shrink: 0;
}

.family-filter-toggle {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    padding: 6px 12px;
    background: var(--footer-bg);
    color: var(--text-blue);
    border: 3px solid #484848;
    border-radius: 6px;
    cursor: pointer;
    width: auto;
}

.family-filter-toggle:hover {
    background: #E0C060;
}

.family-filter-panel {
    background: rgba(255, 255, 255, 0.9);
    border: 3px solid var(--box-border);
    border-radius: 8px;
    padding: 8px;
    margin-top: 6px;
    max-height: 25vh;
    overflow-y: auto;
}

.family-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}

.family-check-item {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    color: var(--text-blue);
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.family-check-item input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

/* ===== RESPONSIVE / MOBILE ===== */
@media (max-width: 640px) {

    /* Body: allow natural scrolling fallback */
    body {
        overflow: auto;
        height: auto;
        min-height: 100dvh;
    }

    #app {
        height: auto;
        min-height: 100dvh;
    }

    /* Header */
    header {
        height: auto;
        min-height: 50px;
        padding: 8px 3vw;
        flex-wrap: wrap;
    }

    header h1 {
        font-size: clamp(12px, 5vw, 20px);
        margin: 0 auto 0 8px;
        letter-spacing: 1px;
    }

    .header-tab {
        display: none;
    }

    .pokeball-icon-header {
        width: clamp(22px, 6vw, 36px);
        height: clamp(22px, 6vw, 36px);
    }

    /* Main layout: single column, left panel hidden */
    main {
        grid-template-columns: 1fr;
        padding: 1vh 2vw;
        gap: 1vh;
        overflow: visible;
        flex: 1;
    }

    #left-panel {
        display: none;
    }

    #right-panel {
        min-height: 0;
        flex: 1;
    }

    /* List container: scrollable within remaining space */
    #list-container {
        padding-right: 6px;
        padding-left: 6px;
        flex: 1;
        min-height: 200px;
        max-height: calc(100dvh - 100px - 80px - 20px);
        overflow-y: auto;
    }

    /* Thin scrollbar on mobile */
    #list-container::-webkit-scrollbar {
        width: 6px;
    }

    #list-container::-webkit-scrollbar-button:single-button {
        height: 0;
        display: none;
    }

    /* List items: full width, no translateX animation */
    .list-item {
        width: 100%;
        min-height: 8vw;
        padding: 10px 12px;
        border-radius: 30px 12px 12px 30px;
    }

    .list-item:hover,
    .list-item.selected {
        transform: none;
    }

    .selected-indicator {
        display: none !important;
    }

    .item-number {
        font-size: clamp(11px, 3vw, 16px);
        margin-right: 2vw;
    }

    .item-name {
        font-size: clamp(11px, 3vw, 16px);
    }

    .pokeball-list-icon {
        width: clamp(18px, 5vw, 30px);
        height: clamp(18px, 5vw, 30px);
        margin-right: 2vw;
    }

    /* Footer */
    footer {
        height: auto;
        min-height: 60px;
        padding: 8px 15px;
    }

    .counter-label {
        font-size: clamp(8px, 2.5vw, 12px);
    }

    .counter-value {
        font-size: clamp(12px, 4vw, 22px);
    }

    /* Modals: full-screen sheet on mobile */
    .modal {
        padding: 0;
        align-items: flex-end;
    }

    .modal-contenido {
        max-height: 92dvh;
        border-radius: 16px 16px 0 0;
        padding: 20px 16px;
        border-width: 6px 6px 0 6px;
    }

    #details-name {
        font-size: clamp(12px, 4vw, 18px);
    }

    #details-content {
        font-size: clamp(10px, 3vw, 14px);
    }

    .btn-retro {
        font-size: 12px;
        padding: 12px;
    }

    #details-content .modal-slider img {
        height: 28vh;
    }

    .cat-viewer-main {
        height: 28vh;
    }

    .cat-viewer-main img {
        height: 28vh;
    }

    /* Family filter */
    .family-filter-toggle {
        font-size: 8px;
        padding: 5px 10px;
        width: 100%;
    }

    .family-filter-panel {
        max-height: 20vh;
    }

    .family-check-item {
        font-size: 7px;
    }

    /* Category filter buttons */
    .cat-filter-label {
        font-size: 8px;
        min-width: 45px;
    }

    .cat-btn {
        font-size: 8px;
        padding: 5px 8px;
    }
}

