:root {
    --pop-scale: 1.18;
    --pop-ms: 180ms;
}

@keyframes pop {
    0% {
        transform: scale(1);
    }
    5% {
        transform: scale(var(--pop-scale));
    }
    100% {
        transform: scale(1);
    }
}

.pop-animate {
    animation: pop var(--pop-ms) ease-out;
    transform-origin: center;
    will-change: transform;
}

/* Respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .pop-animate {
        animation: none;
    }
}

/*` MAIN PAGE */
main {
    position: relative;
    min-height: 0;
    min-width: 0;
    overflow-x: hidden;
    display: grid;
    transition: grid-template-columns 1s;
    transition-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    place-items: center;
}
main {
    grid-template-columns: 0% 100%;
    /* grid-template-columns: 50% 50%; */
}
main.gameActive {
    grid-template-columns: 50% 50%;
}

@media (aspect-ratio < 4/3) {
    body {--thin-screen: 1;}
    main,
    main.gameActive {
        grid-template-columns: 1fr;
    }

    main:not(.gameActive) #gameFrame {
        display: none;
    }

    main.gameActive #gameFrame {
        display: grid;
    }

    main.gameActive #gameFrame {
        display: grid;
    }

    main.gameActive #menuDiv {
        display: none;
    }
}

/*` MAIN PAGE CONTAINERS */
#gameDiv {
    min-width: 0;
    min-height: 0;
    min-block-size: 0;
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
}
#gameFrame {
    display: grid;
    place-items: center;
    grid-template-rows: 1fr auto;
    transition: opacity 0.5s;
}

/*` GAME CANVAS */
#gameCanvas {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
    min-block-size: 0;
}
#gameCanvas canvas {
    border-radius: 8px;
    transition: background-color 0.5s;

    background-color: var(--bg-use);
    --bg-use: var(--bg-dark);

    --bg-dark: rgba(150, 150, 150, 0.7);
    --bg-light: rgba(0, 0, 0, 0);
}
[data-theme="light"] #gameCanvas canvas {--bg-use: var(--bg-light);}

/*` QUICK STATS */
#quickStats {
    display: grid;
    place-items: center;
    grid-template-columns: auto 1fr auto auto;
    padding: 0px 5px;
    width: 100%;
    height: 50px;
    gap: 5px;
}
#quickStats .value.bordered {
    border-radius: 6px;
    height: 40px;
    font-size: 1.3em;
    letter-spacing: 2px;
    font-weight: bold;
    line-height: 0;
    place-items: center;
    display: grid;
    padding: 10px;
    position: relative;
    background-color: var(--ddblue);
    color: white;
}
#statbar-moveNumber {
    font-size: 1.2em;
    aspect-ratio: 1/1;
    border-radius: 6px;
    border: 1px solid white;
    height: 40px;
    line-height: 0;
    place-items: center;
    display: grid;
    background-color: var(--ddblue);
    color: white;
}
#statbar-move {
    display: grid;
    place-items: center;
    grid-template-columns: auto repeat(2, 35px);
}
#statbar-move > :nth-child(1) {
    z-index: 1;
}
#statbar-move > :nth-child(2) {
    z-index: 2;
}
#statbar-move > :nth-child(3) {
    z-index: 3;
}
#statbar-move .mult {
    aspect-ratio: 1/1;
    border-radius: 50%;
    position: relative;
    background-color: var(--dddteal);
    border: 3px solid silver;
    color: rgb(255, 255, 255);
    width: 39px;
    display: grid;
    place-items: center;
    font-size: 1.25em;
    line-height: 0;
    text-align: center;
    grid-template-columns: 0 auto;
}
#statbar-move .mult.highlighted {
    border: 2px solid rgb(0, 137, 0);
    background-color: rgb(255, 234, 116);
    color: rgb(51, 51, 51);
}
#statbar-move .mult::before {
    content: "✕";
    width: auto;
    aspect-ratio: 1/1;
    padding: 2px;
    font-size: 0.4em;
    font-weight: bold;
    color: rgb(0, 0, 0);
    background-color: rgb(255, 255, 255);
    border-radius: 50%;
    display: grid;
    place-items: center;
    line-height: 0;
    transform: translate(3px, 14px);
}
#statbar-totalScore {
    font-family: "Roboto", Arial, monospace;
    font-optical-sizing: auto;
    font-weight: bold;
    font-size: 1.5em;
}

/*` PRIMARY MENU */
#menuDiv {
    /* position: absolute; */
    height: 100%;
    width: 80%;
    max-width: 600px;
    transition: background-color 1s;
    padding-bottom: 10px;
    padding-top: 10px;

    display: grid;
    place-items: center;
    grid-template-rows: auto 1fr;
    overflow: hidden;

    --shadow: var(--lgray);
    background-color: rgba(15, 15, 15, 1);
}
[data-theme="light"] #menuDiv {
    --shadow: var(--dgray);
    background-color: rgba(222, 222, 222, 0.959);
    border: 1px solid var(--dddgray);
    border-radius: 4px;
}
[data-theme="light"] #menuDiv.paused {
    background-color: rgba(15, 15, 15, 0.5);
}

/*` GAME TITLE */
#menuDiv header {
    width: 100%;
    aspect-ratio: 42/8;
    padding: 20px 0;
    /* height: 15%; */
    display: grid;
    place-items: center;
}
#menuDiv header canvas {
    border: 1px solid white;
    /* margin: 15px; */
    width: 80%;
    box-shadow: 5px 5px 5px var(--shadow);
    transition: background-color 1s;
    background-color: rgba(0, 0, 0, 0);
}
[data-theme="light"] #menuDiv header canvas {
    background-color: rgba(15, 15, 15, 0.7);
}

/*` MENU BODY ABOVE NAV */
#menuBody {
    display: grid;
    grid-template-rows: 1fr auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    gap: 10px;
}

/*` MENU BUTTON STYLE */
#menuDiv button {
    border-width: 3px;
    box-shadow: 5px 5px 5px var(--shadow);

    transition: background-color 0.5s, opacity 1s, transform 0.5s, border-color 0.5s;
    transform: translate(0px, 0px);
    opacity: 1;
}
#menuDiv button * {
    transition: color 0.7s;
}
#menuDiv button.hideButton {
    opacity: 0;
    pointer-events: none;
}

#menuDiv button {
    background-color: var(--bg-use);
    border-color: var(--bd-use);
    color: var(--color-use);

    --bg-use: var(--bg-dark);
    --bd-use: var(--bd-dark);
    --color-use: var(--color-dark);

    --bg-dark: transparent;
    --bd-dark: white;
    /* --color-dark: var(--color-dark); */
    
    --bg-light: rgba(255, 255, 255, 0.4);
    --bd-light: black;
    --color-light: rgb(32,32,32);   
}
[data-theme="light"] #menuDiv button {
    --bg-use: var(--bg-light);
    --bd-use: var(--bd-light);
    --color-use: var(--color-light);
}
#menuDiv button:hover {
    --bg-dark: rgba(125, 125, 125, 0.422);
    --bd-dark: var(--llblue);
    /* MAY NEED TO APPLY THIS TO ALL ELEMENTS WITHIN BUTTON, WITH !IMPORTANT TAG, THATS WHAT IT WAS BEFORE THEME REFACTOR */
    --color-dark: var(--llblue); 
    
    --bg-light: rgba(15,15,15,0.6);
    --bd-light: var(--dddblue);
    --color-light: var(--color-light);
}


/* ABOUT PAGE */
#menuAbout {
    grid-template-rows: auto auto 1fr;
}
#menuAbout > div:last-child {
    width: 100%;
    height: 100%;
    padding: 15px;
}

/*` MENU NAV PANEL (SWAP FROM SETTINGS TO STATE) */
#menuNavPanel {
    --buttonWidth: 80px;
    width: 100%;
    display: grid;
    grid-template-columns: auto 1fr auto;
    padding: 0 10px;
}
#menuNavPanel button {
    width: var(--buttonWidth);
    height: var(--buttonWidth);
}
#menuNavPanelButtons {
    display: grid;
    grid-template-columns: var(--buttonWidth) var(--buttonWidth);
    gap: 5px;
    transition: grid-template-columns 0.5s, gap 0.5s;
}
#menuNavPanelButtons:has(.gameMenuNavButton:nth-child(1).hideButton) {
    grid-template-columns: 0px var(--buttonWidth);
    gap: 0px;
}
#menuNavPanelButtons:has(.gameMenuNavButton:nth-child(2).hideButton) {
    grid-template-columns: var(--buttonWidth) 0px;
    gap: 0px;
}
.gameMenuNavButton {
    line-height: 0;
    height: 100%;
    aspect-ratio: 1/1;
    border-radius: 25%;
    padding: 10px;
    font-size: 1.3em;
}

[data-theme="light"] #menuDiv button.gameMenuNavButton {
    background-color: rgba(255, 255, 255, 0.4);
    color: black;
}

#menuDiv #backToMainMenuButton.hideButton {
    transform: translate(-100px, 0px);
}
#menuDiv #menuNavPanelButtons button:nth-child(1).hideButton {
    transform: translate(0px, 100px);
}
#menuDiv #menuNavPanelButtons button:nth-child(2).hideButton {
    transform: translate(0px, 0px);
}

.gameMenuNavButton:active {
    padding: 11px;
}
.gameMenuNavButton:active .svgIcon {
    width: 48px;
    --svg_stroke: rgba(220, 252, 255, 0.772);
}
[data-theme="light"] .gameMenuNavButton:active .svgIcon {
    --svg_stroke: rgba(0, 2, 118, 0.772);
}

#viewControlsButton .svgIcon {
    transition: stroke 0.5s;
}
#viewControlsButton:hover .svgIcon {
    --svg_stroke: var(--llblue);
}
[data-theme="light"] #viewControlsButton:hover .svgIcon {
    --svg_stroke: var(--ddblue);
}

#gameSettingsButton .svgIcon {
    transform: rotate(0deg);
    transition: transform 0.3s, stroke 0.5s;
}
#gameSettingsButton:hover .svgIcon {
    transform: rotate(30deg);
    --svg_stroke: var(--llblue);
}
[data-theme="light"] #gameSettingsButton:hover .svgIcon {
    --svg_stroke: var(--ddblue);
}

/*` MENU MAIN COMPONENTS */
#menuMain {
    display: grid;
    transition: grid-template-rows 1s;
    /* grid-template-rows: 100% 0% 0%; */
    min-height: 0%;
    max-height: 100%;
    overflow: hidden;
}
#menuMain:has(.collapsible:nth-child(1):not(.hideHeight)) {
    grid-template-rows: 100% 0% 0%;
}
#menuMain:has(.collapsible:nth-child(2):not(.hideHeight)) {
    grid-template-rows: 0% 100% 0%;
}
#menuMain:has(.collapsible:nth-child(3):not(.hideHeight)) {
    grid-template-rows: 0% 0% 100%;
}

/*` INTERNAL COLLAPSIBLE COMPONENTS */
.collapsible {
    min-height: 0%;
    max-height: 100%;
    height: 100%;
    transition: transform 0.6s, height 0.15s, opacity 0.6s;
    opacity: 1;
    transform: translateY(0%);
    transition-timing-function: ease-in;
    overflow: none;
}
.collapsible.hideHeight {
    opacity: 0;
    transform: translateY(100%);
}
.collapsible.hideHeight:has(~ .collapsible:not(.hideHeight)) {
    transform: translateY(-100%);
}

@property --menuTrack {
    syntax: "<color>";
    initial-value: red;
    inherits: true;
}
@property --menuThumb {
    syntax: "<color>";
    initial-value: blue;
    inherits: true;
}
@property --sw {
    syntax: "<length>";
    initial-value: 0px;
    inherits: true;
}

.collapsibleScrollArea {
    min-height: 0%;
    max-height: 100%;
    overflow: auto;
}

/*` MAIN VIEW MENU BUTTONS */
#menuMain button {
    font-size: 2em;
}
#menuMain button:active {
    font-size: 1.9em;
}

/*` MAIN VIEW MENU ELEMENTS */
#menuMain hr {
    width: 90%;
}
.menuHeader {
    text-align: center;
    font-size: 2.7em;
    margin: 10px 0;
}

.menuHeader.multiMenuSwap {
    display: grid;
    grid-template-columns: auto 1fr auto;
    width: 100%;
    padding: 0 10px;
    place-items: center;
}
.multiMenuSwap button {
    font-size: 35px !important;
    width: 50px;
    height: 50px;
    aspect-ratio: 1/1;
}
.menuHeader.multiMenuSwap button + span {
    grid-column: 2;
}

.grayBoxVal {
    display: grid;
    place-items: center;
    border: 2px ridge var(--llgray);
    border-radius: 5px;
    --shd: 5px;
    --shdColor: var(--lgray);
    box-shadow: var(--shd) var(--shd) var(--shd) var(--shdColor);
    font-weight: bold;
    /* font-family: auto; */
    line-height: 0px;
    color: white;
    background-color: var(--dddgray);
    transition: 0.1s;

    font-size: 1.3em;

    height: 50px;
    padding: 0 20px;
}

/*` MENU VIEW ROW ITEMS */
.menuRows {
    display: grid;
    width: 90%;
    margin-top: 20px;
    row-gap: 10px;
}
.row {
    display: grid;
    grid-template-columns: 1fr auto;
    place-items: center;
    height: 75px;
}
.row.disabled {
    opacity: 0.5;
    pointer-events: none;
}


.row.setting.cb label {
    cursor: pointer;
}

.paletteList .row {
    padding: 0 8px;
}

.row.setting.cb,
[data-theme="light"] .paletteList .row {border: 1px solid gray;}
[data-theme="light"] .paletteList .row {
    border-style: solid none solid none;
    border-radius: 5px;
}

.row.setting.cb {border-color: var(--dddgray)}
[data-theme="light"] .row.setting.cb {border-color: var(--llgray)}
.row.setting.cb.selected {border-color: var(--dgray)}
[data-theme="light"] .row.setting.cb.selected {border-color: var(--gray)}

.row.setting.range {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    font-size: 0.7em;
    text-align: left;
}
.row.setting.range > * {
    width: 100%;
}
.row.setting.range .value {
    font-size: 1.2em;
    font-weight: bold;
}
.row.setting.range .value {
    color: lightblue;
}
[data-theme="light"] .row.setting.range .value {
    color: rgb(0, 0, 0);
}
.menuRows.tabulated .row {
    grid-template-columns: auto 1fr auto;
    gap: 10px;
}
.row > label {
    font-size: 1.5em;
}
.row .cb 
.row .cb {
    width: 30px;
    height: 30px;
    border: 1px solid silver;
    border-radius: 5px;
    display: grid;
    place-items: center;
    margin: 0 10px;
}
.row .cb span {
    opacity: 0;
}
.row.selected {
    background-color: rgba(50, 50, 50, 0.5);
}
[data-theme="light"] .row.selected {
    background-color: var(--lllblue);
}
.row.selected .cb span {
    opacity: 1;
}

.menuRows.tabulated .row hr {
    height: 2px;
    width: 80%;
    line-height: 0;
    padding: 0;
    margin: 0;
    border-style: dashed;
    border-color: var(--ddgray);
}
.menuRows.tabulated .row > label {
    font-size: 1.5em;
    text-align: left;
}

#palettePane {
    display: grid;
    width: 90%;
    margin-top: 20px;
}
.paletteList {
    width: 100%;
}

/*` STATE MENUS - MAIN / PAUSE */
.collapsibleScrollArea,
#menuState .collapsibleScrollArea > div {
    height: 100%;
    width: 100%;
    display: grid;
    place-items: center;
    /* height: fit-content; */
}
.primaryButtonPanel {
    height: 100%;
    width: 100%;
    display: grid;
    place-items: center;
    gap: 20px;
}
    #menuControls .collapsibleScrollArea,
    #menuControls .menuSettings {
        height: min-content;
    }

/*` PAGE STATE BUTTONS */
#menuState button {
    width: 80%;
    height: 100px;
    padding: 20px;
}

#menuState button:nth-child(1) {
    --shadow: darkgreen;
}
#menuState button:nth-child(2) {
    --shadow: orange;
}
#menuState button:nth-child(3) {
    --shadow: blue;
}

/* COLOR PALETTE PICKER */
.palette {
    display: grid;
    grid-auto-flow: column;
    gap: 3px;
    opacity: 0.7;
}
.row.selected .palette {
    opacity: 1;
}
.colorBox {
    width: 50px;
    height: 50px;
    border: 2px solid silver;
    border-radius: 5px;
}

/* CONTROLS VIEW */
#menuControls .row > div {
    display: grid;
    grid-auto-flow: column;
    gap: 15px;
}

#menuGameStats .grayBoxVal {
    --shdColor: var(--lllblue);
    background-color: var(--dddblue);
    color: white;
    font-weight: normal;
}



@media screen and (max-width: 600px) {
    
#menuDiv {
    width: 90%;
}
    #menuState button {
        padding: 5px;
        font-size: 1.2em;
        width: 70%;
        height: 75px;
    }
.paletteList .colorBox {
    --d: calc( 100vw / 12 );
    width: var(--d);
    height: var(--d);
}

    #menuControls .row {
        height: 40px;
    }
    #menuControls .row > div {
        gap: 10px;
    }
    #menuControls .row > label,
    #menuControls .row .grayBoxVal {
        font-size: 0.9em;
    }

    #menuControls .grayBoxVal {
        height: 35px;
        padding: 0 15px;
    }

    .menuHeader {
        font-size: 1.5em;
    }

    
.menuRows {
    margin-top: 5px;
    row-gap: 15px;
}

    .multiMenuSwap button {
        width: 35px;
        height: 35px;
        font-size: 20px !important;
    }

    .paletteList .row {
        height: 50px;
    }

    #menuSettings .row.setting.cb {
        height: 40px;
    }
    #menuSettings .row.cb label {
        font-size: 1.2em;
    }

    #menuSettings .row.setting.range {
        height: auto;
        gap: 10px;
    }
    #menuSettings .row.setting.range label {
        font-size: 1.2em;
    }
    
    .gameMenuNavButton {
        padding: 5px;
        font-size: 1.1em;
    }
    
    #menuNavPanel {
        --buttonWidth: 60px;
    }
    #menuNavPanelButtons {
        gap: 20px;
    }

}

/* CUSTOM RANGE STYLING */
.range[type="range"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    box-sizing: border-box;
}
.range[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
}
.range[type="range"]::-webkit-slider-runnable-track {
    border-radius: 3px;
}
.range[type="range"]::-moz-range-track {
    border-radius: 3px;
}

.range[type="range"]::-webkit-slider-runnable-track {
    background-color: #00eaff43;
    border: 1px solid black;
}
.range[type="range"]::-moz-range-track {
    background-color: #00eaff43;
    border: 1px solid black;
}

[data-theme="light"] .range[type="range"]::-webkit-slider-runnable-track {
    background-color: #00eaff43;
    border: 1px solid black;
}
[data-theme="light"] .range[type="range"]::-moz-range-track {
    background-color: #00eaff43;
    border: 1px solid black;
}


.range[type="range"]::-webkit-slider-thumb {
    border-width: 1px;
    border-style: solid;
    border-radius: 4px;
}
.range[type="range"]::-moz-range-thumb {
    border-width: 1px;
    border-style: solid;
    border-radius: 4px;
}

.range[type="range"] {
    width: 100%;
    height: 20px;
}
.range[type="range"]::-webkit-slider-runnable-track {
    height: 8px;
}
.range[type="range"]::-moz-range-track {
    height: 8px;
}

.range[type="range"]::-webkit-slider-thumb {
    margin-top: -14px;
    width: 18px;
    height: 34px;
    cursor: ew-resize;
}
.range[type="range"]::-moz-range-thumb {
    width: 10px;
    height: 34px;
    cursor: ew-resize;
}

.range[type="range"].vertical {
    writing-mode: vertical-lr;
    direction: rtl;
    width: 20px;
    height: 100%;
}
.range[type="range"].vertical::-webkit-slider-thumb {
    width: 20px;
    height: 10px;
    cursor: ns-resize;
}
.range[type="range"].vertical::-moz-range-thumb {
    width: 20px;
    height: 10px;
    cursor: ns-resize;
}

.range[type="range"]::-webkit-slider-thumb {
    --bd: #000000ff;
    --fill: #ffffffff;
    background: var(--fill);
    border-color: var(--bd);
}
.range[type="range"]::-moz-range-thumb {
    --bd: #000000ff;
    --fill: #ffffffff;
    background: var(--fill);
    border-color: var(--bd);
}
.range[type="range"]::-webkit-slider-thumb {
    --bd: #ffffffff;
    --fill: #646464bf;
}
.range[type="range"]::-moz-range-thumb {
    --bd: #ffffffff;
    --fill: #646464bf;
}
[data-theme="light"] .range[type="range"]::-webkit-slider-thumb {
    --bd: #000000ff;
    --fill: #a7a7a7fe;
}
[data-theme="light"] .range[type="range"]::-moz-range-thumb {
    --bd: #000000ff;
    --fill: #a7a7a7fe;
}
