:root {
    /* Color Palette */
    --bg-pink: #FDD6D1;
    --content-cream: #FFF9E6;
    --bag-red: #FF6B6B;
    --accent-gold: #FFD93D;
    --text-brown: #5D4037;

    /* Tile Colors */
    --tile-white: #FFFFFF;
    --tile-pink: #FFB7B2;
    --tile-green: #A8E6CF;
    /* Mugwort Green */
    --tile-gold: #FFD700;
}

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

body {
    font-family: 'Gaegu', cursive;
    /* Handwritten feel for texts */
    background-color: var(--bg-pink);
    color: var(--text-brown);
    height: 100vh;
    overflow: hidden;
    display: flex;
    /* Center the wrapper */
    justify-content: center;
    align-items: center;
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><text y="20" font-size="20">🥕</text></svg>'), auto;

    /* Pixel Art Background Pattern */
    background-image:
        radial-gradient(circle, #ffffff 2px, transparent 2.5px);
    background-size: 30px 30px;
}

#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

.pixel-title {
    font-family: 'DotGothic16', sans-serif;
    font-size: 2.2rem;
    text-align: center;
    color: var(--text-brown);
    text-shadow: 2px 2px 0 #FFF, 4px 4px 0 rgba(0, 0, 0, 0.1);
    line-height: 1.2;
}

.count-badge {
    text-align: center;
    font-size: 1.2rem;
    color: var(--text-brown);
    margin-top: 0.5rem;
}

/* Main Wrapper - Split Layout on Desktop */
.game-wrapper {
    width: 95%;
    max-width: 1000px;
    /* Wider for side-by-side */
    height: 85vh;
    /* Fixed viewport height */
    display: flex;
    flex-direction: row;
    /* Side by Side */
    align-items: center;
    /* Vertically center */
    padding: 0;
    gap: 2rem;
    position: relative;
    /* Glass card effect for the wrapper itself? No, keeping individual sections clean */
}

/* Left Panel: Header + Bag */
.game-left {
    flex: 1;
    height: auto;
    /* Allow shrink-wrap for vertical centering */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Header within Left Panel */
.game-header {
    margin-bottom: 2rem;
}

/* Center Stage (Bag) within Left Panel */
.center-stage {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    /* Rabbit positioning relies on this */
}

/* Right Panel: Dashboard */
.game-right {
    flex: 1;
    height: auto;
    /* Allow shrink-wrap */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Dashboard Card Style */
.bottom-dashboard {
    background-color: var(--content-cream);
    border-radius: 20px;
    border: 4px solid var(--text-brown);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 600px;
    /* Fixed height for consistency */
    max-height: 80vh;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    position: relative;
}

.bottom-dashboard h3 {
    font-size: 1.5rem;
    /* Increased size (+4px approx) */
    margin-bottom: 0.5rem;
    border-bottom: 2px dashed #DDD;
    text-align: center;
}

.result-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 0 auto;
}

.big-tile-slot {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Contain scroll */
}

/* Tiles (Rice Cakes) */
.tile,
.mini-tile {
    font-family: 'DotGothic16', sans-serif;
    border-radius: 50%;
    /* Round Rice Cake shape */
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    color: var(--text-brown);
    border: 3px solid var(--text-brown);
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
    position: relative;
    background-color: var(--tile-white);
    /* Default fallback */
}

/* Shine effect on rice cake */
.tile::after,
.mini-tile::after {
    content: '';
    position: absolute;
    top: 15%;
    left: 20%;
    width: 25%;
    height: 15%;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.6);
}

.tile {
    width: 90px;
    height: 90px;
    font-size: 3.2rem;
    /* Increased size (+10px approx) */
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tile.hidden {
    transform: scale(0);
    opacity: 0;
}

/* Tile Variants */
.tile-white {
    background-color: var(--tile-white);
}

.tile-pink {
    background-color: var(--tile-pink);
}

.tile-green {
    background-color: var(--tile-green);
}

.tile-gold {
    background-color: var(--tile-gold);
    border-color: #B45309;
    color: #78350F;
}

.mini-tile {
    width: 40px;
    height: 40px;
    font-size: 1rem;
}

/* Contain scroll */


.history-track {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    /* Stack from top */
    gap: 0.5rem;
    overflow-y: auto;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 12px;
    height: 100%;
    /* Fill remaining space */
}

.reset-link {
    margin-top: auto;
    /* Push to bottom */
    background: none;
    border: none;
    text-decoration: underline;
    color: var(--text-brown);
    opacity: 0.6;
    font-size: 0.9rem;
    cursor: pointer;
    text-align: center;
    padding-top: 1rem;
}

/* Character & Bag adjustments for split view */
.character-area {
    position: absolute;
    left: 10px;
    /* Shift slightly right to not be off-screen */
    top: 50%;
    /* Center vertically relative to bag area */
    transform: translateY(-50%);
    /* Center it */
    z-index: 1;
    /* Removed bottom positioning to avoid top cut-off */
}

.rabbit-img {
    width: 130px;
    /* Slightly smaller to fit better */
    filter: drop-shadow(4px 4px 0 rgba(0, 0, 0, 0.1));
    animation: breath 3s infinite ease-in-out;
}

/* CSS Drawn Lucky Bag */
.lucky-bag {
    width: 200px;
    height: 180px;
    position: relative;
    z-index: 2;
    /* Ensure it's above other things */
}

.bag-area {
    position: relative;
    z-index: 2;
    cursor: pointer;
    transition: transform 0.1s;
}

.bag-body {
    width: 180px;
    height: 140px;
    background-color: var(--bag-red);
    border-radius: 40% 40% 45% 45% / 60% 60% 40% 40%;
    /* Organic bag shape */
    position: absolute;
    bottom: 0;
    left: 10px;
    border: 4px solid var(--text-brown);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset -10px -10px 0 rgba(0, 0, 0, 0.1);
}

.bag-symbol {
    font-family: 'DotGothic16', sans-serif;
    font-size: 3rem;
    color: var(--accent-gold);
    text-shadow: 2px 2px 0 var(--text-brown);
}

.bag-top {
    width: 100px;
    height: 40px;
    background-color: var(--bag-red);
    position: absolute;
    top: 10px;
    left: 50px;
    border-radius: 50% 50% 10% 10%;
    border: 4px solid var(--text-brown);
    z-index: -1;
}

.bag-string-left,
.bag-string-right {
    width: 60px;
    height: 60px;
    border: 6px solid var(--accent-gold);
    border-radius: 50%;
    position: absolute;
    top: 20px;
    z-index: 5;
    /* Create knot look */
    border-bottom-color: transparent;
    border-right-color: transparent;
}

.bag-string-left {
    left: 20px;
    transform: rotate(45deg);
}

.bag-string-right {
    right: 20px;
    transform: rotate(135deg);
}

.click-hint {
    text-align: center;
    margin-top: 1rem;
    font-weight: 700;
    font-size: 1.3rem;
    /* Increased size */
    color: var(--text-brown);
    animation: bounce 1s infinite;
}

/* Animations */
@keyframes squeeze {
    0% {
        transform: scale(1, 1);
    }

    30% {
        transform: scale(1.15, 0.85);
    }

    50% {
        transform: scale(0.95, 1.05);
    }

    70% {
        transform: scale(1.05, 0.95);
    }

    100% {
        transform: scale(1, 1);
    }
}

.squeeze-anim .lucky-bag {
    animation: squeeze 0.4s ease-out;
}

@keyframes bounce {

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

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

/* Mobile Responsive - Stack Vertical */
@media (max-width: 768px) {
    .game-wrapper {
        flex-direction: column;
        height: auto;
        max-height: none;
        padding: 1rem;
        gap: 1rem;
    }

    .game-left {
        height: auto;
        margin-bottom: 1rem;
    }

    .game-right {
        height: auto;
        width: 100%;
    }

    .bottom-dashboard {
        max-height: none;
        height: auto;
    }

    .history-track {
        max-height: 200px;
        /* Limit height on mobile so it doesn't scroll infinite */
        height: auto;
    }

    .lucky-bag {
        transform: scale(0.9);
    }

    .rabbit-img {
        width: 140px;
    }

    .character-area {
        left: 10%;
        transform: none;
    }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background-color: var(--content-cream);
    padding: 3rem;
    border-radius: 30px;
    border: 5px solid var(--text-brown);
    text-align: center;
    box-shadow: 0 10px 0 rgba(0, 0, 0, 0.2);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal h2 {
    font-size: 2rem;
    color: var(--text-brown);
    margin-bottom: 1rem;
    font-family: 'DotGothic16', sans-serif;
}

.modal-score {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--bag-red);
    margin: 2rem 0;
}

.modal-btn {
    background-color: var(--bag-red);
    color: #FFF;
    border: none;
    padding: 1rem 3rem;
    font-size: 1.5rem;
    border-radius: 50px;
    font-family: 'Gaegu', cursive;
    cursor: pointer;
    border: 3px solid var(--text-brown);
    box-shadow: 0 5px 0 var(--text-brown);
    transition: transform 0.1s;
}

.modal-btn:hover {
    transform: translateY(2px);
    box-shadow: 0 3px 0 var(--text-brown);
}

.modal-btn:active {
    transform: translateY(5px);
    box-shadow: none;
}

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

    100% {
        transform: scale(1);
        opacity: 1;
    }
}