.tile {
    --tile-font: 'Courier New', monospace;
    --tile-font-weight: 700;
    --tile-border-radius: 4px;

    position: relative;
    width: 100%;
    aspect-ratio: 0.7;
    perspective: 300px;
    cursor: default;
    user-select: none;
}

.tile-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: none;
}

.tile-face {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a2e;
    color: #f1f5f9;
    font-family: var(--tile-font);
    font-weight: var(--tile-font-weight);
    font-size: clamp(18px, 3.5vw, 52px);
    line-height: 1;
    border-radius: var(--tile-border-radius);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.tile-front {
    z-index: 2;
}

.tile-back {
    transform: rotateX(180deg);
}

.tile-face::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.tile-face::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.03) 45%,
        rgba(255, 255, 255, 0) 50%,
        rgba(0, 0, 0, 0.05) 55%,
        rgba(0, 0, 0, 0) 100%
    );
    border-radius: var(--tile-border-radius);
    pointer-events: none;
}

@keyframes flipTop {
    0% { transform: rotateX(0deg); }
    100% { transform: rotateX(-180deg); }
}

.tile.flipping .tile-inner {
    animation: flipTop var(--flip-duration, 300ms) ease-in-out forwards;
    will-change: transform;
}

.tile.scrambling .tile-front {
    transition: color 60ms ease;
}
