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

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: Arial, sans-serif;
    background-color: #fff6fa;
    color: #8c3a5e;
    min-height: 100dvh;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
}

.container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 16px 12px;
    text-align: center;
    overflow-x: hidden;
}

h1 {
    margin-bottom: 30px;
    color: #e94f86;
}

/* 模式选择页面样式 */
.mode-selection {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 20px;
}

.mode-card {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.mode-card:hover {
    transform: translateY(-5px);
}

.mode-card h2 {
    margin-bottom: 10px;
    color: #8c3a5e;
}

.mode-card p {
    margin-bottom: 20px;
    color: #bd7f9b;
    font-size: 14px;
}

.mode-card button {
    background-color: #e94f86;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
}

.mode-card button:hover {
    background-color: #d13d75;
}

/* 游戏页面样式 */
.game-info {
    margin-bottom: 20px;
}

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

.player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 5px;
}

.player1 {
    background-color: #fff0f6;
}

.player2 {
    background-color: #ffebee;
}

.player .status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #ffd6e0;
}

.player.active .status {
    background-color: #e94f86;
    animation: pulse 1s infinite;
}

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

.current-turn {
    font-size: 18px;
    font-weight: bold;
    margin-top: 10px;
}

.board {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 3px;
    margin: 12px auto;
    width: 100%;
    max-width: min(400px, calc(100vw - 24px));
    position: relative;
    z-index: 1;
}

.dice-container {
    margin: 20px 0;
    position: relative;
    z-index: 10;
}

.cell {
    width: 100%;
    min-width: 0;
    aspect-ratio: 1;
    background-color: white;
    border: 1.5px solid #ffd6e0;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    position: relative;
    transition: all 0.3s ease;
    padding: 2px;
    overflow: hidden;
}

.cell-number {
    font-size: clamp(8px, 2.4vw, 12px);
    color: #bd7f9b;
    margin-bottom: 1px;
    flex-shrink: 0;
}

.cell-content {
    font-size: clamp(6px, 1.8vw, 10px);
    color: #8c3a5e;
    text-align: center;
    line-height: 1.15;
    width: 100%;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    word-break: break-all;
}

.cell.start {
    background-color: #ffe4ec;
    border-color: #e94f86;
}

.cell.end {
    background-color: #fff3e0;
    border-color: #ff9800;
}

.cell.special {
    background-color: #fff0f6;
    border-color: #2196f3;
}

.cell.player1 {
    box-shadow: inset 0 0 10px #2196f3;
}

.cell.player2 {
    box-shadow: inset 0 0 10px #f44336;
}

.player-piece {
    position: absolute;
    width: clamp(10px, 4vw, 20px);
    height: clamp(10px, 4vw, 20px);
    border-radius: 50%;
    z-index: 10;
}

.player1-piece {
    background-color: #2196f3;
    top: 2px;
    left: 2px;
}

.player2-piece {
    background-color: #f44336;
    bottom: 2px;
    right: 2px;
}

.dice-container {
    margin: 20px 0;
}

.dice {
    width: 80px;
    height: 80px;
    background-color: white;
    border: 2px solid #8c3a5e;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: bold;
    margin: 0 auto 20px;
    animation: roll 0.5s ease;
}

@keyframes roll {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#roll-btn {
    background-color: #e94f86;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 18px;
    transition: background-color 0.3s ease;
}

#roll-btn:hover {
    background-color: #d13d75;
}

#roll-btn:disabled {
    background-color: #ffd6e0;
    cursor: not-allowed;
}

.reset-btn, .back-btn {
    display: inline-block;
    margin: 10px;
    padding: 10px 20px;
    background-color: #f44336;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.reset-btn:hover, .back-btn:hover {
    background-color: #d32f2f;
}

.back-btn {
    background-color: #ff9800;
}

.back-btn:hover {
    background-color: #f57c00;
}

.custom-btn {
    display: inline-block;
    margin: 10px;
    padding: 10px 20px;
    background-color: #9c27b0;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.custom-btn:hover {
    background-color: #7b1fa2;
}

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

.modal-buttons button {
    background-color: #e94f86;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
}

.modal-buttons button:hover {
    background-color: #d13d75;
}

.modal-buttons button:nth-child(2) {
    background-color: #f44336;
}

.modal-buttons button:nth-child(2):hover {
    background-color: #d32f2f;
}

textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ffd6e0;
    border-radius: 5px;
    font-size: 14px;
    resize: vertical;
    margin-top: 10px;
}

/* 模态框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    display: none;
    padding: 16px;
    overflow-y: auto;
}

.modal.show {
    display: flex;
}

.modal-content {
    background-image: url('0f770684602ccf0cc5c60499268d6297.jpg');
    background-size: cover;
    background-position: center;
    padding: 24px 16px;
    border-radius: 10px;
    width: min(92vw, 420px);
    max-width: 92vw;
    max-height: min(80dvh, 560px);
    overflow-y: auto;
    text-align: center;
    color: white;
    text-shadow: 0 0 10px rgba(0,0,0,0.8);
    min-height: 180px;
}

.modal-content h3 {
    margin-bottom: 15px;
    color: white;
    font-size: 24px;
}

.modal-content p {
    margin-bottom: 20px;
    color: white;
    font-size: 18px;
    font-weight: bold;
}

#modal-close {
    background-color: #e94f86;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
}

#modal-close:hover {
    background-color: #d13d75;
}

/* 响应式设计 */
@media (max-width: 480px) {
    .container {
        padding: 10px 8px 20px;
    }

    h1 {
        font-size: 22px;
        margin-bottom: 16px;
    }

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

    .mode-card {
        padding: 16px;
    }

    .player-info {
        gap: 8px;
    }

    .player {
        padding: 8px;
        font-size: 14px;
    }

    .current-turn {
        font-size: 16px;
    }

    .board {
        max-width: calc(100vw - 16px);
        gap: 2px;
        margin: 10px auto;
    }

    .cell {
        border-width: 1px;
        padding: 1px;
    }

    .cell-content {
        -webkit-line-clamp: 3;
        font-size: clamp(5px, 2.2vw, 8px);
    }

    .dice {
        width: 56px;
        height: 56px;
        font-size: 22px;
        margin-bottom: 12px;
    }

    #roll-btn {
        padding: 10px 20px;
        font-size: 16px;
    }

    .reset-btn, .back-btn, .custom-btn {
        margin: 6px;
        padding: 8px 14px;
        font-size: 14px;
    }

    .modal-content {
        padding: 20px 12px;
        min-height: 0;
        max-height: 78dvh;
    }

    .modal-content h3 {
        font-size: 18px;
    }

    .modal-content p {
        font-size: 15px;
    }
}

@media (max-width: 360px) {
    .board {
        gap: 1px;
    }

    .cell-content {
        -webkit-line-clamp: 2;
    }
}
