/* ── CSS variable set by JS: --xw-grid-size defaults to 15 ── */

/* ── Grid table ── */
.xw-table {
  border-collapse: collapse;
  display: block;
  width: fit-content;
  margin: 0 auto;
  touch-action: manipulation; /* removes 300ms tap delay */
}

.xw-table td {
  /* Fills 90% of viewport width divided by grid size, capped at 44px */
  width:  min(44px, calc(90vw / var(--xw-grid-size, 15)));
  height: min(44px, calc(90vw / var(--xw-grid-size, 15)));
  padding: 0;
  position: relative;
  border: 1px solid #aaa;
  box-sizing: border-box;
  touch-action: manipulation;
}

.xw-black {
  background: #222;
  border-color: #222;
}

.xw-letter {
  background: #fff;
}

.xw-letter.xw-active-word {
  background: #d4eaf7;
}

.xw-letter.xw-active-cell {
  background: #2185d0 !important;
}

.xw-letter.xw-correct {
  background: #d4f7d4;
}

.xw-letter.xw-wrong {
  background: #f7d4d4;
}

.xw-letter.xw-revealed {
  background: #fff8e1;  /* soft amber: "I peeked" */
}

/* Cell number badge — scales with cell size */
.xw-num {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: clamp(6px, calc(min(44px, 90vw / var(--xw-grid-size, 15)) * 0.28), 10px);
  line-height: 1;
  color: #333;
  pointer-events: none;
  user-select: none;
  z-index: 1;
}

/* Letter input */
.xw-input {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0; /* avoid inset — not in all mobile browsers */
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font-size: clamp(12px, calc(min(44px, 90vw / var(--xw-grid-size, 15)) * 0.52), 22px);
  font-weight: 700;
  text-transform: uppercase;
  color: #1a1a1a;
  cursor: default;
  outline: none;
  padding: 0;
  caret-color: transparent;
  z-index: 2;
  touch-action: manipulation;
  /* Hide browser UI artifacts on mobile */
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

/* Active cell: white text on blue */
.xw-active-cell .xw-input {
  color: #fff;
}

/* ── Mobile clue bar (inline, below grid) — hidden on desktop ── */
#mobile-clue-bar {
  display: none;
}

/* ── Clue list ── */
.clue-item {
  border-radius: 4px;
  transition: background .1s;
}

.clue-item:hover {
  background: #f0f4f8;
}

.clue-item.active-clue {
  background: #d4eaf7;
  font-weight: 600;
}

.xw-clue-num {
  font-weight: 700;
  margin-right: .25rem;
  color: #2185d0;
}

.xw-clue-len {
  color: #999;
  font-size: .85em;
}

/* ── Button toggle groups ── */
.active-choice {
  background-color: #2185d0 !important;
  color: #fff !important;
}

/* ── Mobile (≤ 767px) ── */
@media (max-width: 767px) {
  /* Show inline clue bar; hide desktop sidebar banner */
  #mobile-clue-bar {
    display: block;
    margin-top: .6rem;
    margin-bottom: 0;
    padding: .5rem .75rem;
    font-size: .95rem;
  }

  #active-clue-banner {
    display: none !important;
  }

  /* Clue lists: full width, comfortable tap targets */
  #clue-col {
    margin-top: .5rem;
  }

  .clue-item {
    padding: .55rem .4rem !important;
    font-size: .92rem;
    border-bottom: 1px solid #eee;
  }

  /* Accordion chevrons for clue sections */
  .xw-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: .4rem 0;
    user-select: none;
  }

  /* Action buttons: full width row */
  #puzzle-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: .4rem;
  }

  #puzzle-actions .button {
    text-align: center;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Ensure grid container doesn't add extra scroll */
  #grid-col .segment {
    padding: .5rem !important;
  }
}
