* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #0a0a0a;
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    padding: 10px;
}

.game-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 20px;
}

.kassie-branding {
    height: calc(100vh - 20px);
    max-height: 450px;
    width: auto;
    opacity: 0.5;
    margin-bottom: 5px;
}

.kassie-branding-left {
    transform: scaleX(-1);
}

/* Hide branding on smaller screens and tablets */
@media (max-width: 1024px) {
    .kassie-branding {
        display: none;
    }
    
    body {
        background-color: #1a1a1a;
        padding: 0;
        align-items: center;
        justify-content: center;
    }
    
    .game-wrapper {
        padding: 0;
        width: 100%;
        height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    #game-container {
        border: none !important;
        border-radius: 0 !important;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
    }
    
    #score-display {
        top: 10% !important;
        left: 50%;
        /* transform: translateX(-50%); */
        align-items: center;
        position:absolute;
    }
    
    .kassie-avatar {
        left: 50%;
        transform: translate(-50%, calc(-50% + 10px));
    }
    
    .kassie-avatar.pulsing {
        animation: avatarAnimationMobile 2s ease-out;
    }
    
    @keyframes avatarAnimationMobile {
        0% {
            transform: translate(-50%, calc(-50% + 10px)) scale(0.5);
            opacity: 0.2;
        }
        50% {
            transform: translate(-50%, calc(-50% + 10px)) scale(1.4);
            opacity: 0.3;
        }
        100% {
            transform: translate(-50%, calc(-50% + 10px)) scale(1.4);
            opacity: 0;
        }
    }
    
    #blocks-container {
        bottom: 70px !important;
    }
}

#game-over-heading {
    position: absolute;
    top: 75%;
    left: 50%;
    transform: translateX(-50%);
    color: #ff4444;
    font-size: 26px;
    font-weight: bold;
    text-align: center;
    z-index: 1000;
    display: none;
}

#game-over-heading.show {
    display: block;
    animation: gameOverAnimation 0.5s ease-out forwards;
}

#lets-go-heading {
    position: absolute;
    top: 75%;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 30px;
    font-weight: bold;
    text-align: center;
    z-index: 1000;
    animation: letsGoAnimation 2s ease-out forwards;
}

@keyframes gameOverAnimation {
    0% {
        transform: translateX(-50%) scale(0.5);
        opacity: 0;
    }
    100% {
        transform: translateX(-50%) scale(1.4);
        opacity: 1;
    }
}

@keyframes letsGoAnimation {
    0% {
        transform: translateX(-50%) scale(0.5);
        opacity: 0;
    }
    100% {
        transform: translateX(-50%) scale(1.5);
        opacity: 1;
    }
}

.material-symbols-outlined {
    font-variation-settings:
    'FILL' 1,
    'wght' 400,
    'GRAD' 0,
    'opsz' 48
}

#game-container {
    position: relative;
    width: 280px;
    height: calc(100vh - 20px);
    max-height: 800px;
    background-color: #1a1a1a;
    border: 1px solid white;
    border-radius: 24px;
    overflow: hidden;
}

.settings-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 24px;
    color: #ffffff;
    cursor: pointer;
    z-index: 100;
    user-select: none;
    transition: color 0.3s;
}

.settings-icon:hover {
    color: #00ff88;
    animation: iconRotate 2s linear infinite;
}

.speel-icon {
    position: absolute;
    top: 5px;
    left: 10px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    z-index: 100;
    user-select: none;
}

.speel-icon:hover {
    filter: brightness(1.2);
}

#score-display {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    
    height: 25%;
}

.kassie-avatar {
    width: 80px;
    height: 80px;
    opacity: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, calc(-50% + 10px));
    z-index: -1;
    pointer-events: none;
    transition: transform 0.1s;
}

.kassie-avatar.pulsing {
    animation: avatarAnimation 2s ease-out;
}

@keyframes avatarAnimation {
    0% {
        transform: translate(-50%, calc(-50% + 10px)) scale(0.5);
        opacity: 0.2;
    }
    50% {
        transform: translate(-50%, calc(-50% + 10px)) scale(1.5);
        opacity: 0.3;
    }
    100% {
        transform: translate(-50%, calc(-50% + 10px)) scale(1.5);
        opacity: 0;
    }
}

.kassie-avatar.rotating {
    animation: continuousRotate 2s linear;
}

.score-label {
    font-size: 10px;
    font-weight: bold;
    color: #888;
    letter-spacing: 1px;
}

.score-value {
    font-size: 40px;
    font-weight: bold;
    color: #00ff88;
    margin-top: 20px;
    position: relative;
    z-index: 1;
    min-height: 48px;
}

.level-stars {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.level-star {
    width: 30px;
    height: 30px;
    transition: filter 0.3s ease;
    transform-style: preserve-3d;
}

.level-star.active {
    filter: brightness(0) saturate(100%) invert(45%) sepia(98%) saturate(2847%) hue-rotate(193deg) brightness(101%) contrast(101%);
    animation: coinSpin 2s ease-in-out;
}

.level-star.activating {
    animation: coinSpin 2s ease-in-out;
}

#grid-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#game-grid {
    background-color: #111111;
    border: 1px solid #ffffff;
    display: grid;
    grid-template-columns: repeat(8, 28px);
    grid-template-rows: repeat(8, 28px);
    gap: 1px;
    padding: 0;
    box-sizing: content-box;
    width: fit-content;
    height: fit-content;
}

.grid-cell {
    width: 28px;
    height: 28px;
    background-color: #333333;
    box-sizing: border-box;
    position: relative;
}

.grid-cell.filled {
    box-shadow: inset 2px 2px 2px rgba(155, 155, 155, 0.5),
                inset -2px -2px 2px rgba(0, 0, 0, 0.3);
}

.grid-cell.clearing {
    animation: glowPulse 0.2s ease-out;
}

.grid-cell.highlight {
    background-color: #004433;
    box-shadow: inset 0 0 8px rgba(0, 255, 136, 0.5);
}

.grid-cell.highlight.valid {
    opacity: 1;
    background-color: transparent;
    outline: 2px solid rgba(0, 255, 136, 0.5);
    outline-offset: -2px;
}

/* Show colored preview after 1 second hover on mobile */
.grid-cell.highlight.valid.hovering {
    background-color: inherit !important; /* Use color set by JS */
    outline: none;
}

.grid-cell.highlight.invalid {
    background-color: transparent;
    outline: 2px solid rgba(255, 0, 0, 0.5);
    outline-offset: -2px;
}

.grid-cell.cursor {
    outline: 2px solid #00ff88;
    outline-offset: -2px;
    z-index: 10;
}

#blocks-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    justify-content: center;
}

.block-slot {
    width: 70px;
    height: 70px;
    background-color: #222222;
    border-radius: 8px;
    border: 1px solid #444444;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.block-slot:hover {
    width: 70px;
    height: 70px;
    background-color: #111;
    border-radius: 8px;
    border: 1px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.preview-block {
    display: grid;
    gap: 1px;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.preview-block:active {
    cursor: grabbing;
}

.preview-cell {
    width: 11px;
    height: 11px;
    box-shadow: inset 1px 1px 2px rgba(255, 255, 255, 0.3),
                inset -1px -1px 2px rgba(0, 0, 0, 0.5);
}

.preview-cell-empty {
    width: 11px;
    height: 11px;
    background: transparent;
}

.block-slot.used {
    opacity: 0.3;
}

/* Drag ghost element */
.drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    display: grid;
    gap: 1px;
    transform: translate(-50%, -50%);
    opacity: 0.3;
}

.drag-ghost .ghost-cell {
    width: 28px;
    height: 28px;
    box-shadow: inset 2px 2px 4px rgba(255, 255, 255, 0.3),
                inset -2px -2px 4px rgba(0, 0, 0, 0.5);
}

.drag-ghost .ghost-cell-empty {
    width: 28px;
    height: 28px;
    background: transparent;
}

/* Falling Stars */
.falling-star {
    position: absolute;
    width: 40px;
    height: 40px;
    pointer-events: none;
    z-index: 999;
    animation: starFall linear forwards;
}

/* Animations */
@keyframes fadeOut {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -70%) scale(1.3);
    }
}

@keyframes starFall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg) scale(1);
    }
    25% {
        opacity: 1;
        transform: translateY(calc(var(--fall-distance) * 0.25)) rotate(calc(var(--rotation-speed) * 0.25)) scale(var(--scale-25));
    }
    50% {
        opacity: 1;
        transform: translateY(calc(var(--fall-distance) * 0.5)) rotate(calc(var(--rotation-speed) * 0.5)) scale(var(--scale-50));
    }
    75% {
        opacity: 1;
        transform: translateY(calc(var(--fall-distance) * 0.75)) rotate(calc(var(--rotation-speed) * 0.75)) scale(var(--scale-75));
    }
    95% {
        opacity: 1;
        transform: translateY(calc(var(--fall-distance) * 0.95)) rotate(calc(var(--rotation-speed) * 0.95)) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(var(--fall-distance)) rotate(var(--rotation-speed)) scale(1);
    }
}

@keyframes starExplodeHorizontal {
    0% {
        opacity: 1;
        transform: translateX(0) translateY(0) rotate(0deg) scale(1);
    }
    50% {
        transform: translateX(var(--explode-x)) translateY(0) rotate(360deg) scale(2);
    }
    100% {
        opacity: 0;
        transform: translateX(var(--explode-x)) translateY(50px) rotate(720deg) scale(1);
    }
}

@keyframes starExplodeVertical {
    0% {
        opacity: 1;
        transform: translateX(0) translateY(0) rotate(0deg) scale(1);
    }
    50% {
        transform: translateX(0) translateY(var(--explode-y)) rotate(360deg) scale(2);
    }
    100% {
        opacity: 0;
        transform: translateX(50px) translateY(var(--explode-y)) rotate(720deg) scale(1);
    }
}

@keyframes starExplodeRadial {
    0% {
        opacity: 1;
        transform: translateX(0) translateY(0) rotate(0deg) scale(0.4);
    }
    50% {
        opacity: 0.7;
        transform: translateX(calc(var(--explode-x) * 0.5 + var(--sine-x))) translateY(calc(var(--explode-y) * 0.5 + var(--sine-y))) rotate(360deg) scale(2);
    }
    100% {
        opacity: 0;
        transform: translateX(calc(var(--explode-x) + var(--sine-x) * 0.5)) translateY(calc(var(--explode-y) + var(--sine-y) * 0.5)) rotate(720deg) scale(0.4);
    }
}


@keyframes glowPulse {
    0% {
        box-shadow: inset 2px 2px 4px rgba(255, 255, 255, 0.3),
                    inset -2px -2px 4px rgba(0, 0, 0, 0.5);
    }
    50% {
        box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.8),
                    0 0 20px rgba(255, 255, 255, 0.6);
        filter: brightness(1.5);
    }
    100% {
        box-shadow: inset 2px 2px 4px rgba(255, 255, 255, 0.3),
                    inset -2px -2px 4px rgba(0, 0, 0, 0.5);
    }
}

@keyframes rotate3d {
    0% {
        transform: perspective(200px) rotateZ(0deg);
    }
    100% {
        transform: perspective(200px) rotateZ(360deg);
    }
}

@keyframes coinSpin {
    0% {
        transform: perspective(200px) rotateY(0deg) scale(1);
    }
    25% {
        transform: perspective(200px) rotateY(180deg) scale(2);
    }
    50% {
        transform: perspective(200px) rotateY(360deg) scale(1);
    }
    75% {
        transform: perspective(200px) rotateY(540deg) scale(2);
    }
    100% {
        transform: perspective(200px) rotateY(720deg) scale(1);
    }
}

@keyframes continuousRotate {
    0% {
        transform: translate(-50%, calc(-50% + 25px)) perspective(200px) rotateY(0deg);
    }
    100% {
        transform: translate(-50%, calc(-50% + 25px)) perspective(200px) rotateY(360deg);
    }
}

@keyframes iconRotate {
    0% {
        transform: rotateZ(0deg);
    }
    100% {
        transform: rotateZ(360deg);
    }
}

@keyframes starPulse {
    0% {
        transform: perspective(200px) rotateY(0deg) scale(1);
    }
    25% {
        transform: perspective(200px) rotateY(180deg) scale(2);
    }
    50% {
        transform: perspective(200px) rotateY(360deg) scale(1);
    }
    75% {
        transform: perspective(200px) rotateY(540deg) scale(2);
    }
    100% {
        transform: perspective(200px) rotateY(720deg) scale(1);
    }
}