:root {
    --flash-light-color: #ee6633;
}

#board {
    border-collapse:collapse;
}

a {
    text-decoration:none;
    color:blue;
}

:root {
    --global-bg: #FFF;
    --menu-color: #000;
    --menu-button-color: #000;
    --menu-button-bg: #CFC;
    --menu-button-border: #8C8;
    --menu-button-hover-border: #FD7;
    --menu-button-hover-bg: #CA5;
    --chat-border: silver;
    --participants-th-color: #555;
    --participants-th-bg: #EEE;
    --rack-bg:#EEC;
    --board-td-border: #220;
    --board-tile-bg: #FFC;
    --board-tile-color: #000;
    --rack-tile-bg: #CCA;
    --rack-tile-color: #000;
    --tripleWord-bg: #F77;
    --tripleLetter-bg: #77F;
    --doubleLetter-bg: #7CF;
    --doubleWord-bg: #FBB;
    --tile-bg: #EE8;
    --tile-color: #000;
    --msg-sender-color: blue;
    --score-cell-button-bg: #CCC;
    --score-cell-button-color: #000;
    --score-cell-button-hover-bg: #DDD;
    --score-cell-span-hover-bg: #FFA;
    --help-message-color: #222;
    --next-help-message-color: #333;
    --next-help-message-bg: #F1F1F1;
    --next-help-message-hover-color: #CCC;
    --center-cell-color: #000;
    --modal-bg: #FFF;
    --modal-color: #000;
    --modal-shadow: #000;
    --btn-settings-close-bg: lightgray;
    --modal-button-bg: lightgray;
    --modal-button-hover-bg: darkgray;
    --btn-settings-bg: lightgray;
    --btn-settings-hover-bg: darkgray;
    --btn-settings-color: black;
}

html {
    font-family: "Droid Sans", sans-serif;
    background: #FFF;
    background: var(--global-bg);
    color: #000;
}

html, #board, [draggable], .tile {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;

    -moz-user-select: none;
    -khtml-user-select: none;
    -webkit-user-select: none;
    user-select: none;
}

#chat-messages, #number, #name {
    -webkit-touch-callout: default;
    -webkit-user-select: text;
    -khtml-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

#number {
    -webkit-user-select: all;
    -khtml-user-select: all;
    -moz-user-select: all;
    -ms-user-select: all;
    user-select: all;
}

#chat-messages .error {
    color: #F66;
}

#chat-messages .ok {
    color: green;
}

#clear-game, #clear-rack {
    white-space:pre-wrap;
}

[draggable] {
    /* Required to make elements draggable in old WebKit */
    -khtml-user-drag: element;
    -webkit-user-drag: element;
}

#help-message {
    font-size:small
}

#board td {
    text-transform:uppercase;
    border:1px solid #220;
    border:1px solid var(--board-td-border);
    background:#FFC;
    background:var(--board-tile-bg);
    color: black;
    color: var(--board-tile-color);
    vertical-align:middle;
    text-align:center;
}

#board td .tile-placeholder {
    position: relative;
    height: 100%;
    width: 100%;
    top: 0px;
    left: 0px;
    display: -webkit-flex;
    -webkit-justify-content: center;
    -webkit-flex-direction: column;
    display: flex;
    justify-content: center;
    flex-direction: column;
}

#board th {
    font-size:small;
    color:gray;
    font-weight:normal
}

.corner {
    visibility:hidden;
    border:none !important
}

.special-cell-tripleWord {
    background:#F77 !important;
    background: var(--tripleWord-bg) !important;
    box-shadow: 0 0 1px #F77;
}

.special-cell-tripleLetter {
    background:#77F !important;
    background: var(--tripleLetter-bg) !important;
    box-shadow: 0 0 1px #77F;
}

.special-cell-doubleLetter {
    background:#7CF !important;
    background: var(--doubleLetter-bg) !important;
    box-shadow: 0 0 1px #7CF;
}

.special-cell-doubleWord {
    background:#FBB !important;
    background: var(--doubleWord-bg) !important;
    box-shadow: 0 0 1px #FBB;
}

.special-cell-label {
    display:inline-block;
    white-space:pre-wrap;
    font-size:7px;
    overflow:hidden;
}

.special-cell-label-clip .special-cell-label {
    text-overflow:clip;
}

.special-cell-label-dots .special-cell-label {
    text-overflow:ellipsis;
}

.special-cell-label-none .special-cell-label {
    visibility:hidden;
}

.special-cell-label-short .special-cell-label {
    display:inline;
}

#center-cell .special-cell-label {
    font-weight:bold;
    color:#000;
    color:var(--center-cell-color);
    font-size:large
}

body {
    margin:0;
    padding:0;
    display:-webkit-flex;
    display:flex;
    -webkit-flex-direction:row;
    flex-direction:row;
    justify-content:safe center;
}

#menu, #panel {
    color: #000;
    color: var(--menu-color);
    display:-webkit-flex;
    display:flex;
    -webkit-flex-direction:column;
    flex-direction:column;
    width:15em;
}

#content {
    /* This is important for the auto zoom feature, it allows #content not to take the whole height */
    align-self: baseline;
}

button, select {
    border-radius: 2px;
}

.panel button, select {
    margin: 0.25em 0;
    min-height:2em;
    background: #CFC;
    background: var(--menu-button-bg);
    border: 1px solid #8C8;
    border: 1px solid var(--menu-button-border);
    cursor: pointer;
    transition: 0.2s;
    color: black;
    color: var(--menu-button-color);
}

.panel button:hover, select:hover {
    background: #FD7;
    background: var(--menu-button-hover-border);
    border: 1px solid #CA5;
    border: 1px solid var(--menu-button-hover-bg);
}

.panel button[disabled=disabled], .panel button:disabled {
    background:#AFA;
    cursor:not-allowed;
}

#rack {
    background:#EEC;
    background:var(--rack-bg);

    z-index:10;
    font-size:0;
    border-radius:4px;
    display:inline-block;
    padding:2px 5px;
    white-space:pre;
    box-shadow:0 0 2px gray
}

#board td {
    width:32px;
    height:32px;
    max-width:32px;
    max-height:32px;
}

#rack .tile-placeholder {
    height:32px;
    width: 32px;
}

.tile {
    background-color: #EE8;
    background-color: var(--tile-bg);
    color: #000;
    color: var(--tile-color);
    transition:background-color 1s, border 1s;
    display: inline-block;
    width: 95%;
    height: 95%;
    left: 2.5%;
    top: 2.5%;
    position: absolute;
    border: 1px solid #AA5;
    box-sizing: border-box;
    text-align: center;
    font-size:1rem;
    cursor:pointer
}

.tile.tile-spelling-ok {
    background-color: #3E3;
}

.tile.tile-spelling-nok {
    background-color: #E33;
}

.tile.tile-highlight {
    background-color: #FFF;
    font-weight: bold;
    animation: highlight 4s ease-in;
    border: 1px solid black;
}

@keyframes highlight {
    0% {
        background:red;
        color:white;
    }

    100% {
        background:white
    }
}

.flash-light-highlighting .tile {
    transition:none;
}

.flash-light-highlight {
    background-color: #ee6633;
    background-color: var(--flash-light-color);
}

.flash-light-highlight .tile:not(.tile-highlight) {
    background-color: inherit;
}

.tile-score {
    font-size: 0.5em;
    position: absolute;
    bottom: 0px;
    right: 2px;
}

#chat-messages .tile {
    position:relative;
    cursor:auto;
    top:0;
    left:0;
    width: 1.5em;
    height: 1.5em;
    margin:2px;
    vertical-align:bottom;
}

#chat-messages .tile-letter {
    font-size:0.9em;
}

#chat-messages .tile-score {
    font-size: 0.4em;
}

#chat-messages.blink {
    animation:chat-blink 1s
}

#chat-messages .info {
    color:gray;
    font-style:italic;
}

td.blink {
    animation:td-blink 1s
}

.current-player {
    font-weight:bold;
}

.current-player td:first-child:before {
    position:absolute;
    left:-1em;
    color:red;
    content: "→";
}

@keyframes chat-blink {
    0% {
        background:rgba(255, 255, 150, 0);
    }

    50% {
        background:rgba(255, 255, 150, 1);
    }

    100% {
        background:rgba(255, 255, 150, 0);
    }
}


@keyframes td-blink {
    0% {
        background:rgba(100, 200, 255, 0);
    }

    50% {
        background:rgba(100, 200, 255, 1);
    }

    100% {
        background:rgba(100, 200, 255, 0);
    }
}



.tile-target {
    background:rgba(255,255,255, 0.9);
/* } */

/* #bag.tile-target, td .tile-target { */
    outline: 1px solid #F33
}

#rack .tile-placeholder {
    position:relative;
    margin-left:1px;
    margin-right:1px;
    display:inline-block;
    vertical-align:middle;
    background:#CCA;
    background:var(--rack-tile-bg);
    color: #000;
    color: var(--rack-tile-color);
}

#panel {
    /* -webkit-justify-content:center; does not look good */
    text-align:center;
    padding-right:3px;
}

#menu {
    padding-left:3px;
}

#bag, #rack-outer {
    -webkit-align-self:center;
    align-self:center;
    text-align:center;
}

#rack-outer {
    padding-bottom: 3px;
}

#p-name, #p-number {
    word-break: break-word;
    margin:0;
    text-align:center;
    font-size:small
}

#p-number {
    margin-top:1ex;
}

.panel .minibutton {
    padding:0.25ex 0.5ex;
    min-height:0;
    font-size:small
}

.msg-sender {
    color:blue;
    color: var(--msg-sender-color):
}

#chat-messages {
    overflow:auto
}

#bag {
    width:165px;
    height:160px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin-top:3px;
    margin-bottom:1ex;
}

#bag > #tile-count {
    color:white;
    background: black;
    display:block;
    border-radius: 100px;
    padding:3rem;
    font-size: 42px;
}

#bag:hover {
    cursor:pointer;
    opacity:0.8
}

#bag > svg {
    width: 100%;
    height: 100%;
}

#chat-messages {
    border:1px solid silver;
    border:1px solid var(--chat-border);
    box-sizing:border-box;
    width: 100%;
    margin-bottom:1px;
    height:15em;
}

#chat-ta {
    width:100%;
    box-sizing:border-box;
    height:3em
}

#participants {
    font-size:small;
    border-collapse:collapse;
    margin:0 auto 1ex auto;
}

#participants td {
    word-break:break-word;
}

#participants th, #participants td {
    border:1px solid gray;
    padding:0.33ex 0.5ex;
}

#participants .score-cell > span {
    display:inline-block;
    min-width:2.5em;
}

#participants .score-cell > span:hover, #participants .turn-cell button:hover {
    cursor:pointer;
    background:#FFA;
    background:var(--score-cell-span-hover-bg);
}

#participants .score-cell button {
    min-height:4ex; /* for old webkit */
    min-height: auto;
    font-size:x-small;
    padding:0 1ex;
    margin:0;
    background:#CCC;
    background:var(--score-cell-button-bg);
    color:back;
    color:var(--score-cell-button-color);
    border:0;
}

#participants .score-cell button:hover {
    background:#DDD;
    background:var(--score-cell-button-hover-bg);
}

#participants th {
    font-weight:normal;
    background:#EEE;
    background:var(--participants-th-bg);
    color: black;
    color: var(--participants-th-color);
    font-size:smaller
}

#participants-placeholder {
    font-style:italic;
}

#participants .turn-cell button {
    padding:0 2px;
    background:white;
    min-height:1em;
    height:1em;
    margin:0;
    display:flex;
}

#participants .turn-cell img {
    width:1em;
    vertical-align: middle;
}

@media screen and (max-height:650px) {
    #board td , #rack .tile-placeholder {
        height:28px;
        width: 28px;
    }
}
@media screen and (max-height:600px) {
    #board td , #rack .tile-placeholder {
        height:24px;
        width: 24px;
    }
}

@media screen and (max-height:550px) {
    #chat-messages {
        height:7em;
    }
}

@media (max-width: 940px) {
    body {
        justify-content:start;
    }
}

#modal-settings-dialog p {
    margin:0;
    padding:0;
    font-size:small;
}

#modal-settings-dialog label span, #modal-settings-dialog label input {
    display: inline-block;
    vertical-align: middle;
}

#lang-selection {
    display:table;
}

#lang-selection p {
    display:table-row;
}

#lang-selection p:first-child select {
    margin-bottom:0.5ex;
}

#lang-selection select, #lang-selection label {
    display:table-cell;
    vertical-align:middle;
    font-size:small;
}

#lang-selection select {
    width:100%;
}

#lang-selection label {
    padding-right:0.5ex;
}

.modal {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    -webkit-transition: visibility 0s linear 0.25s, opacity 0.25s 0s;
    -webkit-transform: scale(1.1);
    transform: scale(1.1);
    transition: visibility 0s linear 0.25s, opacity 0.25s 0s, transform 0.25s;
    z-index: 1;
}

.modal-header {
    display:flex;
    flex-direction:row;
}

.modal-header h1 {
    flex:1;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    padding: 1rem 1.5rem;
    width: 24rem;
    border-radius: 0.3rem;
    background-color: #FFF;
    background-color: var(--modal-bg);
    color:#000;
    color:var(--modal-color);
    box-shadow: 0 0 20px #000;
    box-shadow: 0 0 20px var(--modal-shadow);
}

#btn-settings-close {
    font-weight: bold;
    text-align: center;
    border: 0;
}

.modal-content h1 {
    margin: 0px;
    font-weight: bold;
    font-size: large;
}

.modal-button {
    float: right;
    width: 1.5rem;
    line-height: 1.5rem;
    text-align: center;
    cursor: pointer;
    border-radius: 0.25rem;
}

.modal-button, .alert-outer button {
    background-color: lightgray;
    background-color: var(--modal-button-bg);
}

.modal-button:hover, .alert-outer button:hover {
    background-color: darkgray;
    background-color: var(--modal-button-hover-bg);
}

.show-modal {
    opacity: 1;
    visibility: visible;
    -webkit-transition: visibility 0s linear 0s, opacity 0.25s 0s;
    -webkit-transform: scale(1.0);
    transform: scale(1.0);
    transition: visibility 0s linear 0s, opacity 0.25s 0s, transform 0.25s;
}

.modal-content > div:not(:last-child) {
    margin-bottom: 1ex;
}

.span-range {
    display:block;
    text-align:center;
}

.span-range > span {
    font-size:smaller;
}

.span-range > span, .span-range > input {
    display:inline-block;
    vertical-align: middle;
}

.alert {
    z-index: 2;
}

#panel #btn-settings {
    background:lightgray;
    background:var(--btn-settings-bg);
    color:black;
    color: var(--btn-settings-color);
    font-size:small;
    border-radius:3px;
    border:none;
    margin:3px 3px 0 0;
    min-height: 2em;
    float:right
}

#panel #btn-settings:hover {
    background: darkgray;
    background:var(--btn-settings-hover-bg);
}

#panel #btn-settings-and-timer {
    text-align:right;
}


#btn-settings:before {
    content: "⚙️ "
}

#info-spell-checking, #source-code-info p {
    font-size:small;
    color:gray;
    margin: 0;
    padding: 0;
}

#info-spell-checking a {
    color:black;
}

#help-messages {
    box-sizing:border-box;
    overflow:auto;
    width: auto;
    margin-bottom:1px;
}

#help-box {
    margin-left:1ex;
    margin-top:1ex;
    display:-webkit-flex;
    -webkit-flex-direction:column;
    -webkit-justify-content:center;
    -webkit-align-items:center;
    align-items:center;
    display:flex;
    flex-direction:column;
    justify-content:center;
}

#help-box-inner {
    display:-webkit-flex;
    -webkit-flex-direction:row;
    display:flex;
    flex-direction:row;
    min-height:2em;
    border-top:1px solid gray;
    border-bottom:1px solid gray;
    -webkit-align-items:center;
    align-items:center;
}

button#next-help-msg {
    border:0;
    background:#F1F1F1;
    background:var(--next-help-message-bg);
    color:#333;
    color:var(--next-help-message-color);
    font-size:1.2rem;
    margin-right:0.5ex;
    border-radius:100rem;
    height:1.75rem;
    width:2.2rem;
    transition:500ms;
    padding:0;
}

button#next-help-msg:hover {
    background:#CCC;
    background:var(--next-help-message-hover-color);
}

#help-box-title {
    margin:0;
    padding:0 0 0.25ex 0;
    text-align:right;
    width:100%;
    color:gray;
    font-size:small;
    font-style:italic;
}

#help-messages p {
    margin:0;
    font-size:0.9;
    color:#222;
    color: var(--help-message-color);
    padding:0 0.5ex;
    max-width:17em;
}

#help-box-inner:before {
    content:"i";
    display:inline-block;
    height:1.2em;
    width:1.7em;
    font-style:italic;
    font-weight:bold;
    font-family:serif;
    color:#AAA;
    border:2px solid;
    border-radius:100rem;
}

#panel-buttons {
    display:-webkit-flex;
    -webkit-flex-direction: column;
    display:flex;
    flex-direction:column;
}

#timer {
    font-size:x-small;
    text-align:center;
    margin:0;
    margin-right:1ex;
}

#timer > span {
    white-space:nowrap;
}

#timer > span:first-child {
    color:gray;
}

#board-selection {
    display:table;
}

#board-selection > p:not([hidden]) {
    display: table-row
}

#board-selection > p > span {
    display: table-cell;
}

#board-selection > p > .label {
    padding-right:1ex;
}

#board-selection > p > .select, #board-selection > p > .select > select {
    width: 100%;
}

textarea {
    background: inherit;
    color: inherit;
    border: 1px solid gray;
}

.alert {
    position:fixed;
    top:0;
    left:0;
    right:0;
    bottom:0;
    background:rgba(0,0,0,0.5);
    display:-webkit-flex;
    display:flex;
    -webkit-flex-direction:column;
    flex-direction:column;
    -webkit-justify-content:center;
    justify-content:center;
    line-height:1.5em;
    text-align:center;
}

.alert-outer {
    background-color: white;
    background-color: var(--modal-bg);
    color: black;
    color:var(--modal-color);
    border-radius:4px;
    display:-webkit-flex;
    display:flex;
    -webkit-flex-direction:column;
    flex-direction:column;
    -webkit-align-self:center;
    align-self:center;
    text-align:center;
    box-shadow: 0 0 8px #000;
    box-shadow: 0 0 8px var(--modal-shadow);
    max-width:75%;
    padding:4px;
}

.alert.on-ipad.prompt {
    justify-content:flex-start;
    position:absolute;
}

.alert.on-ipad.prompt .alert-outer {
    margin-top:1em;
}

.alert-content-and-input {
    padding:1ex;
}

.alert input[type=text], .alert input[type=number], .alert input[type=password] {
    border-radius:none;
    box-sizing:border-box;
    min-height:1.5rem;
    outline:none;
    width:95%;
    min-width:10ex;
    margin:1ex;
    border:1px solid silver;
    border:1px solid var(--chat-border);
    background: inherit;
    color: inherit;
}

.alert input[type=text]:focus, .alert  input[type=password]:focus {
    border:1px solid #5CF;
    box-shadow:0 0 1px #5CF
}

.alert input[type=button], .alert button {
    margin:1px;
    border-radius:0;
    min-height:1.5rem;
    border:1px solid silver;
    padding:1ex 2ex;
    background:white
}

.alert input[type=button]:active, .alert button:active {
    background:#D5D5D5
}

.alert button {
    margin:0.5ex;
    border:0;
    background-color: lightgray;
    background-color: var(--modal-button-bg);
    color: black;
    text-align: center;
    border-radius: 0.25rem;
    font-weight: bold;
    cursor: pointer;
}

.alert button:hover {
    background-color: darkgray;
    background-color: var(--modal-button-hover-bg);
}

.alert-prompt-buttons {
    display: none;
}

.alert.choice .alert-prompt-buttons, .alert.prompt .alert-prompt-buttons {
    display: block;
}

.alert.choice.choice-inline .alert-content, .choice.choice-inline .alert-prompt {
    display:inline-block;
}

.alert.choice.choice-inline .alert-prompt {
    padding-left: 1ex;
}

@media (prefers-color-scheme: dark) {
    :root {
        --global-bg: black;
        --menu-color: #DDD;
        --menu-button-bg: #030;
        --menu-button-color: #EEE;
        --menu-button-border: green;
        --menu-button-hover-border: green;
        --menu-button-hover-bg: green;
        --chat-border: gray;
        --participants-th-color: #EEE;
        --participants-th-bg: #555;
        --rack-bg: #333;
        --board-td-border: #555;
        --board-tile-bg: #000;
        --board-tile-color: #BBB;
        --rack-tile-bg: #000;
        --rack-tile-color: #BBB;
        --tripleWord-bg: #700;
        --tripleLetter-bg: #234;
        --doubleWord-bg: #522;
        --doubleLetter-bg: #014;
        --tile-bg: #770;
        --tile-color: #DDD;
        --msg-sender-color: #5AC;
        --score-cell-button-bg: #555;
        --score-cell-button-color: #FFF;
        --score-cell-button-hover-bg: #999;
        --score-cell-span-hover-bg: #770;
        --help-message-color: #AAA;
        --next-help-message-bg: #333;
        --next-help-message-color: #AAA;
        --next-help-message-hover-color: #333;
        --center-cell-color: #AAA;
        --modal-bg: #000;
        --modal-color: #DDD;
        --modal-shadow: #AAA;
        --modal-button-bg: #AAA;
        --modal-button-hover-bg: #FFF;
        --btn-settings-bg: #555;
        --btn-settings-hover-bg: #777;
        --btn-settings-color: #CCC;
    }

    #bag {
        filter: invert(30%);
    }
}
