.language-home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 1000px;
  min-height: 100svh;
  margin: 0 auto;
  padding: 16px 20px;
}

.language-home > .brand {
  font-size: 30px;
  line-height: 1.2;
}

.language-home h1 {
  max-width: 760px;
  margin: 12px 0 6px;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.12;
}

.language-home > p {
  font-size: 20px;
  line-height: 1.25;
}

.language-home > .language-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 360px;
  margin-top: 16px;
}

.language-home .language-actions .button {
  flex: 1 0 136px;
  min-height: 42px;
  padding: 10px 12px;
  font-size: 12px;
  white-space: nowrap;
}

.root-demo {
  display: block;
  width: min(100%, clamp(180px, calc(100svh - 340px), 300px));
  margin: 18px auto 0;
  color: #164f47;
  text-align: center;
}

.root-demo-link {
  display: block;
  border-radius: 4px;
  cursor: pointer;
}
.root-demo-link:focus-visible { outline: 3px solid #b44839; outline-offset: 4px; }

.root-demo-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid #164f47;
  border-radius: 4px;
  background: #f7f6f0;
  direction: ltr;
}

.root-demo-cell {
  display: grid;
  min-width: 0;
  place-items: center;
  aspect-ratio: 1;
  border-right: 1px solid #dadfd6;
  border-bottom: 1px solid #dadfd6;
  font-family: var(--serif, Georgia, serif);
  font-size: clamp(16px, 3.2svh, 24px);
  line-height: 1;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.root-demo-cell:nth-child(9n) { border-right: 0; }
.root-demo-cell:nth-child(n + 73) { border-bottom: 0; }
.root-demo-cell.is-box-right { border-right: 2px solid #164f47; }
.root-demo-cell.is-box-bottom { border-bottom: 2px solid #164f47; }
.root-demo-cell.is-given { font-weight: 600; }
.root-demo-cell.is-resolved { color: #546e64; }
.root-demo-cell.is-active { background: #f6e8e2; color: #b44839; }
.root-demo-digit { display: block; }
.root-demo-cell.is-entering > .root-demo-digit {
  animation: root-demo-enter 150ms ease-out both;
}
.root-demo[data-state="paused"] .root-demo-digit,
.root-demo[data-state="suspended"] .root-demo-digit {
  animation-play-state: paused;
}

@keyframes root-demo-enter {
  from { opacity: 0; transform: translateY(-0.35em) scale(0.65); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.root-demo-caption {
  display: grid;
  gap: 0;
  margin-top: 8px;
  color: #5d6d63;
  font-size: 12px;
  line-height: 1.4;
}

.root-demo-toggle {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  margin-top: 6px;
  padding: 8px 14px;
  border: 1px solid #dadfd6;
  border-radius: 5px;
  background: transparent;
  color: #164f47;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.root-demo-toggle[hidden] { display: none; }
.root-demo-toggle:hover { border-color: #164f47; background: #eaf0e5; }
.root-demo-toggle:focus-visible { outline: 3px solid #b44839; outline-offset: 3px; }

@media (min-width: 700px) and (max-height: 620px) {
  .language-home {
    display: grid;
    grid-template-columns: minmax(0, 520px) minmax(0, 300px);
    align-content: center;
    column-gap: 32px;
    row-gap: 12px;
  }
  .language-home > .brand,
  .language-home > h1,
  .language-home > p,
  .language-home > .language-actions { grid-column: 1; justify-self: center; margin: 0; }
  .language-home > .root-demo {
    grid-column: 2;
    grid-row: 1 / 5;
    width: min(100%, calc(100svh - 140px), 300px);
    margin: 0;
    justify-self: center;
  }
}

@media (max-width: 699px) and (max-height: 640px) {
  .language-home { padding: 12px 16px; }
  .language-home > .brand { font-size: 27px; }
  .language-home h1 { margin: 8px 0 4px; }
  .language-home > p { font-size: 18px; }
  .language-home > .language-actions { margin-top: 12px; }
  .language-home .language-actions .button { flex: 1 1 0; min-width: 0; padding-inline: 8px; }
  .root-demo { width: min(100%, clamp(168px, calc(100svh - 320px), 260px)); margin-top: 12px; }
  .root-demo-caption { margin-top: 6px; font-size: 11.5px; line-height: 1.3; }
  .root-demo-toggle { min-height: 36px; margin-top: 4px; padding-block: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .root-demo-cell { transition: none; }
  .root-demo-cell.is-entering > .root-demo-digit { animation: none; }
}
