* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Arial', sans-serif;
    text-wrap: pretty;
}

body {
    background-color: #331f50;
    color: #e0d7f7;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.main-container {
    background-color: #4a2c72;
    width: 100%;
    max-width: 1000px;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

header {
    text-align: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e0d7f7;
}

header img {
    max-width: 160px;
    height: auto;
    margin-bottom: 1rem;
    border-radius: 50%;
    border: none;
}

header h2 {
    color: #e0d7f7;
    font-size: 3rem;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    padding-bottom: 25px;
}

header p {
    color: #e0d7f7;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    line-height: 2;
    font-size: 1.2rem;
    font-weight: 400;
    margin: 0.5rem 0;
    background: rgba(224, 215, 247, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 5px;
    text-align: center;
}

.filter-container {
    margin-bottom: 20px;
    background-color: #4a2c72;
    padding: 0.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.filter-row {
    display: block;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.filter-row h4, #sort-buttons h4 {
    padding: 1.3rem 0;
    background-color: transparent;
    text-align: left;
    margin-bottom: 0;
    margin: 0;
    font-size: 0.9rem;
    color: #e0d7f7;
    white-space: nowrap;
    font-weight: 600;
}

.filter-row.sort-row {
    margin-top: 0.25rem;
}

#sort-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#sort-buttons button {
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;      /* same font size as other chips */
  border-radius: 999px;
  border: 1px solid #ccc;
  cursor: pointer;
}

#type-buttons, #meme-buttons, #keywords-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

.filter-container button {
    margin: 0;
    padding: 8px 12px;
    border: 1px solid #e0d7f7;
    background-color: transparent;
    color: #e0d7f7;
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.filter-container button.active, #sort-buttons button.active {
    background-color: rgba(131, 185, 204, 0.2);
    color: #e0d7f7;
    border-color: #83b9cc;
    box-shadow: 0 4px 8px rgba(131, 185, 204, 0.3);
}

.filter-container button:hover {
    background-color: rgba(224, 215, 247, 0.2);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.content-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 1.5rem 0;
    align-items: center;
    background-color: #4a2c72;
}

.content-section.hidden {
    display: none;
}

.content-section p {
    margin: 0.5rem 0;
    font-size: 1rem;
    line-height: 1.6;
    color: #e0d7f7;
}

.content-section p strong {
    font-weight: 600;
}

.info-box {
    background-color: #5e3b83;
    padding: 1rem;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    max-width: 90%;
    text-align: left;
    color: #e0d7f7;
    cursor: pointer;
}

.info-box .title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-direction: row;
}

.info-box h3 {
    font-size: 1.5rem;
    color: #e0d7f7;
    margin: 0;
}

.arrow {
    font-size: 1.5rem;
    color: #e0d7f7;
    margin-left: auto;
    margin-right: 1rem;
}

.info-box p.image-links {
    display: flex;
    align-items: center;
    margin: 0;
    position: relative;
}

.info-box p.image-links a img {
    width: 32px;
    height: 32px;
    margin: 0 8px;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    object-fit: cover;
    position: relative;
    z-index: 1;
}

.info-box p.image-links a {
    position: relative;
}

a {
    color: #e0d7f7;
}

.info-box p.image-links a::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, rgba(66, 142, 168, 0.3), rgba(131, 185, 204, 0.3));
    border-radius: 50%;
    z-index: 0;
}

.info-box p.image-links img {
    width: 32px;
    height: 32px;
    margin: 0 8px;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    object-fit: cover;
    position: relative;
    z-index: 1;
}

.info-box p.image-links:not(.title-row p) {
    position: relative;
}

.info-box p.image-links:not(.title-row p)::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, rgba(66, 142, 168, 0.3), rgba(131, 185, 204, 0.3));
    border-radius: 50%;
    z-index: 0;
}

.info-box p {
    font-size: 1rem;
    line-height: 1.6;
    margin: 0.5rem 0;
    text-align: left;
}

.info-box .smalltext {
    font-size: 0.7rem;
    margin: 0.25rem 0;
}

.section-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 0.5rem;
}

.section-buttons button {
    padding: 6px 10px;
    border: 1px solid #e0d7f7;
    background-color: #5e3b83;
    color: #e0d7f7;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: background-color 0.2s, color 0.2s;
}

.section-buttons button[data-filter-type="type"],
.section-buttons button[data-filter-type="meme"] {
    background-color: #7C5CBF;
    color: #e0d7f7;
    border-color: #7C5CBF;
}

.section-buttons button[data-filter-type="type"]:hover,
.section-buttons button[data-filter-type="meme"]:hover {
    background-color: #8E6DD1;
    border-color: #8E6DD1;
}

.section-buttons button[data-filter-type="keywords"] {
    background-color: #4a2c72;
    color: #e0d7f7;
    border-color: #4a2c72;
}

.section-buttons button[data-filter-type="keywords"]:hover {
    background-color: #5e3b83;
    border-color: #5e3b83;
    color: #e0d7f7;
}

.section-buttons button.active {
    background-color: #83b9cc;
    color: white;
    border-color: #83b9cc;
}

.section-buttons button:hover {
    background-color: #ced4da;
    color: #333;
}

.image-container {
    max-width: 100%;
    overflow: hidden;
    padding: 1rem 0; /* Added symmetric padding for better spacing under the text/image */
}

.image-container img {
    width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.loader {
    border: 4px solid rgba(224, 215, 247, 0.2);
    border-top: 4px solid #e0d7f7;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    margin: 6px 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.imgflip-icon-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin: 0.5rem 0 1rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    background-color: rgba(224, 215, 247, 0.2);
}

.imgflip-icon {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px;
}

.imgflip-icon.owned::after {
    content: "";
    position: absolute;
    left: 3px;
    right: 3px;
    top: 50%;
    border-top: 2px solid rgba(0, 0, 0, 0.75);
    transform: translateY(-50%) rotate(-25deg);
    pointer-events: none;
}

.imgflip-icon img {
    width: 24px;
    height: 24px;
    display: block;
}

.imgflip-icon-label {
    font-size: 0.70rem;
    line-height: 1;
    margin-top: 4px;
}

.imgflip-icon.current .imgflip-icon-label {
    margin-top: 0px;
}

.imgflip-icon.current img {
    width: 28px;
    height: 28px;
    box-shadow: 0 0 0 2px #f4c542;
    border-radius: 4px;
}

.imgflip-icon.owned::after {
    content: "";
    position: absolute;
    top: 12px;
    left: -1px;
    right: -1px;
    bottom: 45px;
    border-top: 2px solid rgba(0, 0, 0, 0.75);
    transform: rotate(-25deg);
    pointer-events: none;
}

.imgflip-icon.locked img {
    opacity: 0.35;
}

#current-imgflip-icon img {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    margin-left: 6px;
}

footer {
    text-align: center;
    color: #e0d7f7;
    font-size: 1rem;
    padding: 1.2rem;
    border-top: 1px solid #e0d7f7;
}

footer a {
    color: #e0d7f7;
    text-decoration: none;
    margin: 0 0.5rem;
}

footer a:hover {
    text-decoration: underline;
}

/* Mobile (<600px) */
@media (max-width: 600px) {
    body {
        padding: 1.5rem;
    }

    .main-container {
        padding: 1rem;
    }

    header img {
        max-width: 100px;
    }

    header h2 {
        font-size: 2.4rem;
    }

    .info-box {
        padding: 0.8rem;
    }

    .info-box .title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .info-box h3 {
        font-size: 1.2rem;
    }

    .arrow {
        margin-left: 0;
        margin-right: 0.5rem;
    }

    .info-box p.image-links {
        justify-content: flex-start;
        margin: 0;
    }

    .info-box p.image-links a img {
        width: 28px;
        height: 28px;
        margin: 0 6px;
        border-radius: 50%;
        box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
    }

    .info-box p.image-links a::before {
        width: 28px;
        height: 28px;
    }

    .info-box p.image-links img {
        width: 28px;
        height: 28px;
        margin: 0 6px;
        border-radius: 50%;
    }

    .info-box p.image-links:not(.title-row p)::before {
        width: 28px;
        height: 28px;
    }

    .info-box p {
        font-size: 0.9rem;
        text-align: left;
    }

    .info-box .smalltext {
        font-size: 0.6rem;
        margin: 0.2rem 0;
    }

    .section-buttons button {
        padding: 5px 8px;
        font-size: 0.8rem;
    }

    .section-buttons button.chip-type {
        background-color: #e0d7f7;
        border-color: #c1b3f0;
    }

    .section-buttons button.chip-meme {
        background-color: #f1e8ff;
        border-color: #d9c7ff;
    }

    .image-container {
        padding: 0.5rem 0; /* Adjusted for mobile */
    }

    .image-container img {
        max-width: 100%;
    }

    footer {
        font-size: 0.9rem;
        padding: 0.8rem;
    }

    .filter-container button {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .loader {
        width: 16px;
        height: 16px;
    }
}

/* Tablet (600px - 1024px) */
@media (min-width: 601px) and (max-width: 1024px) {
    .main-container {
        padding: 1.5rem;
    }

    .info-box h3 {
        font-size: 1.4rem;
    }

    .info-box p {
        font-size: 1.05rem;
    }

    .info-box p.image-links a img,
    .info-box p.image-links img {
        width: 30px;
        height: 30px;
    }

    .info-box p.image-links a::before,
    .info-box p.image-links:not(.title-row p)::before {
        width: 30px;
        height: 30px;
    }

    .info-box .smalltext {
        font-size: 0.65rem;
        margin: 0.25rem 0;
    }

    .section-buttons button {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    .filter-container button {
        padding: 7px 11px;
        font-size: 0.85rem;
    }

    .loader {
        width: 18px;
        height: 18px;
    }
}
