/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: #0a0a0f;
    color: #ffffff;
    min-height: 100vh;
    line-height: 1.6;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

/* 星空粒子背景 */
#starCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.container {
    max-width: 420px;
    margin: 0 auto;
    padding: 40px 20px 60px;
    position: relative;
    z-index: 1;
}

/* 首页入场动画 */
.header {
    animation: headerFadeIn 0.8s ease forwards;
}

@keyframes headerFadeIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.invite-card {
    animation: cardFadeIn 0.6s ease 0.2s both;
}

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.city-section {
    animation: cardFadeIn 0.6s ease 0.4s both;
}

/* 头部标题样式 */
.header {
    text-align: center;
    margin-bottom: 40px;
}

.main-title {
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 14px;
    color: #9ca3af;
    letter-spacing: 1px;
}

/* 邀请码卡片样式 */
.invite-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 28px 24px;
    margin-bottom: 40px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    text-align: center;
    color: #f87171;
    font-size: 14px;
    display: none;
}

.error-message.show {
    display: block;
}

.error-message.locked {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.5);
}

.input-section {
    margin-bottom: 20px;
}

.input-label {
    display: block;
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 10px;
}

.invite-input {
    width: 100%;
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 14px 16px;
    font-size: 16px;
    color: #1a1a2e;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    letter-spacing: 2px;
    text-align: center;
}

.invite-input::placeholder {
    color: #9ca3af;
    letter-spacing: 0;
    font-size: 14px;
}

.invite-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.invite-input.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.invite-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.submit-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 16px;
}

.submit-btn:hover {
    background: linear-gradient(135deg, #5a72d4 0%, #6a4196 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.submit-btn:active {
    transform: translateY(0);
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.get-code-link {
    display: block;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
    text-decoration: none;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    transition: all 0.3s ease;
}

.get-code-link:hover {
    color: #667eea;
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

/* 城市列表区域 */
.city-section {
    margin-bottom: 40px;
}

.section-title {
    text-align: center;
    font-size: 13px;
    color: #9ca3af;
    margin-bottom: 20px;
    letter-spacing: 1px;
}

.city-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.city-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    transition: all 0.3s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.city-card:hover {
    border-color: #c7d2fe;
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.city-info {
    flex: 1;
}

.city-name {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 4px;
}

.city-name .country {
    font-size: 12px;
    font-weight: 400;
    color: #6b7280;
    margin-left: 8px;
}

.city-tags {
    font-size: 12px;
    color: #6b7280;
}

.city-match {
    font-size: 14px;
    color: #667eea;
    font-weight: 500;
    font-family: 'Courier New', monospace;
}

.refresh-btn {
    display: block;
    margin: 0 auto 20px;
    background: transparent;
    border: none;
    color: #9ca3af;
    font-size: 14px;
    cursor: pointer;
    padding: 8px 16px;
    transition: color 0.3s ease;
}

.refresh-btn:hover {
    color: #667eea;
}

.share-text {
    text-align: center;
    font-size: 13px;
    color: #9ca3af;
}

.share-link {
    color: #667eea;
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.3s ease;
}

.share-link:hover {
    color: #5a72d4;
}

/* 底部样式 */
.footer {
    text-align: center;
    padding-top: 40px;
}

.footer-decoration {
    width: 60px;
    height: 1px;
    background: linear-gradient(90deg, transparent, #3a3a4a, transparent);
    margin: 0 auto 20px;
}

.footer-text {
    font-size: 12px;
    color: #6b7280;
    letter-spacing: 2px;
}

/* 弹窗样式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 360px;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-overlay.show .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
}

.modal-close {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: #1a1a2e;
}

.modal-input {
    width: 100%;
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    color: #1a1a2e;
    outline: none;
    margin-bottom: 16px;
}

.modal-input:focus {
    border-color: #667eea;
}

.modal-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* 动画效果 */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.city-card {
    animation: fadeIn 0.4s ease-out forwards;
}

.city-card:nth-child(1) { animation-delay: 0.05s; }
.city-card:nth-child(2) { animation-delay: 0.1s; }
.city-card:nth-child(3) { animation-delay: 0.15s; }
.city-card:nth-child(4) { animation-delay: 0.2s; }
.city-card:nth-child(5) { animation-delay: 0.25s; }
.city-card:nth-child(6) { animation-delay: 0.3s; }

/* 响应式调整 */
@media (max-width: 380px) {
    .container {
        padding: 30px 16px 50px;
    }
    
    .main-title {
        font-size: 28px;
    }
    
    .invite-card {
        padding: 24px 20px;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #0a0a0f;
}

::-webkit-scrollbar-thumb {
    background: #3a3a4a;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5a5a6a;
}

/* ===== 页面加载遮罩 ===== */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0a0a0f;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.page-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-content {
    text-align: center;
}

.loader-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(102, 126, 234, 0.2);
    border-top-color: #667eea;
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-text {
    font-size: 14px;
    color: #9ca3af;
    letter-spacing: 1px;
}

/* ===== 页面跳转过渡动画 ===== */
body {
    opacity: 1;
    transition: opacity 0.3s ease;
}

body.page-leaving {
    opacity: 0;
    transform: scale(0.98);
    transition: opacity 0.3s ease, transform 0.3s ease;
}
