/* 等式配对消消乐 - 样式文件 */

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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 5px;
    margin: 0;
    /* iPad适配：允许滚动以显示弹窗 */
    overflow: auto;
    position: relative;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

/* 左右布局主容器 */
.main-container {
    display: flex;
    gap: 25px;
    max-width: 1200px;
    width: 100%;
    padding: 20px;
    align-items: flex-start;
}

/* 左侧面板 */
.left-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 200px;
    max-width: 240px;
    flex-shrink: 0;
}

/* 头部区域 */
.header {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.header h1 {
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    font-size: 22px;
    margin-bottom: 15px;
}

.header .game-online-counter {
    margin-top: 10px;
}

.header .online-counter {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 15px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.header .online-dot {
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.header .online-label,
.header .online-count,
.header .online-unit {
    color: white;
    font-size: 14px;
}

.header .online-count {
    font-weight: bold;
}

.game-container {
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    flex: 1;
    min-width: 400px;
    max-height: 98vh;
    min-height: 500px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* h1 样式已移至 .header h1 */

.score-board {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.score-item .label {
    color: white;
    font-size: 14px;
}

.score-item .value {
    color: white;
    font-size: 22px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(6, 60px);
    gap: 5px;
    margin-bottom: 10px;
    background: #f0f0f0;
    padding: 10px;
    border-radius: 8px;
    flex-shrink: 0;
    width: fit-content;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    position: relative;
}

.block {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    will-change: transform;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.block:active {
    transform: scale(0.92);
    transition: transform 0.1s ease;
}

@media (hover: hover) and (pointer: fine) {
    .block:hover {
        transform: scale(1.05);
    }
}

.block.selected {
    transform: scale(0.95);
    box-shadow: 0 0 0 3px #FFD700, inset 0 0 10px rgba(0, 0, 0, 0.3);
}

.block.matched {
    animation: matchPulse 0.5s ease;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
}

.block.wrong {
    animation: shake 0.5s;
}

.block.hint-highlight {
    border: 3px solid #FFD700;
    box-shadow: 0 0 20px #FFD700;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 20px #FFD700;
    }
    50% {
        box-shadow: 0 0 30px #FFD700, 0 0 10px #FFD700 inset;
    }
}

@keyframes matchPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

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

.block-content {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    text-align: center;
    padding: 5px;
}

.block-expression {
    font-size: 16px;
    line-height: 1.2;
}

/* 提示区域 */
.hint-area {
    background: #fff9e6;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 0;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 3px solid #ffd700;
    flex-shrink: 0;
}

.empty-hint {
    text-align: center;
    color: #999;
    font-size: 16px;
}

.hint-text {
    font-size: 18px;
    text-align: center;
    color: #333;
    font-weight: bold;
}

/* 右侧按钮组 */
.right-buttons {
    position: fixed;
    right: 10px;
    top: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 999;
}

.btn-restart {
    display: block;
    padding: 12px 20px;
    font-size: 16px;
    background: linear-gradient(145deg, #ff6b6b, #ff8787);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    min-width: 120px;
    text-align: center;
    font-weight: bold;
}

.btn-restart:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(0,0,0,0.3);
}

.btn-restart:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.btn-home {
    display: block;
    padding: 12px 20px;
    font-size: 16px;
    background: linear-gradient(145deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    min-width: 120px;
    text-align: center;
    font-weight: bold;
}

.btn-home:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(0,0,0,0.3);
}

.btn-home:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* 横竖屏提示 */
.orientation-tip {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    z-index: 9999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    font-size: 24px;
    text-align: center;
    padding: 20px;
}

.orientation-tip .icon {
    font-size: 80px;
    margin-bottom: 20px;
}

@media screen and (orientation: portrait) and (max-width: 768px) {
    .orientation-tip.show-portrait-tip {
        display: flex;
    }
}

/* 道具栏样式 - 固定在右侧 */
.power-ups {
    position: fixed;
    right: 10px;
    top: 150px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 999;
}

.power-up {
    background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
    color: white;
    border: 3px solid #ffd700;
    border-radius: 10px;
    padding: 12px 16px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    min-width: 120px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
    text-align: center;
}

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

.power-up.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #ccc;
}

.power-up .count {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    border: 2px solid white;
}

/* 弹窗样式 */
.egg-modal,
.login-modal,
.rank-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.egg-modal.show,
.login-modal.show,
.rank-modal.show {
    display: flex;
}

.login-modal {
    background: rgba(0, 0, 0, 0.9);
    z-index: 10001;
}

.egg-modal.show {
    animation: fadeIn 0.3s ease;
}

.egg-content,
.login-content,
.rank-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    max-width: 400px;
}

.egg-content {
    animation: bounceIn 0.5s ease;
}

.login-content {
    width: 90%;
}

.rank-content {
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.egg-content h2,
.login-content h2,
.rank-content h2 {
    color: #667eea;
    margin-bottom: 20px;
}

.egg-content h2 {
    font-size: 32px;
}

.login-content h2,
.rank-content h2 {
    font-size: 28px;
}

.login-content p {
    color: #666;
    margin-bottom: 25px;
    font-size: 16px;
}

.egg-content .egg-icon {
    font-size: 80px;
    margin: 20px 0;
    animation: rotate 2s linear infinite;
}

.egg-content .egg-name {
    font-size: 24px;
    color: #333;
    font-weight: bold;
    margin-bottom: 10px;
}

.egg-content .egg-desc {
    font-size: 16px;
    color: #666;
    margin-bottom: 30px;
}

.egg-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 15px 40px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.egg-btn:active {
    transform: scale(0.95);
}

/* 登录输入框 */
.login-input {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    border: 2px solid #667eea;
    border-radius: 10px;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.login-input:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
}

.login-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.login-btn {
    padding: 15px 50px;
    font-size: 18px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    width: auto;
    min-width: 200px;
}

.login-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.login-btn.secondary {
    background: #e0e0e0;
    color: #666;
}

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

/* 动画 */
@keyframes fadeOut {
    to {
        opacity: 0;
        transform: scale(0);
    }
}

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

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

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

/* 排行榜按钮 - 放在右侧道具栏下方 */
.rank-btn {
    position: fixed;
    right: 10px;
    top: 250px;
    padding: 10px 20px;
    background: rgba(255, 215, 0, 0.9);
    border: none;
    border-radius: 8px;
    color: #333;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    min-width: 120px;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.rank-btn:hover {
    background: rgba(255, 215, 0, 1);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
}

.rank-btn:active {
    transform: scale(0.95);
}

/* 排行榜列表 */
.rank-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.rank-item {
    display: flex;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
    background: #f5f5f5;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.rank-item:hover {
    background: #e8e8e8;
    transform: translateX(5px);
}

.rank-item.top1 {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
}

.rank-item.top2 {
    background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%);
}

.rank-item.top3 {
    background: linear-gradient(135deg, #cd7f32 0%, #e8b482 100%);
}

.rank-number {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
    width: 40px;
    text-align: center;
}

.rank-info {
    flex: 1;
    margin-left: 15px;
}

.rank-name {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.rank-detail {
    font-size: 14px;
    color: #666;
}

.rank-score {
    font-size: 20px;
    font-weight: bold;
    color: #f5576c;
}

.rank-close {
    text-align: center;
    margin-top: 20px;
}

.no-records {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 16px;
}

/* 响应式设计 */

/* iPad 端弹窗适配 */
@media (min-width: 768px) and (max-width: 1024px) {
    /* 确保 iPad上登录弹窗可见 */
    body {
        display: flex !important;
        overflow-y: auto;
        position: relative;
        min-height: 100vh;
        padding: 20px 5px;
    }
    
    .login-modal,
    .ranking-modal,
    .shop-modal,
    .anti-addiction-modal {
        position: fixed !important;
        z-index: 10000 !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .main-container {
        margin: 10px auto;
    }
}

/* iPad Pro 横屏优化 */
@media (min-width: 1024px) and (max-width: 1366px) {
    .main-container {
        gap: 20px;
    }
    
    .left-panel {
        min-width: 220px;
        max-width: 260px;
    }
    
    .game-container {
        min-height: 550px;
        padding: 20px;
        min-width: 500px;
    }
    
    .header h1 {
        font-size: 22px;
    }
    
    .block {
        width: 80px;
        height: 56px;
        font-size: 18px;
    }
    
    .block-expression {
        font-size: 16px;
    }
    
    .game-board {
        gap: 6px;
        padding: 12px;
        grid-template-columns: repeat(6, 80px);
    }
    
    .power-ups {
        right: 15px;
        top: 170px;
    }
    
    .power-up {
        min-width: 130px;
        font-size: 17px;
    }
    
    .rank-btn {
        right: 15px;
        top: 260px;
    }
}

/* iPad 竖屏优化 - 切换为上下布局 */
@media (min-width: 768px) and (max-width: 1023px) {
    .main-container {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .left-panel {
        flex-direction: row;
        max-width: 100%;
        min-width: auto;
        width: 100%;
        max-width: 700px;
    }
    
    .header {
        flex: 1;
    }
    
    .score-board {
        flex: 1;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .score-item {
        flex: 0 0 auto;
        min-width: 100px;
    }
    
    .game-container {
        min-height: 450px;
        min-width: 550px;
        width: 100%;
        max-width: 700px;
    }
    
    .header h1 {
        font-size: 20px;
    }
    
    .block {
        width: 75px;
        height: 52px;
        font-size: 16px;
    }
    
    .block-expression {
        font-size: 15px;
    }
    
    .game-board {
        gap: 5px;
        padding: 10px;
        grid-template-columns: repeat(6, 75px);
    }
    
    .power-ups {
        right: 10px;
        top: 60px;
    }
    
    .power-up {
        min-width: 115px;
        font-size: 15px;
    }
    
    .rank-btn {
        right: 10px;
        top: 240px;
    }
}

/* 手机端优化 - 切换为上下布局 */
@media (max-width: 767px) {
    .main-container {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        padding: 10px;
    }
    
    .left-panel {
        flex-direction: row;
        max-width: 100%;
        min-width: auto;
        width: 100%;
        gap: 10px;
    }
    
    .header {
        flex: 1;
        padding: 12px;
    }
    
    .header h1 {
        font-size: 16px;
        margin-bottom: 8px;
    }
    
    .header .online-counter {
        padding: 5px 10px;
    }
    
    .header .online-label,
    .header .online-count,
    .header .online-unit {
        font-size: 12px;
    }
    
    .score-board {
        flex: 1;
        padding: 12px;
        gap: 8px;
    }
    
    .score-item {
        padding: 6px 10px;
    }
    
    .score-item .label {
        font-size: 12px;
    }
    
    .score-item .value {
        font-size: 18px;
    }
    
    .game-container {
        min-height: 400px;
        padding: 12px;
        width: 100%;
        min-width: auto;
    }
    
    .block {
        width: 50px;
        height: 50px;
        font-size: 14px;
    }
    
    .game-board {
        gap: 3px;
        padding: 8px;
        grid-template-columns: repeat(6, 50px);
    }
    
    .hint-area {
        padding: 12px;
        min-height: 70px;
    }
    
    .hint-text {
        font-size: 16px;
    }
    
    .empty-hint {
        font-size: 14px;
    }
    
    /* 手机端道具栏缩小 */
    .power-ups {
        right: 5px;
        top: 55px;
        gap: 8px;
    }
    
    .power-up {
        padding: 8px 12px;
        font-size: 14px;
        min-width: 100px;
    }
    
    .power-up .count {
        width: 20px;
        height: 20px;
        font-size: 12px;
        top: -8px;
        right: -8px;
    }
    
    .rank-btn {
        right: 5px;
        top: 220px;
        padding: 8px 15px;
        font-size: 14px;
        min-width: 100px;
    }
}
