:root {
  color-scheme: dark;
  --bg: #2a5060;
  --soft: #24414e;
  --field: #1f3842;
  --ink: #f1f3e8;
  --mute: #c3d3cf;
  --line: #46707f;
  --edge: #8fb0b6;
  --ok: #a9e2b9;
  --okbg: #1f4a43;
  --bad: #ffb9ae;
  --focus: #f0b35a;
  --acc: #e0a03f;
  --accink: #1b2a30;
}

html {
  font-size: clamp(16px, calc(12px + .42vw), 22px);
}

* {
  box-sizing: border-box;
  border-radius: 0;
}

body,
button,
input {
  font-family: Lexend, sans-serif;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 350;
  line-height: 1.6;
}

main {
  max-width: 1640px;
  margin: auto;
  padding: 2rem clamp(20px, 3vw, 56px) 4rem;
}

#start {
  max-width: 46rem;
}

.flavor,
.help {
  max-width: 60rem;
}

h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.02em;
  text-wrap: balance;
}

h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

p {
  margin: 0 0 16px;
}

.help {
  color: var(--mute);
  font-size: 1rem;
}

.flavor p {
  white-space: pre-line;
}

a {
  color: inherit;
}

nav {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  margin: 1.25rem 0 1.75rem;
  border-bottom: 1px solid var(--line);
}

button {
  font-size: 1rem;
  font-weight: inherit;
  border: 1px solid var(--edge);
  background: var(--bg);
  color: var(--ink);
  padding: 10px 18px;
  cursor: pointer;
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.main {
  background: var(--acc);
  color: var(--accink);
  border-color: var(--acc);
  font-weight: 500;
}

nav button {
  border: 0;
  background: none;
  color: var(--mute);
  padding: 10px 0;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
}

nav button.on {
  color: var(--ink);
  font-weight: 500;
  border-color: var(--acc);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.q {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.q.now {
  border: 0;
  padding: 16px 0;
  font-size: 1.3rem;
  line-height: 1.5;
}

.q .num {
  color: var(--mute);
  margin-right: 8px;
}

.q img {
  display: block;
  max-width: 100%;
  max-height: min(440px, 50vh);
  margin: 16px 0;
  background: #fff;
}

form {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

form button {
  flex: none;
}

input::placeholder {
  color: var(--mute);
  opacity: 1;
}

input {
  font-size: 1rem;
  font-weight: inherit;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--edge);
  padding: 10px 14px;
  min-width: 0;
  width: 100%;
}

.ok {
  color: var(--ok);
  font-weight: 500;
}

.bad {
  color: var(--bad);
}

.msg {
  min-height: 1.6em;
  margin: 10px 0;
  font-size: 1rem;
}

.bins {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin: 16px 0 24px;
}

.bin {
  background: var(--soft);
  border: 2px solid transparent;
  padding: 16px;
  min-height: 150px;
}

.bins {
  align-items: stretch;
}

.bin.over {
  border-color: var(--ink);
}

.bin small {
  display: block;
  color: var(--mute);
  font-size: .95rem;
}

.chip {
  display: block;
  width: 100%;
  text-align: left;
  margin: 8px 0 0;
  padding: 9px 12px;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.chip {
  cursor: grab;
  border-color: var(--line);
}

.bin[data-c="0"] .list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.bin[data-c="0"] .list > * {
  width: auto;
  margin: 0;
}

.scroll {
  overflow-x: auto;
  margin: 24px 0;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 1rem;
}

th,
td {
  padding: 4px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  font-weight: 400;
  color: var(--mute);
}

th:first-child,
td:first-child {
  padding-left: 0;
}

td input {
  border-color: transparent;
  background: var(--soft);
  padding: 7px 10px;
  font-size: 1rem;
}

td.c {
  font-weight: 500;
}

td.s input {
  text-align: center;
}

tr.h td {
  font-weight: 600;
  padding: 26px 0 8px;
}

.q.now {
  padding: 1.5rem;
  border: 2px solid transparent;
  background: var(--soft);
}

.q.now.right {
  background: var(--okbg);
  border-color: var(--ok);
}

.past {
  padding: 14px 0;
}

.q.now.right input {
  border-color: var(--ok);
}

input.wrong {
  border-color: var(--bad);
  animation: shake .3s;
}

.bin.wrong {
  border-color: var(--bad);
}

.final.right input {
  border-color: var(--ok);
  background: var(--okbg);
}

.fade {
  animation: fade 1.5s ease-out both;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes shake {
  25% {
    transform: translateX(-5px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

.final {
  margin-top: 1.5rem;
  max-width: 46rem;
}

#start {
  margin-top: 28px;
}

.msg.big.ok {
  color: var(--ok);
}

.msg.big {
  overflow-wrap: anywhere;
  color: #ff9a3c;
  font-size: clamp(1.75rem, 6vw, 2.5rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -.02em;
  margin: 20px 0;
}

dialog {
  font-family: Lexend, sans-serif;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  border: 1px solid var(--line);
  padding: 32px;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

dialog::backdrop {
  background: #000a;
}

dialog h2 {
  font-size: 1.75rem;
  line-height: 1.2;
  margin: 0 0 16px;
  overflow-wrap: anywhere;
}

dialog button {
  margin-top: 8px;
}

#wimg {
  display: block;
  width: 100%;
  height: auto;
}

#wlink {
  display: block;
  margin: 0 0 20px;
}

dialog[open] {
  animation: fade .5s ease-out;
}

details {
  margin-top: 40px;
}

summary::-webkit-details-marker {
  display: none;
}

summary::before {
  content: '+ ';
}

details[open] > summary::before {
  content: '- ';
}

summary {
  list-style: none;
  cursor: pointer;
  color: var(--mute);
  margin-bottom: 14px;
}

footer {
  margin-top: 72px;
}

footer button {
  border: 0;
  padding: 0;
  background: none;
  color: var(--mute);
  font-size: .95rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.c1 {
  --cat: #ff0dbe;
  --on: #161616;
  --tint: #ff94d3;
}

.c2 {
  --cat: #4a4a4a;
  --on: #fff;
  --tint: #b8b8b8;
}

.c3 {
  --cat: #f55928;
  --on: #161616;
  --tint: #ffb08f;
}

.c4 {
  --cat: #2f8bff;
  --on: #161616;
  --tint: #9cc9ff;
}

.bins h2 {
  margin: -16px -16px 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.bin.done {
  background: var(--tint);
  color: #161616;
  padding: 0;
  border: 0;
  overflow: hidden;
  min-height: 0;
}

.bin.done h2 {
  margin: 0;
  background: var(--cat);
  color: var(--on);
  border: 0;
  padding: 10px 14px;
}

.bin.done small {
  color: #161616;
  padding: 8px 14px;
}

.bin.done small:empty {
  display: none;
}

.bin.fresh {
  animation: tint 1.2s ease-out;
}

.bin.fresh h2 {
  animation: band 1.2s ease-out;
}

@keyframes tint {
  from {
    background: var(--soft);
    color: var(--ink);
  }
}

@keyframes band {
  from {
    background: var(--soft);
    color: var(--ink);
  }
}

.row {
  padding: 10px 14px;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
  border-bottom: 1px solid var(--cat);
}

.menu {
  position: absolute;
  z-index: 5;
  width: 260px;
  max-width: calc(100vw - 24px);
  background: var(--bg);
  border: 1px solid var(--edge);
  padding: 6px;
}

.menu button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  border: 0;
  text-align: left;
  padding: 8px 10px;
}

.menu button:hover,
.menu button:focus-visible {
  background: var(--soft);
}

table {
  border-collapse: separate;
  border-spacing: 0;
}

tr.gap td {
  height: 24px;
  padding: 0;
  border: 0;
}

tr.h td,
tr.h td:first-child {
  background: var(--cat);
  color: var(--on);
  padding: 10px 14px;
  border: 0;
}

tr.r td {
  background: var(--tint);
  color: #161616;
  border-bottom: 1px solid var(--cat);
}

tr.r td:first-child {
  padding-left: 14px;
}

tr.r input {
  background: #fff;
  color: #161616;
}

table {
  table-layout: fixed;
}

tr.r td {
  overflow-wrap: anywhere;
  line-height: 1.35;
  padding-top: 6px;
  padding-bottom: 6px;
}

td.b {
  font-size: .95rem;
}

td.l {
  text-align: center;
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1 !important;
}

td.s input {
  display: block;
  max-width: 96px;
  margin: auto;
}

.k1 {
  width: 42%;
}

.k2 {
  width: 22%;
}

.k3 {
  width: 16%;
}

.k4 {
  width: 20%;
}

@media (max-width: 600px) {
  .k1 {
    width: auto;
  }
  .k2 {
    width: 92px;
  }
  .k3 {
    width: 56px;
  }
  .k4 {
    width: 50px;
  }
  tr.r td {
    padding-left: 4px;
    padding-right: 4px;
  }
  tr.r td:first-child {
    padding-left: 10px;
  }
  td.s input {
    padding: 7px 2px;
  }
}

details {
  margin-top: 1.5rem !important;
}

.cards {
  display: grid;
  gap: 1.25rem;
  margin: 1.25rem 0;
}

.cards table {
  margin: 0;
}

#sort .bin[data-c="0"] {
  min-height: 0;
}

@media (min-width: 1000px) {
  #solve:not([hidden]),
  .top {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    gap: 1.25rem 2.5rem;
    align-items: start;
  }
  .q.now {
    font-size: 1.45rem;
  }
  .cards {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .cards .k1 {
    width: auto;
  }
  .cards .k2 {
    width: 7.5rem;
  }
  .cards .k3 {
    width: 6rem;
  }
  .cards .k4 {
    width: 4rem;
  }
  #sheet:not([hidden]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0 1.25rem;
    align-items: start;
  }
  #sheet .cards {
    grid-column: 1/-1;
    grid-row: 2;
  }
  #sheet .final {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
    max-width: none;
  }
  #sheet .final form {
    margin-top: 0;
  }
}

.top:has(>.bin[hidden]) {
  grid-template-columns: 1fr !important;
}

@media (max-width: 600px) {
  td.b {
    font-size: .875rem;
  }
}

header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

header img {
  width: 5rem;
  height: 5rem;
  flex: none;
}

body.intro header {
  flex-direction: column;
  align-items: flex-start;
}

body.intro header img {
  width: min(300px, 100%);
  height: auto;
}
