/**
 * Adapted from Scott Alexander Williams (swilliams.io/fun/hex/)
 * Fireworks animation adapted from Haiqing Wang (https://codepen.io/whqet/pen/Auzch)
 */

#game {
    display: flex;
    position: relative;
    text-rendering: optimizeLegibility;
    user-select: none;
}

#canvas {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    visibility: hidden;
}

#left {
    width: calc(70% - 100px);
    text-transform: uppercase;
}

#right {
    margin-right: 20px;
    width: calc(30% - 40px);
}

#bottom {
    display: flex;
    text-rendering: optimizeLegibility;
    user-select: none;
}

#bottom-full {
    width: calc(100% - 80px);
}

#bottom-left {
    width: calc(70% - 100px);
}

#bottom-right {
    margin-right: 20px;
    width: calc(30% - 40px);
}

#left,
#right,
#bottom-full,
#bottom-right,
#bottom-left {
    float: left;
    margin-left: 20px;
    padding: 20px;
    background-color: #242424;
    margin-bottom: 20px;
    height: auto;
}

#left #entry,
#left #messageBox {
    padding: 8px;
    display: block;
    border: none;
    width: 100%;
    height: 40px;
    font-size: 32px;
    text-align: center;
    background: none;
}

#left #entry #entryContent {
    display: inline-block;
    position: relative;
    -webkit-transform: translateY(0%);
    transform: translateY(0%);
}

#left #entry #entryContent.valid {
    color: #e7ad00;
}

#left #entry #entryContent.invalid {
    color: #fffbee;
}

#left #entry #entryContent::after {
    content: "";
    display: block;
    position: absolute;
    right: -4px;
    top: 0;
    width: 2px;
    height: 40px;
    background-color: #e7ad00;
    -webkit-animation: 1000ms blink step-end infinite;
    animation: 1000ms blink step-end infinite;
}

.shake {
    animation: 850ms shake step-end;
}

#gridContainer {
    margin: auto;
    overflow: visible;
    max-width: 550px;
}

#grid {
    position: relative;
    width: 105%;
    margin: 0 auto;
    padding: 0;
    margin-left: -10%;
}

#grid li {
    list-style-type: none;
    position: relative;
    float: left;
    width: 27.85714285714286%;
    padding: 0 0 32.16760145166612% 0;
    -o-transform: rotate(-60deg) skewY(30deg);
    -moz-transform: rotate(-60deg) skewY(30deg);
    -webkit-transform: rotate(-60deg) skewY(30deg);
    -ms-transform: rotate(-60deg) skewY(30deg);
    transform: rotate(-60deg) skewY(30deg);
    overflow: hidden;
}

#grid li .hexagon {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fffbee;
    -o-transform: skewY(-30deg) rotate(60deg);
    -moz-transform: skewY(-30deg) rotate(60deg);
    -webkit-transform: skewY(-30deg) rotate(60deg);
    -ms-transform: skewY(-30deg) rotate(60deg);
    transform: skewY(-30deg) rotate(60deg);
    overflow: hidden;
    font-size: 4vw;
    font-weight: bold;
    -moz-user-select: none;
    -khtml-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
}

#grid li .central-hexagon {
    background: #fdbf00;
}

#grid li .central-hexagon,
#grid li .outer-hexagon {
    color: #000000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#grid li .fake-hexagon {
    display: none;
}

#grid li:nth-child(3n+2) {
    margin: 0 1%;
}

#grid li:nth-child(6n+4),
#grid li:nth-child(6n+5),
#grid li:nth-child(6n+6) {
    margin-top: -6.9285714285%;
    margin-bottom: -6.9285714285%;
    -o-transform: translateX(50%) rotate(-60deg) skewY(30deg);
    -moz-transform: translateX(50%) rotate(-60deg) skewY(30deg);
    -webkit-transform: translateX(50%) rotate(-60deg) skewY(30deg);
    -ms-transform: translateX(50%) rotate(-60deg) skewY(30deg);
    transform: translateX(50%) rotate(-60deg) skewY(30deg);
}

#grid li:nth-child(6n+4) {
    margin-left: 0.5%;
}

.clear:after {
    content: "";
    display: block;
    clear: both;
}

#controls {
    display: flex;
    justify-content: center;
    align-items: center
}

#controls .button {
    padding: 4vw;
}

@-webkit-keyframes blink {
    from,
    to {
        opacity: 1
    }
    50% {
        opacity: 0
    }
}

@keyframes blink {
    from,
    to {
        opacity: 1
    }
    50% {
        opacity: 0
    }
}

@-webkit-keyframes shake {
    10%,
    90% {
        -webkit-transform: translate3d(-1px, 0, 0);
        transform: translate3d(-1px, 0, 0)
    }
    20%,
    80% {
        -webkit-transform: translate3d(2px, 0, 0);
        transform: translate3d(2px, 0, 0)
    }
    30%,
    50%,
    70% {
        -webkit-transform: translate3d(-4px, 0, 0);
        transform: translate3d(-4px, 0, 0)
    }
    40%,
    60% {
        -webkit-transform: translate3d(4px, 0, 0);
        transform: translate3d(4px, 0, 0)
    }
}

@keyframes shake {
    10%,
    90% {
        -webkit-transform: translate3d(-1px, 0, 0);
        transform: translate3d(-1px, 0, 0)
    }
    20%,
    80% {
        -webkit-transform: translate3d(2px, 0, 0);
        transform: translate3d(2px, 0, 0)
    }
    30%,
    50%,
    70% {
        -webkit-transform: translate3d(-4px, 0, 0);
        transform: translate3d(-4px, 0, 0)
    }
    40%,
    60% {
        -webkit-transform: translate3d(4px, 0, 0);
        transform: translate3d(4px, 0, 0)
    }
}


/* Mobile support */

@media (max-width: 450px) {
    #game {
        display: block;
    }
    #left {
        width: calc(100% - 80px);
        margin-bottom: 20px;
    }
    #right {
        width: calc(100% - 80px);
        margin-bottom: 20px;
    }
    #bottom {
        display: block;
    }
    #bottom-full {
        width: calc(100% - 80px);
    }
    #bottom-left {
        width: calc(100% - 80px);
        margin-bottom: 20px;
    }
    #bottom-right {
        width: calc(100% - 80px);
        margin-bottom: 20px;
    }
}