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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: white;
    display: flex;
    flex-direction: column;
    transition: all 0.8s ease;
    overflow-x: hidden;
}

/* Анимации фона для разных рангов */
body.rank-common {
    background: linear-gradient(135deg, #1a1a2e 0%, #2e7d32 100%);
}

body.rank-rare {
    background: linear-gradient(135deg, #1a1a2e 0%, #ef6c00 100%);
    animation: rareShake 0.8s ease-in-out;
}

body.rank-epic {
    background: linear-gradient(135deg, #1a1a2e 0%, #6a1b9a 100%);
    animation: epicExpand 1.2s ease-out forwards;
}

body.rank-mythical {
    background: linear-gradient(135deg, #1a1a2e 0%, #c62828 100%);
    animation: mythicalTwitch 0.4s infinite;
}

body.rank-legendary {
    background: linear-gradient(135deg, #1a1a2e 0%, #ffab00 100%);
    animation: legendaryExplosion 1.5s ease-out forwards;
}

body.rank-edit {
    background: linear-gradient(135deg, #000000 0%, #1a1a1a 100%);
    animation: editShake 2s infinite;
}

/* Анимация мощной тряски для edit ранга */
@keyframes editShake {
    0%, 75%, 100% {
        transform: translate(0, 0) rotate(0) scale(1);
    }
    77% {
        transform: translate(25px, -20px) rotate(3deg) scale(1.05);
    }
    79% {
        transform: translate(-20px, 15px) rotate(-2.5deg) scale(0.95);
    }
    81% {
        transform: translate(30px, -25px) rotate(4deg) scale(1.1);
    }
    83% {
        transform: translate(-25px, 20px) rotate(-3.5deg) scale(0.9);
    }
    85% {
        transform: translate(20px, -30px) rotate(2.8deg) scale(1.08);
    }
    87% {
        transform: translate(-30px, 25px) rotate(-4.2deg) scale(0.92);
    }
    89% {
        transform: translate(35px, -15px) rotate(3.2deg) scale(1.12);
    }
    91% {
        transform: translate(-15px, 35px) rotate(-2.8deg) scale(0.88);
    }
    93% {
        transform: translate(28px, -28px) rotate(4.5deg) scale(1.15);
    }
    95% {
        transform: translate(-28px, 28px) rotate(-4.8deg) scale(0.85);
    }
    97% {
        transform: translate(32px, -32px) rotate(5deg) scale(1.2);
    }
    99% {
        transform: translate(0, 0) rotate(0) scale(1);
    }
}

/* Анимация тряски для редкого ранга */
@keyframes rareShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
    20%, 40%, 60%, 80% { transform: translateX(8px); }
}

/* Анимация подергивания для мистического ранга */
@keyframes mythicalTwitch {
    0%, 40% {
        transform: translate(0, 0) rotate(0) scale(1);
        filter: brightness(1);
    }
    5% {
        transform: translate(12px, -8px) rotate(1.5deg) scale(1.02);
        filter: brightness(1.3);
    }
    10% {
        transform: translate(-10px, 6px) rotate(-1.2deg) scale(0.98);
        filter: brightness(0.9);
    }
    15% {
        transform: translate(8px, -12px) rotate(0.8deg) scale(1.01);
        filter: brightness(1.2);
    }
    20% {
        transform: translate(-15px, 4px) rotate(-1.8deg) scale(0.97);
        filter: brightness(0.8);
    }
    25% {
        transform: translate(6px, 10px) rotate(1deg) scale(1.03);
        filter: brightness(1.4);
    }
    30% {
        transform: translate(-8px, -6px) rotate(-0.7deg) scale(0.99);
        filter: brightness(0.95);
    }
    35% {
        transform: translate(10px, 8px) rotate(1.3deg) scale(1.02);
        filter: brightness(1.1);
    }
}

/* Анимация раскрытия для эпического ранга */
@keyframes epicExpand {
    0% {
        background: linear-gradient(135deg, #1a1a2e 0%, #1a1a2e 100%);
        transform: scale(0.8);
        opacity: 0.5;
    }
    50% {
        background: linear-gradient(135deg, #1a1a2e 0%, #4a148c 100%);
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        background: linear-gradient(135deg, #1a1a2e 0%, #6a1b9a 100%);
        transform: scale(1);
        opacity: 1;
    }
}

/* Анимация взрыва для легендарного ранга */
@keyframes legendaryExplosion {
    0% {
        background: radial-gradient(circle at center, #ffd700 0%, #1a1a2e 100%);
        transform: scale(0.1);
        opacity: 0;
    }
    20% {
        background: radial-gradient(circle at center, #ffeb3b 0%, #1a1a2e 70%);
        transform: scale(1.3);
        opacity: 1;
    }
    40% {
        background: radial-gradient(circle at center, #ffc107 0%, #1a1a2e 80%);
        transform: scale(1.1);
        opacity: 0.9;
    }
    60% {
        background: linear-gradient(135deg, #1a1a2e 0%, #ffab00 100%);
        transform: scale(1.05);
        opacity: 1;
    }
    100% {
        background: linear-gradient(135deg, #1a1a2e 0%, #ffab00 100%);
        transform: scale(1);
        opacity: 1;
    }
}

.container {
    max-width: 100vw;
    min-height: 100vh;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

h1 {
    margin-bottom: 15px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    background: linear-gradient(45deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ranks-info {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.rank-item {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    border: 2px solid;
    min-width: 80px;
}

.content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 50px;
    flex: 1;
    margin-bottom: 20px;
}

.mellstroy-face {
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    flex: 0 0 auto;
}

.mellstroy-face:hover {
    transform: scale(1.05);
}

.mellstroy-face:active {
    transform: scale(0.95);
}

.face-container {
    position: relative;
    width: 400px;
    height: 400px;
}

.mellstroy-face img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 8px solid white;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    position: relative;
    z-index: 2;
}

.rank-glow {
    position: absolute;
    top: -15px;
    left: -15px;
    right: -15px;
    bottom: -15px;
    border-radius: 50%;
    background: transparent;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.rank-glow.active {
    opacity: 1;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); opacity: 0.7; }
}

.click-text {
    position: absolute;
    bottom: -45px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.2);
    padding: 12px 25px;
    border-radius: 25px;
    font-weight: bold;
    backdrop-filter: blur(10px);
    font-size: 1.1em;
    border: 2px solid rgba(255,255,255,0.3);
    white-space: nowrap;
}

.meme-container {
    width: 600px;
    min-height: 450px;
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 20px;
    backdrop-filter: blur(10px);
    border: 3px solid rgba(255,255,255,0.2);
    position: relative;
    overflow: hidden;
    flex: 0 0 auto;
}

.meme-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(255,255,255,0.2);
    gap: 20px;
}

.meme-rank {
    padding: 10px 20px;
    border-radius: 15px;
    font-weight: bold;
    font-size: 1em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    border: 2px solid;
    min-width: 100px;
}

.meme-name {
    font-size: 1em;
    opacity: 0.9;
    font-weight: bold;
}

.meme-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    font-size: 1.2em;
    color: rgba(255,255,255,0.7);
    border: 3px dashed rgba(255,255,255,0.3);
    border-radius: 10px;
    margin-bottom: 20px;
}

.video-container {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    height: 300px;
    width: 100%;
    margin-bottom: 20px;
    border: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

#memeVideo {
    width: 100%;
    height: 100%;
    border-radius: 15px;
    background: black;
    position: relative;
    z-index: 2;
    object-fit: cover;
}

.video-glow {
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 18px;
    background: transparent;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.video-glow.active {
    opacity: 0.6;
    animation: glowPulse 2s infinite;
}

@keyframes glowPulse {
    0% { opacity: 0.4; }
    50% { opacity: 0.8; }
    100% { opacity: 0.4; }
}

.meme-stats {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 20px;
    font-size: 0.9em;
    opacity: 0.9;
}

.stat {
    padding: 8px 16px;
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
    font-weight: bold;
}

.loading {
    margin-top: 20px;
    font-size: 1.1em;
}

.spinner {
    border: 4px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top: 4px solid white;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

/* Эффекты для разных рангов */
.rank-effect-common {
    background: linear-gradient(45deg, #4CAF50, #66BB6A);
    border-color: #4CAF50 !important;
}

.rank-effect-rare {
    background: linear-gradient(45deg, #FF9800, #FFB74D);
    border-color: #FF9800 !important;
}

.rank-effect-epic {
    background: linear-gradient(45deg, #9C27B0, #BA68C8);
    border-color: #9C27B0 !important;
}

.rank-effect-mythical {
    background: linear-gradient(45deg, #F44336, #EF5350);
    border-color: #F44336 !important;
}

.rank-effect-legendary {
    background: linear-gradient(45deg, #FFD700, #FFE55C);
    border-color: #FFD700 !important;
}

.rank-effect-edit {
    background: linear-gradient(45deg, #000000, #ff0000) !important;
    border-color: #ff0000 !important;
    color: white !important;
}

.website-link {
    padding: 20px;
    text-align: center;
}

.website-link a {
    display: inline-block;
    font-size: 1.8em;
    font-weight: bold;
    color: #ff6b6b;
    text-decoration: none;
    padding: 15px 40px;
    background: rgba(255,255,255,0.15);
    border-radius: 50px;
    transition: all 0.3s ease;
    border: 3px solid #ff6b6b;
    backdrop-filter: blur(15px);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    box-shadow: 0 10px 35px rgba(255,107,107,0.2);
}

.website-link a:hover {
    background: #ff6b6b;
    color: white;
    transform: scale(1.05);
    box-shadow: 0 15px 45px rgba(255,107,107,0.4);
}

/* МОБИЛЬНАЯ АДАПТИВНОСТЬ */
@media (max-width: 768px) {
    body {
        overflow-y: auto;
        height: auto;
        min-height: 100vh;
    }

    .container {
        padding: 15px;
        height: auto;
        min-height: 100vh;
        justify-content: flex-start;
        gap: 20px;
    }

    h1 {
        font-size: 2em;
        margin-bottom: 15px;
    }

    .ranks-info {
        gap: 6px;
        margin-bottom: 20px;
    }

    .rank-item {
        padding: 6px 12px;
        font-size: 0.75em;
        min-width: 65px;
    }

    .content {
        flex-direction: column;
        gap: 30px;
        margin-bottom: 25px;
        flex: 1;
    }

    .face-container {
        width: 280px;
        height: 280px;
    }

    .mellstroy-face img {
        border-width: 6px;
    }

    .click-text {
        bottom: -40px;
        font-size: 1em;
        padding: 10px 20px;
    }

    .meme-container {
        width: 100%;
        min-height: 400px;
        padding: 15px;
    }

    .video-container {
        height: 250px;
        margin-bottom: 15px;
    }

    .meme-header {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 15px;
        text-align: center;
    }

    .meme-rank {
        font-size: 0.9em;
        padding: 8px 16px;
        min-width: 90px;
    }

    .meme-name {
        font-size: 0.9em;
    }

    .meme-stats {
        flex-direction: column;
        gap: 10px;
        align-items: center;
        margin-right: 0;
    }

    .stat {
        font-size: 0.9em;
        padding: 8px 16px;
        width: 100%;
        text-align: center;
    }

    .website-link a {
        font-size: 1.4em;
        padding: 12px 30px;
    }

    .loading {
        font-size: 1em;
        margin-top: 15px;
    }

    .spinner {
        width: 25px;
        height: 25px;
    }

    /* Упрощенные анимации для мобильных */
    body.rank-mythical {
        animation: mythicalPulseMobile 0.6s infinite;
    }

    body.rank-edit {
        animation: editShakeMobile 1.5s infinite;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 480px) {
    .container {
        padding: 12px;
        gap: 15px;
    }

    h1 {
        font-size: 1.7em;
    }

    .face-container {
        width: 220px;
        height: 220px;
    }

    .meme-container {
        min-height: 350px;
        padding: 12px;
    }

    .video-container {
        height: 200px;
    }

    .click-text {
        font-size: 0.9em;
        bottom: -35px;
        padding: 8px 16px;
    }

    .website-link a {
        font-size: 1.2em;
        padding: 10px 25px;
    }

    .ranks-info {
        gap: 4px;
    }

    .rank-item {
        font-size: 0.7em;
        padding: 5px 10px;
        min-width: 60px;
    }
}

/* Для горизонтальной ориентации на мобильных */
@media (max-height: 500px) and (orientation: landscape) {
    .container {
        padding: 10px;
        gap: 10px;
    }

    .content {
        flex-direction: row;
        gap: 20px;
        margin-bottom: 15px;
    }

    .face-container {
        width: 150px;
        height: 150px;
    }

    .meme-container {
        min-height: 250px;
        padding: 10px;
    }

    .video-container {
        height: 180px;
    }

    .click-text {
        bottom: -30px;
        font-size: 0.8em;
        padding: 6px 12px;
    }

    h1 {
        font-size: 1.5em;
        margin-bottom: 10px;
    }

    .ranks-info {
        margin-bottom: 10px;
    }
}

/* Упрощенные анимации для мобильных */
@keyframes mythicalPulseMobile {
    0%, 100% {
        background: linear-gradient(135deg, #1a1a2e 0%, #c62828 100%);
    }
    50% {
        background: linear-gradient(135deg, #1a1a2e 0%, #ff5252 100%);
    }
}

@keyframes editShakeMobile {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Улучшаем touch-опыт */
@media (hover: none) and (pointer: coarse) {
    .mellstroy-face:hover {
        transform: none;
    }

    .mellstroy-face:active {
        transform: scale(0.95);
    }

    .website-link a:active {
        transform: scale(0.98);
    }

    .mellstroy-face {
        padding: 10px;
    }
}

/* Стили для полноэкранного режима */
.video-container:fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    padding: 0 !important;
    background: black !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.video-container:fullscreen #memeVideo {
    width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    object-fit: contain !important;
}