/* ============================================================================
   Common Ground.

   Same tokens and the same tile language as the other two games. The one rule
   worth stating: a word tile is a thumb target, never smaller than 44px tall,
   and the grid is three across on a phone so the longest words still fit
   without shrinking the type into unreadability.
   ========================================================================== */

.ground-shell {
  width: min(100%, 40rem);
  margin: clamp(0.5rem, 2.5vw, 1.5rem) auto;
  padding-inline: clamp(0.5rem, 3vw, 1rem);
}

.ground-board {
  padding: clamp(0.9rem, 3.5vw, 1.75rem);
}

.ground-lead {
  max-width: 28rem;
  margin: 0.5rem auto 0;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink-2);
}

/* --------------------------------------------------------- solved groups -- */

.ground-found {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.ground-found:empty {
  margin-bottom: 0;
}

.ground-group {
  padding: 0.7rem 0.9rem;
  border: 2px solid;
  border-radius: var(--r-md);
  text-align: center;
  animation: ground-lock 0.35s var(--ease);
}

@keyframes ground-lock {
  from { transform: scale(0.96); opacity: 0.4; }
  to { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .ground-group { animation: none; }
}

.ground-group.is-a { background: var(--row-0-wash); border-color: var(--row-0-line); }
.ground-group.is-b { background: var(--row-2-wash); border-color: var(--row-2-line); }
.ground-group.is-c { background: var(--row-3-wash); border-color: var(--row-3-line); }
.ground-group.is-d { background: var(--row-1-wash); border-color: var(--row-1-line); }

.ground-group__pivot {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 4vw, 1.4rem);
  line-height: 1.1;
  text-transform: lowercase;
  color: var(--ink);
}

.ground-group__words {
  margin: 0.2rem 0 0;
  font-size: 0.88rem;
  font-weight: 600;
  text-transform: lowercase;
  color: var(--ink);
}

/* ------------------------------------------------------------- the board -- */

.ground-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.35rem, 1.8vw, 0.6rem);
}

/* Four across at every width, the way the genre lays it out: sixteen words in
   a 4x4 is the shape players recognise, and breaking it into threes loses that
   at exactly the size where most people play. The type shrinks instead, with a
   floor that keeps the longest words readable. */
@media (max-width: 420px) {
  .ground-grid { gap: 0.3rem; }
}

.ground-word {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 0.35rem 0.25rem;
  appearance: none;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: clamp(0.66rem, 2.6vw, 0.95rem);
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  text-transform: lowercase;
  overflow-wrap: anywhere;
  color: var(--ink);
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: var(--r-sm);
  transition: background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}

.ground-word:not(:disabled):hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

/* Selected is deliberately loud: on a phone, four picked out of twelve has to
   be obvious at a glance before you commit a mistake. */
.ground-word.is-selected {
  color: var(--action-ink);
  background: var(--action);
  border-color: var(--action);
}

.ground-word.shake {
  animation: shake 0.34s var(--ease);
}

/* ---------------------------------------------------------------- feedback */

.ground-status {
  min-height: 1.5rem;
  margin: 0.85rem 0 0;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-2);
}

.ground-status.is-bad { color: var(--row-1-line); }
.ground-status.is-good { color: var(--row-3-line); }

.ground-lives {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 0.35rem 0 0.85rem;
}

.ground-lives__label {
  margin-inline-end: 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.ground-life {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ink-2);
  transition: background var(--t-fast) var(--ease);
}

.ground-life.is-spent {
  background: color-mix(in srgb, var(--ink-3) 28%, transparent);
}

/* ------------------------------------------------------------------ ending */

.ground-done {
  margin-top: 1.25rem;
  padding: clamp(0.9rem, 3vw, 1.4rem);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  text-align: center;
}

.ground-done__title {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 4vw, 1.5rem);
}

.ground-done__note {
  margin: 0 0 0.85rem;
  font-size: 0.92rem;
  color: var(--ink-2);
}

.ground-done .btn--block + .btn--block {
  margin-top: 0.5rem;
}

/* ----------------------------------------------------------------- archive */

.ground-archive {
  margin-top: clamp(1rem, 3vw, 1.5rem);
  padding: clamp(0.9rem, 3vw, 1.5rem);
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}

.ground-archive h2 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.05rem, 3.5vw, 1.25rem);
}

.ground-archive__list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.35rem;
}

.ground-archive__day {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.ground-archive__day:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.ground-archive__day.is-here {
  border-color: var(--brand-500);
}

.ground-archive__mark {
  font-size: 0.8rem;
  color: var(--ink-3);
}

/* The way out to the full list, which lives in the puzzle archive. */
.ground-archive__all {
  margin: 0.75rem 0 0;
  font-size: 0.88rem;
  font-weight: 600;
}

/* ------------------------------------------------------------------- prose */

.ground-about {
  margin-top: clamp(1.25rem, 4vw, 2rem);
  padding: clamp(1rem, 3.5vw, 1.75rem);
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}

.ground-about h2 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.1rem, 3.5vw, 1.35rem);
}

.ground-about p {
  max-width: var(--prose-max);
  margin-bottom: 0.9rem;
  color: var(--ink-2);
  line-height: 1.7;
}

.ground-about p:last-child { margin-bottom: 0; }


/* --------------------------------------------------- the worked example --
   A finished board inside the rules, using the same group boxes the game
   itself draws, so the example and the real thing are visibly one game.   */

.ground-example {
  display: grid;
  gap: 0.5rem;
  margin: 1.25rem 0;
  padding: clamp(0.6rem, 2.5vw, 1rem);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.ground-example .example-title {
  margin: 0 0 0.1rem;
}

/* No entrance animation on an example: nothing was just solved. */
.ground-example .ground-group {
  animation: none;
}
