:root {
    --bg-color: #FFFBF0;
    /* Cream */
    --text-color: #5D5D5D;
    --card-bg: #FFFFFF;

    /* Cozy Palette */
    --primary-color: #B5EAD7;
    /* Pastel Green */
    --secondary-color: #87CEEB;
    /* Sky Blue - P1 */
    --secondary-light: #E0F7FA;
    /* Light Blue for P1 Column */
    --p2-color: #C3B1E1;
    /* Pastel Purple/Lavender - P2 */
    --p2-light: #F3E5F5;
    /* Light Purple for P2 Column */
    --accent-color: #FFB7B2;
    /* Pastel Red/Pink */
    --peach: #FFDAC1;
    --warm-gray: #D3C4BE;
    --highlight-color: #FFB7B2;

    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --radius: 12px;
}

body {
    margin: 0;
    font-family: 'Nunito', 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

.game-container {
    width: 100%;
    max-width: 600px;
    /* Slightly wider for score card */
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    position: relative;
}

header {
    text-align: center;
    flex-shrink: 0;
    margin-bottom: 10px;
}

h1 {
    margin: 0;
    color: var(--peach);
    font-size: 2.5rem;
    text-shadow: 2px 2px 0px var(--accent-color);
    letter-spacing: 1px;
}

.subtitle {
    margin: 5px 0 15px 0;
    color: var(--primary-color);
    font-weight: bold;
    letter-spacing: 0.5px;
}

#game-area {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#game-area::-webkit-scrollbar {
    display: none;
}

/* Dice Area */
.dice-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-color);
    border-radius: var(--radius);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.die {
    width: 50px;
    height: 50px;
    background: white;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    font-weight: normal;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    border: 3px solid transparent;
    user-select: none;
}

/* Dice */
.die:nth-child(1) {
    animation-delay: 0s;
}

.die:nth-child(2) {
    animation-delay: 0.1s;
}

.die:nth-child(3) {
    animation-delay: 0.05s;
}

.die:nth-child(4) {
    animation-delay: 0.15s;
}

.die:nth-child(5) {
    animation-delay: 0.08s;
}

.die.held {
    border-color: var(--secondary-color);
    background: var(--secondary-light);
    transform: translateY(-5px);
    box-shadow: 0 8px 12px rgba(135, 206, 235, 0.4);
}

/* P2 Held State (applied via JS class 'p2-turn') */
.p2-turn .die.held {
    border-color: var(--p2-color);
    background: var(--p2-light);
    box-shadow: 0 8px 12px rgba(195, 177, 225, 0.4);
}

.die.rolling {
    animation: bounce 0.5s infinite;
}

@keyframes bounce {
    0% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-20px) rotate(180deg);
    }

    100% {
        transform: translateY(0) rotate(360deg);
    }
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.roll-btn {
    background: var(--primary-color);
    border: none;
    padding: 10px 25px;
    border-radius: 50px;
    font-weight: bold;
    color: #555;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.roll-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rolls-left {
    font-weight: bold;
    color: var(--warm-gray);
}

/* Score Card */
.score-card {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
}

.score-card th,
.score-card td {
    padding: 8px;
    border-bottom: 1px solid #eee;
}

.score-card th {
    text-align: left;
    color: var(--warm-gray);
}

.score-cell {
    text-align: center;
    width: 60px;
    background: #fdfdfd;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    color: #ccc;
    /* Placeholder color */
}

.score-cell:hover {
    background: #f0f0f0;
}

.score-cell.filled {
    color: var(--text-color);
    font-weight: bold;
    background: transparent;
    cursor: default;
}

.score-cell.potential {
    color: var(--primary-color);
    background: #e6f7f2;
}

.score-cell.zero {
    color: #ccc;
    text-decoration: line-through;
}

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

.total-row {
    background: var(--bg-color);
    font-weight: bold;
}

/* Player Headers */
.player-header {
    text-align: center;
    padding: 5px;
    border-radius: 8px 8px 0 0;
    font-weight: bold;
    color: var(--warm-gray);
}

.player-header.active {
    color: white;
}

#p1-header.active {
    background-color: var(--secondary-color);
}

#p2-header.active {
    background-color: var(--p2-color);
}

/* Active Column Coloring */
.game-container.p1-turn .score-cell.p1 {
    background-color: var(--secondary-light);
}

.game-container.p1-turn .score-cell.p1:hover {
    background-color: #B3E5FC;
}

.game-container.p2-turn .score-cell.p2 {
    background-color: var(--p2-light);
}

.game-container.p2-turn .score-cell.p2:hover {
    background-color: #E1BEE7;
}

/* Overlay & Modals (Recycled from FirstLast) */
.game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    backdrop-filter: blur(5px);
}

.game-overlay.hidden {
    display: none;
}

/* Game Over Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 90%;
    width: 320px;
    animation: popIn 0.3s ease;
}

.overlay-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    width: 400px;
}

/* Lobby Inputs */
input[type="text"] {
    padding: 15px;
    font-size: 1.2rem;
    border: 3px solid #EEE;
    border-radius: 12px;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    color: #555;
    font-weight: bold;
    margin-bottom: 20px;
    transition: border-color 0.3s;
}

input[type="text"]:focus {
    border-color: #B5EAD7;
}

.lobby-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.join-section {
    display: flex;
    gap: 10px;
}

.join-section input {
    margin-bottom: 0;
    flex: 1;
    text-transform: uppercase;
}

button {
    padding: 15px;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

button:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: #B5EAD7;
    color: #444;
}

.btn-secondary {
    background-color: #EEE;
    color: #333;
}

.room-code-display {
    font-size: 2.5rem;
    font-family: monospace;
    letter-spacing: 5px;
    color: var(--text-color);
    background: #f9f9f9;
    padding: 10px 20px;
    border-radius: 10px;
    margin: 10px 0;
    border: 2px dashed var(--warm-gray);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .game-container {
        padding: 10px;
    }

    h1 {
        font-size: 2rem;
    }

    #game-area {
        padding: 10px;
    }

    /* Dice adjustments */
    .dice-container {
        gap: 5px;
        padding: 5px;
    }

    .die {
        width: 40px;
        height: 40px;
        font-size: 2.2rem;
        /* Adjusted for smaller box */
        border-radius: 6px;
    }

    /* Controls */
    .controls {
        gap: 10px;
    }

    .roll-btn {
        padding: 8px 15px;
        font-size: 1rem;
    }

    .rolls-left {
        font-size: 0.9rem;
    }

    /* Score Card squishing */
    .score-card {
        font-size: 0.8rem;
    }

    .score-card th,
    .score-card td {
        padding: 4px;
    }

    .score-cell {
        width: 40px;
    }

    .room-code-display {
        font-size: 1.8rem;
        letter-spacing: 2px;
    }
}