@import url("https://fonts.googleapis.com/css2?family=Libre+Franklin:wght@400;600;700&display=swap");

:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --bg-accent: #f0e6d6;
  --ink: #1d1b16;
  --muted: #5b544b;
  --panel: #ffffff;
  --accent: #c45f2a;
  --accent-dark: #8f3f1b;
  --line: #e5d9c8;
  --yellow: #f5df7b;
  --green: #b6d98a;
  --blue: #8ab4ff;
  --purple: #c7a7f4;
  --shadow: 0 24px 50px rgba(29, 27, 22, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "interstate-mono", monospace;
  font-size: 100%;
  font-weight: 300;
  background:
    radial-gradient(circle at top left, #fff5e6 0%, var(--bg) 40%),
    repeating-linear-gradient(45deg, rgba(196, 95, 42, 0.08) 0 6px, rgba(255, 255, 255, 0) 6px 12px);
}

.tcb-flags {
  text-align: center;
  margin: 1em auto 0.25em;
  display: flex;
  justify-content: center;
}

.flag {
  width: 8px;
  height: 8px;
  display: inline-block;
  position: relative;
  overflow: hidden;
  padding: 4px;
  margin: 2px;
  border: 1px solid #eee;
}

.flag::before,
.flag::after {
  content: "";
  position: absolute;
  inset: 0;
}

.c {
  background: #152536;
}

.c::before {
  top: 20%;
  bottom: 20%;
  background: #faf7f4;
}

.c::after {
  top: 40%;
  bottom: 40%;
  background: #f2916b;
}

.o {
  background: #f2916b;
}

.o::before {
  background: #ffe882;
  right: 35%;
  bottom: -100%;
  transform: rotate(-45deg);
  left: -100%;
}

.k {
  background: #ffe882;
}

.k::before {
  background: #152536;
  left: 50%;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 32px;
  display: grid;
  gap: 16px;
}

.hero {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 6px;
}

h1 {
  margin: 0;
  font-family: "matrix-ii-ext-semi-narrow", serif;
  font-size: 3rem;
  font-weight: 500;
  line-height: 1.1;
}

.subhead {
  max-width: 760px;
  margin: 0;
  font-size: 13px;
  font-weight: 400;
  color: #726969;
}

.manual,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.manual {
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.hint-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.hint-pill {
  display: inline-block;
  padding: 6px 10px;
  border: 1px solid #d9cab5;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  color: #6e6254;
  font-size: 11px;
  letter-spacing: 0.1px;
}

button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 12px;
  font-family: "interstate-mono", monospace;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-dark);
}

.ghost {
  background: #fff;
  border-color: #cab9a2;
  color: var(--ink);
}

.ghost:hover {
  background: #faf7f2;
}

textarea {
  width: 100%;
  border: 1px solid #d9cdbd;
  border-radius: 10px;
  padding: 10px;
  resize: vertical;
  font-family: "interstate-mono", monospace;
  font-size: 13px;
}

label {
  color: var(--muted);
  font-size: 12px;
}

.board {
  display: grid;
  gap: 14px;
}

.panel {
  padding: 12px;
  position: relative;
}

.panel h2 {
  margin: 0 0 10px;
  font-family: "interstate-mono", monospace;
  text-transform: uppercase;
  font-size: 14px;
  font-weight: 700;
  color: #726969;
}

.tiles {
  min-height: 68px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  align-content: start;
}

.dropzone:empty::before {
  content: "Drop words here";
  color: #9f9689;
  font-size: 11px;
  letter-spacing: 0.1px;
  align-self: center;
}

.tile {
  width: 100%;
  border: 1px solid #d6c8b8;
  background: #fffdf9;
  color: var(--ink);
  border-radius: 8px;
  min-height: 44px;
  display: grid;
  place-items: center;
  text-align: center;
  font-family: "Libre Franklin", system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: grab;
  padding: 6px;
  user-select: none;
}

.tile:active {
  cursor: grabbing;
}

.tile.selected {
  border-color: var(--accent);
  box-shadow: 0 8px 18px rgba(196, 95, 42, 0.2);
}

.tile.dragging {
  opacity: 0.45;
}

.tile.insert-before,
.tile.insert-after {
  position: relative;
}

.tile.insert-before {
  transform: translateX(2px);
}

.tile.insert-after {
  transform: translateX(-2px);
}

.tile.insert-before::before,
.tile.insert-after::after {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.tile.insert-before::before {
  left: -6px;
}

.tile.insert-after::after {
  right: -6px;
}

.dropzone.active {
  outline: 2px dashed var(--accent);
  outline-offset: 3px;
}

.groups {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.group.yellow {
  background: color-mix(in oklab, var(--yellow) 28%, white);
}

.group.green {
  background: color-mix(in oklab, var(--green) 28%, white);
}

.group.blue {
  background: color-mix(in oklab, var(--blue) 28%, white);
}

.group.purple {
  background: color-mix(in oklab, var(--purple) 28%, white);
}

.pool-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

#status {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-family: "interstate-mono", monospace;
  font-weight: 400;
}

.manual {
  margin-top: 4px;
}

.manual summary {
  list-style: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  user-select: none;
}

.manual summary::-webkit-details-marker {
  display: none;
}

.manual summary::before {
  content: "+ ";
  font-weight: 700;
}

.manual[open] summary::before {
  content: "- ";
}

.manual-body {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.manual-help {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.manual-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 780px) {
  h1 {
    font-size: 2.5rem;
  }

  .groups {
    grid-template-columns: 1fr;
  }

  .hint-bar {
    justify-content: flex-start;
  }
}
