:root {
    --boy-color: #5D9CEC;
    --boy-bg: #E0F0FF;
    --girl-color: #FF6B81;
    --girl-bg: #FFE0E6;
    --primary-text: #2C3E50;
    --secondary-text: #7F8C8D;
    --board-bg: #FFFFFF;
    --cell-1: #F7F9FC;
    --cell-2: #EBF2FA;
    --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 8px 15px rgba(0, 0, 0, 0.1);
    --radius-lg: 20px;
    --radius-md: 12px;
}

* {
    box-sizing: border-box;
    /* Fixes width calculations including padding */
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    color: var(--primary-text);
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    overflow: hidden;
    /* Prevent body scroll, handle in #main if needed */
}

/* Main Container */
#main {
    width: 100%;
    height: 100%;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-flow: row wrap;
    align-content: flex-start;
    gap: 15px;
    padding: 10px;
    box-sizing: border-box;
    /* Reinforced */
    background-color: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
    overflow-x: hidden;
    /* Prevent horizontal scrollbar */
}

/* Remove #upper_part styles - it's gone */

/* Player Board Area - Now a Card */
#player_board {
    flex: 2;
    min-width: 300px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 15px;
    margin: 0;
    box-sizing: border-box;
}

.player {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border-radius: var(--radius-md);
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: bold;
    font-size: 1.1em;
    border: none;
}

/* Boy Player Styling */
.player:first-child {
    background-color: var(--boy-bg);
    color: var(--boy-color);
}

.player:first-child img {
    border: 3px solid var(--boy-color);
}

/* Girl Player Styling */
.player:last-child {
    background-color: var(--girl-bg);
    color: var(--girl-color);
}

.player:last-child img {
    border: 3px solid var(--girl-color);
}

.player:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.player_img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 5px;
    background-color: #ddd;
}

/* Turn Indicator */
#current_turn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: none;
    font-size: 0.9em;
    color: var(--secondary-text);
}

#current_turn_text {
    font-size: 1.5em;
    font-weight: bold;
    margin: 5px 0 0 0;
    color: var(--primary-text);
}

/* Dice Section - Now a Card */
#dice {
    flex: 1;
    min-width: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 15px;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

#dice_num {
    text-align: center;
    width: 100%;
}

#roll_dice {
    background: linear-gradient(90deg, var(--boy-color), var(--girl-color));
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 1em;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    margin-bottom: 5px;
}

#roll_dice:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

#roll_dice:active {
    transform: scale(0.95);
}

#dice_num_text {
    font-size: 2em;
    margin: 0;
    color: var(--primary-text);
    font-weight: 800;
}

#task_text {
    margin: 0;
    font-size: 0.8em;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    padding: 0 5px;
}


/* Checkerboard */
#checkerboard {
    flex: 0 0 100%;
    /* Force valid new row on desktop */
    order: 3;
    /* Ensure it comes last in the flow */
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 10px;
    border: none;
    overflow-y: auto;
    margin-bottom: 10px;
    height: 600px;
    /* Give it a fixed height on desktop or flex-grow if container allows */
    /* Actually, purely 100% width is enough to wrap it */
    box-sizing: border-box;
}

.row {
    flex: 1;
    display: flex;
    gap: 0;
    /* Remove gap */
    padding: 0;
}

.cell {
    flex: 1;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    margin: 1px;
    background-color: var(--cell-1);
}

/* Checkerboard Pattern using nth-child */
.row:nth-child(even) .cell:nth-child(odd),
.row:nth-child(odd) .cell:nth-child(even) {
    background-color: var(--cell-2);
}

.cell p {
    position: absolute;
    bottom: 2px;
    right: 2px;
    margin: 0;
    font-size: 0.7em;
    color: #cbd5e0;
    line-height: 1;
}

/* Pieces */
.piece-img {
    width: 80%;
    height: 80%;
    object-fit: contain;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.3));
    transition: all 0.5s ease-in-out;
    animation: float 2s ease-in-out infinite;
}

.house {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.3));
    transition: all 0.5s ease-in-out;
    animation: float 2s ease-in-out infinite;
}

@keyframes float {
    0% {
        transform: translate(-50%, -50%) translateY(0);
    }

    50% {
        transform: translate(-50%, -50%) translateY(-5px);
    }

    100% {
        transform: translate(-50%, -50%) translateY(0);
    }
}

/* Directions Arrows */
.arrow {
    position: absolute;
    width: 30%;
    height: 30%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.15;
    pointer-events: none;
    z-index: 1;
}

.arrow.right {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z'/%3E%3C/svg%3E") no-repeat center/contain;
}

.arrow.left {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z'/%3E%3C/svg%3E") no-repeat center/contain;
}

.arrow.down {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8z'/%3E%3C/svg%3E") no-repeat center/contain;
}

/* Enhance arrows for better visibility but keeping them subtle */
.arrow {
    filter: invert(50%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(80%) contrast(100%);
}

/* Modal Windows */
#Task_Window,
#gameOver {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
}

#task_content {
    width: 90%;
    max-width: 400px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    padding: 30px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Style for the content inside gameOver div */
#gameOver {
    flex-direction: column;
}

/* We need to style the children of #gameOver directly since it doesn't have a wrapper div in HTML */
#gameOver h1,
#gameOver p {
    color: white;
    /* Text on dark background if no wrapper, wait. */
    /* original HTML: <div id="gameOver"> <h1>...</h1> <p>...</p> <button>...</button> </div> */
    /* To make it look like a card, we should wrap the content in JS or just style the background of #gameOver? 
       No, #gameOver IS the overlay. 
       If I want a card, I need a wrapper. 
       OR I can style the #gameOver to NOT be the overlay but the card? No, v-show is on it.
       Best approach without changing HTML: Style the elements to look good on the overlay, or give them a semi-transparent background container?
       Actually, let's just make the overlay the background and the content float in the center.
       To make a "card" look without a wrapper div, we can't really do it easily for multiple elements (h1, p, button).
       
       Alternative: Style #gameOver items to have a white background? No.
       
       Let's just style the text to be readable on the dark overlay, OR add a pseudo-element?
       
       Actually, `index.html` structure:
       <div id="gameOver" v-show="gameOver">
            <h1>游戏结束</h1>
            <p id="gameOver_text">{{gameOverText}}</p>
            <button id="restart_game" @click="restartGame">重新开始</button>
        </div>
        
       I can't treat #gameOver as the card because it overs the whole screen.
       I will just style the text to be white and big, and the button to pop.
       OR I can ask to edit HTML? 
       No, I should try to work with CSS.
       
       Let's stick to a full-screen simple splash for Game Over.
    */
}

#gameOver h1 {
    font-size: 3em;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
}

#gameOver p {
    font-size: 1.5em;
    color: white;
    margin-bottom: 30px;
}

/* Adjust Pieces to not complete overlap */
.piece-img.boy-piece {
    left: 35%;
}

.piece-img.girl-piece {
    left: 65%;
}

button#accept_task,
button#reject_task,
button#restart_game {
    border: none;
    padding: 10px 20px;
    margin: 5px;
    border-radius: 20px;
    font-size: 1em;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.1s;
}

button#accept_task,
button#restart_game {
    background-color: #2ecc71;
    color: white;
    box-shadow: 0 4px 6px rgba(46, 204, 113, 0.2);
}

button#reject_task {
    background-color: #e74c3c;
    color: white;
    box-shadow: 0 4px 6px rgba(231, 76, 60, 0.2);
}

button:hover {
    transform: scale(1.05);
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Mobile Responsive Redesign */
@media (max-width: 768px) {
    body {
        background: #f0f2f5;
    }

    #main {
        padding: 0;
        height: 100vh;
        width: 100vw;
        max-width: 100%;
        background: none;
        backdrop-filter: none;
        box-shadow: none;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Break the wrapper structure using display: contents */
    #upper_part {
        display: contents;
    }

    /* 1. Top Section: Players and Turn */
    #player_board {
        order: 1;
        width: 100%;
        height: auto;
        padding: 5px 10px;
        background: white;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
        z-index: 10;
        gap: 10px;
        flex: 0 0 auto;
        box-sizing: border-box;
        border-radius: 0 0 15px 15px;
    }

    .player {
        flex-direction: row;
        /* Horizontal layout for player info */
        padding: 5px;
        background: transparent;
        font-size: 0.8rem;
        gap: 5px;
    }

    .player_img {
        width: 35px;
        height: 35px;
        margin-bottom: 0;
        border-width: 2px;
    }

    #current_turn_text {
        font-size: 1.2em;
    }

    /* 2. Middle Section: The Board */
    #checkerboard {
        order: 2;
        flex: 1;
        /* Take up remaining space */
        width: 100vw;
        max-width: 100vw;
        aspect-ratio: 1;
        /* Try to keep it square */
        margin: auto;
        /* Center vertically and horizontally */
        padding: 2px;
        border-radius: 5px;
        box-shadow: none;
        background: transparent;
        overflow: hidden;
        /* Prevent scrolling inside board */
    }

    .row {
        gap: 1px;
    }

    .cell {
        margin: 0;
        border-radius: 2px;
        border: none;
    }

    .cell p {
        font-size: 0.6em;
        opacity: 0.7;
    }

    /* Arrows on mobile */
    .arrow {
        width: 50%;
        height: 50%;
        opacity: 0.25;
    }

    /* 3. Bottom Section: Dice & Tasks */
    #dice {
        order: 3;
        width: 100%;
        flex: 0 0 auto;
        padding: 10px;
        background: white;
        border-radius: 15px 15px 0 0;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
        display: flex;
        flex-direction: row;
        /* Horizontal bar */
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        box-sizing: border-box;
    }

    #dice_num {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        flex: 1;
        gap: 10px;
    }

    #roll_dice {
        padding: 12px 24px;
        font-size: 1.1em;
        margin: 0;
        white-space: nowrap;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }

    #dice_num_text {
        font-size: 1.8em;
    }

    #task_text {
        flex: 1;
        margin: 0;
        font-size: 0.85em;
        background: #f8f9fa;
        padding: 5px 10px;
        border-radius: 5px;
        text-align: left;
        display: block;
        white-space: normal;
        /* Allow wrap */
        line-height: 1.2;
        max-height: 3em;
        /* Limit height */
        overflow: hidden;
    }

    /* Splash Screens */
    #gameOver h1 {
        font-size: 2em;
    }

    #gameOver p {
        font-size: 1.2em;
    }
}

/* Extra small screens fix */
@media (max-width: 380px) {
    .player_img {
        width: 30px;
        height: 30px;
    }

    #roll_dice {
        padding: 8px 16px;
        font-size: 0.9em;
    }

    #dice_num_text {
        font-size: 1.4em;
    }

    /* Ensure board fits vertically */
    #checkerboard {
        width: 95vw;
        height: 95vw;
        max-height: 60vh;
    }
}