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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(45deg, #8e44ad 0%, #3498db 50%, #e74c3c 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    color: white;
    overflow-x: hidden;
    padding: 1rem;
    touch-action: manipulation;
}

.game-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 500px;
    width: 100%;
    text-align: center;
}

.header {
    margin-bottom: 1rem;
}

.title {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.navigation {
    margin-bottom: 1rem;
}

.nav-button {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.game-mode-selector {
    margin-bottom: 1rem;
}

.mode-button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
}

.mode-button.active {
    background-color: #27ae60;
}

.game-content {
    margin-top: 1rem;
}

.game-info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    margin-bottom: 0;
    position: relative;
}

.tile {
    /* Explicitly set width/height as padding trick no longer works */
    width: 100px; /* This will be overridden by JS */
    height: 100px; /* This will be overridden by JS */
    padding-bottom: 0; 
    
    background-color: rgba(255, 255, 255, 0.3);
    background-size: 400% 400%;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    
    position: absolute; /* Allows tiles to be positioned freely */
    
    -webkit-tap-highlight-color: transparent;
    transform: translateZ(0);

    /* The actual slide animation: animate the top and left properties */
    transition: top 0.15s ease-in-out, left 0.15s ease-in-out;
}

.tile span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    -webkit-text-stroke: 2px black;
    text-stroke: 2px black;
}

.tile.empty {
    background-color: transparent;
    cursor: default;
}

.button-container {
    margin-top: 1rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.new-game-button, .share-button {
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    border: none;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
}

.new-game-button {
    background-color: #e74c3c;
}

.share-button {
    background-color: #27ae60;
}

.game-button {
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    border: none;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
    background-color: #f39c12; /* A nice orange color for the pause button */
}

/* Style for the overlay that freezes the board */
.pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    border-radius: 8px; /* Match the board's corner radius */
    z-index: 10;
    color: white;
    font-size: 3rem;
    font-weight: bold;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.7);

    /* Use flex to center the "PAUSED" text */
    display: flex;
    justify-content: center;
    align-items: center;

    /* Hidden by default */
    opacity: 0;
    pointer-events: none; /* Can't be clicked when hidden */
    transition: opacity 0.3s ease-in-out;
}

/* A class to make the overlay visible */
.pause-overlay.active {
    opacity: 1;
    pointer-events: all; /* Clickable when visible */
}

.stats {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    margin-bottom: 0;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 80px;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #ffd700;
}

.stat-label {
    font-size: 0.7rem;
    color: #e0e0e0;
    margin-top: 0.25rem;
}

/* Style for the new Stats button */
#statsButton {
    background-color: #8e44ad;
}

/* Stats Modal Styling (similar to Alpha-Bit) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #2c2c2e;
    color: #fff;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    position: relative;
    text-align: center;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
}

.modal-close-button {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 15px;
    margin: 20px 0;
}