.ag-wordle-search {
  --ag-wordle-navy: #16324f;
  --ag-wordle-blue: #1769aa;
  --ag-wordle-sky: #f3fafe;
  --ag-wordle-green: #16866c;
  --ag-wordle-border: #c7d8e7;
  --ag-wordle-text: #293b4e;
  margin: 1.5em 0 2.2em;
  padding: clamp(1em, 3vw, 1.6em);
  border: 1px solid var(--ag-wordle-border);
  border-radius: 16px;
  background: #fff;
  color: var(--ag-wordle-text);
  box-shadow: 0 8px 22px rgb(35 65 90 / 7%);
}

.ag-wordle-search [hidden] {
  display: none !important;
}

.ag-wordle-search__title {
  margin: 0 0 0.35em;
  color: var(--ag-wordle-navy);
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  line-height: 1.4;
}

.ag-wordle-search__lead {
  margin: 0 0 1.2em;
}

.ag-wordle-search fieldset {
  min-width: 0;
  margin: 0 0 1.1em;
  padding: 0;
  border: 0;
}

.ag-wordle-search legend,
.ag-wordle-search label {
  color: var(--ag-wordle-navy);
  font-weight: 700;
}

.ag-wordle-search__help {
  margin: 0.35em 0 0.7em;
  color: #53687c;
  font-size: 0.9rem;
  line-height: 1.65;
}

.ag-wordle-search__positions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.55em;
  max-width: 24rem;
  margin-inline: auto;
}

/*
 * WordPress の自動整形でラベル間・ラベル内に追加される改行を、
 * 5列グリッドのアイテムとして数えない。
 */
.ag-wordle-search__positions > br,
.ag-wordle-search__position > br {
  display: none;
}

.ag-wordle-search__position {
  display: grid;
  gap: 0.35em;
  text-align: center;
}

.ag-wordle-search input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 0.65em 0.75em;
  border: 1px solid #96b1c8;
  border-radius: 9px;
  background: #fff;
  color: #142a40;
  font: inherit;
  text-transform: uppercase;
}

.ag-wordle-search__position input {
  aspect-ratio: 1;
  padding-inline: 0.25em;
  line-height: 1;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
}

.ag-wordle-search input:focus-visible,
.ag-wordle-search button:focus-visible {
  outline: 3px solid #ffbf47;
  outline-offset: 3px;
}

.ag-wordle-search__criteria {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9em;
}

/*
 * WordPress の自動整形で追加される段落と改行をレイアウトから外し、
 * label・input・補足説明を一つのまとまりとして扱う。
 */
.ag-wordle-search__criteria > p {
  display: contents;
}

.ag-wordle-search__field > br {
  display: none;
}

/*
 * 自動広告が検索条件の途中へ挿入された場合も広告は隠さず、
 * 3つの入力項目より後の全幅行に配置する。
 */
.ag-wordle-search__criteria > .google-auto-placed {
  grid-column: 1 / -1;
  grid-row: 2;
}

.ag-wordle-search__field {
  display: grid;
  align-content: start;
  gap: 0.35em;
}

.ag-wordle-search__field small {
  color: #53687c;
  line-height: 1.55;
}

.ag-wordle-search__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7em;
  margin-top: 1.2em;
}

.ag-wordle-search button {
  min-height: 44px;
  padding: 0.7em 1.15em;
  border: 1px solid var(--ag-wordle-blue);
  border-radius: 9px;
  background: var(--ag-wordle-blue);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.ag-wordle-search button[data-wordle-reset],
.ag-wordle-search button[data-wordle-more] {
  background: #fff;
  color: var(--ag-wordle-blue);
}

.ag-wordle-search button:hover {
  filter: brightness(0.95);
}

.ag-wordle-search__summary {
  margin: 1.35em 0 0.8em;
  padding: 0.8em 1em;
  border-left: 4px solid var(--ag-wordle-green);
  background: #ebf8f4;
  font-weight: 700;
}

.ag-wordle-search__results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5em, 1fr));
  gap: 0.55em;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ag-wordle-search__results li {
  padding: 0.6em 0.7em;
  border: 1px solid #d5e2ed;
  border-radius: 8px;
  background: var(--ag-wordle-sky);
  color: var(--ag-wordle-navy);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.04rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.ag-wordle-search__empty {
  margin: 0;
  padding: 1em;
  border: 1px solid #e1b35d;
  border-radius: 9px;
  background: #fff9e8;
}

.ag-wordle-search button[data-wordle-more] {
  display: block;
  margin: 1em auto 0;
}

.ag-wordle-search__noscript {
  margin: 1em 0 0;
  padding: 1em;
  border: 1px solid #e1b35d;
  border-radius: 9px;
  background: #fff9e8;
}

.ag-wordle-tips {
  margin: 2em 0;
}

.ag-wordle-tips h2 {
  color: var(--ag-wordle-navy, #16324f);
}

@media (max-width: 680px) {
  .ag-wordle-search {
    border-radius: 12px;
  }

  .ag-wordle-search__criteria {
    grid-template-columns: 1fr;
  }

  .ag-wordle-search__criteria > .google-auto-placed {
    grid-row: 4;
  }

  .ag-wordle-search__positions {
    gap: 0.35em;
  }

  .ag-wordle-search__position {
    font-size: 0.84rem;
  }

  .ag-wordle-search__results {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ag-wordle-search__actions button {
    flex: 1 1 8em;
  }
}

@media (max-width: 359px) {
  .ag-wordle-search__results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .ag-wordle-search * {
    scroll-behavior: auto !important;
  }
}
