:root {
    --primary-color: #E91E8C;
    --secondary-color: #9B59B6;
    --success-color: #2ECC71;
    --warning-color: #F39C12;
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --board-bg: #E8E8F0;
    --shadow-color: rgba(0, 0, 0, 0.15);
    --card-bg: rgba(233, 30, 140, 0.9);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    user-select: none;
}

/* 背景粒子 */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: float 8s infinite ease-in-out;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100vh) translateX(50px);
        opacity: 0;
    }
}

/* 游戏容器 */
.game-container {
    position: relative;
    z-index: 2;
    background: white;
    border-radius: 30px;
    padding: 25px;
    box-shadow: 0 20px 80px rgba(102, 126, 234, 0.4);
    max-width: 650px;
    width: 95%;
    margin: 20px auto;
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 头部 */
.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.logo h1 {
    font-size: 2.2em;
    background: linear-gradient(135deg, #E91E8C, #9B59B6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 900;
    margin-bottom: 20px;
    animation: pulse 2s infinite;
    letter-spacing: 2px;
}

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

.game-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.info-item {
    background: linear-gradient(135deg, var(--card-bg), #9B59B6);
    padding: 12px 15px;
    border-radius: 15px;
    color: white;
    box-shadow: 0 4px 15px rgba(233, 30, 140, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.3s ease;
    white-space: nowrap;
}

.info-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(233, 30, 140, 0.5);
}

.info-label {
    font-size: 0.85em;
    opacity: 0.95;
    margin-bottom: 5px;
    font-weight: 600;
    white-space: nowrap;
}

.info-value {
    font-size: 1.5em;
    font-weight: 900;
    white-space: nowrap;
}

/* 游戏棋盘 */
.game-board-wrapper {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto 20px;
    aspect-ratio: 1;
}

#gameBoard {
    width: 100%;
    height: 100%;
    border-radius: 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8e8f0 100%);
    box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    touch-action: none;
}

.effects-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* 控制按钮 */
.game-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px var(--shadow-color);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn span {
    position: relative;
    z-index: 1;
}

.btn-primary {
    background: linear-gradient(135deg, #E91E8C, #9B59B6);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(233, 30, 140, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #3498DB, #2980B9);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(52, 152, 219, 0.4);
}

.btn-info {
    background: linear-gradient(135deg, #2ECC71, #27AE60);
    color: white;
}

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

.btn-large {
    padding: 18px 40px;
    font-size: 1.2em;
}

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

/* 道具栏 */
.power-ups {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.power-up {
    background: linear-gradient(135deg, #FFF5E1 0%, #FFE4B5 100%);
    border-radius: 20px;
    padding: 18px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    border: 3px solid transparent;
}

.power-up:hover {
    transform: translateY(-8px) scale(1.08);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.15);
    border-color: var(--primary-color);
}

.power-up.active {
    animation: glow 1s infinite;
    border: 3px solid var(--primary-color);
    background: linear-gradient(135deg, #FFE4E1 0%, #FFD1DC 100%);
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 15px var(--primary-color), 0 4px 15px rgba(0, 0, 0, 0.1);
    }
    50% {
        box-shadow: 0 0 30px var(--primary-color), 0 8px 25px rgba(0, 0, 0, 0.15);
    }
}

.power-up-icon {
    font-size: 2.5em;
    margin-bottom: 5px;
}

.power-up-count {
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9em;
}

.power-up-name {
    font-size: 0.9em;
    font-weight: bold;
    color: #555;
}

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

.modal.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    animation: scaleIn 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-content h2 {
    background: linear-gradient(135deg, #E91E8C, #9B59B6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 25px;
    font-size: 2.2em;
    font-weight: 900;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #999;
    transition: color 0.3s ease;
}

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

/* 开始游戏模态框 */
.game-preview {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 30px 0;
    font-size: 2em;
}

.preview-gem {
    animation: bounce 1s infinite;
}

.preview-gem:nth-child(1) { animation-delay: 0s; }
.preview-gem:nth-child(2) { animation-delay: 0.1s; }
.preview-gem:nth-child(3) { animation-delay: 0.2s; }
.preview-gem:nth-child(4) { animation-delay: 0.3s; }
.preview-gem:nth-child(5) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

.game-rules-brief {
    text-align: left;
    margin: 25px 0;
    padding: 25px;
    background: linear-gradient(135deg, #FFF5E1 0%, #FFE4B5 100%);
    border-radius: 20px;
    border: 3px solid #FFD700;
}

.game-rules-brief h3 {
    background: linear-gradient(135deg, #E91E8C, #9B59B6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 15px;
    font-weight: 800;
}

.game-rules-brief ul {
    list-style: none;
    padding: 0;
}

.game-rules-brief li {
    margin: 10px 0;
    font-size: 1em;
    line-height: 1.6;
}

/* 胜利模态框 */
.stars {
    font-size: 3em;
    margin: 20px 0;
    animation: starShine 1s infinite;
}

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

.win-stats, .lose-stats {
    background: linear-gradient(135deg, #FFF5E1 0%, #FFE4B5 100%);
    border-radius: 20px;
    padding: 25px;
    margin: 25px 0;
    border: 3px solid #FFD700;
}

.win-stats p, .lose-stats p {
    font-size: 1.2em;
    margin: 12px 0;
    font-weight: 700;
}

.win-stats span, .lose-stats span {
    color: #E91E8C;
    font-weight: 900;
}

/* 规则模态框 */
.rules-modal {
    position: relative;
}

.rules-content {
    text-align: left;
    max-height: 400px;
    overflow-y: auto;
}

.rules-content section {
    margin-bottom: 20px;
}

.rules-content h3 {
    background: linear-gradient(135deg, #E91E8C, #9B59B6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    font-weight: 800;
}

.rules-content ul {
    margin-left: 20px;
}

.rules-content li {
    margin: 8px 0;
    line-height: 1.6;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

/* 组合提示 */
.combo-text {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3.5em;
    font-weight: 900;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    pointer-events: none;
    z-index: 999;
    opacity: 0;
    animation: comboAppear 1s ease-out;
}

@keyframes comboAppear {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* 响应式设计 - 手机端 */
@media (max-width: 768px) {
    .game-container {
        padding: 15px;
        width: 100%;
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .logo h1 {
        font-size: 1.6em;
    }

    .game-info {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }

    .info-item {
        padding: 8px 10px;
    }

    .info-label {
        font-size: 0.7em;
    }

    .info-value {
        font-size: 1.2em;
    }

    .game-board-wrapper {
        flex: 1;
        max-width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .game-controls {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .btn {
        padding: 10px 15px;
        font-size: 0.9em;
    }

    .power-ups {
        gap: 10px;
    }

    .power-up {
        padding: 10px;
    }

    .power-up-icon {
        font-size: 2em;
    }

    .modal-content {
        padding: 30px 20px;
        width: 95%;
    }

    .modal-content h2 {
        font-size: 1.5em;
    }

    .game-preview {
        font-size: 1.5em;
        gap: 8px;
    }

    .combo-text {
        font-size: 2em;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 1.3em;
    }

    .info-label {
        font-size: 0.7em;
    }

    .info-value {
        font-size: 1em;
    }

    .btn {
        padding: 8px 12px;
        font-size: 0.85em;
    }

    .power-up-icon {
        font-size: 1.8em;
    }

    .power-up-name {
        font-size: 0.8em;
    }
}

/* 触摸反馈 */
@media (hover: none) {
    .btn:active {
        transform: scale(0.95);
    }

    .power-up:active {
        transform: scale(0.95);
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}