* {
    box-sizing: border-box;
}

body {
    font-family: 'Rethink Sans', sans-serif;
    background-color: #FCFCFC;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
}

.screen.active {
    display: flex;
}

h1 {
    font-size: 60px;
    font-weight: 700;
    margin-bottom: 4px;
}

.subtitle {
    font-size: 16px;
    font-weight: 400;
}

#welcomeScreen {
    width: 100%;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: radial-gradient(106.85% 66.09% at 32.5% 22.33%, #FCFCFC 0%, #ECF2FF 50%, #FCFCFC 100%);
    padding: 0;
    margin: 0;
}

.welcomeContainer {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.floatingCharacters {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.floatingChar {
    position: absolute;
    width: 150px;
    height: 150px;
    object-fit: contain;
    pointer-events: auto;
    cursor: pointer;
}

.floatingChar:hover {
    animation: shake 0.5s ease-in-out infinite;
}

.floatingChar.star {
    top: 15%;
    left: 15%;
}

.floatingChar.dumpling {
    top: 15%;
    right: 15%;
}

.floatingChar.cat {
    bottom: 15%;
    left: 15%;
}

.floatingChar.letter {
    bottom: 15%;
    right: 15%;
}

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

.welcomeTitle {
    font-size: 80px;
    font-weight: 700;
    margin-bottom: 40px;
    z-index: 1;
}

.welcomeButton {
    background-color: #0F1312;
    color: #FCFCFC;
    border: none;
    padding: 18px 36px;
    font-size: 18px;
    border-radius: 99px;
    cursor: pointer;
    font-family: 'Rethink Sans', sans-serif;
    font-weight: 500;
    transition: all 0.3s ease;
    z-index: 1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.welcomeButton:hover {
    background-color: #2a2a2a;
    transform: translateY(-2px);
}

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

#selectionTitle {
    font-size: 16px;
    margin-top: 80px;
    font-weight: 600;
}

.characterOptions {
    display: flex;
    gap: 40px;
    justify-content: center;
    margin-top: 24px;
    margin-bottom: 40px;
}

.buttonContainer {
    display: flex;
    justify-content: center;
    align-items: center;
}

.characterButton {
    width: 175px;
    height: 175px;
    border: none;
    border-radius: 16px;
    background-color: #ECF2FF;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 12px;
}

.characterButton:hover {
    background-color: #d4e4ff;
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(30, 86, 205, 0.2);
}

.characterButton.selected {
    background-color: #1E56CD;
}

.characterButton.selected:hover {
    background-color: #1E56CD;
    transform: none;
    box-shadow: none;
}

.characterButton.selected .characterName {
    color: #FCFCFC;
}

.characterIcon {
    width: 100px;
    height: 100px;
    object-fit: contain;
}

.characterName {
    font-size: 16px;
    font-weight: 500;
    color: #0F1312;
    margin: 0;
}

.startButton {
    background-color: #F2F2F2;
    color: #0F1312;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 99px;
    cursor: pointer;
    font-family: 'Rethink Sans', sans-serif;
    font-weight: 400;
}

.startButton:hover {
    background-color: #0F1312;
    color: #FCFCFC;
}

#gameScreen {
    width: 100%;
    position: relative;
}

.gameHeader {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 48px;
    margin-top: 20px;
}

.headerScore {
    display: flex;
    align-items: center;
    gap: 32px;
}

#player1NameHeader, #player2NameHeader {
    font-size: 24px;
    font-weight: 500;
    width: 100px;
    text-align: center;
}

.scoreDisplay {
    font-size: 32px;
    font-weight: 600;
    width: auto;
}

.scoreDisplay span {
    font-size: 32px;
    font-weight: 600;
}

.gameContainer {
    display: grid;
    grid-template-columns: 200px 1fr 200px;
    gap: 40px;
    align-items: center;
    justify-items: center;
    margin-bottom: 32px;
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.playerInfo {
    text-align: center;
    width: 200px;
    height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-self: center;
    align-self: center;
}

.playerInfo p {
    font-size: 16px;
    margin-bottom: 16px;
    width: 100%;
}

.playerIconDisplay {
    width: 120px;
    height: 120px;
    background-color: #1E56CD;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    margin-bottom: 20px;
}

.playerIconDisplay img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.turnIndicator {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-top: 16px;
}

.turnIndicator svg {
    filter: drop-shadow(0 2px 4px rgba(30, 86, 205, 0.3));
    animation: floatArrow 1.5s ease-in-out infinite;
}

@keyframes floatArrow {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.boardContainer {
    background-color: #F2F2F2;
    padding: 40px;
    border-radius: 12px;
    grid-column: 2;
    position: relative;
}

#gameBoard {
    display: grid;
    grid-template-columns: repeat(3, 140px);
    grid-template-rows: repeat(3, 140px);
    gap: 2px;
    background-color: #1E56CD;
    padding: 2px;
}

.cell {
    background-color: #F2F2F2;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: background-color 0.2s ease;
}

.cell img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cell:hover:not(.taken) {
    background-color: #e8e8e8;
}

.cell.taken {
    cursor: not-allowed;
}

.gameFooter {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 24px;
}

.endButton {
    background-color: #F2F2F2;
    color: #0F1312;
    padding: 12px 24px;
    font-size: 16px;
    border: none;
    border-radius: 99px;
    cursor: pointer;
    font-family: 'Rethink Sans', sans-serif;
    font-weight: 400;
    transition: all 0.3s ease;
}

.endButton:hover {
    background-color: #0F1312;
    color: #FCFCFC;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.24);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modalContent {
    background-color: #FCFCFC;
    padding: 40px;
    border-radius: 12px;
    text-align: left;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.modalContent h2 {
    text-align: left;
    margin: 0 0 12px 0;
}

.modalContent p {
    font-size: 16px;
    margin: 0 0 30px 0;
    text-align: left;
}

.modalButtons {
    display: flex;
    gap: 16px;
    justify-content: flex-start;
}

.modalButtons .startButton {
    flex: 1;
    min-width: 120px;
}

.modalButtons .startButton.secondary {
    background-color: #F2F2F2;
    color: #0F1312;
    border: none;
    border-radius: 99px;
    margin-top: 0;
}

.modalButtons .startButton.secondary:hover {
    background-color: #e8e8e8;
}

.modalButtons .startButton:not(.secondary) {
    background-color: #0F1312;
    color: #FCFCFC;
    border-radius: 99px;
}

.modalButtons .startButton:not(.secondary):hover {
    background-color: #2a2a2a;
}

#winnerText {
    font-size: 24px;
    margin: 0 0 20px 0;
    text-align: center;
}

#winnerIcon {
    width: 100px;
    height: 100px;
    margin: 2px auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

#winnerIcon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#winnerModal .modalContent {
    text-align: center;
}

#winnerModal .modalContent .startButton {
    margin: 0 auto;
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -10px;
    z-index: 9999;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

@media (max-width: 800px) {
    body {
        padding: 10px;
        min-height: 100vh;
    }

    h1 {
        font-size: 40px;
    }

    .subtitle {
        font-size: 14px;
        padding: 0 20px;
    }

    .welcomeTitle {
        font-size: 48px;
        margin-bottom: 30px;
    }

    .floatingChar {
        width: 120px;
        height: 120px;
    }

    .floatingChar.star {
        top: 10%;
        left: 10%;
    }

    .floatingChar.dumpling {
        top: 12%;
        right: 10%;
    }

    .floatingChar.cat {
        bottom: 20%;
        left: 10%;
    }

    .floatingChar.letter {
        bottom: 18%;
        right: 10%;
    }

    .welcomeButton {
        padding: 14px 28px;
        font-size: 16px;
    }

    #selectionTitle {
        font-size: 14px;
        margin-top: 40px;
        padding: 0 20px;
    }

    .characterOptions {
        flex-wrap: wrap;
        gap: 20px;
        padding: 0 20px;
    }

    .characterButton {
        width: 140px;
        height: 140px;
        padding: 16px;
        gap: 8px;
    }

    .characterIcon {
        width: 70px;
        height: 70px;
    }

    .characterName {
        font-size: 14px;
    }

    .gameHeader {
        margin-bottom: 24px;
        margin-top: 10px;
    }

    .headerScore {
        gap: 16px;
    }

    #player1NameHeader,#player2NameHeader {
        font-size: 16px;
        width: 70px;
    }

    .scoreDisplay {
        font-size: 24px;
    }

    .scoreDisplay span {
        font-size: 24px;
    }

    .gameContainer {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 24px;
        padding: 0 10px;
    }

    .playerInfo {
        width: 100%;
        height: auto;
        flex-direction: row;
        justify-content: space-between;
        padding: 0 20px;
        grid-row: 1;
    }

    .playerInfo.nextPlayer {
        grid-row: 3;
    }

    .playerInfo p {
        font-size: 14px;
        margin-bottom: 0;
        text-align: left;
        flex: 1;
    }

    .playerIconDisplay {
        width: 80px;
        height: 80px;
        padding: 12px;
        margin-bottom: 0;
    }

    .turnIndicator {
        width: 40px;
        height: 40px;
        margin-top: 0;
        margin-left: 20px;
    }

    .turnIndicator svg {
        width: 40px;
        height: 40px;
        transform: rotate(-90deg);
    }

    .playerInfo.nextPlayer .turnIndicator svg {
        transform: rotate(-90deg);
    }

    @keyframes floatArrow {
        0%, 100% {
            transform: translateX(0px) rotate(-90deg);
        }
        50% {
            transform: translateX(-10px) rotate(-90deg);
        }
    }

    .playerInfo.nextPlayer .turnIndicator svg {
        animation: floatArrow 1.5s ease-in-out infinite;
    }

    .boardContainer {
        padding: 20px;
        grid-row: 2;
        grid-column: 1;
    }

    #gameBoard {
        grid-template-columns: repeat(3, 100px);
        grid-template-rows: repeat(3, 100px);
    }

    .cell {
        padding: 12px;
    }

    .gameFooter {
        margin-top: 16px;
    }

    .modalContent {
        padding: 24px;
        margin: 0 20px;
        max-width: 90%;
    }

    .modalContent h2 {
        font-size: 20px;
    }

    .modalContent p {
        font-size: 14px;
        margin-bottom: 20px;
    }

    .modalButtons {
        flex-direction: column;
    }

    .modalButtons .startButton {
        width: 100%;
    }

    #winnerText {
        font-size: 20px;
    }

    #winnerIcon {
        width: 80px;
        height: 80px;
    }
}