:root {
    --primary: #ff758c;
    --primary-dark: #d4366e;
    --secondary: #4b7bff;
    --bg-gradient: linear-gradient(135deg, #FF9A9E 0%, #FECFEF 99%, #FECFEF 100%);
    /* Sweeter, more "lovely" gradient */
    --card-bg: rgba(255, 255, 255, 0.25);
    --card-border: rgba(255, 255, 255, 0.5);
    --text-main: #5e2a40;
    /* Softer dark for contrast on light pink */
    --board-size: min(95vw, 500px);
    --tile-size: calc(var(--board-size) / 10);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#app {
    width: 100%;
    height: 100%;
    max-width: 600px;
    position: relative;
}

/* --- Screens --- */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    z-index: 0;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
    z-index: 10;
}

/* --- Menu --- */
.game-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 3.5rem;
    text-align: center;
    margin-top: 10vh;
    margin-bottom: 2rem;
    line-height: 1;
    color: #fff;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

.game-title span {
    font-size: 1.5rem;
    color: #ffeb3b;
    letter-spacing: 0.2em;
    background: #ff4b8b;
    padding: 0.2rem 1rem;
    border-radius: 20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--card-border);
    padding: 2rem;
    border-radius: 30px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

input {
    width: 100%;
    padding: 1rem;
    border-radius: 15px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.6);
    color: var(--text-main);
    font-size: 1.1rem;
    outline: none;
    text-align: center;
    transition: all 0.3s;
}

input:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(255, 75, 139, 0.2);
}

.btn {
    width: 100%;
    padding: 1rem;
    border-radius: 20px;
    border: none;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background: linear-gradient(135deg, #FF6B95, #FFB86C);
    color: white;
    box-shadow: 0 8px 20px rgba(255, 107, 149, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;
    box-shadow: 0 8px 20px rgba(79, 172, 254, 0.3);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--text-main);
    color: var(--text-main);
}

.divider {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-main);
    opacity: 0.7;
    margin: 0.5rem 0;
}

.join-group {
    display: flex;
    gap: 0.5rem;
}

.join-group input {
    flex: 2;
}

.join-group button {
    flex: 1;
}

.room-id-display {
    background: #fff;
    color: var(--primary);
    padding: 1rem;
    border-radius: 15px;
    font-family: monospace;
    font-size: 1.5rem;
    text-align: center;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1rem 0;
    border: 2px dashed var(--primary);
}

.btn-copy {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.btn-copy:hover {
    opacity: 1;
}

/* --- Game Screen --- */
#game-screen {
    padding: 1rem;
    justify-content: space-between;
}

.game-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.player-badge {
    background: rgba(255, 255, 255, 0.7);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 3px solid transparent;
    opacity: 0.7;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: var(--text-main);
    font-weight: 600;
}

.player-badge.active {
    opacity: 1;
    border-color: #FFD700;
    background: #fff;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transform: scale(1.05);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    background: #eee;
}

.info {
    display: flex;
    flex-direction: column;
}

.info .name {
    font-size: 0.8rem;
    font-weight: 700;
}

.info .pos {
    font-size: 0.7rem;
    opacity: 0.7;
}

.board-container {
    width: var(--board-size);
    height: var(--board-size);
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
    border: 4px solid #fff;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    width: 100%;
    height: 100%;
    background-image: url('board_bg.png');
    background-size: cover;
    background-position: center;
}

.tile {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.7rem;
    color: rgba(50, 50, 50, 0.7);
    position: relative;
    font-weight: 900;
    font-family: 'Fredoka', sans-serif;
    backdrop-filter: blur(2px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Sweet Coloring Pattern (Transparent) */
.tile:nth-child(odd) {
    background-color: rgba(255, 240, 245, 0.4);
}

.tile:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.4);
}

.tile:nth-child(4n+1) {
    background-color: rgba(255, 228, 230, 0.5);
}

.tile:nth-child(4n+3) {
    background-color: rgba(224, 247, 250, 0.5);
}

/* Special Tiles */
.tile-bonus {
    background-color: rgba(76, 175, 80, 0.3) !important;
    box-shadow: inset 0 0 10px rgba(76, 175, 80, 0.2);
}

.tile-penalty {
    background-color: rgba(244, 67, 54, 0.3) !important;
    box-shadow: inset 0 0 10px rgba(244, 67, 54, 0.2);
}

.tile-trap {
    background-color: rgba(33, 33, 33, 0.2) !important;
    border: 2px dashed #FF5722 !important;
}

.tile-effect {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 0.75rem;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 4px;
    padding: 1px 4px;
    color: #333;
    pointer-events: none;
}

/* Snakes and Ladders Overlay */
.board-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

/* Player Pieces */
.player-piece {
    width: 70%;
    height: 70%;
    border-radius: 50%;
    position: absolute;
    z-index: 10;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Bouncy move */
    box-shadow: 0 4px 5px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    border: 2px solid white;
}

.player-piece.p1 {
    background: #ff4b8b;
    bottom: 15%;
    right: 15%;
    color: white;
}

.player-piece.p2 {
    background: #4b7bff;
    top: 15%;
    left: 15%;
    color: white;
}

/* Control Area */
.controls-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.status-bar {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    background: rgba(0, 0, 0, 0.1);
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
}

.btn-roll {
    width: auto;
    padding: 0.8rem 3rem;
    font-size: 1.2rem;
    background: #fff;
    color: var(--primary);
    box-shadow: 0 6px 0 #eee;
    transform: translateY(0);
}

.btn-roll:active {
    box-shadow: 0 2px 0 #eee;
    transform: translateY(4px);
}

.btn-roll:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #ddd;
    color: #888;
    box-shadow: none;
}

/* 3D Dice */
.dice-container {
    perspective: 1000px;
    width: 60px;
    height: 60px;
}

.dice {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.face {
    position: absolute;
    width: 60px;
    height: 60px;
    background: white;
    border: 2px solid #ffeb3b;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
}

.front {
    transform: rotateY(0deg) translateZ(30px);
}

.back {
    transform: rotateY(180deg) translateZ(30px);
}

.right {
    transform: rotateY(90deg) translateZ(30px);
}

.left {
    transform: rotateY(-90deg) translateZ(30px);
}

.top {
    transform: rotateX(90deg) translateZ(30px);
}

.bottom {
    transform: rotateX(-90deg) translateZ(30px);
}

/* Win Overlay */
.win-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.5s;
}

.win-card {
    background: white;
    padding: 2rem;
    border-radius: 30px;
    text-align: center;
    width: 90%;
    max-width: 400px;
    animation: popIn 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.win-card h1 {
    font-family: 'Fredoka';
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.avatar-win {
    font-size: 4rem;
    margin: 1rem 0;
}

.love-msg {
    font-family: 'Fredoka';
    font-size: 1.5rem;
    color: #E91E63;
    margin: 1rem 0 2rem;
    line-height: 1.4;
}

/* Confetti */
.confetti {
    position: fixed;
    top: -10px;
    width: 10px;
    height: 10px;
    background: red;
    z-index: 999;
    animation: fall linear forwards;
}

@keyframes fall {
    to {
        transform: translateY(100vh) rotate(720deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes popIn {
    from {
        transform: scale(0.5);
    }

    to {
        transform: scale(1);
    }
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    color: var(--primary);
    padding: 0.8rem 2rem;
    border-radius: 50px;
    z-index: 100;
    font-weight: 700;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    transition: opacity 0.3s, transform 0.3s;
}

.toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
}

/* Game Notification (Above Dice) */
.game-notification {
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary-dark);
    padding: 0.5rem 1rem;
    border-radius: 15px;
    font-weight: 700;
    font-size: 1rem;
    margin: 0.5rem 0;
    min-height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: opacity 0.3s, transform 0.3s;
    text-align: center;
    border: 2px solid var(--primary);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.game-notification.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    position: absolute;
    /* Take out of flow when hidden to prevent layout shift? 
                          Or keep relative to maintain space? 
                          Let's try absolute to avoid jumpiness, or display: none behavior via class logic.
                          If we want it "Above dice", occupying space is fine.
                          But if hidden, better to collapse? 
                          The 'hidden' class usually implies opacity 0. 
                          Let's make it display:none if completely gone or just distinct visibility state.
                       */
    display: none;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid var(--primary);
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
    margin: 0 auto;
}

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

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

/* SVG Lines */
/* SVG Lines */
line {
    /* stroke-width handled in JS attributes (0.5 for thin) */
    stroke-linecap: round;
    /* optional: vector-effect: non-scaling-stroke if we want constant pixel width, 
       but viewBox is fixed, so relative width is fine. */
}

@media (max-width: 400px) {
    .game-title {
        font-size: 2.5rem;
    }

    :root {
        --board-size: 96vw;
    }
}