:root {
    --gem-size: 50px;
    --grid-padding: 15px;
    --grid-width: calc(8 * 50px );  /* 6列宝石 + 5个间隔 + 内边距 */
    --grid-height: calc(10 * 50px ); /* 8行宝石 + 7个间隔 + 内边距 */
    --background-color: #1a2634;
    --background-end: #2c3e50;
    --container-color: #34495e;
    --text-color: #ecf0f1;
    --score-highlight: #2ecc71;
    --combo-text: #f1c40f;
}

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

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--background-color) 0%, var(--background-end) 100%);
    padding: 20px;
}

.game-container {
    background: linear-gradient(145deg, #2c3e50, #34495e);
    padding: 25px;
    border-radius: 15px;
    box-shadow: 
        0 0 50px rgba(0,0,0,0.3),
        inset 0 0 30px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    max-width: 100%;
    max-height: 100vh;
    overflow: hidden;
}

.score {
    color: #ecf0f1;
    font-size: 28px;
    margin-bottom: 25px;
    text-align: center;
    text-shadow: 0 0 10px rgba(255,255,255,0.3);
    font-family: 'Arial', sans-serif;
    letter-spacing: 2px;
}

.score-update {
    transform: scale(1.2);
    color: #2ecc71;
    text-shadow: 0 0 10px rgba(46,204,113,0.5);
}

.score-points {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    color: #f1c40f;
    font-size: 18px;
    animation: pointsFloat 0.8s ease-out forwards;
    opacity: 0;
}

@keyframes pointsFloat {
    0% {
        transform: translate(-50%, 0);
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -30px);
        opacity: 0;
    }
}

/* 添加连锁反应提示 */
.chain-reaction {
    position: absolute;
    color: #f1c40f;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(0,0,0,0.5);
    animation: floatUp 1s ease-out forwards;
}

@keyframes floatUp {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(-50px);
        opacity: 0;
    }
}

.grid {
    position: relative;
    width: var(--grid-width);
    height: var(--grid-height);
    background: linear-gradient(135deg, var(--background-color) 0%, var(--background-end) 100%);
    padding: var(--grid-padding);
    border-radius: 15px;
    box-shadow: 
        inset 0 0 60px rgba(0,0,0,0.6),
        0 0 40px rgba(0,0,0,0.4);
    perspective: 1000px;
    overflow: hidden;
}

.grid::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px) 0 0 / var(--gem-size) var(--gem-size),
        linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px) 0 0 / var(--gem-size) var(--gem-size),
        radial-gradient(circle at 50% 50%, rgba(255,255,255,0.1) 0%, transparent 60%);
    pointer-events: none;
}

.gem {
    width: var(--gem-size);
    height: var(--gem-size);
    border-radius: 12px;
    cursor: pointer;
    position: absolute;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backface-visibility: hidden;
    overflow: hidden;
    transform-style: preserve-3d;
    box-shadow: 
        inset 0 0 20px rgba(255,255,255,0.8),
        inset 0 0 8px rgba(255,255,255,0.9),
        0 4px 12px rgba(0,0,0,0.6);
    border: 2px solid rgba(255,255,255,0.3);
    background-image: linear-gradient(
        135deg,
        rgba(255,255,255,0.4) 0%,
        rgba(255,255,255,0.1) 50%,
        rgba(255,255,255,0.2) 100%
    );
}

.gem::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        circle at 30% 30%,
        rgba(255,255,255,0.4) 0%,
        rgba(255,255,255,0.1) 30%,
        rgba(255,255,255,0) 70%
    );
    filter: blur(1px);
    z-index: 1;
}

.gem::after {
    content: '';
    position: absolute;
    top: -150%;
    left: -150%;
    width: 400%;
    height: 400%;
    background: linear-gradient(
        45deg,
        rgba(255,255,255,0) 0%,
        rgba(255,255,255,0.1) 25%,
        rgba(255,255,255,0.4) 50%,
        rgba(255,255,255,0.1) 75%,
        rgba(255,255,255,0) 100%
    );
    transform: rotate(45deg);
    animation: shine 4s infinite linear;
    z-index: 2;
    pointer-events: none;
}

.gem:hover {
    transform: scale(1.1) translateZ(15px);
    box-shadow: 
        inset 0 0 25px rgba(255,255,255,0.8),
        inset 0 0 12px rgba(255,255,255,0.9),
        0 6px 20px rgba(0,0,0,0.6),
        0 0 15px currentColor;
    filter: brightness(1.2);
}

.gem.selected {
    transform: scale(1.15) translateZ(25px);
    box-shadow: 
        inset 0 0 30px rgba(255,255,255,0.9),
        inset 0 0 15px rgba(255,255,255,1),
        0 0 25px currentColor,
        0 8px 25px rgba(0,0,0,0.7);
    filter: brightness(1.3);
    z-index: 10;
}

.gem.matched {
    animation: 
        cyberpop 0.5s ease-out,
        cyberglow 0.5s ease-in-out;
}

@keyframes cyberpop {
    0% { 
        transform: scale(1) translateZ(0) rotate(0deg);
        filter: brightness(1);
    }
    50% { 
        transform: scale(1.3) translateZ(40px) rotate(180deg);
        filter: brightness(1.5);
        opacity: 0.8;
    }
    100% { 
        transform: scale(0) translateZ(-60px) rotate(360deg);
        filter: brightness(2);
        opacity: 0;
    }
}

@keyframes cyberglow {
    0% { 
        filter: brightness(1) blur(0) hue-rotate(0deg);
        box-shadow: 0 0 0 transparent;
    }
    50% { 
        filter: brightness(2) blur(4px) hue-rotate(180deg);
        box-shadow: 
            0 0 40px currentColor,
            0 0 80px currentColor,
            0 0 120px currentColor;
    }
    100% { 
        filter: brightness(0) blur(8px) hue-rotate(360deg);
        box-shadow: 0 0 0 transparent;
    }
}

/* 添加闪光效果 */
.gem::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        rgba(255,255,255,0) 0%,
        rgba(255,255,255,0.1) 50%,
        rgba(255,255,255,0) 100%
    );
    transform: rotate(45deg);
    animation: shine 2s infinite;
    pointer-events: none;
}

@keyframes shine {
    0% { transform: translateX(-100%) rotate(45deg); }
    100% { transform: translateX(100%) rotate(45deg); }
}

/* 连锁反应效果 */
.chain-combo {
    position: absolute;
    font-size: 32px;
    font-weight: bold;
    color: #f1c40f;
    text-shadow: 
        0 0 10px rgba(241,196,15,0.5),
        0 0 20px rgba(241,196,15,0.3);
    animation: comboFloat 1s ease-out forwards;
    z-index: 100;
}

@keyframes comboFloat {
    0% {
        transform: scale(0.5) translateY(0);
        opacity: 0;
    }
    20% {
        transform: scale(1.2) translateY(-10px);
        opacity: 1;
    }
    100% {
        transform: scale(1) translateY(-50px);
        opacity: 0;
    }
} 

/* 添加响应式支持 */
@media (max-height: 800px) {
    :root {
        --gem-size: 45px;
    }
}

@media (max-height: 700px) {
    :root {
        --gem-size: 40px;
    }
}

@media (max-width: 500px) {
    :root {
        --gem-size: 35px;
        --grid-padding: 10px;
    }
    
    .game-container {
        padding: 15px;
    }
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.timer {
    color: var(--text-color);
    font-size: 28px;
    text-align: center;
    text-shadow: 0 0 10px rgba(255,255,255,0.3);
    font-family: 'Arial', sans-serif;
    letter-spacing: 2px;
}

.timer.warning {
    color: var(--time-warning);
    animation: pulse 1s infinite;
}

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

.time-bonus {
    position: absolute;
    color: var(--score-highlight);
    font-size: 20px;
    font-weight: bold;
    animation: timeBonus 1s ease-out forwards;
    pointer-events: none;
}

@keyframes timeBonus {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 0;
    }
    20% {
        transform: translateY(-10px) scale(1.2);
        opacity: 1;
    }
    100% {
        transform: translateY(-30px) scale(1);
        opacity: 0;
    }
}

.level-info {
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-color);
}

.level-title {
    font-size: 32px;
    margin-bottom: 5px;
    text-shadow: 0 0 15px rgba(255,255,255,0.3);
}

.level-name {
    font-size: 20px;
    opacity: 0.8;
}

.score-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.target-score {
    color: var(--text-color);
    font-size: 20px;
    opacity: 0.8;
}

.progress-bar {
    width: 200px;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress {
    width: 0%;
    height: 100%;
    background: var(--progress-bar);
    transition: width 0.3s ease;
}

.level-complete {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, rgba(0,0,0,0.95) 0%, rgba(20,20,20,0.95) 100%);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    color: var(--level-complete);
    z-index: 1000;
    animation: levelComplete 0.5s ease-out;
    border: 2px solid rgba(255,255,255,0.1);
    box-shadow: 
        0 0 50px rgba(0,0,0,0.5),
        0 0 30px var(--level-complete);
    min-width: 300px;
}

.level-complete h2 {
    font-size: 36px;
    margin-bottom: 20px;
    text-shadow: 0 0 10px var(--level-complete);
    animation: glowText 2s infinite;
}

.level-complete p {
    font-size: 24px;
    margin-bottom: 30px;
    color: var(--text-color);
}

.level-complete .stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
}

.level-complete .stat-item {
    text-align: center;
}

.level-complete .stat-value {
    font-size: 28px;
    font-weight: bold;
    color: var(--score-highlight);
    margin-bottom: 5px;
}

.level-complete .stat-label {
    font-size: 16px;
    color: var(--text-color);
    opacity: 0.8;
}

.level-complete button {
    background: linear-gradient(45deg, #2ecc71, #27ae60);
    border: none;
    padding: 15px 40px;
    border-radius: 25px;
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(46,204,113,0.3);
}

.level-complete button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(46,204,113,0.4);
}

.level-complete button:active {
    transform: translateY(1px);
}

.level-complete .stars {
    margin-bottom: 30px;
}

.level-complete .star {
    font-size: 40px;
    color: #ffd700;
    margin: 0 5px;
    animation: starPop 0.5s ease-out backwards;
}

@keyframes starPop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes glowText {
    0% { text-shadow: 0 0 10px var(--level-complete); }
    50% { text-shadow: 0 0 20px var(--level-complete), 0 0 30px var(--level-complete); }
    100% { text-shadow: 0 0 10px var(--level-complete); }
}

/* 添加烟花效果容器 */
.fireworks {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}