.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.puzzle {
  position: relative;
  display: grid;
  grid-template-columns: 30% 68%;
  gap: 2%;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 2cqh 2cqw;
  overflow: hidden;
}

.companion-launcher {
  position: absolute;
  z-index: 7;
  bottom: 1.2cqh;
  left: 1.2cqw;
  width: 7.5cqh;
  height: 7.5cqh;
  padding: 0;
  overflow: hidden;
  background: rgb(255 250 229);
  border: 0.3cqh solid rgb(35 31 27);
  border-radius: 50%;
  box-shadow: 0 0.7cqh 1.5cqh rgb(0 0 0 / 35%);
  cursor: pointer;
}

.companion-launcher[hidden] {
  display: none;
}

.companion-launcher img {
  position: absolute;
  top: -5%;
  left: 50%;
  width: 155%;
  max-width: none;
  transform: translateX(-50%);
}

.companion-launcher:focus-visible {
  outline: 0.35cqh solid var(--highlight2);
  outline-offset: 0.3cqh;
}

.puzzle button,
.puzzle input,
.puzzle select {
  font-size: inherit;
}

.progress-panel {
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  border: 0.25cqh solid var(--line);
  border-radius: 2cqh;
  background: var(--panel-glass);
  box-shadow: 0 0.8cqh 2.2cqh rgb(0 0 0 / 28%);
  backdrop-filter: blur(0.7cqh) saturate(85%);
}

.progress-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.progress-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6cqh 1cqw;
  align-items: center;
  padding: 2cqh 1.5cqw;
  color: var(--text);
  text-align: left;
  background: transparent;
  border: 0;
}

.progress-label {
  font-weight: 750;
}

.progress-summary progress {
  grid-column: 1 / -1;
  width: 100%;
  height: 1.5cqh;
  overflow: hidden;
  accent-color: var(--highlight1);
  border-radius: 1cqh;
}

.progress-chevron {
  display: none;
}

.progress-details {
  min-height: 0;
  padding: 0 1.5cqw 2cqh;
  overflow: auto;
}

.found-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1cqw;
  padding-bottom: 1cqh;
  border-bottom: 0.15cqh solid var(--line);
}

.found-heading h2 {
  margin: 0;
  font-size: 1em;
}

.found-heading select {
  max-width: 100%;
  padding: 0.5cqh 0.5cqw;
  color: var(--text);
  background: var(--button);
  border: 0.15cqh solid var(--line);
  border-radius: 0.8cqh;
}

.found-words {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8cqh 1.5cqw;
  padding-left: 1.6em;
  margin: 1.5cqh 0;
  font-family: "JetBrains Mono", monospace;
  text-transform: uppercase;
}

.found-empty {
  margin: 2cqh 0;
  color: color-mix(in srgb, var(--text) 65%, transparent);
  text-align: center;
}

.game-panel {
  display: grid;
  grid-template-rows: 14% 72% 14%;
  align-items: center;
  padding: 0 3cqw;
}

#b-top-bar .theme-toggle {
  display: none;
}

#b-top-bar {
  grid-template-columns: 30% 40% 30%;
}

#b-top-bar .header-left {
  justify-self: start;
  padding-left: 2cqw;
}

#b-top-bar .header-right {
  justify-self: end;
  padding-right: 2cqw;
}

.puzzle-date-heading {
  margin: 0;
  font-size: 0.86em;
  font-weight: 700;
  white-space: nowrap;
  text-shadow: 0 0.15cqh 0.45cqh var(--panel), 0 0 1.2cqh var(--panel);
}

.utility-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2cqw;
  width: 100%;
}

.utility-row h1 {
  margin: 0;
  font-size: 0.9em;
  font-weight: 650;
  white-space: nowrap;
  text-shadow: 0 0.15cqh 0.45cqh var(--panel), 0 0 1.2cqh var(--panel);
}

.utility-actions,
.game-actions {
  display: flex;
  align-items: center;
  gap: 1cqw;
}

.easy-control {
  display: flex;
  align-items: center;
  gap: 0.5cqw;
  cursor: pointer;
}

.easy-control input {
  width: 1.2em;
  height: 1.2em;
  accent-color: var(--highlight1);
}

.settings-button,
.game-actions button,
.settings-dialog button,
.help-dialog button {
  padding: 0.8cqh 1.2cqw;
  color: var(--text);
  font-weight: 650;
  background: var(--button);
  border: 0.2cqh solid var(--line);
  border-radius: 1cqh;
  cursor: pointer;
}

.settings-button {
  display: grid;
  place-items: center;
  width: 3.2em;
  height: 3.2em;
  padding: 0;
  font-size: 1.1em;
  line-height: 1;
  border-radius: 50%;
  box-shadow: 0 0.6cqh 1.4cqh rgb(0 0 0 / 28%);
}

.fragment-wrap {
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
}

.fragment {
  min-width: 10ch;
  color: var(--text);
  font-family: "JetBrains Mono", monospace;
  font-size: 4.5cqh;
  font-weight: 700;
  letter-spacing: 0.15em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 0.2cqh 0.4cqh rgb(0 0 0 / 18%);
}

.fragment.word-found {
  color: var(--highlight1);
  animation: word-found 320ms ease-out;
}

.board {
  align-self: center;
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 2cqh;
  box-sizing: border-box;
  height: min(58cqh, 48cqw);
  aspect-ratio: 1;
  padding: 2cqh;
  border: 0.2cqh solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 3cqh;
  background: color-mix(in srgb, var(--back) 45%, transparent);
  box-shadow: inset 0 0.5cqh 1.5cqh rgb(0 0 0 / 12%);
}

.letter-tile {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  color: var(--text);
  background: linear-gradient(145deg, color-mix(in srgb, var(--button) 70%, white), var(--button));
  border: 0.25cqh solid var(--line);
  border-radius: 2cqh;
  box-shadow: 0 0.9cqh 0 color-mix(in srgb, var(--line) 75%, black), 0 1.2cqh 1.5cqh rgb(0 0 0 / 22%);
  cursor: pointer;
  transition: transform 140ms ease, opacity 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.tile-letter {
  font-family: "JetBrains Mono", monospace;
  font-size: 7cqh;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

.tile-count {
  position: absolute;
  top: 0.6cqh;
  right: 0.7cqh;
  display: grid;
  place-items: center;
  min-width: 1.5em;
  min-height: 1.5em;
  color: var(--text);
  font-size: 0.65em;
  font-weight: 750;
  background: color-mix(in srgb, var(--panel) 75%, transparent);
  border-radius: 50%;
}

.tile-count[hidden] {
  display: none;
}

.letter-tile.selectable:not(.current) {
  border-color: var(--highlight1);
  box-shadow: 0 0.9cqh 0 color-mix(in srgb, var(--highlight1) 65%, black), 0 0 1.8cqh color-mix(in srgb, var(--highlight1) 45%, transparent);
}

.letter-tile.current {
  transform: translateY(0.7cqh) scale(1.04);
  color: var(--panel);
  background: var(--highlight1);
  border-color: color-mix(in srgb, var(--highlight1) 65%, white);
  box-shadow: 0 0.2cqh 0 color-mix(in srgb, var(--highlight1) 65%, black), 0 0 2cqh var(--highlight1);
}

.letter-tile:disabled:not(.current) {
  transform: translateY(0.7cqh);
  opacity: 0.34;
  box-shadow: 0 0.2cqh 0 var(--line);
  cursor: default;
}

.letter-tile:focus-visible,
.settings-button:focus-visible,
.settings-row:focus-visible,
.game-actions button:focus-visible,
.progress-summary:focus-visible {
  outline: 0.35cqh solid var(--highlight2);
  outline-offset: 0.3cqh;
}

.game-actions {
  justify-content: center;
}

.game-actions button {
  min-width: 9cqw;
  min-height: 5cqh;
}

.game-actions button:disabled {
  opacity: 0.42;
  cursor: default;
}

.settings-dialog,
.help-dialog {
  box-sizing: border-box;
  max-width: min(80cqw, 34rem);
  padding: 3cqh 3cqw;
  color: var(--text);
  background: var(--panel);
  border: 0.25cqh solid var(--highlight1);
  border-radius: 2cqh;
  box-shadow: 0 2cqh 6cqh rgb(0 0 0 / 35%);
}

.settings-dialog::backdrop,
.help-dialog::backdrop {
  background: rgb(0 0 0 / 55%);
  backdrop-filter: blur(0.4cqh);
}

.settings-dialog h2,
.help-dialog h2 {
  margin-top: 0;
}

.settings-dialog form,
.help-dialog form {
  display: flex;
  justify-content: flex-end;
}

.settings-list {
  display: grid;
  gap: 1cqh;
  margin: 2cqh 0 3cqh;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3cqw;
  width: 100%;
  padding: 1.4cqh 1.2cqw;
  color: var(--text);
  text-align: left;
  background: var(--button);
  border: 0.15cqh solid var(--line);
  border-radius: 1cqh;
  cursor: pointer;
}

.settings-row > span:first-child {
  display: grid;
  gap: 0.3cqh;
}

.settings-row small {
  font-weight: 400;
  opacity: 0.72;
}

.settings-row input {
  flex: 0 0 auto;
  width: 1.4em;
  height: 1.4em;
  accent-color: var(--highlight1);
}

.companion-control {
  align-items: flex-start;
  margin: 0;
}

.companion-control legend {
  display: grid;
  gap: 0.3cqh;
  padding: 0;
}

.companion-control legend small {
  display: block;
}

.companion-options {
  display: grid;
  gap: 0.8cqh;
  white-space: nowrap;
}

.companion-options label {
  display: flex;
  gap: 0.6cqw;
  align-items: center;
  cursor: pointer;
}

.companion-dialog {
  width: min(94vw, 130vh);
  height: min(88vh, 76vw);
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: visible;
  background: transparent;
  border: 0;
}

.companion-dialog::backdrop {
  background: rgb(5 12 18 / 58%);
  backdrop-filter: blur(0.35cqh) saturate(70%);
}

.companion-scene {
  position: relative;
  width: 100%;
  height: 100%;
}

.companion-character {
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: 1;
  width: auto;
  height: 77%;
  object-fit: contain;
  object-position: left bottom;
  filter: drop-shadow(0 1.3cqh 1.3cqh rgb(0 0 0 / 35%));
}

.companion-form {
  position: absolute;
  top: 5%;
  right: 0;
  z-index: 2;
  width: 68%;
}

.companion-bubble {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  padding: 1.6cqh 2cqw 1.2cqh;
  color: rgb(35 31 27);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(0.82rem, 1.5cqh, 1rem);
  line-height: 1.27;
  text-align: left;
  background: rgb(255 250 229);
  border: 0.45cqh solid rgb(35 31 27);
  border-radius: 48% 44% 46% 42% / 18% 22% 20% 19%;
  box-shadow: 0.9cqh 1.1cqh 0 rgb(0 0 0 / 24%);
  cursor: pointer;
}

.companion-bubble::before,
.companion-bubble::after {
  position: absolute;
  top: 58%;
  width: 0;
  height: 0;
  content: "";
  transform: rotate(10deg);
}

.companion-bubble::before {
  left: -5.1cqh;
  border-top: 2.4cqh solid transparent;
  border-right: 5.2cqh solid rgb(35 31 27);
  border-bottom: 1.5cqh solid transparent;
}

.companion-bubble::after {
  left: -4.1cqh;
  margin-top: 0.38cqh;
  border-top: 1.75cqh solid transparent;
  border-right: 4.25cqh solid rgb(255 250 229);
  border-bottom: 1.05cqh solid transparent;
}

.companion-bubble small {
  display: block;
  margin-top: 1cqh;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.55em;
  font-weight: 700;
  text-align: right;
  text-transform: uppercase;
  opacity: 0.55;
}

.companion-bubble:focus-visible {
  outline: 0.4cqh solid var(--highlight2);
  outline-offset: 0.5cqh;
}

@keyframes word-found {
  50% {
    transform: translateY(-0.8cqh) scale(1.08);
    text-shadow: 0 0 1.8cqh var(--highlight1);
  }
}

.CAM-LANDSCAPE-B .puzzle,
.CAM-LANDSCAPE-B #b-top-bar,
.CAM-LANDSCAPE-B #b-bottom-bar {
  font-size: 2.8cqh;
}

.CAM-LANDSCAPE-B .found-heading {
  align-items: stretch;
  flex-direction: column;
}

.CAM-LANDSCAPE-B .found-heading select {
  width: 100%;
}

.CAM-LANDSCAPE-B .found-words {
  grid-template-columns: 1fr;
}

.CAM-PORTRAIT#b-camera-style {
  grid-template-rows: 10% 90% 0;
}

.PORTRAIT #b-bottom-bar {
  display: none;
}

.PORTRAIT .puzzle {
  position: relative;
  display: block;
  padding: 1.5cqh 3cqw 10cqh;
}

.PORTRAIT .game-panel {
  position: absolute;
  top: 1.5cqh;
  right: 3cqw;
  bottom: 10cqh;
  left: 3cqw;
  grid-template-rows: 14% 72% 14%;
  box-sizing: border-box;
  height: auto;
  padding: 0 3cqw;
}

.PORTRAIT #b-top-bar {
  grid-template-columns: 32% 36% 32%;
}

.PORTRAIT .puzzle-date-heading {
  font-size: 0.68em;
}

.PORTRAIT .fragment {
  font-size: 4cqh;
}

.PORTRAIT .board {
  width: min(92cqw, 68cqh);
  height: auto;
  gap: 2cqw;
  padding: 2cqw;
}

.PORTRAIT .tile-letter {
  font-size: min(14cqw, 7cqh);
}

.PORTRAIT .game-actions {
  gap: 3cqw;
}

.PORTRAIT .game-actions button {
  min-width: 28cqw;
  min-height: 5cqh;
}

.PORTRAIT .progress-panel {
  position: absolute;
  z-index: 5;
  right: 3cqw;
  bottom: 0;
  left: 3cqw;
  display: grid;
  grid-template-rows: 10cqh 1fr;
  height: 35cqh;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
  transform: translateY(calc(100% - 10cqh));
  transition: transform 240ms ease-out;
}

.PORTRAIT .progress-panel.open {
  transform: translateY(0);
}

.PORTRAIT .progress-summary {
  padding: 1.5cqh 4cqw;
  cursor: pointer;
}

.PORTRAIT .progress-chevron {
  position: absolute;
  top: 0.3cqh;
  left: 50%;
  display: block;
  transform: translateX(-50%);
}

.PORTRAIT .progress-panel.open .progress-chevron {
  transform: translateX(-50%) rotate(180deg);
}

.PORTRAIT .progress-details {
  padding-inline: 4cqw;
}

.PORTRAIT .companion-dialog {
  width: 94vw;
  height: 86vh;
}

.PORTRAIT .companion-launcher {
  position: fixed;
  bottom: 11.2cqh;
  left: 3cqw;
  width: 7cqh;
  height: 7cqh;
}

.PORTRAIT .companion-character {
  right: auto;
  bottom: 0;
  left: -3%;
  width: 46%;
  height: auto;
  max-height: 50%;
}

.PORTRAIT .companion-form {
  top: 4%;
  right: 2%;
  width: 82%;
}

.PORTRAIT .companion-bubble {
  padding: 2.2cqh 4.5cqw 1.6cqh;
  font-size: clamp(0.85rem, 1.85cqh, 1.1rem);
  border-radius: 44% 48% 43% 46% / 15% 17% 16% 18%;
}

.PORTRAIT .companion-bubble::before,
.PORTRAIT .companion-bubble::after {
  top: auto;
  transform: rotate(-58deg);
}

.PORTRAIT .companion-bubble::before {
  bottom: -3.7cqh;
  left: 18%;
}

.PORTRAIT .companion-bubble::after {
  bottom: -2.65cqh;
  left: calc(18% + 0.7cqh);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}
