:root {
    --t1-color: #426f0f;
    --t2-color: #d4c32b;
    --t3-color: #ad311b;
    --td-color: #f3f4f0;
}

* {
    box-sizing: border-box;
}
  
body {
    margin: 0;
    height: 100dvh;
    display: grid;
    place-items: center;
    background: #f3f4f0;
    color: #1b270d;
    font-family: system-ui, sans-serif;
}
  
h1 {
    font-size: clamp(14px, min(8vw,4dvh), 28px);
}
  
button {
    text-align: center;
    border: 0;
    padding: 12pt 12pt;
    background: #f3f4f0;
    color: #1b270d;
    cursor: pointer;
}

/* Desktop */
main {
    width: 728px;
    /*padding: 3rem 2rem;*/
    text-align: center;
    margin: 0 auto;
}

.adspace {
    width: 728px;
    height: 90px;
    padding: 0 0;
    position: fixed;
    margin: 0 auto;
    border: 2pt solid #1b270d
}

#gamespace {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 6px;
    margin-inline: auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;

    width: min(500px, 50dvh, 100vw);
    aspect-ratio: 1;
}

#wipspace {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 12px auto;
    width: min(500px, 50dvh, 100vw);
    height: min(calc(476px / 5), calc(calc(50dvh - 24px) / 5));
}

#wiptext {
    display: flex;
    align-items: center;
    padding: 0 12px;
    font-size: clamp(14px, min(8vw,4dvh), 28px);
    white-space: nowrap;
    overflow: hidden;
    width: min(399px, calc((50dvh - 24px) * 4 / 5 + 18px), calc((100vw - 24px) * 4 / 5 + 18px));
    height: min(calc(476px / 5), calc(calc(50dvh - 24px) / 5));
    line-height: min(calc(476px / 5), calc(calc(50dvh - 24px) / 5));
    
    opacity: 0;
    transition-property: opacity; 
    transition-delay: 0s;
    transition-duration: 0s;
    color: #71716e;
}

#wiptext.named {
    opacity: 1;
    color: #71716e;
    transition-property: opacity;
    transition-duration: 1.5s;
    transition-delay: 2s;
}

#wiptext.inprog {
    opacity: 1;
    color: black;
    transition-property: opacity;
    transition-delay: 0s;
    transition-duration: 0s;
}

#infobutton {
    display: flex;
    place-items: center;
    width: min(calc(476px / 5), calc(calc(50dvh - 24px) / 5));
    height: min(calc(476px / 5), calc(calc(50dvh - 24px) / 5));
}

#scoredisplay {
    display: flex;
    align-items: center;
    padding: 0 12px;
    width: min(247px, calc(25dvh - 3px), calc(50vw - 3px));
    height: min(calc(476px / 5), calc(calc(50dvh - 24px) / 5));
}

#movesdisplay {
    display: flex;
    align-items: center;
    padding: 0 12px;
    width: min(247px, calc(25dvh - 3px), calc(50vw - 3px));
    height: min(calc(476px / 5), calc(calc(50dvh - 24px) / 5));
}

#scorespace {
    display: flex;
    margin: 12px auto;
    align-items: center;
    flex-direction: row;
    width: min(500px, 50dvh, 100vw);
    gap: 4px;
}

#resultspace {
    position: fixed;
    inset: 0;
    z-index: 1000;
    
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: min(500px, 50dvh, 100vw);
    height: min(calc(500px + (952px / 5)), calc((100dvh - 48px) / 5 + 50dvh));
    background: #f3f4f0;
    margin: auto auto;
}

#infospace {
    position: fixed;
    inset: 0;
    z-index: 1000;

    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: min(500px, 50dvh, 100vw);
    height: min(calc(500px + (952px / 5)), calc((100dvh - 48px) / 5 + 50dvh));
    background: #f3f4f0;
    margin: auto auto;
}

.hidden {
    display: none;
}

.shown {
    display: flex;
}

.tile {
    display: grid;
    place-items: center;

    background: #f3f4f0;
    border: 3px solid #426f0f;
    border-radius: 7px;
    font-size: clamp(14px, min(8vw,4dvh), 28px);
    font-weight: bold;
    user-select: none;
    touch-action: none;
}

/* Mobile and narrow windows */
@media (max-width: 728px) {
    main {
        width: 100%;
        /*padding: 3rem 2rem;*/
        text-align: center;
    }

    .adspace {
        width: 100vw;
        height: 15.625vw;
        padding: 0 0;
        position: fixed;
        margin: 0 auto;
    }
}