/* 像素风格字体 */
@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&family=DotGothic16&display=swap");

/* 通用样式 */
body {
    font-family: "DotGothic16", Arial, sans-serif;
    background-color: #f9f7f0;
    margin: 0;
    padding: 20px;
    color: #5a5a5a;
    transition: all 0.3s ease;
    background-image: linear-gradient(#e8e5d8 1px, transparent 1px),
        linear-gradient(90deg, #e8e5d8 1px, transparent 1px);
    background-size: 20px 20px;
}

body.dark-mode {
    background-color: #1a1a2e;
    color: #e0e0e0;
    background-image: linear-gradient(#2a2a3a 1px, transparent 1px),
        linear-gradient(90deg, #2a2a3a 1px, transparent 1px);
}

h1 {
    font-family: "Press Start 2P", cursive;
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    color: #5a5a5a;
    text-align: center;
    text-shadow: 3px 3px 0px rgba(0, 0, 0, 0.1);
    letter-spacing: 1px;
}

.dark-mode h1 {
    color: #e0e0e0;
    text-shadow: 3px 3px 0px rgba(255, 255, 255, 0.1);
}

/* 上传区域 */
.upload-section {
    margin-bottom: 2rem;
    text-align: center;
}

.upload-label {
    display: inline-block;
    background-color: #8bb8e8;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: "Press Start 2P", cursive;
    font-size: 0.8rem;
    letter-spacing: 1px;
    box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.1);
    border: 2px solid #5a8bc8;
    position: relative;
    overflow: hidden;
}

.upload-label:hover {
    background-color: #7aa7d8;
    transform: translateY(-2px);
    box-shadow: 6px 6px 0px rgba(0, 0, 0, 0.1);
}

.upload-label:active {
    transform: translateY(1px);
    box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

.upload-label input[type="file"] {
    display: none;
}

/* 帧容器 */
.frames-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1.5rem;
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.frame-item {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 3px solid #fff;
    position: relative;
}

.dark-mode .frame-item {
    background-color: #2d2d4d;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-color: #3d3d5d;
}

.frame-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.dark-mode .frame-item:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

.frame-item img {
    width: 100%;
    height: auto;
    display: block;
    image-rendering: pixelated;
}

.frame-info {
    padding: 0.8rem;
    text-align: center;
    font-size: 0.9rem;
    color: #666;
    background-color: #f5f5f5;
    font-family: "Press Start 2P", cursive;
    letter-spacing: 0;
}

.dark-mode .frame-info {
    color: #ccc;
    background-color: #3d3d5d;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    transform-origin: center;
    transition: transform 0.3s ease;
    border: 4px solid #fff;
    image-rendering: pixelated;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.5);
    font-family: "Press Start 2P", cursive;
}

.modal-close:hover {
    color: #ff9a9e;
    transform: scale(1.1);
}

/* 导航箭头 */
.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    user-select: none;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    transition: all 0.3s ease;
    font-family: "Press Start 2P", cursive;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.modal-nav:hover {
    background-color: rgba(0, 0, 0, 0.8);
    color: #a18cd1;
    transform: translateY(-50%) scale(1.1);
}

.modal-nav.left {
    left: 20px;
}

.modal-nav.right {
    right: 20px;
}

/* 使用手册模态框样式 */
.manual-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
}

.manual-content {
    background-color: #fff;
    border-radius: 12px;
    padding: 2rem;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    border: 4px solid #8bb8e8;
    position: relative;
}

.dark-mode .manual-content {
    background-color: #2d2d4d;
    border-color: #5a8bc8;
}

.manual-title {
    font-family: "Press Start 2P", cursive;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: #5a5a5a;
    text-align: center;
}

.dark-mode .manual-title {
    color: #e0e0e0;
}

.manual-section {
    margin-bottom: 1.5rem;
}

.manual-section-title {
    /* font-family: "Press Start 2P", cursive; */
    font-size: 1rem;
    color: #8bb8e8;
    margin-bottom: 0.5rem;
}

.dark-mode .manual-section-title {
    color: #a18cd1;
}

.manual-text {
    font-family: "DotGothic16", Arial, sans-serif;
    /* font-size: 0.9rem; */
    line-height: 1.5;
    color: #5a5a5a;
}

.dark-mode .manual-text {
    color: #e0e0e0;
}

.manual-list {
    padding-left: 1.5rem;
}

.manual-list li {
    margin-bottom: 0.5rem;
}

/* 帮助按钮 */
.help-button {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background: #ff9a9e;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1003;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 2px solid #ff7b7f;
}

.help-button:hover {
    background-color: #ff7b7f;
    transform: translateY(-5px);
}

.help-button svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

/* 加载遮罩 */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(249, 247, 240, 0.9);
    justify-content: center;
    align-items: center;
    z-index: 1001;
    flex-direction: column;
}

.dark-mode .loading-overlay {
    background-color: rgba(26, 26, 46, 0.9);
}

.loading-spinner {
    border: 6px solid #f3f3f3;
    border-top: 6px solid #8bb8e8;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dark-mode .loading-spinner {
    border: 6px solid #3d3d5d;
    border-top: 6px solid #a18cd1;
}

.loading-text {
    margin-top: 20px;
    font-size: 1.2rem;
    color: #5a5a5a;
    font-family: "Press Start 2P", cursive;
    letter-spacing: 1px;
}

.dark-mode .loading-text {
    color: #e0e0e0;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* 错误消息 */
.error-message {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #ff6b6b;
    color: #fff;
    padding: 1rem 2rem;
    border-radius: 8px;
    z-index: 1002;
    text-align: center;
    font-family: "Press Start 2P", cursive;
    font-size: 0.9rem;
    box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.2);
    border: 2px solid #ff4c4c;
}

/* 进度条 */
.progress-bar {
    width: 300px;
    height: 12px;
    background-color: #e0e0e0;
    border-radius: 6px;
    margin-top: 20px;
    overflow: hidden;
    border: 2px solid #d0d0d0;
}

.dark-mode .progress-bar {
    background-color: #3d3d5d;
    border-color: #4d4d6d;
}

.progress-bar-fill {
    height: 100%;
    background-color: #8bb8e8;
    width: 0;
    transition: width 0.3s ease;
    background-image: linear-gradient(90deg, #8bb8e8, #a18cd1);
}

/* 取消按钮 */
.cancel-button {
    margin-top: 20px;
    padding: 0.75rem 1.5rem;
    background-color: #ff6b6b;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: "Press Start 2P", cursive;
    font-size: 0.8rem;
    letter-spacing: 1px;
    box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.1);
    border: 2px solid #ff4c4c;
}

.cancel-button:hover {
    background-color: #ff4c4c;
    transform: translateY(-2px);
    box-shadow: 6px 6px 0px rgba(0, 0, 0, 0.1);
}

.cancel-button:active {
    transform: translateY(1px);
    box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

/* 主题切换按钮 */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #fff;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1003;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    transform: rotate(15deg) scale(1.1);
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
    transition: all 0.3s ease;
}

#moonIcon {
    fill: #5a5a5a;
}

#sunIcon {
    fill: #ffcc00;
}

.dark-mode .theme-toggle {
    background-color: #3d3d5d;
}

.dark-mode #moonIcon {
    fill: #ffcc00;
}

/* 返回顶部按钮 */
.back-to-top {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #8bb8e8;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1003;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 2px solid #5a8bc8;
}

.back-to-top:hover {
    background-color: #7aa7d8;
    transform: translateY(-5px);
}

.back-to-top svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

/* 像素颜色显示 */
.pixel-color {
    position: fixed;
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 1004;
    display: none;
    pointer-events: none;
    font-family: "Press Start 2P", cursive;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.pixel-color .color-preview {
    width: 100%;
    height: 12px;
    margin-top: 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

#sunIcon {
    display: none;
}

/* 生成雪碧图按钮 */
.generate-sprite-button {
    display: inline-block;
    background-color: #a1d8a1;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1.5rem;
    font-family: "Press Start 2P", cursive;
    font-size: 0.8rem;
    letter-spacing: 1px;
    box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.1);
    border: 2px solid #81b881;
}

.generate-sprite-button:hover {
    background-color: #91c891;
    transform: translateY(-2px);
    box-shadow: 6px 6px 0px rgba(0, 0, 0, 0.1);
}

.generate-sprite-button:active {
    transform: translateY(1px);
    box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

/* 像素风格装饰元素 */
.pixel-corner {
    position: fixed;
    width: 40px;
    height: 40px;
    z-index: -1;
}

.pixel-corner.top-left {
    top: 0;
    left: 0;
    border-top: 10px solid #8bb8e8;
    border-left: 10px solid #8bb8e8;
}

.pixel-corner.top-right {
    top: 0;
    right: 0;
    border-top: 10px solid #ff9a9e;
    border-right: 10px solid #ff9a9e;
}

.pixel-corner.bottom-left {
    bottom: 0;
    left: 0;
    border-bottom: 10px solid #a18cd1;
    border-left: 10px solid #a18cd1;
}

.pixel-corner.bottom-right {
    bottom: 0;
    right: 0;
    border-bottom: 10px solid #a1d8a1;
    border-right: 10px solid #a1d8a1;
}

.dark-mode .pixel-corner.top-left {
    border-color: #5a8bc8;
}

.dark-mode .pixel-corner.top-right {
    border-color: #ff7b7f;
}

.dark-mode .pixel-corner.bottom-left {
    border-color: #917cbf;
}

.dark-mode .pixel-corner.bottom-right {
    border-color: #81b881;
}

/* 响应式调整 */
@media (max-width: 768px) {
    h1 {
        font-size: 1.5rem;
    }

    .frames-container {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .upload-label,
    .generate-sprite-button {
        padding: 0.6rem 1.2rem;
        font-size: 0.7rem;
    }
}