html {
    height: 100vh;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

body {
    min-width: 100vw;
    margin: 0;
    position:fixed;
    overflow:hidden;
    font-family: Arial, sans-serif;
    font-size: large;
}

/* fix safari.ios bugs */
@supports (-webkit-touch-callout: none) {
    html {
        height: -webkit-fill-available;
    }
    body {
        height: -webkit-fill-available;
    }
    header .title1 {
        height: 18vw;
    }
    header .title2 {
        height: 19vw;
    }
    .popup-head .title1 {
        height: 75px;
    }
    .popup-head .title2 {
        height: 75px;
    }
}

header {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.page {
    width: 100vw;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

fieldset {
    padding: 0;
    margin: 0;
    border: none;
}

.content {
    margin: 5px;
}
#iTitle .content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    height: calc(100% - 10px);
}

.title1 {
    width: 35%;
    stroke: none;
    fill: white;
    max-height: calc(100vh - 280px);
    min-height: 55px;
    max-width: calc((100vh - 280px) / 9 * 17);
    min-width: calc(55px / 9 * 17);
}

.title2 {
    width:65%;
    display: flex;
    flex-direction: row;
    stroke: white;
    stroke-width: 5px;
    font-family: Arial, sans-serif;
    font-size:70px;
    fill: white;
    stroke-linejoin: round;
    stroke-linecap: round;
    text-shadow: none;
    max-height: calc(100vh - 280px);
    min-height: 55px;
    max-width: calc((100vh - 280px) / 9 * 32);
    min-width: calc(55px / 9 * 32);
}
.popup-head .title1 {
    min-width: initial;
}
.popup-head .title2 {
    min-width: initial;
}
.title2card {
    flex: 1;
}

#iGame {
    transform: translateX(100vw);
    opacity: 0;
    visibility: hidden;
}

.swipe-in {
    animation-name: swipe-in;
    animation-fill-mode: forwards;
    animation-duration: 0.7s;
}

@keyframes swipe-in {
    0% {
        transform: translateX(100vw);
        opacity: 0;
        visibility: hidden;
    }
    1% {
        transform: translateX(100vw);
        opacity: 1;
        visibility: visible;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
        visibility: visible;
    }
}

.swipe-out {
    animation-name: swipe-out;
    animation-fill-mode: forwards;
    animation-duration: 0.7s;
}

@keyframes swipe-out {
    0% {
        transform: translateX(0);
        opacity: 1;
        visibility: visible;
    }
    99% {
        transform: translateX(-100vw);
        opacity: 1;
        visibility: visible;
    }
    100% {
        transform: translateX(-100vw);
        opacity: 0;
        visibility: hidden;
    }
}
.swipe-in-left {
    animation-name: swipe-in-left;
    animation-fill-mode: forwards;
    animation-duration: 0.7s;
}

@keyframes swipe-in-left {
    0% {
        transform: translateX(0);
        opacity: 1;
        visibility: visible;
    }
    99% {
        transform: translateX(100vw);
        opacity: 1;
        visibility: visible;
    }
    100% {
        transform: translateX(100vw);
        opacity: 0;
        visibility: hidden;
    }
}

.swipe-out-right {
    animation-name: swipe-out-right;
    animation-fill-mode: forwards;
    animation-duration: 0.7s;
}

@keyframes swipe-out-right {
    0% {
        transform: translateX(-100vw);
        opacity: 0;
        visibility: hidden;
    }
    1% {
        transform: translateX(-100vw);
        opacity: 1;
        visibility: visible;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
        visibility: visible;
    }
}

.mini-button, .close-button {
    border:  1px transparent;
    background-origin: border-box;
    background-clip: content-box, border-box;
    cursor: pointer;
    padding: 1px;
}
.mini-buttonlist > .mini-button:first-child {
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
    padding: 1px 0 1px 1px;
    margin-left: 0;
}
.mini-buttonlist > .mini-button:last-child {
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
    padding: 1px 1px 1px 0;
}
.mini-buttonlist {
    height: 42px;
    margin: 5px 5px 10px 5px;
    display: flex;
}
.mini-buttonlist, .close-button {
    border-radius: 10px;
}
.mini-button:active > img {
    margin-top: 7px;
    margin-bottom: 3px;
}
.mini-button:active > .bttxt {
    margin-top: 12px;
    margin-bottom: 8px;
}
.mini-button {
    width: 60px;
    height: 42px;
    padding: 1px 0 1px 0;
    display: inline-block;
    margin-left: 1px;
}
.mini-img {
    margin: 5px 15px 5px 15px;
    height: 30px;
    width: 30px;
    max-height: calc(100% - 10px);
    pointer-events: none;
}
.close-button {
    border-radius: 20px;
    width: 22px;
    height: 22px;
    position: absolute;
    top: 10px;
    right: 10px;
}
.close-button img {
    width: 20px;
}
#iMessage {
    padding: 5px;
}
.controlgroup {
    flex-grow: 1;
    display: flex;
}
.control {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
}
.control-icon {
    pointer-events: none;
    position: relative;
}
.control-icon > img {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.6s linear;
    opacity: 0;
}
.control-icon > img.active {
    opacity: 1;
}

.footer, .popup-footer {
    display: flex; flex-direction: row-reverse; justify-content: space-between;
}
.flex-right {
    align-self: flex-start;
    margin-left: auto;
}
@media screen and (orientation: landscape) {
    .controlgroup {
        flex-direction: row;
    }
    .control {
        flex-direction: column;
        align-items: center;
        justify-content: space-around;
    }
    .control-icon {
        flex-grow: 4;
        width: 100%;
    }
    .control-icon > img {
        object-fit: contain;
        width: 100%;
        height: 100%;
    }
    .grow1 {
        display: flex;
        flex-grow: 1;
        align-items: center
    }
}
@media screen and (orientation: portrait) {
    .controlgroup {
        flex-direction: column;
    }
    .control {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    .control-icon {
        height: calc(30vw / 1.5);
        width: 30vw;
        max-height: calc(100vh - 260px);
        max-width: calc((100vh - 260px) * 1.5);
    }
}

.settings-control {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}
.settings-icon {
    height: 42px;
}
.settings-label {
    flex-grow: 1;
    margin-left: 30px;
}
.settings-control .mini-buttonlist {
    margin-left: auto;
}

.w25 {
    width: 30px;
}
.w60 {
    width: 60px;
}
.w100 {
    width: 100%;
}
a:link {
    color: #40C4FF;
}
a:visited {
    color: #00B0FF;
}
a:hover, a:focus {
    color: #80D8FF;
}
a:active {
    color: #80D8FF;
}

#thRank, #thPairs, #thTries {
    text-transform:capitalize;
}
#tScore td:nth-child(3), #tScore td:nth-child(4), #tScore th:nth-child(3), #tScore th:nth-child(4) {
    text-align: right;
}
#tScore th:nth-child(1), #tScore th:nth-child(2) {
    text-align: left;
}


.popup {
    display: block;
    left: 0;
    right: 0;
    margin: auto;
    border: 1px transparent;
    border-radius: 15px;
    background-origin: border-box;
    background-clip: content-box, border-box;
    padding: 2px;
    width: 400px;
    max-width: calc(100vw - 40px);
}
.popup-init {
    visibility: hidden;
    opacity: 0;
}
.popup-show {
    animation: 1s fadeIn;
    animation-fill-mode: forwards;
}
.popup-show > div:first-child {
    animation: 1s zoomIn;
    animation-fill-mode: forwards;
}
.popup-hide {
    animation: 1s fadeOut;
    animation-fill-mode: forwards;
}
.popup-hide > div:first-child {
    animation: 1s zoomOut;
    animation-fill-mode: forwards;
}

@keyframes fadeIn {
    0% {
        opacity: 0;
    }
    100% {
        visibility: visible;
        opacity: 1;
    }
}
@keyframes zoomIn {
    0% {
        transform: scale(0.75);
    }
    100% {
        transform: scale(1);
    }
}
@keyframes fadeOut {
    0% {
        opacity: 1;
    }
    100% {
        visibility: hidden;
        opacity: 0;
    }
}
@keyframes zoomOut {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(0.75);
    }
}
.popup-head {
    margin: 10px;
    display: flex;
    max-height: 80px;
}
.popup-body {
    margin: 15px;
}
.popup-content {
    margin-bottom: 20px;
}
.popup-footer {
    height: 50px;
    margin: 15px;
}
#iPopupScore > div:first-child {
    position:absolute;
    top: 123px;
}
.overflow {
    display: block;
    position:absolute;
    top: 0;
    left: 0;
    right: 0;
    margin: 0 auto 0 auto;
    padding-top: 20px;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
}
@supports (-webkit-overflow-scrolling: touch) {
    .overflow {
        overflow-y: scroll;
        -webkit-overflow-scrolling: touch;
    }
}
@supports not (-webkit-overflow-scrolling: touch) {
    .overflow {
        overflow-y: auto;
    }
}
.buffer {
    height: 40px;
}
button:focus, .flip-container:focus {
    outline: none;
}
.button {
    border: 1px transparent;
    border-radius: 10px;
    background-image: linear-gradient(#26C6DA, #006064), linear-gradient(#80DEEA, #00ACC1 12px, #00838F 100%);
    background-origin: border-box;
    background-clip: content-box, border-box;
    padding: 1px;
    height: 42px;
    width: 121px;
    margin: 5px;
    cursor: pointer;
    text-align: center;
    font-weight: bold;
}
.button:hover, .button:focus {
    background-image: linear-gradient(#51d1e1, #009499), linear-gradient(#a7e8f1, #00cbe6 12px, #00a4b3 100%);
}
.button:active {
    background-image: linear-gradient(#1e9eae, #004a4d), linear-gradient(#65d7e6, #008799 calc(100% - 12px), #005e66 100%);;
}
.button:disabled {
    background-image: linear-gradient(#d4d4d4, #535454),
    linear-gradient(#e6e6e6, #ababab 12px, #7d7d7d 100%);
    pointer-events: none;
}
.button-span {
    display: block;
    margin-top: -3px;
    color: white;
    font-size: large;
}
.button:active > .button-span {
    margin-top: 0;
}
.button-span > img {
    margin-bottom: -8px;
}

#settingsgrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    grid-gap: 0.5rem;
}
#settingsgrid img {
    border-radius: 10%;
}
.ownimg {
    border: none;
    padding: 0;
    background-color: transparent;
    cursor: pointer;
    margin-bottom: -3px;
    transition: all .2s ease-in-out;
}
.ownimg:hover, .ownimg:focus, .flip-container[tabindex]:hover, .flip-container:focus {
    filter: brightness(110%);
    transform: scale(1.05);
    z-index: 999;
}
.playownimg {
    display: none;
}
.play .playownimg {
    display: flex;
}
.settings {
    display: flex;
}
.play .settings {
    display: none;
}
#iDown {
    transition: transform 0.25s ease;
}
#iOwnImg2 {
    margin-right: -20px;
}
#lOwnImg {
    margin-top: 5px;
}
.rotate {
    transform: rotate(180deg);
    transition: transform 0.25s ease;
}
#iCollapsable {
    max-height: 0;
    transition: max-height 0.5s ease-out, opacity 0s 0.5s, visibility 0s 0.5s;
    overflow: hidden;
    padding: 0 5px 5px 5px;
}
#iCollapsable.show {
    max-height: 900px;
    transition: max-height 0.75s ease-in;
}


#grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    grid-gap: 0.5rem;
}
#grid > div {
    position: relative;
}

#grid > div img {
    position: absolute;
    width: 100%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 10%;
    pointer-events: none;
}

.hidden {
    display: none;
}

/* entire container, keeps perspective */
.flip-container {
    perspective: 1000px;
    cursor: pointer;
    transition: all .2s ease-in-out;
}

.flip-container.turned .flipper {
    transform: rotateY(180deg);
}

#grid>.flip-container, #grid .front, #grid .back {
    width: 100%;
    padding-bottom: 100%;
}

/* flip speed goes here */
.flipper {
    transition: 0.6s;
    transform-style: preserve-3d;
    position: relative;
}

/* hide back of pane during swap */
.front, .back {
    position: absolute;
    backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* front pane, placed above back */
.front {
    z-index: 2;
    /* for firefox 31 */
    transform: rotateY(0deg);
}

/* back, initially hidden pane */
.back {
    transform: rotateY(180deg);
}

/* dark style */
body {
    background: linear-gradient(#444, #222);
    color: white;
    text-shadow: 1px 1px 2px #000;
    transition: background 0.6s linear, color 0.6s linear, text-shadow 0.6s linear;
}
.page {
    background: linear-gradient(#444, #222);
    transition: background 0.6s linear;
}
.popup {
    box-shadow: 3px 3px 3vmin 3px #000;
    background-image: linear-gradient(#333, #444 35%, #222 100%),
    linear-gradient(#bbb, #444 10%, #111 100%);
    transition: background-image 0.6s linear, box-shadow 0.6s linear;
}
.button {
    box-shadow: 0 0 0.5vmin 2px #000;
    text-shadow: 1px 1px 2px #000;
}
.mini-button, .close-button {
    background-image: linear-gradient(#444, #2d2d2d), linear-gradient(#999, #444 10px, #111 100%);
    transition: background-image 0.6s linear;
}
.mini-buttonlist {
    background-color: #111;
}
.mini-buttonlist, .close-button {
    box-shadow: 0 0 0.5vmin 2px #111;
}
.mini-button:hover, .mini-button:focus, .close-button:hover, .close-button:focus {
    background-image: linear-gradient(#555555, #383838), linear-gradient(#ccc, #555 10px, #222 100%);
}
.mini-button:active, .close-button:active {
    background-image: linear-gradient(#202020, #2c2c2c), linear-gradient(#222, #111 calc(100% - 10px), #aaa 100%);
}
.shadow {
    filter: drop-shadow( 2px 2px 2px #111);
}
.title2 {
    filter: drop-shadow( 5px 5px 2px #111);
}

/* light style */
body.light {
    background: linear-gradient(#ddd, #bbb);
    color: #555;
    text-shadow: 1px 1px 2px #aaa;
}
.light .page {
    background: linear-gradient(#eee, #ddd);
}
.light .popup {
    box-shadow: 3px 3px 3vmin 3px #444;
    background-image: linear-gradient(#eee, #fff 35%, #ddd 100%),
    linear-gradient(#fff, #ccc 10%, #555 100%);
}
.light .button {
    box-shadow: 0 0 0.5vmin 2px #aaa;
    text-shadow: 1px 1px 2px #000;
    color: white;
}
.light .mini-button, .light .close-button {
    background-image: linear-gradient(#eee, #ccc),
    linear-gradient(#eee, #bbb 10px, #777 100%);
}
.light .mini-buttonlist {
    background-color: #aaa;
}
.light .mini-buttonlist, .light .close-button {
    box-shadow: 0 0 0.5vmin 2px #aaa;
}
.light .mini-button:hover, .light .mini-button:focus, .light .close-button:hover, .light .close-button:focus {
    background-image: linear-gradient(#fff, #ddd),
    linear-gradient(#fff, #ccc 10px, #888 100%);
}
.light .mini-button:active, .light .close-button:active {
    background-image: linear-gradient(#bbb, #ddd),
    linear-gradient(#ddd, #eee calc(100% - 10px), #555 100%);
}
.light .w25.shadow {
    filter: drop-shadow( 2px 2px 2px #111);
}
.light .title2 {
    filter: drop-shadow( 5px 5px 2px #aaa);
}
.light .control-icon, .light .settings-icon, .light .mini-img, .light .w60, .light .title1, .light .close-button > img {
    filter: invert(60%) drop-shadow( 2px 2px 2px #aaa);
}
