/************************************************************
   Global configuration of colors
 ************************************************************

 *-----------------------------------------------------------
   Background color and text
 *-----------------------------------------------------------
   --bg-color
   --bg-color-text

 * Lighter text color used for games and move ordinal numbers
   --bg-color-text-light

 * A light variant of background color (used for text-areas, input fields and dropdown-menus)
   --bg-color-light
   --bg-color-light-text

 * Colors when hovering elements on background color (move or game selection)
   --bg-color-hover
   --bg-color-hover-text

 * Color of active (selected) game and move
   --bg-color-active

 *------------------------------------------------------------
   Main color (for buttons, navbar and more)
 *------------------------------------------------------------
   --main-color-bg
   --main-color-text

 * A light variant of main color (used toggled nav background on smaller screens)
   --bg-color-light
   --bg-color-light-text

 * Color when hovering main-color elements
   --main-color-hover
   --main-color-hover-text

 *------------------------------------------------------------
   Chess board colors
 *------------------------------------------------------------
   --white-square
   --black-square
   --highlight-white-sq
   --highlight-black-sq

 * Colors for row with player names
   --player-item-color
   --player-item-color-text

 * Color for ticking clock (of player to move)
   --bg-active-clock
   --bg-active-clock-text
 */

/* Light theme example preset */
:root {
    --bg-color: #fff;
    --bg-color-text: #111;
    --bg-color-text-light: #888;
    --bg-color-light: #eee;
    --bg-color-light-text: #111;
    --bg-color-hover: #27c;
    --bg-color-hover-text: #fff;
    --bg-color-active: #cde;
    --main-color-bg: #2095d2a6;
    --main-color-text: #111;
    --main-color-light: #2A94CDA5;
    --main-color-light-text: #111;
    --main-color-hover: #2095c2ff;
    --main-color-hover-text: #111;
    --main-color-border: #bbb;
    --player-item-color: #ddd;
    --player-item-color-text: #111;
    --bg-active-clock: #659d25;
    --bg-active-clock-text: #fff;
}

/* Dark theme example preset */
[data-theme="alternative"] {
    --bg-color: #111;
    --bg-color-text: #eee;
    --bg-color-text-light: #888;
    --bg-color-light: #333;
    --bg-color-light-text: #eee;
    --bg-color-hover: #3692e7;
    --bg-color-hover-text: #eee;
    --bg-color-active: #293a49;
    --main-color-bg: #2095d2a6;
    --main-color-text: #eee;
    --main-color-light: #2699D6A6;
    --main-color-light-text: #eee;
    --main-color-hover: #2095c0ff;
    --main-color-hover-text: #eee;
    --main-color-border: #216C9C;
    --player-item-color: #444;
    --player-item-color-text: #eee;
    --bg-active-clock: #659d25;
    --bg-active-clock-text: #eee;
}

[board-theme=gray] {
    --white-square: #d6d6d6;
    --black-square: #8f8f8f;
    --highlight-white-sq: #d6d6b3;
    --highlight-black-sq: #bfbf88;
}

[board-theme=brown] {
    --white-square: #f0d9b5;
    --black-square: #b58863;
    --highlight-white-sq: #ced26b;
    --highlight-black-sq: #aba23a;
}

[board-theme=red] {
    --white-square: #f7dac3;
    --black-square: #bf584a;
    --highlight-white-sq: #f7e9aa;
    --highlight-black-sq: #dba86e;
}

[board-theme=green] {
    --white-square: #ffffdd;
    --black-square: #86a666;
    --highlight-white-sq: #f6f879;
    --highlight-black-sq: #b9cc36;
}

.bad {
    color: #cc3333;
}

.rtgLoss::before {
    content: "⬊";
    padding-right: .25em;
}

.good {
    color: #629924;
}

/* Result and rating changes usually have small space in player tooltip table - prevent line wrap */
.good, .bad {
    white-space: nowrap;
}

.rtgGain::before {
    content: "⬈";
    padding-right: .25em;
}

/* Override Bootstrap variables */
.form-select {
    border-radius: var(--border-radius);
}

.btn {
    --bs-btn-border-radius: var(--border-radius);
}

.dropdown-menu {
    --bs-dropdown-border-radius: var(--border-radius);
}

.modal {
    --bs-modal-border-radius: var(--border-radius);
}


/************************************************************
   General
 ************************************************************/
body {
    background-color: var(--bg-color);
    color: var(--bg-color-text);
    font-family: Verdana, Arial, Helvetica, sans-serif;
    text-align: center;
    /* Single place to set border-radius for whole page */
    --border-radius: .25rem;
}

input::placeholder {
    color: var(--bg-color-light-text);
}

#GameSelectionDiv, #GameText {
    overscroll-behavior: none;
}

/************************************************************
   Navigation bar
 ************************************************************/
.navbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    padding: 0;
}

nav ul {
    margin: 0;
    padding: 0 1rem;
}

nav ul > li {
    list-style-type: none;
}

nav a > span, nav a > i {
    font-size: 1.1rem;
}

nav a {
    padding: 1rem .4rem;
    margin: 0 .25rem;
    border-radius: var(--border-radius);
    display:inline-block;
}


/* Note: Customize the navbar flexbox according to your needs */
#MainBody {
    padding-top: 7.5rem; /* adjust in order to accomodate navbar contents */
}

nav img {
    height: 100px;
    padding: .5rem;
    margin-right: 1rem;
}

nav h3 {
    margin-left: 1rem;
}

nav h3 {
    /* Title should flex-grow, but not cause the nav to flex-wrap in a new line */
    flex-basis: 5rem;
    flex-grow: 1;
    padding: 0 .5rem;
    margin-bottom: 0;
    text-align: left;
}

#NavbarContent {
    flex-grow: 0;
    justify-content: flex-end;
}

nav > .container-fluid {
    padding: 0;
}

nav .dropdown {
    /* Centering dropdown menu in navbar has an issue. Workaround for smaller screens
       See: https://github.com/twbs/bootstrap/issues/36897 */
    display: inline;
}

.navbar-toggler {
    border: 0;
    padding: 0;
    margin: .5rem;
}

.navbar-toggler-icon {
    width: 2em;
    height: 2em;
}

body[data-theme="alternative"] .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' \
                      viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' \
                      stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' \
                      d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.navbar-toggler:focus {
    box-shadow: none;
}

body[data-theme="alternative"] .navbar-toggler {
    border-color: rgba(255,255,255,0.1);
}

/* Custom breakpoint for navbar aligned with clint sizes, toggle navbar below 1260px */
@media (min-width: 1260px) {
    nav {
        justify-content: flex-start
    }

    nav .navbar-collapse {
        display: flex!important;
        flex-basis: auto
    }

    nav .navbar-toggler {
        display: none
    }
}

@media (max-width: 1259px) {
    nav a {
        padding: .75rem .25rem;
    }

    nav ul {
        background-color: var(--main-color-light);
        color: var(--main-color-light-text);
        padding: .5rem 0;
    }

    nav h3 {
        text-align: center;
        margin: 0;
    }
}

@media (max-width: 799px) {
    .navbar-toggler-icon {
        width: 1.5em;
        height: 1.5em;
    }
}

/************************************************************
   Buttons
 ************************************************************/
/* Border for custom buttons */
.btn-custom, .btn-custom:hover, .btn-custom:active, .btn-custom:active:focus,
.btn:first-child:active, .btn.show,
#MultiboardSettingsItem select {
    border: 0;
    border-bottom: 2.5px solid var(--main-color-border);
}

#Miniboard #ControlPanel button {
    border: 0;
    padding: .375rem 0;
}

/* Normal colors
   Note: hover colors are enabled only on devices supporting hovering */
nav, .btn-custom, .btn-custom:hover, .btn:first-child:active, .panelTitle {
    background-color: var(--main-color-bg);
    color: var(--main-color-text);
}

/* Hover colors */
nav a:active, .btn-custom:not(:disabled):not(.disabled):active,
.dropdown > .show.dropdown-toggle, .dropup > .show.dropdown-toggle {
    background-color: var(--main-color-hover);
    color: var(--main-color-hover-text)
}

@media (hover: hover) and (pointer: fine) {
    /* Enable when user's primary input mechanism can hover elements and
       user has an accurate pointing device (e.g. mouse, not a finger) */
    #NavbarContent a:hover, .btn-custom:hover,
    .dropdown-menu .dropdown-item:hover,
    #StreamDiv > div:hover,
    .streamItem:hover {
        background-color: var(--main-color-hover);
        color: var(--main-color-hover-text);
    }

    #GameText a.move:hover {
        background-color: var(--bg-color-hover);
        color: var(--bg-color-hover-text);
    }

    #GameSelectionDiv > div:hover,
    #GameSelectionDiv > div.active:hover,
    #GameSelectionDiv > div:hover > span:first-child {
        background-color: var(--bg-color-hover);
        color: var(--bg-color-hover-text);
    }

    #EngineToggleIcon:hover {
        filter: drop-shadow(0px 0px 3px var(--main-color-text));
    }

    #GameSelectionDiv > div.active:not(:hover) {
        background-color: var(--bg-color-active);
    }

    .streamerLink:hover {
        background-color: var(--main-color-bg);
        color: var(--main-color-text);
    }

    #PlayerTooltip .btn-close {
        display: none;
    }
}

@media (not (hover: hover)) or (not (pointer: fine)) {
    #GameWhite, #GameBlack {
        /* Disable selection of text on first touch in mobile */
        -webkit-user-select: none;
        user-select: none;
    }
}

.btn-custom:focus {
    box-shadow: none;
}

/* Override bootstrap styling for anchors */
a, a:hover {
    color: inherit;
    text-decoration: none;
}

#ControlsItem .btn, #SettingsItem > div > .btn {
    padding: 0;
}

.dropdownItemBtn {
    padding: 0 .375rem;
}

.dropdown-menu {
    background-color: var(--main-color-bg);
    color: var(--main-color-text);
    font-size: 1.2rem;
    z-index: 1500;
}

.dropdown-item:active, .dropdown-item:focus, .dropdown-item:hover {
    background-color: inherit;
    color: inherit;
}

.dropdown-item {
    color: var(--main-color-text);
    padding: 0.25rem 0.75rem;
    margin: 0.25rem 0;
    border-radius: var(--border-radius);
}

.dropdown-menu.dropdown-submenu a:not(.dropdown-submenu-active-item) {
    display: none;
}

.dropdown-menu:not(.dropdown-submenu) .fa-angle-left {
    display: none;
}

.board-colors-submenu span {
    display: inline-block;
    width: 30px;
    height: 30px;
}

.board-colors-submenu .btn,
.board-colors-submenu .btn:active {
    border: 0;
}

textarea, input {
    background-color: var(--bg-color-light);
    color: var(--bg-color-light-text);
    font-family: monospace;
    font-size: 14px;
    border: 0;
    border-radius: var(--border-radius);
}

textarea:focus, input:focus {
    outline: none;
    border: 0;
}

textarea::-webkit-resizer {
    border-width: 8px;
    border-style: solid;
    border-color: var(--bg-color-light) var(--main-color-bg) var(--main-color-bg) var(--bg-color-light);
}

::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 12px rgba(200,200,200,1);
    border-radius: var(--border-radius);
}

::-webkit-scrollbar-thumb {
    border-radius: var(--border-radius);
    background-color: var(--main-color-bg);
}

.btn-close {
    color: var(--bg-color-text);
}

.btn-close:focus {
    box-shadow: none;
}

.btn-close:focus:not(:hover) {
    opacity: .5;
}

body[data-theme="alternative"] .btn-close {
    filter: invert(1);
}

.modal-content {
    background-color: var(--bg-color);
}

/* PGN text styles */
.highlightMove {
    background-color: var(--bg-color-active);
}

#GameText, #EngineVariationDiv {
    /* Select chess figurines fonts */
    font-family: "pgn4web ChessSansPiratf";
    /* font-family: "pgn4web ChessSansMerida"; */
    /* font-family: "pgn4web ChessSansUsual"; */
    font-size: 18px;
}

#ShowPgnText {
    line-height: 1.2;
}

#GameSideToMove, #GameResult {
    display: none;
}

#GameText {
    margin-left: .5rem;
    margin-right: .5rem;
    margin-top: .2rem;
}

#GameText span.move.notranslate {
    color: var(--bg-color-text-light);
    font-size: 90%;
}

#GameText a.move {
    padding: 2px 0px;
    white-space: nowrap;
    border-radius: var(--border-radius);
}

#GameText.lineFormNotation a.move {
    text-align: left;
    display: inline-block;
    width: 35%;
    margin-left: 3px;
    padding: 2px 5px;
}

#GameText.lineFormNotation span.move {
    text-align: center;
    display: inline-block;
    width: 20%;
}

#GameText.lineFormNotation .variation:nth-of-type(3n) {
    display: block;
}

/* Game text and engine are in the same flexbox because it is undesirable
   to resize other elements in the panel by toggling the engine */
#GameTextDiv {
    display: flex;
    flex-direction: column;
}

#GameText {
    flex: 1 1 5em;
}

#EngineEvalDiv, #EngineVariationDiv {
    flex-shrink: 0;
}

#EngineEvalDiv {
    background-color: var(--main-color-bg);
    color: var(--main-color-text);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

#Score {
    font-size: 175%;
}

#EngineToggleIcon {
    font-size: 200%;
}

@media (min-width: 800px) and (max-width: 1259px) {
    #EngineEvalDiv {
        font-size: calc(10px + ((100vw - 800px) / 100));
    }
}

#EngineNote {
    white-space: nowrap;
}

#EngineVariationDiv {
    background-color: var(--bg-color-light);
    color: var(--bg-color-light-text);
    line-height: 1.5em;
    height: 3em;
    overflow: hidden;
    display: none;
}

/* Game board styles */
#GameBoard {
    user-select: none;
}

.whiteSquare {
    background-color: var(--white-square);
}

.blackSquare {
    background-color: var(--black-square);
}

.highlightWhiteSquare {
    background-color: var(--highlight-white-sq);
}

.highlightBlackSquare {
    background-color: var(--highlight-black-sq);
}

.playerName, .result, .rating {
    font-size: calc(17px + ((100vw - 320px) / 800));
}

.playerName, .result {
    font-weight: 700;
}

.result {
    border-right: 1px solid var(--main-color-text);
}

.clock {
    font-size: calc(16px + ((100vw - 320px) / 700));
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 .5rem;
    height: 100%;
}

.clockActive {
    background-color: var(--bg-active-clock);
    color: var(--bg-active-clock-text);
}

#ClockPlace1 {
    border-radius: 0 var(--border-radius) 0 0;
}

#ClockPlace2 {
    border-radius: 0 0 var(--border-radius) 0;
}

#TopPlayerItem, #BotPlayerItem {
    display: flex;
}

#PlayerInfo1, #PlayerInfo2 {
    overflow: hidden;
    flex-grow: 1;
}

#ResultPlace1, #ResultPlace2 {
    flex-basis: 3rem;
    flex-grow: 0;
    flex-shrink: 0;
}

#ClockPlace1, #ClockPlace2 {
    flex-grow: 0;
    flex-shrink: 0;
}

#PlayerPlace1, #PlayerPlace2, #RatingPlace1, #RatingPlace2, #PlayerFlagBlack, #PlayerFlagWhite {
    padding-left: .75rem;
}

#RatingPlace1, #RatingPlace2 {
    padding-right: .75rem;
}

@media (max-width: 799px) {
    #ResultPlace1, #ResultPlace2 {
        flex-basis: 2rem;
    }

    #PlayerPlace1, #PlayerPlace2, #RatingPlace1, #RatingPlace2, #PlayerFlagBlack, #PlayerFlagWhite {
        padding-left: .5rem;
    }
}

#TopPlayerItem, #BotPlayerItem {
    background-color: var(--player-item-color);
    color: var(--player-item-color-text);
    align-items: center;
}

#TopPlayerItem {
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

#BotPlayerItem {
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

#GameWhite, #GameBlack, #GameWhiteClock, #GameBlackClock {
    white-space: nowrap;
}

/* Double internal flexbox to handle long player names without overflow */
#PlayerInfo1, #PlayerInfo2 {
    display: flex;
}

#PlayerPlace1, #PlayerPlace2 {
    display: flex;
    overflow: hidden;
}

#GameBlack, #GameWhite {
    overflow: hidden;
    text-overflow: ellipsis;
}

.fi-fide {
    background-image: url(images/FID.svg);
}

/* Game selection styles*/
.form-select {
    background-color:  var(--main-color-bg);
    background-image: none;
    color: var(--main-color-text);
    border: 0px;
}

#GameSelectionDiv {
    text-align: left;
}

#GameSelectionDiv > div > span:first-child {
    color: var(--bg-color-text-light);
    font-size: 90%;
    text-align: center;
}

#GameSelectionDiv {
    font-size: calc(15px + ((100vw - 320px) / 700));
}

#GameSelectionDiv > div > * {
    padding: 0 .25rem;
}

/* Display player names in game selection on a single line */
#GameSelectionDiv span:nth-child(2) {
    overflow: hidden;
    text-overflow: ellipsis;
}

#GameSelectionDiv span:nth-child(2) > span {
    white-space: nowrap;
}

#GameSelectionDiv span:last-child {
    text-align: center;
}

#GameSelectionDiv > div {
    align-items: center;
    border-radius: var(--border-radius);
    border-bottom: 2px solid var(--bg-color-light);
}

#GameSelectionDiv > div.active {
    background-color: var(--bg-color-active);
}

#GameSelectionDiv .btn {
    line-height: 2;
    padding: 0;
}

#GameSelectionDiv .btn.active {
    background-color: var(--bg-color-active);
    color: var(--bg-color-text);
    border-color: transparent;
}

.fa-list-ul {
    font-size: 22px;
    vertical-align: middle;
    padding-bottom: .25rem;
}

#DownloadModalBtn {
    width: 100%;
}

/* Modal styles */
#DownloadModal a.btn, #DownloadModal button.btn {
    width: 42px;
}

.modal-footer {
    display: block;
    padding-left: 0;
    padding-right: 0;
}

#ClockTimes span {
    color: var(--bg-color-text-light);
    font-size: 90%;
}

.modal a > i
{
    vertical-align: middle;
}

/* Snackbar & player tooltip styles */
#Snackbar {
    visibility: hidden;
    min-width: 250px;
    background-color: var(--main-color-text);
    color: var(--main-color-bg);
    text-align: center;
    border-radius: var(--border-radius);
    padding: 16px;
    position: fixed;
    z-index: 2000;
    left: 50%;
    transform: translateX(-50%);
    bottom: 60px;
}

#Snackbar.show {
    visibility: visible;
}

.tooltipPlayerInfo {
    padding: 1.5em 1em;
    font-size: 1.1em;
}

.tooltipPlayerInfo > div {
    padding-left: 1em;
    margin-top: auto;
    margin-bottom: auto;
}

.tooltipPlayerInfo span {
    padding: 0 .25em;
}


.colorIconWhite::before {
    content: "○";
}

.colorIconBlack::before {
    content: "●";
}

.tooltipOpponents td {
    padding: .2rem .4rem;
}

.tooltipOpponents td:first-child {
    padding-inline-start: 1rem;
}

.tooltipOpponents td:last-child {
    padding-inline-end: 1rem;
}

.tooltipProfiles {
    padding: 1.5em 2em;
    font-size: 1.1em;
}

.tooltipProfiles a {
    padding: .5rem;
    font-size: 1.4rem;
}

.tooltipPlayerInfo {
    background-color: var(--bg-color-light);
    color: var(--bg-color-light-text);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    display: flex;
}

#PlayerTooltip {
    text-align: left;
    position: absolute;
    background-color: var(--bg-color);
    color: var(--bg-color-text);
    border-radius: var(--border-radius);
    border: 1px solid var(--main-color-bg);
}

#PlayerTooltip tr {
    border-bottom: 1px solid var(--bg-color-light);
}

#PlayerTooltip .btn-close {
    position: absolute;
    top: 3%;
    right: 3%;
}

#PlayerTooltip img {
    height: 150px;
}

#PlayerTooltip img[src=""] {
    width: 0;
    height: 0;
}

@media (max-width: 799px) {
    #PlayerTooltip {
        width: 100%;
    }

    #PlayerTooltip table {
        margin-right: auto;
        margin-left: auto;
    }

    .tooltipOpponents td {
        padding: .2rem .2rem;
    }

    .tooltipOpponents td:first-child {
        padding-inline-start: .5rem;
    }

    .tooltipOpponents td:last-child {
        padding-inline-end: .5rem;
    }
}

/* Miniboard styles */
iframe {
    border: 0;
}

#Miniboard {
    background-color: var(--main-color-bg);
    color: var(--main-color-text);
}

#Miniboard * {
    border-radius: 0;
}

.resultTile {
    border-right: 1px solid var(--main-color-text);
}

.playerNameTile {
    font-weight: 600;
    padding: 0px 0px 0px 6px;
    overflow: hidden;
    text-align: left;
}

.clockTile {
    padding: 0px 3px;
    overflow: hidden;
}

#MiniboardBlackInfo, #MiniboardWhiteInfo {
    display: flex;
}

#ResultBlack, #ResultWhite {
    flex: 1.875rem 0 0;
}

#GameBlack, #GameWhite {
    flex-basis: 0;
    flex-grow: 1;
}

#MiniboardBlackClock, #MiniboardWhiteClock {
    flex-grow: 0;
    flex-shrink: 0;
}

#MiniboardBlackInfo, #MiniboardWhiteInfo {
    line-height: 2;
}

#GamesSelectionContainer{
    max-height: 450px;
    overflow-y: scroll;
}

#ControlPanel {
    border-top: 0;
}

.controlPanelBtn {
    width: 20%;
    border: 0;
}

.controlPanelBtn:focus {
    outline: none;
}

#StreamList {
    width: 100%;
}

.streamerEntry {
    display: flex;
}

.streamerName {
    flex-grow: 1;
    flex-shrink: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.streamerFlag, .streamerLink {
    flex-shrink: 0;
}

#StreamList ul {
    padding: 0;
    list-style: square none inside;
    font-size: 90%;
}

.streamItem {
    padding-left: 1rem;
}

/* Embedded video styles */
#VideoDivLeft iframe, #VideoDivRight iframe {
    width: 100%;
    height: 100%;
    border-radius: var(--border-radius);
}

#ImageDivLeft img, #ImageDivRight img {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--border-radius);
}

/************************************************************
   CSS Grid
************************************************************/
#SingleBoardView, #MultiBoardView {
    margin-bottom: 0.5rem;
}

/* Notes:
     - side panels have a fixed height (set from JS) in order for the chessboard to be a square
     - items inside the flexbox can be reordered using the `order` property
     - height of each element can be customized using `flex-{basis/grow/shrink}` properties
*/

/* Single board view */
#RightPanel {
    grid-area: right;
}

#LeftPanel {
    grid-area: left;
}

#LeftPanel, #RightPanel {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

#LeftPanel > *, #RightPanel > * {
    margin: 0 1rem;
}

#VideoDivLeft, #ImageDivLeft, #CustomItemLeft,
#VideoDivRight, #ImageDivRight, #CustomItemRight {
    overflow: hidden;
    flex-basis: 20%;
    flex-grow: 1;
}

#GameSelectionDiv {
    flex-basis: 20%;
    flex-grow: 1;
}

#GameTextDiv {
    overflow: hidden;
    flex-basis: 10rem;
    flex-grow: 1;
}

.panelTitle {
    height: 50px;
    line-height: 50px;
    font-weight: 700;
    border-radius: var(--border-radius);
}

#GameSelectionDiv, #GameText {
    overflow-y: scroll;
}

@media (min-width: 800px) {
    #CustomItemLeft, #CustomItemRight {
        overflow-y: auto;
    }
}

#ControlsItem button, #SettingsItem > div > button {
    font-size: 1.5rem;
}

#ControlsItem button, #SettingsItem button, #SearchInput, #DownloadModal .btn, #PgnFileSelect {
    height: 42px;
}

#BoardItem {
    grid-area: board;
    /* First part of the hack to maintain 1:1 aspect ratio for the board element */
    position: relative;
    padding-top: 100%;
}

#SingleBoardView #boardTable {
    /* Second part of the hack to maintain 1:1 aspect ratio for the board element */
    position: absolute;

    /* Center the board horizontally */
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);

    /* Adjust the width and height at pgn4web.js startup time (when opening PGN from URL params) */
    width: 100%;
    height: 100%;
}

#TopPlayerItem {
    grid-area: topname;
}

#BotPlayerItem {
    grid-area: botname;
}

#SingleBoardView {
    display: grid;
    --spacing: 1em;
    --player-names: 34px;
    grid-template-columns:
        minmax(350px, 45vw)
        minmax(16px, 1.25vw)
        minmax(min(60vw, 60vh), min(80vw, 80vh))
        minmax(350px, 45vw);
    grid-template-rows:
        var(--player-names)
        min-content
        var(--player-names);
    grid-template-areas:
        "left  .    topname  right"
        "left  bar  board    right"
        "left  .    botname  right";
    justify-content: center;
}

#EvaluationBarContainer {
    position: relative;
    background-color: #000;
    border: 1px solid var(--player-item-color);
    grid-area: bar;
}

#EvaluationBarContainer tick {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    border-bottom: 1px solid #eb4;
}

#EvaluationBarContainer tick.zero {
    top: 1px;
    border-bottom: 2px solid #a00;
}

#EvaluationBar {
    background-color: #fff;
    width: 100%;
    position: absolute;
    bottom: 0;
    transition: height 1s;
}

@media (min-width: 800px) and (max-width: 1259px) {
    #SingleBoardView {
        grid-template-columns:
            minmax(12px, 1.5vw)
            minmax(min(60vw, 60vh), min(80vw, 80vh))
            minmax(25vw, 45vw);
        grid-template-rows:
            var(--player-names)
            min-content
            var(--player-names)
            var(--spacing)
            min-content;
        grid-template-areas:
            ".     topname  right"
            "bar   board    right"
            ".     botname  right"
            ".     .        .    "
            "left  left     left";
    }

    #LeftPanel > * {
        flex: initial;
    }

    #CustomItemLeft, #GameSelectionDiv {
        max-height: 50vh;
    }

    #ImageDivLeft {
        max-height: 62vh;
    }

    #VideoDivLeft {
        /* YouTube embeds don't have significant intrinsic size, so they naturally appear small */
        flex-basis: 500px;
    }

}

@media (max-width: 799px) {
    #LeftPanel > *, #RightPanel > * {
        margin: 0;
    }

    /* In mobile view, there is no limit on panel height */
    #LeftPanel > *, #RightPanel > *, #GameText {
        flex: initial;
    }

    #LeftPanel, #RightPanel {
        gap: 1rem;
    }

    #ControlsItem, #SettingsItem {
        order: -1;
    }

    #VideoDivRight, #ImageDivRight {
        order: 1;
    }

    /* Dimension of elements is only limited in terms of total viewport height */
    #GameSelectionDiv, #GameTextDiv {
        max-height: 50vh;
    }

    #ImageDivLeft, #ImageDivRight, #CustomItemLeft, #CustomItemRight {
        max-height: 75vh;
    }

    #VideoDivRight,  #VideoDivLeft {
        /* YouTube embeds don't have significant intrinsic size, so they naturally appear small */
        flex-basis: 300px;
    }

    #SingleBoardView {
        --player-names: 30px;
        grid-template-columns:
            minmax(8px, 3vw)
            minmax(min(60vw, 60vh), min(100vw, 80vh));
        grid-template-rows:
            var(--player-names)
            min-content
            var(--player-names)
            var(--spacing)
            min-content
            var(--spacing)
            min-content;
        grid-template-areas:
            ".      topname"
            "bar    board  "
            ".      botname"
            ".      .      "
            "right  right  "
            ".      .      "
            "left   left   ";
    }

    #ControlsItem > button, #SettingsItem > button, #SearchInput, #PgnFileSelect {
        height: 50px;
    }
}

/* Multiple board view */
#IframesContainer {
    grid-area: iframes;
}

#MultiboardSettingsItem {
    grid-area: mbSettings;
    white-space: nowrap;
}

#MultiboardSettingsItem .btn {
    overflow: hidden;
}

#MultiBoardView {
    display: grid;
    grid-template-rows: auto;
    grid-template-areas:
        "iframes"
        "mbSettings";
    row-gap: .5rem;
    justify-content: center;
}

#MultiboardSearchInput, #MultiboardSaveBtn, #MultiboardSettingsItem button,
#MultiboardFileSelect {
    height: 42px;
}

#MultiboardSettingsItem .btn i {
    font-size: 1.5rem;
}

#MultiboardSettingsItem .btn span, #MultiboardSettingsItem select {
    font-size: 1.25rem;
}

#MultiboardSettingsItem select {
    text-align: center;
}

@media (max-width: 799px) {
    #MultiBoardView {
        grid-template-columns: 100vw;
    }
    #MultiboardSettingsItem button, #MultiboardSettingsItem select,
    #MultiboardSearchInput, #MultiboardSaveBtn {
        height: 50px;
    }
}

#MultiboardSearchInput {
    text-align: center;
}

.small-wrap {
    font-size: .825em;
    word-wrap: anywhere;
}
