/* Base styles */
table {
    border-collapse: collapse;
    margin: 0.5rem auto;
    text-align: center;
    width: 90%;
    max-width: 500px;
    table-layout: auto;
}

td {
    border: solid #FFFFFF;
    width: auto;
    min-width: 70px;
    max-width: none;
    height: 80px;
    position: relative;
    user-select: none;
    cursor: pointer;
    background-color: #15151E;
    padding: 0;
}

td > div {
    position: absolute;
    top: 4px;
    right: 4px;
    bottom: 4px;
    left: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    word-wrap: break-word;
    word-break: normal;
    overflow-wrap: break-word;
    overflow: hidden;
    line-height: 1.2;
    white-space: normal;
    text-align: center;
}

@media screen and (min-width: 768px) {
    td > div {
        font-size: 13px;
    }

    button {
        width: 80%;
        max-width: 300px;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        -webkit-tap-highlight-color: transparent;
    }

    button:active {
        transform: translateX(-50%) scale(0.95);
        background-color: #FF1E00 !important;  /* Force override */
    }

    button:not(:active) {
        transform: translateX(-50%);
        background-color: #15151E;
    }
}

@media screen and (max-width: 480px) {
    td {
        min-width: 18%;
        max-width: 22%;
        height: 0;
        padding-bottom: 20%;
    }
    
    td > div {
        font-size: min(2.5vw, 2.5vh);
    }

    table {
        margin: 0.5rem auto;
    }

    button {
        width: 80%;
        max-width: 300px;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        -webkit-tap-highlight-color: transparent;
    }

    button:active {
        transform: translateX(-50%) scale(0.95);
        background-color: #FF1E00 !important;  /* Force override */
    }

    button:not(:active) {
        transform: translateX(-50%);
        background-color: #15151E;
    }
}

body {
    background-color: #15151E;
    color: #FFFFFF;
    font-family: 'bahnschrift', 'Trebuchet MS', 'Helvetica', sans-serif;
}

.center {
    text-align: center;
}

/* Base button styles */
button {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;  /* Default narrow width for desktop */
    background-color: #15151E;
    border-radius: 8px;
    border-color: #FFFFFF;
    border: 2px solid;
    color: #FFFFFF;
    padding: 5px;
    font-family: 'bahnschrift', 'Trebuchet MS', 'Helvetica', sans-serif;
    font-size: medium;
    -webkit-tap-highlight-color: transparent;
}

button:hover {
    background-color: #FF1E00;
}

button:active {
    transform: translateX(-50%) scale(0.95);
    background-color: #FF1E00;
}

button:not(:active) {
    transform: translateX(-50%);
    background-color: #15151E;
}

#rules-title {
    font-weight: bold;
}

/* Mobile styles */
@media screen and (max-width: 600px) {
    table {
        width: 300px;
        height: 300px;
    }

    td {
        width: 60px;
        height: 60px;
        padding: 2px;
        font-size: 11px;
    }

    p {
        font-size: 14px;
        padding: 0 10px;
    }

    button {
        width: 80%;
        max-width: 300px;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        -webkit-tap-highlight-color: transparent;
    }

    button:active {
        transform: translateX(-50%) scale(0.95);
        background-color: #FF1E00 !important;  /* Force override */
    }

    button:not(:active) {
        transform: translateX(-50%);
        background-color: #15151E;
    }
}

@media screen and (max-width: 360px) {
    table {
        width: 250px;
        height: 250px;
    }

    td {
        width: 50px;
        height: 50px;
        padding: 1px;
        font-size: 10px;
    }

    button {
        width: 80%;
        max-width: 300px;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        -webkit-tap-highlight-color: transparent;
    }

    button:active {
        transform: translateX(-50%) scale(0.95);
        background-color: #FF1E00 !important;  /* Force override */
    }

    button:not(:active) {
        transform: translateX(-50%);
        background-color: #15151E;
    }
}

.popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    height: auto;
    background-color: #15151E;
    padding: 15px;
    border-radius: 15px;
    text-align: center;
    border: 2px solid #FFFFFF;
    z-index: 1000;
    max-width: 300px;
}

.popup-content {
    background-color: #15151E;
    padding: 15px;
    border-radius: 5px;
    text-align: center;
    border: none;
    min-width: 200px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
    max-width: 280px;
}

.popup-content h2 {
    color: #FFFFFF;
    margin: 0;
    font-size: 1.8em;
}

.popup-content button {
    position: relative;
    left: 0;
    transform: none !important;  /* Force no transform */
    width: auto;
    margin: 0;
    background-color: #15151E !important;  /* Force constant background color */
}

/* Override any active/hover states for popup buttons */
.popup-content button:active,
.popup-content button:hover,
.popup-content button:not(:active) {
    transform: none !important;
    background-color: #15151E !important;
}

/* Very small screens */
@media screen and (max-width: 360px) {
    td > div {
        font-size: min(2.2vw, 2.2vh);
    }
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* Dim effect */
    z-index: 1000; /* Ensure it is above other content */
    display: none; /* Initially hidden */
}
