@font-face {
  font-family: Vazir;
  src: url('../fonts/vazir.ttf') format('truetype');
  font-display: swap;
}

:root {
  --ink: #293346;
  --muted: #8991a2;
  --paper: #f7f8fc;
  --purple: #6263d9;
  --line: #e5e8f0;
  font-family: Vazir, Tahoma, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  cursor: pointer;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
.board:focus-visible {
  outline: 3px solid #8586e9;
  outline-offset: 4px;
}
button {
  color: inherit;
}
a {
  color: inherit;
  text-decoration: none;
}
.reset-button {
  align-self: flex-start;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  padding: 9px 15px;
  font-size: 12px;
  min-height: 44px;
}
.reset-button:hover {
  background: #f2f2fb;
}
.reset-button > span {
  font-family: Arial, sans-serif;
  font-size: 21px;
  color: #737d95;
}
.workspace {
  display: flex;
  min-height: 100dvh;
  max-width: 1800px;
  margin: auto;
}
.sidebar {
  flex: 0 0 294px;
  padding: 35px 32px 22px;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.words {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.word {
  --tile-ink: #596174;
  --tile-bg: #f8f9fc;
  --tile-border: #dce1e9;
  background: var(--tile-bg);
  color: var(--tile-ink);
  border: 1px solid var(--tile-border);
  border-radius: 7px;
  padding: 8px 13px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 500;
  user-select: none;
  touch-action: none;
  cursor: grab;
  white-space: nowrap;
  transition:
    box-shadow 0.15s,
    opacity 0.15s;
}
.grip {
  font-size: 13px;
  letter-spacing: -2px;
  opacity: 0.4;
  font-family: Arial, sans-serif;
  line-height: 1;
}
.word:hover {
  box-shadow: 0 3px 10px #3038540d;
  border-color: var(--tile-ink);
}
.word.placed-source {
  opacity: 0.35;
  cursor: default;
}
.word.selected {
  outline: 2px solid var(--tile-ink);
  outline-offset: 3px;
}
.board-section {
  padding: 24px 32px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.board {
  position: relative;
  flex: 1;
  min-height: 540px;
  overflow: hidden;
  border: 1px solid #dce1ed;
  border-radius: 12px;
  background-color: #fff;
  background-image:
    linear-gradient(#dfe4ee 1px, transparent 1px),
    linear-gradient(90deg, #dfe4ee 1px, transparent 1px);
  background-size: 120px 120px;
  background-position: -17px -23px;
  box-shadow: 0 3px 9px #323f6210;
}
.board.fine-grid {
  background-image:
    linear-gradient(#dfe4ee 1px, transparent 1px),
    linear-gradient(90deg, #dfe4ee 1px, transparent 1px),
    linear-gradient(#edf0f6 1px, transparent 1px),
    linear-gradient(90deg, #edf0f6 1px, transparent 1px);
  background-size:
    120px 120px,
    120px 120px,
    24px 24px,
    24px 24px;
}
.board.target {
  box-shadow: inset 0 0 0 2px #9594df;
}
.board-word {
  position: absolute;
  z-index: 2;
  box-shadow: 0 3px 5px #34415b0a;
}
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 10px 22px #34415b26;
  transform: rotate(-3deg);
  cursor: grabbing;
}
.dragging-original {
  opacity: 0.2;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
[hidden] {
  display: none !important;
}
@media (min-width: 1500px) {
  .sidebar {
    flex-basis: 330px;
    padding: 40px;
  }
  .board-section {
    padding: 28px 40px;
  }
}
@media (max-width: 800px) {
  .sidebar {
    flex-basis: 220px;
    padding: 25px 20px;
  }
  .board-section {
    padding: 18px 16px;
  }
  .word {
    padding: 8px 10px;
  }
}
@media (max-width: 560px) {
  .reset-button {
    padding: 6px 10px;
    font-size: 10px;
  }
  .workspace {
    flex-direction: column;
  }
  .sidebar {
    flex-basis: auto;
    padding: 20px 16px 12px;
    border-left: 0;
    border-bottom: 1px solid var(--line);
  }
  .words {
    gap: 5px;
  }
  .word {
    font-size: 11px;
    min-height: 44px;
    padding: 6px 8px;
    gap: 6px;
  }
  .board-section {
    padding: 12px;
  }
  .board {
    min-height: 430px;
    height: 55dvh;
    flex: auto;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* One uncategorized word pool, with color reserved for selection feedback. */
#word-list {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 10px;
  margin-bottom: 28px;
}
.board {
  touch-action: none;
  user-select: none;
}

.board-word.selected {
  background: #eeeefb;
  border-color: #7779bc;
  outline: 2px solid #8587ca;
  outline-offset: 2px;
  z-index: 3;
}
.selection-box {
  position: absolute;
  border: 1px solid #8587ca;
  background: #8587ca20;
  pointer-events: none;
  z-index: 4;
}
@media (max-width: 560px) {
  #word-list {
    gap: 7px;
    margin-bottom: 0;
  }
}

/* A fixed grid window contains words in an unbounded world. */
.board-viewport {
  position: relative;
  flex: 1;
  min-height: 540px;
  overflow: hidden;
  border-radius: 12px;
  touch-action: none;
  background: #edf0f6;
}
.board-viewport > .board {
  position: absolute;
  inset: 0;
  min-height: 0;
  height: 100%;
}
@media (max-width: 560px) {
  .board-viewport {
    min-height: 430px;
    height: 55dvh;
    flex: auto;
  }
}

.sheet-content {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  pointer-events: none;
}
.sheet-content > .board-word {
  pointer-events: auto;
}
