:root {
    --bg-color: #0f0f13;
    --text-color: #ffffff;
    --accent-color: #ffea6f;
    --title-color: #ffea6f;
    --title-color-secondary: #FFC629;
    --secondary-color: #2a2a35;
    --success-color: #4ade80;
    --fail-color: #f87171;
    --font-main: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#app {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;

    padding: 2rem 1rem;
    max-width: 600px;
}

#banner-container:empty {
    display: none;
}

header {
    text-align: center;
    z-index: 10;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(100deg, var(--title-color), var(--title-color-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.highlight {
    color: var(--accent-color);
    cursor: pointer;
    position: relative;
    z-index: 100;
}

.subtitle {
    color: #888;
    font-weight: 300;
}

#game-container {
    position: relative;
    width: 100%;
    margin: auto 0;

    aspect-ratio: 1;
    max-height: 60vh;
    background: var(--secondary-color);
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

#overlay,
#result-overlay,
#intro-overlay,
#game2-intro-overlay,
#game2-play-overlay,
#game2-result-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 15, 19, 0.8);
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#overlay.hidden,
#result-overlay.hidden,
#intro-overlay.hidden,
#game2-intro-overlay.hidden,
#game2-play-overlay.hidden,
#game2-result-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#overlay.visible {
    opacity: 1;
    pointer-events: none;

}

#intro-overlay.visible {
    opacity: 1;
    pointer-events: auto;

}

#intro-overlay.visible .content {
    animation: slideInLeft 0.5s ease-out forwards;
}

#result-overlay.visible,
#game2-intro-overlay.visible,
#game2-play-overlay.visible,
#game2-result-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.content {
    text-align: center;
    width: 100%;
    padding: 0 20px;
}

h2 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

#action-bar,
#game2-action-bar,
#game2-result-action-bar {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

.action-btn {
    width: 100%;
    max-width: 300px;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    font-family: var(--font-main);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #555;
    color: #888;
}

.action-btn:active {
    transform: scale(0.98);
}

.btn-fail {
    background-color: var(--secondary-color);
    color: var(--fail-color);
    border: 2px solid var(--fail-color);
}

.btn-success {
    background-color: var(--success-color);
    color: #fff;
}

.fail-banner {
    width: 100vw;
    background-color: var(--secondary-color);
    color: var(--fail-color);
    padding: 1.5rem;
    text-align: center;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-top: 2px solid var(--fail-color);
    border-bottom: 2px solid var(--fail-color);
    pointer-events: none;
    margin-top: 1rem;
    margin-bottom: 1rem;
    animation: slideInLeft 0.5s ease-out forwards;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

#tap-hint,
.tap-hint {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 0.9rem;
    color: #888;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

footer {
    text-align: center;
    color: #666;
    font-weight: 500;
}

#draw-hint {
    position: absolute;
    bottom: 30px;
    width: 100%;
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: #888;
    pointer-events: none;
    animation: pulse 2s infinite;
}

#game-input {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--secondary-color);
    border-radius: 12px;
    padding: 1rem;
    color: #fff;
    font-family: var(--font-main);
    font-size: 1.2rem;
    width: 100%;
    max-width: 300px;
    margin-top: 1rem;
    text-align: center;
    outline: none;
}

#game-input:focus {
    border-color: var(--accent-color);
}



.game2-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    gap: 2rem;

}

.card-stack-area {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;

    justify-content: center;
    position: relative;
}

.ranking-area {
    width: 140px;

    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

#card-stack {
    position: relative;
    max-width: 100%;
    width: 280px;
    /* 2x rank-box width */
    height: 160px;
    /* 2x rank-box max-height */
}

.card {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    cursor: grab;
    transition: transform 0.1s linear;

    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #333;
    font-weight: bold;
    user-select: none;
    touch-action: none;
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.card.dragging {
    cursor: grabbing;
    z-index: 100;
    transition: none;

    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    opacity: 0.5;
}

.ranking-boxes {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    height: 100%;

    justify-content: center;

}

.rank-box {
    width: 100%;
    flex: 1;

    max-height: 80px;

    border: 2px dashed #444;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #444;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
    cursor: default;
}

.rank-box.filled {
    border-style: solid;
    border-color: var(--success-color);
    background: rgba(74, 222, 128, 0.1);
    color: var(--success-color);
    font-size: 1rem;
    overflow: hidden;
    overflow: hidden;
    position: relative;
    cursor: grab;
}

.rank-box.filled:active {
    cursor: grabbing;
}

.rank-box.highlight {
    border-color: var(--accent-color);
    background: rgba(255, 234, 111, 0.1);
    transform: scale(1.05);
}

.rank-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.6;
}


@media (max-width: 600px) {
    .game2-container {
        flex-direction: row;

        gap: 0.5rem;

        padding: 0.5rem;
    }

    #app {
        padding: 1rem;

    }

    .card-stack-area {
        height: 100%;
        flex: 1;
    }

    .ranking-area {
        height: 100%;
        width: 100px;

        flex-shrink: 0;
        flex-direction: column;

        align-items: center;
        justify-content: center;
    }

    .ranking-boxes {
        flex-direction: column;

        height: 100%;
        gap: 5px;
    }

    .rank-box {
        height: auto;

        width: 100%;
        font-size: 1rem;
    }

    #card-stack {
        width: 200px;
        /* 2x mobile rank-box width (100 * 2) */
        height: 120px;
        /* 2x presumed mobile rank-box height (60 * 2) */
        max-height: none;
        aspect-ratio: auto;
    }

    h3 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }


    #raft-status {
        font-size: 1.2rem;
    }

    #raft-context {
        font-size: 0.9rem;
    }

    .raft-emoji {
        font-size: 1.8rem;
    }
}


#game3-intro-overlay,
#game3-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 15, 19, 0.8);
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#game3-intro-overlay.hidden,
#game3-play-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#game3-intro-overlay.visible,
#game3-play-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}


.emoji-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 2rem;
    width: 100%;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.emoji-square {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--secondary-color);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.emoji-square:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
    border-color: var(--accent-color);
}

.emoji-square:active {
    transform: scale(0.95);
}


#game3-container {
    width: 100%;
    height: 100%;
    display: block;
    position: relative;
    overflow: hidden;
}

#game3-status {
    font-size: 2rem;
    color: var(--text-color);
    font-weight: 700;
    position: absolute;
    top: 30px;
    /* Just below timer */
    width: 100%;
    text-align: center;
    z-index: 10;
    pointer-events: none;
}

#emoji-float-container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 1.5rem;
    width: 100%;
    position: absolute;
    top: 30%;
    /* Lowered to 30% as requested (was 20%) */
    left: 0;
    transform: translateY(-50%);
    padding-top: 0;
    z-index: 50;
}

.floating-emoji {
    font-size: 2.7rem;
    cursor: grab;
    user-select: none;
    transition: transform 0.2s;
    animation: float 3s ease-in-out infinite;
}

.floating-emoji:active {
    cursor: grabbing;
}

.floating-emoji.dragging {
    opacity: 0.5;
    transform: scale(1.2);
    z-index: 1000;
    pointer-events: none;
    /* Let clicks pass through to drop targets if needed, mainly for visual feedback */
    position: fixed;
    /* Switch to fixed when dragging logic takes over via JS, or keep simplified */
}

/* Stagger animations */
.floating-emoji:nth-child(1) {
    animation-delay: 0s;
}

.floating-emoji:nth-child(2) {
    animation-delay: 0.2s;
}

.floating-emoji:nth-child(3) {
    animation-delay: 0.4s;
}

.floating-emoji:nth-child(4) {
    animation-delay: 0.6s;
}

.floating-emoji:nth-child(5) {
    animation-delay: 0.8s;
}

@keyframes float {

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

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

#trashcan-area {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    position: absolute;
    bottom: 15%;
    left: 0;
    margin-bottom: 0;
    z-index: 10;
}

#trashcan-target {
    font-size: 4.5rem;
    transition: transform 0.2s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100vw);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.slide-in-right {
    animation: slideInRight 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes winSlideOut {
    0% {
        transform: translate(0, -50%);
        opacity: 1;
    }

    100% {
        transform: translate(-120vw, -50%);
        opacity: 0;
    }
}

.win-slide-out {
    animation: winSlideOut 0.8s ease-in forwards;
}

@keyframes winSlideOutSimple {
    0% {
        transform: translateX(0);
        opacity: 1;
    }

    100% {
        transform: translateX(-120vw);
        opacity: 0;
    }
}

.win-slide-out-simple {
    animation: winSlideOutSimple 0.8s ease-in forwards;
}

/* Remove blur from result overlay to keep text crisp */
#result-overlay {
    backdrop-filter: none;
    z-index: 1000;
}

.burning {
    animation: burn 0.5s forwards;
}




.match-banner {
    width: 100vw;
    background-color: var(--secondary-color);
    color: var(--success-color);
    padding: 1.5rem;
    text-align: center;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-top: 2px solid var(--success-color);
    border-bottom: 2px solid var(--success-color);
    pointer-events: none;
    margin-top: 1rem;
    margin-bottom: 1rem;
    animation: slideInLeft 0.5s ease-out forwards;
}


#why-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 15, 19, 0.9);
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
    z-index: 2000;
}

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

#why-modal.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--secondary-color);
    padding: 2rem;
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    width: 90%;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: slideInUp 0.3s ease-out forwards;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h3 {
    margin-bottom: 1rem;
    color: var(--title-color);
    font-size: 1.5rem;
}

.modal-content ul {
    list-style-type: none;
    padding: 0;
    text-align: left;
}

.modal-content li {
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
    position: relative;
    color: #ccc;
    line-height: 1.4;
}

.modal-content li::before {
    content: "•";
    color: var(--accent-color);
    position: absolute;
    left: 0;
    font-weight: bold;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    color: #666;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--fail-color);
}