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

body {
    min-height: 100vh;
    margin: 0;
    padding: 0;
    background: url('images/background.jpg') center center fixed;
    background-size: cover;
    overflow: hidden;
    position: relative;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1;
}

.tile-container {
    position: relative;
    z-index: 2;
    display: grid;
    width: 100vw;
    height: 100vh;
    padding: 0;
    /* Responsive grid that adjusts based on screen size */
    grid-template-columns: repeat(auto-fit, minmax(min(120px, 100%), 1fr));
    gap: 0;
}

/* Ensure we maintain roughly 40 tiles across different screen sizes */
@media (min-width: 1200px) {
    .tile-container {
        grid-template-columns: repeat(10, 1fr); /* 10x4 grid for large screens */
    }
}

@media (max-width: 1199px) and (min-width: 768px) {
    .tile-container {
        grid-template-columns: repeat(8, 1fr); /* 8x5 grid for medium screens */
    }
}

@media (max-width: 767px) {
    .tile-container {
        grid-template-columns: repeat(5, 1fr); /* 5x8 grid for small screens */
    }
}

.tile {
    position: relative;
    aspect-ratio: 1;
    perspective: 1000px;
    cursor: pointer;
}

.tile-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.4s ease-in-out;
}

.tile.flipped .tile-inner {
    transform: rotateY(180deg);
}

.tile.ripple-flip .tile-inner {
    animation: rippleFlip 0.8s ease-in-out forwards;
}

@keyframes rippleFlip {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(180deg); }
}

.tile-front, .tile-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 0;
    box-shadow: none;
}

.tile-front {
    background-color: rgba(0, 71, 171, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(3px);
}

.tile-back {
    background-color: rgba(44, 44, 44, 0.9);
    transform: rotateY(180deg);
    border: 1px solid rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(3px);
}

.tile-back a {
    text-decoration: none;
    color: #66B2FF;
    font-size: clamp(0.7em, 1.8vw, 1em);
    font-family: Arial, sans-serif;
    padding: 8px;
    text-align: center;
    word-break: break-word;
}

.tile-back a:hover {
    color: #99CCFF;
}
