/* 游戏页面公共样式 */

/* 游戏容器 */
.game-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
    min-width: 0;
}

/* 游戏头部 */
.game-header {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
}

.back-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
    flex-shrink: 0;
}

.back-btn:hover {
    background: #5568d3;
    transform: scale(1.05);
}

.game-info {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
}

.info-item {
    text-align: center;
    min-width: 0;
}

.info-label {
    font-size: 0.9em;
    color: #999;
    margin-bottom: 5px;
}

.info-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #667eea;
}

/* 游戏列表 */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.game-item {
    background: white;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.game-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.game-item .game-icon {
    font-size: 4em;
    margin-bottom: 15px;
}

.game-item h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.5em;
}

.game-item p {
    color: #999;
    margin-bottom: 15px;
}

.game-item .high-score {
    background: #f0f0f0;
    padding: 8px 15px;
    border-radius: 10px;
    font-size: 0.9em;
    color: #666;
}

/* 游戏主体区域 */
.game-main {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

.game-title {
    text-align: center;
    color: #667eea;
    margin-bottom: 20px;
    font-size: 2em;
}

.game-description {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1em;
    line-height: 1.6;
}

/* 游戏区域 */
.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin: 30px 0;
    width: 100%;
    min-width: 0;
}

/* 按钮样式 */
.btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 14px 36px;
    border-radius: 10px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.3;
}

.btn:hover {
    background: #5568d3;
    transform: scale(1.05);
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-success {
    background: #51cf66;
}

.btn-success:hover {
    background: #40c057;
}

.btn-danger {
    background: #ff6b6b;
}

.btn-danger:hover {
    background: #ff5252;
}

/* Toast提示 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    font-size: 1.1em;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
    z-index: 10000;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

/* 奖励弹窗 */
.reward-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.reward-popup.show {
    opacity: 1;
}

.reward-content {
    background: white;
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    width: min(420px, calc(100vw - 40px));
    max-width: 100%;
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.reward-popup.show .reward-content {
    transform: scale(1);
}

.reward-icon {
    font-size: 5em;
    margin-bottom: 20px;
}

.reward-score {
    font-size: 3em;
    color: #51cf66;
    font-weight: bold;
    margin-bottom: 15px;
}

.reward-message {
    font-size: 1.5em;
    color: #667eea;
}

/* 休息提醒 */
.rest-reminder {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 20px;
}

.reminder-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    width: min(400px, calc(100vw - 40px));
    max-width: 100%;
}

.reminder-icon {
    font-size: 5em;
    margin-bottom: 20px;
}

.reminder-content h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.8em;
}

.reminder-content p {
    color: #666;
    margin-bottom: 25px;
    font-size: 1.2em;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.reminder-content button {
    background: #51cf66;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 10px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 48px;
}

.reminder-content button:hover {
    background: #40c057;
    transform: scale(1.05);
}

/* 游戏结束弹窗 */
.game-over-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.modal-content h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 2em;
}

.modal-content .final-score {
    font-size: 3em;
    color: #51cf66;
    font-weight: bold;
    margin: 20px 0;
}

.modal-content .new-record {
    background: #fff3cd;
    color: #856404;
    padding: 10px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-weight: bold;
}

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

@media (min-width: 1024px) {
    body {
        padding: 28px;
        background:
            radial-gradient(920px 520px at 8% -8%, rgba(102, 126, 234, 0.24), transparent 60%),
            radial-gradient(780px 460px at 96% 2%, rgba(81, 207, 102, 0.14), transparent 56%),
            #eef1f7;
    }

    .game-container {
        max-width: 1280px;
        min-height: calc(100vh - 56px);
        display: grid;
        grid-template-columns: 300px minmax(0, 1fr);
        grid-template-rows: auto 1fr;
        gap: 18px 24px;
        padding: 0;
    }

    .game-header {
        grid-column: 1;
        grid-row: 1 / span 2;
        position: sticky;
        top: 28px;
        align-self: start;
        min-height: calc(100vh - 56px);
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 24px;
        margin: 0;
        padding: 22px;
        border-radius: 8px;
    }

    .back-btn {
        width: 100%;
        border-radius: 8px;
    }

    .game-info {
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 12px;
    }

    .info-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 12px 14px;
        border-radius: 8px;
        background: #f5f7ff;
        text-align: left;
    }

    .info-label {
        margin: 0;
        font-size: 0.86rem;
    }

    .info-value {
        font-size: 1.35rem;
        line-height: 1;
    }

    .game-main {
        grid-column: 2;
        grid-row: 1 / span 2;
        min-height: calc(100vh - 56px);
        display: grid;
        grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
        grid-template-rows: auto 1fr;
        grid-template-areas:
            "title play"
            "desc play";
        align-items: start;
        gap: 18px 32px;
        padding: 30px;
        border-radius: 8px;
        overflow-x: visible;
    }

    .game-title {
        grid-area: title;
        margin: 0;
        text-align: left;
        font-size: 2.15rem;
        letter-spacing: 0;
    }

    .game-description {
        grid-area: desc;
        margin: 0 !important;
        padding: 18px !important;
        border-radius: 8px !important;
        text-align: left;
        font-size: 1rem;
        line-height: 1.7;
    }

    .game-description h3,
    .game-description p {
        text-align: left;
    }

    .game-area {
        grid-area: play;
        align-self: center;
        justify-self: stretch;
        min-height: min(720px, calc(100vh - 116px));
        margin: 0;
        gap: 18px;
        justify-content: center;
    }

    .btn {
        width: auto;
        min-width: 150px;
        max-width: none;
        border-radius: 8px;
    }

    .games-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .game-item,
    .modal-content,
    .reward-content,
    .reminder-content {
        border-radius: 8px;
    }

    .toast {
        top: 28px;
        right: 28px;
    }

    .schulte-panel,
    .sequence-stage,
    .game2048-info,
    .reaction-stats,
    .game-status,
    .game-stats,
    .game-controls,
    .level-selector,
    .tier-selector,
    .focus-strip {
        max-width: 720px;
    }

    .schulte-grid,
    .number-grid,
    .sudoku-board,
    .memory-board,
    .card-grid,
    .mole-grid,
    .puzzle-grid,
    .color-board,
    .odd-board,
    .llk-board,
    .grid-container {
        width: min(58vh, 560px);
        max-width: min(100%, 560px) !important;
    }

    .grid-container {
        width: min(58vh, 500px);
    }

    .number-grid,
    .llk-board {
        width: min(68vh, 760px);
        max-width: min(100%, 760px) !important;
    }

    .game-images {
        width: 100%;
        max-width: 920px;
    }
}

@media (min-width: 1280px) {
    .game-container {
        grid-template-columns: 320px minmax(0, 1fr);
    }

    .game-main {
        grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
        padding: 34px;
    }
}

/* 响应式设计 - 平板及大手机 */
@media (max-width: 768px) {
    .game-container {
        padding: 8px;
    }

    .game-header {
        flex-direction: row;
        gap: 6px;
        padding: 8px 10px;
        margin-bottom: 8px;
        border-radius: 10px;
        justify-content: space-between;
        position: sticky;
        top: max(8px, env(safe-area-inset-top));
        z-index: 20;
    }

    .game-info {
        flex-wrap: wrap;
        gap: 6px;
        justify-content: flex-end;
        flex: 1;
    }

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

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

    .back-btn {
        padding: 6px 12px;
        font-size: 0.82em;
        min-height: 36px;
    border-radius: 8px;
}

    .game-main {
        padding: 10px;
        border-radius: 10px;
    }

    .game-title {
        font-size: 1.2em;
        margin-bottom: 6px;
    }

    .game-description {
        font-size: 0.9em;
        margin-bottom: 12px;
        line-height: 1.5;
        padding: 12px !important;
    }

    /* 规则卡片移动端缩小 */
    .game-description[style*="padding: 20px"] {
        padding: 12px !important;
    }

    /* 规则区折叠：移动端默认收起，只显示一行摘要 */
    .game-description {
        cursor: pointer;
        max-height: 44px;
        overflow: hidden;
        position: relative;
        transition: max-height 0.3s ease;
        padding: 10px 12px !important;
        margin-bottom: 8px !important;
        border-radius: 10px !important;
        font-size: 0.85em !important;
        line-height: 1.5;
    }

    /* 渐变遮罩提示可展开 */
    .game-description::after {
        content: '展开 ▼';
        position: absolute;
        right: 8px;
        bottom: 4px;
        font-size: 0.8em;
        opacity: 0.8;
        pointer-events: none;
    }

    .game-description.expanded {
        max-height: 500px;
    }

    .game-description.expanded::after {
        content: '收起 ▲';
    }

    /* 规则区内的大标题和间距收紧 */
    .game-description h3 {
        font-size: 1.05em !important;
        margin-bottom: 6px !important;
    }

    .game-description p {
        margin: 4px 0 !important;
        line-height: 1.5;
    }

    .game-area {
        gap: 8px;
        margin: 8px 0;
    }

    .games-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .btn {
        padding: 12px 28px;
        font-size: 1.05em;
        width: 100%;
        max-width: 320px;
        border-radius: 12px;
    }

    .modal-content {
        padding: 20px 16px;
        border-radius: 16px;
    }

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

    .modal-content .final-score {
        font-size: 2.2em;
    }

    .modal-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .modal-buttons .btn {
        width: 100%;
        max-width: none;
    }

    .reward-content {
        padding: 25px 18px;
        border-radius: 16px;
    }

    .reward-icon {
        font-size: 4em;
        margin-bottom: 12px;
    }

    .reward-score {
        font-size: 2.5em;
    }

    .reward-message {
        font-size: 1.2em;
    }

    .reminder-content {
        padding: 20px 16px;
        max-width: 100%;
        border-radius: 16px;
    }

    .reminder-icon {
        font-size: 4em;
        margin-bottom: 12px;
    }

    .reminder-content h3 {
        font-size: 1.5em;
    }

    .reminder-content p {
        font-size: 1.05em;
        margin-bottom: 20px;
    }

    /* Toast 移动端底部居中 */
    .toast {
        top: auto;
        bottom: 80px;
        right: 50%;
        transform: translateX(50%) translateY(100px);
        max-width: 90%;
        text-align: center;
        font-size: 1em;
        padding: 12px 20px;
    }

    .toast.show {
        transform: translateX(50%) translateY(0);
    }
}

/* 小屏手机优化 */
@media (max-width: 480px) {
    .game-container {
        padding: 4px;
    }

    .game-header {
        padding: 6px 8px;
        margin-bottom: 6px;
        border-radius: 8px;
        gap: 4px;
        box-shadow: 0 3px 14px rgba(33, 37, 41, 0.12);
    }

    .game-info {
        gap: 4px;
    }

    .info-item {
        flex: 1 1 auto;
        min-width: 42px;
    }

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

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

    .back-btn {
        padding: 5px 10px;
        font-size: 0.8em;
        min-height: 34px;
        border-radius: 6px;
    }

    .game-main {
        padding: 8px;
        border-radius: 8px;
    }

    .game-title {
        font-size: 1.1em;
        margin-bottom: 4px;
    }

    .game-description {
        padding: 8px 10px !important;
        margin-bottom: 6px !important;
        font-size: 0.8em !important;
        max-height: 40px;
    }

    .game-description h3 {
        font-size: 0.95em !important;
        margin-bottom: 4px !important;
    }

    .game-description p {
        margin: 3px 0 !important;
        font-size: 0.82em;
    }

    .game-area {
        gap: 8px;
        margin: 8px 0;
    }

    .btn {
        padding: 8px 18px;
        font-size: 0.9em;
        min-height: 40px;
    }

    .modal-content {
        padding: 16px 12px;
    }

    .modal-content h2 {
        font-size: 1.2em;
        margin-bottom: 12px;
    }

    .modal-content .final-score {
        font-size: 2em;
    }

    .reward-content {
        padding: 20px 14px;
    }

    .reward-icon {
        font-size: 3em;
    }

    .reward-score {
        font-size: 2em;
    }

    .reminder-content {
        padding: 16px 12px;
    }

    .reminder-icon {
        font-size: 3em;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .back-btn:hover,
    .btn:hover {
        transform: none;
    }

    .back-btn:active {
        transform: scale(0.95);
        background: #5568d3;
    }

    .btn:active:not(:disabled) {
        transform: scale(0.96);
    }

    .game-item:hover {
        transform: none;
    }

    .game-item:active {
        transform: scale(0.97);
    }
}

/* 横屏手机优化 */
@media (max-width: 900px) and (orientation: landscape) {
    .game-container {
        padding: 6px;
    }

    .game-header {
        padding: 8px 12px;
        margin-bottom: 8px;
        border-radius: 10px;
    }

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

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

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

    .game-main {
        padding: 10px;
        border-radius: 10px;
    }

    .game-title {
        font-size: 1.2em;
        margin-bottom: 6px;
    }

    .game-description {
        font-size: 0.82em;
        margin-bottom: 8px;
    }

    .game-area {
        margin: 6px 0;
        gap: 6px;
    }

    .btn {
        padding: 6px 16px;
        font-size: 0.88em;
    }

    /* 横屏规则区也折叠 */
    .game-description {
        max-height: 36px;
        padding: 6px 10px !important;
        font-size: 0.78em !important;
    }
}
