/* Font Awesome Free 6.5.2, subset to the icons used by Wördl.
   Font license: /fonts/LICENSE.txt (SIL OFL 1.1). */
@font-face {
  font-family: 'Woerdl Icons Solid';
  src: url('/versioned/icons-solid.7a8807f26696.woff2') format('woff2');
  font-weight: 900;
  font-display: block;
}
@font-face {
  font-family: 'Woerdl Icons Regular';
  src: url('/versioned/icons-regular.fb68185073a9.woff2') format('woff2');
  font-weight: 400;
  font-display: block;
}
.fa-solid, .fa-regular {
  display: inline-block;
  font-style: normal;
  font-variant: normal;
  line-height: 1;
  text-rendering: auto;
  -webkit-font-smoothing: antialiased;
}
.fa-solid { font-family: 'Woerdl Icons Solid'; font-weight: 900; }
.fa-regular { font-family: 'Woerdl Icons Regular'; font-weight: 400; }
.fa-arrow-left::before { content: "\f060"; }
.fa-circle-question::before { content: "\f059"; }
.fa-gear::before { content: "\f013"; }
.fa-chevron-down::before { content: "\f078"; }
.fa-check::before { content: "\f00c"; }
.fa-moon::before { content: "\f186"; }
.fa-sun::before { content: "\f185"; }
.fa-eye::before { content: "\f06e"; }
.fa-eye-slash::before { content: "\f070"; }
.fa-download::before { content: "\f019"; }
.fa-upload::before { content: "\f093"; }
.fa-trophy::before { content: "\f091"; }
.fa-delete-left::before { content: "\f55a"; }
.fa-rotate-right::before { content: "\f2f9"; }
.fa-share-nodes::before { content: "\f1e0"; }
.fa-star::before { content: "\f005"; }

:root {
  color-scheme: dark;
  --color-correct: #4caf50;
  --color-present: #f9a825;
  --color-missing: rgba(255, 255, 255, 0.08);
  --color-unknown: rgba(255, 255, 255, 0.09);
  --color-background: #0d0d0d;
  --color-surface: #151515;
  --color-missing-key: #B71C1C;
  --color-text: #FFFFFF;
  --color-key-bg: rgba(255, 255, 255, 0.10);
  --color-key-border: rgba(255, 255, 255, 0.06);
}

[data-theme="light"] {
  color-scheme: light;
  --color-correct: #4caf50;
  --color-present: #f9a825;
  --color-missing: #787c7e;
  --color-unknown: #d3d6da;
  --color-background: #f9f9f9;
  --color-surface: #f0f0f0;
  --color-missing-key: #787c7e;
  --color-text: #1a1a1b;
  --color-key-bg: #d3d6da;
  --color-key-border: #c0c3c6;
}

/* ===== Keyframe Animations ===== */

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes flip-in {
  0% { transform: rotateX(0deg); }
  50% { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

@keyframes dialog-enter {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-4px); }
  30%, 70% { transform: translateX(4px); }
}

/* ===== Base ===== */

html,
body {
  font-family: 'Avenir Next', 'Segoe UI', 'Noto Sans', sans-serif;
  width: 100%;
  min-height: 100vh;
  padding: 0;
  margin: 0;
  background-color: var(--color-background);
  color: var(--color-text);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.main {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  max-width: 500px;
  width: 100%;
  padding-bottom: 20px;
  box-sizing: border-box;
}

/* ===== Grid ===== */

.grid {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 8px;
  padding: 10px;
  box-sizing: border-box;
  width: 100%;
  max-width: 400px;
  aspect-ratio: var(--word-length, 5) / 6;
  margin: 0 auto;
}

.row {
  display: grid;
  grid-template-columns: repeat(var(--word-length, 5), minmax(0, 1fr));
  gap: 5px;
}

.row-shake {
  animation: shake 0.5s ease-in-out;
}

/* ===== Tiles ===== */

.tile {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  font-weight: bold;
  text-transform: uppercase;
  border: 2px solid var(--color-unknown);
  background-color: transparent;
  color: var(--color-text);
  user-select: none;
  border-radius: 6px;
  aspect-ratio: 1;
  transition: background-color 0.4s ease, border-color 0.4s ease;
}

.tile.tile-pop {
  animation: pop 0.1s ease-in-out;
}

.tile.tile-filled {
  border-color: rgba(255, 255, 255, 0.25);
}

[data-theme="light"] .tile.tile-filled {
  border-color: #878a8c;
}

.tile.tile-flip {
  animation: flip-in 0.5s ease-in-out;
  animation-fill-mode: both;
}

.tile.correct {
  background-color: var(--color-correct);
  border-color: var(--color-correct);
  color: #ffffff;
}

.tile.present {
  background-color: var(--color-present);
  border-color: var(--color-present);
  color: #ffffff;
}

.tile.missing {
  background-color: var(--color-missing);
  border-color: var(--color-missing);
}

.tile.unknown {
  border-color: var(--color-unknown);
  background-color: transparent;
}

.row-active .tile.unknown {
  border-color: #787c7e;
}

.row-active .tile.unknown:not(.tile-filled):is(:first-child, .tile-filled + .tile) {
  box-shadow: inset 0 -3px var(--color-text);
}

/* ===== Keyboard ===== */

.keyboard {
  width: 100%;
  box-sizing: border-box;
  max-width: 400px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.key {
  font-family: inherit;
  font-weight: bold;
  border: 1px solid var(--color-key-border);
  padding: 0;
  margin: 0;
  height: 52px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  background-color: var(--color-key-bg);
  color: var(--color-text);
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  text-transform: uppercase;
  font-size: 1.1rem;
  touch-action: manipulation;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, transform 0.1s ease;
}

.key:hover {
  filter: brightness(1.15);
}

.key:active {
  transform: scale(0.95);
  opacity: 0.8;
}

.key.large {
  flex: 1.5;
  font-size: 0.8rem;
}

.key.action.enabled {
  background-color: #2196F3;
  color: white;
}

.key.action.disabled {
  background-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.30);
  cursor: default;
}

[data-theme="light"] .key.action.disabled {
  background-color: #d3d6da;
  color: rgba(0, 0, 0, 0.30);
}

.key.correct {
  background-color: var(--color-correct);
  color: #ffffff;
}

.key.present {
  background-color: var(--color-present);
  color: #ffffff;
}

.key.missing {
  background-color: var(--color-missing-key);
  color: #ffffff;
}

/* ===== Score Widgets ===== */

.score-widget {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
}

.score-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1.2rem;
}

.score-icon {
  width: 18px;
  height: 18px;
}

.score-icon-fa {
  font-size: 16px;
  color: goldenrod;
}

/* ===== Dialog ===== */

.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.dialog-content {
  overflow-wrap: anywhere;
  background-color: var(--color-surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-sizing: border-box;
  padding: 0;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  max-width: 92%;
  width: 480px;
  max-height: 88vh;
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.04);
  position: relative;
  animation: dialog-enter 0.2s ease-out;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.dialog-content::-webkit-scrollbar {
  width: 5px;
}

.dialog-content::-webkit-scrollbar-track {
  background: transparent;
}

.dialog-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 10px;
}

.dialog-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.32);
}

[data-theme="light"] .dialog-content {
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.04);
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

[data-theme="light"] .dialog-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .dialog-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.35);
}

.dialog-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding: 8px 16px;
  border-bottom: 1px solid var(--color-unknown);
}
.dialog-header h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1.3;
}

.dialog-close {
  flex: 0 0 44px;
  margin-left: auto;
  background: none;
  border: none;
  color: var(--color-text);
  font-size: 1.5rem;
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.dialog-close:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .dialog-close:hover {
  background-color: rgba(0, 0, 0, 0.08);
}

/* ===== Header ===== */

.header {
  width: 100%;
  max-width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 14px 20px;
  box-sizing: border-box;
  background-color: transparent;
  transition: none;
}

.header > :first-child {
  justify-self: start;
}

.header > :last-child {
  justify-self: end;
}

.header-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--color-text);
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  background-color: var(--color-key-bg);
  border: 1px solid var(--color-key-border);
  color: var(--color-text);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
}

.icon-button i {
  font-size: 0.95rem;
}

.icon-button:hover {
  background-color: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
}

[data-theme="light"] .icon-button:hover {
  background-color: rgba(0, 0, 0, 0.12);
  border-color: rgba(0, 0, 0, 0.2);
}

.icon-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ===== Buttons ===== */

.primary-button {
  background-color: var(--color-correct);
  color: #ffffff;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 10px;
  font-weight: bold;
  transition: opacity 0.2s ease, transform 0.1s ease;
}

.primary-button:hover {
  opacity: 0.85;
}

.primary-button:active {
  transform: scale(0.97);
}

.secondary-button {
  background-color: #2196F3;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 10px;
  font-weight: bold;
  transition: opacity 0.2s ease, transform 0.1s ease;
}

.secondary-button:hover {
  opacity: 0.85;
}

.secondary-button:active {
  transform: scale(0.97);
}

.secondary-button.share-button {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dialog-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* ===== Toast ===== */

.toast {
  width: max-content;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
  text-align: center;
  position: fixed;
  top: 8px;
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--color-text);
  color: var(--color-background);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: clamp(13px, 0.85rem, 18px);
  line-height: 1.25;
  font-weight: bold;
  opacity: 0;
  z-index: 2000;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.dictionary-status {
  flex-shrink: 0;
  align-self: center; width: min(100%, 420px); margin: auto;
  box-sizing: border-box; padding: 24px; border: 1px solid var(--color-unknown);
  border-radius: 16px; background: var(--color-surface); text-align: center;
}
.dictionary-status h2 { margin: 0 0 12px; font-size: 1.15rem; line-height: 1.35; }
.game-area-loading { overflow-y: auto; }
.dictionary-status p { margin: 0; line-height: 1.5; }
.dictionary-retry { max-width: 100%; min-height: 44px; white-space: normal; margin-bottom: 16px; }
.dictionary-progress { height: 3px; width: 80px; margin: 0 auto 20px; background: var(--color-correct); border-radius: 3px; }
@media (max-height: 540px) {
  .dictionary-status { padding: 16px; }
  .dictionary-status h2 { font-size: 1rem; }
}

.toast.show {
  animation: toast-in 0.3s ease-out forwards;
}

/* ===== Difficulty Widget ===== */

.difficulty-widget {
  background-color: rgba(255, 255, 255, 0.12);
  padding: 4px 12px;
  border-radius: 24px;
  font-size: 0.9rem;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  transition: background-color 0.3s ease, color 0.3s ease;
}

[data-theme="light"] .difficulty-widget {
  background-color: rgba(0, 0, 0, 0.08);
}

.difficulty-widget.difficulty-easy {
  background-color: rgba(76, 175, 80, 0.20);
  color: var(--color-correct);
}

.difficulty-widget.difficulty-medium {
  background-color: rgba(249, 168, 37, 0.20);
  color: var(--color-present);
}

.difficulty-widget.difficulty-hard {
  background-color: rgba(244, 67, 54, 0.20);
  color: #f44336;
}

[data-theme="light"] .difficulty-widget.difficulty-easy {
  background-color: rgba(76, 175, 80, 0.15);
  color: #388e3c;
}

[data-theme="light"] .difficulty-widget.difficulty-medium {
  background-color: rgba(249, 168, 37, 0.15);
  color: #e65100;
}

[data-theme="light"] .difficulty-widget.difficulty-hard {
  background-color: rgba(244, 67, 54, 0.15);
  color: #c62828;
}

/* ===== Info Chip ===== */

.info-chip {
  background-color: #2196F3;
  color: white;
  border: none;
  padding: 4px 12px;
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.1s ease;
}

.info-chip:hover {
  opacity: 0.85;
}

.info-chip:active {
  transform: scale(0.95);
}

/* ===== HowTo Dialog ===== */

.how-to-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.how-to-content h3 {
  margin-top: 10px;
  margin-bottom: 5px;
}

.how-to-content p {
  margin: 0;
  line-height: 1.5;
  font-size: 0.95rem;
}

.how-to-content .settings-section {
  padding: 16px 0;
}

.how-to-content .settings-section h4 {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0;
  opacity: 0.5;
  text-transform: none;
  margin: 0 0 12px 0;
}

.example-block {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

[data-theme="light"] .example-block {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.07);
}

.example-block:last-of-type {
  margin-bottom: 0;
}

.example-block p {
  margin: 0;
  font-size: 0.88rem;
  opacity: 0.8;
}

.example-row {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.example-tile-wrapper {
  margin: 2px;
}

.dialog-spacer {
  height: 4px;
}

.dialog-footer-links {
  margin-top: 6px;
  font-size: 0.8rem;
  text-align: center;
  color: var(--color-text);
  opacity: 0.45;
}

.dialog-footer-links a {
  color: inherit;
  text-decoration: none;
}

.dialog-footer-links a:hover {
  opacity: 1;
  text-decoration: underline;
}

.dialog-info-box {
  background: rgba(33, 150, 243, 0.08);
  border: 1px solid rgba(33, 150, 243, 0.2);
  border-radius: 10px;
  padding: 12px 14px !important;
  margin-top: 4px;
}

.dialog-info-box p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
}

.dialog-info-box a {
  color: #2196F3;
  text-decoration: none;
  font-weight: 500;
}

.dialog-info-box a:hover {
  text-decoration: underline;
}

/* ===== Stats Dialog ===== */

.stats-content {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stats-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 4px;
  text-align: center;
}

.stats-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stats-value {
  font-size: 2rem;
  font-weight: bold;
  white-space: nowrap;
  line-height: 1.15;
}

.stats-label {
  font-size: 0.75rem;
  opacity: 0.7;
  text-transform: uppercase;
  overflow-wrap: normal;
  hyphens: auto;
  line-height: 1.4;
}

.stats-distribution {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stats-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stats-bar-label {
  width: 1em;
  flex-shrink: 0;
  text-align: right;
  font-weight: bold;
  font-size: 0.9rem;
}

.stats-bar-track {
  flex: 1;
  background-color: var(--color-unknown);
  border-radius: 4px;
  overflow: hidden;
  min-height: 24px;
}

.stats-bar-fill {
  box-sizing: border-box;
  background-color: var(--color-correct);
  min-width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
}

.stats-bar-fill.stats-bar-empty {
  background-color: var(--color-missing);
}

.stats-bar-count {
  font-size: 0.8rem;
  font-weight: bold;
  color: #ffffff;
}

.score-widget-button {
  background-color: var(--color-key-bg);
  border: 1px solid var(--color-key-border);
  border-radius: 999px;
  cursor: pointer;
  padding: 5px 8px;
  color: inherit;
  transition: background-color 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
}

.score-widget-button:hover {
  background-color: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
}

[data-theme="light"] .score-widget-button:hover {
  background-color: rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.2);
}

/* ===== Finish Dialog ===== */

.finish-dialog-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.finish-dialog-header {
  margin-bottom: 8px;
}

.finish-icon {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.finish-icon-lost {
  font-size: 4rem;
}

.finish-title {
  margin: 0;
  font-size: 2rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.finish-word-row {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin: 10px 0;
}

.finish-description {
  font-size: 1rem;
  color: var(--color-text);
  max-width: 300px;
  line-height: 1.6;
  margin-top: 4px;
}

.finish-description b {
  display: block;
  margin-bottom: 4px;
}

.finish-guess-count {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 1px;
  opacity: 0.75;
  color: var(--color-text);
}

.finish-buttons {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

.primary-button.restart-button {
  background-color: var(--color-correct);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
}

/* ===== Settings Dialog ===== */

.settings-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-content h3 {
  margin: 0 0 8px 0;
}

.settings-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--color-unknown);
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-section h4 {
  margin: 0 0 6px 0;
  font-size: 0.95rem;
  font-weight: 700;
  opacity: 0.7;
  text-transform: none;
  letter-spacing: 0;
}

.settings-section p {
  margin: 0 0 10px 0;
  font-size: 0.9rem;
  opacity: 0.8;
  line-height: 1.4;
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.settings-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.theme-toggle-button {
  min-height: 44px;
  background-color: var(--color-key-bg);
  color: var(--color-text);
  border: 1px solid var(--color-unknown);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.2s ease;
}

.theme-toggle-button:hover {
  background-color: rgba(255, 255, 255, 0.18);
}

[data-theme="light"] .theme-toggle-button:hover {
  background-color: rgba(0, 0, 0, 0.12);
}

/* ===== How-To Actions ===== */

.how-to-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

.how-to-actions a img {
  display: block;
  border-radius: 8px;
}

.how-to-actions a:first-child img {
  background: #000;
}

/* ===== Color-Blind Mode ===== */

[data-colorblind="true"] {
  --color-correct: #0077BB;
  --color-present: #EE7733;
  --color-missing: #555555;
  --color-missing-key: #555555;
}

[data-colorblind="true"] .tile,
[data-colorblind="true"] .guide-letter {
  position: relative;
  overflow: hidden;
}

[data-colorblind="true"] .tile.correct::after,
[data-colorblind="true"] .guide-letter.correct::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 3px,
    rgba(255, 255, 255, 0.15) 3px,
    rgba(255, 255, 255, 0.15) 6px
  );
  border-radius: inherit;
  pointer-events: none;
}

[data-colorblind="true"] .tile.present::after,
[data-colorblind="true"] .guide-letter.present::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 1px, transparent 1px);
  background-size: 6px 6px;
  border-radius: inherit;
  pointer-events: none;
}

/* ===== Responsive: Tablet / Large Phone ===== */

@media (max-width: 600px) {
  .header {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .header-title {
    /* Static — sits naturally between difficulty and score in the flex row */
    position: static;
    transform: none;
    pointer-events: auto;
    font-size: 1.1rem;
    letter-spacing: 1px;
    flex-shrink: 0;
  }

  /* Push score + buttons to the right, tighten cluster */
  .header-right {
    margin-left: auto;
    gap: 4px;
  }

  /* Compact score widget so it takes less header space */
  .score-widget {
    gap: 10px;
  }

  .score-item {
    font-size: 1rem;
    gap: 4px;
  }

  /* Smaller icon buttons on mobile */
  .icon-button {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }

  /* Hide the nav-link buttons (spieltipps / über) — they're <a> elements,
     the action buttons (settings, how-to) are <button> elements */
  .header-right a.icon-button {
    display: none;
  }

  /* Keep difficulty badge from overflowing its cell */
  .difficulty-widget {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    font-size: 0.78rem;
    padding: 4px 8px;
  }

  /* Keyboard: tighter padding so keys get more width; taller for easier tapping */
  .keyboard {
    padding: 4px 6px;
    gap: 6px;
    max-width: 100%;
  }

  .keyboard-row {
    gap: 3px;
  }

  .key {
    height: 56px;
    font-size: 0.95rem;
    border-radius: 6px;
  }

  .key.large {
    font-size: 0.72rem;
  }

  .tile {
    font-size: 1.8rem;
    border-radius: 5px;
  }

  /* Grid: tighten up to leave more room for the keyboard */
  .grid {
    padding: 6px;
    gap: 5px;
  }

  .game-area {
    padding-bottom: 4px;
  }

  .dialog-content {
    width: 94%;
    max-height: 88dvh;
    padding: 0;
    border-radius: 16px;
  }

  .finish-dialog-header {
    margin-bottom: 0;
  }

  .finish-dialog-content {
    gap: 10px;
  }

  .home-grid,
  .home-link-grid {
    grid-template-columns: 1fr;
  }

  .content-panel,
  .home-card,
  .home-link-card {
    padding: 18px;
  }

  .home-content {
    padding: 0 12px 40px;
  }
}

/* ===== Responsive: Small Phone ===== */

@media (max-width: 380px) {
  .keyboard {
    gap: 4px;
    padding: 3px 4px;
  }

  .keyboard-row {
    gap: 2px;
  }

  .key {
    height: 52px;
    font-size: 0.85rem;
    border-radius: 5px;
  }

  .key.large {
    font-size: 0.65rem;
  }

  .grid {
    padding: 4px;
    gap: 4px;
  }

  .row {
    gap: 3px;
  }

  .tile {
    border-radius: 4px;
    font-size: 1.5rem;
    border-width: 2px;
  }

  .icon-button {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .header {
    padding: 8px 10px;
  }

  .header-title {
    font-size: 1rem;
    letter-spacing: 1px;
  }

  /* Score widget: hide max-streak on tiny screens to save header space */
  .score-item:nth-child(2) {
    display: none;
  }

  .score-widget {
    gap: 8px;
  }
}

/* ===== Responsive: Very Small Phone (320px) ===== */

@media (max-width: 340px) {
  .keyboard {
    padding: 2px;
    gap: 3px;
  }

  .keyboard-row {
    gap: 1px;
  }

  .key {
    height: 48px;
    font-size: 0.78rem;
    border-radius: 4px;
  }

  .key.large {
    font-size: 0.6rem;
  }

  .header-title {
    font-size: 0.9rem;
    letter-spacing: 0;
  }

  .difficulty-widget {
    font-size: 0.72rem;
    padding: 3px 6px;
  }

  .icon-button {
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
  }
}

/* ===== Legal Pages ===== */

.legal-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
  line-height: 1.6;
  color: var(--color-text);
  overflow-wrap: anywhere;
  hyphens: auto;
}

.legal-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-unknown);
}

.legal-header h2 {
  color: var(--color-text);
  margin: 0;
}

.legal-body {
  padding: 0 4px;
}

.legal-body h2 {
  color: var(--color-correct);
  margin-top: 28px;
  margin-bottom: 12px;
  font-size: 1.2rem;
}

.legal-body h3 {
  margin-top: 18px;
  margin-bottom: 8px;
  font-size: 1rem;
  opacity: 0.9;
}

.legal-body p {
  margin: 0 0 10px 0;
  font-size: 0.95rem;
  line-height: 1.6;
}

.legal-body ul {
  margin: 0 0 14px 0;
  padding-left: 22px;
}

.legal-body li {
  margin-bottom: 8px;
}

.legal-page a,
.legal-page .editorial-links a {
  color: #2196F3;
  text-decoration: none;
}

.legal-page a:hover {
  text-decoration: underline;
}

/* ===== SEO Content ===== */

.seo-content {
  width: 100%;
  box-sizing: border-box;
  padding: 24px 16px 48px;
}

.seo-container {
  max-width: 760px;
  margin: 0 auto;
  color: var(--color-text);
  line-height: 1.65;
}

.seo-container h2 {
  margin: 0 0 14px;
  font-size: 1.4rem;
}

.seo-container h3 {
  margin: 18px 0 8px;
  font-size: 1.05rem;
}

.seo-container p {
  margin: 0 0 10px;
}

.seo-list {
  margin: 8px 0 14px;
  padding-left: 20px;
}

.seo-list li {
  margin-bottom: 6px;
}

.seo-links {
  margin-top: 16px;
  font-size: 0.95rem;
}

.seo-links a {
  color: inherit;
}

.seo-faq {
  margin-top: 18px;
}

/* ===== Home Content ===== */

.home-page {
  width: 100%;
}

.home-content {
  width: 100%;
  box-sizing: border-box;
  padding: 0 16px 56px;
}

.home-content-shell {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.content-panel {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

[data-theme="light"] .content-panel {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
}

.content-panel h2,
.content-panel h3,
.home-link-card h3 {
  margin: 0 0 12px;
}

.content-panel p,
.home-card li,
.home-link-card p,
.faq-entry p {
  line-height: 1.7;
}

.section-eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.78rem;
  opacity: 0.65;
}

.feature-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.feature-pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(76, 175, 80, 0.14);
  border: 1px solid rgba(76, 175, 80, 0.25);
  color: var(--color-text);
  font-size: 0.88rem;
}

[data-theme="light"] .feature-pill {
  background: rgba(76, 175, 80, 0.1);
  border-color: rgba(56, 142, 60, 0.18);
}

.home-grid,
.home-link-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.home-card,
.home-link-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 20px;
}

[data-theme="light"] .home-card,
[data-theme="light"] .home-link-card {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.07);
}

.home-card ul,
.content-list {
  margin: 0;
  padding-left: 20px;
}

.home-card li,
.content-list li {
  margin-bottom: 10px;
}

.faq-entry + .faq-entry {
  margin-top: 14px;
}

.faq-entry h4 {
  margin: 0 0 6px;
}

.home-link-card {
  color: inherit;
  text-decoration: none;
  transition: transform 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
}

.home-link-card:hover {
  transform: translateY(-2px);
  border-color: rgba(33, 150, 243, 0.35);
  background: rgba(33, 150, 243, 0.08);
}

[data-theme="light"] .home-link-card:hover {
  background: rgba(33, 150, 243, 0.06);
}

.home-footer-links {
  padding: 4px 4px 0;
  text-align: center;
  font-size: 0.92rem;
  opacity: 0.75;
}

.home-footer-links a {
  color: inherit;
  text-decoration: none;
}

.home-footer-links a:hover {
  text-decoration: underline;
}

/* ===== Über-Page ===== */

.ueber-store-badge {
  margin: 8px 0 14px;
}

.ueber-store-badge img {
  height: 40px;
  background: #000;
  border-radius: 6px;
}

[data-app-hydrated="true"] .prerender-legal {
  display: none;
}

/* Editorial content remains visible after the game mounts. */
.editorial-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-top: 24px;
}

.game-footer {
  margin: 0;
  padding: 8px 16px 16px;
  font-size: 0.85rem;
}

.seo-container a,
.editorial-links a,
.support-panel a,
.finish-support a {
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.support-panel {
  margin-top: 28px;
  padding: 16px 20px 20px;
  border: 1px solid var(--color-unknown);
  border-radius: 12px;
}

.support-panel h3 { margin-top: 0; }
.finish-support { margin: 8px 0 0; font-size: 0.85rem; text-align: center; }
.finish-play-link {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  min-height: 44px; max-width: 100%; box-sizing: border-box; padding: 10px 12px;
  border: 1px solid var(--color-unknown); border-radius: 10px;
  color: var(--color-text); text-decoration: none; text-align: left;
}
.finish-play-link > i { flex-shrink: 0; font-size: 1.2rem; }
.finish-play-link > span { min-width: 0; }
.finish-play-caption { display: block; font-size: 0.75rem; line-height: 1.5; }
.finish-play-label { display: block; font-size: 0.85rem; line-height: 1.5; text-decoration: underline; text-underline-offset: 3px; }
.finish-play-link:hover { background: var(--color-key-bg); }
.finish-play-link:focus-visible { outline: 2px solid var(--color-text); outline-offset: 3px; }
@media (max-width: 600px) {
  .finish-buttons { flex-direction: column; width: 100%; }
  .finish-buttons button { width: 100%; min-height: 44px; justify-content: center; }
}
.guide-page { max-width: 760px; }
.legal-header h1 { margin: 0; font-size: 1.5rem; min-width: 0; flex: 1; line-height: 1.3; }

#woerdl-guide { scroll-margin-top: 16px; }

/* Letter modes keep tile sizes consistent while fitting narrow screens. */
.grid-3 { --word-length: 3; max-width: 248px; }
.grid-4 { --word-length: 4; max-width: 324px; }
.grid-5 { --word-length: 5; }
.grid-6 { --word-length: 6; }
/* One quiet entry point; the four choices appear only on request. */
.mode-switch-trigger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 6px 12px; margin: 0 0 4px; max-width: calc(100% - 24px);
  border: 1px solid var(--color-unknown); border-radius: 9px; background: var(--color-surface);
  color: var(--color-text); font: inherit; font-size: 0.75rem; cursor: pointer;
}
.mode-switch-trigger i { font-size: 0.65rem; }
.mode-switch-trigger:hover, .mode-switch-trigger[aria-expanded="true"] { border-color: var(--color-text); }
.mode-switch-trigger:focus-visible { outline: 2px solid var(--color-text); outline-offset: 2px; }
.mode-switch-trigger:disabled { opacity: 0.5; cursor: wait; }
.anchored-picker {
  background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none;
  align-items: flex-start; padding-top: min(var(--picker-top), 35dvh); box-sizing: border-box;
}
.anchored-picker .dialog-content {
  width: 320px; max-width: calc(100% - 24px); padding: 0; border-radius: 14px;
  max-height: calc(100dvh - min(var(--picker-top), 35dvh) - 16px);
  animation: none;
}
.anchored-picker .dialog-scroll-content { padding: 16px; }
.anchored-picker h2 { font-size: 1rem; }
.mode-selector { width: 100%; }
.word-length-picker { display: flex; flex-direction: column; gap: 4px; }
.word-length-button {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-height: 48px; padding: 10px 12px; box-sizing: border-box;
  border: 1px solid transparent; border-radius: 8px; background: transparent;
  color: var(--color-text); font: inherit; font-size: 0.9rem; text-align: left; cursor: pointer;
}
.word-length-button[aria-pressed="true"] { background: var(--color-key-bg); border-color: var(--color-unknown); }
.word-length-button:focus-visible { outline: 2px solid var(--color-text); outline-offset: -2px; }
.word-length-button:disabled { opacity: 0.5; cursor: wait; }
.mode-option-label { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mode-option-detail { font-size: 0.75rem; opacity: 0.75; }
.mode-selected-mark { width: 16px; flex-shrink: 0; font-size: 0.8rem; text-align: center; }
@media (hover: hover) {
  .word-length-button:not(:disabled):hover { background: var(--color-key-bg); }
}
.mode-filter[aria-pressed="true"] {
  background: var(--color-text); color: var(--color-background); border-color: var(--color-text);
  box-shadow: inset 0 0 0 1px var(--color-text);
}
.mode-switch-hint { font-size: 0.7rem; line-height: 1.5; text-align: center; margin: 12px 0 0; opacity: 0.7; }
.stats-mode-picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.mode-filter { min-height: 44px; border-radius: 9px; border: 1px solid var(--color-unknown); background: var(--color-surface); color: var(--color-text); font: inherit; font-weight: 600; cursor: pointer; }
.mode-filter:focus-visible { outline: 2px solid var(--color-text); outline-offset: 3px; }
@container (max-width: 24rem) {
  .stats-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-mode-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@container (max-width: 12rem) {
  .stats-summary { grid-template-columns: minmax(0, 1fr); }
}
.stats-scope, .result-mode { text-align: center; font-weight: 600; font-size: 0.85rem; }
.stats-empty { background: var(--color-surface); border-radius: 10px; padding: 12px; font-size: 0.9rem; line-height: 1.5; }
.stats-note { font-size: 0.8rem; line-height: 1.5; opacity: 0.8; }
.rules-colors { padding-left: 20px; line-height: 1.6; }
.rules-colors li + li { margin-top: 8px; }
.how-to-content .example-row { display: flex; flex-wrap: nowrap; gap: 3px; }
.how-to-content .example-tile-wrapper { min-width: 0; flex: 0 1 40px; }
.how-to-content .example-tile-wrapper .tile { width: 100% !important; height: auto !important; box-sizing: border-box; }
.grid {
  --board-width: 400px; --board-min-height: 240px; --game-chrome-space: 335px;
  max-width: min(var(--board-width), calc(max(var(--board-min-height), 100dvh - var(--game-chrome-space)) * var(--word-length, 5) / 6));
}
.grid-3 { --board-width: 248px; }
.grid-4 { --board-width: 324px; }
@media (min-width: 600px) {
  .grid { --game-chrome-space: 375px; }
}
@media (max-height: 650px) {
  .grid { --board-min-height: 220px; }
}
@media (prefers-reduced-motion: reduce) {
  .tile, .key, .mode-selector .word-length-button { transition: none; }
  .tile.tile-pop, .tile.tile-flip, .row-shake, .dialog-content { animation: none; }
}

/* Keep navigation comfortable to tap, including with enlarged text. */
@media (max-width: 600px) {
  .header { flex-wrap: wrap; }
  .header-right { flex-wrap: wrap; justify-content: flex-end; max-width: 100%; }
  .icon-button { width: 44px; height: 44px; flex-shrink: 0; box-sizing: border-box; }
  .score-widget-button, .info-chip { min-height: 44px; }
}
.main { padding-bottom: env(safe-area-inset-bottom, 0px); box-sizing: border-box; }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
@media (max-width: 340px) {
  /* Keep the main header on one row; the full totals remain in Statistics. */
  .score-item:nth-child(3) { display: none; }
}

/* Help pages: short sections, visual examples, and optional detail. */
.info-page { max-width: 680px; padding: 24px 20px 40px; overflow-wrap: anywhere; }
.info-page h1 { font-size: clamp(1.8rem, 5vw, 2.5rem); line-height: 1.2; margin: 20px 0 16px; }
.info-page h2 { font-size: 1.2rem; line-height: 1.4; margin: 0 0 12px; }
.info-page section { margin: 32px 0; scroll-margin-top: 20px; }
.info-page p { margin: 0 0 12px; }
.info-page li + li { margin-top: 10px; }
.info-page a { text-decoration: underline; text-underline-offset: 3px; }
.info-page .page-back,
.legal-page .page-back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.legal-page h1 {
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  line-height: 1.2;
  margin: 16px 0;
}
.page-intro { font-size: 1.05rem; opacity: 0.85; }
.guide-jumps { display: flex; flex-wrap: wrap; gap: 8px; margin: 24px 0; }
.guide-jumps a { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border: 1px solid var(--color-unknown); border-radius: 8px; text-decoration: none; background: var(--color-surface); }
.guide-example { padding: 16px; margin: 12px 0; background: var(--color-surface); border: 1px solid var(--color-unknown); border-radius: 12px; }
.guide-example-tiles { display: flex; gap: 5px; margin-bottom: 12px; }
.guide-letter { display: flex; justify-content: center; align-items: center; width: 42px; height: 46px; font-weight: 800; font-size: 1.2rem; border-radius: 5px; color: #fff; }
.guide-letter.correct { background: var(--color-correct); }
.guide-letter.present { background: var(--color-present); }
.guide-letter.missing { background: var(--color-missing); color: var(--color-text); }
.guide-example p { margin: 0; }
.guide-faq { border-top: 1px solid var(--color-unknown); }
.guide-faq summary { cursor: pointer; padding: 14px 4px; min-height: 44px; box-sizing: border-box; font-weight: 600; line-height: 1.5; }
.guide-faq > div { padding: 0 4px 14px; line-height: 1.6; }
.guide-faq p { margin: 0 0 12px; }
.rules-intro { font-size: 1.05rem; line-height: 1.6; }
.rules-steps { padding-left: 22px; line-height: 1.6; }
.rules-steps li + li { margin-top: 8px; }
.how-to-content { line-height: 1.5; }
.how-to-content h3 { font-size: 1rem; margin-top: 24px; }
.rules-more a { color: #2196F3; display: inline-block; padding: 8px 0; text-underline-offset: 3px; }
.guide-faq summary:focus-visible, .info-page a:focus-visible, .legal-page a:focus-visible { outline: 2px solid var(--color-text); outline-offset: 3px; }

/* The invitation stays below the result; never covers the board. */
.app-transfer-card {
  margin: 20px 0; padding: 18px; border: 1px solid var(--color-unknown);
  border-radius: 14px; text-align: left;
}
.app-transfer-card h4 { margin: 0 0 8px; }
.app-transfer-card p { line-height: 1.5; }
.app-transfer-card .primary-button, .transfer-page .primary-button,
.transfer-page .secondary-button {
  display: inline-block; box-sizing: border-box; max-width: 100%;
  white-space: normal; text-align: center; text-decoration: none; margin: 6px 0;
}
.transfer-text-button {
  display: block; background: transparent; border: 0; color: inherit;
  padding: 12px 0; cursor: pointer; text-decoration: underline; font: inherit;
}
.transfer-page { max-width: 620px; margin: 0 auto; padding: 24px 20px 48px; line-height: 1.6; }
.transfer-page h1 { font-size: clamp(1.6rem, 6vw, 2.2rem); line-height: 1.2; }
.transfer-page h2 { font-size: 1.2rem; margin-top: 28px; }
.transfer-page .secondary-button { margin-right: 8px; }
.transfer-code { font-family: monospace; font-size: 1.1rem; overflow-wrap: anywhere; user-select: all; }
/* Link defaults must not override readable call-to-action labels. */
.transfer-page .primary-button, .app-transfer-card a.primary-button {
  color: #fff;
}
.transfer-page .secondary-button {
  color: #fff;
}

.feedback-card { margin: 18px 0; padding: 16px; border: 1px solid var(--color-unknown); border-radius: 12px; text-align: left; }
.feedback-card h4 { margin: 0 0 8px; }
.feedback-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.feedback-options .secondary-button { padding: 10px 14px; min-height: 44px; white-space: normal; }

.settings-help-links {
  display: grid;
  gap: 8px;
}

.settings-help-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  box-sizing: border-box;
  border: 1px solid var(--color-unknown);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.settings-help-link:hover {
  border-color: var(--color-text);
}

.settings-help-link:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

/* Keep the game within the available window; only previous guesses scroll. */
.main {
  height: 100dvh;
  min-height: 440px;
  max-height: 1000px;
  margin: 0 auto;
}
.header {
  max-width: 680px;
  flex-shrink: 0;
  gap: 8px;
}
.header-title { font-size: clamp(0.9rem, 3.5vw, 1.5rem); }
.header-right { gap: 4px; }
.icon-button { width: 44px; height: 44px; flex-shrink: 0; box-sizing: border-box; }
.mode-switch-trigger { flex-shrink: 0; font-size: 0.875rem; }
.game-area {
  min-height: 0;
  gap: 8px;
  padding: 8px 0;
  max-height: 720px;
  margin-block: auto;
}
.game-area:has(.grid-6) { max-height: 620px; }
.board-viewport {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 96px;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  container-type: size;
}
.board-viewport .grid {
  flex-shrink: 0;
  margin-block: auto;
  gap: 5px;
  --board-min-height: 264px;
  max-width: min(var(--board-width), calc(max(var(--board-min-height), 100cqh) * var(--word-length, 5) / 6));
}
.board-viewport .row { gap: 5px; }
.keyboard { flex-shrink: 0; }
.key { min-width: 0; font-size: clamp(14px, 3.8vw, 1.1rem); }
.key.large { font-size: clamp(10px, 2.7vw, 0.8rem); }
.key:focus-visible, .icon-button:focus-visible, .score-widget-button:focus-visible,
.primary-button:focus-visible, .secondary-button:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}
.mode-option-detail { line-height: 1.4; }
.mode-switch-hint { font-size: 0.8rem; }
.stats-mode-picker .mode-filter { overflow-wrap: normal; }

/* Results keep their actions available while the details can scroll. */
.dialog-content.dialog-with-actions {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}
.dialog-scroll-content { min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 28px; scrollbar-width: thin; }
.dialog-actions {
  flex-shrink: 0;
  padding: 12px 28px 20px;
  border-top: 1px solid var(--color-unknown);
  background: var(--color-surface);
}
.dialog-actions .finish-buttons { margin: 0; width: 100%; }
.dialog-actions .finish-buttons > button { flex: 1; min-width: 0; justify-content: center; }
.dialog-actions button { margin-top: 0; min-height: 44px; }
.finish-word-row { width: 100%; max-width: 284px; }
.finish-word-row .tile { min-width: 0; flex: 1 1 0; box-sizing: border-box; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

@media (max-width: 600px) {
  .header { padding: 6px 8px; }
  .dialog-scroll-content { padding: 20px 16px; }
  .dialog-actions { padding: 12px 16px; }
}
@media (max-width: 380px) {
  .header { gap: 4px; }
  .header-right { gap: 2px; }
  .score-widget-button { padding: 5px; }
  .dialog-header { gap: 8px; padding: 8px 10px; }
  .dialog-header h2 { font-size: 1rem; }
  .settings-help-link { padding: 8px 10px; gap: 6px; }
  .settings-help-link > span[aria-hidden="true"] { display: none; }
}

/* A short, wide window gets a board beside the keyboard. */
@media (max-height: 540px) and (min-width: 480px) {
  .main { min-height: 280px; }
  .header { max-width: 960px; padding: 4px 12px; }
  .mode-switch-trigger { margin-bottom: 0; }
  .game-area {
    flex-direction: row;
    align-items: center;
    max-width: 960px;
    padding: 4px 8px 8px;
    gap: 12px;
  }
  .board-viewport { align-self: stretch; flex: 0 1 38%; min-width: 0; min-height: 0; }
  .board-viewport .grid { --board-min-height: 264px; }
  .keyboard { flex: 1; width: 0; max-width: 600px; padding: 2px; gap: 3px; }
  .keyboard-row { gap: 2px; }
  .key { height: 48px; font-size: 14px; }
  .key.large { font-size: 10px; }
}

/* Anchoring must not consume the menu's usable height. */
@media (max-height: 650px), (max-width: 360px) {
  .anchored-picker { padding: 8px; align-items: center; }
  .anchored-picker .dialog-content {
    width: 360px;
    max-width: 100%;
    max-height: calc(100dvh - 16px);
    padding: 0;
  }
  .anchored-picker .dialog-scroll-content { padding: 12px; }
}
@media (max-height: 420px) and (min-width: 480px) {
  .anchored-picker .dialog-content { width: 540px; }
  .word-length-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mode-switch-hint { margin-top: 8px; }
  .dialog-actions { padding: 8px 16px; }
  .dialog-actions .finish-buttons { flex-direction: row; }
}

/* Useful first paint while the game downloads; replaced when Jaspr mounts. */
.startup-page {
  box-sizing: border-box;
  min-height: 100svh;
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  line-height: 1.6;
}
.startup-page h1 { font-size: clamp(1.5rem, 5vw, 2rem); }
.startup-page a { color: var(--color-text); }
.startup-status { opacity: 0.7; }
.startup-noscript { max-width: 600px; margin: 0 auto; padding: 16px; text-align: center; }

/* The component renders one set of keys in visual reading order.
   Phones and tablets with enough height share the wider four-row input. */
.keyboard.keyboard-roomy {
  display: grid;
  grid-template-columns: repeat(20, minmax(0, 1fr));
  grid-template-rows: repeat(4, 58px);
  max-width: 500px;
  padding: 4px 2px 8px;
  column-gap: 1px;
  row-gap: 4px;
}
.keyboard-roomy .keyboard-row { display: contents; }
.keyboard-roomy .key {
  grid-row: var(--key-row);
  grid-column: var(--key-column) / span var(--key-span, 2);
  height: 58px;
  font-size: 17px;
  border-radius: 7px;
}
.keyboard-roomy .key.large { font-size: 15px; }

/* Information has the same clear reading rhythm as the game panels. */
.settings-link-copy { display: flex; flex-direction: column; gap: 4px; text-align: left; min-width: 0; }
.settings-link-copy > span { font-size: clamp(15px, 0.88rem, 24px); font-weight: 600; overflow-wrap: normal; }
.settings-link-copy small { font-size: clamp(12px, 0.78rem, 19px); line-height: 1.35; font-weight: 400; color: var(--color-text); opacity: .8; }
.info-page > section, .info-page > div > section {
  border: 1px solid var(--color-unknown);
  border-radius: 14px;
  background: var(--color-surface);
  padding: 20px;
  margin: 18px 0;
}
.info-page section h2 { margin-top: 0; color: var(--color-correct); }
.info-page p, .info-page li { line-height: 1.65; }
.info-page .page-intro { font-size: 1.15rem; line-height: 1.6; max-width: 58ch; }
.how-to-content .rules-intro { padding: 14px 16px; border: 1px solid var(--color-unknown); border-radius: 12px; background: var(--color-surface); }
.how-to-content .rules-steps { padding-left: 24px; }
.how-to-content .rules-steps li { padding-left: 6px; margin: 10px 0; }
.how-to-content .rules-steps li::marker { color: var(--color-correct); font-weight: 700; }
.how-to-content .rules-colors { list-style: none; padding: 0; }
.how-to-content .rules-colors li { position: relative; padding: 10px 12px 10px 38px; margin: 8px 0; border: 1px solid var(--color-unknown); border-radius: 10px; }
.clue-swatch { position: absolute; top: 14px; left: 12px; width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--color-unknown); }
.clue-swatch.correct { background: var(--color-correct); }
.clue-swatch.present { background: var(--color-present); }
.clue-swatch.missing { background: var(--color-missing); }
.word-information { width: 100%; box-sizing: border-box; text-align: left; padding: 16px; border: 1px solid var(--color-unknown); border-radius: 12px; background: var(--color-surface); margin: 16px 0 4px; }
.word-information h4 { margin: 0 0 8px; font-size: .9rem; color: var(--color-correct); }
.word-information .word-meaning { margin: 0 0 16px; line-height: 1.6; }
.word-frequency { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding-top: 12px; border-top: 1px solid var(--color-unknown); font-size: .85rem; }
.information-label { padding: 5px 10px; border: 1px solid var(--color-unknown); border-radius: 8px; color: var(--color-text); background: var(--color-surface); }
.word-information .word-frequency-help { font-size: .85rem; line-height: 1.5; opacity: .8; margin: 10px 0 0; }
@media (max-width: 380px) {
  .info-page > section, .info-page > div > section { padding: 16px; }
}

/* Essential result information stays ahead of decoration and optional details. */
.result-summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
  padding-top: 0;
}
.result-summary .result-mode, .result-summary h3, .result-summary .finish-guess-count { margin: 0; }
.result-summary h3 { font-size: 1.35rem; line-height: 1.25; }
.result-summary .finish-word-row { margin: 0; }
.legal-page button { max-width: 100%; box-sizing: border-box; white-space: normal; overflow-wrap: anywhere; }
.legal-body a { overflow-wrap: anywhere; }
.share-status { width: 100%; margin: 0; font-size: .9rem; line-height: 1.5; }
.share-status:empty {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.finish-dialog-lost .word-information { margin-top: 0; }
.share-fallback-text {
  width: 100%; min-height: 8rem; max-width: 100%; box-sizing: border-box;
  padding: 12px; border: 1px solid var(--color-key-border); border-radius: 8px;
  color: var(--color-text); background: var(--color-background); font: inherit; line-height: 1.5;
  resize: vertical;
}
.share-retry, .import-undo { align-self: flex-start; }
.import-confirmation { margin-top: 16px; padding: 14px; border: 1px solid var(--color-key-border); border-radius: 10px; }
.import-confirmation h4 { text-transform: none; opacity: 1; }
.import-summary { line-height: 1.5; }
.import-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.import-actions > button { min-width: 0; max-width: 100%; }
.import-status { line-height: 1.5; }
@media (max-height: 540px) {
  .finish-dialog-content { gap: 10px; }
  .finish-dialog-header { display: none; }
  .dialog-with-actions .dialog-scroll-content { padding: 12px 16px; }
  .result-summary { gap: 6px; padding-top: 0; }
  .result-summary .result-mode { font-size: .75rem; }
  .result-summary h3 { font-size: 1rem; }
  .result-summary .finish-guess-count { font-size: .8rem; line-height: 1.3; }
  .result-summary .finish-word-row { margin: 0; }
  .dialog-actions { padding: 8px 16px; }
  .dialog-actions .finish-buttons { flex-direction: row; gap: 8px; }
  .dialog-actions button { padding: 10px 14px; }
}
@media (max-height: 420px) and (min-width: 480px) {
  .result-summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; text-align: left; align-items: center; }
  .result-summary h3 { grid-row: 1; grid-column: 1; }
  .result-summary .finish-guess-count { grid-row: 1; grid-column: 2; text-align: right; }
  .result-summary .finish-word-row { grid-row: 2; grid-column: 1 / -1; justify-self: center; }
  .result-summary .result-mode { grid-row: 3; grid-column: 1 / -1; text-align: center; }
}

@media (max-height: 540px) and (max-width: 479px) {
  .dialog-actions .finish-buttons { flex-direction: column; }
  .dialog-actions .finish-buttons > button { flex: 0 0 auto; width: 100%; }
}
@media (max-height: 650px) and (max-width: 479px) {
  /* Leave the outcome, answer and count visible above the pinned actions. */
  .result-summary .result-mode { order: 1; }
}

.completed-game-actions {
  display: flex; flex-wrap: wrap; flex-shrink: 0; gap: 8px;
  width: 100%; max-width: 500px; padding: 12px; box-sizing: border-box;
}
.completed-game-actions > button {
  display: flex; flex: 1 1 10rem; min-width: 0; align-items: center; justify-content: center;
  gap: 8px; margin: 0; min-height: 44px; padding: 12px 16px;
}
.completed-game-actions > button span { min-width: 0; }
.key:disabled:not(.action) { opacity: .55; cursor: wait; }
@media (max-height: 540px) and (min-width: 480px) {
  .completed-game-actions { flex: 1; width: 0; }
}
