@import url("https://fonts.googleapis.com/css2?family=Luckiest+Guy&family=Nunito:wght@400;700;900&display=swap");

:root {
    --color-bg: #ea580c;
    --color-tile: #ffffff;
    --color-border: #18181b;
    --shadow-depth: 6px;
    --tile-size-desktop: 120px;
    --tile-size-mobile: 90px;
}

body {
    font-family: "Nunito", sans-serif;
    background-color: var(--color-bg);
    overflow-x: hidden;
}

h1,
h2,
h3,
.font-display {
    font-family: "Luckiest Guy", cursive;
}

button:enabled{
    cursor: pointer;
}

button:disabled{
    cursor: not-allowed;
}

/* --- 3D FLIP CARD MECHANICS (Index & Room) --- */
.flip-container {
    perspective: 1000px;
    width: var(--tile-size-desktop);
    height: var(--tile-size-desktop);
    position: absolute;
}

.flipper {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
    transform-style: preserve-3d;
}

.flip-container.flipped .flipper {
    transform: rotateY(180deg);
}

.flip-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background-color: white;
    border: 3px solid var(--color-border);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 4px 4px 0px 0px var(--color-border);
}

.flip-face.front {
    z-index: 2;
    font-size: 3rem;
    color: var(--color-border);
    transform: rotateY(0deg);
}

.flip-face.back {
    transform: rotateY(180deg);
}

/* Match Badge Animation (Index) */
.match-badge-container {
    opacity: 0;
    transform: scale(0.5) rotate(-10deg);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 30;
}
.match-badge-container.show-match {
    opacity: 1;
    transform: scale(1) rotate(12deg);
}

/* --- Premium Hard Shadow Utilities --- */
.hard-shadow {
    box-shadow: 4px 4px 0px 0px var(--color-border);
    border: 2px solid var(--color-border);
}

.hard-shadow-solid {
    box-shadow: 4px 4px 0px 0px var(--color-border);
}

.hard-shadow-hover:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px 0px #18181b;
}

.hard-shadow-active:active {
    transform: translate(2px, 2px);
    box-shadow: 0px 0px 0px 0px #18181b;
}

.hard-shadow-sm {
    box-shadow: 2px 2px 0px 0px var(--color-border);
    border: 2px solid var(--color-border);
}

.text-stroke {
    -webkit-text-stroke: 2px var(--color-border);
    text-shadow: 4px 4px 0px rgba(0, 0, 0, 0.2);
}

.card-back {
    border-width: 3px !important;
    /* border-radius: 4px; */
}

/* --- Background Pattern --- */
.bg-grid-pattern {
    background-image: linear-gradient(
            to right,
            rgba(255, 255, 255, 0.1) 1px,
            transparent 1px
        ),
        linear-gradient(
            to bottom,
            rgba(255, 255, 255, 0.1) 1px,
            transparent 1px
        );
    background-size: 40px 40px;
}

/* --- Scrollbar styling --- */
.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: #e5e7eb;
    border-radius: 20px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: #d1d5db;
}

/* --- FIXED 3D CARD FLIP MECHANICS --- */
/* This is the container that holds the card */
.card-container {
    perspective: 1000px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* The inner wrapper that actually rotates */
.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    transform-origin: center center;
}

/* When flipped, rotate the inner wrapper */
.card-inner.card-flipped {
    transform: rotateY(180deg);
}

/* Both faces of the card */
.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    box-sizing: border-box;
}

/* Front face (question mark) */
.card-front {
    background-color: white;
    transform: rotateY(0deg);
    z-index: 2;
}

/* Back face (emoji) - starts rotated 180deg */
.card-back {
    transform: rotateY(180deg);
    z-index: 1;
}

/* --- Room Specific Styles --- */
.game-board-container {
    background-color: #fff7ed;
    border: 3px solid var(--color-border);
    box-shadow: 8px 8px 0px 0px rgba(0, 0, 0, 0.2);
    position: relative;
}

/* Decorative corner screws for the board */
.board-screw {
    width: 12px;
    height: 12px;
    background-color: #d1d5db;
    border: 2px solid #9ca3af;
    border-radius: 50%;
    position: absolute;
    box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.2);
}

/* --- Animations --- */
@keyframes float-p1 {
    0%,
    100% {
        transform: translateY(0) rotate(-3deg);
    }
    50% {
        transform: translateY(-12px) rotate(2deg);
    }
}

@keyframes float-p2 {
    0%,
    100% {
        transform: translateY(0) rotate(3deg);
    }
    50% {
        transform: translateY(-15px) rotate(-2deg);
    }
}

@keyframes float-bg {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

@keyframes float-slow {
    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-12px) rotate(3deg);
    }
}

.animate-float-1 {
    animation: float-p1 4s ease-in-out infinite;
}

.animate-float-2 {
    animation: float-p2 5s ease-in-out infinite;
}

.animate-float-bg {
    animation: float-bg 4s ease-in-out infinite;
}

.animate-float {
    animation: float-slow 5s ease-in-out infinite;
}

.delay-1000 {
    animation-delay: 1.5s;
}

.btn-action {
    transition: all 0.1s;
}

.btn-action:active {
    transform: translate(3px, 3px);
    box-shadow: 0px 0px 0px 0px !important;
}

/* Active Player Pulse */
.player-active-indicator {
    box-shadow: 0 0 0 3px #facc15, 4px 4px 0px 0px var(--color-border);
    border: 2px solid var(--color-border);
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% {
        box-shadow: 0 0 0 0px rgba(250, 204, 21, 0.7),
            4px 4px 0px 0px var(--color-border);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(250, 204, 21, 0),
            4px 4px 0px 0px var(--color-border);
    }
    100% {
        box-shadow: 0 0 0 0px rgba(250, 204, 21, 0),
            4px 4px 0px 0px var(--color-border);
    }
}

/* Match Badge Animation */
.match-badge-container {
    opacity: 0;
    transform: scale(0.5) rotate(-10deg);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 30;
}

.match-badge-container.show-match {
    opacity: 1;
    transform: scale(1) rotate(12deg);
}

/* Mobile Responsive */
@media (max-width: 640px) {
    .flip-container {
        width: var(--tile-size-mobile);
        height: var(--tile-size-mobile);
    }
    .flip-face {
        border-width: 2px;
        border-radius: 0.75rem;
    }
    .flip-face.front {
        font-size: 2.5rem;
    }

    .card-face {
        border-radius: 8px;
    }

    .card-back {
        border-width: 2px !important;
    }

    .game-board-container {
        border: 1.5px solid var(--color-border);
        box-shadow: 2px 2px 0px 0px rgba(0, 0, 0, 0.2);
    }

    .hard-shadow {
        box-shadow: 1.5px 1.5px 0px 0px var(--color-border);
        border: 1.5px solid var(--color-border);
    }

    /* Decorative corner screws for the board */
    .board-screw {
        width: 8px;
        height: 8px;
        background-color: #d1d5db;
        border: 2px solid #9ca3af;
        border-radius: 50%;
        position: absolute;
        box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.2);
    }

    .card-face {
        border-radius: 10px;
    }
}
