:root {
    --closed-color: grey;
    --open-color: lightgray;
    --header-height: 50px;          /* should be immediately overwritten by js */
    --cell-width: 24px;             /* should be immediately overwritten by js */
    --grid-width: 400px;            /* should be immediately overwritten by js */
    --grid-height: 300px;           /* should be immediately overwritten by js */
    --game-border-thickness: 10px;  /* should be immediately overwritten by js */
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

.centered {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    text-align: center;
}
.underline {
    text-decoration: underline;
}
.bold {
    font-weight: bold;
}

@font-face {
    font-family: 'Retro Gaming';
    src: url('/assets/fonts/retro_gaming-webfont.woff2');
    src: url('/assets/fonts/retro_gaming-webfont.woff2') format('woff2'),
         url('/assets/fonts/retro_gaming-webfont.woff') format('woff'),
         url('/assets/fonts/retro_gaming.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

div.game-container {
    position: relative;
}

div.game-container > div {
    margin: auto;
    text-align: center;
}
div.game-container > button {
    margin: auto;
    display: block;
}
/* 
#highscores {
    margin: auto;
}
 */
h1,
h4,
#help-me-find-my-twine {
    text-align: center;
    margin: 0;
    display: block;
}
/* 
#highscores-heading {
    display: block;
    font-weight: 700;
    margin: auto;
    text-align: center;
}
 */
#game {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
}

.board-container {
    position: relative;
}
.board-container.settings-open > div.game-header,
.board-container.settings-open > div.grid-container {
    pointer-events: none;
}

#title {
    background-color: lightgray;
    border-bottom: 2px solid gray;
    font-family: 'Retro Gaming', serif;
}

.game-grid {
    display: grid;
}

.game-header {
    display: flex;
    background-color: lightgray;
    width: calc(var(--grid-width) + var(--game-border-thickness) * 2);
    justify-content: space-between;
    align-items: center;
    font-size: calc(0.75 * var(--header-height));
}

div.game-cell {
    background-color: var(--closed-color);
    border-right: 2px solid darkgray;
    border-bottom: 2px solid darkgray;
    border-left: 2px solid lightgray;
    border-top: 2px solid lightgray;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    line-height: calc(var(--cell-width) - 6px);
    height: var(--cell-width);
    width: var(--cell-width);
    z-index: 10;
    position: relative;
}

div.hex-grid > div > div.game-cell {
    clip-path: polygon(
        0% 50%, 25% 100%, 75% 100%, 
        100% 50%, 75% 0%, 25% 0%
    );
}

div.hex-grid > .even-col {
    margin-top: calc(var(--cell-width) * 0.5);
}


div.game-cell.revealed {
    background-color: var(--open-color);
    border-left: 2px solid darkgray;
    border-top: 2px solid darkgray;
    border-right: 2px solid lightgray;
    border-bottom: 2px solid lightgray;
}

div.game-cell.null-cell {
    background-color: hsl(0, 0%, 33%);
    border-left: 2px solid hsl(0, 0%, 55%);
    border-top: 2px solid hsl(0, 0%, 55%);
    border-right: 2px solid hsl(0, 0%, 26%);
    border-bottom: 2px solid hsl(0, 0%, 26%);
    cursor: default;
}

div.game-ended > div > div > div.game-grid {
    background-color: black;
}

div.analysis-message {
    display: inline-block;
}
div.analysis-message.analyzing {
    color:darkgoldenrod;
}
div.analysis-message.errored {
    color:red;
}
div.analysis-message.incomplete {
    color:sienna;
}
/*
div.analysis-message.confused {
    color:sienna;
}
div.analysis-message.complete {
    color:green;
}
*/

div.gameOverText {
    --font-size: min(calc(var(--grid-height) * 0.175), calc(var(--grid-width) * 0.2));
    color:red;
    position: absolute;
    top: calc(var(--header-height) + 2 * var(--game-border-thickness) + var(--grid-height) * 0.3 - var(--font-size));
    font-family: 'Retro Gaming', serif;
    text-align: center;
    font-size: var(--font-size);
    z-index: 2;
    user-select: none;
}

div.game-cell.gameOver {
    cursor: default;
    pointer-events: none;
}

div.game-cell.fallAway {
    animation: 1s ease-out 0s 1 fallOutBottom forwards;
}

@keyframes fallOutBottom {
    0% {
        transform: translate(0, 0);
        opacity: 1;
    }
    100% {
        transform: translate(0, 30vh);
        opacity: 0;
    }
}

div.game-cell.flagged {
    background-image: url("/assets/flag.svg");
    background-repeat: no-repeat;
    background-size: var(--cell-width);
}
div.game-cell.flagged-wrong {
    background-image: url("/assets/flag-wrong.svg");
    background-repeat: no-repeat;
    background-size: var(--cell-width);
}
div.game-cell.question-marked {
    background-color: #CCCCCC;
    border-top: calc(var(--cell-width) / 7) solid white;
    border-left: calc(var(--cell-width) / 7) solid white;
}
div.game-cell.question-marked::before {
    content: "?";
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}

div.game-cell[data-mines="1"].revealed::before {
    content: "1";
    color: blue;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="2"].revealed::before {
    content: "2";
    color: green;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="3"].revealed::before {
    content: "3";
    color: red;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="4"].revealed::before {
    content: "4";
    color: #000080;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="5"].revealed::before {
    content: "5";
    color: #800000;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="6"].revealed::before {
    content: "6";
    color: #008080;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="7"].revealed::before {
    content: "7";
    color: black;
    font-weight: bold;
    font-size: calc(var(--cell-width) - 6px);
}
div.game-cell[data-mines="8"].revealed::before {
    content: "8";
    color: gray;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="9"].revealed::before {
    content: "9";
    color: gray;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="10"].revealed::before {
    content: "10";
    color: gray;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="11"].revealed::before {
    content: "11";
    color: gray;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="12"].revealed::before {
    content: "12";
    color: gray;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="13"].revealed::before {
    content: "13";
    color: gray;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="14"].revealed::before {
    content: "14";
    color: gray;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="15"].revealed::before {
    content: "15";
    color: gray;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="16"].revealed::before {
    content: "16";
    color: gray;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="17"].revealed::before {
    content: "17";
    color: gray;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="18"].revealed::before {
    content: "18";
    color: gray;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="19"].revealed::before {
    content: "19";
    color: gray;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="20"].revealed::before {
    content: "20";
    color: gray;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="21"].revealed::before {
    content: "21";
    color: gray;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="22"].revealed::before {
    content: "22";
    color: gray;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="23"].revealed::before {
    content: "23";
    color: gray;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="24"].revealed::before {
    content: "24";
    color: gray;
    font-weight: bold;
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}
div.game-cell[data-mines="-1"].revealed::before {
    content: "\1F9F6";
    font-size: calc(var(--cell-width) * 0.75);
    line-height: calc(var(--cell-width) * 0.92);
}

div.game-cell.exploded {
    background-color: black;
    border-right: 2px solid rgb(90, 8, 8);
    border-bottom: 2px solid rgb(90, 8, 8);
    border-left: 2px solid rgb(130, 15, 15);
    border-top: 2px solid rgb(130, 15, 15);
}

.new-game-button {
    width: 90px;
}
#under-game-footer {
    height: 1.8em;
    width: 100%;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: min(1rem, 5svw);
}
#help {
    align-content: center;
    border-radius: 50%;
    aspect-ratio: 1;
    background-color: grey;
    margin: 1px 0px;
    font-size: 0.8em;
    height: 75%;
    cursor: pointer;
    color: white;
}


.top-border {
    border-top: 2px solid lightgray;
    border-left: 2px solid lightgray;
    background-color: grey;
    border-right: 2px solid darkgray;
    width: calc(var(--grid-width) + var(--game-border-thickness) * 2);
    height: var(--game-border-thickness);
}
.header-left-border {
    border-left: 2px solid lightgray;
    background-color: grey;
    border-right: 2px solid darkgray;
    width: var(--game-border-thickness);
    height: var(--header-height);
    display: inline;
}
.game-mines,
.game-time {
    height: var(--header-height);
    position: relative;
}
.game-mines > img.counter-background,
.game-time > img.counter-background {
    position: relative;
    height: var(--header-height);
    display: inline;
    z-index: 0;
}
.counter-digit {
    position: absolute;
    height: calc(50px - 4px);
    margin-left: 2px;
    margin-top: 2px;
    z-index: 100;
}
.counter-100s {
    left: 0;
}
.counter-10s {
    left: 26px;
}
.counter-1s {
    left: 52px;
}
.header-right-border {
    border-left: 2px solid lightgray;
    background-color: grey;
    border-right: 2px solid darkgray;
    width: var(--game-border-thickness);
    height: var(--header-height);
}
.header-grid-border {
    background-color: grey;
    width: calc(var(--grid-width) + var(--game-border-thickness) * 2);
    height: var(--game-border-thickness);
    border-left: 2px solid lightgray;
    border-right: 2px solid darkgray;
}
.grid-container {
    display: flex;
    width: calc(var(--grid-width) + var(--game-border-thickness) * 2);
    position: relative;
}
.grid-left-border {
    border-left: 2px solid lightgray;
    background-color: grey;
    border-right: 2px solid darkgray;
    width: var(--game-border-thickness);
    height: var(--grid-height);
}
.grid-right-border {
    border-left: 2px solid lightgray;
    background-color: grey;
    border-right: 2px solid darkgray;
    width: var(--game-border-thickness);
    height: var(--grid-height);
}
.grid-bottom-border {
    border-left: 2px solid lightgray;
    background-color: grey;
    border-right: 2px solid darkgray;
    height: var(--game-border-thickness);
    width: calc(var(--grid-width) + var(--game-border-thickness) * 2);
    border-bottom: 2px solid darkgray;
}
.settings-popup-header {
    text-align: center;
    font-family: 'Retro Gaming', serif;
    display: flex;
    justify-content: center;
    width: 100%;
    margin-bottom: 5px;
}
.settings-popup-header > strong {
    border-bottom: solid 1px black;
}

.board-cat {
    cursor: pointer;
}

div.popup {
    position: absolute;
    background-color: aliceblue;
    border: 2px solid black;
    border-radius: 10px;
    z-index: 100;
    width: calc(var(--grid-width) - 2 * var(--game-border-thickness));
    left: calc(var(--game-border-thickness) * 2);
    padding: 1em;
    display: flex;
    flex-direction: column;
}
div.winner-popup {
    height: calc(var(--grid-height) * 0.5);
    animation: 0.5s ease-out 0s winner-popup-slide forwards;
    font-size: calc(var(--grid-height) * 0.05);
    justify-content: space-around;
    align-items: center;
    font-family: 'Retro Gaming', serif;
}
div.winner-popup > button {
    font-size: calc(var(--grid-height) * 0.05);
}

div.popup > span {
    text-align: center;
}
div.settings-popup {
    animation: 0.5s ease-out 0s settings-popup-slide forwards;
    font-size: calc(var(--grid-height) * 0.028);
    justify-content: space-around;
    align-items: start;
}
div.settings-popup > button {
    font-size: calc(var(--grid-height) * 0.032);
}

@keyframes winner-popup-slide {
    0% {
        top: calc(var(--grid-height) * 0.5);
        opacity: 0;
    }
    100% {
        top: calc(var(--grid-height) * 0.25);
        opacity: 1;
    }
}
@keyframes settings-popup-slide {
    0% {
        top: calc(var(--grid-height) * 0.5);
        opacity: 0;
    }
    100% {
        top: calc(var(--grid-height) * 0.3);
        opacity: 1;
    }
}

.shake {
    animation: 0.5s linear 0s 1 shake forwards;
}
@keyframes shake {
  0%   { transform: rotate(0deg); }
  25%  { transform: rotate(30deg); }
  50%  { transform: rotate(-30deg); }
  75%  { transform: rotate(15deg); }
  100% { transform: rotate(0deg); }
}
.disabled {
    cursor: default;
    opacity: 0.2;
    filter: brightness(0.5); 
}

button.analyze-clear {
    display: none;
}

.settings-box,
.mode-toggle-box {
    cursor: pointer;
}
div.empty-box,
img.mode-toggle-box {
    height: calc(var(--header-height) * 0.9);
    width: calc(var(--header-height) * 0.9);
}
.game-header,
.grid-container {
    user-select: none;
    -webkit-user-select: none; /* For Safari */
    -moz-user-select: none;    /* For Firefox */
    -ms-user-select: none;     /* For IE/Edge */
}

/***** Analysis Feature *****/
div.game-cell.unsatisfied {
    background-color: #ffc0cb;
}
div.game-cell.satisfied {
    background-color: #8ee88e;
}
div.game-cell.inner {
    background-color: #959580;
}
div.game-cell.border {
    background-color: #bc7e74;
}
div.game-cell.its-a-mine::before {
    font-size: calc(var(--cell-width) * 0.82);
    display: inline-block;
    padding-top: 2px;
    content: "😾";
}
div.game-cell.its-safe::before {
    content: "✔️";
}
div.game-cell.best-chance {
    color: ivory;
    font-weight: bold;
    text-decoration: underline;
}


/****************/

#help-modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 999;
}
#help-modal {
    width: min(728px, 75vw);
    height: 100;
    border-radius: 4rem;
    background-color: aliceblue;
    box-shadow: 15px 15px 40px rgba(0, 0, 0, 0.8);
    z-index: 1000;
    padding: 1rem;
    animation: fadeIn 0.3s ease-out;
}
#help-modal h2 {
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
    font-family: 'Retro Gaming', serif;
}
#close-popup {
    margin-top: 0.5rem;
    background-color: lightgray;
    border-radius: 1em;
    padding: 0.2em 0.5em;
    border: none;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    color: black;
}
#help-content {
    display: grid;
    grid-template-rows: 6fr 2fr 1fr;
    gap: 0.5rem;
}

/*** Moving help content ***/
.help-content-section {
    position: relative;
    display: grid;
    grid-template-rows: 18% 82%;
    border-radius: 1rem;
    background-clip: border-box;
    border: 2px solid darkgray;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
}
.help-content-title-mover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: darkgray;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: row;
    font-size: 1.2em;
    font-weight: bold;
    border-radius: 1rem;
    border: 2px solid darkgray;
    border: none;
    transition: height 0.6s ease;
    color: black;
}
.shrink {
    height: 18%;
}
.help-content-title-spacer {
    border-radius: 1rem;
    background-color: darkgray;
}
.help-content-text {
    align-content: center;
    padding: 0.3rem 0.5rem;
}
@media screen and (min-width: 602px) {
    .help-content-section {
        grid-template-rows: 1fr;
        grid-template-columns: 18% 82%;
    }
    .help-content-title-mover {
        flex-direction: column;
        transition: width 0.6s ease;
    }
    .shrink {
        width: 18%;
    }
}

header {
    width: 100svw;
    border-bottom: 3px solid wheat;
    height: 3.5rem;
    background-color: black;
    text-align: center;
    align-content: center;
}