:root {
  --menu-width: 260px;
  --menu-zoom: 1;
}

/* Shared puzzle controls: keep the legacy games visually and behaviorally aligned
   with the Lispenard Street menu. */
#wordMenu {
  width: min(var(--menu-width), calc(100vw - 16px));
  min-width: 0;
  max-width: calc(100vw - 16px);
  max-height: min(70vh, calc(100dvh - 16px));
  overflow: visible;
  box-sizing: border-box;
  background: rgba(0, 0, 0, .82);
  font-size: calc(1rem * var(--menu-zoom));
}

#menuHeader {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 0;
  border-bottom: 0;
  touch-action: none;
}

#menuHeader > .title:first-child {
  flex: 0 0 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

#menuHeader .title,
#menuHeader .right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin: 8px;
  white-space: nowrap;
}

#menuHeader .right,
#menuHeader .title:last-child {
  flex: 0 0 auto;
  align-self: stretch;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 0;
  overflow: visible;
}

#menuHeader > .title.title--compact { font-size: .88em; }

#menuHeader > .title.title--wrap {
  align-self: stretch;
  white-space: normal;
  line-height: 1.05;
  overflow: visible;
  text-overflow: clip;
}

.info-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.info-wrapper .info-btn { touch-action: manipulation; }

.info-wrapper .tooltip {
  top: calc(100% + 6px);
  left: calc(100% + 6px);
  right: auto;
  width: auto;
  min-width: 180px;
  max-width: min(320px, 80vw);
  margin-top: 0;
  padding: 8px 10px;
  box-sizing: border-box;
  background: rgba(0, 0, 0, .92);
  color: #fff;
  font-size: inherit;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease, visibility .18s ease;
  z-index: 9999;
}

.info-wrapper .tooltip.help-tooltip {
  width: max-content;
  min-width: 240px;
  max-width: min(380px, 80vw);
}

.info-wrapper:hover .tooltip,
.info-wrapper:focus-within .tooltip,
.info-wrapper.active .tooltip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.info-btn,
.menu-btn,
#toggleMenu {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  min-width: 16px;
  height: 16px;
  padding: 0;
  margin-right: 4px;
  border: 0;
  border-radius: 50%;
  background: #ccc;
  color: #000;
  font-size: calc(11px * var(--menu-zoom));
  line-height: 16px;
  text-decoration: none;
  cursor: pointer;
}

.menu-btn { font-size: calc(9px * var(--menu-zoom)); }

.menu-font-controls {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  margin-right: auto;
  gap: 3px;
  font-size: .72em;
}

.menu-font-label {
  white-space: nowrap;
}

.menu-font-controls button {
  width: 18px;
  min-width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid #aaa;
  border-radius: 3px;
  background: #eee;
  color: #000;
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

#wordList {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: inherit;
}

#wordMenu > button,
#wordMenu > select {
  width: 100%;
  border: 0;
  border-top: 1px solid #fff;
  background: rgba(0, 0, 0, .42);
  color: #fff;
  padding: 8px;
  /* Override legacy fixed sizes so every text-based menu control follows
     --menu-zoom through the menu's inherited font size. */
  font: inherit !important;
  cursor: pointer;
}

#mobileMenuOptions,
#mobileMenuOptions label,
#mobileMenuOptions input,
#mobileMenuOptions select,
#mobileMenuOptions option,
#wordTooltip,
#menuHeader .tooltip {
  font-size: inherit !important;
}

#wordMenu.collapsed {
  width: min(var(--menu-width), calc(100vw - 16px));
  height: auto !important;
  max-height: calc(100dvh - 16px);
}

/* Minimize only the checklist; keep the menu controls available. */
#wordMenu.collapsed > #wordList { display: none !important; }
#mobileMenuOptions { display: none !important; }
#wordMenu.mobile-pinned,
#wordMenu.pinned-bottom-collapsed,
#wordMenu.pinned-top-left,
#wordMenu.pinned-top-right {
  right: auto !important;
  bottom: auto !important;
}

@media (max-width: 900px) and (any-pointer: coarse) {
  #wordMenu {
    top: 8px;
    left: 8px;
    width: min(500px, calc(100vw - 16px));
    font-size: calc(1rem * var(--menu-zoom));
  }
}
