:root {
    --bg-color: #ffffff;
    --text-color: #000000;
    --icon-bg: #f0f0f0;
    --icon-item-bg:#e8e8e8;
    --icon-filter: none;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1D1D1D;
        --text-color: #e0e0e0;
        --icon-bg: #333333;
        --icon-item-bg:#555;
        --icon-filter: invert(0.9);
    }
}

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

body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: PingFang SC, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Ubuntu, Helvetica Neue, Helvetica, Arial, Hiragino Sans GB, Microsoft YaHei UI, Microsoft YaHei, Source Han Sans CN, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    padding: 20px;
    max-width: 550px;
    width: 90%;
}

.icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 15px;
    position: relative;
    user-select: none;
    outline: none;
}

.icon-item:hover {
    background: var(--icon-item-bg);
    transform: translateY(-5px);
}

.icon-item:active {
    transform: translateY(0) scale(0.95);
    opacity: 0.9;
    transition: all 0.1s ease;
}

.icon-item.clicked {
    animation: clickAnimation 0.3s ease;
}

@keyframes clickAnimation {
    0% {
        transform: scale(0.95);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: var(--icon-bg);
}

.icon img {
    width: 70%;
    height: 70%;
    border-radius: 50%;
    object-fit: contain;
    filter: var(--icon-filter);
    transition: filter 0.3s ease;
}

.icon-label {
    font-size: 14px;
    word-break: break-word;
    max-width: 100%;
    color: var(--text-color);
}

/* 改进后的关闭按钮样式 */
.close-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1;
    cursor: pointer;
    background-color: transparent;
    border: none;
    outline: none;
}

.close-btn::before, .close-btn::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 1px;
    background-color: var(--text-color);
    transition: background-color 0.2s ease;
}

.close-btn::before {
    transform: rotate(45deg);
}

.close-btn::after {
    transform: rotate(-45deg);
}

.icon-item:hover .close-btn {
    opacity: 0.6;
}

.close-btn:hover {
    opacity: 1 !important;
}

.close-btn:hover::before, .close-btn:hover::after {
    background-color: #ff4444;
}

@media (max-width: 768px) {
    .container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .container {
        grid-template-columns: 1fr;
    }
}