/* 喵趣消消乐 - 样式文件 */

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

:root {
    --primary-color: #FF6B9D;
    --secondary-color: #88D8E8;
    --accent-color: #FFD93D;
    --bg-gradient-start: #FFE5EC;
    --bg-gradient-end: #E8F4F8;
    --card-bg: rgba(255, 255, 255, 0.9);
    --shadow-color: rgba(255, 107, 157, 0.3);
    --text-color: #5D4E60;
    --text-light: #8B7B8E;
}

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    user-select: none;
}

/* 游戏容器 */
#game-container {
    width: 100%;
    max-width: 420px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* 顶部信息栏 */
#header {
    width: 100%;
    background: var(--card-bg);
    border-radius: 20px;
    padding: 15px 20px;
    box-shadow: 0 4px 15px var(--shadow-color);
}

.score-panel {
    display: flex;
    justify-content: space-around;
    margin-bottom: 10px;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-item .label {
    font-size: 12px;
    color: var(--text-light);
}

.score-item .value {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
}

.target-panel {
    text-align: center;
    padding: 8px;
    background: linear-gradient(90deg, #FFE5EC, #E8F4F8);
    border-radius: 10px;
    font-size: 14px;
    color: var(--text-color);
}

.target-cat {
    display: inline-block;
    width: 24px;
    height: 24px;
    vertical-align: middle;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
}

/* 游戏棋盘 */
#board-container {
    position: relative;
    background: var(--card-bg);
    border-radius: 20px;
    padding: 10px;
    box-shadow: 0 4px 20px var(--shadow-color);
}

#game-board {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 4px;
    width: 340px;
    height: 450px;
}

.cell {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    background: linear-gradient(145deg, #f0f0f0, #e6e6e6);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
    overflow: hidden;
}

.cell:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255, 107, 157, 0.4);
}

.cell.selected {
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--primary-color);
    animation: pulse 0.5s ease infinite alternate;
}

@keyframes pulse {
    from { box-shadow: 0 0 10px var(--primary-color); }
    to { box-shadow: 0 0 25px var(--primary-color); }
}

.cell.hint {
    animation: hint-glow 0.8s ease infinite;
}

@keyframes hint-glow {
    0%, 100% { box-shadow: 0 0 5px var(--accent-color); }
    50% { box-shadow: 0 0 20px var(--accent-color); }
}

.cat {
    width: 90%;
    height: 90%;
    border-radius: 50%;
    object-fit: cover;
    transition: transform 0.2s ease;
    pointer-events: none;
}

.cell:active .cat {
    transform: scale(0.9);
}

/* 消除动画 */
.cell.matched {
    animation: match-pop 0.4s ease forwards;
}

@keyframes match-pop {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.8; }
    100% { transform: scale(0); opacity: 0; }
}

/* 下落动画 */
.cell.falling .cat {
    animation: fall-in 0.3s ease;
}

@keyframes fall-in {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* 交换动画 */
.cell.swapping {
    transition: transform 0.2s ease;
}

/* 特效层 */
#effects-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    border-radius: 20px;
}

.particle {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    pointer-events: none;
    animation: particle-fly 0.8s ease-out forwards;
}

@keyframes particle-fly {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

/* 道具栏 */
#items-bar {
    width: 100%;
    display: flex;
    justify-content: space-around;
    background: var(--card-bg);
    border-radius: 15px;
    padding: 10px 15px;
    box-shadow: 0 4px 15px var(--shadow-color);
}

.item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 15px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.item:hover {
    background: linear-gradient(145deg, #FFE5EC, #E8F4F8);
    transform: translateY(-2px);
}

.item.active {
    background: var(--primary-color);
    box-shadow: 0 4px 15px var(--shadow-color);
}

.item.active .item-icon,
.item.active .item-count {
    color: white;
}

.item-icon {
    font-size: 28px;
    line-height: 1;
}

.item-count {
    font-size: 12px;
    font-weight: bold;
    color: var(--text-color);
    background: var(--accent-color);
    padding: 2px 8px;
    border-radius: 10px;
    margin-top: 4px;
}

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

/* 底部按钮 */
#footer {
    width: 100%;
    display: flex;
    gap: 10px;
}

.btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 15px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: 0 4px 15px var(--shadow-color);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow-color);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #FF8FAB);
    color: white;
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 25px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 320px;
    width: 90%;
}

.modal-content h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 24px;
}

.modal-content p {
    color: var(--text-color);
    margin-bottom: 10px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-buttons .btn {
    flex: 1;
}

/* 星级评分 */
.star-rating {
    font-size: 36px;
    margin: 15px 0;
}

.star {
    opacity: 0.3;
    transition: all 0.3s ease;
}

.star.active {
    opacity: 1;
    animation: star-pop 0.5s ease;
}

@keyframes star-pop {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* 连击提示 */
#combo-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: bold;
    color: var(--primary-color);
    text-shadow: 0 0 20px rgba(255, 107, 157, 0.8);
    z-index: 500;
    pointer-events: none;
    animation: combo-pop 0.6s ease;
}

#combo-display.hidden {
    display: none;
}

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

/* 响应式适配 */
@media (max-width: 420px) {
    #game-board {
        width: calc(100vw - 40px);
        height: calc((100vw - 40px) * 4 / 3);
    }
    
    .score-item .value {
        font-size: 20px;
    }
    
    .item-icon {
        font-size: 24px;
    }
}

/* 障碍物样式 */
.cell.obstacle-can {
    background: linear-gradient(145deg, #FFD93D, #FFA500);
}

.cell.obstacle-yarn {
    background: linear-gradient(145deg, #FFB6C1, #FF69B4);
}

.cell.obstacle-sleep {
    background: linear-gradient(145deg, #B8E6CF, #98D8AA);
}

.cell.obstacle-food {
    background: linear-gradient(145deg, #D4A574, #C4956A);
}

/* 特殊猫咪样式 */
.cell.special-paw::after {
    content: '🐾';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 12px;
}

.cell.special-bow::after {
    content: '🎀';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 12px;
}

.cell.special-crown::after {
    content: '👑';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 12px;
}

/* 炸弹选择模式 */
#game-board.bomb-mode .cell {
    cursor: crosshair;
}

#game-board.bomb-mode .cell.bomb-target {
    box-shadow: 0 0 15px #FF4444;
    background: rgba(255, 68, 68, 0.3);
}

/* ─── 音效/震动控制按钮 ─── */
.settings-btns {
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: center;
    align-items: center;
}

.setting-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(145deg, #fff0f5, #ffe8f0);
    box-shadow: 0 2px 8px rgba(255, 107, 157, 0.25),
                inset 0 1px 2px rgba(255, 255, 255, 0.9);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.setting-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.6), transparent 60%);
    pointer-events: none;
}

.setting-btn:hover {
    transform: scale(1.12) translateY(-1px);
    box-shadow: 0 4px 14px rgba(255, 107, 157, 0.4),
                inset 0 1px 2px rgba(255, 255, 255, 0.9);
}

.setting-btn:active {
    transform: scale(0.9);
    box-shadow: 0 1px 4px rgba(255, 107, 157, 0.2);
}

/* 静音状态 */
.setting-btn.muted {
    background: linear-gradient(145deg, #f0f0f0, #e8e8e8);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1),
                inset 0 1px 2px rgba(255, 255, 255, 0.8);
    opacity: 0.75;
}

/* 震动关闭状态 */
.setting-btn.disabled-state {
    background: linear-gradient(145deg, #f0f0f0, #e8e8e8);
    opacity: 0.75;
}

/* ─── 增强 combo 显示动画 ─── */
#combo-display {
    animation: combo-pop 0.65s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-shadow:
        0 0 20px rgba(255, 107, 157, 0.9),
        0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ─── 格子 hover 增强 ─── */
.cell:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 14px rgba(255, 107, 157, 0.45);
    z-index: 1;
}
