:root {
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--text);
  background: var(--background);
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button:disabled {
  opacity: 0.35;
  cursor: default;
}
button:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid var(--selection);
  outline-offset: 3px;
}
a {
  color: var(--accent);
}
h1,
h2,
.brand {
  font-family: Georgia, serif;
  font-weight: 400;
}
h1 {
  font-size: 36px;
  margin: 0 0 10px;
}
h2 {
  font-size: 25px;
  margin: 0 0 10px;
}
p {
  line-height: 1.65;
}
.muted,
.subtitle {
  color: var(--muted);
}
.home-header {
  max-width: 1200px;
  margin: auto;
  padding: 18px 28px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 30px;
  letter-spacing: -1px;
  white-space: nowrap;
}
.brand img {
  width: 34px;
  height: 34px;
}
.languages {
  display: flex;
  gap: 3px;
}
.language {
  border: 0;
  background: transparent;
  font-size: 12px;
  border-radius: 8px;
  min-width: 36px;
  height: 44px;
}
.language[aria-pressed="true"] {
  background: var(--selected);
  color: var(--accent);
  font-weight: 700;
}
.home-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  grid-column: 1/-1;
  justify-content: flex-end;
}
.theme-picker > span {
  display: none;
}
.theme-picker select {
  height: 44px;
  min-width: 140px;
}
.icon-button {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  flex-shrink: 0;
}
.icon-button:hover {
  background: var(--hover);
}
.icon-button svg {
  width: 21px;
  height: 21px;
}
.home-main {
  max-width: 1100px;
  margin: auto;
  padding: 42px 28px 20px;
}
.subtitle {
  margin: 0 0 30px;
  font-size: 16px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}
.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: var(--surface);
}
.card-art {
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(
    ellipse at center,
    var(--selected),
    var(--background)
  );
}
.card-art svg {
  width: 170px;
  max-width: 100%;
}
.card-body {
  padding: 22px 20px 8px;
}
.card-body .muted {
  font-size: 14px;
  margin: 0 0 18px;
}
.puzzle-list {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
}
.puzzle-choice {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--background);
  font-size: 13px;
  padding: 0;
}
.puzzle-choice:hover {
  background: var(--selected);
  border-color: var(--accent);
}
.collection {
  font-size: 12px;
  color: var(--muted);
  margin-top: 18px;
}
.resume {
  margin-bottom: 24px;
}
.home-hint {
  max-width: 690px;
  margin: 30px auto 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.home-hint p {
  margin-bottom: 12px;
}
.home-footer {
  font: italic 12px Georgia, serif;
  color: var(--muted);
  opacity: 0.65;
  text-align: center;
  flex-shrink: 0;
  margin: 0 12px max(4px, env(safe-area-inset-bottom));
}
.home-footer a {
  color: inherit;
  text-underline-offset: 3px;
  margin-left: 5px;
  display: inline-block;
  padding: 8px 0;
}
.home-footer a:hover {
  color: var(--text);
}
.game {
  touch-action: none;
  height: 100dvh;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.game-toolbar {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 10px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.game-title {
  font-size: 14px;
  color: var(--muted);
}
.game-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.game-area {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.board-wrap {
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.board {
  height: 100%;
  width: auto;
  max-width: 100%;
  max-height: 760px;
  aspect-ratio: 1;
  background: var(--board);
  border: 1px solid var(--board-edge);
  border-radius: 18px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
/* SVG edge targets need the same native tap-highlight suppression as buttons. */
.board,
.board * {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
.clue {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.37px;
  fill: var(--text);
  pointer-events: none;
  transition: fill 0.12s;
}
.clue.matched {
  fill: var(--accent);
}
.clue.error,
.dot.error {
  fill: var(--danger);
}
.edge-line {
  stroke: var(--board-edge);
  stroke-width: 0.018;
  opacity: 0.5;
  /* One short guide per edge: no continuous lattice at intersections. */
  stroke-dasharray: 0.72 1;
  stroke-dashoffset: -0.14;
  stroke-linecap: round;
  pointer-events: none;
}
.edge-cross {
  stroke: var(--muted);
  stroke-width: 0.035;
  fill: none;
  display: none;
  pointer-events: none;
}
.edge-halo {
  stroke: var(--accent);
  stroke-linecap: round;
  pointer-events: none;
  opacity: 0;
}
.edge-ink {
  stroke: var(--accent);
  stroke-width: 0.065;
  stroke-linecap: round;
  pointer-events: none;
  opacity: 0;
}
.edge[data-state="1"] .edge-ink {
  opacity: 1;
}
.edge[data-state="2"] .edge-cross {
  display: block;
}
.edge[data-state="2"] .edge-line {
  opacity: 0.35;
}
.hit {
  fill: transparent;
  cursor: pointer;
  rx: 0.07;
}
.edge:focus {
  outline: none;
}
.edge:focus-visible .hit {
  fill: var(--selection);
  fill-opacity: 0.22;
  stroke: var(--selection);
  stroke-width: 0.025;
}
/* Avoid high-contrast spots at every junction, including on the loop. */
.dot {
  fill: none;
  pointer-events: none;
}
.dot.error {
  fill: var(--danger);
}
.game-bottom {
  padding: 4px 12px max(12px, env(safe-area-inset-bottom));
  text-align: center;
  flex-shrink: 0;
}
.modes {
  display: flex;
  justify-content: center;
  gap: 6px;
}
.mode {
  min-width: 100px;
  font-size: 14px;
}
.mode[aria-pressed="true"] {
  background: var(--selected);
  border-color: var(--accent);
  color: var(--accent);
}
.progress {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}
dialog {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px;
  max-width: min(560px, calc(100vw - 28px));
  max-height: 85dvh;
}
dialog::backdrop {
  background: var(--overlay);
  backdrop-filter: blur(3px);
}
.dialog-copy {
  color: var(--muted);
  line-height: 1.7;
}
.dialog-close {
  float: right;
  margin: -15px -15px 8px 12px;
}
.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  flex-wrap: wrap;
}
.setting {
  display: flex;
  gap: 12px;
  align-items: center;
  line-height: 1.6;
}
.setting input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(520px, 90vw);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 20px;
  box-shadow: 0 5px 30px #0004;
  opacity: 0;
  pointer-events: none;
  font-size: 14px;
  z-index: 10;
}
.toast.visible {
  opacity: 1;
}
.update-banner {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: var(--selected);
  font-size: 13px;
  flex-shrink: 0;
}
@media (min-width: 850px) {
  .home-header {
    grid-template-columns: 1fr auto auto auto;
  }
  .home-tools {
    grid-column: auto;
    grid-row: 1;
    grid-column: 2;
  }
  .languages {
    grid-column: 3;
  }
  .home-header > .icon-button {
    grid-column: 4;
  }
  .home-main {
    padding-top: 48px;
  }
}
@media (max-width: 700px) {
  .home-header {
    padding: 12px 16px;
    gap: 8px;
  }
  .brand {
    font-size: clamp(20px, 6vw, 26px);
  }
  .brand img {
    width: 30px;
    height: 30px;
  }
  .language {
    min-width: 30px;
  }
  .home-tools {
    justify-content: stretch;
  }
  .home-tools > .button {
    flex: 1;
  }
  .home-tools .theme-picker {
    flex: 1;
  }
  .theme-picker select {
    width: 100%;
    min-width: 115px;
  }
  .home-main {
    padding: 28px 16px 12px;
  }
  h1 {
    font-size: 30px;
  }
  .cards {
    gap: 14px;
    grid-template-columns: 1fr;
  }
  .card {
    display: block;
  }
  .card-art {
    height: 180px;
  }
  .card-art svg {
    width: 170px;
    max-width: 100%;
  }
  .card-body {
    padding: 18px 14px 0;
  }
  .card h2 {
    font-size: 23px;
  }
  .card-body .muted {
    margin-bottom: 12px;
  }
  .collection {
    margin: 10px 0 14px;
  }
  .home-hint {
    margin-top: 22px;
  }
  .game-toolbar {
    gap: 8px;
    padding: 7px 10px;
  }
  .game-actions {
    gap: 4px;
  }
  .game-title {
    font-size: 12px;
  }
  .game-area {
    padding: 8px 4px;
  }
  .board {
    border-radius: 12px;
  }
  .game-bottom {
    padding-bottom: 10px;
  }
  .mode {
    min-width: 90px;
    padding: 10px 15px;
  }
}
@media (max-width: 370px) {
  .brand {
    font-size: 20px;
    gap: 6px;
  }
  .brand img { width: 26px; height: 26px; }
  .languages { gap: 1px; }
  .home-header {
    padding: 10px;
  }
  .language {
    min-width: 25px;
  }
  .game-toolbar .icon-button {
    width: 39px;
    height: 42px;
  }
  .game-title {
    max-width: 66px;
  }
}
@media (max-height: 500px) and (orientation: landscape) {
  .game-toolbar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 68px;
    flex-direction: column;
    border: 0;
    padding: 8px;
  }
  .game-actions {
    margin: 0;
    flex-direction: column;
    gap: 4px;
  }
  .game-title {
    display: none;
  }
  .game-area {
    padding: 8px 130px 8px 75px;
  }
  .game-bottom {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 115px;
  }
  .modes {
    flex-direction: column;
  }
  .mode {
    min-width: 0;
  }
  .progress {
    font-size: 11px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

.edge[aria-disabled="true"] .hit {
  cursor: default;
}
