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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #000;
    color: #fff;
}

#app {
    height: 100%;
    width: 100%;
    position: relative;
}

#domain-links {
    position: fixed;
    bottom: 5px;
    right: 20px;
    font-size: 10px;
    z-index: 100;
}

#domain-links a {
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    transition: color 0.2s;
}

#domain-links a:hover {
    color: #fff;
}

#domain-links .separator {
    color: rgba(255,255,255,0.4);
    margin: 0 2px;
}

#viewpane {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

#meme-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

#meme-content {
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#meme-content img {
    max-width: 100%;
    max-height: calc(100vh - 120px);
    object-fit: contain;
}

#meme-content video {
    max-width: 100%;
    max-height: calc(100vh - 120px);
    object-fit: contain;
}

#meme-content .text-meme {
    width: 95%;
    max-height: calc(100vh - 120px);
    padding: 20px;
    background: rgba(30, 30, 30, 0.9);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

#meme-footer {
    padding: 15px 20px;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
}

#meme-info {
    flex: 1;
}

#meme-name {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 8px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
}

#meme-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

#meme-counter {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    margin-top: 6px;
}

.tag {
    background: rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.tag:hover {
    background: rgba(255,255,255,0.4);
}

#vote-buttons {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    z-index: 100;
}

.vote-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    color: #fff;
    font-size: 14px;
    transition: background 0.2s, transform 0.1s;
}

.vote-btn:hover {
    background: rgba(255,255,255,0.25);
}

.vote-btn:active {
    transform: scale(0.95);
}

.vote-btn.active {
    background: rgba(100, 200, 100, 0.5);
}

#downvote-btn.active {
    background: rgba(200, 100, 100, 0.5);
}

.vote-icon {
    width: 24px;
    height: 24px;
    color: #fff;
}

#controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    z-index: 100;
}

#type-selector,
#sort-selector {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    padding: 8px 12px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}

#type-selector option,
#sort-selector option {
    background: #222;
    color: #fff;
}

#admin-link {
    background: rgba(255,255,255,0.15);
    padding: 8px 12px;
    border-radius: 8px;
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
}

#admin-link:hover {
    background: rgba(255,255,255,0.25);
}

#tag-mode-indicator {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    padding: 10px 20px;
    border-radius: 25px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 100;
}

#current-tag {
    font-weight: 500;
}

#exit-tag-mode {
    background: rgba(255,255,255,0.2);
    border: none;
    padding: 5px 12px;
    border-radius: 15px;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
}

#exit-tag-mode:hover {
    background: rgba(255,255,255,0.3);
}

#admin-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

#admin-panel-content {
    background: #1a1a1a;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
}

#admin-panel-content h3 {
    margin-bottom: 20px;
    font-size: 20px;
}

.admin-field {
    margin-bottom: 15px;
}

.admin-field label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #aaa;
}

.admin-field input {
    width: 100%;
    padding: 10px;
    border: 1px solid #333;
    border-radius: 8px;
    background: #2a2a2a;
    color: #fff;
    font-size: 14px;
    margin-bottom: 8px;
}

.admin-field button {
    background: #4a90d9;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
}

.admin-field button:hover {
    background: #5aa0e9;
}

#tag-suggestions {
    background: #333;
    border: 1px solid #444;
    border-radius: 8px;
    margin-top: 4px;
    margin-bottom: 8px;
    max-height: 150px;
    overflow-y: auto;
}

#tag-suggestions .tag-suggestion {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
}

#tag-suggestions .tag-suggestion:hover {
    background: #444;
}

#tag-suggestions .tag-suggestion:first-child {
    border-radius: 8px 8px 0 0;
}

#tag-suggestions .tag-suggestion:last-child {
    border-radius: 0 0 8px 8px;
}

#tag-suggestions .tag-suggestion:only-child {
    border-radius: 8px;
}

#close-admin-btn {
    width: 100%;
    margin-top: 10px;
    background: #444;
    border: none;
    padding: 10px;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
}

#close-admin-btn:hover {
    background: #555;
}

#sound-prompt {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 150;
}

#enable-sound-btn {
    background: rgba(255,255,255,0.9);
    border: none;
    padding: 8px 16px;
    border-radius: 15px;
    color: #000;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

#enable-sound-btn:hover {
    background: #fff;
}

#loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 50;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Preload container */
#preload-container {
    position: absolute;
    left: -9999px;
    visibility: hidden;
}

/* NSFW blur overlay */
#nsfw-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    cursor: pointer;
}

#nsfw-overlay-content {
    text-align: center;
    color: #fff;
    padding: 20px;
}

#nsfw-overlay-content .nsfw-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

#nsfw-overlay-content .nsfw-text {
    font-size: 18px;
    opacity: 0.9;
}

#meme-content.nsfw-blur img,
#meme-content.nsfw-blur video,
#meme-content.nsfw-blur .text-meme {
    filter: blur(30px);
    transition: filter 0.3s;
}

#meme-content.nsfw-revealed img,
#meme-content.nsfw-revealed video,
#meme-content.nsfw-revealed .text-meme {
    filter: none;
}

/* Gesture hint overlay */
#gesture-hint {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
}

#gesture-hint-content {
    text-align: center;
    color: #fff;
}

#gesture-arrow {
    font-size: 48px;
    animation: bounce 1s ease infinite;
}

#gesture-text {
    font-size: 18px;
    margin-top: 10px;
    opacity: 0.9;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-15px);
    }
}

/* Touch feedback */
@media (hover: none) {
    .vote-btn:active {
        background: rgba(255,255,255,0.35);
    }

    .tag:active {
        background: rgba(255,255,255,0.5);
    }
}

/* Desktop adjustments */
@media (min-width: 768px) {
    #meme-footer {
        padding: 20px 40px;
    }

    #meme-name {
        font-size: 18px;
    }

    .tag {
        font-size: 13px;
        padding: 5px 12px;
    }
}

/* Hamburger menu button - hidden on desktop */
.hamburger-btn {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 10px;
    z-index: 100;
}

.hamburger-line {
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 1px;
    transition: transform 0.3s, opacity 0.3s;
}

/* Hamburger animation when open */
.hamburger-btn.open .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-btn.open .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.open .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Mobile menu overlay */
#mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 140;
}

#mobile-menu-overlay.hidden {
    display: none;
}

/* Mobile styles */
@media (max-width: 767px) {
    /* Show hamburger button - top-left on mobile */
    .hamburger-btn {
        display: flex;
        bottom: auto;
        right: auto;
        top: calc(20px + env(safe-area-inset-top, 0px));
        left: 20px;
    }

    /* Hide domain links on mobile */
    #domain-links {
        display: none;
    }

    /* Transform controls into mobile menu - top-left dropdown */
    #controls {
        position: fixed;
        bottom: auto;
        right: auto;
        top: calc(80px + env(safe-area-inset-top, 0px));
        left: 20px;
        flex-direction: column;
        gap: 12px;
        background: rgba(0, 0, 0, 0.9);
        padding: 15px;
        border-radius: 12px;
        display: none;
        z-index: 150;
    }

    /* Show controls when open */
    #controls.controls-open {
        display: flex;
    }

    /* Make selectors full width in menu */
    #controls select {
        width: 100%;
        min-width: 150px;
        padding: 12px 15px;
        font-size: 16px;
    }

    /* Admin link styling in menu */
    #controls #admin-link {
        width: 100%;
        text-align: center;
        padding: 12px 15px;
    }

    /* Adjust vote buttons for safe area */
    #vote-buttons {
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }

    /* Increase touch targets on vote buttons */
    .vote-btn {
        padding: 12px 16px;
        min-width: 44px;
        min-height: 44px;
    }

    /* Collapsible footer on mobile */
    #meme-footer {
        padding: 10px 15px;
        padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }

    #meme-footer.footer-expanded {
        opacity: 1;
        pointer-events: auto;
    }

    /* Always hide meme counter on mobile */
    #meme-counter {
        display: none;
    }

    /* Smaller text on mobile */
    #meme-name {
        font-size: 14px;
        margin-bottom: 6px;
    }

    .tag {
        font-size: 11px;
        padding: 3px 8px;
    }
}
