/* 游戏页面样式 */

/* 游戏头部 */
.game-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
}

.btn-pause {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-pause:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.game-timer, .game-progress {
    text-align: center;
}

.timer-label, .progress-label {
    display: block;
    font-size: 0.8rem;
    opacity: 0.9;
    margin-bottom: 0.3rem;
}

.timer-value {
    font-size: 1.8rem;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

.progress-value {
    font-size: 1.5rem;
    font-weight: bold;
}

/* 游戏容器 */
.game-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    min-height: calc(100vh - 200px);
}

/* 舒尔特方格 */
.shulte-grid {
    display: grid;
    gap: 8px;
    padding: 15px;
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    max-width: 90vw;
    max-height: 70vh;
}

.grid-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.2rem, 4vw, 2.5rem);
    font-weight: bold;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.grid-cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
    pointer-events: none;
}

.grid-cell:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.grid-cell:active {
    transform: scale(0.95);
}

.grid-cell.correct {
    background: var(--success-color) !important;
    color: white !important;
    animation: correctPulse 0.5s ease;
}

.grid-cell.wrong {
    animation: wrongShake 0.5s ease;
}

.grid-cell.hint {
    animation: hintPulse 1s infinite;
}

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

@keyframes wrongShake {
    0%, 100% {
        transform: translateX(0);
    }
    20%, 60% {
        transform: translateX(-5px);
    }
    40%, 80% {
        transform: translateX(5px);
    }
}

@keyframes hintPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(255, 215, 0, 0);
    }
}

/* 不同方格大小的样式 */
.shulte-grid.size-3 {
    grid-template-columns: repeat(3, minmax(60px, 100px));
}

.shulte-grid.size-4 {
    grid-template-columns: repeat(4, minmax(55px, 90px));
}

.shulte-grid.size-5 {
    grid-template-columns: repeat(5, minmax(50px, 80px));
}

.shulte-grid.size-6 {
    grid-template-columns: repeat(6, minmax(45px, 70px));
}

.shulte-grid.size-7 {
    grid-template-columns: repeat(7, minmax(40px, 60px));
}

.shulte-grid.size-8 {
    grid-template-columns: repeat(8, minmax(35px, 55px));
}

.shulte-grid.size-9 {
    grid-template-columns: repeat(9, minmax(32px, 50px));
}

/* 颜色主题 */
.grid-cell.theme-default {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.grid-cell.theme-rainbow {
    color: white;
}

.grid-cell.theme-pastel {
    color: #2C3E50;
}

.grid-cell.theme-nature {
    color: white;
}

.grid-cell.theme-ocean {
    color: white;
}

/* 干扰效果 */
.grid-cell.disturb-shake {
    animation: disturbShake 0.3s infinite;
}

@keyframes disturbShake {
    0%, 100% {
        transform: translate(0, 0);
    }
    25% {
        transform: translate(-2px, 2px);
    }
    50% {
        transform: translate(2px, -2px);
    }
    75% {
        transform: translate(-2px, -2px);
    }
}

.grid-cell.disturb-fade {
    animation: disturbFade 2s infinite;
}

@keyframes disturbFade {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

/* 游戏底部 */
.game-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: white;
    display: flex;
    justify-content: space-around;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.btn-hint, .btn-quit {
    padding: 0.8rem 2rem;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-hint {
    background: var(--warning-color);
    color: white;
}

.btn-hint:hover {
    background: #E09400;
    transform: translateY(-2px);
}

.btn-quit {
    background: var(--accent-color);
    color: white;
}

.btn-quit:hover {
    background: #E85555;
    transform: translateY(-2px);
}

/* 暂停遮罩 */
.pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.pause-content {
    background: white;
    border-radius: 20px;
    padding: 3rem;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.pause-content h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.pause-buttons button {
    padding: 1rem;
    font-size: 1.1rem;
}

/* 胜利动画 */
.victory-animation {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 999;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* 进度条动画 */
.progress-bar-animation {
    position: fixed;
    top: 0;
    left: 0;
    height: 4px;
    background: var(--success-color);
    transition: width 0.3s ease;
    z-index: 1001;
}

/* 对战模式样式 */
.battle-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.battle-player {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

.battle-player.player {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.battle-player.opponent {
    background: linear-gradient(135deg, var(--accent-color), #FF8E8E);
}

.battle-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
    margin-bottom: 1rem;
}

.battle-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.battle-name {
    font-weight: bold;
}

.battle-progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.battle-progress-fill {
    height: 100%;
    background: white;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.battle-grid-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.battle-grid {
    display: grid;
    gap: 4px;
    padding: 10px;
    background: white;
    border-radius: 15px;
    box-shadow: var(--shadow-md);
}

.battle-grid .grid-cell {
    font-size: clamp(0.8rem, 2.5vw, 1.5rem);
    border-radius: 8px;
}

/* 倒计时 */
.countdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.countdown-number {
    font-size: 10rem;
    font-weight: bold;
    color: white;
    animation: countdownPulse 1s ease-in-out;
}

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

/* 特殊效果 */
.flash-effect {
    animation: flashEffect 0.5s ease;
}

@keyframes flashEffect {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.5);
    }
}

.screen-shake {
    animation: screenShake 0.5s ease;
}

@keyframes screenShake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* 响应式调整 */
@media (max-width: 768px) {
    .game-header {
        padding: 0.8rem;
    }

    .timer-value {
        font-size: 1.5rem;
    }

    .progress-value {
        font-size: 1.2rem;
    }

    .game-container {
        padding: 1rem;
    }

    .shulte-grid {
        gap: 5px;
        padding: 10px;
    }

    .grid-cell {
        font-size: clamp(1rem, 3.5vw, 2rem);
        border-radius: 8px;
    }
}

@media (max-width: 480px) {
    .btn-pause {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .timer-label, .progress-label {
        font-size: 0.7rem;
    }

    .timer-value {
        font-size: 1.3rem;
    }

    .progress-value {
        font-size: 1.1rem;
    }

    .shulte-grid {
        gap: 4px;
        padding: 8px;
    }

    .grid-cell {
        border-radius: 6px;
    }
}

/* 横屏模式 */
@media (orientation: landscape) and (max-height: 500px) {
    .game-container {
        min-height: auto;
        padding: 1rem;
    }

    .shulte-grid {
        max-height: 80vh;
    }

    .game-footer {
        padding: 0.5rem;
    }

    .btn-hint, .btn-quit {
        padding: 0.5rem 1.5rem;
        font-size: 0.9rem;
    }
}

/* 匹配页面样式 */
.matching-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 2rem;
}

.matching-animation {
    text-align: center;
    color: white;
}

.matching-spinner {
    width: 80px;
    height: 80px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 2rem;
}

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

.matching-text {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.matching-time {
    font-size: 2rem;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

.cancel-btn {
    margin-top: 3rem;
    padding: 1rem 3rem;
    font-size: 1.1rem;
}

/* 对战结果页面样式 */
.battle-result-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.result-banner {
    text-align: center;
    color: white;
    margin-bottom: 2rem;
}

.result-banner.win {
    animation: winPulse 1s ease-in-out infinite;
}

.result-banner.lose {
    opacity: 0.8;
}

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

.result-emoji {
    font-size: 5rem;
    display: block;
    margin-bottom: 1rem;
}

.result-banner h2 {
    font-size: 2.5rem;
}

.battle-result-stats {
    display: flex;
    align-items: center;
    gap: 2rem;
    background: white;
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
}

.result-player {
    text-align: center;
    min-width: 100px;
}

.result-player .player-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 0.5rem;
}

.result-player .player-name {
    font-weight: bold;
    margin-bottom: 0.3rem;
}

.result-player .player-time {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.result-vs {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-secondary);
}

.battle-rewards {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.reward-item {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.8rem 1.5rem;
    border-radius: 25px;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.battle-result-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.battle-result-actions button {
    min-width: 140px;
}

/* 对手方格样式 */
.opponent-cell {
    pointer-events: none;
    opacity: 0.8;
}

/* Toast 提示样式 */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 1rem 2rem;
    border-radius: 25px;
    z-index: 3000;
    animation: toastIn 0.3s ease;
}

.toast.hidden {
    display: none !important;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* VS 分隔线样式 */
.battle-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.1);
}

.vs-text {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

/* 段位徽章样式 */
.rank-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: bold;
}

.rank-badge.bronze {
    background: linear-gradient(135deg, #CD7F32, #B8860B);
    color: white;
}

.rank-badge.silver {
    background: linear-gradient(135deg, #C0C0C0, #A0A0A0);
    color: white;
}

.rank-badge.gold {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
}

.rank-badge.platinum {
    background: linear-gradient(135deg, #E5E4E2, #BCC6CC);
    color: #333;
}

.rank-badge.diamond {
    background: linear-gradient(135deg, #B9F2FF, #4EE2EC);
    color: #333;
}

.rank-badge.master {
    background: linear-gradient(135deg, #9B59B6, #8E44AD);
    color: white;
}

.rank-badge.king {
    background: linear-gradient(135deg, #FF6B6B, #EE5A5A);
    color: white;
}
