:root {
    --acid: #ccff00;
    --black: #000000;
    --paper: #f7ffd4;
    --border: 3px solid var(--black);
    --shadow: 8px 8px 0 var(--black);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--acid);
    color: var(--black);
    font-family: Arial, Helvetica, sans-serif;
}

button,
a,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    color: inherit;
}

.noise {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.055;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.45'/%3E%3C/svg%3E");
    mix-blend-mode: multiply;
}

.navbar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
    padding: 10px 32px;
    background: rgba(204, 255, 0, 0.94);
    border-bottom: var(--border);
    backdrop-filter: blur(8px);
}

.brand,
.nav-links a {
    color: var(--black);
    text-decoration: none;
    font-weight: 900;
    text-transform: uppercase;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    letter-spacing: -1px;
}

.brand-logo {
    width: 46px;
    height: 46px;
    object-fit: contain;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-links a,
.ca-button {
    position: relative;
    font-size: 14px;
    letter-spacing: 0.04em;
}

.nav-links a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 100%;
    bottom: -4px;
    height: 3px;
    background: var(--black);
    transition: right 150ms ease;
}

.nav-links a:hover::after {
    right: 0;
}

.ca-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 2px solid var(--black);
    background: transparent;
    cursor: pointer;
    font-weight: 900;
}

.ca-button:hover {
    background: var(--black);
    color: var(--acid);
}

main {
    padding-top: 72px;
}

.hero {
    position: relative;
    display: flex;
    min-height: calc(100vh - 72px);
    padding: 64px 24px 70px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
}



.hero-logo-button {
    position: relative;
    z-index: 1;
    max-width: min(680px, 92vw);
    border: 0;
    background: transparent;
    cursor: pointer;
}

.hero-logo {
    display: block;
    width: 100%;
    max-height: 510px;
    object-fit: contain;
    filter: drop-shadow(11px 11px 0 rgba(0, 0, 0, 0.92));
    transition: transform 160ms ease;
}

.hero-logo-button:hover .hero-logo {
    transform: rotate(-1deg) scale(1.015);
}

h1 {
    position: relative;
    z-index: 1;
    margin-top: 24px;
    font-size: clamp(52px, 9vw, 124px);
    line-height: 0.86;
    letter-spacing: -0.085em;
    text-transform: uppercase;
}

.primary-button,
.secondary-button {
    border: var(--border);
    cursor: pointer;
    font-weight: 900;
    text-transform: lowercase;
    transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, color 120ms ease;
}

.primary-button {
    position: relative;
    z-index: 1;
    margin-top: 34px;
    padding: 17px 24px;
    background: var(--black);
    color: var(--acid);
    box-shadow: 7px 7px 0 rgba(0, 0, 0, 0.3);
}

.primary-button:hover {
    transform: translate(-3px, -3px);
    box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.3);
}

.primary-button:active,
.secondary-button:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

.meme-gallery {
    padding: 84px 5vw 110px;
    border-top: var(--border);
    background: var(--black);
    color: var(--acid);
}

.gallery-heading {
    display: flex;
    justify-content: flex-end;
    max-width: 1400px;
    margin: 0 auto 28px;
}

.gallery-heading h2 {
    font-size: clamp(42px, 7vw, 90px);
    line-height: 0.9;
    letter-spacing: -0.07em;
    text-transform: lowercase;
}

.meme-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 18px;
    max-width: 1400px;
    margin: 0 auto;
}

.meme-grid img {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border: 3px solid var(--acid);
    background: var(--acid);
    cursor: zoom-in;
    transition: transform 150ms ease, box-shadow 150ms ease;
}

.meme-grid img:hover {
    position: relative;
    z-index: 2;
    transform: translate(-5px, -5px) rotate(-1deg);
    box-shadow: 9px 9px 0 var(--acid);
}


.meme-lightbox {
    position: fixed;
    inset: 0;
    z-index: 4500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 26px;
    background: rgba(0, 0, 0, 0.94);
}

.meme-lightbox.is-open {
    display: flex;
}

.meme-lightbox-dialog {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 22px;
    width: min(1180px, 100%);
    max-height: calc(100vh - 52px);
}

.meme-lightbox-figure {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.meme-lightbox-figure img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 120px);
    object-fit: contain;
    border: 3px solid var(--acid);
    background: var(--acid);
}

.meme-lightbox-figure figcaption {
    min-height: 18px;
    color: var(--acid);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.12em;
}

.meme-lightbox-close,
.meme-lightbox-arrow {
    display: grid;
    place-items: center;
    border: 3px solid var(--acid);
    background: var(--black);
    color: var(--acid);
    cursor: pointer;
    font-weight: 900;
}

.meme-lightbox-close:hover,
.meme-lightbox-arrow:hover {
    background: var(--acid);
    color: var(--black);
}

.meme-lightbox-close {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
    width: 48px;
    height: 48px;
    transform: translate(50%, -50%);
    font-size: 34px;
    line-height: 1;
}

.meme-lightbox-arrow {
    width: 58px;
    height: 58px;
    font-size: 30px;
}

.editor-modal {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.88);
    overflow-y: auto;
}

.editor-modal.is-open {
    display: flex;
}

.editor-shell {
    width: min(1120px, 100%);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: var(--acid);
    border: var(--border);
    box-shadow: 12px 12px 0 rgba(255, 255, 255, 0.18);
}

.editor-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 22px;
    background: var(--acid);
    border-bottom: var(--border);
}

.editor-header h2 {
    font-size: clamp(24px, 4vw, 40px);
    line-height: 0.95;
    letter-spacing: -0.045em;
    text-transform: lowercase;
}

.icon-button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border: var(--border);
    background: transparent;
    cursor: pointer;
    font-size: 32px;
    line-height: 1;
}

.icon-button:hover {
    background: var(--black);
    color: var(--acid);
}

.editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(290px, 0.75fr);
    gap: 26px;
    padding: 26px;
}

.canvas-panel {
    min-width: 0;
}

.canvas-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border: var(--border);
    background: #111111;
}

.canvas-frame.is-dragging {
    outline: 8px solid rgba(204, 255, 0, 0.45);
    outline-offset: -11px;
}

.canvas-frame .canvas-container {
    width: 100% !important;
    height: 100% !important;
}

.canvas-frame canvas {
    width: 100% !important;
    height: 100% !important;
}

.canvas-placeholder {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    width: 100%;
    border: 0;
    background: #111111;
    color: var(--acid);
    cursor: pointer;
    text-transform: uppercase;
}

.canvas-placeholder strong {
    padding: 15px 18px;
    border: 2px solid currentColor;
    font-size: 18px;
    letter-spacing: 0.08em;
}

.canvas-placeholder.is-hidden {
    display: none;
}

.canvas-help {
    margin-top: 10px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.45;
}

.editor-controls {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.control-block h3 {
    margin-bottom: 12px;
    font-size: 20px;
    text-transform: lowercase;
}

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

.item-card {
    display: flex;
    min-width: 0;
    min-height: 128px;
    padding: 10px;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 2px solid var(--black);
    background: rgba(255, 255, 255, 0.42);
    cursor: pointer;
    font-weight: 900;
}

.item-card:hover {
    background: var(--black);
    color: var(--acid);
}

.item-card img {
    width: 100%;
    height: 76px;
    object-fit: contain;
}

.item-card span {
    font-size: 11px;
    text-align: center;
}

.editor-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
}

.secondary-button {
    min-height: 48px;
    padding: 11px 12px;
    background: transparent;
    color: var(--black);
}

.secondary-button:hover:not(:disabled) {
    background: var(--black);
    color: var(--acid);
}

.secondary-button:disabled {
    cursor: not-allowed;
    opacity: 0.38;
}

.danger-button:hover:not(:disabled) {
    background: #f02d2d;
    color: #ffffff;
}

.save-button {
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 0;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 7000;
    max-width: calc(100vw - 32px);
    padding: 12px 16px;
    transform: translate(-50%, 24px);
    border: 2px solid var(--acid);
    background: var(--black);
    color: var(--acid);
    font-size: 13px;
    font-weight: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (max-width: 980px) {
    .meme-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .editor-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .navbar {
        min-height: 64px;
        padding: 8px 14px;
    }

    .brand {
        font-size: 15px;
    }

    .brand-logo {
        width: 38px;
        height: 38px;
    }

    .nav-links {
        gap: 11px;
    }

    .nav-links a,
    .ca-button {
        font-size: 11px;
    }

    .ca-button {
        padding: 8px;
    }

    .copy-icon {
        display: none;
    }

    main {
        padding-top: 64px;
    }

    .hero {
        min-height: calc(100vh - 64px);
        padding: 48px 16px 58px;
    }

    h1 {
        margin-top: 22px;
    }

    .primary-button {
        max-width: 92vw;
    }

    .meme-gallery {
        padding: 58px 16px 76px;
    }

    .gallery-heading {
        justify-content: flex-start;
    }

    .meme-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .meme-lightbox {
        padding: 14px;
    }

    .meme-lightbox-dialog {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .meme-lightbox-figure {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    .meme-lightbox-arrow {
        width: 100%;
        height: 48px;
    }

    .meme-lightbox-prev {
        grid-column: 1;
        grid-row: 2;
    }

    .meme-lightbox-next {
        grid-column: 2;
        grid-row: 2;
    }

    .meme-lightbox-close {
        top: 8px;
        right: 8px;
        width: 42px;
        height: 42px;
        transform: none;
    }

    .meme-lightbox-figure img {
        max-height: calc(100vh - 115px);
    }

    .editor-modal {
        padding: 0;
        align-items: stretch;
    }

    .editor-shell {
        min-height: 100vh;
        max-height: none;
        border: 0;
        box-shadow: none;
    }

    .editor-header,
    .editor-layout {
        padding: 16px;
    }

    .editor-layout {
        gap: 18px;
    }

    .item-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .item-card {
        min-height: 108px;
        padding: 7px;
    }

    .item-card img {
        height: 60px;
    }
}

@media (max-width: 460px) {
    .brand span {
        display: none;
    }

    .nav-links {
        gap: 8px;
    }

    .meme-grid {
        grid-template-columns: 1fr;
    }

    .item-grid {
        grid-template-columns: 1fr;
    }

    .item-card {
        min-height: 96px;
        flex-direction: row;
        justify-content: flex-start;
        text-align: left;
    }

    .item-card img {
        width: 92px;
        height: 70px;
    }
}
