/* Connections Game Styles */
:root {
    /* Game-specific colors */
    --connections-primary: #6366f1;
    --connections-secondary: #8b5cf6;
    --connections-accent: #06b6d4;
    --connections-success: #10b981;
    --connections-warning: #f59e0b;
    --connections-danger: #ef4444;
    
    /* Category colors (NYT Connections inspired) */
    --category-yellow: #f9df6d;
    --category-yellow-dark: #ebc634;
    --category-green: #a0c35a;
    --category-green-dark: #7ea338;
    --category-blue: #b0c4ef;
    --category-blue-dark: #8ba6de;
    --category-purple: #ba81c5;
    --category-purple-dark: #9a63a5;
    
    /* Game dimensions */
    --word-card-height: 60px;
    --word-card-gap: 8px;
    --border-radius: 12px;
}

/* Game header */
.game-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.back-home-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--connections-primary);
    color: white;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.back-home-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.game-title {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--connections-primary), var(--connections-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.help-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--connections-accent);
    color: white;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}

.help-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.4);
}

/* Audio Control Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    font-size: 0.95rem;
}

.btn-secondary {
    background: var(--connections-accent);
    color: white;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.4);
}

.btn-secondary.disabled {
    opacity: 0.5;
    background: #9ca3af;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-icon {
    font-size: 1.1rem;
    line-height: 1;
}

/* Main game area */
.game-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-size: 200% 200%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

/* 背景渐变动画 */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* 背景漂浮粒子效果（可选） */
.game-main::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
    animation: floatingParticles 20s ease-in-out infinite;
    pointer-events: none;
}

@keyframes floatingParticles {
    0%, 100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateY(-20px) scale(1.1);
        opacity: 0.8;
    }
}

.game-description {
    text-align: center;
    margin-bottom: 2rem;
}

.game-description p {
    font-size: 1.2rem;
    color: white;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Welcome screen */
.welcome-screen {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.3) inset;
    border: 1px solid rgba(255, 255, 255, 0.2);
    opacity: 0;
    visibility: hidden;
    display: none; /* ensure hidden state truly removes from flow */
    transition: all 0.3s ease;
}

.welcome-screen.visible {
    opacity: 1;
    visibility: visible;
    display: block; /* ensure visible state shows */
}

.welcome-content {
    text-align: center;
}

.welcome-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--connections-primary), var(--connections-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-description {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 2rem;
    line-height: 1.6;
}

/* Difficulty selector */
.difficulty-selector {
    margin-bottom: 2rem;
}

.difficulty-selector h3 {
    color: #333;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.difficulty-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.difficulty-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid transparent;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.difficulty-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.difficulty-btn.active {
    border-color: var(--connections-primary);
    background: rgba(99, 102, 241, 0.1);
}

.difficulty-btn i {
    font-size: 2rem;
    color: var(--connections-primary);
}

.difficulty-btn span {
    font-weight: 600;
    color: #333;
}

.difficulty-btn small {
    color: #666;
    font-size: 0.85rem;
}

/* Game controls */
.game-controls {
    margin-bottom: 2rem;
}

.game-controls button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: var(--connections-success);
    color: white;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.game-controls button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* Welcome tabs */
.welcome-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid transparent;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    color: #666;
}

.tab-btn.active {
    border-color: var(--connections-accent);
    background: rgba(6, 182, 212, 0.1);
    color: var(--connections-accent);
}

.tab-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Tab content */
.tab-content {
    display: none;
    text-align: left;
}

.tab-content.active {
    display: block;
}

/* Game rules */
.game-rules h3 {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.game-rules ul {
    list-style: none;
    padding: 0;
    margin: 0 0 2rem 0;
}

.game-rules li {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    color: #555;
    line-height: 1.6;
    position: relative;
    padding-left: 2rem;
}

.game-rules li:before {
    content: '🧩';
    position: absolute;
    left: 0;
    top: 0.75rem;
}

.game-rules li:last-child {
    border-bottom: none;
}

/* High scores preview */
.high-scores-preview h3 {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.scores-display {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    transition: transform 0.3s ease;
}

.score-row:hover {
    transform: translateY(-2px);
}

.score-label {
    font-weight: 600;
    color: #333;
}

.score-value {
    font-weight: 700;
    color: var(--connections-primary);
    font-size: 1.1rem;
}

/* Achievements */
.achievements-container {
    text-align: center;
}

.achievements-progress {
    margin-bottom: 2rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--connections-primary), var(--connections-secondary));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    color: #666;
    font-weight: 600;
}

.achievements-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.achievement-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    transition: transform 0.3s ease;
    text-align: left;
}

.achievement-item:hover {
    transform: translateY(-2px);
}

.achievement-item.unlocked {
    background: rgba(16, 185, 129, 0.2);
    border: 2px solid var(--connections-success);
}

.achievement-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.1);
}

.achievement-details h4 {
    margin: 0 0 0.5rem 0;
    color: #333;
    font-size: 1rem;
}

.achievement-details p {
    margin: 0;
    color: #666;
    font-size: 0.9rem;
}

/* Statistics */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}

.stat-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    transition: transform 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
}

.stat-label {
    font-weight: 600;
    color: #333;
}

.stat-value {
    font-weight: 700;
    color: var(--connections-accent);
    font-size: 1.1rem;
}

/* Game board */
.game-board {
    display: none;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.3) inset;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.game-board.visible {
    display: block;
}

/* Game stats */
.game-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-box {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.stat-box:hover {
    transform: translateY(-4px);
}

.stat-title {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--connections-primary);
    line-height: 1;
    transition: all 0.3s ease;
}

/* 生命值减少动画 */
.stat-value.life-lost {
    animation: lifeLost 0.5s ease;
}

@keyframes lifeLost {
    0% {
        transform: scale(1);
        color: var(--connections-primary);
    }
    25% {
        transform: scale(1.3);
        color: var(--connections-danger);
    }
    50% {
        transform: scale(0.9) rotate(-5deg);
    }
    75% {
        transform: scale(1.1) rotate(5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        color: var(--connections-danger);
    }
}

/* 分数增长滚动数字动画 */
.stat-value.score-increase {
    animation: scoreIncrease 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scoreIncrease {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.4);
        color: var(--connections-success);
    }
    100% {
        transform: scale(1);
    }
}

/* Game tools */
.game-tools {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--connections-accent);
    color: white;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}

.tool-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.4);
}

.tool-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.tool-btn i {
    font-size: 1.1rem;
}

/* Word grid container */
.word-grid-container {
    max-width: 600px;
    margin: 0 auto;
}

.word-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--word-card-gap);
    margin-bottom: 2rem;
}

.word-card {
    height: var(--word-card-height);
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #e5e7eb;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    text-align: center;
    padding: 0.5rem;
    position: relative;
    transform-style: preserve-3d;
    perspective: 1000px;
    /* 入场动画准备 */
    opacity: 0;
    transform: translateY(20px) rotateX(-10deg);
    animation: cardEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* 入场动画 - stagger效果通过nth-child实现 */
@keyframes cardEntrance {
    to {
        opacity: 1;
        transform: translateY(0) rotateX(0);
    }
}

.word-card:nth-child(1) { animation-delay: 0.05s; }
.word-card:nth-child(2) { animation-delay: 0.1s; }
.word-card:nth-child(3) { animation-delay: 0.15s; }
.word-card:nth-child(4) { animation-delay: 0.2s; }
.word-card:nth-child(5) { animation-delay: 0.25s; }
.word-card:nth-child(6) { animation-delay: 0.3s; }
.word-card:nth-child(7) { animation-delay: 0.35s; }
.word-card:nth-child(8) { animation-delay: 0.4s; }
.word-card:nth-child(9) { animation-delay: 0.45s; }
.word-card:nth-child(10) { animation-delay: 0.5s; }
.word-card:nth-child(11) { animation-delay: 0.55s; }
.word-card:nth-child(12) { animation-delay: 0.6s; }
.word-card:nth-child(13) { animation-delay: 0.65s; }
.word-card:nth-child(14) { animation-delay: 0.7s; }
.word-card:nth-child(15) { animation-delay: 0.75s; }
.word-card:nth-child(16) { animation-delay: 0.8s; }

/* 3D悬浮效果 */
.word-card:hover {
    transform: translateY(-6px) rotateX(5deg) scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15), 0 0 0 2px var(--connections-primary);
    border-color: var(--connections-primary);
    z-index: 10;
}

/* 选中状态 - 脉冲光圈动画 */
.word-card.selected {
    background: var(--connections-primary);
    color: white;
    border-color: var(--connections-primary);
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
    animation: selectedPulse 1.5s ease-in-out infinite;
}

@keyframes selectedPulse {
    0%, 100% {
        box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4), 0 0 0 0 rgba(99, 102, 241, 0.4);
    }
    50% {
        box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4), 0 0 0 8px rgba(99, 102, 241, 0);
    }
}

/* 正确匹配类 - 缩放+旋转动画 */
.word-card.correct-yellow {
    background: var(--category-yellow);
    border-color: var(--category-yellow-dark);
    color: #000;
    animation: correctMatch 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.word-card.correct-green {
    background: var(--category-green);
    border-color: var(--category-green-dark);
    color: #000;
    animation: correctMatch 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.word-card.correct-blue {
    background: var(--category-blue);
    border-color: var(--category-blue-dark);
    color: #000;
    animation: correctMatch 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.word-card.correct-purple {
    background: var(--category-purple);
    border-color: var(--category-purple-dark);
    color: #000;
    animation: correctMatch 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* 正确匹配动画 - 缩放+旋转+弹跳 */
@keyframes correctMatch {
    0% {
        transform: scale(1) rotate(0deg);
    }
    30% {
        transform: scale(1.15) rotate(5deg);
    }
    60% {
        transform: scale(0.95) rotate(-3deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

/* 增强shake错误动画 */
.word-card.shake {
    animation: enhancedShake 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes enhancedShake {
    0%, 100% { 
        transform: translateX(0) rotate(0deg); 
    }
    10%, 30%, 50%, 70%, 90% { 
        transform: translateX(-8px) rotate(-2deg);
        background: rgba(239, 68, 68, 0.1);
    }
    20%, 40%, 60%, 80% { 
        transform: translateX(8px) rotate(2deg);
        background: rgba(239, 68, 68, 0.1);
    }
}

/* Submit button */
.submit-btn {
    width: 100%;
    padding: 1rem 2rem;
    background: var(--connections-success);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    position: relative;
    overflow: hidden;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.submit-btn:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

.submit-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading spinner for submit button */
.submit-btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: btnSpinner 0.6s linear infinite;
    margin-left: 8px;
}

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

/* Solved groups */
.solved-groups {
    margin-top: 2rem;
}

.solved-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
    transition: transform 0.3s ease;
}

.solved-group:hover {
    transform: translateY(-2px);
}

.solved-group.yellow {
    background: var(--category-yellow);
    border: 2px solid var(--category-yellow-dark);
}

.solved-group.green {
    background: var(--category-green);
    border: 2px solid var(--category-green-dark);
}

.solved-group.blue {
    background: var(--category-blue);
    border: 2px solid var(--category-blue-dark);
}

.solved-group.purple {
    background: var(--category-purple);
    border: 2px solid var(--category-purple-dark);
}

.group-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: #000;
    min-width: 120px;
}

.group-words {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 1;
}

.group-word {
    padding: 0.25rem 0.75rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
}

/* Game message */
.game-message {
    text-align: center;
    margin: 1rem 0;
    padding: 1rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.game-message.visible {
    opacity: 1;
    visibility: visible;
}

.game-message.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--connections-success);
    border: 2px solid var(--connections-success);
}

.game-message.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--connections-danger);
    border: 2px solid var(--connections-danger);
}

.game-message.info {
    background: rgba(6, 182, 212, 0.1);
    color: var(--connections-accent);
    border: 2px solid var(--connections-accent);
}

/* Game overlays */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 10;
}

.game-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.overlay-content {
    text-align: center;
    color: white;
    max-width: 400px;
    padding: 2rem;
}

.overlay-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--connections-primary), var(--connections-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.overlay-score {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--connections-warning);
}

.overlay-level {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    color: #ccc;
}

.overlay-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.overlay-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: var(--connections-primary);
    color: white;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.overlay-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.overlay-btn.share-btn {
    background: var(--connections-success);
}

.overlay-btn.share-btn:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.overlay-btn.primary {
    background: linear-gradient(135deg, var(--connections-primary), var(--connections-secondary));
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.overlay-btn.primary:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

/* 难度完成提示界面 */
.difficulty-complete-modal {
    z-index: 1000;
}

.difficulty-complete-content {
    max-width: 500px;
    padding: 3rem 2rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.9));
    backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    animation: modalBounceIn 0.5s ease-out;
}

@keyframes modalBounceIn {
    0% {
        opacity: 0;
        transform: scale(0.7) translateY(-50px);
    }
    50% {
        transform: scale(1.05) translateY(0);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.complete-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: celebrationBounce 1s ease-in-out infinite;
}

@keyframes celebrationBounce {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.2) rotate(-10deg);
    }
    75% {
        transform: scale(1.2) rotate(10deg);
    }
}

.complete-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #f59e0b, #ef4444, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.complete-message {
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.complete-question {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 2rem;
    font-weight: 500;
}

/* Mobile controls */
.mobile-controls {
    display: none;
    margin-top: 2rem;
    text-align: center;
}

.mobile-instructions {
    color: #666;
    font-weight: 500;
}

.mobile-instructions p {
    margin: 0;
}

/* Game instructions */
.game-instructions {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    margin-top: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.game-instructions h3 {
    color: #333;
    margin-bottom: 2rem;
    font-size: 1.5rem;
    text-align: center;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.feature-item {
    text-align: center;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 16px;
    transition: transform 0.3s ease;
}

.feature-item:hover {
    transform: translateY(-5px);
}

.feature-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 1rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--connections-primary);
}

.feature-item h4 {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.feature-item p {
    color: #666;
    line-height: 1.6;
    margin: 0;
}

/* Help modal */
.help-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.help-modal.visible {
    opacity: 1;
    visibility: visible;
}

.help-content {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    margin: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.help-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    transition: color 0.3s ease;
}

.help-close:hover {
    color: var(--connections-primary);
}

.help-title {
    color: var(--connections-primary);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.help-section {
    margin-bottom: 2rem;
}

.help-section h4 {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.help-section p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.help-section ul {
    color: #666;
    line-height: 1.6;
    padding-left: 1.5rem;
}

.help-section li {
    margin-bottom: 0.5rem;
}

.help-section strong {
    color: var(--connections-primary);
}

/* Share modal */
.share-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.share-modal.visible {
    opacity: 1;
    visibility: visible;
}

.share-content {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    max-width: 400px;
    position: relative;
    margin: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.share-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    transition: color 0.3s ease;
}

.share-close:hover {
    color: var(--connections-primary);
}

.share-title {
    color: var(--connections-primary);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.share-result {
    color: #666;
    margin-bottom: 2rem;
    font-size: 1.1rem;
    line-height: 1.6;
}

.share-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.share-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
}

.share-btn.twitter {
    background: #1da1f2;
}

.share-btn.facebook {
    background: #4267b2;
}

.share-btn.whatsapp {
    background: #25d366;
}

.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Achievement notification */
.achievement-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 16px;
    padding: 1rem 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    border-left: 4px solid var(--connections-success);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 1001;
    max-width: 300px;
}

.achievement-notification.visible {
    transform: translateX(0);
}

.achievement-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.achievement-icon {
    font-size: 2rem;
}

.achievement-text {
    flex: 1;
}

.achievement-title {
    font-weight: 700;
    color: var(--connections-success);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.achievement-name {
    color: #333;
    font-size: 1rem;
    font-weight: 600;
}

/* Responsive design */
@media (max-width: 768px) {
    .header-content {
        padding: 0 1rem;
    }
    
    .back-home-btn span,
    .help-btn span {
        display: none;
    }
    
    .game-title {
        font-size: 1.5rem;
    }
    
    .game-main {
        padding: 1rem;
    }
    
    .welcome-title {
        font-size: 2rem;
    }
    
    .difficulty-buttons {
        grid-template-columns: 1fr;
    }
    
    .game-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .game-tools {
        grid-template-columns: repeat(2, 1fr);
        display: grid;
    }
    
    .tool-btn span {
        display: none;
    }
    
    .word-grid {
        gap: 6px;
    }
    
    .word-card {
        height: 50px;
        font-size: 0.8rem;
        padding: 0.25rem;
    }
    
    .overlay-content {
        padding: 1rem;
    }
    
    .overlay-title {
        font-size: 2rem;
    }
    
    .overlay-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .mobile-controls {
        display: block;
    }
    
    .feature-grid {
        grid-template-columns: 1fr;
    }
    
    .scores-display {
        grid-template-columns: 1fr;
    }
    
    .stats-container {
        grid-template-columns: 1fr;
    }
    
    .help-content,
    .share-content {
        margin: 0.5rem;
        padding: 1.5rem;
    }
    
    .share-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .achievement-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        transform: translateY(-100px);
    }
    
    .achievement-notification.visible {
        transform: translateY(0);
    }
}

@media (max-width: 480px) {
    .game-stats {
        grid-template-columns: 1fr;
    }
    
    .stat-box {
        padding: 1rem;
    }
    
    .welcome-screen,
    .game-board,
    .game-instructions {
        padding: 1rem;
    }
    
    .overlay-content {
        padding: 0.5rem;
    }
    
    .overlay-title {
        font-size: 1.5rem;
    }
    
    .welcome-tabs {
        flex-direction: column;
        align-items: center;
    }
    
    .word-card {
        height: 45px;
        font-size: 0.75rem;
    }
}

/* Animation classes */
@keyframes correctGroup {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.correct-group-animation {
    animation: correctGroup 0.5s ease;
}

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

.wrong-guess-animation {
    animation: wrongGuess 0.5s ease;
}

/* Performance optimizations */
.game-board,
.game-overlay,
.help-modal,
.share-modal,
.achievement-notification {
    will-change: transform, opacity;
}

.word-card {
    will-change: transform;
}

/* ===== Particle System Canvas ===== */
.particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* ===== Next Puzzle Button & Progress ===== */
.overlay-progress {
    font-size: 0.95rem;
    color: #666;
    margin: 0.5rem 0 1rem 0;
    font-weight: 600;
}

.overlay-btn.primary {
    background: linear-gradient(135deg, var(--connections-success), #059669);
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    animation: pulseGlow 2s ease-in-out infinite;
}

.overlay-btn.primary:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.5);
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    }
    50% {
        box-shadow: 0 6px 20px rgba(16, 185, 129, 0.6), 0 0 0 4px rgba(16, 185, 129, 0.2);
    }
}
