/* Styles for the game menu, Spelling Bee, and Letter Boxed. Loaded after
   style.css, so every theme's custom properties apply here too. */

/* ---------- Shared bits ---------- */
.pill-btn {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
  border-radius: 999px;
  padding: 0.65rem 1.15rem;
  min-width: 5.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.pill-btn:active {
  filter: brightness(0.85);
}

.pill-btn.round {
  min-width: 0;
  width: 3rem;
  height: 3rem;
  padding: 0;
  font-size: 1.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.link-btn {
  background: none;
  border: none;
  color: var(--color-text-dim);
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0.3rem;
}

.help-subhead {
  margin: 1rem 0 0.25rem;
  font-size: 1rem;
}

.help-keys {
  font-size: 0.8rem;
  color: var(--color-text-dim);
}

kbd {
  border: 1px solid var(--color-border-strong);
  border-radius: 4px;
  padding: 0 0.3rem;
  font-size: 0.75rem;
  font-family: inherit;
}

.result-text {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.result-stats small {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--color-text-dim);
}

.lb-table tr.lb-me td {
  font-weight: 700;
  color: var(--color-accent);
}

@keyframes game-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

.shake {
  animation: game-shake 0.4s ease;
}

/* ---------- Menu ---------- */
.menu-main {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0.75rem 1rem calc(0.85rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  overflow-y: auto;
}

.menu-top-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.menu-greeting {
  margin: 0.1rem 0;
  text-align: center;
  font-weight: 600;
  color: var(--color-text);
}

.menu-recap-btn {
  padding: 0.32rem 0.75rem;
  min-width: 0;
  font-size: 0.78rem;
}

.wordly-share-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 0.5rem 0 0.85rem;
}

.wordly-share-row {
  display: flex;
  gap: 4px;
}

.wordly-sq {
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 3px;
  background: var(--color-absent);
}

.wordly-sq.correct {
  background: var(--color-correct);
}

.wordly-sq.present {
  background: var(--color-present);
}

.menu-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.6rem;
  width: 100%;
}

@media (min-width: 660px) {
  .menu-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }
}

@media (min-width: 960px) {
  .menu-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
  }
}

.game-card {
  display: flex;
  align-items: center;
  gap: 0.95rem;
  padding: 0.85rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  color: var(--color-text);
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.game-card:hover,
.game-card:focus-visible {
  border-color: var(--color-accent);
  transform: translateY(-1px);
}

.game-card:active {
  transform: scale(0.99);
}

.game-icon {
  flex-shrink: 0;
  width: 4.2rem;
  height: 4.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-icon svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.icon-wordly {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  padding: 0.2rem;
}

.icon-wordly .t {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
  border-radius: 4px;
  background: var(--color-absent);
  color: var(--color-text);
}

.icon-wordly .t.correct {
  background: var(--color-correct);
  color: var(--key-text-on-color);
}

.icon-wordly .t.present {
  background: var(--color-present);
  color: var(--key-text-on-color);
}

.icon-bee polygon {
  fill: var(--bee-center, var(--color-present));
}

.icon-bee text {
  fill: var(--bee-center-text, var(--key-text-on-color));
  font-size: 44px;
  font-weight: 800;
  text-anchor: middle;
}

.icon-boxed rect {
  fill: var(--color-bg);
  stroke: var(--color-text);
  stroke-width: 3;
}

.icon-boxed polyline {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 3;
  stroke-linejoin: round;
}

.icon-boxed circle {
  fill: var(--color-bg);
  stroke: var(--color-text);
  stroke-width: 2.5;
}

.game-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.game-name {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.game-desc {
  font-size: 0.85rem;
  color: var(--color-text-dim);
}

.game-status {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-dim);
}

.game-status.done {
  color: var(--color-accent);
}

.menu-foot {
  margin-top: auto;
  text-align: center;
  font-size: 0.78rem;
  color: var(--color-text-dim);
}

/* ---------- Spelling Bee ---------- */
.bee-main {
  justify-content: flex-start;
}

.bee-game {
  width: 100%;
  max-width: 440px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}

.bee-rank {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: none;
  border: none;
  color: var(--color-text);
  padding: 0.35rem 0.1rem;
  cursor: pointer;
}

.bee-rank-name {
  font-weight: 800;
  font-size: 0.95rem;
  min-width: 6.2rem;
  text-align: left;
}

.bee-track {
  position: relative;
  flex: 1;
  height: 12px;
  display: flex;
  align-items: center;
}

.bee-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-border-strong);
}

.bee-track-fill {
  position: absolute;
  left: 0;
  height: 2px;
  background: var(--bee-center, var(--color-present));
  transition: width 0.3s ease;
}

.bee-track-dots {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bee-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-border-strong);
}

.bee-dot.done {
  background: var(--bee-center, var(--color-present));
}

.bee-dot.current {
  transform: scale(1.5);
  box-shadow: 0 0 0 2px var(--color-bg);
}

.bee-score {
  min-width: 2.2rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: var(--bee-center, var(--color-present));
  color: var(--bee-center-text, var(--key-text-on-color));
  font-weight: 800;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.bee-meta {
  min-height: 1.1rem;
  display: flex;
  justify-content: center;
  margin-top: -0.35rem;
}

.bee-found {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  text-align: left;
}

.bee-found-summary {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: pre;
  text-overflow: ellipsis;
}

.bee-found-caret {
  color: var(--color-text-dim);
  transition: transform 0.2s ease;
}

.bee-found[aria-expanded="true"] .bee-found-caret {
  transform: rotate(180deg);
}

.bee-found-panel {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-top: -0.3rem;
}

.bee-found-list,
.answers-list {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2;
  column-gap: 1.5rem;
}

.bee-found-list li,
.answers-list li {
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--color-border);
  break-inside: avoid;
  font-size: 0.95rem;
}

.bee-found-list li.pangram,
.answers-list li.pangram {
  font-weight: 800;
  color: var(--color-accent);
}

.answers-list li:not(.found) {
  color: var(--color-text-dim);
}

.answers-list li.found::after {
  content: " ✓";
  color: var(--color-accent);
}

/* When the found-words panel is open it takes over the hive's space. */
.bee-game.found-open .bee-input,
.bee-game.found-open .hive,
.bee-game.found-open .bee-controls,
.bee-game.found-open .link-btn {
  display: none;
}

.bee-input {
  min-height: 2.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text);
  margin-top: 0.3rem;
}

.bee-input .center {
  color: var(--bee-center, var(--color-present));
}

.bee-input .bad {
  color: var(--color-text-dim);
  opacity: 0.6;
}

.bee-input.accepted {
  animation: bee-pop 0.3s ease;
}

@keyframes bee-pop {
  50% { transform: scale(1.08); }
}

.bee-caret {
  display: inline-block;
  width: 2px;
  height: 1.8rem;
  margin-left: 2px;
  background: var(--bee-center, var(--color-present));
  animation: caret-blink 1s steps(1) infinite;
}

@keyframes caret-blink {
  50% { opacity: 0; }
}

.hive {
  width: min(78vw, 290px, 38dvh);
  height: auto;
  flex-shrink: 0;
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.hive-cell {
  cursor: pointer;
  transition: opacity 0.16s ease;
}

.hive-cell polygon {
  fill: var(--color-key-bg);
  stroke: var(--color-border);
  stroke-width: 1;
  transition: transform 0.1s ease;
  transform-box: fill-box;
  transform-origin: center;
}

.hive-cell text {
  fill: var(--color-key-text);
  font-size: 34px;
  font-weight: 800;
  text-anchor: middle;
  pointer-events: none;
}

.hive-cell.center polygon {
  fill: var(--bee-center, var(--color-present));
  stroke: none;
}

.hive-cell.center text {
  fill: var(--bee-center-text, var(--key-text-on-color));
}

.hive-cell.pressed polygon {
  transform: scale(0.92);
}

.hive.shuffling .hive-cell:not(.center) {
  opacity: 0;
}

.bee-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.2rem;
}

.rank-summary {
  color: var(--color-text-dim);
  font-size: 0.9rem;
}

.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rank-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-dim);
}

.rank-list li.done {
  color: var(--color-text);
}

.rank-list li.current {
  color: var(--bee-center-text, var(--key-text-on-color));
  background: var(--bee-center, var(--color-present));
  border-radius: 6px;
  font-weight: 800;
}

.answers-letters,
.answers-sides {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.answers-letters span,
.answers-sides span {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--color-key-bg);
  color: var(--color-key-text);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.answers-letters span.center {
  background: var(--bee-center, var(--color-present));
  color: var(--bee-center-text, var(--key-text-on-color));
}

.answers-summary {
  color: var(--color-text-dim);
  font-size: 0.85rem;
}

/* Themes whose "present" color is too dark or muted to read as the hive's
   highlighted center get an explicit center color instead. */
[data-theme="neon-city"] {
  --bee-center: #ffff00;
  --bee-center-text: #150f37;
}

[data-theme="ocean"] {
  --bee-center: #00f0ff;
  --bee-center-text: #041421;
}

[data-theme="neon-standard"] .hive-cell.center polygon,
[data-theme="neon-city"] .hive-cell.center polygon,
[data-theme="neon80s"] .hive-cell.center polygon,
[data-theme="synthwave"] .hive-cell.center polygon,
[data-theme="ocean"] .hive-cell.center polygon,
[data-theme="sunset"] .hive-cell.center polygon {
  filter: drop-shadow(0 0 6px var(--bee-center, var(--color-present)));
}

[data-theme="neon-standard"] .hive-cell:not(.center) polygon,
[data-theme="neon-city"] .hive-cell:not(.center) polygon,
[data-theme="neon80s"] .hive-cell:not(.center) polygon,
[data-theme="synthwave"] .hive-cell:not(.center) polygon {
  stroke: var(--color-accent);
  stroke-width: 1.5;
}

/* ---------- Letter Boxed ---------- */
.boxed-main {
  justify-content: flex-start;
}

.boxed-loading {
  margin: auto;
  color: var(--color-text-dim);
}

.boxed-game {
  width: 100%;
  max-width: 440px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.boxed-top {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding-top: 0.4rem;
}

.boxed-current {
  min-height: 2.6rem;
  min-width: 60%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 2px solid var(--color-border-strong);
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--color-text);
}

.boxed-current .placeholder {
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--color-text-dim);
}

.boxed-words {
  min-height: 1.3rem;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--color-accent);
  text-align: center;
  overflow-wrap: anywhere;
}

.boxed-meta {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.82rem;
  color: var(--color-text-dim);
}

.boxed-meta .daily-timer {
  font-size: 0.85rem;
}

.box {
  width: min(88vw, 340px, 46dvh);
  height: auto;
  flex-shrink: 0;
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
  /* Dragging across letters must not scroll or zoom the page. */
  touch-action: none;
}

.box-frame {
  fill: var(--color-surface);
  stroke: var(--color-text);
  stroke-width: 3;
}

.box-line {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 4;
  stroke-linejoin: round;
  stroke-linecap: round;
  opacity: 0.55;
}

.box-line.current {
  stroke: var(--bee-center, var(--color-present));
  stroke-dasharray: 7 6;
  opacity: 1;
}

.box-letter {
  cursor: pointer;
}

.box-drag {
  opacity: 0.6;
  pointer-events: none;
}

.box-hit {
  fill: transparent;
}

.box-dot {
  fill: var(--color-surface);
  stroke: var(--color-text);
  stroke-width: 2.5;
  transition: fill 0.15s ease;
}

.box-letter.used .box-dot {
  fill: var(--color-accent);
  stroke: var(--color-accent);
}

.box-letter.active .box-dot {
  fill: var(--bee-center, var(--color-present));
  stroke: var(--bee-center, var(--color-present));
}

.box-letter.last .box-dot {
  stroke: var(--color-text);
  stroke-width: 3;
}

.box-label {
  fill: var(--color-text);
  font-size: 25px;
  font-weight: 800;
  text-anchor: middle;
  pointer-events: none;
  /* Outline in the page color so labels stay readable over theme art. */
  stroke: var(--color-bg);
  stroke-width: 5px;
  stroke-linejoin: round;
  paint-order: stroke;
}

.box-letter.used .box-label {
  fill: var(--color-accent);
}

.box-letter:active .box-dot {
  transform: scale(1.2);
  transform-box: fill-box;
  transform-origin: center;
}

[data-theme="neon-standard"] .box-line,
[data-theme="neon-city"] .box-line,
[data-theme="neon80s"] .box-line,
[data-theme="synthwave"] .box-line,
[data-theme="ocean"] .box-line {
  filter: drop-shadow(0 0 4px var(--color-accent));
  opacity: 0.8;
}

/* ---------- Short viewports ---------- */
@media (max-height: 700px) {
  .bee-game,
  .boxed-game {
    gap: 0.35rem;
  }
  .bee-input,
  .boxed-current {
    font-size: 1.6rem;
    min-height: 2.2rem;
  }
  .pill-btn {
    padding: 0.5rem 1rem;
  }
  .pill-btn.round {
    width: 2.6rem;
    height: 2.6rem;
  }
}

/* Small dim text sits straight on the page background, which on image
   themes is busy art - a soft halo in the page color keeps it legible. */
.link-btn,
.boxed-meta,
.boxed-words,
.boxed-current .placeholder,
.bee-meta,
.menu-greeting,
.menu-foot {
  text-shadow: 0 0 4px var(--color-bg), 0 0 8px var(--color-bg), 0 1px 2px var(--color-bg);
}

/* ---------- Per-theme touches for the new games ---------- */
[data-theme="bubblegum"] .hive-cell polygon {
  stroke: #5a2a52;
  stroke-width: 3;
}

[data-theme="bubblegum"] .pill-btn,
[data-theme="bubblegum"] .game-card,
[data-theme="bubblegum"] .bee-found {
  border: 2.5px solid #5a2a52;
  box-shadow: 0 3px 0 #5a2a52;
}

[data-theme="terminal"] .pill-btn,
[data-theme="terminal"] .game-card,
[data-theme="terminal"] .bee-found,
[data-theme="terminal"] .bee-found-panel {
  border-radius: 0;
  border-color: #1a661a;
}

[data-theme="terminal"] .hive-cell:not(.center) polygon {
  stroke: #1f8f1f;
  stroke-width: 1.5;
}

[data-theme="art-deco"] .pill-btn,
[data-theme="art-deco"] .game-card,
[data-theme="art-deco"] .bee-found,
[data-theme="art-deco"] .bee-found-panel {
  border-radius: 0;
  border-color: #6b5a2a;
}

[data-theme="art-deco"] .hive-cell:not(.center) polygon,
[data-theme="forest"] .hive-cell:not(.center) polygon,
[data-theme="halloween"] .hive-cell:not(.center) polygon {
  stroke: var(--color-border-strong);
  stroke-width: 1.2;
}

[data-theme="forest"] .hive-cell:not(.center) polygon {
  stroke: #2a5566;
}

[data-theme="forest"] .hive-cell.center polygon,
[data-theme="forest"] .box-line {
  filter: drop-shadow(0 0 6px rgba(242, 54, 193, 0.7));
}

[data-theme="halloween"] .hive-cell:not(.center) polygon {
  stroke: #5a3f99;
}

[data-theme="halloween"] .hive-cell.center polygon,
[data-theme="halloween"] .box-line {
  filter: drop-shadow(0 0 6px rgba(255, 150, 40, 0.7));
}

[data-theme="sunset"] .hive-cell:not(.center) polygon {
  stroke: #2f5072;
  stroke-width: 1.2;
}

[data-theme="sunset"] .box-line {
  filter: drop-shadow(0 0 5px rgba(240, 100, 58, 0.7));
  opacity: 0.85;
}

/* ---------- Connections ---------- */
/* Group colors are the game's signature, so they stay the same in every
   theme (dark text on all four). */
:root {
  --conn-t0: #f9df6d;
  --conn-t1: #a0c35a;
  --conn-t2: #b0c4ef;
  --conn-t3: #ba81c5;
  --conn-on: #121213;
}

.conn-main {
  justify-content: flex-start;
}

.conn-game {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.conn-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 1.4rem;
}

.conn-label {
  font-size: 0.9rem;
  color: var(--color-text);
}

/* Tile height scales with the viewport so the whole board, mistakes, and
   buttons fit without scrolling, even with the browser toolbar at the
   bottom of the screen. */
.conn-board {
  --conn-row: clamp(46px, calc((100dvh - 330px) / 4), 80px);
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: var(--conn-row);
  gap: 8px;
  container-type: inline-size;
}

.conn-tile {
  min-width: 0;
  border: none;
  border-radius: 8px;
  background: var(--color-key-bg);
  color: var(--color-key-text);
  font-family: inherit;
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1.1;
  padding: 0 3px;
  cursor: pointer;
  user-select: none;
  overflow-wrap: anywhere;
  /* Each tile is ~a quarter of the board; shrink long words to fit. */
  font-size: min(1.05rem, calc((25cqi - 14px) / (var(--len, 6) * 0.82)));
  transition: background-color 0.12s ease, color 0.12s ease, transform 0.1s ease;
}

.conn-tile:active {
  transform: scale(0.96);
}

.conn-tile.selected {
  background: var(--color-text);
  color: var(--color-bg);
}

.conn-tile.shake {
  animation: game-shake 0.4s ease;
}

.conn-group {
  grid-column: 1 / -1;
  border-radius: 8px;
  color: var(--conn-on);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.2rem 0.5rem;
  min-height: 0;
  overflow: hidden;
}

.conn-answers .conn-group {
  min-height: 3.6rem;
  margin-bottom: 8px;
}

.conn-group-name {
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.95rem;
}

.conn-group-words {
  font-size: 0.85rem;
  text-transform: uppercase;
}

.conn-group.t0, .conn-sq.t0, .conn-sw.t0 { background: var(--conn-t0); }
.conn-group.t1, .conn-sq.t1, .conn-sw.t1 { background: var(--conn-t1); }
.conn-group.t2, .conn-sq.t2, .conn-sw.t2 { background: var(--conn-t2); }
.conn-group.t3, .conn-sq.t3, .conn-sw.t3 { background: var(--conn-t3); }

.conn-group.pop {
  animation: conn-pop 0.35s ease;
}

.conn-group.revealed {
  animation: conn-pop 0.35s ease both;
}

.conn-group.revealed:nth-child(2) { animation-delay: 0.15s; }
.conn-group.revealed:nth-child(3) { animation-delay: 0.3s; }
.conn-group.revealed:nth-child(4) { animation-delay: 0.45s; }

@keyframes conn-pop {
  0% { transform: scale(0.94); opacity: 0.4; }
  60% { transform: scale(1.02); opacity: 1; }
  100% { transform: scale(1); }
}

.conn-mistakes {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: var(--color-text);
}

.conn-dots {
  display: inline-flex;
  gap: 0.45rem;
}

.conn-dot {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: var(--color-text);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.conn-dot.used {
  transform: scale(0);
  opacity: 0;
}

.conn-controls .pill-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.conn-submit:not(:disabled) {
  background: var(--color-text);
  color: var(--color-bg);
  border-color: var(--color-text);
}

.conn-label,
.conn-mistakes {
  text-shadow: 0 0 4px var(--color-bg), 0 0 8px var(--color-bg), 0 1px 2px var(--color-bg);
}

.conn-share-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 0.5rem 0 1rem;
}

.conn-share-row {
  display: flex;
  gap: 4px;
}

.conn-sq {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 4px;
}

.conn-legend {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--color-text-dim);
}

.conn-sw {
  display: inline-block;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 3px;
}

#share-btn {
  margin-bottom: 0.5rem;
}

@media (max-height: 700px) {
  .conn-game {
    gap: 0.4rem;
  }
  .conn-board {
    --conn-row: clamp(42px, calc((100dvh - 290px) / 4), 80px);
    gap: 6px;
  }
  .conn-group-name {
    font-size: 0.85rem;
  }
  .conn-group-words {
    font-size: 0.75rem;
  }
}

/* Menu icon: four colored rows. */
.icon-connections {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  align-items: stretch;
  justify-items: stretch;
  gap: 3px;
  padding: 0.45rem;
}

.icon-connections .c {
  border-radius: 3px;
  background: var(--color-key-bg);
}

.icon-connections .c.bar {
  grid-column: 1 / -1;
}

.icon-connections .c.t0 {
  background: var(--conn-t0);
}

/* ---------- Crosswords (Mini Crossy, Midi Crossy & Crossy) ---------- */
.icon-mini svg,
.icon-midi svg,
.icon-crossword svg {
  width: 100%;
  height: 100%;
  display: block;
}

.cw-size-nav a.len-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cw-clue-len {
  opacity: 0.72;
  font-weight: 700;
  font-size: 0.85em;
}

.cw-main {
  justify-content: flex-start;
  overflow-y: auto;
}

.cw-game {
  width: 100%;
  max-width: 840px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.cw-keyboard-wrap {
  width: 100%;
  max-width: 500px;
  padding-top: 0.25rem;
}

.cw-top {
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 1.3rem;
}

.cw-byline {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 0 4px var(--color-bg), 0 0 8px var(--color-bg), 0 1px 2px var(--color-bg);
}

.cw-layout {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.cw-board-col {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}

.cw-board {
  --cw-size: min(86vw, 310px, calc(100dvh - 380px));
  width: var(--cw-size);
  height: var(--cw-size);
  display: grid;
  grid-template-columns: repeat(var(--cw-cols, 5), minmax(0, 1fr));
  grid-template-rows: repeat(var(--cw-rows, 5), minmax(0, 1fr));
  gap: 2px;
  padding: 3px;
  background: #09090a;
  border: 2.5px solid var(--color-border-strong);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.24);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.cw-board.cw-midi {
  --cw-size: min(92vw, 355px, calc(100dvh - 395px));
  gap: 1.5px;
  padding: 2.5px;
}

.cw-board.cw-large {
  --cw-size: min(94vw, 385px, calc(100dvh - 415px));
  gap: 1.5px;
  padding: 2.5px;
}

.cw-answers-board {
  --cw-size: min(78vw, 280px);
  margin: 0.5rem auto;
}

.cw-answers-board.cw-large {
  --cw-size: min(84vw, 380px);
}

.cw-cell {
  position: relative;
  background: color-mix(in srgb, var(--color-key-bg) 52%, var(--color-surface));
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 2px;
}

[data-theme="light"] .cw-cell,
[data-theme="bubblegum-3d"] .cw-cell {
  background: #ffffff;
}

.cw-cell.block {
  background: #09090a;
  cursor: default;
  border-radius: 1px;
}

[data-theme="light"] .cw-board,
[data-theme="light"] .cw-cell.block {
  background: #1a1a1b;
}

[data-theme="oled"] .cw-board {
  background: #33333a;
  border-color: #3d3d42;
}

[data-theme="oled"] .cw-cell {
  background: #1c1c22;
}

[data-theme="oled"] .cw-cell.block {
  background: #000000;
}

.cw-cell.in-word {
  background: color-mix(in srgb, var(--bee-center, var(--color-present)) 42%, var(--color-surface));
}

.cw-cell.active {
  background: var(--bee-center, var(--color-present));
  color: var(--bee-center-text, var(--key-text-on-color));
}

.cw-cell.solved {
  background: var(--color-correct);
  color: var(--key-text-on-color);
}

.cw-num {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  opacity: 0.78;
  pointer-events: none;
}

.cw-midi .cw-num {
  font-size: 0.5rem;
  top: 1px;
  left: 1.5px;
}

.cw-large .cw-num {
  font-size: 0.44rem;
  top: 0.5px;
  left: 1px;
}

.cw-letter {
  font-weight: 800;
  font-size: 1.35rem;
  line-height: 1;
  text-transform: uppercase;
  margin-top: 0.12rem;
}

.cw-midi .cw-letter {
  font-size: clamp(0.82rem, 3.2vw, 1.1rem);
  margin-top: 0.1rem;
}

.cw-large .cw-letter {
  font-size: clamp(0.62rem, 2.5vw, 0.95rem);
  margin-top: 0.1rem;
}

/* Corner marker for hinted/revealed cells */
.cw-cell.hinted::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-style: solid;
  border-width: 0 7px 7px 0;
  border-color: transparent var(--color-accent) transparent transparent;
}

/* Diagonal slash for checked wrong letters */
.cw-cell.wrong .cw-letter {
  color: var(--color-danger);
  text-decoration: line-through;
}

.cw-clue-nav {
  width: 100%;
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
}

.cw-nav-btn {
  flex-shrink: 0;
  width: 2.2rem;
  border: 1px solid var(--color-border-strong);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 1.35rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cw-nav-btn:active {
  filter: brightness(0.85);
}

.cw-clue-bar {
  flex: 1;
  min-width: 0;
  min-height: 2.65rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--color-border-strong);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.cw-clue-badge {
  flex-shrink: 0;
  padding: 0.15rem 0.4rem;
  border-radius: 5px;
  background: var(--bee-center, var(--color-present));
  color: var(--bee-center-text, var(--key-text-on-color));
  font-weight: 800;
  font-size: 0.78rem;
}

.cw-clue-text {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.25;
}

.cw-controls {
  gap: 0.45rem;
  flex-wrap: wrap;
}

.cw-controls .pill-btn {
  padding: 0.42rem 0.75rem;
  min-width: 0;
  font-size: 0.8rem;
}

.cw-clues-panel {
  display: none;
}

@media (min-width: 780px) {
  .cw-top {
    max-width: 820px;
  }
  .cw-layout {
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    gap: 1.25rem;
  }
  .cw-clues-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    flex: 1;
    max-width: 390px;
    max-height: min(495px, calc(100dvh - 285px));
  }
  .cw-clue-col {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.5rem;
  }
  .cw-clue-col h3 {
    margin: 0 0 0.35rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-dim);
  }
  .cw-clue-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1;
  }
  .cw-clue-item {
    padding: 0.3rem 0.4rem;
    border-radius: 5px;
    font-size: 0.8rem;
    line-height: 1.25;
    cursor: pointer;
    margin-bottom: 2px;
  }
  .cw-clue-item.done {
    color: var(--color-text-dim);
    text-decoration: line-through;
  }
  .cw-clue-item.active {
    background: var(--bee-center, var(--color-present));
    color: var(--bee-center-text, var(--key-text-on-color));
    font-weight: 700;
    text-decoration: none;
  }
  .cw-clue-item-num {
    font-weight: 800;
  }
}

@media (max-height: 700px) {
  .cw-game {
    gap: 0.25rem;
  }
  .cw-board-col {
    gap: 0.3rem;
  }
  .cw-board {
    --cw-size: min(82vw, 270px, calc(100dvh - 335px));
  }
  .cw-board.cw-large {
    --cw-size: min(92vw, 370px, calc(100dvh - 325px));
  }
  .cw-clue-bar {
    min-height: 2.25rem;
    padding: 0.25rem 0.5rem;
  }
  .cw-clue-text {
    font-size: 0.8rem;
  }
  .cw-controls .pill-btn {
    padding: 0.32rem 0.65rem;
    font-size: 0.75rem;
  }
}

/* ---------- Daily Archive (Missed Days) ---------- */
.archive-btn.is-past {
  background: color-mix(in srgb, var(--color-accent) 22%, var(--color-surface));
  box-shadow: 0 0 0 1.5px var(--color-accent);
}

.archive-sub {
  margin: -0.35rem 0 0.85rem;
  font-size: 0.85rem;
  color: var(--color-text-dim);
}

.archive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 0.55rem;
  max-height: 58vh;
  overflow-y: auto;
  padding: 2px;
}

.archive-day {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.3rem;
  padding: 0.6rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
  transition: transform 0.14s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.14s ease, box-shadow 0.14s ease;
}

.archive-day:hover,
.archive-day:focus-visible {
  border-color: var(--color-accent);
}

.archive-day.active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1.5px var(--color-accent);
}

.archive-day-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}

.archive-day-label {
  font-size: 0.86rem;
  font-weight: 800;
}

.archive-day-badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.1rem 0.42rem;
  border-radius: 999px;
  background: var(--color-key-bg);
  color: var(--color-key-text);
}

.archive-day.st-won .archive-day-badge {
  background: var(--color-correct);
  color: var(--key-text-on-color);
}

.archive-day.st-lost .archive-day-badge {
  background: var(--color-absent);
  color: var(--color-text);
}

.archive-day.st-progress .archive-day-badge {
  background: var(--bee-center, var(--color-present));
  color: var(--bee-center-text, var(--key-text-on-color));
}

.archive-day-meta {
  font-size: 0.72rem;
  color: var(--color-text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Tiley (/tiles) ---------- */
.icon-tiles svg {
  width: 100%;
  height: 100%;
  display: block;
}

.tiles-main {
  justify-content: flex-start;
  overflow-y: auto;
}

.tiles-game {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}

.tiles-top {
  width: 100%;
  max-width: 370px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.tiles-hud {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.tiles-stat {
  display: flex;
  align-items: baseline;
  gap: 0.32rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
}

.tiles-stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-dim);
}

.tiles-stat-val {
  font-size: 0.92rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}

#tiles-combo {
  color: var(--color-accent);
}

.tiles-board {
  --tiles-w: min(92vw, 370px, calc((100dvh - 230px) * 5 / 6));
  width: var(--tiles-w);
  aspect-ratio: 5 / 6;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(6, minmax(0, 1fr));
  gap: 7px;
  padding: 8px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--color-surface) 88%, var(--color-bg));
  border: 1.5px solid var(--color-border-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.tiles-cell {
  position: relative;
  border-radius: 10px;
  border: 1.5px solid var(--color-border-strong);
  background: color-mix(in srgb, var(--color-bg) 72%, var(--color-surface));
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: transform 0.14s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.14s ease, box-shadow 0.14s ease, opacity 0.2s ease;
}

.tiles-cell svg {
  width: 88%;
  height: 88%;
  display: block;
}

.tiles-cell.selected {
  border-color: var(--bee-center, var(--color-present));
  box-shadow: 0 0 0 2px var(--bee-center, var(--color-present)), 0 4px 12px rgba(0, 0, 0, 0.28);
  transform: scale(1.04);
  z-index: 2;
}

.tiles-cell.empty {
  background: color-mix(in srgb, var(--color-bg) 45%, transparent);
  border-style: dashed;
  border-color: color-mix(in srgb, var(--color-border) 55%, transparent);
  cursor: default;
}

.tiles-cell.selected-empty {
  border-style: dashed;
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 14%, var(--color-bg));
  box-shadow: 0 0 0 1.5px var(--color-accent);
}

.tiles-hop {
  font-size: 0.56rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-accent);
  text-align: center;
  line-height: 1.1;
  padding: 0 2px;
}

/* ---------- Sudoky (/sudoku) ---------- */
.icon-sudoku svg {
  width: 100%;
  height: 100%;
  display: block;
}

.sudoku-main {
  justify-content: flex-start;
  overflow-y: auto;
}

.sudoku-game {
  width: 100%;
  max-width: 430px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.sudoku-top {
  width: 100%;
  max-width: 378px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 1.35rem;
}

.sudoku-meta-label {
  font-size: 0.84rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-dim);
  text-shadow: 0 0 4px var(--color-bg), 0 0 8px var(--color-bg), 0 1px 2px var(--color-bg);
}

.sudoku-board {
  --su-size: min(92vw, 378px, calc(100dvh - 310px));
  width: var(--su-size);
  height: var(--su-size);
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
  background: var(--color-border-strong);
  border: 2.5px solid var(--color-text);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.sudoku-cell {
  position: relative;
  border: none;
  border-right: 1px solid var(--color-border-strong);
  border-bottom: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-accent);
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  transition: background-color 0.1s ease, color 0.1s ease;
}

.sudoku-cell:nth-child(9n) {
  border-right: none;
}

.sudoku-cell:nth-child(n + 73) {
  border-bottom: none;
}

.sudoku-cell.box-right {
  border-right: 2.5px solid var(--color-text);
}

.sudoku-cell.box-bottom {
  border-bottom: 2.5px solid var(--color-text);
}

.sudoku-cell.given {
  color: var(--color-text);
}

.sudoku-cell.peer {
  background: color-mix(in srgb, var(--color-key-bg) 28%, var(--color-surface));
}

.sudoku-cell.same-digit {
  background: color-mix(in srgb, var(--color-correct) 38%, var(--color-surface));
}

.sudoku-cell.selected {
  background: var(--bee-center, var(--color-present));
  color: var(--bee-center-text, var(--key-text-on-color));
}

.sudoku-cell.conflict {
  background: color-mix(in srgb, var(--color-danger) 26%, var(--color-surface));
  color: var(--color-danger);
}

.sudoku-cell.selected.conflict {
  background: var(--color-danger);
  color: #ffffff;
}

.sudoku-cell.solved {
  background: color-mix(in srgb, var(--color-correct) 22%, var(--color-surface));
}

.sudoku-cell.hinted::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-style: solid;
  border-width: 0 7px 7px 0;
  border-color: transparent var(--color-accent) transparent transparent;
}

.sudoku-val {
  font-size: clamp(1rem, 4.2vw, 1.38rem);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.sudoku-notes {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 1px;
  pointer-events: none;
}

.sudoku-notes span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.45rem, 1.6vw, 0.58rem);
  font-weight: 700;
  line-height: 1;
  color: var(--color-text-dim);
  font-variant-numeric: tabular-nums;
}

.sudoku-notes span.hi {
  color: var(--color-accent);
  font-weight: 900;
}

.sudoku-cell.selected .sudoku-notes span {
  color: var(--bee-center-text, var(--key-text-on-color));
}

.sudoku-tools {
  gap: 0.45rem;
  flex-wrap: wrap;
}

.sudoku-tools .pill-btn {
  padding: 0.42rem 0.78rem;
  min-width: 0;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
}

.sudoku-tools .pill-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.sudoku-tools .pill-btn.active-tool {
  background: var(--color-accent);
  color: var(--color-on-accent, #fff);
  border-color: var(--color-accent);
}

.notes-badge {
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 0.08rem 0.34rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
}

.sudoku-numpad {
  width: 100%;
  max-width: 380px;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 5px;
}

.sudoku-num-btn {
  height: 3.1rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-key-bg);
  color: var(--color-key-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  cursor: pointer;
  user-select: none;
  font-variant-numeric: tabular-nums;
}

.sudoku-num-btn .num-main {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
}

.sudoku-num-btn .num-rem {
  font-size: 0.58rem;
  font-weight: 700;
  opacity: 0.72;
  line-height: 1;
}

.sudoku-num-btn.active-digit {
  border-color: var(--bee-center, var(--color-present));
  box-shadow: 0 0 0 1.5px var(--bee-center, var(--color-present));
}

.sudoku-num-btn.completed {
  opacity: 0.36;
}

.sudoku-lb-bars {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
   justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.sudoku-lb-bars .leaderboard-tabs {
  margin-bottom: 0;
}

@media (max-height: 700px) {
  .tiles-board {
    --tiles-w: min(88vw, 330px, calc((100dvh - 210px) * 5 / 6));
    gap: 5px;
    padding: 5px;
  }
  .sudoku-board {
    --su-size: min(90vw, 330px, calc(100dvh - 285px));
  }
  .sudoku-num-btn {
    height: 2.65rem;
  }
}

/* ---------- Craft & Typography Polish ---------- */
.result-stat-value,
.lb-table td,
.cw-num,
.result-countdown {
  font-variant-numeric: tabular-nums;
}

.modal h2,
.name-gate h2,
.cw-clue-text,
.menu-greeting,
.menu-foot,
.game-desc,
.archive-sub {
  text-wrap: balance;
}

.game-card {
  border-radius: 14px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12), 0 8px 20px rgba(0, 0, 0, 0.14);
}

.modal {
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.38), 0 2px 8px rgba(0, 0, 0, 0.2);
}

@media (prefers-reduced-motion: no-preference) {
  .pill-btn,
  .primary-btn,
  .key,
  .sudoku-num-btn,
  .cw-nav-btn,
  .icon-btn {
    transition: transform 0.14s cubic-bezier(0.22, 1, 0.36, 1), filter 0.14s ease, background-color 0.14s ease;
  }
  .pill-btn:active:not(:disabled),
  .primary-btn:active:not(:disabled),
  .key:active,
  .sudoku-num-btn:active,
  .cw-nav-btn:active,
  .archive-day:active {
    transform: scale(0.96);
  }
}

[data-theme="terminal"] .tiles-board,
[data-theme="terminal"] .tiles-cell,
[data-theme="terminal"] .sudoku-board,
[data-theme="terminal"] .sudoku-num-btn,
[data-theme="terminal"] .archive-day,
[data-theme="art-deco"] .tiles-board,
[data-theme="art-deco"] .tiles-cell,
[data-theme="art-deco"] .sudoku-board,
[data-theme="art-deco"] .sudoku-num-btn,
[data-theme="art-deco"] .archive-day {
  border-radius: 0;
}

[data-theme="bubblegum"] .tiles-board,
[data-theme="bubblegum"] .sudoku-board,
[data-theme="bubblegum"] .sudoku-num-btn,
[data-theme="bubblegum"] .archive-day {
  border: 2.5px solid #5a2a52;
  box-shadow: 0 3px 0 #5a2a52;
}

/* ---------- Phone-First Touch & Anti-Zoom ---------- */
html,
body {
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  user-select: none;
  -webkit-user-select: none;
}

button,
a,
.key,
.tile,
.cw-cell,
.tiles-cell,
.sudoku-cell,
.strands-cell,
.conn-tile,
.bee-cell {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

input[type="text"],
input[type="password"],
input[type="search"],
textarea {
  font-size: 16px !important;
  user-select: text;
  -webkit-user-select: text;
}

/* ---------- Wordly Hard Mode Button ---------- */
.hard-mode-btn {
  width: auto;
  height: 1.7rem;
  min-width: 2.75rem;
  padding: 0 0.45rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}

.hard-mode-btn[aria-pressed="true"] {
  background: var(--color-present);
  border-color: var(--color-present);
  color: var(--key-text-on-color, #fff);
}

/* ---------- Cross-Device Profile Sync & Backup ---------- */
.profile-sync-box {
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.profile-sync-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-dim);
}

.profile-sync-row {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.profile-sync-btn {
  flex: 1 1 auto;
  padding: 0.44rem 0.65rem;
  min-width: 0;
  font-size: 0.76rem;
}

/* ---------- Strandy (Daily 6×8 Word Trail) ---------- */
.icon-strands .strands-path-blue {
  stroke: #4a90d9;
}

.icon-strands .strands-path-gold {
  stroke: var(--color-present);
}

.icon-strands .strands-dot-blue {
  fill: #4a90d9;
}

.icon-strands .strands-dot-gold {
  fill: var(--color-present);
}

.icon-strands .strands-dot-idle {
  fill: var(--color-absent);
}

.strands-main {
  flex: 1 1 auto;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 0.35rem 0.75rem calc(0.6rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
  overflow-y: auto;
}

.strands-game {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.38rem;
}

.strands-top {
  width: 100%;
  max-width: 390px;
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.strands-theme-box {
  flex: 1 1 auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: 10px;
  padding: 0.42rem 0.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: left;
}

.strands-theme-label {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #4a90d9;
  text-transform: uppercase;
}

.strands-theme-clue {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1.2;
}

.strands-meta-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  gap: 0.15rem;
  flex-shrink: 0;
}

.strands-progress {
  margin: 0;
  font-size: 0.76rem;
  color: var(--color-text-dim);
  white-space: nowrap;
}

.strands-progress strong {
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.strands-current {
  min-height: 1.75rem;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.strands-board-wrap {
  --st-w: min(88vw, 340px, calc((100dvh - 265px) * 6 / 8));
  width: var(--st-w);
  height: calc(var(--st-w) * 8 / 6);
  position: relative;
  user-select: none;
  touch-action: none;
}

.strands-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.strands-line {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.72;
}

.strands-line.theme {
  stroke: #3b82f6;
}

.strands-line.spangram {
  stroke: var(--color-present);
}

.strands-line.active {
  stroke: var(--color-border-strong);
  opacity: 0.9;
}

.strands-board {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  place-items: center;
  touch-action: none;
}

.strands-cell {
  width: 78%;
  height: 78%;
  border-radius: 999px;
  border: 1.5px solid transparent;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: clamp(0.95rem, 3.8vw, 1.2rem);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  user-select: none;
  touch-action: none;
  transition: transform 0.1s ease, background-color 0.12s ease, border-color 0.12s ease;
}

.strands-cell.found-theme {
  background: #2563eb;
  color: #ffffff;
}

.strands-cell.found-spangram {
  background: var(--color-present);
  color: var(--key-text-on-color, #ffffff);
}

.strands-cell.traced {
  background: var(--color-border-strong);
  color: var(--color-text);
  transform: scale(1.08);
}

.strands-cell.trace-head {
  border-color: var(--color-text);
  transform: scale(1.13);
}

.strands-cell.hinted {
  border: 2px dashed #3b82f6;
}

.strands-cell.hint-start {
  border: 2.5px solid var(--color-present);
  box-shadow: 0 0 0 2px rgba(210, 153, 34, 0.35);
}

.strands-actions,
.strands-controls {
  gap: 0.45rem;
}

.strands-actions .pill-btn,
.strands-controls .pill-btn {
  padding: 0.45rem 0.85rem;
  min-width: 4.5rem;
  font-size: 0.84rem;
}

  .strands-share-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.3rem;
  font-size: 1.35rem;
  margin: 0.4rem 0 0.75rem;
}

/* ---------- Searchy (Word Search /wordsearch) ---------- */
.icon-wordsearch svg {
  width: 100%;
  height: 100%;
  display: block;
}

.ws-main {
  flex: 1 1 auto;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 0.35rem 0.75rem calc(0.6rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  overflow-y: auto;
}

.ws-game {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.38rem;
}

.ws-top {
  width: 100%;
  max-width: 400px;
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.ws-theme-box {
  flex: 1 1 auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: 10px;
  padding: 0.38rem 0.7rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: left;
}

.ws-theme-label {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--color-correct);
  text-transform: uppercase;
}

.ws-theme-title {
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1.2;
}

.ws-meta-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  gap: 0.15rem;
  flex-shrink: 0;
}

.ws-progress {
  margin: 0;
  font-size: 0.76rem;
  color: var(--color-text-dim);
  white-space: nowrap;
}

.ws-progress strong {
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.ws-selection-preview {
  min-height: 1.45rem;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.ws-board-wrap {
  --ws-px: min(92vw, 370px, calc(100dvh - 300px));
  width: var(--ws-px);
  height: var(--ws-px);
  position: relative;
  background: var(--color-surface);
  border: 2px solid var(--color-border-strong);
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overflow: hidden;
}

.ws-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.ws-pill {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.42;
}

.ws-pill.active {
  stroke: var(--color-present);
  opacity: 0.58;
}

.ws-board {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(var(--ws-size, 10), minmax(0, 1fr));
  grid-template-rows: repeat(var(--ws-size, 10), minmax(0, 1fr));
  place-items: center;
  touch-action: none;
}

.ws-cell {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--color-text);
  font-size: clamp(0.78rem, calc(var(--ws-px) / var(--ws-size, 10) * 0.48), 1.18rem);
  font-weight: 800;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  user-select: none;
  touch-action: none;
  border-radius: 6px;
  transition: transform 0.08s ease;
}

.ws-cell.active {
  color: var(--color-text);
  transform: scale(1.14);
}

.ws-cell.hint-start {
  outline: 2.5px dashed var(--color-present);
  outline-offset: -3px;
  background: color-mix(in srgb, var(--color-present) 22%, transparent);
}

.ws-wordlist {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.15rem 0;
}

.ws-word-chip {
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  border: 1.5px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.ws-word-chip.found {
  background: color-mix(in srgb, var(--ws-chip-color, var(--color-correct)) 24%, var(--color-surface));
  border-color: var(--ws-chip-color, var(--color-correct));
  color: var(--color-text-dim);
  text-decoration: line-through;
  opacity: 0.72;
}

.ws-word-chip.hinted {
  border-color: var(--color-present);
  box-shadow: 0 0 0 1.5px var(--color-present);
}

.ws-controls {
  gap: 0.45rem;
}

.ws-controls .pill-btn {
  padding: 0.42rem 0.85rem;
  min-width: 4.5rem;
  font-size: 0.82rem;
}

/* ---------- Mobile Viewport Compact Optimizations ---------- */
@media (max-width: 520px) {
  .app-header {
    padding: 0.25rem 0.5rem;
  }
  .header-row.title-row {
    min-height: 2.1rem;
  }
  .app-title {
    font-size: 1.15rem;
  }
  .menu-main {
    padding: 0.55rem 0.7rem calc(0.75rem + env(safe-area-inset-bottom));
    gap: 0.5rem;
  }
  .game-card {
    padding: 0.68rem 0.82rem;
    gap: 0.78rem;
  }
  .game-icon {
    width: 3.55rem;
    height: 3.55rem;
  }
  .game-name {
    font-size: 1rem;
  }
  .game-desc {
    font-size: 0.78rem;
  }
  .game-status {
    font-size: 0.74rem;
  }
  .cw-key-row .key {
    height: 2.65rem;
    font-size: 0.86rem;
  }
  .controls-row {
    gap: 0.24rem;
    flex-wrap: nowrap;
  }
  .mode-btn,
  .len-btn {
    padding: 0.24rem 0.48rem;
    font-size: 0.68rem;
  }
  .controls-row .icon-btn {
    width: 1.72rem;
    height: 1.72rem;
    font-size: 0.96rem;
  }
}

