:root {
    --body-bc: #e8ffff;
    --body-fc: black;
    --shadow: lightgray;
    --border-color: #555b6e;
    --box-bc: #F7FFF7;
    --box-fc: black;
    --forbidden-box-bc: #FFEE99;
    --same-value-box-bc: #ffbc25;
    --placeholder-fc: var(--grid-color);
    --clue-bc: #60D2CB;
    --forbidden-clue-bc: var(--clue-bc);
    --same-value-clue-bc: #24737F;
    --clue-fc: var(--box-bc);
    --forbidden-clue-fc: var(--forbidden-box-bc);
    --same-value-clue-fc: var(--forbidden-box-bc);
    --tool-fc: var(--clue-fc);
    --tool-bc: var(--clue-bc);
    --selected-tool-bc: var(--same-value-clue-bc);
    --selected-tool-fc: var(--same-value-clue-fc);
    --tool-hover-bc: #80DBD5;
    --selected-tool-hover-bc: #319EAF;
}

@media (prefers-color-scheme: dark) {
     :root {
        --body-bc: #1c1c1e;
        --body-fc: #fefefe;
        --shadow: darkgray;
        --border-color: #292929;
        --box-bc: #0C151D;
        --box-fc: #bfcbce;
        --forbidden-box-bc: #004E52;
        --same-value-box-bc: #09BC8A;
        --placeholder-fc: var(--grid-color);
        --clue-bc: #508991;
        --forbidden-clue-bc: var(--clue-bc);
        --same-value-clue-bc: #75DDDD;
        --clue-fc: var(--box-bc);
        --forbidden-clue-fc: var(--forbidden-box-bc);
        --same-value-clue-fc: var(--forbidden-box-bc);
        --tool-fc: var(--clue-fc);
        --tool-bc: var(--clue-bc);
        --selected-tool-bc: var(--same-value-clue-bc);
        --selected-tool-fc: var(--same-value-clue-fc);
        --tool-hover-bc: #61A0A8;
        --selected-tool-hover-bc: #9DE7E7;
    }
}

body {
    font-family: sans-serif;
    width: min-content;
    margin: auto;
    background: var(--body-bc);
    color: var(--body-fc)
}

h1 {
    text-align: center;
    font-weight: 50;
    margin: 2rem;
    text-transform: uppercase;
    letter-spacing: 1rem;
    text-indent: 1rem;
    text-shadow: .1rem .1rem var(--shadow);
}

section,
div,
footer {
    align-items: center;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin: 1rem 0;
}

div {
    display: flex;
    flex-wrap: wrap;
    row-gap: 0.5rem;
    column-gap: 0.3rem;
    margin: 0.5rem auto;
}

.grid {
    border-spacing: 0;
    margin: auto;
    cursor: url(img/ink-pen.svg) 2 22, text;
    border-collapse: collapse;
}

.grid td,
tr {
    padding: 0;
}

.grid tr:nth-child(3n+1) td {
    border-top: 2px solid var(--border-color);
}

.grid tr:nth-child(3n+2) td {
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.grid tr:nth-child(3n) td {
    border-bottom: 2px solid var(--border-color);
}

.grid td:nth-child(3n+1) {
    border-left: 2px solid var(--border-color);
}

.grid td:nth-child(3n+2) {
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

.grid td:nth-child(3n+3) {
    border-right: 2px solid var(--border-color);
}

.grid input {
    width: 2.5rem;
    height: 2.5rem;
    border: 0;
    border-radius: 0;
    padding: 0;
    text-align: center;
    transition: background 0.5s;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"]::-webkit-calendar-picker-indicator {
    display: none;
}

.grid input:enabled {
    font-size: 1.4rem;
    color: var(--box-fc);
    background: var(--box-bc);
    cursor: inherit;
}

.grid input.pencil,
.grid input::placeholder {
    color: #666 !important;
    font-size: 0.9rem !important;
}

.grid input:disabled {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--clue-fc);
    background: var(--clue-bc);
    cursor: default;
}

.grid input.forbidden:enabled {
    background: var(--forbidden-box-bc);
    cursor: not-allowed;
}

.grid input.same-value:enabled {
    background: var(--same-value-box-bc);
    cursor: not-allowed !important;
}

.grid input.forbidden:disabled {
    color: var(--forbidden-clue-fc);
    background: var(--forbidden-clue-bc) !important;
    cursor: not-allowed;
}

.grid input.same-value:disabled {
    color: var(--same-value-clue-fc) !important;
    background: var(--same-value-clue-bc) !important;
}

.grid input.one-candidate {
    cursor: help !important;
}

.tools div {
    justify-content: space-between;
}

.tools button,
.tools input+label {
    color: var(--tool-fc);
    background: var(--clue-bc);
    border: 1px outset var(--clue-bc);
    font-size: 1.3rem;
    font-weight: bold;
    min-width: 20px;
    padding: 6px;
    margin: .1rem;
    cursor: pointer;
}

.tools img {
    display: block;
    width: 24px;
    height: 24px;
}

.tools input {
    position: fixed;
    opacity: 0;
    width: 0;
    pointer-events: none;
}

.tools button:enabled:checked,
.tools input:enabled:checked+label {
    border-style: inset;
}

.tools button.same-value:enabled,
.tools input:enabled:checked+label {
    background: var(--selected-tool-bc);
    color: var(--selected-tool-fc);
    border-color: var(--selected-tool-bc);
}

.tools button:enabled:hover,
.tools input:enabled:hover+label {
    background: var(--tool-hover-bc);
    border-color: var(--tool-hover-bc);
}

.tools button:enabled:checked:hover,
.tools input:enabled:checked:hover+label {
    background: var(--selected-tool-hover-bc);
    border-color: var(--selected-tool-hover-bc);
}

.tools button:disabled,
.tools input:disabled+label {
    color: #ccc;
    background: darkgrey;
    border-style: outset;
    border-color: darkgrey;
    cursor: not-allowed;
}

.tools button:disabled * {
    filter: grayscale(100%);
    opacity: 0.7;
}

.tools button.warning:hover {
    background: #ff5050;
    border-color: #ff5050;
}

.context-menu {
    display: none;
    z-index: 1000;
    position: absolute;
    overflow: hidden;
    border: 1px solid #CCC;
    white-space: nowrap;
    font-family: sans-serif;
    background: #EEE;
    color: #333;
    border-top-right-radius: 3px;
    border-bottom-left-radius: 3px;
    border-bottom-right-radius: 3px;
    padding: 0;
    margin: 0;
}

.context-menu li {
    padding: 6px 10px;
    cursor: default;
    list-style-type: none;
    transition: all .3s ease;
    font-size: 1rem;
}

.context-menu li:hover {
    background-color: #DEF;
}

.context-menu li.error {
    color: #888
}

.context-menu li.error:hover {
    background-color: #EEE;
}

a {
    text-decoration: none;
    color: var(--forbidden-clue-bc);
}

a:visited {
    color: var(--same-value-clue-bc);
}

.credits {
    font-size: 0.8rem;
    margin: 0;
}